window.Laya=function(d){"use strict";class Dt{}Dt.animationInterval=50,Dt.isAntialias=!0,Dt.isAlpha=!1,Dt.premultipliedAlpha=!0,Dt.isStencil=!0,Dt.preserveDrawingBuffer=!1,Dt.webGL2D_MeshAllocMaxMem=!0,Dt.is2DPixelArtGame=!1,Dt.useWebGL2=!0,Dt.printWebglOrder=!1,Dt.allowGPUInstanceDynamicBatch=!0,Dt.enableStaticBatch=!0,Dt.useRetinalCanvas=!1,window.Config=Dt;class c{static regClass(t){c.__classMap[t.name]=t}}c.Laya=null,c.Timer=null,c.WorkerLoader=null,c.Dragging=null,c.GraphicsBounds=null,c.Sprite=null,c.TextRender=null,c.TextAtlas=null,c.timer=null,c.systemTimer=null,c.startTimer=null,c.updateTimer=null,c.lateTimer=null,c.physicsTimer=null,c.stage=null,c.Loader=null,c.loader=null,c.TTFLoader=null,c.SoundManager=null,c.WebAudioSound=null,c.AudioSound=null,c.ShaderCompile=null,c.ClassUtils=null,c.SceneUtils=null,c.Context=null,c.Render=null,c.MouseManager=null,c.Text=null,c.Browser=null,c.WebGL=null,c.Pool=null,c.Utils=null,c.Graphics=null,c.Submit=null,c.Stage=null,c.Resource=null,c.__classMap={};class D{static getPoolBySign(t){return D._poolDic[t]||(D._poolDic[t]=[])}static clearBySign(t){D._poolDic[t]&&(D._poolDic[t].length=0)}static recover(t,e){e[D.POOLSIGN]||(e[D.POOLSIGN]=!0,D.getPoolBySign(t).push(e))}static recoverByClass(t){if(t){var e=t.__className||t.constructor._$gid;e&&D.recover(e,t)}}static _getClassSign(t){var e=t.__className||t._$gid;return e||(t._$gid=e=D._CLSID+"",D._CLSID++),e}static createByClass(t){return D.getItemByClass(D._getClassSign(t),t)}static getItemByClass(t,e){if(!D._poolDic[t])return new e;var i=D.getPoolBySign(t);if(i.length){var s=i.pop();s[D.POOLSIGN]=!1}else s=new e;return s}static getItemByCreateFun(t,e,i=null){var s=D.getPoolBySign(t),r=s.length?s.pop():e.call(i);return r[D.POOLSIGN]=!1,r}static getItem(t){var e=D.getPoolBySign(t),i=e.length?e.pop():null;return i&&(i[D.POOLSIGN]=!1),i}}D._CLSID=0,D.POOLSIGN="__InPool",D._poolDic={};class $e{static create(t){var e=D.getItemByClass("AlphaCmd",$e);return e.alpha=t,e}recover(){D.recover("AlphaCmd",this)}run(t,e,i){t.alpha(this.alpha)}get cmdID(){return $e.ID}}$e.ID="Alpha";class Je{static create(t,e,i,s,r,a,n){var h=D.getItemByClass("DrawCircleCmd",Je);return h.x=t,h.y=e,h.radius=i,h.fillColor=s,h.lineColor=r,h.lineWidth=a,h.vid=n,h}recover(){this.fillColor=null,this.lineColor=null,D.recover("DrawCircleCmd",this)}run(t,e,i){t._drawCircle(this.x+e,this.y+i,this.radius,this.fillColor,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return Je.ID}}Je.ID="DrawCircle";class ti{static create(t,e,i,s,r){var a=D.getItemByClass("DrawCurvesCmd",ti);return a.x=t,a.y=e,a.points=i,a.lineColor=s,a.lineWidth=r,a}recover(){this.points=null,this.lineColor=null,D.recover("DrawCurvesCmd",this)}run(t,e,i){this.points&&t.drawCurves(this.x+e,this.y+i,this.points,this.lineColor,this.lineWidth)}get cmdID(){return ti.ID}}ti.ID="DrawCurves";class He{static create(t,e,i,s,r){var a=D.getItemByClass("DrawImageCmd",He);return a.texture=t,t._addReference(),a.x=e,a.y=i,a.width=s,a.height=r,a}recover(){this.texture&&this.texture._removeReference(),this.texture=null,D.recover("DrawImageCmd",this)}run(t,e,i){this.texture&&t.drawTexture(this.texture,this.x+e,this.y+i,this.width,this.height)}get cmdID(){return He.ID}}He.ID="DrawImage";class ei{static create(t,e,i,s,r,a,n){var h=D.getItemByClass("DrawLineCmd",ei);return h.fromX=t,h.fromY=e,h.toX=i,h.toY=s,h.lineColor=r,h.lineWidth=a,h.vid=n,h}recover(){D.recover("DrawLineCmd",this)}run(t,e,i){t._drawLine(e,i,this.fromX,this.fromY,this.toX,this.toY,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return ei.ID}}ei.ID="DrawLine";class ii{static create(t,e,i,s,r,a){var n=D.getItemByClass("DrawLinesCmd",ii);return n.x=t,n.y=e,n.points=i,n.lineColor=s,n.lineWidth=r,n.vid=a,n}recover(){this.points=null,this.lineColor=null,D.recover("DrawLinesCmd",this)}run(t,e,i){this.points&&t._drawLines(this.x+e,this.y+i,this.points,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return ii.ID}}ii.ID="DrawLines";class si{static create(t,e,i,s,r){var a=D.getItemByClass("DrawPathCmd",si);return a.x=t,a.y=e,a.paths=i,a.brush=s,a.pen=r,a}recover(){this.paths=null,this.brush=null,this.pen=null,D.recover("DrawPathCmd",this)}run(t,e,i){this.paths&&t._drawPath(this.x+e,this.y+i,this.paths,this.brush,this.pen)}get cmdID(){return si.ID}}si.ID="DrawPath";class ri{static create(t,e,i,s,r,a,n,h,o){var l=D.getItemByClass("DrawPieCmd",ri);return l.x=t,l.y=e,l.radius=i,l._startAngle=s,l._endAngle=r,l.fillColor=a,l.lineColor=n,l.lineWidth=h,l.vid=o,l}recover(){this.fillColor=null,this.lineColor=null,D.recover("DrawPieCmd",this)}run(t,e,i){t._drawPie(this.x+e,this.y+i,this.radius,this._startAngle,this._endAngle,this.fillColor,this.lineColor,this.lineWidth,this.vid)}get cmdID(){return ri.ID}get startAngle(){return this._startAngle*180/Math.PI}set startAngle(t){this._startAngle=t*Math.PI/180}get endAngle(){return this._endAngle*180/Math.PI}set endAngle(t){this._endAngle=t*Math.PI/180}}ri.ID="DrawPie";class ai{static create(t,e,i,s,r,a,n,h){var o=D.getItemByClass("DrawPolyCmd",ai);return o.x=t,o.y=e,o.points=i,o.fillColor=s,o.lineColor=r,o.lineWidth=a,o.isConvexPolygon=n,o.vid=h,o}recover(){this.points=null,this.fillColor=null,this.lineColor=null,D.recover("DrawPolyCmd",this)}run(t,e,i){this.points&&t._drawPoly(this.x+e,this.y+i,this.points,this.fillColor,this.lineColor,this.lineWidth,this.isConvexPolygon,this.vid)}get cmdID(){return ai.ID}}ai.ID="DrawPoly";class ni{static create(t,e,i,s,r,a,n){var h=D.getItemByClass("DrawRectCmd",ni);return h.x=t,h.y=e,h.width=i,h.height=s,h.fillColor=r,h.lineColor=a,h.lineWidth=n,h}recover(){this.fillColor=null,this.lineColor=null,D.recover("DrawRectCmd",this)}run(t,e,i){t.drawRect(this.x+e,this.y+i,this.width,this.height,this.fillColor,this.lineColor,this.lineWidth)}get cmdID(){return ni.ID}}ni.ID="DrawRect";class et{constructor(t=1,e=0,i=0,s=1,r=0,a=0,n=0){if(this._bTransform=!1,et._createFun!=null)return et._createFun(t,e,i,s,r,a,n);this.a=t,this.b=e,this.c=i,this.d=s,this.tx=r,this.ty=a,this._checkTransform()}identity(){return this.a=this.d=1,this.b=this.tx=this.ty=this.c=0,this._bTransform=!1,this}_checkTransform(){return this._bTransform=this.a!==1||this.b!==0||this.c!==0||this.d!==1}setTranslate(t,e){return this.tx=t,this.ty=e,this}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this._bTransform=!0,this}rotate(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,r=this.c,a=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=r*e-this.d*i,this.d=r*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this._bTransform=!0,this}skew(t,e){var i=Math.tan(t),s=Math.tan(e),r=this.a,a=this.b;return this.a+=s*this.c,this.b+=s*this.d,this.c+=i*r,this.d+=i*a,this}invertTransformPoint(t){var e=this.a,i=this.b,s=this.c,r=this.d,a=this.tx,n=e*r-i*s,h=r/n,o=-i/n,l=-s/n,u=e/n,_=(s*this.ty-r*a)/n,f=-(e*this.ty-i*a)/n;return t.setTo(h*t.x+l*t.y+_,o*t.x+u*t.y+f)}transformPoint(t){return t.setTo(this.a*t.x+this.c*t.y+this.tx,this.b*t.x+this.d*t.y+this.ty)}transformPointN(t){return t.setTo(this.a*t.x+this.c*t.y,this.b*t.x+this.d*t.y)}getScaleX(){return this.b===0?this.a:Math.sqrt(this.a*this.a+this.b*this.b)}getScaleY(){return this.c===0?this.d:Math.sqrt(this.c*this.c+this.d*this.d)}invert(){var t=this.a,e=this.b,i=this.c,s=this.d,r=this.tx,a=t*s-e*i;return this.a=s/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-s*r)/a,this.ty=-(t*this.ty-e*r)/a,this}setTo(t,e,i,s,r,a){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=r,this.ty=a,this}concat(t){var e=this.a,i=this.c,s=this.tx;return this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d,this.tx=s*t.a+this.ty*t.c+t.tx,this.ty=s*t.b+this.ty*t.d+t.ty,this}static mul(t,e,i){var s=t.a,r=t.b,a=t.c,n=t.d,h=t.tx,o=t.ty,l=e.a,u=e.b,_=e.c,f=e.d,p=e.tx,m=e.ty;return u!==0||_!==0?(i.a=s*l+r*_,i.b=s*u+r*f,i.c=a*l+n*_,i.d=a*u+n*f,i.tx=l*h+_*o+p,i.ty=u*h+f*o+m):(i.a=s*l,i.b=r*f,i.c=a*l,i.d=n*f,i.tx=l*h+p,i.ty=f*o+m),i}static mul16(t,e,i){var s=t.a,r=t.b,a=t.c,n=t.d,h=t.tx,o=t.ty,l=e.a,u=e.b,_=e.c,f=e.d,p=e.tx,m=e.ty;return u!==0||_!==0?(i[0]=s*l+r*_,i[1]=s*u+r*f,i[4]=a*l+n*_,i[5]=a*u+n*f,i[12]=l*h+_*o+p,i[13]=u*h+f*o+m):(i[0]=s*l,i[1]=r*f,i[4]=a*l,i[5]=n*f,i[12]=l*h+p,i[13]=f*o+m),i}scaleEx(t,e){var i=this.a,s=this.b,r=this.c,a=this.d;s!==0||r!==0?(this.a=t*i,this.b=t*s,this.c=e*r,this.d=e*a):(this.a=t*i,this.b=0*a,this.c=0*i,this.d=e*a),this._bTransform=!0}rotateEx(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,r=this.b,a=this.c,n=this.d;r!==0||a!==0?(this.a=e*s+i*a,this.b=e*r+i*n,this.c=-i*s+e*a,this.d=-i*r+e*n):(this.a=e*s,this.b=i*n,this.c=-i*s,this.d=e*n),this._bTransform=!0}clone(){var t=et.create();return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t._bTransform=this._bTransform,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t._bTransform=this._bTransform,t}toString(){return this.a+","+this.b+","+this.c+","+this.d+","+this.tx+","+this.ty}destroy(){this.recover()}recover(){D.recover("Matrix",this.identity())}static create(){return D.getItemByClass("Matrix",et)}}et.EMPTY=new et,et.TEMP=new et,et._createFun=null;class Tt{constructor(t=0,e=0){this.x=t,this.y=e}static create(){return D.getItemByClass("Point",Tt)}setTo(t,e){return this.x=t,this.y=e,this}reset(){return this.x=this.y=0,this}recover(){D.recover("Point",this.reset())}distance(t,e){return Math.sqrt((this.x-t)*(this.x-t)+(this.y-e)*(this.y-e))}toString(){return this.x+","+this.y}normalize(){var t=Math.sqrt(this.x*this.x+this.y*this.y);if(t>0){var e=1/t;this.x*=e,this.y*=e}}copy(t){return this.setTo(t.x,t.y)}}Tt.TEMP=new Tt,Tt.EMPTY=new Tt;class tt{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s}get right(){return this.x+this.width}get bottom(){return this.y+this.height}setTo(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}reset(){return this.x=this.y=this.width=this.height=0,this}recover(){if(this==tt.TEMP||this==tt.EMPTY){console.log("recover Temp or Empty:",this);return}D.recover("Rectangle",this.reset())}static create(){return D.getItemByClass("Rectangle",tt)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&ethis.x+this.width||t.x+t.widththis.y+this.height||t.y+t.heightt&&(this.width+=this.x-t,this.x=t),this.y>e&&(this.height+=this.y-e,this.y=e),this.widtho.x?a:o.x,h=h>o.y?h:o.y;return e.setTo(r,n,a-r,h-n)}isEmpty(){return this.width<=0||this.height<=0}}tt.EMPTY=new tt,tt.TEMP=new tt,tt._temB=[],tt._temA=[];class I{}I.ARRAY_BUFFER_TYPE_DATA=0,I.ARRAY_BUFFER_TYPE_CMD=1,I.ARRAY_BUFFER_REF_REFERENCE=0,I.ARRAY_BUFFER_REF_COPY=1,I.UPLOAD_SHADER_UNIFORM_TYPE_ID=0,I.UPLOAD_SHADER_UNIFORM_TYPE_DATA=1;var Hi=1,Xi=0;class A{static __init__(){var t=I.instance;A._depthFunc=t.LESS,A._blendEquation=t.FUNC_ADD,A._blendEquationRGB=t.FUNC_ADD,A._blendEquationAlpha=t.FUNC_ADD,Hi=t.ONE,Xi=t.ZERO,A._sFactorAlpha=t.ONE,A._dFactorAlpha=t.ZERO,A._activedTextureID=t.TEXTURE0;var e=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);A._activeTextures=new Array(e),A._glTextureIDs=[t.TEXTURE0,t.TEXTURE1,t.TEXTURE2,t.TEXTURE3,t.TEXTURE4,t.TEXTURE5,t.TEXTURE6,t.TEXTURE7,t.TEXTURE8,t.TEXTURE9,t.TEXTURE10,t.TEXTURE11,t.TEXTURE12,t.TEXTURE13,t.TEXTURE14,t.TEXTURE15,t.TEXTURE16,t.TEXTURE17,t.TEXTURE18,t.TEXTURE19,t.TEXTURE20,t.TEXTURE21,t.TEXTURE22,t.TEXTURE23,t.TEXTURE24,t.TEXTURE25,t.TEXTURE26,t.TEXTURE27,t.TEXTURE28,t.TEXTURE29,t.TEXTURE30,t.TEXTURE31];var i=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),s=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS);A._maxUniformFragmentVectors=Math.min(i,s)}static useProgram(t,e){return A._useProgram===e?!1:(t.useProgram(e),A._useProgram=e,!0)}static setDepthTest(t,e){e!==A._depthTest&&(A._depthTest=e,e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST))}static setDepthMask(t,e){e!==A._depthMask&&(A._depthMask=e,t.depthMask(e))}static setDepthFunc(t,e){e!==A._depthFunc&&(A._depthFunc=e,t.depthFunc(e))}static setStencilTest(t,e){e!==A._stencilTest&&(A._stencilTest=e,e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST))}static setStencilMask(t,e){e!==A._stencilMask&&(A._stencilMask=e,e?t.stencilMask(255):t.stencilMask(0))}static setStencilFunc(t,e,i){(e!=A._stencilFunc||i!=A._stencilRef)&&(A._stencilFunc=e,A._stencilRef=i,t.stencilFunc(e,i,255))}static setstencilOp(t,e,i,s){(A._stencilOp_fail!=e||A._stencilOp_zfail!=i||A._stencilOp_zpass!=s)&&(A._stencilOp_fail=e,A._stencilOp_zfail=i,A._stencilOp_zpass=s,t.stencilOp(e,i,s))}static setBlend(t,e){e!==A._blend&&(A._blend=e,e?t.enable(t.BLEND):t.disable(t.BLEND))}static setBlendEquation(t,e){e!==A._blendEquation&&(A._blendEquation=e,A._blendEquationRGB=A._blendEquationAlpha=null,t.blendEquation(e))}static setBlendEquationSeparate(t,e,i){(e!==A._blendEquationRGB||i!==A._blendEquationAlpha)&&(A._blendEquationRGB=e,A._blendEquationAlpha=i,A._blendEquation=null,t.blendEquationSeparate(e,i))}static setBlendFunc(t,e,i,s=!1){(s||e!==Hi||i!==Xi)&&(Hi=e,Xi=i,A._sFactorRGB=null,A._dFactorRGB=null,A._sFactorAlpha=null,A._dFactorAlpha=null,t.blendFunc(e,i))}static setBlendFuncSeperate(t,e,i,s,r){(e!==A._sFactorRGB||i!==A._dFactorRGB||s!==A._sFactorAlpha||r!==A._dFactorAlpha)&&(A._sFactorRGB=e,A._dFactorRGB=i,A._sFactorAlpha=s,A._dFactorAlpha=r,Hi=null,Xi=null,t.blendFuncSeparate(e,i,s,r))}static setCullFace(t,e){e!==A._cullFace&&(A._cullFace=e,e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE))}static setFrontFace(t,e){e!==A._frontFace&&(A._frontFace=e,t.frontFace(e))}static activeTexture(t,e){A._activedTextureID!==e&&(t.activeTexture(e),A._activedTextureID=e)}static bindTexture(t,e,i){A._activeTextures[A._activedTextureID-t.TEXTURE0]!==i&&(t.bindTexture(e,i),A._activeTextures[A._activedTextureID-t.TEXTURE0]=i)}static __init_native(){if(c.Render.supportWebGLPlusRendering){var t=A;t.activeTexture=t.activeTextureForNative,t.bindTexture=t.bindTextureForNative}}static useProgramForNative(t,e){return t.useProgram(e),!0}static setDepthTestForNative(t,e){e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST)}static setDepthMaskForNative(t,e){t.depthMask(e)}static setDepthFuncForNative(t,e){t.depthFunc(e)}static setBlendForNative(t,e){e?t.enable(t.BLEND):t.disable(t.BLEND)}static setBlendFuncForNative(t,e,i){t.blendFunc(e,i)}static setCullFaceForNative(t,e){e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE)}static setFrontFaceForNative(t,e){t.frontFace(e)}static activeTextureForNative(t,e){t.activeTexture(e)}static bindTextureForNative(t,e,i){t.bindTexture(e,i)}static bindVertexArrayForNative(t,e){t.bindVertexArray(e)}static getUniformMaxVector(){return A._maxUniformFragmentVectors}}A._activeTextures=new Array(1),A._useProgram=null,A._depthTest=!0,A._depthMask=!0,A._stencilTest=!1,A._blend=!1,A._cullFace=!1,A.mainContext=null;class mt{constructor(t=null,e=null,i=null,s=!1){this.once=!1,this._id=0,this.setTo(t,e,i,s)}setTo(t,e,i,s=!1){return this._id=mt._gid++,this.caller=t,this.method=e,this.args=i,this.once=s,this}run(){if(this.method==null)return null;var t=this._id,e=this.method.apply(this.caller,this.args);return this._id===t&&this.once&&this.recover(),e}runWith(t){if(this.method==null)return null;var e=this._id;if(t==null)var i=this.method.apply(this.caller,this.args);else!this.args&&!t.unshift?i=this.method.call(this.caller,t):this.args?i=this.method.apply(this.caller,this.args.concat(t)):i=this.method.apply(this.caller,t);return this._id===e&&this.once&&this.recover(),i}clear(){return this.caller=null,this.method=null,this.args=null,this}recover(){this._id>0&&(this._id=0,mt._pool.push(this.clear()))}static create(t,e,i=null,s=!0){return mt._pool.length?mt._pool.pop().setTo(t,e,i,s):new mt(t,e,i,s)}}mt._pool=[],mt._gid=1;class $t{hasListener(t){var e=this._events&&this._events[t];return!!e}event(t,e=null){if(!this._events||!this._events[t])return!1;var i=this._events[t];if(i.run)i.once&&delete this._events[t],e!=null?i.runWith(e):i.run();else{for(var s=0,r=i.length;s-1;e--)t[e]&&(t[e].recover(),t[e]=null)}isMouseEvent(t){return $t.MOUSE_EVENTS[t]||!1}}$t.MOUSE_EVENTS={rightmousedown:!0,rightmouseup:!0,rightclick:!0,mousedown:!0,mouseup:!0,mousemove:!0,mouseover:!0,mouseout:!0,click:!0,doubleclick:!0};class hi extends mt{constructor(t,e,i,s){super(t,e,i,s)}recover(){this._id>0&&(this._id=0,hi._pool.push(this.clear()))}static create(t,e,i=null,s=!0){return hi._pool.length?hi._pool.pop().setTo(t,e,i,s):new hi(t,e,i,s)}}hi._pool=[];class ${constructor(t){this._url=$.formatURL(t),this._path=$.getPath(t)}get url(){return this._url}get path(){return this._path}static set basePath(t){$._basePath=c.Laya._getUrlPath(),$._basePath=$.formatURL(t)}static get basePath(){return $._basePath}static formatURL(t){if(!t)return"null path";if(t.indexOf(":")>0)return t;$.exportSceneToJson&&(t=$.getAdptedFilePath(t)),$.customFormat!=null&&(t=$.customFormat(t));var e=t.charAt(0);if(e===".")return $._formatRelativePath($._basePath+t);if(e==="~")return $.rootPath+t.substring(1);if(e==="d"){if(t.indexOf("data:image")===0)return t}else if(e==="/")return t;return $._basePath+t}static _formatRelativePath(t){for(var e=t.split("/"),i=0,s=e.length;i0?t.substr(0,e+1):""}static getFileName(t){var e=t.lastIndexOf("/");return e>0?t.substr(e+1):t}static getAdptedFilePath(t){if(!$.exportSceneToJson||!t)return t;var e,i;i=$._adpteTypeList.length;var s;for(e=0;et&&this._resizeBuffer(this._allocated_=t),this._length=t}get length(){return this._length}_resizeBuffer(t){try{var e=new Uint8Array(t);this._u8d_!=null&&(this._u8d_.length<=t?e.set(this._u8d_):e.set(this._u8d_.subarray(0,t))),this._u8d_=e,this._d_=new DataView(e.buffer)}catch{throw"Invalid typed array length:"+t}}getString(){return this.readString()}readString(){return this._rUTF(this.getUint16())}getFloat32Array(t,e){return this.readFloat32Array(t,e)}readFloat32Array(t,e){var i=t+e;i=i>this._length?this._length:i;var s=new Float32Array(this._d_.buffer.slice(t,i));return this._pos_=i,s}getUint8Array(t,e){return this.readUint8Array(t,e)}readUint8Array(t,e){var i=t+e;i=i>this._length?this._length:i;var s=new Uint8Array(this._d_.buffer.slice(t,i));return this._pos_=i,s}getInt16Array(t,e){return this.readInt16Array(t,e)}readInt16Array(t,e){var i=t+e;i=i>this._length?this._length:i;var s=new Int16Array(this._d_.buffer.slice(t,i));return this._pos_=i,s}getFloat32(){return this.readFloat32()}readFloat32(){if(this._pos_+4>this._length)throw"getFloat32 error - Out of bounds";var t=this._d_.getFloat32(this._pos_,this._xd_);return this._pos_+=4,t}getFloat64(){return this.readFloat64()}readFloat64(){if(this._pos_+8>this._length)throw"getFloat64 error - Out of bounds";var t=this._d_.getFloat64(this._pos_,this._xd_);return this._pos_+=8,t}writeFloat32(t){this._ensureWrite(this._pos_+4),this._d_.setFloat32(this._pos_,t,this._xd_),this._pos_+=4}writeFloat64(t){this._ensureWrite(this._pos_+8),this._d_.setFloat64(this._pos_,t,this._xd_),this._pos_+=8}getInt32(){return this.readInt32()}readInt32(){if(this._pos_+4>this._length)throw"getInt32 error - Out of bounds";var t=this._d_.getInt32(this._pos_,this._xd_);return this._pos_+=4,t}getUint32(){return this.readUint32()}readUint32(){if(this._pos_+4>this._length)throw"getUint32 error - Out of bounds";var t=this._d_.getUint32(this._pos_,this._xd_);return this._pos_+=4,t}writeInt32(t){this._ensureWrite(this._pos_+4),this._d_.setInt32(this._pos_,t,this._xd_),this._pos_+=4}writeUint32(t){this._ensureWrite(this._pos_+4),this._d_.setUint32(this._pos_,t,this._xd_),this._pos_+=4}getInt16(){return this.readInt16()}readInt16(){if(this._pos_+2>this._length)throw"getInt16 error - Out of bounds";var t=this._d_.getInt16(this._pos_,this._xd_);return this._pos_+=2,t}getUint16(){return this.readUint16()}readUint16(){if(this._pos_+2>this._length)throw"getUint16 error - Out of bounds";var t=this._d_.getUint16(this._pos_,this._xd_);return this._pos_+=2,t}writeUint16(t){this._ensureWrite(this._pos_+2),this._d_.setUint16(this._pos_,t,this._xd_),this._pos_+=2}writeInt16(t){this._ensureWrite(this._pos_+2),this._d_.setInt16(this._pos_,t,this._xd_),this._pos_+=2}getUint8(){return this.readUint8()}readUint8(){if(this._pos_+1>this._length)throw"getUint8 error - Out of bounds";return this._u8d_[this._pos_++]}writeUint8(t){this._ensureWrite(this._pos_+1),this._d_.setUint8(this._pos_,t),this._pos_++}_getUInt8(t){return this._readUInt8(t)}_readUInt8(t){return this._d_.getUint8(t)}_getUint16(t){return this._readUint16(t)}_readUint16(t){return this._d_.getUint16(t,this._xd_)}_getMatrix(){return this._readMatrix()}_readMatrix(){var t=new et(this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32(),this.getFloat32());return t}_rUTF(t){var e=this._pos_+t,i,s,r,a=String.fromCharCode,n=this._u8d_,h=[],o=0;for(h.length=1e3;this._pos_=65536){const u=l-65536,_=55296|u>>10,f=56320|u&1023;h[o++]=a(_),h[o++]=a(f)}else h[o++]=a(l)}return h.length=o,h.join("")}getCustomString(t){return this.readCustomString(t)}readCustomString(t){for(var e="",i=0,s,r,a=String.fromCharCode,n=this._u8d_;t>0;)if(s=n[this._pos_],s<128)e+=a(s),this._pos_++,t--;else for(i=s-128,this._pos_++,t-=i;i>0;)s=n[this._pos_++],r=n[this._pos_++],e+=a(r<<8|s),i--;return e}get pos(){return this._pos_}set pos(t){this._pos_=t}get bytesAvailable(){return this._length-this._pos_}clear(){this._pos_=0,this.length=0}__getBuffer(){return this._d_.buffer}writeUTFBytes(t){t=t+"";for(var e=0,i=t.length;e>6,128|s&63],this._pos_),this._pos_+=2;else if(s>=55296&&s<=56319){e++;const r=t.charCodeAt(e);if(!Number.isNaN(r)&&r>=56320&&r<=57343){const a=(s&1023)+64,n=r&1023,h=240|a>>8&63,o=128|a>>2&63,l=128|(a&3)<<4|n>>6&15,u=128|n&63;this._ensureWrite(this._pos_+4),this._u8d_.set([h,o,l,u],this._pos_),this._pos_+=4}}else s<=65535?(this._ensureWrite(this._pos_+3),this._u8d_.set([224|s>>12,128|s>>6&63,128|s&63],this._pos_),this._pos_+=3):(this._ensureWrite(this._pos_+4),this._u8d_.set([240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63],this._pos_),this._pos_+=4)}}writeUTFString(t){var e=this.pos;this.writeUint16(1),this.writeUTFBytes(t);var i=this.pos-e-2;this._d_.setUint16(e,i,this._xd_)}writeUTFString32(t){var e=this.pos;this.writeUint32(1),this.writeUTFBytes(t);var i=this.pos-e-4;this._d_.setUint32(e,i,this._xd_)}readUTFString(){return this.readUTFBytes(this.getUint16())}readUTFString32(){return this.readUTFBytes(this.getUint32())}getUTFString(){return this.readUTFString()}readUTFBytes(t=-1){if(t===0)return"";var e=this.bytesAvailable;if(t>e)throw"readUTFBytes error - Out of bounds";return t=t>0?t:e,this._rUTF(t)}getUTFBytes(t=-1){return this.readUTFBytes(t)}writeByte(t){this._ensureWrite(this._pos_+1),this._d_.setInt8(this._pos_,t),this._pos_+=1}readByte(){if(this._pos_+1>this._length)throw"readByte error - Out of bounds";return this._d_.getInt8(this._pos_++)}getByte(){return this.readByte()}_ensureWrite(t){this._length>-e-14,it._baseTable[t|256]=1024>>-e-14|32768,it._shiftTable[t|0]=-e-1,it._shiftTable[t|256]=-e-1):e<=15?(it._baseTable[t|0]=e+15<<10,it._baseTable[t|256]=e+15<<10|32768,it._shiftTable[t|0]=13,it._shiftTable[t|256]=13):e<128?(it._baseTable[t|0]=31744,it._baseTable[t|256]=64512,it._shiftTable[t|0]=24,it._shiftTable[t|256]=24):(it._baseTable[t|0]=31744,it._baseTable[t|256]=64512,it._shiftTable[t|0]=13,it._shiftTable[t|256]=13)}for(it._mantissaTable[0]=0,t=1;t<1024;++t){var i=t<<13;for(e=0;!(i&8388608);)e-=8388608,i<<=1;i&=-8388609,e+=947912704,it._mantissaTable[t]=i|e}for(t=1024;t<2048;++t)it._mantissaTable[t]=939524096+(t-1024<<13);for(it._exponentTable[0]=0,t=1;t<31;++t)it._exponentTable[t]=t<<23;for(it._exponentTable[31]=1199570944,it._exponentTable[32]=2147483648,t=33;t<63;++t)it._exponentTable[t]=2147483648+(t-32<<23);for(it._exponentTable[63]=3347054592,it._offsetTable[0]=0,t=1;t<64;++t)t===32?it._offsetTable[t]=0:it._offsetTable[t]=1024}static roundToFloat16Bits(t){it._floatView[0]=t;var e=it._uint32View[0],i=e>>23&511;return it._baseTable[i]+((e&8388607)>>it._shiftTable[i])}static convertToNumber(t){var e=t>>10;return it._uint32View[0]=it._mantissaTable[it._offsetTable[e]+(t&1023)]+it._exponentTable[e],it._floatView[0]}}it._buffer=new ArrayBuffer(4),it._floatView=new Float32Array(it._buffer),it._uint32View=new Uint32Array(it._buffer),it._baseTable=new Uint32Array(512),it._shiftTable=new Uint32Array(512),it._mantissaTable=new Uint32Array(2048),it._exponentTable=new Uint32Array(64),it._offsetTable=new Uint32Array(64);class _t extends Nt{constructor(t=0,e=0,i=d.TextureFormat.R8G8B8A8,s=!0,r=!1){super(i,s);var a=I.instance;this._glTextureType=a.TEXTURE_2D,this._width=t,this._height=e,this._canRead=r,this._setWarpMode(a.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(a.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._setAnisotropy(this._anisoLevel);var n=this._gpuCompressFormat();if(s){var h=Math.max(Math.ceil(Math.log2(t))+1,Math.ceil(Math.log2(e))+1);if(!n)for(var o=0;o>o,1),Math.max(e>>o,1));this._mipmapCount=h,this._setGPUMemory(t*e*4*(1+1/3))}else n||this._setPixels(null,0,t,e),this._mipmapCount=1,this._setGPUMemory(t*e*4)}static __init__(){var t=new Uint8Array(3);t[0]=128,t[1]=128,t[2]=128,_t.grayTexture=new _t(1,1,d.TextureFormat.R8G8B8,!1,!1),_t.grayTexture.setPixels(t),_t.grayTexture.lock=!0,t[0]=255,t[1]=255,t[2]=255,_t.whiteTexture=new _t(1,1,d.TextureFormat.R8G8B8,!1,!1),_t.whiteTexture.setPixels(t),_t.whiteTexture.lock=!0,t[0]=0,t[1]=0,t[2]=0,_t.blackTexture=new _t(1,1,d.TextureFormat.R8G8B8,!1,!1),_t.blackTexture.setPixels(t),_t.blackTexture.lock=!0,_t.erroTextur=_t.whiteTexture}static _parse(t,e=null,i=null){var s=i?new _t(i[0],i[1],i[2],i[3],i[4]):new _t(0,0);switch(e&&(s.wrapModeU=e.wrapModeU,s.wrapModeV=e.wrapModeV,s.filterMode=e.filterMode,s.anisoLevel=e.anisoLevel),s._format){case d.TextureFormat.R8G8B8:case d.TextureFormat.R8G8B8A8:s.loadImageSource(t);break;case d.TextureFormat.DXT1:case d.TextureFormat.DXT5:case d.TextureFormat.ETC1RGB:case d.TextureFormat.PVRTCRGB_2BPPV:case d.TextureFormat.PVRTCRGBA_2BPPV:case d.TextureFormat.PVRTCRGB_4BPPV:case d.TextureFormat.PVRTCRGBA_4BPPV:case d.TextureFormat.ETC2RGB:case d.TextureFormat.ETC2RGBA:case d.TextureFormat.ETC2SRGB:case d.TextureFormat.ASTC4x4:case d.TextureFormat.ASTC6x6:case d.TextureFormat.ASTC8x8:case d.TextureFormat.ASTC10x10:case d.TextureFormat.ASTC12x12:case d.TextureFormat.KTXTEXTURE:case d.TextureFormat.PVRTEXTURE:s.setCompressData(t);break;default:throw"Texture2D:unkonwn format."}return s}static _SimpleAnimatorTextureParse(t,e=null,i=null){var s=new de(t),r=s.readUTFString(),a,n,h;switch(r){case"LAYAANIMATORTEXTURE:0000":var o=s.readInt32(),l=s.readInt32();n=new Float32Array(o*o*4),h=new Float32Array(s.readArrayBuffer(l*4)),n.set(h,0);var a=new _t(o,o,d.TextureFormat.R32G32B32A32,!1,!1);a.setPixels(n,0),a.filterMode=d.FilterMode.Point;break;case"LAYACOMPRESSANIMATORTEXTURE:0000":var o=s.readInt32(),l=s.readInt32();if(n=new Uint16Array(s.readArrayBuffer(l*2)),oi.supportTextureFormat(d.TextureFormat.R16G16B16A16))h=new Uint16Array(o*o*4),h.set(n,0),a=new _t(o,o,d.TextureFormat.R16G16B16A16,!1,!1),a.setPixels(h,0),a.filterMode=d.FilterMode.Point;else{console.log("The platform does not support 16-bit floating-point textures"),oi.supportTextureFormat(d.TextureFormat.R32G32B32A32)||console.error("The platform does not support 32-bit floating-point textures"),h=new Float32Array(o*o*4);for(var u=0,_=n.length;u<_;u++)h[u]=it.convertToNumber(n[u]);a=new _t(o,o,d.TextureFormat.R32G32B32A32,!1,!1),a.setPixels(h,0),a.filterMode=d.FilterMode.Point}break;default:throw"Laya3D:unknow version."}return a}static load(t,e){c.loader.create(t,e,null,c.Loader.TEXTURE2D)}get defaulteTexture(){return _t.grayTexture}_gpuCompressFormat(){return this._format!=d.TextureFormat.R8G8B8A8&&this._format!=d.TextureFormat.R8G8B8&&this._format!=d.TextureFormat.R16G16B16A16&&this._format!=d.TextureFormat.R32G32B32A32&&this._format!=d.TextureFormat.R5G6B5&&this._format!=d.TextureFormat.Alpha8}_setPixels(t,e,i,s){var r=I.instance,a=this._glTextureType,n=this._getGLFormat();switch(A.bindTexture(r,a,this._glTexture),this.format){case d.TextureFormat.R8G8B8:case d.TextureFormat.R8G8B8A8:r.pixelStorei(r.UNPACK_ALIGNMENT,1),r.texImage2D(a,e,n,i,s,0,n,r.UNSIGNED_BYTE,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case d.TextureFormat.R5G6B5:r.pixelStorei(r.UNPACK_ALIGNMENT,2),r.texImage2D(a,e,n,i,s,0,n,r.UNSIGNED_SHORT_5_6_5,t),r.pixelStorei(r.UNPACK_ALIGNMENT,4);break;case d.TextureFormat.R32G32B32A32:I.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA32F,i,s,0,n,r.FLOAT,t):r.texImage2D(a,e,r.RGBA,i,s,0,n,r.FLOAT,t);break;case d.TextureFormat.R16G16B16A16:I.layaGPUInstance._isWebGL2?r.texImage2D(a,e,r.RGBA16F,i,s,0,n,r.HALF_FLOAT,t):r.texImage2D(a,e,r.RGBA,i,s,0,n,I.layaGPUInstance._oesTextureHalfFloat.HALF_FLOAT_OES,t);break;default:r.texImage2D(a,e,n,i,s,0,n,r.UNSIGNED_BYTE,t)}}_calcualatesCompressedDataSize(t,e,i){switch(t){case d.TextureFormat.DXT1:return(e+3>>2)*(i+3>>2)*8;case d.TextureFormat.DXT5:return(e+3>>2)*(i+3>>2)*16;case d.TextureFormat.PVRTCRGB_4BPPV:case d.TextureFormat.PVRTCRGBA_4BPPV:return Math.floor((Math.max(e,8)*Math.max(i,8)*4+7)/8);case d.TextureFormat.PVRTCRGB_2BPPV:case d.TextureFormat.PVRTCRGBA_2BPPV:return Math.floor((Math.max(e,16)*Math.max(i,8)*2+7)/8);default:return 0}}_pharseDDS(t){var e=new Int32Array(t,0,31);if(e[0]!=542327876)throw"Invalid magic number in DDS header";if(!(e[20]&4))throw"Unsupported format, must contain a FourCC code";var i=e[21];switch(this._format){case d.TextureFormat.DXT1:if(i!==827611204)throw"the FourCC code is not same with texture format.";break;case d.TextureFormat.DXT5:if(i!==894720068)throw"the FourCC code is not same with texture format.";break;default:throw"unknown texture format."}var s=1;if(e[2]&131072){if(s=Math.max(1,e[7]),!this._mipmap)throw"the mipmap is not same with Texture2D."}else if(this._mipmap)throw"the mipmap is not same with Texture2D.";var r=e[4],a=e[3];this._width=r,this._height=a;var n=e[1]+4;this._upLoadCompressedTexImage2D(t,r,a,s,n,0)}_pharseKTX(t){var e=new Uint8Array(t,0,12);if(e[0]!=171||e[1]!=75||e[2]!=84||e[3]!=88||e[4]!=32||e[5]!=49||e[6]!=49||e[7]!=187||e[8]!=13||e[9]!=10||e[10]!=26||e[11]!=10)throw"Invalid fileIdentifier in KTX header";var i=new Int32Array(e.buffer,e.length,13),s=i[4];if(this._format=-1,I.layaGPUInstance._compressedTextureASTC)switch(s){case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_4x4_KHR:this._format=d.TextureFormat.ASTC4x4;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:this._format=d.TextureFormat.ASTC4x4SRGB;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:this._format=d.TextureFormat.ASTC6x6SRGB;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:this._format=d.TextureFormat.ASTC8x8SRGB;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:this._format=d.TextureFormat.ASTC10x10SRGB;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:this._format=d.TextureFormat.ASTC12x12SRGB;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_6x6_KHR:this._format=d.TextureFormat.ASTC6x6;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_8x8_KHR:this._format=d.TextureFormat.ASTC8x8;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_10x10_KHR:this._format=d.TextureFormat.ASTC10x10;break;case I.layaGPUInstance._compressedTextureASTC.COMPRESSED_RGBA_ASTC_12x12_KHR:this._format=d.TextureFormat.ASTC12x12;break}if(I.layaGPUInstance._compressedTextureEtc1)switch(s){case I.layaGPUInstance._compressedTextureEtc1.COMPRESSED_RGB_ETC1_WEBGL:this._format=d.TextureFormat.ETC1RGB;break}if(I.layaGPUInstance._compressedTextureETC)switch(s){case I.layaGPUInstance._compressedTextureETC.COMPRESSED_RGBA8_ETC2_EAC:this._format=d.TextureFormat.ETC2RGBA;break;case I.layaGPUInstance._compressedTextureETC.COMPRESSED_RGB8_ETC2:this._format=d.TextureFormat.ETC2RGB;break;case I.layaGPUInstance._compressedTextureETC.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:this._format=d.TextureFormat.ETC2RGB_Alpha8;break;case I.layaGPUInstance._compressedTextureETC.COMPRESSED_SRGB8_ETC2:this._format=d.TextureFormat.ETC2SRGB;break}if(this._format==-1)throw"unknown texture format.";var r=i[11],a=i[6],n=i[7];this._width=a,this._height=n;var h=64+i[12];this._upLoadKTXCompressedTexImage2D(t,a,n,r,h,4)}_pharsePVR(t){var e=new Int32Array(t,0,13);if(e[0]!=55727696)throw"Invalid magic number in PVR header";var i=e[2];switch(i){case 0:this._format=d.TextureFormat.PVRTCRGB_2BPPV;break;case 2:this._format=d.TextureFormat.PVRTCRGB_4BPPV;break;case 1:this._format=d.TextureFormat.PVRTCRGBA_2BPPV;break;case 3:this._format=d.TextureFormat.PVRTCRGBA_4BPPV;break;default:throw"Texture2D:unknown PVR format."}var s=e[11],r=e[7],a=e[6];this._width=r,this._height=a;var n=e[12]+52;this._upLoadCompressedTexImage2D(t,r,a,s,n,0)}_upLoadCompressedTexImage2D(t,e,i,s,r,a){var n=I.instance,h=this._glTextureType;A.bindTexture(n,h,this._glTexture);for(var o=this._getGLFormat(),l=r,u=0;u>1,1),i=Math.max(i>>1,1),l+=_}var p=l;this._setGPUMemory(p),this._readyed=!0,this._activeResource()}_upLoadKTXCompressedTexImage2D(t,e,i,s,r,a){var n=I.instance,h=this._glTextureType;A.bindTexture(n,h,this._glTexture);for(var o=this._getGLFormat(),l=r,u=0;u>1,1),i=Math.max(i>>1,1),l+=_,l+=3-(_+3)%4}var p=l;this._setGPUMemory(p),this._readyed=!0,this._activeResource()}loadImageSource(t,e=!1){var i=I.instance,s=t.width,r=t.height;this._width=s,this._height=r,this._isPot(s)&&this._isPot(r)||(this._mipmap=!1),this._setWarpMode(i.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(i.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),A.bindTexture(i,this._glTextureType,this._glTexture);var a=this._getGLFormat();c.Render.isConchApp?(t.setPremultiplyAlpha&&t.setPremultiplyAlpha(e),i.texImage2D(this._glTextureType,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t)):(e&&i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.format==d.TextureFormat.R5G6B5?i.texImage2D(this._glTextureType,0,i.RGB,i.RGB,i.UNSIGNED_SHORT_5_6_5,t):i.texImage2D(this._glTextureType,0,a,a,i.UNSIGNED_BYTE,t),e&&i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)),this._mipmap?(i.generateMipmap(this._glTextureType),this._setGPUMemory(s*r*4*(1+1/3))):this._setGPUMemory(s*r*4),this._canRead&&(c.Render.isConchApp&&t._nativeObj?this._pixels=new Uint8Array(t._nativeObj.getImageData(0,0,s,r)):(c.Browser.canvas.size(s,r),c.Browser.canvas.clear(),c.Browser.context.drawImage(t,0,0,s,r),this._pixels=new Uint8Array(c.Browser.context.getImageData(0,0,s,r).data.buffer))),this._readyed=!0,this._activeResource()}setPixels(t,e=0){if(this._gpuCompressFormat())throw"Texture2D:the format is GPU compression format.";if(!t)throw"Texture2D:pixels can't be null.";var i=Math.max(this._width>>e,1),s=Math.max(this._height>>e,1),r=i*s*this._getFormatByteCount();if(t.length=1e4&&console.error("getRT error! w too big");var i;return i=new kt(t,e,d.RenderTextureFormat.R8G8B8A8,-1),i}static releaseRT(t){t.destroy()}}li.dict={};class rt{static _init_(t){rt.fns=[rt.BlendNormal,rt.BlendAdd,rt.BlendMultiply,rt.BlendScreen,rt.BlendOverlay,rt.BlendLight,rt.BlendMask,rt.BlendDestinationOut,rt.BlendAddOld],rt.targetFns=[rt.BlendNormalTarget,rt.BlendAddTarget,rt.BlendMultiplyTarget,rt.BlendScreenTarget,rt.BlendOverlayTarget,rt.BlendLightTarget,rt.BlendMask,rt.BlendDestinationOut,rt.BlendAddTargetOld]}static BlendNormal(t){A.setBlendFunc(t,t.ONE,t.ONE_MINUS_SRC_ALPHA,!0)}static BlendAddOld(t){A.setBlendFunc(t,t.ONE,t.DST_ALPHA,!0)}static BlendAdd(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendMultiply(t){A.setBlendFunc(t,t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,!0)}static BlendScreen(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendOverlay(t){A.setBlendFunc(t,t.ONE,t.ONE_MINUS_SRC_COLOR,!0)}static BlendLight(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendNormalTarget(t){A.setBlendFunc(t,t.ONE,t.ONE_MINUS_SRC_ALPHA,!0)}static BlendAddTargetOld(t){A.setBlendFunc(t,t.ONE,t.DST_ALPHA,!0)}static BlendAddTarget(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendMultiplyTarget(t){A.setBlendFunc(t,t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,!0)}static BlendScreenTarget(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendOverlayTarget(t){A.setBlendFunc(t,t.ONE,t.ONE_MINUS_SRC_COLOR,!0)}static BlendLightTarget(t){A.setBlendFunc(t,t.ONE,t.ONE,!0)}static BlendMask(t){A.setBlendFunc(t,t.ZERO,t.SRC_ALPHA,!0)}static BlendDestinationOut(t){A.setBlendFunc(t,t.ZERO,t.ZERO,!0)}}rt.activeBlendFunction=null,rt.NAMES=["normal","add","multiply","screen","overlay","light","mask","destination-out","add_old"],rt.TOINT={normal:0,add:1,multiply:2,screen:3,overlay:4,light:5,mask:6,"destination-out":7,lighter:1,lighter_old:8,add_old:8},rt.NORMAL="normal",rt.MASK="mask",rt.LIGHTER="lighter";class Ki{constructor(t,e,i){this._value=0,this._name2int=t,this._int2name=e,this._int2nameMap=i}add(t){return typeof t=="string"?this._value|=this._name2int[t]:this._value|=t,this._value}addInt(t){return this._value|=t,this._value}remove(t){return typeof t=="string"?this._value&=~this._name2int[t]:this._value&=~t,this._value}isDefine(t){return(this._value&t)===t}getValue(){return this._value}setValue(t){this._value=t}toNameDic(){var t=this._int2nameMap[this._value];return t||Ki._toText(this._value,this._int2name,this._int2nameMap)}static _reg(t,e,i,s){i[t]=e,s[e]=t}static _toText(t,e,i){var s=i[t];if(s)return s;for(var r={},a=1,n=0;n<32&&(a=1<t));n++)if(t&a){var h=e[a];h&&(r[h]="")}return i[t]=r,r}static _toInt(t,e){for(var i=t.split("."),s=0,r=0,a=i.length;r0&&(i.name=i.name.substr(0,i.name.length-3),i.isArray=!0,i.location=e.getUniformLocation(this._program,i.name)),this._params.push(i)}for(s=0,r=this._params.length;s=0;h-=2)a=this._paramsMap[t[h]],a&&(r=t[h+1],r!=null&&(i&&i[a.name]&&i[a.name].bind(),n+=a.fun.call(this,a,r)));F.shaderCall+=n}getParams(){return this._params}setAttributesLocation(t){this._attribInfo=t}}bt._count=0,bt._preCompileShader={},bt.SHADERNAME2ID=2e-4,bt.nameKey=new Ss,bt.sharders=new Array(32);class qi extends bt{constructor(t,e,i=null,s=null,r=null){super(t,e,i,s,r),this._params2dQuick2=null,this._shaderValueWidth=0,this._shaderValueHeight=0}_disposeResource(){super._disposeResource(),this._params2dQuick2=null}upload2dQuick2(t){this.upload(t,this._params2dQuick2||this._make2dQuick2())}_make2dQuick2(){if(!this._params2dQuick2){this._params2dQuick2=[];for(var t=this._params,e,i=0,s=t.length;i0&&!this._inClassCache&&(this._inClassCache=vt._cache[this._cacheID]=[],this._inClassCache._length=0),this.clear()}static _initone(t,e){vt._typeClass[t]=e,vt._cache[t]=[],vt._cache[t]._length=0}static __init__(){}setValue(t){}_ShaderWithCompile(){var t=bt.withCompile2D(0,this.mainID,this.defines.toNameDic(),this.mainID|this.defines._value,qi.create,this._attribLocation);return t}upload(){var t=U;U.worldMatrix4===U.TEMPMAT4_ARRAY||this.defines.addInt(V.WORLDMAT),this.mmat=t.worldMatrix4,U.matWVP&&(this.defines.addInt(V.MVP3D),this.u_MvpMatrix=U.matWVP.elements);var e=bt.sharders[this.mainID|this.defines._value]||this._ShaderWithCompile();e._shaderValueWidth!==t.width||e._shaderValueHeight!==t.height?(this.size[0]=t.width,this.size[1]=t.height,e._shaderValueWidth=t.width,e._shaderValueHeight=t.height,e.upload(this,null)):e.upload(this,e._params2dQuick2||e._make2dQuick2())}setFilters(t){if(this.filters=t,!!t)for(var e=t.length,i,s=0;s-1&&t[i]._zOrder>r;)t[i+1]=t[i];t[i+1]=a,e++}return!0}static transPointList(t,e,i){var s,r=t.length;for(s=0;s1?e[1].toLowerCase():null}static getFilecompatibleExtension(t){var e=t.split("."),i=e.length;return e.length>2?e[i-2]+"."+e[i-1]:null}static getTransformRelativeToWindow(t,e,i){var s=J.gStage,r=J.getGlobalPosAndScale(t),a=s._canvasTransform.clone(),n=a.tx,h=a.ty;a.rotate(-Math.PI/180*s.canvasDegree),a.scale(s.clientScaleX,s.clientScaleY);var o=s.canvasDegree%180!=0,l,u;o?(l=i+r.y,u=e+r.x,l*=a.d,u*=a.a,s.canvasDegree==90?(l=n-l,u+=h):(l+=n,u=h-u)):(l=e+r.x,u=i+r.y,l*=a.a,u*=a.d,l+=n,u+=h),u+=s._safariOffsetY;var _,f;return o?(_=a.d*r.height,f=a.a*r.width):(_=a.a*r.width,f=a.d*r.height),{x:l,y:u,scaleX:_,scaleY:f}}static fitDOMElementInArea(t,e,i,s,r,a){t._fitLayaAirInitialized||(t._fitLayaAirInitialized=!0,t.style.transformOrigin=t.style.webKittransformOrigin="left top",t.style.position="absolute");var n=J.getTransformRelativeToWindow(e,i,s);t.style.transform=t.style.webkitTransform="scale("+n.scaleX+","+n.scaleY+") rotate("+J.gStage.canvasDegree+"deg)",t.style.width=r+"px",t.style.height=a+"px",t.style.left=n.x+"px",t.style.top=n.y+"px"}static isOkTextureList(t){if(!t)return!1;var e,i=t.length,s;for(e=0;e\s+<"),t=new DOMParser().parseFromString(v,"text/xml"),t.firstChild.textContent.indexOf("This page contains the following errors")>-1)throw new Error(t.firstChild.firstChild.textContent);return t};class lt{constructor(t){if(this.arrColor=[],t==null||t=="none"){this.strColor="#00000000",this.numColor=0,this.arrColor=[0,0,0,0];return}var e,i,s;if(typeof t=="string")if(t.indexOf("rgba(")>=0||t.indexOf("rgb(")>=0){var r=t,a,n;for(a=r.indexOf("("),n=r.indexOf(")"),r=r.substring(a+1,n),this.arrColor=r.split(","),i=this.arrColor.length,e=0;e=0||this.strColor.length===9?(this.arrColor=[((4278190080&s)>>>24)/255,((16711680&s)>>16)/255,((65280&s)>>8)/255,(255&s)/255],this.numColor=(4278190080&s)>>>24|(s&16711680)>>8|(s&65280)<<8|(s&255)<<24):(this.arrColor=[((16711680&s)>>16)/255,((65280&s)>>8)/255,(255&s)/255,1],this.numColor=4278190080|(s&16711680)>>16|s&65280|(s&255)<<16),this.arrColor.__id=++lt._COLODID}static _initDefault(){lt._DEFAULT={};for(var t in lt._COLOR_MAP)lt._SAVE[t]=lt._DEFAULT[t]=new lt(lt._COLOR_MAP[t]);return lt._DEFAULT}static _initSaveMap(){lt._SAVE_SIZE=0,lt._SAVE={};for(var t in lt._DEFAULT)lt._SAVE[t]=lt._DEFAULT[t]}static create(t){var e=t+"",i=lt._SAVE[e];return i??(lt._SAVE_SIZE<1e3&<._initSaveMap(),lt._SAVE[e]=new lt(t))}}lt._SAVE={},lt._SAVE_SIZE=0,lt._COLOR_MAP={purple:"#800080",orange:"#ffa500",white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",black:"#000000",yellow:"#FFFF00",gray:"#808080"},lt._DEFAULT=lt._initDefault(),lt._COLODID=1;class Xt extends oe{constructor(t=null){super(),t||(t=this._copyMatrix(Xt.IDENTITY_MATRIX)),this._mat=new Float32Array(16),this._alpha=new Float32Array(4),this.setByMatrix(t)}gray(){return this.setByMatrix(Xt.GRAY_MATRIX)}color(t=0,e=0,i=0,s=1){return this.setByMatrix([1,0,0,0,t,0,1,0,0,e,0,0,1,0,i,0,0,0,1,s])}setColor(t){var e=lt.create(t).arrColor,i=[0,0,0,0,256*e[0],0,0,0,0,256*e[1],0,0,0,0,256*e[2],0,0,0,1,0];return this.setByMatrix(i)}setByMatrix(t){this._matrix!=t&&this._copyMatrix(t);for(var e=0,i=0,s=0;s<20;s++)s%5!=4?this._mat[e++]=t[s]:this._alpha[i++]=t[s];return this}get type(){return oe.COLOR}adjustColor(t,e,i,s){return this.adjustHue(s),this.adjustContrast(e),this.adjustBrightness(t),this.adjustSaturation(i),this}adjustBrightness(t){return t=this._clampValue(t,100),t==0||isNaN(t)?this:this._multiplyMatrix([1,0,0,0,t,0,1,0,0,t,0,0,1,0,t,0,0,0,1,0,0,0,0,0,1])}adjustContrast(t){if(t=this._clampValue(t,100),t==0||isNaN(t))return this;var e;t<0?e=127+t/100*127:(e=t%1,e==0?e=Xt.DELTA_INDEX[t]:e=Xt.DELTA_INDEX[t<<0]*(1-e)+Xt.DELTA_INDEX[(t<<0)+1]*e,e=e*127+127);var i=e/127,s=(127-e)*.5;return this._multiplyMatrix([i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0,0,0,0,0,1])}adjustSaturation(t){if(t=this._clampValue(t,100),t==0||isNaN(t))return this;var e=1+(t>0?3*t/100:t/100),i=1-e,s=.3086*i,r=.6094*i,a=.082*i;return this._multiplyMatrix([s+e,r,a,0,0,s,r+e,a,0,0,s,r,a+e,0,0,0,0,0,1,0,0,0,0,0,1])}adjustHue(t){if(t=this._clampValue(t,180)/180*Math.PI,t==0||isNaN(t))return this;var e=Math.cos(t),i=Math.sin(t),s=.213,r=.715,a=.072;return this._multiplyMatrix([s+e*(1-s)+i*-s,r+e*-r+i*-r,a+e*-a+i*(1-a),0,0,s+e*-s+i*.143,r+e*(1-r)+i*.14,a+e*-a+i*-.283,0,0,s+e*-s+i*-(1-s),r+e*-r+i*r,a+e*(1-a)+i*a,0,0,0,0,0,1,0,0,0,0,0,1])}reset(){return this.setByMatrix(this._copyMatrix(Xt.IDENTITY_MATRIX))}_multiplyMatrix(t){var e=[];this._matrix=this._fixMatrix(this._matrix);for(var i=0;i<5;i++){for(var s=0;s<5;s++)e[s]=this._matrix[s+i*5];for(s=0;s<5;s++){for(var r=0,a=0;a<5;a++)r+=t[s+a*5]*e[a];this._matrix[s+i*5]=r}}return this.setByMatrix(this._matrix)}_clampValue(t,e){return Math.min(e,Math.max(-e,t))}_fixMatrix(t=null){return t==null?Xt.IDENTITY_MATRIX:(t.lengthXt.LENGTH&&(t=t.slice(0,Xt.LENGTH)),t)}_copyMatrix(t){var e=Xt.LENGTH;this._matrix||(this._matrix=[]);for(var i=0;i0?t:5;var s;for(s=1/t,i=0;i<=1;i+=s)this._calFun(i,e)}getBezierPoints(t,e=5,i=2){var s,r;if(r=t.length,r<(i+1)*2)return[];var a=[];switch(i){case 2:this._calFun=this.getPoint2;break;case 3:this._calFun=this.getPoint3;break;default:return[]}for(;this._controlPoints.length<=i;)this._controlPoints.push(Tt.create());for(s=0;s=0;e--)r=t[e],o=r.x+"_"+r.y,o in h||(h[o]=!0,n.push(r));for(a=n.length,J.copyArray(t,n),e=1;e0||Lt.multiply(t[i],t[s],t[0])==0&&Lt.dis(t[0],t[i])=2&&Lt.multiply(t[e],n[n.length-1],n[n.length-2])>=0;)n.pop();t[e]&&n.push(t[e])}return n}}Lt._tempPointList=[],Lt._temPList=[],Lt._temArr=[];class be{constructor(t){this.setValue(t)}static create(t){if(t){var e=t instanceof lt?t:lt.create(t);return e._drawStyle||(e._drawStyle=new be(t))}return be.DEFAULT}setValue(t){t?this._color=t instanceof lt?t:lt.create(t):this._color=lt.create("#000000")}reset(){this._color=lt.create("#000000")}toInt(){return this._color.numColor}equal(t){return typeof t=="string"?this._color.strColor===t:t instanceof lt?this._color.numColor===t.numColor:!1}toColorStr(){return this._color.strColor}}be.DEFAULT=new be("#000000");class Ms{constructor(){this._lastOriX=0,this._lastOriY=0,this.paths=[],this._curPath=null}beginPath(t){this.paths.length=1,this._curPath=this.paths[0]=new ji,this._curPath.convex=t}closePath(){this._curPath.loop=!0}newPath(){this._curPath=new ji,this.paths.push(this._curPath)}addPoint(t,e){this._curPath.path.push(t,e)}push(t,e){this._curPath?this._curPath.path.length>0&&(this._curPath=new ji,this.paths.push(this._curPath)):(this._curPath=new ji,this.paths.push(this._curPath));var i=this._curPath;i.path=t.slice(),i.convex=e}reset(){this.paths.length=0}}class ji{constructor(){this.path=[],this.loop=!1,this.convex=!1}}class W{constructor(t=W.TYPE_2D){this.clipInfoID=-1,this._mesh=null,this._blendFn=null,this._id=0,this._renderType=0,this._parent=null,this._key=new Pi,this._startIdx=0,this._numEle=0,this._ref=1,this.shaderValue=null,this._renderType=t,this._id=++W.ID}static __init__(){var t=W.RENDERBASE=new W(-1);t.shaderValue=new vt(0,0),t.shaderValue.ALPHA=1,t._ref=4294967295}getID(){return this._id}getRenderType(){return this._renderType}toString(){return"ibindex:"+this._startIdx+" num:"+this._numEle+" key="+this._key}renderSubmit(){return 1}releaseRender(){}}W.TYPE_2D=1e4,W.TYPE_CANVAS=10003,W.TYPE_CMDSETRT=10004,W.TYPE_CUSTOM=10005,W.TYPE_BLURRT=10006,W.TYPE_CMDDESTORYPRERT=10007,W.TYPE_DISABLESTENCIL=10008,W.TYPE_OTHERIBVB=10009,W.TYPE_PRIMITIVE=10010,W.TYPE_RT=10011,W.TYPE_BLUR_RT=10012,W.TYPE_TARGET=10013,W.TYPE_CHANGE_VALUE=10014,W.TYPE_SHAPE=10015,W.TYPE_TEXTURE=10016,W.TYPE_FILLTEXTURE=10017,W.KEY_ONCE=-1,W.KEY_FILLRECT=1,W.KEY_DRAWTEXTURE=2,W.KEY_VG=3,W.KEY_TRIANGLES=4,W.ID=1,W.preRender=null;class X{constructor(){}static _createArray(){var t=[];return t._length=0,t}static _init(){var t=X._namemap={};return t[X.TYPE_ALPHA]="ALPHA",t[X.TYPE_FILESTYLE]="fillStyle",t[X.TYPE_FONT]="font",t[X.TYPE_LINEWIDTH]="lineWidth",t[X.TYPE_STROKESTYLE]="strokeStyle",t[X.TYPE_ENABLEMERGE]="_mergeID",t[X.TYPE_MARK]=t[X.TYPE_TRANSFORM]=t[X.TYPE_TRANSLATE]=[],t[X.TYPE_TEXTBASELINE]="textBaseline",t[X.TYPE_TEXTALIGN]="textAlign",t[X.TYPE_GLOBALCOMPOSITEOPERATION]="_nBlendType",t[X.TYPE_SHADER]="shader",t[X.TYPE_FILTERS]="filters",t[X.TYPE_COLORFILTER]="_colorFiler",t}isSaveMark(){return!1}restore(t){this._dataObj[this._valueName]=this._value,X.POOL[X.POOL._length++]=this,this._newSubmit&&(t._curSubmit=W.RENDERBASE)}static save(t,e,i,s){if((t._saveMark._saveuse&e)!==e){t._saveMark._saveuse|=e;var r=X.POOL,a=r._length>0?r[--r._length]:new X;a._value=i[a._valueName=X._namemap[e]],a._dataObj=i,a._newSubmit=s;var n=t._save;n[n._length++]=a}}}X.TYPE_ALPHA=1,X.TYPE_FILESTYLE=2,X.TYPE_FONT=8,X.TYPE_LINEWIDTH=256,X.TYPE_STROKESTYLE=512,X.TYPE_MARK=1024,X.TYPE_TRANSFORM=2048,X.TYPE_TRANSLATE=4096,X.TYPE_ENABLEMERGE=8192,X.TYPE_TEXTBASELINE=16384,X.TYPE_TEXTALIGN=32768,X.TYPE_GLOBALCOMPOSITEOPERATION=65536,X.TYPE_CLIPRECT=131072,X.TYPE_CLIPRECT_STENCIL=262144,X.TYPE_IBVB=524288,X.TYPE_SHADER=1048576,X.TYPE_FILTERS=2097152,X.TYPE_FILTERS_TYPE=4194304,X.TYPE_COLORFILTER=8388608,X.POOL=X._createArray(),X._namemap=X._init();class Ke{constructor(){this._globalClipMatrix=new et,this._clipInfoID=-1,this._clipRect=new tt,this.incache=!1}isSaveMark(){return!1}restore(t){this._globalClipMatrix.copyTo(t._globalClipMatrix),this._clipRect.clone(t._clipRect),t._clipInfoID=this._clipInfoID,Ke.POOL[Ke.POOL._length++]=this,t._clipInCache=this.incache}static save(t){if((t._saveMark._saveuse&X.TYPE_CLIPRECT)!=X.TYPE_CLIPRECT){t._saveMark._saveuse|=X.TYPE_CLIPRECT;var e=Ke.POOL,i=e._length>0?e[--e._length]:new Ke;t._globalClipMatrix.copyTo(i._globalClipMatrix),t._clipRect.clone(i._clipRect),i._clipInfoID=t._clipInfoID,i.incache=t._clipInCache;var s=t._save;s[s._length++]=i}}}Ke.POOL=X._createArray();class Ge{constructor(){this._saveuse=0}isSaveMark(){return!0}restore(t){t._saveMark=this._preSaveMark,Ge.POOL[Ge.POOL._length++]=this}static Create(t){var e=Ge.POOL,i=e._length>0?e[--e._length]:new Ge;return i._saveuse=0,i._preSaveMark=t._saveMark,t._saveMark=i,i}}Ge.POOL=X._createArray();class Se{constructor(){this._matrix=new et}isSaveMark(){return!1}restore(t){t._curMat=this._savematrix,Se.POOL[Se.POOL._length++]=this}static save(t){var e=t._saveMark;if((e._saveuse&X.TYPE_TRANSFORM)!==X.TYPE_TRANSFORM){e._saveuse|=X.TYPE_TRANSFORM;var i=Se.POOL,s=i._length>0?i[--i._length]:new Se;s._savematrix=t._curMat,t._curMat=t._curMat.copyTo(s._matrix);var r=t._save;r[r._length++]=s}}}Se.POOL=X._createArray();class qe{constructor(){this._mat=new et}isSaveMark(){return!1}restore(t){this._mat.copyTo(t._curMat),qe.POOL[qe.POOL._length++]=this}static save(t){var e=qe.POOL,i=e._length>0?e[--e._length]:new qe;t._curMat.copyTo(i._mat);var s=t._save;s[s._length++]=i}}qe.POOL=X._createArray();class ke{constructor(){this._nativeVertexArrayObject=I.layaGPUInstance.createVertexArray()}bind(){ke._curBindedBufferState!==this&&(I.layaGPUInstance.bindVertexArray(this._nativeVertexArrayObject),ke._curBindedBufferState=this)}unBind(){if(ke._curBindedBufferState===this)I.layaGPUInstance.bindVertexArray(null),ke._curBindedBufferState=null;else throw"BufferState: must call bind() function first."}destroy(){I.layaGPUInstance.deleteVertexArray(this._nativeVertexArrayObject)}bindForNative(){I.instance.bindVertexArray(this._nativeVertexArrayObject),ke._curBindedBufferState=this}unBindForNative(){I.instance.bindVertexArray(null),ke._curBindedBufferState=null}}class Is extends ke{constructor(){super()}}class Ie{constructor(){this._byteLength=0,this._glBuffer=I.instance.createBuffer()}get bufferUsage(){return this._bufferUsage}_bindForVAO(){}bind(){return!1}destroy(){this._glBuffer&&(I.instance.deleteBuffer(this._glBuffer),this._glBuffer=null)}}class ae{}ae.loopStTm=0,ae.loopCount=0;class Ri extends Ie{constructor(){super(),this._maxsize=0,this._upload=!0,this._uploadSize=0,this._bufferSize=0,this._u8Array=null}static __int__(t){}get bufferLength(){return this._buffer.byteLength}set byteLength(t){this.setByteLength(t)}setByteLength(t){this._byteLength!==t&&(t<=this._bufferSize||this._resizeBuffer(t*2+256,!0),this._byteLength=t)}needSize(t){var e=this._byteLength;if(t){var i=this._byteLength+t;i<=this._bufferSize||this._resizeBuffer(i<<1,!0),this._byteLength=i}return e}_bufferData(){this._maxsize=Math.max(this._maxsize,this._byteLength),ae.loopCount%30==0&&(this._buffer.byteLength>this._maxsize+64&&(this._buffer=this._buffer.slice(0,this._maxsize+64),this._bufferSize=this._buffer.byteLength,this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSizethis._maxsize+64&&(this._buffer=this._buffer.slice(0,this._maxsize+64),this._bufferSize=this._buffer.byteLength,this._checkArrayUse()),this._maxsize=this._byteLength),this._uploadSize0){var r=new ArrayBuffer(t),a=s&&s.buffer==i?s:new Uint8Array(i);s=this._u8Array=new Uint8Array(r),s.set(a,0),i=this._buffer=r}else i=this._buffer=new ArrayBuffer(t),this._u8Array=null;return this._checkArrayUse(),this._upload=!0,this._bufferSize=i.byteLength,this}append(t){this._upload=!0;var e,i;e=t.byteLength,t instanceof Uint8Array?(this._resizeBuffer(this._byteLength+e,!0),i=new Uint8Array(this._buffer,this._byteLength)):t instanceof Uint16Array?(this._resizeBuffer(this._byteLength+e,!0),i=new Uint16Array(this._buffer,this._byteLength)):t instanceof Float32Array&&(this._resizeBuffer(this._byteLength+e,!0),i=new Float32Array(this._buffer,this._byteLength)),i.set(t,0),this._byteLength+=e,this._checkArrayUse()}appendU16Array(t,e){this._resizeBuffer(this._byteLength+e*2,!0);var i=new Uint16Array(this._buffer,this._byteLength,e);if(e==6)i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5];else if(e>=100)i.set(new Uint16Array(t.buffer,0,e));else for(var s=0;s>2;this.setByteLength(this._byteLength+t.length*4);var i=this.getFloat32Array();i.set(t,e),this._upload=!0}_checkArrayUse(){this._floatArray32&&(this._floatArray32=new Float32Array(this._buffer)),this._uint32Array&&(this._uint32Array=new Uint32Array(this._buffer))}deleteBuffer(){super._disposeResource()}_bindForVAO(){var t=I.instance;t.bindBuffer(t.ARRAY_BUFFER,this._glBuffer)}bind(){if(Ie._bindedVertexBuffer!==this._glBuffer){var t=I.instance;return t.bindBuffer(t.ARRAY_BUFFER,this._glBuffer),Ie._bindedVertexBuffer=this._glBuffer,!0}return!1}destroy(){super.destroy(),this._byteLength=0,this._upload=!0,this._buffer=null,this._floatArray32=null}}Li.create=function(v,t=35048){return new Li(v,t)};class We{constructor(t,e,i){this._stride=0,this.vertNum=0,this.indexNum=0,this._applied=!1,this._quadNum=0,this.canReuse=!1,this._stride=t,this._vb=new Li(t,I.instance.DYNAMIC_DRAW),e?this._vb._resizeBuffer(e,!1):Dt.webGL2D_MeshAllocMaxMem&&this._vb._resizeBuffer(64*1024*t,!1),this._ib=new Fi,i&&this._ib._resizeBuffer(i,!1)}cloneWithNewVB(){var t=new We(this._stride,0,0);return t._ib=this._ib,t._quadNum=this._quadNum,t._attribInfo=this._attribInfo,t}cloneWithNewVBIB(){var t=new We(this._stride,0,0);return t._attribInfo=this._attribInfo,t}getVBW(){return this._vb.setNeedUpload(),this._vb}getVBR(){return this._vb}getIBR(){return this._ib}getIBW(){return this._ib.setNeedUpload(),this._ib}createQuadIB(t){this._quadNum=t,this._ib._resizeBuffer(t*6*2,!1),this._ib.byteLength=this._ib.bufferLength;for(var e=this._ib.getUint16Array(),i=0,s=0,r=0;r>2;r.setByteLength(a+Bt.const_stride<<2);var n=r._floatArray32||r.getFloat32Array(),h=r._uint32Array,o=a,l=s?255:0;n[o++]=t[0],n[o++]=t[1],n[o++]=e[0],n[o++]=e[1],h[o++]=i,h[o++]=l,n[o++]=t[2],n[o++]=t[3],n[o++]=e[2],n[o++]=e[3],h[o++]=i,h[o++]=l,n[o++]=t[4],n[o++]=t[5],n[o++]=e[4],n[o++]=e[5],h[o++]=i,h[o++]=l,n[o++]=t[6],n[o++]=t[7],n[o++]=e[6],n[o++]=e[7],h[o++]=i,h[o++]=l,r._upload=!0}}Bt.const_stride=24,Bt._maxIB=16*1024,Bt._POOL=[];class ne extends We{constructor(){super(ne.const_stride,4,4),this.canReuse=!0,this.setAttributes(ne._fixattriInfo)}static __init__(){ne._fixattriInfo=[5126,4,0,5121,4,16,5121,4,20]}static getAMesh(t){var e;return ne._POOL.length?e=ne._POOL.pop():e=new ne,t&&e._vb._resizeBuffer(64*1024*ne.const_stride,!1),e}addData(t,e,i,s,r){var a=this._vb,n=this._ib,h=t.length>>1,o=a.needSize(h*ne.const_stride),l=o>>2,u=a._floatArray32||a.getFloat32Array(),_=a._uint32Array,f=0,p=s.a,m=s.b,g=s.c,y=s.d,C=s.tx,w=s.ty,M=0;for(M=0;M>1;if(k>0){var nt=Mt+z,pt=0;for(M=Mt;M>2,n=this._vb._floatArray32||this._vb.getFloat32Array(),h=this._vb._uint32Array,o=0,l=e.length/2,u=0;u0.0){\r clpos.x+=mmat[3].x; //tx \u6700\u7B80\u5355\u5904\u7406\r clpos.y+=mmat[3].y; //ty\r }\r #endif\r vec2 clippos = pos.xy - clpos; //pos\u5DF2\u7ECF\u5E94\u7528\u77E9\u9635\u4E86\uFF0C\u4E3A\u4E86\u51CF\u7684\u6709\u610F\u4E49\uFF0Cclip\u7684\u4F4D\u7F6E\u4E5F\u8981\u7F29\u653E\r if(clipw>20000. && cliph>20000.)\r cliped = vec2(0.5,0.5);\r else {\r //\u8F6C\u62100\u52301\u4E4B\u95F4\u3002/clipw/clipw \u8868\u793Aclippos\u4E0Enormalize\u4E4B\u540E\u7684clip\u671D\u5411\u70B9\u79EF\u4E4B\u540E\uFF0C\u518D\u9664\u4EE5clipw\r cliped=vec2( dot(clippos,clipMatDir.xy)/clipw/clipw, dot(clippos,clipMatDir.zw)/cliph/cliph);\r }\r \r }`,qs=`/*\r texture\u548Cfillrect\u4F7F\u7528\u7684\u3002\r */\r #if defined(GL_FRAGMENT_PRECISION_HIGH)//\xA0\u539F\u6765\u7684\u5199\u6CD5\u4F1A\u88AB\u6211\u4EEC\u81EA\u5DF1\u7684\u89E3\u6790\u6D41\u7A0B\u5904\u7406\uFF0C\u800C\u6211\u4EEC\u7684\u89E3\u6790\u662F\u4E0D\u8BA4\u5185\u7F6E\u5B8F\u7684\uFF0C\u5BFC\u81F4\u88AB\u5220\u6389\uFF0C\u6240\u4EE5\u6539\u6210\xA0if\xA0defined\xA0\u4E86\r precision highp float;\r #else\r precision mediump float;\r #endif\r \r varying vec4 v_texcoordAlpha;\r varying vec4 v_color;\r varying float v_useTex;\r uniform sampler2D texture;\r varying vec2 cliped;\r \r #ifdef BLUR_FILTER\r uniform vec4 strength_sig2_2sig2_gauss1;//TODO\u6A21\u7CCA\u7684\u8FC7\u7A0B\u4E2D\u4F1A\u5BFC\u81F4\u53D8\u6697\u53D8\u4EAE \r uniform vec2 blurInfo;\r \r #define PI 3.141593\r \r float getGaussian(float x, float y){\r return strength_sig2_2sig2_gauss1.w*exp(-(x*x+y*y)/strength_sig2_2sig2_gauss1.z);\r }\r \r vec4 blur(){\r const float blurw = 9.0;\r vec4 vec4Color = vec4(0.0,0.0,0.0,0.0);\r vec2 halfsz=vec2(blurw,blurw)/2.0/blurInfo; \r vec2 startpos=v_texcoordAlpha.xy-halfsz;\r vec2 ctexcoord = startpos;\r vec2 step = 1.0/blurInfo; //\u6BCF\u4E2A\u50CF\u7D20 \r \r for(float y = 0.0;y<=blurw; ++y){\r ctexcoord.x=startpos.x;\r for(float x = 0.0;x<=blurw; ++x){\r //TODO \u7EB9\u7406\u5750\u6807\u7684\u56FA\u5B9A\u504F\u79FB\u5E94\u8BE5\u5728vs\u4E2D\u5904\u7406\r vec4Color += texture2D(texture, ctexcoord)*getGaussian(x-blurw/2.0,y-blurw/2.0);\r ctexcoord.x+=step.x;\r }\r ctexcoord.y+=step.y;\r }\r //vec4Color.w=1.0; \u8FD9\u4E2A\u4F1A\u5BFC\u81F4\u4E22\u5931alpha\u3002\u4EE5\u540E\u6709\u65F6\u95F4\u518D\u627E\u6A21\u7CCA\u4F1A\u5BFC\u81F4\u900F\u660E\u7684\u95EE\u9898\r return vec4Color;\r }\r #endif\r \r #ifdef COLOR_FILTER\r uniform vec4 colorAlpha;\r uniform mat4 colorMat;\r #endif\r \r #ifdef GLOW_FILTER\r uniform vec4 u_color;\r uniform vec4 u_blurInfo1;\r uniform vec4 u_blurInfo2;\r #endif\r \r #ifdef COLOR_ADD\r uniform vec4 colorAdd;\r #endif\r \r #ifdef FILLTEXTURE \r uniform vec4 u_TexRange;//startu,startv,urange, vrange\r #endif\r void main() {\r if(cliped.x<0.) discard;\r if(cliped.x>1.) discard;\r if(cliped.y<0.) discard;\r if(cliped.y>1.) discard;\r \r #ifdef FILLTEXTURE \r vec4 color= texture2D(texture, fract(v_texcoordAlpha.xy)*u_TexRange.zw + u_TexRange.xy);\r #else\r vec4 color= texture2D(texture, v_texcoordAlpha.xy);\r #endif\r \r if(v_useTex<=0.)color = vec4(1.,1.,1.,1.);\r color.a*=v_color.w;\r //color.rgb*=v_color.w;\r color.rgb*=v_color.rgb;\r gl_FragColor=color;\r \r #ifdef COLOR_ADD\r gl_FragColor = vec4(colorAdd.rgb,colorAdd.a*gl_FragColor.a);\r gl_FragColor.xyz *= colorAdd.a;\r #endif\r \r #ifdef BLUR_FILTER\r gl_FragColor = blur();\r gl_FragColor.w*=v_color.w; \r #endif\r \r #ifdef COLOR_FILTER\r mat4 alphaMat =colorMat;\r \r alphaMat[0][3] *= gl_FragColor.a;\r alphaMat[1][3] *= gl_FragColor.a;\r alphaMat[2][3] *= gl_FragColor.a;\r \r gl_FragColor = gl_FragColor * alphaMat;\r gl_FragColor += colorAlpha/255.0*gl_FragColor.a;\r #endif\r \r #ifdef GLOW_FILTER\r const float c_IterationTime = 10.0;\r float floatIterationTotalTime = c_IterationTime * c_IterationTime;\r vec4 vec4Color = vec4(0.0,0.0,0.0,0.0);\r vec2 vec2FilterDir = vec2(-(u_blurInfo1.z)/u_blurInfo2.x,-(u_blurInfo1.w)/u_blurInfo2.y);\r vec2 vec2FilterOff = vec2(u_blurInfo1.x/u_blurInfo2.x/c_IterationTime * 2.0,u_blurInfo1.y/u_blurInfo2.y/c_IterationTime * 2.0);\r float maxNum = u_blurInfo1.x * u_blurInfo1.y;\r vec2 vec2Off = vec2(0.0,0.0);\r float floatOff = c_IterationTime/2.0;\r for(float i = 0.0;i<=c_IterationTime; ++i){\r for(float j = 0.0;j<=c_IterationTime; ++j){\r vec2Off = vec2(vec2FilterOff.x * (i - floatOff),vec2FilterOff.y * (j - floatOff));\r vec4Color += texture2D(texture, v_texcoordAlpha.xy + vec2FilterDir + vec2Off)/floatIterationTotalTime;\r }\r }\r gl_FragColor = vec4(u_color.rgb,vec4Color.a * u_blurInfo2.z);\r gl_FragColor.rgb *= gl_FragColor.a; \r #endif\r \r }`,js=`attribute vec4 position;\r attribute vec4 attribColor;\r //attribute vec4 clipDir;\r //attribute vec2 clipRect;\r uniform vec4 clipMatDir;\r uniform vec2 clipMatPos;\r #ifdef WORLDMAT\r uniform mat4 mmat;\r #endif\r uniform mat4 u_mmat2;\r //uniform vec2 u_pos;\r uniform vec2 size;\r varying vec4 color;\r //vec4 dirxy=vec4(0.9,0.1, -0.1,0.9);\r //vec4 clip=vec4(100.,30.,300.,600.);\r varying vec2 cliped;\r void main(){\r \r #ifdef WORLDMAT\r vec4 pos=mmat*vec4(position.xy,0.,1.);\r gl_Position =vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\r #else\r gl_Position =vec4((position.x/size.x-0.5)*2.0,(0.5-position.y/size.y)*2.0,position.z,1.0);\r #endif \r float clipw = length(clipMatDir.xy);\r float cliph = length(clipMatDir.zw);\r vec2 clippos = position.xy - clipMatPos.xy; //pos\u5DF2\u7ECF\u5E94\u7528\u77E9\u9635\u4E86\uFF0C\u4E3A\u4E86\u51CF\u7684\u6709\u610F\u4E49\uFF0Cclip\u7684\u4F4D\u7F6E\u4E5F\u8981\u7F29\u653E\r if(clipw>20000. && cliph>20000.)\r cliped = vec2(0.5,0.5);\r else {\r //clipdir\u662F\u5E26\u7F29\u653E\u7684\u65B9\u5411\uFF0C\u7531\u4E8E\u4E0A\u9762clippos\u662F\u5728\u7F29\u653E\u540E\u7684\u7A7A\u95F4\u8BA1\u7B97\u7684\uFF0C\u6240\u4EE5\u9700\u8981\u628A\u65B9\u5411\u5148normalize\u4E00\u4E0B\r cliped=vec2( dot(clippos,clipMatDir.xy)/clipw/clipw, dot(clippos,clipMatDir.zw)/cliph/cliph);\r }\r //pos2d.x = dot(clippos,dirx);\r color=attribColor/255.;\r }`,Qs=`precision mediump float;\r //precision mediump float;\r varying vec4 color;\r //uniform float alpha;\r varying vec2 cliped;\r void main(){\r //vec4 a=vec4(color.r, color.g, color.b, 1);\r //a.a*=alpha;\r gl_FragColor= color;// vec4(color.r, color.g, color.b, alpha);\r gl_FragColor.rgb*=color.a;\r if(cliped.x<0.) discard;\r if(cliped.x>1.) discard;\r if(cliped.y<0.) discard;\r if(cliped.y>1.) discard;\r }`,Zs=`attribute vec2 position;\r attribute vec2 texcoord;\r attribute vec4 color;\r uniform vec2 size;\r uniform float offsetX;\r uniform float offsetY;\r uniform mat4 mmat;\r uniform mat4 u_mmat2;\r varying vec2 v_texcoord;\r varying vec4 v_color;\r void main() {\r vec4 pos=mmat*u_mmat2*vec4(offsetX+position.x,offsetY+position.y,0,1 );\r gl_Position = vec4((pos.x/size.x-0.5)*2.0,(0.5-pos.y/size.y)*2.0,pos.z,1.0);\r v_color = color;\r v_color.rgb *= v_color.a;\r v_texcoord = texcoord; \r }`,$s=`precision mediump float;\r varying vec2 v_texcoord;\r varying vec4 v_color;\r uniform sampler2D texture;\r uniform float alpha;\r void main() {\r vec4 t_color = texture2D(texture, v_texcoord);\r gl_FragColor = t_color.rgba * v_color;\r gl_FragColor *= alpha;\r }`;class Qi{constructor(){this.ALPHA=1,this.defines=new V,this.shaderType=0,this.fillStyle=be.DEFAULT,this.strokeStyle=be.DEFAULT}destroy(){this.defines=null,this.filters=null}static __init__(){bt.preCompile2D(0,V.TEXTURE2D,Ks,qs,null),bt.preCompile2D(0,V.PRIMITIVE,js,Qs,null),bt.preCompile2D(0,V.SKINMESH,Zs,$s,null)}}class fi{constructor(){var t=I.instance;this.ib=Fi.create(t.DYNAMIC_DRAW),this.vb=Li.create(8)}static getInstance(){return fi.instance=fi.instance||new fi}addSkinMesh(t){t.getData2(this.vb,this.ib,this.vb._byteLength/32)}reset(){this.vb.clear(),this.ib.clear()}}class bi{static createLine2(t,e,i,s,r,a){if(t.length<4)return null;var n=bi.tempData.length>t.length+2?bi.tempData:new Array(t.length+2);n[0]=t[0],n[1]=t[1];var h=2,o=0,l=t.length;for(o=2;o.01&&(n[h++]=t[o],n[h++]=t[o+1]);a&&Math.abs(t[0]-n[h-2])+Math.abs(t[1]-n[h-1])>.01&&(n[h++]=t[0],n[h++]=t[1]);var u=r;l=h/2;var _=i/2,f,p,m,g,y,C,w,M,R,B,k,z,S,dt,Mt,nt,pt,Qt,Ot,ht;for(m=n[0],g=n[1],y=n[2],C=n[3],R=-(g-C),B=m-y,ht=Math.sqrt(R*R+B*B),R=R/ht*_,B=B/ht*_,u.push(m-R,g-B,m+R,g+B),o=1;o.001&&(m=M*4,w[m]=l,w[m+1]=u,w[m+2]=g/p,w[m+3]=y/p,M++));for(s?(l=h[o-2],u=h[o-1],_=h[0],f=h[1],g=_-l,y=f-u,g!=0&&y!=0&&(p=Math.sqrt(g*g+y*y),p>.001&&(m=M*4,w[m]=l,w[m+1]=u,w[m+2]=g/p,w[m+3]=y/p,M++))):(m=M*4,w[m]=l,w[m+1]=u,w[m+2]=g/p,w[m+3]=y/p,M++),R=0,B=0;B80*i){h=l=t[0],o=u=t[1];for(var m=i;ml&&(l=_),f>u&&(u=f);p=Math.max(l-h,u-o),p=p!==0?1/p:0}return H.earcutLinked(a,n,i,h,o,p),n}static linkedList(t,e,i,s,r){var a,n;if(r===H.signedArea(t,e,i,s)>0)for(a=e;a=e;a-=s)n=H.insertNode(a,t[a],t[a+1],n);return n&&H.equals(n,n.next)&&(H.removeNode(n),n=n.next),n}static filterPoints(t,e){if(!t)return t;e||(e=t);var i=t,s;do if(s=!1,!i.steiner&&(H.equals(i,i.next)||H.area(i.prev,i,i.next)===0)){if(H.removeNode(i),i=e=i.prev,i===i.next)break;s=!0}else i=i.next;while(s||i!==e);return e}static earcutLinked(t,e,i,s,r,a,n=null){if(t){!n&&a&&H.indexCurve(t,s,r,a);for(var h=t,o,l;t.prev!==t.next;){if(o=t.prev,l=t.next,a?H.isEarHashed(t,s,r,a):H.isEar(t)){e.push(o.i/i),e.push(t.i/i),e.push(l.i/i),H.removeNode(t),t=l.next,h=l.next;continue}if(t=l,t===h){n?n===1?(t=H.cureLocalIntersections(t,e,i),H.earcutLinked(t,e,i,s,r,a,2)):n===2&&H.splitEarcut(t,e,i,s,r,a):H.earcutLinked(H.filterPoints(t,null),e,i,s,r,a,1);break}}}}static isEar(t){var e=t.prev,i=t,s=t.next;if(H.area(e,i,s)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(H.pointInTriangle(e.x,e.y,i.x,i.y,s.x,s.y,r.x,r.y)&&H.area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}static isEarHashed(t,e,i,s){var r=t.prev,a=t,n=t.next;if(H.area(r,a,n)>=0)return!1;for(var h=r.xa.x?r.x>n.x?r.x:n.x:a.x>n.x?a.x:n.x,u=r.y>a.y?r.y>n.y?r.y:n.y:a.y>n.y?a.y:n.y,_=H.zOrder(h,o,e,i,s),f=H.zOrder(l,u,e,i,s),p=t.nextZ;p&&p.z<=f;){if(p!==t.prev&&p!==t.next&&H.pointInTriangle(r.x,r.y,a.x,a.y,n.x,n.y,p.x,p.y)&&H.area(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=_;){if(p!==t.prev&&p!==t.next&&H.pointInTriangle(r.x,r.y,a.x,a.y,n.x,n.y,p.x,p.y)&&H.area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}static cureLocalIntersections(t,e,i){var s=t;do{var r=s.prev,a=s.next.next;!H.equals(r,a)&&H.intersects(r,s,s.next,a)&&H.locallyInside(r,a)&&H.locallyInside(a,r)&&(e.push(r.i/i),e.push(s.i/i),e.push(a.i/i),H.removeNode(s),H.removeNode(s.next),s=t=a),s=s.next}while(s!==t);return s}static splitEarcut(t,e,i,s,r,a){var n=t;do{for(var h=n.next.next;h!==n.prev;){if(n.i!==h.i&&H.isValidDiagonal(n,h)){var o=H.splitPolygon(n,h);n=H.filterPoints(n,n.next),o=H.filterPoints(o,o.next),H.earcutLinked(n,e,i,s,r,a),H.earcutLinked(o,e,i,s,r,a);return}h=h.next}n=n.next}while(n!==t)}static eliminateHoles(t,e,i,s){var r=[],a,n,h,o,l;for(a=0,n=e.length;a=i.next.y&&i.next.y!==i.y){var h=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(h<=s&&h>a){if(a=h,h===s){if(r===i.y)return i;if(r===i.next.y)return i.next}n=i.x=i.x&&i.x>=l&&s!==i.x&&H.pointInTriangle(rn.x)&&H.locallyInside(i,t)&&(n=i,_=f)),i=i.next;return n}static indexCurve(t,e,i,s){var r=t;do r.z===null&&(r.z=H.zOrder(r.x,r.y,e,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,H.sortLinked(r)}static sortLinked(t){var e,i,s,r,a,n,h,o,l=1;do{for(i=t,t=null,a=null,n=0;i;){for(n++,s=i,h=0,e=0;e0||o>0&&s;)h!==0&&(o===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,h--):(r=s,s=s.nextZ,o--),a?a.nextZ=r:t=r,r.prevZ=a,a=r;i=s}a.nextZ=null,l*=2}while(n>1);return t}static zOrder(t,e,i,s,r){return t=32767*(t-i)*r,e=32767*(e-s)*r,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}static getLeftmost(t){var e=t,i=t;do e.x=0&&(t-n)*(s-h)-(i-n)*(e-h)>=0&&(i-n)*(a-h)-(r-n)*(s-h)>=0}static isValidDiagonal(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!H.intersectsPolygon(t,e)&&H.locallyInside(t,e)&&H.locallyInside(e,t)&&H.middleInside(t,e)}static area(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}static equals(t,e){return t.x===e.x&&t.y===e.y}static intersects(t,e,i,s){return H.equals(t,e)&&H.equals(i,s)||H.equals(t,s)&&H.equals(i,e)?!0:H.area(t,e,i)>0!=H.area(t,e,s)>0&&H.area(i,s,t)>0!=H.area(i,s,e)>0}static intersectsPolygon(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&H.intersects(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}static locallyInside(t,e){return H.area(t.prev,t,t.next)<0?H.area(t,e,t.next)>=0&&H.area(t,t.prev,e)>=0:H.area(t,e,t.prev)<0||H.area(t,t.next,e)<0}static middleInside(t,e){var i=t,s=!1,r=(t.x+e.x)/2,a=(t.y+e.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&r<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next;while(i!==t);return s}static splitPolygon(t,e){var i=new Zi(t.i,t.x,t.y),s=new Zi(e.i,e.x,e.y),r=t.next,a=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,s.next=i,i.prev=s,a.next=s,s.prev=a,s}static insertNode(t,e,i,s){var r=new Zi(t,e,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}static removeNode(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}static signedArea(t,e,i,s){for(var r=0,a=e,n=i-s;a0&&(this._tex!=e||this._imgId!=i||this._clipid>=0&&this._clipid!=t._clipInfoID)&&this.submit(t),this._clipid=t._clipInfoID,t._globalClipMatrix.copyTo(this._clipMatrix),this._tex=e,this._imgId=i,this._colorFiler=t._colorFiler,this._data[this._ndata]=s,this._data[this._ndata+1]=r,this._data[this._ndata+2]=a,this._ndata+=3}getPos(){return Fe.__nPosPool==0?new Array(8):Fe.__posPool[--Fe.__nPosPool]}enable(t,e){t!==this._enable&&(this._enable=t,this._enable||this.submit(e))}submit(t){var e=this._ndata;if(e){var i=t._mesh,s=t._colorFiler;t._colorFiler=this._colorFiler;var r=le.create(t,i,vt.create(V.TEXTURE2D,0));t._submits[t._submits._length++]=t._curSubmit=r,r.shaderValue.textureHost=this._tex,r._key.other=this._imgId,t._colorFiler=s,t._copyClipInfo(r,this._clipMatrix),r.clipInfoID=this._clipid;for(var a=0;athis._width||e>this._height)return!1;for(var s=-1,r=-1,a=this._width,n=this._height,h=this._cells,o=0;o=i),this._rowInfo[h]-=i;for(var o=0;o0)for(h=0;h=0&&this._cells[((e+h)*a+o)*3]==0;--o,++u);for(o=u;o>0;--o)this._cells[((e+h)*a+t-o)*3+1]=o,this._check(o>0)}if(e>0)for(o=t;o=0&&this._cells[(o+h*a)*3]==0;--h,u++);for(h=u;h>0;--h)this._cells[(o+(e-h)*a)*3+2]=h,this._check(h>0)}this._used+=i*s/(this._width*this._height)}_check(t){t==!1&&console.log("xtexMerger \u9519\u8BEF\u5566")}_clear(){this._texCount=0;for(var t=0;t=Pt.gTextRender.checkCleanTextureDt){for(var e=0;e=Pt.gTextRender.destroyUnusedTextureDt&&(i.destroy(),Pt.pool[e]=Pt.pool[Pt.poolLen-1],Pt.poolLen--,e--)}Pt.cleanTm=t}}touchRect(t,e){this.lastTouchTm!=e&&(this.curUsedCovRate=0,this.curUsedCovRateAtlas=0,this.lastTouchTm=e);var i=Pt.gTextRender.atlasWidth*Pt.gTextRender.atlasWidth,s=c.TextAtlas.atlasGridW*c.TextAtlas.atlasGridW;this.curUsedCovRate+=t.bmpWidth*t.bmpHeight/i,this.curUsedCovRateAtlas+=Math.ceil(t.bmpWidth/c.TextAtlas.atlasGridW)*Math.ceil(t.bmpHeight/c.TextAtlas.atlasGridW)/(i/s)}get texture(){return this}_getSource(){return this._source}drawOnScreen(t,e){}}Pt.gTextRender=null,Pt.pool=new Array(10),Pt.poolLen=0,Pt.cleanTm=0;class Ae{constructor(){this.texWidth=1024,this.texHeight=1024,this.texture=null,this.charMaps={},this.texHeight=this.texWidth=c.TextRender.atlasWidth,this.texture=Pt.getTextTexture(this.texWidth,this.texHeight),this.texWidth/Ae.atlasGridW>256&&(Ae.atlasGridW=Math.ceil(this.texWidth/256)),this.atlasgrid=new Ps(this.texWidth/Ae.atlasGridW,this.texHeight/Ae.atlasGridW,this.texture.id)}setProtecteDist(t){}getAEmpty(t,e,i){var s=this.atlasgrid.addRect(1,Math.ceil(t/Ae.atlasGridW),Math.ceil(e/Ae.atlasGridW),i);return s&&(i.x*=Ae.atlasGridW,i.y*=Ae.atlasGridW),s}get usedRate(){return this.atlasgrid._used}destroy(){for(var t in this.charMaps){var e=this.charMaps[t];e.deleted=!0}this.texture.discard()}printDebugInfo(){}}Ae.atlasGridW=16;class T{setTo(t,e,i){return this.type=t,this.currentTarget=e,this.target=i,this}stopPropagation(){this._stoped=!0}get touches(){if(!this.nativeEvent)return null;var t=this.nativeEvent.touches;if(t)for(var e=c.stage,i=0,s=t.length;if.width&&(s=f.width-e),f.height&&i+r>f.height&&(r=f.height-i);var p;l?(p=l,p.setTo(f,null,h||s,o||r)):p=new ut(f,null,h||s,o||r),p.width=s,p.height=r,p.offsetX=a,p.offsetY=n;var m=1/f.width,g=1/f.height;e*=m,i*=g,s*=m,r*=g;var y=p.uv[0],C=p.uv[1],w=p.uv[4],M=p.uv[5],R=w-y,B=M-C,k=ut.moveUV(_[0],_[1],[e,i,e+s,i,e+s,i+r,e,i+r]);p.uv=new Float32Array([y+k[0]*R,C+k[1]*B,w-(1-k[2])*R,C+k[3]*B,w-(1-k[4])*R,M-(1-k[5])*B,y+k[6]*R,M-(1-k[7])*B]);var z=f.scaleRate;return z&&z!=1?(p.sourceWidth/=z,p.sourceHeight/=z,p.width/=z,p.height/=z,p.scaleRate=z,p.offsetX/=z,p.offsetY/=z):p.scaleRate=1,p}static createFromTexture(t,e,i,s,r){var a=t.scaleRate;a!=1&&(e*=a,i*=a,s*=a,r*=a);var n=tt.TEMP.setTo(e-t.offsetX,i-t.offsetY,s,r),h=n.intersection(ut._rect1.setTo(0,0,t.width,t.height),ut._rect2);if(h)var o=ut.create(t,h.x,h.y,h.width,h.height,h.x-n.x,h.y-n.y,s,r);else return null;return o}get uv(){return this._uv}set uv(t){this.uvrect[0]=Math.min(t[0],t[2],t[4],t[6]),this.uvrect[1]=Math.min(t[1],t[3],t[5],t[7]),this.uvrect[2]=Math.max(t[0],t[2],t[4],t[6])-this.uvrect[0],this.uvrect[3]=Math.max(t[1],t[3],t[5],t[7])-this.uvrect[1],this._uv=t}get width(){return this._w?this._w:this.bitmap?this.uv&&this.uv!==ut.DEF_UV?(this.uv[2]-this.uv[0])*this.bitmap.width:this.bitmap.width:0}set width(t){this._w=t,this.sourceWidth||(this.sourceWidth=t)}get height(){return this._h?this._h:this.bitmap?this.uv&&this.uv!==ut.DEF_UV?(this.uv[5]-this.uv[1])*this.bitmap.height:this.bitmap.height:0}set height(t){this._h=t,this.sourceHeight||(this.sourceHeight=t)}get bitmap(){return this._bitmap}set bitmap(t){this._bitmap&&this._bitmap._removeReference(this._referenceCount),this._bitmap=t,t&&t._addReference(this._referenceCount)}get destroyed(){return this._destroyed}_addReference(){this._bitmap&&this._bitmap._addReference(),this._referenceCount++}_removeReference(){this._bitmap&&this._bitmap._removeReference(),this._referenceCount--}_getSource(t=null){return this._destroyed||!this._bitmap?null:(this.recoverBitmap(t),this._bitmap.destroyed?null:this.bitmap._getSource())}_onLoaded(t,e){if(e&&e!=this)if(e instanceof ut){var i=e;ut._create(e,0,0,i.width,i.height,0,0,i.sourceWidth,i.sourceHeight,this)}else this.bitmap=e,this.sourceWidth=this._w=e.width,this.sourceHeight=this._h=e.height;t&&t.run(),this.event(T.READY,this)}getIsReady(){return this._destroyed?!1:!!this._bitmap}setTo(t=null,e=null,i=0,s=0){this.bitmap=t,this.sourceWidth=i,this.sourceHeight=s,t&&(this._w=t.width,this._h=t.height,this.sourceWidth=this.sourceWidth||t.width,this.sourceHeight=this.sourceHeight||t.height),this.uv=e||ut.DEF_UV}load(t,e=null){this._destroyed||c.loader.load(t,mt.create(this,this._onLoaded,[e]),null,"htmlimage",1,!0)}getTexturePixels(t,e,i,s){var r,a,n,h=this.bitmap,o=this._w,l=this._h,u=this.sourceWidth,_=this.sourceHeight,f=h.width,p=h.height,m=this.offsetX,g=this.offsetY;let y=i,C=s;if(t+i>o+m&&(y-=t+i-o-m),t+i>u&&(i-=t+i-u),e+s>l+g&&(C-=e+s-l-g),e+s>_&&(s-=e+s-_),i<=0||s<=0)return null;let w=m>t?m-t:0,M=g>e?g-e:0,R=t>m?t-m:0,B=e>g?e-g:0;y-=w,C-=M;var k=i*4,z=null;try{z=h.getPixels()}catch{}if(z){if(t==0&&e==0&&i==f&&s==p)return z;let At=this._uv.slice(),Re=Math.round(At[0]*f),Vi=Math.round(At[1]*p);var S=new Uint8Array(i*s*4);for(k=f*4,a=(Vi+B)*k,r=Re*4+R*4+a,n=0;n=0;n--)S.set(Ct.slice(a,a+k),r),r+=k,a-=k;return S}getPixels(t,e,i,s){return this.getTexturePixels(t,e,i,s)}recoverBitmap(t=null){var e=this._bitmap.url;if(!this._destroyed&&(!this._bitmap||this._bitmap.destroyed)&&e){let i=c.Loader.loadedMap[e];i?(this.bitmap=i,t&&t()):c.loader.load(e,mt.create(this,s=>{this.bitmap=s,t&&t()}),null,"htmlimage",1,!0)}}disposeBitmap(){!this._destroyed&&this._bitmap&&this._bitmap.destroy()}destroy(t=!1){if(!this._destroyed){this._destroyed=!0;var e=this._bitmap;e&&(e._removeReference(this._referenceCount),(e.referenceCount===0||t)&&e.destroy(),e=null),this.url&&this===c.loader.getRes(this.url)&&c.Loader.clearRes(this.url)}}}ut.DEF_UV=new Float32Array([0,0,1,0,1,1,0,1]),ut.NO_UV=new Float32Array([0,0,0,0,0,0,0,0]),ut.INV_UV=new Float32Array([0,1,1,1,1,0,0,0]),ut._rect1=new tt,ut._rect2=new tt;class ee{constructor(t){this._font="14px Arial",this._family="Arial",this._size=14,this._italic=!1,this._bold=!1,this._id=ee._gfontID++,this.setFont(t||this._font)}static Parse(t){if(t===ee._lastFont)return ee._lastFontInfo;var e=ee._cache[t];return e||(e=ee._cache[t]=new ee(t)),ee._lastFont=t,ee._lastFontInfo=e,e}setFont(t){this._font=t;var e=t.split(" "),i=e.length;if(i<2){i==1&&e[0].indexOf("px")>0&&(this._size=parseInt(e[0]));return}for(var s=-1,r=0;r0||e[r].indexOf("pt")>0){s=r,this._size=parseInt(e[r]),this._size<=0&&(console.error("font parse error:"+t),this._size=14);break}var a=s+1,n=e[a];for(a++;a=0,this._bold=e.indexOf("bold")>=0}}ee.EMPTY=new ee(null),ee._cache={},ee._gfontID=0,ee._lastFont="";class Bi{constructor(){this.save=[],this.toUpperCase=null,this.width=-1,this.pageChars=[],this.startID=0,this.startIDStroke=0,this.lastGCCnt=0,this.splitRender=!1,this.scalex=1,this.scaley=1}setText(t){this.changed=!0,this._text=t,this.width=-1,this.cleanCache()}toString(){return this._text}get length(){return this._text?this._text.length:0}charCodeAt(t){return this._text?this._text.charCodeAt(t):NaN}charAt(t){return this._text?this._text.charAt(t):null}cleanCache(){let t=this.pageChars;for(var e in t){let r=t[e];var i=r.tex,s=r.words;s.length==1&&i&&i.ri&&i.destroy()}this.pageChars=[],this.startID=0,this.scalex=1,this.scaley=1}}class us{constructor(){this.char="",this.deleted=!1,this.uv=new Array(8),this.pos=0,this.orix=0,this.oriy=0,this.touchTick=0,this.isSpace=!1}touch(){var t=ae.loopCount;this.touchTick!=t&&this.tex.touchRect(this,t),this.touchTick=t}}class cs{constructor(){this.fontsz=16}getWidth(t,e){return 0}scale(t,e){}get canvasWidth(){return 0}set canvasWidth(t){}getCharBmp(t,e,i,s,r,a,n,h,o,l,u=null){return null}}class x{static __init__(){var t=window.Laya||c.Laya;if(x._window)return x._window;var e=x._window=window,i=x._document=e.document,s=x.userAgent=e.navigator.userAgent,r=e.navigator.maxTouchPoints||0,a=e.navigator.platform;"my"in x.window&&(s.indexOf("TB/")>-1||s.indexOf("Taobao/")>-1||s.indexOf("TM/")>-1?(window.tbMiniGame(t,t),t.TBMiniAdapter?t.TBMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u6DD8\u5B9D\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-10-0")):s.indexOf("AlipayMiniGame")>-1&&(window.aliPayMiniGame(t,t),t.ALIMiniAdapter?t.ALIMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u963F\u91CC\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-6-0"))),s.indexOf("OPPO")==-1&&s.indexOf("MiniGame")>-1&&"wx"in x.window&&("tt"in x.window?(window.ttMiniGame(t,t),t.TTMiniAdapter?t.TTMiniAdapter.enable():console.error("\u8BF7\u5F15\u5165\u5B57\u8282\u8DF3\u52A8\u5C0F\u6E38\u620F\u7684\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-8-0")):"bl"in x.window?(window.biliMiniGame(t,t),t.BLMiniAdapter?t.BLMiniAdapter.enable():console.error("\u8BF7\u5F15\u5165bilibili\u5C0F\u6E38\u620F\u7684\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-7-0")):"qq"in x.window?(window.qqMiniGame(t,t),t.QQMiniAdapter?t.QQMiniAdapter.enable():console.error("\u8BF7\u5F15\u5165\u624B\u673AQQ\u5C0F\u6E38\u620F\u7684\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-5-0")):(window.wxMiniGame(t,t),t.MiniAdpter?t.MiniAdpter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?nav=zh-ts-5-0-0"))),"hbs"in x.window&&(window.hwMiniGame(t,t),t.HWMiniAdapter?t.HWMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u5C0F\u6E38\u620F\u9002\u914D\u5E93\uFF0C\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-9-1")),s.indexOf("SwanGame")>-1&&(window.bdMiniGame(t,t),t.BMiniAdapter?t.BMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u767E\u5EA6\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-1-0")),s.indexOf("QuickGame")>-1&&(window.miMiniGame(t,t),t.KGMiniAdapter?t.KGMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0\u5C0F\u7C73\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-2-0")),s.indexOf("OPPO")>-1&&s.indexOf("MiniGame")>-1&&(window.qgMiniGame(t,t),t.QGMiniAdapter?t.QGMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0OPPO\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-3-0")),s.indexOf("VVGame")>-1&&(window.vvMiniGame(t,t),t.VVMiniAdapter?t.VVMiniAdapter.enable():console.error("\u8BF7\u5148\u6DFB\u52A0vivo\u5C0F\u6E38\u620F\u9002\u914D\u5E93,\u8BE6\u7EC6\u6559\u7A0B\uFF1Ahttps://ldc2.layabox.com/doc/?language=zh&nav=zh-ts-5-4-0")),e.trace=console.log,e.requestAnimationFrame=e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(f){return e.setTimeout(f,1e3/60)};var n=i.body.style;n.margin=0,n.overflow="hidden",n["-webkit-user-select"]="none",n["-webkit-tap-highlight-color"]="rgba(200,200,200,0)";for(var h=i.getElementsByTagName("meta"),o=0,l=!1,u="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no";o-1,x.onIOS=!!s.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),x.onIPhone=s.indexOf("iPhone")>-1,x.onMac=s.indexOf("Mac OS X")>-1,x.onIPad=s.indexOf("iPad")>-1||a==="MacIntel"&&r>1,x.onAndroid=s.indexOf("Android")>-1||s.indexOf("Adr")>-1,x.onWP=s.indexOf("Windows Phone")>-1,x.onQQBrowser=s.indexOf("QQBrowser")>-1,x.onMQQBrowser=s.indexOf("MQQBrowser")>-1||s.indexOf("Mobile")>-1&&s.indexOf("QQ")>-1,x.onIE=!!e.ActiveXObject||"ActiveXObject"in e,x.onWeiXin=s.indexOf("MicroMessenger")>-1,x.onSafari=s.indexOf("Safari")>-1,x.onChrome=s.indexOf("Chrome")>-1,x.onPC=!x.onMobile,x.onFirefox=s.indexOf("Firefox")>-1,x.onEdge=s.indexOf("Edge")>-1,x.onMiniGame=s.indexOf("MiniGame")>-1,x.onBDMiniGame=s.indexOf("SwanGame")>-1,x.onLayaRuntime=!!window.conch,s.indexOf("OPPO")>-1&&s.indexOf("MiniGame")>-1?(x.onQGMiniGame=!0,x.onMiniGame=!1):"qq"in x.window&&s.indexOf("MiniGame")>-1?(x.onQQMiniGame=!0,x.onMiniGame=!1):"bl"in x.window&&s.indexOf("MiniGame")>-1?(x.onBLMiniGame=!0,x.onMiniGame=!1):"tt"in x.window&&s.indexOf("MiniGame")>-1&&(x.onTTMiniGame=!0,x.onMiniGame=!1),x.onHWMiniGame="hbs"in x.window,x.onVVMiniGame=s.indexOf("VVGame")>-1,x.onKGMiniGame=s.indexOf("QuickGame")>-1,s.indexOf("AlipayMiniGame")>-1&&(x.onAlipayMiniGame=!0,x.onMiniGame=!1),(s.indexOf("TB/")>-1||s.indexOf("Taobao/")>-1||s.indexOf("TM/")>-1)&&(x.onTBMiniGame=!0),e}static get _isMiniGame(){return x.onMiniGame||x.onBDMiniGame||x.onQGMiniGame||x.onKGMiniGame||x.onVVMiniGame||x.onAlipayMiniGame||x.onQQMiniGame||x.onBLMiniGame||x.onTTMiniGame||x.onHWMiniGame||x.onTBMiniGame}static createElement(t){return x.__init__(),x._document.createElement(t)}static getElementById(t){return x.__init__(),x._document.getElementById(t)}static removeElement(t){t&&t.parentNode&&t.parentNode.removeChild(t)}static now(){return Date.now()}static get clientWidth(){return x.__init__(),x._window.innerWidth||x._document.body.clientWidth}static get clientHeight(){return x.__init__(),x._window.innerHeight||x._document.body.clientHeight||x._document.documentElement.clientHeight}static get width(){return x.__init__(),(c.stage&&c.stage.canvasRotation?x.clientHeight:x.clientWidth)*x.pixelRatio}static get height(){return x.__init__(),(c.stage&&c.stage.canvasRotation?x.clientWidth:x.clientHeight)*x.pixelRatio}static get pixelRatio(){return x._pixelRatio<0&&(x.__init__(),x.userAgent.indexOf("Mozilla/6.0(Linux; Android 6.0; HUAWEI NXT-AL10 Build/HUAWEINXT-AL10)")>-1?x._pixelRatio=2:(x._pixelRatio=x._window.devicePixelRatio||1,x._pixelRatio<1&&(x._pixelRatio=1))),x._pixelRatio}static get container(){return x._container||(x.__init__(),x._container=x.createElement("div"),x._container.id="layaContainer",x._document.body.appendChild(x._container)),x._container}static set container(t){x._container=t}static get window(){return x._window||x.__init__()}static get document(){return x.__init__(),x._document}}x._pixelRatio=-1,x.mainCanvas=null,x.hanzi=new RegExp("^[\u4E00-\u9FA5]$"),x.fontMap={},x.measureText=function(v,t){var e=x.hanzi.test(v);if(e&&x.fontMap[t])return x.fontMap[t];var i=x.context;i.font=t;var s=i.measureText(v);return e&&(x.fontMap[t]=s),s};class Zt extends cs{constructor(t,e,i=!0,s=!0,r=!1){super(),this.ctx=null,this.lastScaleX=1,this.lastScaleY=1,this.maxTexW=0,this.maxTexH=0,this.scaleFontSize=!0,this.showDbgInfo=!1,this.supportImageData=!0,this.maxTexW=t,this.maxTexH=e,this.scaleFontSize=i,this.supportImageData=s,this.showDbgInfo=r,Zt.canvas||(Zt.canvas=x.createElement("canvas"),Zt.canvas.width=1024,Zt.canvas.height=512,Zt.canvas.style.left="-10000px",Zt.canvas.style.position="absolute",window.document.body.appendChild(Zt.canvas),this.ctx=Zt.canvas.getContext("2d"))}get canvasWidth(){return Zt.canvas.width}set canvasWidth(t){Zt.canvas.width!=t&&(Zt.canvas.width=t,t>2048&&console.warn("\u753B\u6587\u5B57\u8BBE\u7F6E\u7684\u5BBD\u5EA6\u592A\u5927\uFF0C\u8D85\u8FC72048\u4E86"),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.lastScaleX,this.lastScaleY))}getWidth(t,e){return this.ctx?(this.ctx._lastFont!=t&&(this.ctx.font=t,this.ctx._lastFont=t),this.ctx.measureText(e).width):0}scale(t,e){if(!this.supportImageData){this.lastScaleX=t,this.lastScaleY=e;return}(this.lastScaleX!=t||this.lastScaleY!=e)&&(this.ctx.setTransform(t,0,0,e,0,0),this.lastScaleX=t,this.lastScaleY=e)}getCharBmp(t,e,i,s,r,a,n,h,o,l,u=null){if(!this.supportImageData)return this.getCharCanvas(t,e,i,s,r,a,n,h,o,l);var _=this.ctx,f=this.fontsz;_.font!=e&&(_.font=e,_._lastFont=e),a.width=_.measureText(t).width;var p=a.width*this.lastScaleX,m=a.height*this.lastScaleY;p+=(n+o)*this.lastScaleX,m+=(h+l)*this.lastScaleY,p=Math.ceil(p),m=Math.ceil(m),p=Math.min(p,Zt.canvas.width),m=Math.min(m,Zt.canvas.height);var g=p+i*2+1,y=m+i*2+1;u&&(g=Math.max(g,u[0]+u[2]+1),y=Math.max(y,u[1]+u[3]+1)),_.clearRect(0,0,g/this.lastScaleX+1,y/this.lastScaleY+1),_.save(),_.textBaseline="middle",i>0&&(_.lineJoin="round",_.strokeStyle=r,_.lineWidth=i,_.strokeText(t,n,h+f/2)),s&&(_.fillStyle=s,_.fillText(t,n,h+f/2)),this.showDbgInfo&&(_.strokeStyle="#ff0000",_.strokeRect(1,1,p-2,m-2),_.strokeStyle="#00ff00",_.strokeRect(n,h,a.width,a.height)),u&&(u[2]==-1&&(u[2]=Math.ceil((a.width+i*2)*this.lastScaleX)),u[2]<=0&&(u[2]=1));var C=u?_.getImageData(u[0],u[1],u[2],u[3]+1):_.getImageData(0,0,p,m+1);return _.restore(),a.bmpWidth=C.width,a.bmpHeight=C.height,C}getCharCanvas(t,e,i,s,r,a,n,h,o,l){var u=this.ctx;u.font!=e&&(u.font=e,u._lastFont=e),a.width=u.measureText(t).width;var _=a.width*this.lastScaleX,f=a.height*this.lastScaleY;_+=(n+o)*this.lastScaleX,f+=(h+l)*this.lastScaleY+1,_=Math.min(_,this.maxTexW),f=Math.min(f,this.maxTexH),Zt.canvas.width=Math.min(_+1,this.maxTexW),Zt.canvas.height=Math.min(f+1,this.maxTexH),u.clearRect(0,0,_+1+i,f+1+i),u.setTransform(1,0,0,1,0,0),u.save(),u.font=e,this.scaleFontSize&&u.scale(this.lastScaleX,this.lastScaleY),u.translate(n,h),u.textAlign="left";var p=this.fontsz;return u.textBaseline="middle",i>0?(u.strokeStyle=r,u.fillStyle=s,u.lineWidth=i,u.fillAndStrokeText?u.fillAndStrokeText(t,0,p/2):(u.strokeText(t,0,p/2),u.fillText(t,0,p/2))):s&&(u.fillStyle=s,u.fillText(t,0,p/2)),this.showDbgInfo&&(u.strokeStyle="#ff0000",u.strokeRect(0,0,_,f),u.strokeStyle="#00ff00",u.strokeRect(0,0,a.width,a.height)),u.restore(),a.bmpWidth=Zt.canvas.width,a.bmpHeight=Zt.canvas.height,Zt.canvas}}Zt.canvas=null;class Ds extends cs{constructor(){super(),this.lastFont="",this.lastScaleX=1,this.lastScaleY=1}getWidth(t,e){return window.conchTextCanvas?(window.conchTextCanvas.font=t,this.lastFont=t,window.conchTextCanvas.measureText(e).width):0}scale(t,e){this.lastScaleX=t,this.lastScaleY=e}getCharBmp(t,e,i,s,r,a,n,h,o,l,u=null){if(!window.conchTextCanvas)return null;window.conchTextCanvas.font=e,this.lastFont=e;var _=a.width=window.conchTextCanvas.measureText(t).width,f=a.height;_+=n+o,f+=h+l,window.conchTextCanvas.scale&&window.conchTextCanvas.scale(this.lastScaleX,this.lastScaleY);var p=lt.create(r),m=p.numColor,g=lt.create(s),y=g.numColor,C=window.conchTextCanvas.getTextBitmapData(t,y,i>2?2:i,m);return a.bmpWidth=C.width,a.bmpHeight=C.height,C}}class O{constructor(){this.fontSizeInfo={},this.mapFont={},this.fontID=0,this.fontScaleX=1,this.fontScaleY=1,this._curStrPos=0,this.textAtlases=[],this.isoTextures=[],this.lastFont=null,this.fontSizeW=0,this.fontSizeH=0,this.fontSizeOffX=0,this.fontSizeOffY=0,this.renderPerChar=!0,this.tmpAtlasPos=new Tt,this.textureMem=0,c.TextAtlas=Ae;var t=!1,e=c.Laya.MiniAdpter;e&&e.systemInfo&&e.systemInfo.system&&(t=e.systemInfo.system.toLowerCase()==="ios 10.1.1"),(c.Browser.onMiniGame||c.Browser.onTTMiniGame||c.Browser.onBLMiniGame||c.Browser.onAlipayMiniGame||c.Browser.onTBMiniGame)&&!t&&(O.isWan1Wan=!0),this.charRender=c.Render.isConchApp?new Ds:new Zt(2048,2048,O.scaleFontWithCtx,!O.isWan1Wan,!1),O.textRenderInst=this,c.Laya.textRender=this,O.atlasWidth2=O.atlasWidth*O.atlasWidth}setFont(t){if(this.lastFont!=t){this.lastFont=t;var e=this.getFontSizeInfo(t._family),i=e>>24,s=e>>16&255,r=e>>8&255,a=e&255,n=t._size/O.standardFontSize;this.fontSizeOffX=Math.ceil(i*n),this.fontSizeOffY=Math.ceil(s*n),this.fontSizeW=Math.ceil(r*n),this.fontSizeH=Math.ceil(a*n),t._font.indexOf("italic")>=0?this.fontStr=t._font.replace("italic",""):this.fontStr=t._font}}getNextChar(t){var e=t.length,i=this._curStrPos;if(!t.substring||i>=e)return null;for(var s=i,r=0;s>>11==27){if(r==1)break;r=1,s++}else if(!(a===65038||a===65039)){if(a==8205)r=2;else if(r==0)r=1;else if(r==1)break}}return this._curStrPos=s,t.substring(i,s)}filltext(t,e,i,s,r,a,n,h,o,l=0){if(!(e.length<=0)){var u=ee.Parse(r),_=0;switch(o){case"center":_=c.Context.ENUM_TEXTALIGN_CENTER;break;case"right":_=c.Context.ENUM_TEXTALIGN_RIGHT;break}this._fast_filltext(t,e,null,i,s,u,a,n,h,_,l)}}fillWords(t,e,i,s,r,a,n,h){if(e&&!(e.length<=0)){var o=typeof r=="string"?ee.Parse(r):r;this._fast_filltext(t,null,e,i,s,o,a,n,h,0,0)}}_fast_filltext(t,e,i,s,r,a,n,h,o,l,u=0){if(!(e&&!(e.length>=1))&&!(i&&i.length<1)){if(o<0&&(o=0),this.setFont(a),this.fontScaleX=this.fontScaleY=1,O.scaleFontWithCtx){var _=1,f=1;if((!c.Render.isConchApp||window.conchTextCanvas.scale)&&(_=t.getMatScaleX(),f=t.getMatScaleY()),_<1e-4||f<.1)return;_>1&&(this.fontScaleX=_),f>1&&(this.fontScaleY=f)}a._italic&&(t._italicDeg=13);var p=e,m=!i&&e instanceof Bi,g=e&&e.toString(),y=!!i,C=m?p.pageChars:[],w=0;switch(m?(g=p._text,w=p.width,w<0&&(w=p.width=this.charRender.getWidth(this.fontStr,g))):w=g?this.charRender.getWidth(this.fontStr,g):0,l){case c.Context.ENUM_TEXTALIGN_CENTER:s-=w/2;break;case c.Context.ENUM_TEXTALIGN_RIGHT:s-=w;break}p&&C&&this.hasFreedText(C)&&(C=p.pageChars=[]);var M=null,R=this.renderPerChar=!m||O.forceSplitRender||y||m&&p.splitRender;if(!C||C.length<1)if(m&&(p.scalex=this.fontScaleX,p.scaley=this.fontScaleY),R){var B=0,k=0;this._curStrPos=0;for(var z;;){if(i){var S=i[this._curStrPos++];S?(z=S.char,B=S.x,k=S.y):z=null}else z=this.getNextChar(g);if(!z||(M=this.getCharRenderInfo(z,a,n,h,o,!1),!M))break;if(!M.isSpace){var dt=C[M.tex.id];if(dt)dt=dt.words;else{var Mt={texgen:M.tex.genID,tex:M.tex,words:new Array};C[M.tex.id]=Mt,dt=Mt.words}dt.push({ri:M,x:B,y:k,w:M.bmpWidth/this.fontScaleX,h:M.bmpHeight/this.fontScaleY}),B+=M.width}}}else{var nt=c.Render.isConchApp?0:a._size/3|0,pt=O.noAtlas||(w+nt+nt)*this.fontScaleX>O.atlasWidth;M=this.getCharRenderInfo(g,a,n,h,o,pt),C[0]={texgen:M.tex.genID,tex:M.tex,words:[{ri:M,x:0,y:0,w:M.bmpWidth/this.fontScaleX,h:M.bmpHeight/this.fontScaleY}]}}this._drawResortedWords(t,s,r,C),t._italicDeg=0}}_drawResortedWords(t,e,i,s){var r=t._charSubmitCache?t._charSubmitCache._enable:!1,a=t._curMat;for(var n in s){var h=s[n];if(h){var o=h.words,l=o.length;if(!(l<=0))for(var u=s[n].tex,_=0;_0&&(h+="_"+s+r),e._bold&&(h+="P"),(this.fontScaleX!=1||this.fontScaleY!=1)&&(h+=(this.fontScaleX*20|0)+"_"+(this.fontScaleY*20|0));var o=0,l=this.textAtlases.length,u,_;if(!a){for(o=0;othis.charRender.canvasWidth&&(this.charRender.canvasWidth=Math.min(2048,m+f*2)),a){if(this.charRender.fontsz=e._size,p=this.charRender.getCharBmp(t,this.fontStr,r,i,s,u,f,f,f,f,null),p){var g=Pt.getTextTexture(p.width,p.height);g.addChar(p,0,0,u.uv),u.tex=g,u.orix=f,u.oriy=f,g.ri=u,this.isoTextures.push(g)}}else{var y=t.length,C=r*1,w=Math.ceil((this.fontSizeW+C*2)*this.fontScaleX),M=Math.ceil((this.fontSizeH+C*2)*this.fontScaleY);if(O.imgdtRect[0]=(f-this.fontSizeOffX-C)*this.fontScaleX|0,O.imgdtRect[1]=(f-this.fontSizeOffY-C)*this.fontScaleY|0,this.renderPerChar||y==1?(O.imgdtRect[2]=Math.max(m,w),O.imgdtRect[3]=Math.max(m,M)):(O.imgdtRect[2]=-1,O.imgdtRect[3]=M),this.charRender.fontsz=e._size,p=this.charRender.getCharBmp(t,this.fontStr,r,i,s,u,f,f,f,f,O.imgdtRect),p)if(p.width>O.atlasWidth||p.height>O.atlasWidth){var g=Pt.getTextTexture(p.width,p.height);g.addChar(p,0,0,u.uv),u.tex=g,u.orix=f,u.oriy=f,g.ri=u,this.isoTextures.push(g)}else _=this.addBmpData(p,u),O.isWan1Wan?(u.orix=f,u.oriy=f):(u.orix=this.fontSizeOffX+C,u.oriy=this.fontSizeOffY+C),_.charMaps[h]=u}return u}addBmpData(t,e){for(var i=t.width,s=t.height,r=this.textAtlases.length,a,n=!1,h=0;hs&&(O.showLog&&console.log("TextRender GC delete atlas "+l?u.texture.id:"unk"),u.destroy(),this.textAtlases[t]=this.textAtlases[e-1],e--,t--,h=-1)}for(this.textAtlases.length=e,e=this.isoTextures.length,t=0;tO.destroyUnusedTextureDt&&(l.ri.deleted=!0,l.ri.tex=null,l.destroy(),this.isoTextures[t]=this.isoTextures[e-1],e--,t--);this.isoTextures.length=e;var f=this.textAtlases.length>1&&this.textAtlases.length-a>=2;(O.atlasWidth*O.atlasWidth*4*this.textAtlases.length>O.cleanMem||f||O.simClean)&&(O.simClean=!1,O.showLog&&console.log("\u6E05\u7406\u4F7F\u7528\u7387\u4F4E\u7684\u8D34\u56FE\u3002\u603B\u4F7F\u7528\u7387:",a,":",this.textAtlases.length,"\u6700\u5DEE\u8D34\u56FE:"+h),h>=0&&(u=this.textAtlases[h],u.destroy(),this.textAtlases[h]=this.textAtlases[this.textAtlases.length-1],this.textAtlases.length=this.textAtlases.length-1)),Pt.clean()}cleanAtlases(){}getCharBmp(t){}checkBmpLine(t,e,i,s){this.bmpData32.buffer!=t.data.buffer&&(this.bmpData32=new Uint32Array(t.data.buffer));for(var r=t.width*e+i,a=i;a=n){e[1]=o;break}this.checkBmpLine(t,o,0,s)?n=o:h=o}if(e[3]>r)e[3]=r;else if(o=n=e[3],h=r,this.checkBmpLine(t,n,0,s))for(;;){if(o=(n+h)/2|0,o-1<=n){e[3]=o;break}this.checkBmpLine(t,o,0,s)?n=o:h=o}if(!i){var l=e[0],u=s*e[1];for(o=e[1];o>24,s=e>>16&255,r=e>>8&255,a=e&255;console.log(" "+t," off:",i,s," size:",r,a)}var n=0;console.log("\u7F13\u5B58\u6570\u636E:");var h=0,o=0;this.textAtlases.forEach(function(l){var u=l.texture.id,_=ae.loopCount-l.texture.lastTouchTm,f=_>0?""+_+"\u5E27\u4EE5\u524D":"\u5F53\u524D\u5E27";h+=l.texture.curUsedCovRate,o+=l.texture.curUsedCovRateAtlas,console.log("--\u56FE\u96C6(id:"+u+",\u5F53\u524D\u4F7F\u7528\u7387:"+(l.texture.curUsedCovRate*1e3|0)+"\u2030","\u5F53\u524D\u56FE\u96C6\u4F7F\u7528\u7387:",(l.texture.curUsedCovRateAtlas*100|0)+"%","\u56FE\u96C6\u4F7F\u7528\u7387:",l.usedRate*100|0,"%, \u4F7F\u7528\u4E8E:"+f+")--:");for(var p in l.charMaps){var m=l.charMaps[p];console.log(" off:",m.orix,m.oriy," bmp\u5BBD\u9AD8:",m.bmpWidth,m.bmpHeight,"\u65E0\u6548:",m.deleted,"touchdt:",ae.loopCount-m.touchTick,"\u4F4D\u7F6E:",m.uv[0]*O.atlasWidth|0,m.uv[1]*O.atlasWidth|0,"\u5B57\u7B26:",m.char,"key:",p),n++}}),console.log("\u72EC\u7ACB\u8D34\u56FE\u6587\u5B57("+this.isoTextures.length+"\u4E2A):"),this.isoTextures.forEach(function(l){console.log(" size:",l._texW,l._texH,"touch\u95F4\u9694:",ae.loopCount-l.lastTouchTm,"char:",l.ri.char)}),console.log("\u603B\u7F13\u5B58:",n,"\u603B\u4F7F\u7528\u7387:",h,"\u603B\u5F53\u524D\u56FE\u96C6\u4F7F\u7528\u7387:",o)}showAtlas(t,e,i,s,r,a){if(!this.textAtlases[t])return console.log("\u6CA1\u6709\u8FD9\u4E2A\u56FE\u96C6"),null;var n=new c.Sprite,h=this.textAtlases[t].texture,o={width:O.atlasWidth,height:O.atlasWidth,sourceWidth:O.atlasWidth,sourceHeight:O.atlasWidth,offsetX:0,offsetY:0,getIsReady:function(){return!0},_addReference:function(){},_removeReference:function(){},_getSource:function(){return h._getSource()},bitmap:{id:h.id},_uv:ut.DEF_UV};return n.size=function(l,u){return this.width=l,this.height=u,n.graphics.clear(),n.graphics.drawRect(0,0,n.width,n.height,e),n.graphics.drawTexture(o,0,0,n.width,n.height),this},n.graphics.drawRect(0,0,r,a,e),n.graphics.drawTexture(o,0,0,r,a),n.pos(i,s),c.stage.addChild(n),n}filltext_native(t,e,i,s,r,a,n,h,o,l,u=0){if(!(e&&e.length<=0)&&!(i&&i.length<1)){var _=ee.Parse(a),f=0;switch(l){case"center":f=c.Context.ENUM_TEXTALIGN_CENTER;break;case"right":f=c.Context.ENUM_TEXTALIGN_RIGHT;break}return this._fast_filltext(t,e,i,s,r,_,n,h,o,f,u)}}}O.useOldCharBook=!1,O.atlasWidth=1024,O.noAtlas=!1,O.forceSplitRender=!1,O.forceWholeRender=!1,O.scaleFontWithCtx=!0,O.standardFontSize=32,O.destroyAtlasDt=10,O.checkCleanTextureDt=2e3,O.destroyUnusedTextureDt=3e3,O.cleanMem=100*1024*1024,O.isWan1Wan=!1,O.showLog=!1,O.debugUV=!1,O.tmpRI=new us,O.pixelBBX=[0,0,0,0],O.imgdtRect=[0,0,0,0],O.simClean=!1,Pt.gTextRender=O;class K{constructor(){if(this._tmpMatrix=new et,this._drawTexToDrawTri_Vert=new Float32Array(8),this._drawTexToDrawTri_Index=new Uint16Array([0,1,2,0,2,3]),this._tempUV=new Float32Array(8),this._drawTriUseAbsMatrix=!1,this._id=++K._COUNT,this._other=null,this._renderNextSubmitIndex=0,this._path=null,this._drawCount=1,this._width=K._MAXSIZE,this._height=K._MAXSIZE,this._renderCount=0,this._submits=null,this._curSubmit=null,this._submitKey=new Pi,this._pathMesh=null,this._triangleMesh=null,this.meshlist=[],this._transedPoints=new Array(8),this._temp4Points=new Array(8),this._clipRect=K.MAXCLIPRECT,this._globalClipMatrix=new et(K._MAXSIZE,0,0,K._MAXSIZE,0,0),this._clipInCache=!1,this._clipInfoID=0,this._clipID_Gen=0,this._lastMatScaleX=1,this._lastMatScaleY=1,this._lastMat_a=1,this._lastMat_b=0,this._lastMat_c=0,this._lastMat_d=1,this._nBlendType=0,this._save=null,this._targets=null,this._charSubmitCache=null,this._saveMark=null,this._shader2D=new Qi,this.sprite=null,this._italicDeg=0,this._lastTex=null,this._fillColor=0,this._flushCnt=0,this.defTexture=null,this._colorFiler=null,this.drawTexAlign=!1,this._incache=!1,this.isMain=!1,K._contextcount++,K._textRender=K._textRender||new O,!this.defTexture){var t=new _t(2,2);t.setPixels(new Uint8Array(16)),t.lock=!0,this.defTexture=new ut(t)}this._lastTex=this.defTexture,this.clear()}static __init__(){K.MAXCLIPRECT=new tt(0,0,K._MAXSIZE,K._MAXSIZE),mi.DEFAULT=new mi}drawImage(...t){}getImageData(...t){}measureText(t){return null}setTransform(...t){}$transform(t,e,i,s,r,a){}get lineJoin(){return""}set lineJoin(t){}get lineCap(){return""}set lineCap(t){}get miterLimit(){return""}set miterLimit(t){}clearRect(t,e,i,s){}_drawRect(t,e,i,s,r){F.renderBatches++,r&&(this.fillStyle=r),this.fillRect(t,e,i,s,null)}drawTexture2(t,e,i,s,r,a){}transformByMatrix(t,e,i){this.transform(t.a,t.b,t.c,t.d,t.tx+e,t.ty+i)}saveTransform(t){this.save()}restoreTransform(t){this.restore()}drawRect(t,e,i,s,r,a,n){var h=this;r!=null&&(h.fillStyle=r,h.fillRect(t,e,i,s)),a!=null&&(h.strokeStyle=a,h.lineWidth=n,h.strokeRect(t,e,i,s))}alpha(t){this.globalAlpha*=t}_transform(t,e,i){this.translate(e,i),this.transform(t.a,t.b,t.c,t.d,t.tx,t.ty),this.translate(-e,-i)}_rotate(t,e,i){this.translate(e,i),this.rotate(t),this.translate(-e,-i)}_scale(t,e,i,s){this.translate(i,s),this.scale(t,e),this.translate(-i,-s)}_drawLine(t,e,i,s,r,a,n,h,o){this.beginPath(),this.strokeStyle=n,this.lineWidth=h,this.moveTo(t+i,e+s),this.lineTo(t+r,e+a),this.stroke()}_drawLines(t,e,i,s,r,a){this.beginPath(),this.strokeStyle=s,this.lineWidth=r,this.addPath(i.slice(),!1,!1,t,e),this.stroke()}drawCurves(t,e,i,s,r){this.beginPath(),this.strokeStyle=s,this.lineWidth=r,this.moveTo(t+i[0],e+i[1]);for(var a=2,n=i.length;a0&&(this.strokeStyle=e,this.lineWidth=i,this.stroke())}_drawCircle(t,e,i,s,r,a,n){F.renderBatches++,this.beginPath(!0),this.arc(t,e,i,0,K.PI2),this.closePath(),this._fillAndStroke(s,r,a)}_drawPie(t,e,i,s,r,a,n,h,o){this.beginPath(),this.moveTo(t,e),this.arc(t,e,i,s,r),this.closePath(),this._fillAndStroke(a,n,h)}_drawPoly(t,e,i,s,r,a,n,h){this.beginPath(),this.addPath(i.slice(),!0,n,t,e),this.closePath(),this._fillAndStroke(s,r,a,n)}_drawPath(t,e,i,s,r){this.beginPath();for(var a=0,n=i.length;a=0;i--){var s=this._save[i];if(s.restore(this),s.isSaveMark()){this._save._length=i;return}}e!=this._nBlendType&&(this._curSubmit=W.RENDERBASE)}}set font(t){this._other=this._other.make(),X.save(this,X.TYPE_FONT,this._other,!1)}fillText(t,e,i,s,r,a,n=0,h=""){K._textRender.filltext(this,t,e,i,s,r,h,n,a)}drawText(t,e,i,s,r,a){K._textRender.filltext(this,t,e,i,s,r,null,0,a)}fillWords(t,e,i,s,r){K._textRender.fillWords(this,t,e,i,s,r,null,0)}strokeWord(t,e,i,s,r,a,n){K._textRender.filltext(this,t,e,i,s,null,r,a,n)}fillBorderText(t,e,i,s,r,a,n,h){K._textRender.filltext(this,t,e,i,s,r,a,n,h)}fillBorderWords(t,e,i,s,r,a,n){K._textRender.fillWords(this,t,e,i,s,r,a,n)}_fast_filltext(t,e,i,s,r,a,n,h,o=0){K._textRender._fast_filltext(this,t,null,e,i,s,r,a,n,h,o)}_fillRect(t,e,i,s,r){var a=this._curSubmit,n=a&&a._key.submitType===W.KEY_DRAWTEXTURE&&a._key.blendShader===this._nBlendType;this._mesh.vertNum+4>K._MAXVERTNUM&&(this._mesh=Bt.getAMesh(this.isMain),this.meshlist.push(this._mesh),n=!1),n&&(n=n&&this.isSameClipInfo(a)),this.transformQuad(t,e,i,s,0,this._curMat,this._transedPoints),this.clipedOff(this._transedPoints)||(this._mesh.addQuad(this._transedPoints,ut.NO_UV,r,!1),n||(a=this._curSubmit=le.create(this,this._mesh,vt.create(V.TEXTURE2D,0)),this._submits[this._submits._length++]=a,this._copyClipInfo(a,this._globalClipMatrix),a.shaderValue.textureHost=this._lastTex,a._key.other=this._lastTex&&this._lastTex.bitmap?this._lastTex.bitmap.id:-1,a._renderType=W.TYPE_TEXTURE),this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4)}fillRect(t,e,i,s,r){var a=r?be.create(r):this._shader2D.fillStyle,n=this.mixRGBandAlpha(a.toInt());this._fillRect(t,e,i,s,n)}fillTexture(t,e,i,s,r,a,n,h){if(!t._getSource()){this.sprite&&c.systemTimer.callLater(this,this._repaintSprite);return}this._fillTexture(t,t.width,t.height,t.uvrect,e,i,s,r,a,n.x,n.y)}_fillTexture(t,e,i,s,r,a,n,h,o,l,u){var _=this._curSubmit;this._mesh.vertNum+4>K._MAXVERTNUM&&(this._mesh=Bt.getAMesh(this.isMain),this.meshlist.push(this._mesh));var f=!0,p=!0;switch(o){case"repeat":break;case"repeat-x":p=!1;break;case"repeat-y":f=!1;break;case"no-repeat":f=p=!1;break}var m=this._temp4Points,g=0,y=0,C=0,w=0,M=0,R=0;if(l<0?(C=r,g=-l%e/e):C=r+l,u<0?(w=a,y=-u%i/i):w=a+u,M=r+n,R=a+h,!f&&(M=Math.min(M,r+l+e)),!p&&(R=Math.min(R,a+u+i)),!(MM||w>R)){var B=(M-r-l)/e,k=(R-a-u)/i;if(this.transformQuad(C,w,M-C,R-w,0,this._curMat,this._transedPoints),m[0]=g,m[1]=y,m[2]=B,m[3]=y,m[4]=B,m[5]=k,m[6]=g,m[7]=k,!this.clipedOff(this._transedPoints)){var z=this._mixRGBandAlpha(4294967295,this._shader2D.ALPHA);this._mesh.addQuad(this._transedPoints,m,z,!0);var S=vt.create(V.TEXTURE2D,0);S.defines.add(V.FILLTEXTURE),S.u_TexRange=s.concat(),_=this._curSubmit=le.create(this,this._mesh,S),this._submits[this._submits._length++]=_,this._copyClipInfo(_,this._globalClipMatrix),_.shaderValue.textureHost=t,_._renderType=W.TYPE_TEXTURE,this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4}this.breakNextMerge()}}setColorFilter(t){X.save(this,X.TYPE_COLORFILTER,this,!0),this._colorFiler=t,this._curSubmit=W.RENDERBASE}drawTexture(t,e,i,s,r){this._drawTextureM(t,e,i,s,r,null,1,null)}drawTextures(t,e,i,s){if(!t._getSource()){this.sprite&&c.systemTimer.callLater(this,this._repaintSprite);return}for(var r=e.length/2,a=0,n=t.bitmap.id,h=0;hK._MAXVERTNUM&&(this._mesh=Bt.getAMesh(this.isMain),this.meshlist.push(this._mesh));var i=le.create(this,this._mesh,vt.create(V.TEXTURE2D,0));this._submits[this._submits._length++]=this._curSubmit=i,i.shaderValue.textureHost=t,this._copyClipInfo(i,this._globalClipMatrix)}_drawTexRect(t,e,i,s,r){this.transformQuad(t,e,i,s,this._italicDeg,this._curMat,this._transedPoints);var a=this._transedPoints;a[0]=a[0]+.5|0,a[1]=a[1]+.5|0,a[2]=a[2]+.5|0,a[3]=a[3]+.5|0,a[4]=a[4]+.5|0,a[5]=a[5]+.5|0,a[6]=a[6]+.5|0,a[7]=a[7]+.5|0,this.clipedOff(this._transedPoints)||(this._mesh.addQuad(this._transedPoints,r,this._fillColor,!0),this._curSubmit._numEle+=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4)}drawCallOptimize(t){return this._charSubmitCache.enable(t,this),t}_inner_drawTexture(t,e,i,s,r,a,n,h,o,l){if(r<=0||a<=0)return!1;var u=this._curSubmit._key;if(h=h||t._uv,u.submitType===W.KEY_TRIANGLES&&u.other===e){var _=this._drawTexToDrawTri_Vert;_[0]=i,_[1]=s,_[2]=i+r,_[3]=s,_[4]=i+r,_[5]=s+a,_[6]=i,_[7]=s+a,this._drawTriUseAbsMatrix=!0;var f=this._tempUV;return f[0]=h[0],f[1]=h[1],f[2]=h[2],f[3]=h[3],f[4]=h[4],f[5]=h[5],f[6]=h[6],f[7]=h[7],this.drawTriangles(t,0,0,_,f,this._drawTexToDrawTri_Index,n||this._curMat,o,null,null),this._drawTriUseAbsMatrix=!1,!0}var p=this._mesh,m=this._curSubmit,g=l?this._charSubmitCache.getPos():this._transedPoints;if(this.transformQuad(i,s,r||t.width,a||t.height,this._italicDeg,n||this._curMat,g),this.drawTexAlign){var y=Math.round;g[0]=y(g[0]),g[1]=y(g[1]),g[2]=y(g[2]),g[3]=y(g[3]),g[4]=y(g[4]),g[5]=y(g[5]),g[6]=y(g[6]),g[7]=y(g[7]),this.drawTexAlign=!1}var C=this._mixRGBandAlpha(4294967295,this._shader2D.ALPHA*o);if(l)return this._charSubmitCache.add(this,t,e,g,h,C),!0;this._drawCount++;var w=e>=0&&u.submitType===W.KEY_DRAWTEXTURE&&u.other===e;return w&&(w=w&&this.isSameClipInfo(m)),this._lastTex=t,p.vertNum+4>K._MAXVERTNUM&&(p=this._mesh=Bt.getAMesh(this.isMain),this.meshlist.push(p),w=!1),p.addQuad(g,h,C,!0),w||(this._submits[this._submits._length++]=this._curSubmit=m=le.create(this,p,vt.create(V.TEXTURE2D,0)),m.shaderValue.textureHost=t,m._key.other=e,this._copyClipInfo(m,this._globalClipMatrix)),m._numEle+=6,p.indexNum+=6,p.vertNum+=4,!0}transform4Points(t,e,i){var s=e.tx,r=e.ty,a=e.a,n=e.b,h=e.c,o=e.d,l=t[0],u=t[1],_=t[2],f=t[3],p=t[4],m=t[5],g=t[6],y=t[7];e._bTransform?(i[0]=l*a+u*h+s,i[1]=l*n+u*o+r,i[2]=_*a+f*h+s,i[3]=_*n+f*o+r,i[4]=p*a+m*h+s,i[5]=p*n+m*o+r,i[6]=g*a+y*h+s,i[7]=g*n+y*o+r):(i[0]=l+s,i[1]=u+r,i[2]=_+s,i[3]=f+r,i[4]=p+s,i[5]=m+r,i[6]=g+s,i[7]=y+r)}clipedOff(t){return this._clipRect.width<=0||this._clipRect.height<=0}transformQuad(t,e,i,s,r,a,n){var h=0;r!=0&&(h=Math.tan(r*Math.PI/180)*s);var o=t+i,l=e+s,u=a.tx,_=a.ty,f=a.a,p=a.b,m=a.c,g=a.d,y=t+h,C=e,w=o+h,M=e,R=o,B=l,k=t,z=l;a._bTransform?(n[0]=y*f+C*m+u,n[1]=y*p+C*g+_,n[2]=w*f+M*m+u,n[3]=w*p+M*g+_,n[4]=R*f+B*m+u,n[5]=R*p+B*g+_,n[6]=k*f+z*m+u,n[7]=k*p+z*g+_):(n[0]=y+u,n[1]=C+_,n[2]=w+u,n[3]=M+_,n[4]=R+u,n[5]=B+_,n[6]=k+u,n[7]=z+_)}pushRT(){this.addRenderObject(te.create(null,kt.pushRT,this))}popRT(){this.addRenderObject(te.create(null,kt.popRT,this)),this.breakNextMerge()}useRT(t){function e(i){if(i)i.start(),i.clear(0,0,0,0);else throw"error useRT"}this.addRenderObject(te.create([t],e,this)),this.breakNextMerge()}RTRestore(t){function e(i){i.restore()}this.addRenderObject(te.create([t],e,this)),this.breakNextMerge()}breakNextMerge(){this._curSubmit=W.RENDERBASE}_repaintSprite(){this.sprite&&this.sprite.repaint()}drawTextureWithTransform(t,e,i,s,r,a,n,h,o,l,u=null,_){var f,p=this._curMat;l&&(f=this.globalCompositeOperation,this.globalCompositeOperation=l);var m=this._colorFiler;if(u&&this.setColorFilter(u),!a){this._drawTextureM(t,e+n,i+h,s,r,p,o,_),l&&(this.globalCompositeOperation=f),u&&this.setColorFilter(m);return}var g=this._tmpMatrix;g.a=a.a,g.b=a.b,g.c=a.c,g.d=a.d,g.tx=a.tx+n,g.ty=a.ty+h,g._bTransform=a._bTransform,a&&p._bTransform?(et.mul(g,p,g),a=g,a._bTransform=!0):(g.tx+=p.tx,g.ty+=p.ty,a=g),this._drawTextureM(t,e,i,s,r,a,o,_),l&&(this.globalCompositeOperation=f),u&&this.setColorFilter(m)}_flushToTarget(t,e){U.worldScissorTest=!1;var i=I.instance;i.disable(i.SCISSOR_TEST);var s=U.worldAlpha,r=U.worldMatrix4,a=U.worldMatrix;U.worldMatrix=et.EMPTY,U.restoreTempArray(),U.worldMatrix4=U.TEMPMAT4_ARRAY,U.worldAlpha=1,ve.activeShader=null,c.Browser.onIOS&&i.flush(),e.start(),t._submits._length>0&&e.clear(0,0,0,0),t._curSubmit=W.RENDERBASE,t.flush(),t.clear(),e.restore(),t._curSubmit=W.RENDERBASE,ve.activeShader=null,U.worldAlpha=s,U.worldMatrix4=r,U.worldMatrix=a}drawCanvas(t,e,i,s,r){if(t){var a=t.context,n;if(a._targets)a._submits._length>0&&(n=te.create([a,a._targets],this._flushToTarget,this),this._submits[this._submits._length++]=n),this._drawRenderTexture(a._targets,e,i,s,r,null,1,kt.flipyuv),this._curSubmit=W.RENDERBASE;else{var h=t;h.touches&&h.touches.forEach(function(_){_.touch()}),n=Pe.create(t,this._shader2D.ALPHA,this._shader2D.filters),this._submits[this._submits._length++]=n,n._key.clear();var o=n._matrix;this._curMat.copyTo(o);var l=o.tx,u=o.ty;o.tx=o.ty=0,o.transformPoint(Tt.TEMP.setTo(e,i)),o.translate(Tt.TEMP.x+l,Tt.TEMP.y+u),et.mul(h.invMat,o,o),this._curSubmit=W.RENDERBASE}}}drawTarget(t,e,i,s,r,a,n,h=null,o=-1){if(this._drawCount++,this._mesh.vertNum+4>K._MAXVERTNUM&&(this._mesh=Bt.getAMesh(this.isMain),this.meshlist.push(this._mesh)),this.transformQuad(e,i,s,r,0,a||this._curMat,this._transedPoints),!this.clipedOff(this._transedPoints)){this._mesh.addQuad(this._transedPoints,h||ut.DEF_UV,4294967295,!0);var l=this._curSubmit=De.create(this,this._mesh,n,t);return l.blendType=o==-1?this._nBlendType:o,this._copyClipInfo(l,this._globalClipMatrix),l._numEle=6,this._mesh.indexNum+=6,this._mesh.vertNum+=4,this._submits[this._submits._length++]=l,this._curSubmit=W.RENDERBASE,!0}return this._curSubmit=W.RENDERBASE,!1}drawTriangles(t,e,i,s,r,a,n,h,o,l,u=4294967295){if(!t._getSource()){this.sprite&&c.systemTimer.callLater(this,this._repaintSprite);return}var _=null;l&&(_=this.globalCompositeOperation,this.globalCompositeOperation=l),this._drawCount++;var f=this._tmpMatrix,p=this._triangleMesh,m=null,g=!1;o&&(m=this._colorFiler,this._colorFiler=o,this._curSubmit=W.RENDERBASE,g=m!=o);var y=t.bitmap,C=this._curSubmit._key,w=C.submitType===W.KEY_TRIANGLES&&C.other===y.id&&C.blendShader==this._nBlendType;if(p.vertNum+s.length/2>K._MAXVERTNUM&&(p=this._triangleMesh=ne.getAMesh(this.isMain),this.meshlist.push(p),w=!1),!w){var M=this._curSubmit=le.create(this,p,vt.create(V.TEXTURE2D,0));M.shaderValue.textureHost=t,M._renderType=W.TYPE_TEXTURE,M._key.submitType=W.KEY_TRIANGLES,M._key.other=y.id,this._copyClipInfo(M,this._globalClipMatrix),this._submits[this._submits._length++]=M}var R=this._mixRGBandAlpha(u,this._shader2D.ALPHA*h);this._drawTriUseAbsMatrix?p.addData(s,r,a,n,R):(n?(f.a=n.a,f.b=n.b,f.c=n.c,f.d=n.d,f.tx=n.tx+e,f.ty=n.ty+i):(f.a=1,f.b=0,f.c=0,f.d=1,f.tx=e,f.ty=i),et.mul(f,this._curMat,f),p.addData(s,r,a,f||this._curMat,R)),this._curSubmit._numEle+=a.length,g&&(this._colorFiler=m,this._curSubmit=W.RENDERBASE),l&&(this.globalCompositeOperation=_)}transform(t,e,i,s,r,a){Se.save(this),et.mul(et.TEMP.setTo(t,e,i,s,r,a),this._curMat,this._curMat),this._curMat._checkTransform()}_transformByMatrix(t,e,i){t.setTranslate(e,i),et.mul(t,this._curMat,this._curMat),t.setTranslate(0,0),this._curMat._bTransform=!0}setTransformByMatrix(t){t.copyTo(this._curMat)}rotate(t){Se.save(this),this._curMat.rotateEx(t)}scale(t,e){Se.save(this),this._curMat.scaleEx(t,e)}clipRect(t,e,i,s){Ke.save(this),this._clipRect==K.MAXCLIPRECT?this._clipRect=new tt(t,e,i,s):(this._clipRect.width=i,this._clipRect.height=s,this._clipRect.x=t,this._clipRect.y=e),this._clipID_Gen++,this._clipID_Gen%=1e4,this._clipInfoID=this._clipID_Gen;var r=this._globalClipMatrix,a=r.tx,n=r.ty,h=a+r.a,o=n+r.d;if(this._clipRect.width>=K._MAXSIZE?(r.a=r.d=K._MAXSIZE,r.b=r.c=r.tx=r.ty=0):(this._curMat._bTransform?(r.tx=this._clipRect.x*this._curMat.a+this._clipRect.y*this._curMat.c+this._curMat.tx,r.ty=this._clipRect.x*this._curMat.b+this._clipRect.y*this._curMat.d+this._curMat.ty,r.a=this._clipRect.width*this._curMat.a,r.b=this._clipRect.width*this._curMat.b,r.c=this._clipRect.height*this._curMat.c,r.d=this._clipRect.height*this._curMat.d):(r.tx=this._clipRect.x+this._curMat.tx,r.ty=this._clipRect.y+this._curMat.ty,r.a=this._clipRect.width,r.b=r.c=0,r.d=this._clipRect.height),this._incache&&(this._clipInCache=!0)),r.a>0&&r.d>0){var l=r.tx+r.a,u=r.ty+r.d;l<=a||u<=n||r.tx>=h||r.ty>=o?(r.a=-.1,r.d=-.1):(r.txh&&(r.a-=l-h),r.tyo&&(r.d-=u-o),r.a<=0&&(r.a=-.1),r.d<=0&&(r.d=-.1))}}drawMesh(t,e,i,s,r,a,n,h,o=0){}addRenderObject(t){this._submits[this._submits._length++]=t}submitElement(t,e){var i=this.isMain,s=this._submits,r=s._length;e<0&&(e=s._length);for(var a=W.RENDERBASE;tK._MAXVERTNUM&&(this._curSubmit._numEle+=a,a=0,this._pathMesh=se.getAMesh(this.isMain),this._curSubmit=this.addVGSubmit(this._pathMesh));var C=this._pathMesh.vertNum;if(l.convex){var w=u-2;n=new Array(w*3);for(var M=0,R=0;R0)for(var B=0;B0){var t=this.mixRGBandAlpha(this.strokeStyle._color.numColor),e=this._getPath(),i=this._curSubmit,s=i._key.submitType===W.KEY_VG&&i._key.blendShader===this._nBlendType;s&&(s=s&&this.isSameClipInfo(i)),s||(this._curSubmit=this.addVGSubmit(this._pathMesh));for(var r=0,a=0,n=e.paths.length;aK._MAXVERTNUM&&(this._curSubmit._numEle+=r,r=0,this._pathMesh=se.getAMesh(this.isMain),this.meshlist.push(this._pathMesh),this._curSubmit=this.addVGSubmit(this._pathMesh)),bi.createLine2(h.path,o,this.lineWidth,this._pathMesh.vertNum,l,h.loop);var _=l.length/2,f=this._curMat,p=0,m,g,y,C;if(f._bTransform)for(p=0;p<_;p++)m=p<<1,g=m+1,y=l[m],C=l[g],l[m]=f.a*y+f.c*C+f.tx,l[g]=f.b*y+f.d*C+f.ty;else for(p=0;p<_;p++)m=p<<1,g=m+1,y=l[m],C=l[g],l[m]=y+f.tx,l[g]=C+f.ty;this._pathMesh.addVertAndIBToMesh(this,l,t,o),r+=o.length}}}this._curSubmit._numEle+=r}}moveTo(t,e){var i=this._getPath();i.newPath(),i._lastOriX=t,i._lastOriY=e,i.addPoint(t,e)}lineTo(t,e){var i=this._getPath();Math.abs(t-i._lastOriX)<.001&&Math.abs(e-i._lastOriY)<.001||(i._lastOriX=t,i._lastOriY=e,i.addPoint(t,e))}arcTo(t,e,i,s,r){var a=0,n=0,h=0,o=this._path._lastOriX-t,l=this._path._lastOriY-e,u=Math.sqrt(o*o+l*l);if(!(u<=1e-6)){var _=o/u,f=l/u,p=i-t,m=s-e,g=p*p+m*m,y=Math.sqrt(g);if(!(y<=1e-6)){var C=p/y,w=m/y,M=_+C,R=f+w,B=Math.sqrt(M*M+R*R);if(!(B<=1e-6)){var k=M/B,z=R/B,S=Math.acos(k*_+z*f),dt=Math.PI/2-S;u=r*Math.tan(dt);var Mt=u*_+t,nt=u*f+e,pt=Math.sqrt(u*u+r*r),Qt=t+k*pt,Ot=e+z*pt,ht=_*w-f*C,Et=0,Ct=0,At=0;if(ht>=0){Et=dt*2;var Re=Et/K.SEGNUM;Ct=Math.sin(Re),At=Math.cos(Re)}else Et=-dt*2,Re=Et/K.SEGNUM,Ct=Math.sin(Re),At=Math.cos(Re);var Vi=this._path._lastOriX,As=this._path._lastOriY,Cs=Mt,Rs=nt;(Math.abs(Cs-this._path._lastOriX)>.1||Math.abs(Rs-this._path._lastOriY)>.1)&&(n=Cs,h=Rs,Vi=Cs,As=Rs,this._path._lastOriX=n,this._path._lastOriY=h,this._path.addPoint(n,h));var bs=Mt-Qt,ws=nt-Ot;for(a=0;a.1||Math.abs(As-h)>.1)&&(this._path._lastOriX=n,this._path._lastOriY=h,this._path.addPoint(n,h),Vi=n,As=h),bs=Xs,ws=zs}}}}}arc(t,e,i,s,r,a=!1,n=!0){var h=0,o=0,l=0,u=0,_=0,f=0,p,m;if(o=r-s,a)if(Math.abs(o)>=Math.PI*2)o=-Math.PI*2;else for(;o>0;)o-=Math.PI*2;else if(Math.abs(o)>=Math.PI*2)o=Math.PI*2;else for(;o<0;)o+=Math.PI*2;var g=this.getMatScaleX(),y=this.getMatScaleY(),C=i*(g>y?g:y),w=2*Math.PI*C;m=Math.max(w/10,10)|0;var M=this._getPath();for(p=0;p<=m;p++)h=s+o*(p/m),l=Math.cos(h),u=Math.sin(h),_=t+l*i,f=e+u*i,(_!=this._path._lastOriX||f!=this._path._lastOriY)&&M.addPoint(_,f);l=Math.cos(r),u=Math.sin(r),_=t+l*i,f=e+u*i,(_!=this._path._lastOriX||f!=this._path._lastOriY)&&M.addPoint(_,f)}quadraticCurveTo(t,e,i,s){for(var r=Di.I,a=r.getBezierPoints([this._path._lastOriX,this._path._lastOriY,t,e,i,s],30,2),n=0,h=a.length/2;n=1)return t;var i=(t&4278190080)>>>24;return i!=0?i*=e:i=e*255,t&16777215|i<<24}strokeRect(t,e,i,s,r){if(this.lineWidth>0){var a=this.mixRGBandAlpha(this.strokeStyle._color.numColor),n=this.lineWidth/2;this._fillRect(t-n,e-n,i+this.lineWidth,this.lineWidth,a),this._fillRect(t-n,e-n+s,i+this.lineWidth,this.lineWidth,a),this._fillRect(t-n,e+n,this.lineWidth,s-this.lineWidth,a),this._fillRect(t-n+i,e+n,this.lineWidth,s-this.lineWidth,a)}}clip(){}drawParticle(t,e,i){i.x=t,i.y=e,this._submits[this._submits._length++]=i}_getPath(){return this._path||(this._path=new Ms)}get canvas(){return this._canvas}_fillTexture_h(t,e,i,s,r,a,n,h){s<=0&&console.error("_fillTexture_h error: oriw must>0");for(var o=a,l=Math.floor(h/s),u=h%s,_=0;_0){var f=i[2]-i[0],p=i[0]+f*(u/s),m=K.tmpuv1;m[0]=i[0],m[1]=i[1],m[2]=p,m[3]=i[3],m[4]=p,m[5]=i[5],m[6]=i[6],m[7]=i[7],this._inner_drawTexture(t,e,o,n,u,r,this._curMat,m,1,!1)}}_fillTexture_v(t,e,i,s,r,a,n,h){r<=0&&console.error("_fillTexture_v error: orih must>0");for(var o=n,l=Math.floor(h/r),u=h%r,_=0;_0){var f=i[7]-i[1],p=i[1]+f*(u/r),m=K.tmpuv1;m[0]=i[0],m[1]=i[1],m[2]=i[2],m[3]=i[3],m[4]=i[4],m[5]=p,m[6]=i[6],m[7]=p,this._inner_drawTexture(t,e,a,o,s,u,this._curMat,m,1,!1)}}drawTextureWithSizeGrid(t,e,i,s,r,a,n,h){if(t._getSource()){e+=n,i+=h;var o=t.uv,l=t.bitmap.width,u=t.bitmap.height,_=t.sourceWidth,f=t.sourceHeight,p=a[0],m=a[3],g=a[1],y=a[2],C=a[4];s==_&&(m=g=0),r==f&&(p=y=0);var w=p/u,M=m/l,R=g/l,B=y/u,k=t.bitmap.id,z=this._curMat,S=this._tempUV,dt=1,Mt=1;m+g>s&&(dt=s/(m+g)),p+y>r&&(Mt=r/(p+y)),m*=dt,g*=dt,p*=Mt,y*=Mt;var nt=o[0],pt=o[1],Qt=o[4],Ot=o[5],ht=nt,Et=pt,Ct=Qt,At=Ot;if(m&&p&&(Ct=nt+M,At=pt+w,S[0]=nt,S[1]=pt,S[2]=Ct,S[3]=pt,S[4]=Ct,S[5]=At,S[6]=nt,S[7]=At,this._inner_drawTexture(t,k,e,i,m,p,z,S,1,!1)),g&&p&&(ht=Qt-R,Et=pt,Ct=Qt,At=pt+w,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,this._inner_drawTexture(t,k,s-g+e,0+i,g,p,z,S,1,!1)),m&&y&&(ht=nt,Et=Ot-B,Ct=nt+M,At=Ot,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,this._inner_drawTexture(t,k,0+e,r-y+i,m,y,z,S,1,!1)),g&&y&&(ht=Qt-R,Et=Ot-B,Ct=Qt,At=Ot,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,this._inner_drawTexture(t,k,s-g+e,r-y+i,g,y,z,S,1,!1)),p&&(ht=nt+M,Et=pt,Ct=Qt-R,At=pt+w,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,C?this._fillTexture_h(t,k,S,t.width-m-g,p,m+e,i,s-m-g):this._inner_drawTexture(t,k,m+e,i,s-m-g,p,z,S,1,!1)),y&&(ht=nt+M,Et=Ot-B,Ct=Qt-R,At=Ot,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,C?this._fillTexture_h(t,k,S,t.width-m-g,y,m+e,r-y+i,s-m-g):this._inner_drawTexture(t,k,m+e,r-y+i,s-m-g,y,z,S,1,!1)),m&&(ht=nt,Et=pt+w,Ct=nt+M,At=Ot-B,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,C?this._fillTexture_v(t,k,S,m,t.height-p-y,e,p+i,r-p-y):this._inner_drawTexture(t,k,e,p+i,m,r-p-y,z,S,1,!1)),g&&(ht=Qt-R,Et=pt+w,Ct=Qt,At=Ot-B,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,C?this._fillTexture_v(t,k,S,g,t.height-p-y,s-g+e,p+i,r-p-y):this._inner_drawTexture(t,k,s-g+e,p+i,g,r-p-y,z,S,1,!1)),ht=nt+M,Et=pt+w,Ct=Qt-R,At=Ot-B,S[0]=ht,S[1]=Et,S[2]=Ct,S[3]=Et,S[4]=Ct,S[5]=At,S[6]=ht,S[7]=At,C){var Re=K.tmpUVRect;Re[0]=ht,Re[1]=Et,Re[2]=Ct-ht,Re[3]=At-Et,this._fillTexture(t,t.width-m-g,t.height-p-y,Re,m+e,p+i,s-m-g,r-p-y,"repeat",0,0)}else this._inner_drawTexture(t,k,m+e,p+i,s-m-g,r-p-y,z,S,1,!1)}}}K.ENUM_TEXTALIGN_DEFAULT=0,K.ENUM_TEXTALIGN_CENTER=1,K.ENUM_TEXTALIGN_RIGHT=2,K._SUBMITVBSIZE=32e3,K._MAXSIZE=99999999,K._MAXVERTNUM=65535,K.MAXCLIPRECT=null,K._COUNT=0,K.SEGNUM=32,K._contextcount=0,K.PI2=2*Math.PI,K._textRender=null,K.tmpuv1=[0,0,0,0,0,0,0,0],K.tmpUV=[0,0,0,0,0,0,0,0],K.tmpUVRect=[0,0,0,0];class mi{constructor(){this.lineWidth=1}clear(){this.lineWidth=1,this.textAlign=this.textBaseline=null}make(){return this===mi.DEFAULT?new mi:this}}class Ce{static _uint8ArraySlice(){for(var t=this,e=t.length,i=new Uint8Array(t.length),s=0;sa)for(i=n-a,s=new Uint16Array(i),r=a;r0?h.offsetX:0,g=h.offsetY>0?h.offsetY:0;m*=u,g*=_,ot._addPointArrToRst(i,tt._getBoundPointS(n.x-m,n.y-g,f,p),r)}break;case ze.ID:n.width&&n.height?ot._addPointArrToRst(i,tt._getBoundPointS(n.x,n.y,n.width,n.height),r):(h=n.texture,ot._addPointArrToRst(i,tt._getBoundPointS(n.x,n.y,h.width,h.height),r));break;case Xe.ID:var y;n.matrix?(r.copyTo(a),a.concat(n.matrix),y=a):y=r,t?n.width&&n.height?ot._addPointArrToRst(i,tt._getBoundPointS(n.x,n.y,n.width,n.height),y):(h=n.texture,ot._addPointArrToRst(i,tt._getBoundPointS(n.x,n.y,h.width,h.height),y)):(h=n.texture,u=(n.width||h.sourceWidth)/h.width,_=(n.height||h.sourceHeight)/h.height,f=u*h.sourceWidth,p=_*h.sourceHeight,m=h.offsetX>0?h.offsetX:0,g=h.offsetY>0?h.offsetY:0,m*=u,g*=_,ot._addPointArrToRst(i,tt._getBoundPointS(n.x-m,n.y-g,f,p),y));break;case ni.ID:ot._addPointArrToRst(i,tt._getBoundPointS(n.x,n.y,n.width,n.height),r);break;case Je.ID:ot._addPointArrToRst(i,tt._getBoundPointS(n.x-n.radius,n.y-n.radius,n.radius+n.radius,n.radius+n.radius),r);break;case ei.ID:ot._tempPoints.length=0;var C;C=n.lineWidth*.5,n.fromX==n.toX?ot._tempPoints.push(n.fromX+C,n.fromY,n.toX+C,n.toY,n.fromX-C,n.fromY,n.toX-C,n.toY):n.fromY==n.toY?ot._tempPoints.push(n.fromX,n.fromY+C,n.toX,n.toY+C,n.fromX,n.fromY-C,n.toX,n.toY-C):ot._tempPoints.push(n.fromX,n.fromY,n.toX,n.toY),ot._addPointArrToRst(i,ot._tempPoints,r);break;case ti.ID:ot._addPointArrToRst(i,Di.I.getBezierPoints(n.points),r,n.x,n.y);break;case ii.ID:case ai.ID:ot._addPointArrToRst(i,n.points,r,n.x,n.y);break;case si.ID:ot._addPointArrToRst(i,this._getPathPoints(n.paths),r,n.x,n.y);break;case ri.ID:ot._addPointArrToRst(i,this._getPiePoints(n.x,n.y,n.radius,n.startAngle,n.endAngle),r);break;case gi.ID:ot._addPointArrToRst(i,this._getTriAngBBXPoints(n.vertices),r);break;case Ti.ID:ot._addPointArrToRst(i,this._getDraw9GridBBXPoints(n),r);break}return i.length>200?i=J.copyArray(i,tt._getWrapRec(i)._getBoundPoints()):i.length>8&&(i=Lt.scanPList(i)),i}_switchMatrix(t,e){e.concat(t),e.copyTo(t)}static _addPointArrToRst(t,e,i,s=0,r=0){var a,n;for(n=e.length,a=0;a=360||h<=-360)return a.push(t-i,e-i),a.push(t+i,e-i),a.push(t+i,e+i),a.push(t-i,e+i),a;a.push(t,e);var o=h%360;o<0&&(o+=360);var l=s+o,u=s*n,_=l*n;a.push(t+i*Math.cos(u),e+i*Math.sin(u)),a.push(t+i*Math.cos(_),e+i*Math.sin(_));for(var f=Math.ceil(s/90)*90,p=Math.floor(l/90)*90,m=f;m<=p;m+=90){var g=m*n;a.push(t+i*Math.cos(g),e+i*Math.sin(g))}return a}_getTriAngBBXPoints(t){var e=t.length;if(e<2)return[];for(var i=t[0],s=t[1],r=i,a=s,n=2;nh&&(i=h),s>o&&(s=o),r1&&(s.push(r[1],r[2]),r.length>3&&s.push(r[3],r[4]));return s}}ot._tempMatrix=new et,ot._initMatrix=new et,ot._tempPoints=[],ot._tempMatrixArrays=[],ot._tempCmds=[];class P{}P.ALPHA=1,P.TRANSFORM=2,P.BLEND=4,P.CANVAS=8,P.FILTERS=16,P.MASK=32,P.CLIP=64,P.STYLE=128,P.TEXTURE=256,P.GRAPHICS=512,P.LAYAGL3D=1024,P.CUSTOM=2048,P.ONECHILD=4096,P.CHILDS=8192,P.REPAINT_NONE=0,P.REPAINT_NODE=1,P.REPAINT_CACHE=2,P.REPAINT_ALL=3;class wi{static create(t,e,i,s){var r=D.getItemByClass("ClipRectCmd",wi);return r.x=t,r.y=e,r.width=i,r.height=s,r}recover(){D.recover("ClipRectCmd",this)}run(t,e,i){t.clipRect(this.x+e,this.y+i,this.width,this.height)}get cmdID(){return wi.ID}}wi.ID="ClipRect";class Si{static create(t,e){var i=D.getItemByClass("DrawTexturesCmd",Si);return i.texture=t,t._addReference(),i.pos=e,i}recover(){this.texture._removeReference(),this.texture=null,this.pos=null,D.recover("DrawTexturesCmd",this)}run(t,e,i){t.drawTextures(this.texture,this.pos,e,i)}get cmdID(){return Si.ID}}Si.ID="DrawTextures";class xe{constructor(){this._textIsWorldText=!1,this._fontColor=4294967295,this._strokeColor=0,this._fontObj=xe._defFontObj,this._nTexAlign=0}static create(t,e,i,s,r,a,n,h,o){var l=D.getItemByClass("FillTextCmd",xe);return l.text=t,l._textIsWorldText=t instanceof Bi,l._words=e,l.x=i,l.y=s,l.font=r,l.color=a,l.textAlign=n,l._lineWidth=h,l._borderColor=o,l}recover(){D.recover("FillTextCmd",this)}run(t,e,i){c.stage.isGlobalRepaint()&&this._textIsWorldText&&this._text.cleanCache(),this._words?K._textRender.fillWords(t,this._words,this.x+e,this.y+i,this._fontObj,this._color,this._borderColor,this._lineWidth):this._textIsWorldText?t._fast_filltext(this._text,this.x+e,this.y+i,this._fontObj,this._color,this._borderColor,this._lineWidth,this._nTexAlign,0):K._textRender.filltext(t,this._text,this.x+e,this.y+i,this.font,this.color,this._borderColor,this._lineWidth,this._textAlign)}get cmdID(){return xe.ID}get text(){return this._text}set text(t){this._text=t,this._textIsWorldText=t instanceof Bi,this._textIsWorldText&&this._text.cleanCache()}get font(){return this._font}set font(t){this._font=t,this._fontObj=ee.Parse(t),this._textIsWorldText&&this._text.cleanCache()}get color(){return this._color}set color(t){this._color=t,this._fontColor=lt.create(t).numColor,this._textIsWorldText&&this._text.cleanCache()}get textAlign(){return this._textAlign}set textAlign(t){switch(this._textAlign=t,t){case"center":this._nTexAlign=c.Context.ENUM_TEXTALIGN_CENTER;break;case"right":this._nTexAlign=c.Context.ENUM_TEXTALIGN_RIGHT;break;default:this._nTexAlign=c.Context.ENUM_TEXTALIGN_DEFAULT}this._textIsWorldText&&this._text.cleanCache()}}xe.ID="FillText",xe._defFontObj=new ee(null);class Yt{constructor(){}static regCacheByFunction(t,e){Yt.unRegCacheByFunction(t,e);var i;i={tryDispose:t,getCacheList:e},Yt._cacheList.push(i)}static unRegCacheByFunction(t,e){var i,s;for(s=Yt._cacheList.length,i=0;i0&&(Yt._index++,Yt._index=Yt._index%s,t[Yt._index].tryDispose(!1),!(c.Browser.now()-e>Yt.loopTimeLimit));)i--}}}Yt.loopTimeLimit=2,Yt._cacheList=[],Yt._index=0;class Le{constructor(){this.useDic={},this.shapeDic={},this.shapeLineDic={},this._id=0,this._checkKey=!1,this._freeIdArray=[],Yt.regCacheByFunction(this.startDispose.bind(this),this.getCacheList.bind(this))}static getInstance(){return Le.instance=Le.instance||new Le}getId(){return this._id++}addShape(t,e){this.shapeDic[t]=e,this.useDic[t]||(this.useDic[t]=!0)}addLine(t,e){this.shapeLineDic[t]=e,this.shapeLineDic[t]||(this.shapeLineDic[t]=!0)}getShape(t){this._checkKey&&this.useDic[t]!=null&&(this.useDic[t]=!0)}deleteShape(t){this.shapeDic[t]&&(this.shapeDic[t]=null,delete this.shapeDic[t]),this.shapeLineDic[t]&&(this.shapeLineDic[t]=null,delete this.shapeLineDic[t]),this.useDic[t]!=null&&delete this.useDic[t]}getCacheList(){var t,e=[];for(t in this.shapeDic)e.push(this.shapeDic[t]);for(t in this.shapeLineDic)e.push(this.shapeLineDic[t]);return e}startDispose(t){var e;for(e in this.useDic)this.useDic[e]=!1;this._checkKey=!0}endDispose(){if(this._checkKey){var t;for(t in this.useDic)this.useDic[t]||this.deleteShape(t);this._checkKey=!1}}}class xi{constructor(){this._sp=null,this._one=null,this._render=this._renderEmpty,this._cmds=null,this._vectorgraphArray=null,this._graphicBounds=null,this.autoDestroy=!1,this._createData()}_createData(){}_clearData(){}_destroyData(){}destroy(){this.clear(!0),this._graphicBounds&&this._graphicBounds.destroy(),this._graphicBounds=null,this._vectorgraphArray=null,this._sp&&(this._sp._renderType=0,this._sp._setRenderType(0),this._sp=null),this._destroyData()}clear(t=!0){if(t){var e=this._one;if(this._cmds){var i,s=this._cmds.length;for(i=0;i-1;i--)if(this._isTextCmd(e[i]))return e[i].text=t,!0}else if(this._one&&this._isTextCmd(this._one))return this._one.text=t,!0;return!1}_isTextCmd(t){var e=t.cmdID;return e==xe.ID}replaceTextColor(t){this._repaint();var e=this._cmds;if(!e)this._one&&this._isTextCmd(this._one)&&this._setTextCmdColor(this._one,t);else for(var i=e.length-1;i>-1;i--)this._isTextCmd(e[i])&&this._setTextCmdColor(e[i],t)}_setTextCmdColor(t,e){var i=t.cmdID;switch(i){case xe.ID:t.color=e;break}}loadImage(t,e=0,i=0,s=0,r=0,a=null){var n=c.Loader.getRes(t);n?n.getIsReady()?this.drawImage(n,e,i,s,r):n.once(T.READY,this,this.drawImage,[n,e,i,s,r]):(n=new ut,n.load(t),c.Loader.cacheTexture(t,n),n.once(T.READY,this,this.drawImage,[n,e,i,s,r])),a!=null&&(n.getIsReady()?a.call(this._sp):n.on(T.READY,this._sp,a))}_renderEmpty(t,e,i,s){}_renderAll(t,e,i,s){for(var r=this._cmds,a=0,n=r.length;a=1&&a?n/2:0,o=a?n:0;return this._saveToCmd(j._context.drawRect,ni.create.call(this,t+h,e+h,i-o,s-o,r,a,n))}drawCircle(t,e,i,s,r=null,a=1){var n=a>=1&&r?a/2:0;return this._saveToCmd(j._context._drawCircle,Je.create.call(this,t,e,i-n,s,r,a,0))}drawPie(t,e,i,s,r,a,n=null,h=1){var o=h>=1&&n?h/2:0,l=n?h:0;return this._saveToCmd(j._context._drawPie,ri.create.call(this,t+o,e+o,i-l,J.toRadian(s),J.toRadian(r),a,n,h,0))}drawPoly(t,e,i,s,r=null,a=1){var n=!1;i.length>6?n=!1:n=!0;var h=a>=1&&r?a%2===0?0:.5:0;return this._saveToCmd(j._context._drawPoly,ai.create.call(this,t+h,e+h,i,s,r,a,n,0))}drawPath(t,e,i,s=null,r=null){return this._saveToCmd(j._context._drawPath,si.create.call(this,t,e,i,s,r))}draw9Grid(t,e=0,i=0,s=0,r=0,a){this._saveToCmd(null,Ti.create(t,e,i,s,r,a))}}class Q{}Q.NOT_ACTIVE=1,Q.ACTIVE_INHIERARCHY=2,Q.AWAKED=4,Q.NOT_READY=8,Q.DISPLAY=16,Q.HAS_ZORDER=32,Q.HAS_MOUSE=64,Q.DISPLAYED_INSTAGE=128,Q.DRAWCALL_OPTIMIZE=256;class Rt{static __init__(){Rt.map[P.ALPHA|P.TRANSFORM|P.GRAPHICS]=Rt.alpha_transform_drawLayaGL,Rt.map[P.ALPHA|P.GRAPHICS]=Rt.alpha_drawLayaGL,Rt.map[P.TRANSFORM|P.GRAPHICS]=Rt.transform_drawLayaGL,Rt.map[P.TRANSFORM|P.CHILDS]=Rt.transform_drawNodes,Rt.map[P.ALPHA|P.TRANSFORM|P.TEXTURE]=Rt.alpha_transform_drawTexture,Rt.map[P.ALPHA|P.TEXTURE]=Rt.alpha_drawTexture,Rt.map[P.TRANSFORM|P.TEXTURE]=Rt.transform_drawTexture,Rt.map[P.GRAPHICS|P.CHILDS]=Rt.drawLayaGL_drawNodes}static transform_drawTexture(t,e,i,s){var r=t._style,a=t.texture;e.saveTransform(Rt.curMat),e.transformByMatrix(t.transform,i,s);var n=t._width||a.sourceWidth,h=t._height||a.sourceHeight,o=n/a.sourceWidth,l=h/a.sourceHeight;if(n=a.width*o,h=a.height*l,n<=0||h<=0)return null;var u=-t.pivotX+a.offsetX*o,_=-t.pivotY+a.offsetY*l;e.drawTexture(a,u,_,n,h),e.restoreTransform(Rt.curMat)}static alpha_drawTexture(t,e,i,s){var r=t._style,a,n=t.texture;if((a=r.alpha)>.01||t._needRepaint()){var h=e.globalAlpha;e.globalAlpha*=a;var o=t._width||n.width,l=t._height||n.height,u=o/n.sourceWidth,_=l/n.sourceHeight;if(o=n.width*u,l=n.height*_,o<=0||l<=0)return null;var f=i-r.pivotX+n.offsetX*u,p=s-r.pivotY+n.offsetY*_;e.drawTexture(n,f,p,o,l),e.globalAlpha=h}}static alpha_transform_drawTexture(t,e,i,s){var r=t._style,a,n=t.texture;if((a=r.alpha)>.01||t._needRepaint()){var h=e.globalAlpha;e.globalAlpha*=a,e.saveTransform(Rt.curMat),e.transformByMatrix(t.transform,i,s);var o=t._width||n.sourceWidth,l=t._height||n.sourceHeight,u=o/n.sourceWidth,_=l/n.sourceHeight;if(o=n.width*u,l=n.height*_,o<=0||l<=0)return null;var f=-r.pivotX+n.offsetX*u,p=-r.pivotY+n.offsetY*_;e.drawTexture(n,f,p,o,l),e.restoreTransform(Rt.curMat),e.globalAlpha=h}}static alpha_transform_drawLayaGL(t,e,i,s){var r=t._style,a;if((a=r.alpha)>.01||t._needRepaint()){var n=e.globalAlpha;e.globalAlpha*=a,e.saveTransform(Rt.curMat),e.transformByMatrix(t.transform,i,s),t._graphics&&t._graphics._render(t,e,-r.pivotX,-r.pivotY),e.restoreTransform(Rt.curMat),e.globalAlpha=n}}static alpha_drawLayaGL(t,e,i,s){var r=t._style,a;if((a=r.alpha)>.01||t._needRepaint()){var n=e.globalAlpha;e.globalAlpha*=a,t._graphics&&t._graphics._render(t,e,i-r.pivotX,s-r.pivotY),e.globalAlpha=n}}static transform_drawLayaGL(t,e,i,s){var r=t._style;e.saveTransform(Rt.curMat),e.transformByMatrix(t.transform,i,s),t._graphics&&t._graphics._render(t,e,-r.pivotX,-r.pivotY),e.restoreTransform(Rt.curMat)}static transform_drawNodes(t,e,i,s){var r=t._getBit(Q.DRAWCALL_OPTIMIZE)&&e.drawCallOptimize(!0),a=t._style;e.saveTransform(Rt.curMat),e.transformByMatrix(t.transform,i,s),i=-a.pivotX,s=-a.pivotY;var n=t._children,h=n.length,o;if(a.viewport){var l=a.viewport,u=l.x,_=l.y,f=l.right,p=l.bottom,m,g;for(y=0;yu&&(g=o._y)_&&o.render(e,i,s)}else for(var y=0;yu&&(g=o._y)_&&o.render(e,i,s)}else for(var y=0;y0;)i&t&&(e=new xt(i,e)),i=i>>1;return e}onCreate(t){}_style(t,e,i,s){var r=t._style;r.render!=null&&r.render(t,e,i,s);var a=this._next;a._fun.call(a,t,e,i,s)}_no(t,e,i,s){}_custom(t,e,i,s){t.customRender(e,i,s),this._next._fun.call(this._next,t,e,0,0)}_clip(t,e,i,s){var r=this._next;if(r!=xt.NORENDER){var a=t._style.scrollRect,n=a.width,h=a.height;n===0||h===0||(e.save(),e.clipRect(i,s,n,h),r._fun.call(r,t,e,i-a.x,s-a.y),e.restore())}}_texture(t,e,i,s){var r=t.texture;if(r._getSource()){var a=t._width||r.sourceWidth,n=t._height||r.sourceHeight,h=a/r.sourceWidth,o=n/r.sourceHeight;if(a=r.width*h,n=r.height*o,a<=0||n<=0)return;var l=i-t.pivotX+r.offsetX*h,u=s-t.pivotY+r.offsetY*o;e.drawTexture(r,l,u,a,n)}var _=this._next;_!=xt.NORENDER&&_._fun.call(_,t,e,i,s)}_graphics(t,e,i,s){var r=t._style,a=t._graphics;a&&a._render(t,e,i-r.pivotX,s-r.pivotY);var n=this._next;n!=xt.NORENDER&&n._fun.call(n,t,e,i,s)}_image(t,e,i,s){var r=t._style;e.drawTexture2(i,s,r.pivotX,r.pivotY,t.transform,t._graphics._one)}_image2(t,e,i,s){var r=t._style;e.drawTexture2(i,s,r.pivotX,r.pivotY,t.transform,t._graphics._one)}_alpha(t,e,i,s){var r=t._style,a;if((a=r.alpha)>.01||t._needRepaint()){var n=e.globalAlpha;e.globalAlpha*=a;var h=this._next;h._fun.call(h,t,e,i,s),e.globalAlpha=n}}_transform(t,e,i,s){var r=t.transform,a=this._next,n=t._style;r&&a!=xt.NORENDER?(e.save(),e.transform(r.a,r.b,r.c,r.d,r.tx+i,r.ty+s),a._fun.call(a,t,e,0,0),e.restore()):a!=xt.NORENDER&&a._fun.call(a,t,e,i,s)}_children(t,e,i,s){var r=t._style,a=t._children,n=a.length,h;i=i-t.pivotX,s=s-t.pivotY;var o=t._getBit(Q.DRAWCALL_OPTIMIZE)&&e.drawCallOptimize(!0);if(r.viewport){var l=r.viewport,u=l.x,_=l.y,f=l.right,p=l.bottom,m,g;for(y=0;yu&&(g=h._y)_&&h.render(e,i,s)}else for(var y=0;y2048||p>2048)){console.warn("cache bitmap size larger than 2048,cache ignored"),r.releaseContext(),a._fun.call(a,t,e,i,s);return}if(h||(r.createContext(),h=r.canvas),n=h.context,n.sprite=t,(h.width!=f||h.height!=p)&&h.size(f,p),_==="bitmap"?n.asBitmap=!0:_==="normal"&&(n.asBitmap=!1),n.clear(),m!=1||g!=1){var C=n;C.save(),C.scale(m,g),a._fun.call(a,t,n,-o,-l),C.restore(),t._applyFilters()}else C=n,a._fun.call(a,t,n,-o,-l),t._applyFilters();r.staticCache&&(r.reCache=!1),F.canvasReCache++}_canvas_webgl_normal_repaint(t,e){var i=t._cacheStyle,s=this._next,r=i.canvas,a=i.cacheAs;i._calculateCacheRect(t,a,0,0),r||(r=new ls(e,t),i.canvas=r);var n=r.context;r.startRec(),s._fun.call(s,t,n,t.pivotX,t.pivotY),t._applyFilters(),F.canvasReCache++,r.endRec()}_blend(t,e,i,s){var r=t._style,a=this._next;r.blendMode?(e.save(),e.globalCompositeOperation=r.blendMode,a._fun.call(a,t,e,i,s),e.restore()):a._fun.call(a,t,e,i,s)}_mask(t,e,i,s){var r=this._next,a=t.mask,n=e;if(a){n.save();var h=n.globalCompositeOperation,o=new tt;if(o.copyFrom(a.getBounds()),o.width=Math.round(o.width),o.height=Math.round(o.height),o.x=Math.round(o.x),o.y=Math.round(o.y),o.width>0&&o.height>0){var l=o.width,u=o.height,_=li.getRT(l,u);n.breakNextMerge(),n.pushRT(),n.addRenderObject(te.create([n,_,l,u],xt.tmpTarget,this)),a.render(n,-o.x,-o.y),n.breakNextMerge(),n.popRT(),n.save();let m=.1;n.clipRect(i+o.x-t.getStyle().pivotX+m,s+o.y-t.getStyle().pivotY+m,l-m*2,u-m*2),r._fun.call(r,t,n,i,s),n.restore(),h=n.globalCompositeOperation,n.addRenderObject(te.create(["mask"],xt.setBlendMode,this));var f=vt.create(V.TEXTURE2D,0),p=ut.INV_UV;n.drawTarget(_,i+o.x-t.getStyle().pivotX,s+o.y-t.getStyle().pivotY,l,u,et.TEMP.identity(),f,p,6),n.addRenderObject(te.create([_],xt.recycleTarget,this)),n.addRenderObject(te.create([h],xt.setBlendMode,this))}n.restore()}else r._fun.call(r,t,e,i,s)}static tmpTarget(t,e,i,s){e.start(),e.clear(0,0,0,0)}static recycleTarget(t){li.releaseRT(t)}static setBlendMode(t){var e=A.mainContext;rt.targetFns[rt.TOINT[t]](e)}}xt.INIT=69905,xt.renders=[],xt.NORENDER=new xt(0,null),xt.tempUV=new Array(8);class je extends zi{constructor(t=!1){super(),t?this._source=x.createElement("canvas"):this._source=this,this.lock=!0}get source(){return this._source}_getSource(){return this._source}clear(){this._ctx&&(this._ctx.clear?this._ctx.clear():this._ctx.clearRect(0,0,this._width,this._height)),this._texture&&(this._texture.destroy(),this._texture=null)}destroy(){super.destroy(),this._setCPUMemory(0),this._ctx&&this._ctx.destroy&&this._ctx.destroy(),this._ctx=null}release(){}get context(){return this._ctx?this._ctx:(this._source==this?this._ctx=new c.Context:this._ctx=this._source.getContext(c.Render.isConchApp?"layagl":"2d"),this._ctx._canvas=this,this._ctx)}_setContext(t){this._ctx=t}getContext(t,e=null){return this.context}getMemSize(){return 0}size(t,e){(this._width!=t||this._height!=e||this._source&&(this._source.width!=t||this._source.height!=e))&&(this._width=t,this._height=e,this._setCPUMemory(t*e*4),this._ctx&&this._ctx.size&&this._ctx.size(t,e),this._source&&(this._source.height=e,this._source.width=t),this._texture&&(this._texture.destroy(),this._texture=null))}getTexture(){if(!this._texture){var t=new _t;t.loadImageSource(this.source),this._texture=new ut(t)}return this._texture}toBase64(t,e){if(this._source)if(c.Render.isConchApp){var i=window;if(i.conchConfig.threadMode==2)throw"native 2 thread mode use toBase64Async";var s=this._ctx._targets.sourceWidth,r=this._ctx._targets.sourceHeight,a=this._ctx._targets.getData(0,0,s,r);return i.conchToBase64FlipY?i.conchToBase64FlipY(t,e,a.buffer,s,r):i.conchToBase64(t,e,a.buffer,s,r)}else return this._source.toDataURL(t,e);return null}toBase64Async(t,e,i){var s=this._ctx._targets.sourceWidth,r=this._ctx._targets.sourceHeight;this._ctx._targets.getDataAsync(0,0,s,r,function(a){let n=window;var h=n.conchToBase64FlipY?n.conchToBase64FlipY(t,e,a.buffer,s,r):n.conchToBase64(t,e,a.buffer,s,r);i(h)})}}class ye{contains(t,e){return ye._isHitGraphic(t,e,this.hit)?!ye._isHitGraphic(t,e,this.unHit):!1}static _isHitGraphic(t,e,i){if(!i)return!1;var s=i.cmds;if(!s&&i._one&&(s=ye._cmds,s.length=1,s[0]=i._one),!s)return!1;var r,a;a=s.length;var n;for(r=0;r=Math.max(n,o))){var _=(s.y-n)*(h-a)/(o-n)+a;_>s.x&&r++}return r%2==1}get hit(){return this._hit||(this._hit=new c.Graphics),this._hit}set hit(t){this._hit=t}get unHit(){return this._unHit||(this._unHit=new c.Graphics),this._unHit}set unHit(t){this._unHit=t}}ye._cmds=[],ye._rect=new tt,ye._ptPoint=new Tt;class Y{static regClass(t,e){Y._classMap[t]=e}static regShortClassName(t){for(var e=0;e=0)return null;this._extUIChild.push(t)}return null}removeInputChild(t){var e=this._extUIChild.indexOf(t);e>=0&&this._extUIChild.splice(e,1)}addChildren(...t){for(var e=0,i=t.length;e=0&&e<=this._children.length){if(t._parent===this){var i=this.getChildIndex(t);this._children.splice(i,1),this._children.splice(e,0,t),this._childChanged()}else t._parent&&t._parent.removeChild(t),this._children===ge.ARRAY_EMPTY&&(this._children=[]),this._children.splice(e,0,t),t._setParent(this);return t}else throw new Error("appendChildAt:The index is out of bounds")}getChildIndex(t){return this._children.indexOf(t)}getChildByName(t){var e=this._children;if(e)for(var i=0,s=e.length;i=i.length)throw new Error("setChildIndex:The index is out of bounds.");var s=this.getChildIndex(t);if(s<0)throw new Error("setChildIndex:node is must child of this object.");return i.splice(s,1),i.splice(e,0,t),this._childChanged(),t}_childChanged(t=null){}removeChild(t){if(!this._children)return t;var e=this._children.indexOf(t);return this.removeChildAt(e)}removeSelf(){return this._parent&&this._parent.removeChild(this),this}removeChildByName(t){var e=this.getChildByName(t);return e&&this.removeChild(e),e}removeChildAt(t){var e=this.getChildAt(t);return e&&(this._children.splice(t,1),e._setParent(null)),e}removeChildren(t=0,e=2147483647){if(this._children&&this._children.length>0){var i=this._children;if(t===0&&e>=i.length-1){var s=i;this._children=ge.ARRAY_EMPTY}else s=i.splice(t,e-t+1);for(var r=0,a=s.length;r-1?(this._children.splice(i,1,t),e._setParent(null),t._setParent(this),t):null}get numChildren(){return this._children.length}get parent(){return this._parent}_setParent(t){this._parent!==t&&(t?(this._parent=t,this._onAdded(),this.event(T.ADDED),this._getBit(Q.DISPLAY)&&(this._setUpNoticeChain(),t.displayedInStage&&this._displayChild(this,!0)),t._childChanged(this)):(this._onRemoved(),this.event(T.REMOVED),this._parent._childChanged(),this._getBit(Q.DISPLAY)&&this._displayChild(this,!1),this._parent=t))}get displayedInStage(){return this._getBit(Q.DISPLAY)?this._getBit(Q.DISPLAYED_INSTAGE):(this._setBitUp(Q.DISPLAY),this._getBit(Q.DISPLAYED_INSTAGE))}_updateDisplayedInstage(){var t;t=this;for(var e=c.stage,i=!1;t;){if(t._getBit(Q.DISPLAY)){i=t._getBit(Q.DISPLAYED_INSTAGE);break}if(t===e||t._getBit(Q.DISPLAYED_INSTAGE)){i=!0;break}t=t._parent}this._setBit(Q.DISPLAYED_INSTAGE,i)}_setDisplay(t){this._getBit(Q.DISPLAYED_INSTAGE)!==t&&(this._setBit(Q.DISPLAYED_INSTAGE,t),t?this.event(T.DISPLAY):this.event(T.UNDISPLAY))}_displayChild(t,e){var i=t._children;if(i)for(var s=0,r=i.length;s0?this._displayChild(a,e):a._setDisplay(e))}t._setDisplay(e)}contains(t){if(t===this)return!0;for(;t;){if(t._parent===this)return!0;t=t._parent}return!1}timerLoop(t,e,i,s=null,r=!0,a=!1){var n=this.scene?this.scene.timer:c.timer;n.loop(t,e,i,s,r,a)}timerOnce(t,e,i,s=null,r=!0){var a=this.scene?this.scene.timer:c.timer;a._create(!1,!1,t,e,i,s,r)}frameLoop(t,e,i,s=null,r=!0){var a=this.scene?this.scene.timer:c.timer;a._create(!0,!0,t,e,i,s,r)}frameOnce(t,e,i,s=null,r=!0){var a=this.scene?this.scene.timer:c.timer;a._create(!0,!1,t,e,i,s,r)}clearTimer(t,e){var i=this.scene?this.scene.timer:c.timer;i.clear(t,e)}callLater(t,e=null){var i=this.scene?this.scene.timer:c.timer;i.callLater(this,t,e)}runCallLater(t){var e=this.scene?this.scene.timer:c.timer;e.runCallLater(this,t)}get scene(){return this._scene}get active(){return!this._getBit(Q.NOT_READY)&&!this._getBit(Q.NOT_ACTIVE)}set active(t){if(t=!!t,!this._getBit(Q.NOT_ACTIVE)!==t){if(this._activeChangeScripts&&this._activeChangeScripts.length!==0)throw t?"Node: can't set the main inActive node active in hierarchy,if the operate is in main inActive node or it's children script's onDisable Event.":"Node: can't set the main active node inActive in hierarchy,if the operate is in main active node or it's children script's onEnable Event.";this._setBit(Q.NOT_ACTIVE,!t),this._parent&&this._parent.activeInHierarchy&&(t?this._processActive():this._processInActive())}}get activeInHierarchy(){return this._getBit(Q.ACTIVE_INHIERARCHY)}_onActive(){F.spriteCount++}_onInActive(){F.spriteCount--}_onActiveInScene(){}_onInActiveInScene(){}_parse(t,e){}_setBelongScene(t){if(!this._scene){this._scene=t,this._onActiveInScene();for(var e=0,i=this._children.length;e1?1:t,this._setAlpha(t)}get visible(){return this.get_visible()}set visible(t){this.set_visible(t)}get_visible(){return this._visible}set_visible(t){this._visible!==t&&(this._visible=t,this.parentRepaint(P.REPAINT_ALL))}_setBlendMode(t){}get blendMode(){return this._style.blendMode}set blendMode(t){this._setBlendMode(t),this.getStyle().blendMode=t,t&&t!="source-over"?this._renderType|=P.BLEND:this._renderType&=~P.BLEND,this._setRenderType(this._renderType),this.parentRepaint()}get graphics(){return this._graphics||(this.graphics=new xi,this._graphics.autoDestroy=!0),this._graphics}_setGraphics(t){}_setGraphicsCallBack(){}set graphics(t){this._graphics&&(this._graphics._sp=null),this._graphics=t,t?(this._setGraphics(t),this._renderType|=P.GRAPHICS,t._sp=this):this._renderType&=~P.GRAPHICS,this._setRenderType(this._renderType),this.repaint()}get scrollRect(){return this._style.scrollRect}_setScrollRect(t){}set scrollRect(t){this.getStyle().scrollRect=t,this._setScrollRect(t),this.repaint(),t?this._renderType|=P.CLIP:this._renderType&=~P.CLIP,this._setRenderType(this._renderType)}pos(t,e,i=!1){if(this._x!==t||this._y!==e){if(this.destroyed)return this;if(i){this._setX(t),this._setY(e),this.parentRepaint(P.REPAINT_CACHE);var s=this._cacheStyle.maskParent;s&&s.repaint(P.REPAINT_CACHE)}else this.x=t,this.y=e}return this}pivot(t,e){return this.pivotX=t,this.pivotY=e,this}size(t,e){return this.width=t,this.height=e,this}scale(t,e,i=!1){var s=this.getStyle();if(s.scaleX!=t||s.scaleY!=e){if(this.destroyed)return this;i?(this._setScaleX(t),this._setScaleY(e),this._setTranformChange()):(this.scaleX=t,this.scaleY=e)}return this}skew(t,e){return this.skewX=t,this.skewY=e,this}render(t,e,i){xt.renders[this._renderType]._fun(this,t,e+this._x,i+this._y),this._repaint=0}drawToCanvas(t,e,i,s){return zt.drawToCanvas(this,this._renderType,t,e,i,s)}drawToTexture(t,e,i,s,r=null){return zt.drawToTexture(this,this._renderType,t,e,i,s,r)}drawToTexture3D(t,e,i){throw"not implement"}static drawToCanvas(t,e,i,s,r,a){r-=t.x,a-=t.y,r|=0,a|=0,i|=0,s|=0;var n=new K;n.size(i,s),n.asBitmap=!0,n._targets.start(),n._targets.clear(0,0,0,0),xt.renders[e]._fun(t,n,r,a),n.flush(),n._targets.end(),n._targets.restore();var h=n._targets.getData(0,0,i,s);n.destroy();for(var o=new ImageData(i,s),l=i*4,u=o.data,_=s-1,f=_*l,p=0;_>=0;_--)u.set(h.subarray(p,p+l),f),f-=l,p+=l;var m=new je(!0);m.size(i,s);var g=m.getContext("2d");return g.putImageData(o,0,0),m}static drawToTexture(t,e,i,s,r,a,n=null){zt.drawtocanvCtx||(zt.drawtocanvCtx=new K),r-=t.x,a-=t.y,r|=0,a|=0,i|=0,s|=0;var h=n?zt.drawtocanvCtx:new K;if(h.clear(),h.size(i,s),n?h._targets=n:h.asBitmap=!0,h._targets&&(h._targets.start(),h._targets.clear(0,0,0,0),xt.renders[e]._fun(t,h,r,a),h.flush(),h._targets.end(),h._targets.restore()),!n){var o=new ut(h._targets,ut.INV_UV);return h.destroy(!0),o}return t._repaint=0,n}customRender(t,e,i){this._repaint=P.REPAINT_ALL}_applyFilters(){}get filters(){return this._cacheStyle.filters}_setColorFilter(t){}set filters(t){t&&t.length===0&&(t=null),this._getCacheStyle().filters=t?t.slice():null,t&&t.length?(this._setColorFilter(t[0]),this._renderType|=P.FILTERS):(this._setColorFilter(null),this._renderType&=~P.FILTERS),this._setRenderType(this._renderType),t&&t.length>0?(this._getBit(Q.DISPLAY)||this._setBitUp(Q.DISPLAY),t.length==1&&t[0]instanceof Xt||(this._getCacheStyle().cacheForFilters=!0,this._checkCanvasEnable())):this._cacheStyle.cacheForFilters&&(this._cacheStyle.cacheForFilters=!1,this._checkCanvasEnable()),this._getCacheStyle().hasGlowFilter=this._isHaveGlowFilter(),this.repaint()}_isHaveGlowFilter(){var t,e;if(this.filters){for(t=0;t=0;)s=r[a],t=s.fromParentPoint(t),a--;return t}toParentPoint(t){if(!t)return t;t.x-=this.pivotX,t.y-=this.pivotY,this.transform&&this._transform.transformPoint(t),t.x+=this._x,t.y+=this._y;var e=this._style.scrollRect;return e&&(t.x-=e.x,t.y-=e.y),t}fromParentPoint(t){if(!t)return t;t.x-=this._x,t.y-=this._y;var e=this._style.scrollRect;return e&&(t.x+=e.x,t.y+=e.y),this.transform&&this._transform.invertTransformPoint(t),t.x+=this.pivotX,t.y+=this.pivotY,t}fromStagePoint(t){return t}on(t,e,i,s=null){return this._mouseState!==1&&this.isMouseEvent(t)?(this.mouseEnabled=!0,this._setBit(Q.HAS_MOUSE,!0),this._parent&&this._onDisplay(),this._createListener(t,e,i,s,!1)):super.on(t,e,i,s)}once(t,e,i,s=null){return this._mouseState!==1&&this.isMouseEvent(t)?(this.mouseEnabled=!0,this._setBit(Q.HAS_MOUSE,!0),this._parent&&this._onDisplay(),this._createListener(t,e,i,s,!0)):super.once(t,e,i,s)}_onDisplay(t){if(this._mouseState!==1){var e=this;for(e=e.parent;e&&e._mouseState!==1&&!e._getBit(Q.HAS_MOUSE);)e.mouseEnabled=!0,e._setBit(Q.HAS_MOUSE,!0),e=e.parent}}_setParent(t){super._setParent(t),t&&this._getBit(Q.HAS_MOUSE)&&this._onDisplay()}loadImage(t,e=null){if(!t)this.texture=null,s.call(this);else{var i=c.Loader.textureMap[$.formatURL(t)];i||(i=new ut,i.load(t),c.Loader.cacheTexture(t,i)),this.texture=i,i.getIsReady()?s.call(this):i.once(T.READY,this,s)}function s(){this.repaint(P.REPAINT_ALL),e&&e.run()}return this}static fromImage(t){return new zt().loadImage(t)}repaint(t=P.REPAINT_CACHE){this._repaint&t||(this._repaint|=t,this.parentRepaint(t)),this._cacheStyle&&this._cacheStyle.maskParent&&this._cacheStyle.maskParent.repaint(t)}_needRepaint(){return this._repaint&P.REPAINT_CACHE&&this._cacheStyle.enableCanvasRender&&this._cacheStyle.reCache}_childChanged(t=null){this._children.length?this._renderType|=P.CHILDS:this._renderType&=~P.CHILDS,this._setRenderType(this._renderType),t&&this._getBit(Q.HAS_ZORDER)&&c.systemTimer.callLater(this,this.updateZOrder),this.repaint(P.REPAINT_ALL)}parentRepaint(t=P.REPAINT_CACHE){var e=this._parent;e&&!(e._repaint&t)&&(e._repaint|=t,e.parentRepaint(t))}get stage(){return c.stage}get hitArea(){return this._style.hitArea}set hitArea(t){this.getStyle().hitArea=t}_setMask(t){}get mask(){return this._cacheStyle.mask}set mask(t){t&&this.mask&&this.mask._cacheStyle.maskParent||(this._getCacheStyle().mask=t,this._setMask(t),this._checkCanvasEnable(),t?t._getCacheStyle().maskParent=this:this.mask&&(this.mask._getCacheStyle().maskParent=null),this._renderType|=P.MASK,this._setRenderType(this._renderType),this.parentRepaint(P.REPAINT_ALL))}get mouseEnabled(){return this._mouseState>1}set mouseEnabled(t){this._mouseState=t?2:1}startDrag(t=null,e=!1,i=0,s=300,r=null,a=!1,n=.92){this._style.dragging||(this.getStyle().dragging=new c.Dragging),this._style.dragging.start(this,t,e,i,s,r,a,n)}stopDrag(){this._style.dragging&&this._style.dragging.stop()}_setDisplay(t){t||this._cacheStyle&&(this._cacheStyle.releaseContext(),this._cacheStyle.releaseFilterCache(),this._cacheStyle.hasGlowFilter&&(this._cacheStyle.hasGlowFilter=!1)),super._setDisplay(t)}hitTestPoint(t,e){var i=this.globalToLocal(Tt.TEMP.setTo(t,e));t=i.x,e=i.y;var s=this._style.hitArea?this._style.hitArea:this._width>0&&this._height>0?tt.TEMP.setTo(0,0,this._width,this._height):this.getSelfBounds();return s.contains(t,e)}getMousePoint(){return this.globalToLocal(Tt.TEMP.setTo(c.stage.mouseX,c.stage.mouseY))}get globalScaleX(){for(var t=1,e=this;e&&e!==c.stage;)t*=e.scaleX,e=e.parent;return t}get globalRotation(){for(var t=0,e=this;e&&e!==c.stage;)t+=e.rotation,e=e.parent;return t}get globalScaleY(){for(var t=1,e=this;e&&e!==c.stage;)t*=e.scaleY,e=e.parent;return t}get mouseX(){return this.getMousePoint().x}get mouseY(){return this.getMousePoint().y}get zOrder(){return this._zOrder}set zOrder(t){this._zOrder!=t&&(this._zOrder=t,this._parent&&(t&&this._parent._setBit(Q.HAS_ZORDER,!0),c.systemTimer.callLater(this._parent,this.updateZOrder)))}get texture(){return this._texture}_setTexture(t){}set texture(t){typeof t=="string"?this.loadImage(t):this._texture!=t&&(this._texture&&this._texture._removeReference(),this._texture=t,t&&t._addReference(),this._setTexture(t),this._setWidth(this._texture,this.width),this._setHeight(this._texture,this.height),t?this._renderType|=P.TEXTURE:this._renderType&=~P.TEXTURE,this._setRenderType(this._renderType),this.repaint())}get viewport(){return this._style.viewport}set viewport(t){if(typeof t=="string"){var e;e=t.split(","),e.length>3&&(t=new tt(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])))}this.getStyle().viewport=t}_setRenderType(t){}_setTranformChange(){this._tfChanged=!0,this._renderType|=P.TRANSFORM,this.parentRepaint(P.REPAINT_CACHE)}_setBgStyleColor(t,e,i,s,r){}_setBorderStyleColor(t,e,i,s,r,a){}captureMouseEvent(t){c.MouseManager.instance.setCapture(this,t)}releaseMouseEvent(){c.MouseManager.instance.releaseCapture()}set drawCallOptimize(t){this._setBit(Q.DRAWCALL_OPTIMIZE,t)}get drawCallOptimize(){return this._getBit(Q.DRAWCALL_OPTIMIZE)}}Y.regClass("laya.display.Sprite",zt),Y.regClass("Laya.Sprite",zt);class Me extends Be{constructor(){super(...arguments),this.italic=!1}reset(){return super.reset(),this.italic=!1,this.align="left",this.wordWrap=!1,this.leading=0,this.padding=[0,0,0,0],this.bgColor=null,this.borderColor=null,this.asPassword=!1,this.stroke=0,this.strokeColor="#000000",this.bold=!1,this.underline=!1,this.underlineColor=null,this.currBitmapFont=null,this}recover(){this!==Me.EMPTY&&D.recover("TextStyle",this.reset())}static create(){return D.getItemByClass("TextStyle",Me)}render(t,e,i,s){(this.bgColor||this.borderColor)&&e.drawRect(i-this.pivotX,s-this.pivotY,t.width,t.height,this.bgColor,this.borderColor,1)}}Me.EMPTY=new Me;class st extends zt{constructor(){super(),this._textWidth=0,this._textHeight=0,this._lines=[],this._lineWidths=[],this._startX=0,this._startY=0,this._charSize={},this._valign="top",this._fontSize=st.defaultFontSize,this._font=st.defaultFont,this._color="#000000",this._singleCharRender=!1,this.overflow=st.VISIBLE,this._style=Me.EMPTY}static defaultFontStr(){return st.defaultFontSize+"px "+st.defaultFont}getStyle(){return this._style===Me.EMPTY&&(this._style=Me.create()),this._style}_getTextStyle(){return this._style===Me.EMPTY&&(this._style=Me.create()),this._style}static registerBitmapFont(t,e){st._bitmapFonts||(st._bitmapFonts={}),st._bitmapFonts[t]=e}static unregisterBitmapFont(t,e=!0){if(st._bitmapFonts&&st._bitmapFonts[t]){var i=st._bitmapFonts[t];e&&i.destroy(),delete st._bitmapFonts[t]}}destroy(t=!0){super.destroy(t),this._clipPoint=null,this._lines=null,this._lineWidths=null,this._words&&this._words.forEach(function(e){e.cleanCache()}),this._words=null,this._charSize=null}_getBoundPointsM(t=!1){var e=tt.TEMP;return e.setTo(0,0,this.width,this.height),e._getBoundPoints()}getGraphicBounds(t=!1){var e=tt.TEMP;return e.setTo(0,0,this.width,this.height),e}get width(){return this._width?this._width:this.textWidth+this.padding[1]+this.padding[3]}set width(t){t!=this._width&&(super.set_width(t),this.isChanged=!0,this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}_getCSSStyle(){return this._style}get height(){return this._height?this._height:this.textHeight}set height(t){t!=this._height&&(super.set_height(t),this.isChanged=!0,this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}get textWidth(){return this._isChanged&&c.systemTimer.runCallLater(this,this.typeset),this._textWidth}get textHeight(){return this._isChanged&&c.systemTimer.runCallLater(this,this.typeset),this._textHeight}get text(){return this._text||""}get_text(){return this._text||""}set_text(t){this._text!==t&&(this.lang(t+""),this.isChanged=!0,this.event(T.CHANGE),this.borderColor&&this._setBorderStyleColor(0,0,this.width,this.height,this.borderColor,1))}set text(t){this.set_text(t)}lang(t,e=null,i=null,s=null,r=null,a=null,n=null,h=null,o=null,l=null,u=null){if(t=st.langPacks&&st.langPacks[t]?st.langPacks[t]:t,arguments.length<2)this._text=t;else{for(var _=0,f=arguments.length;_0;s--)i+="\u25CF";return i}_renderText(){var t=this.padding,e=this._lines.length;this.overflow!=st.VISIBLE&&(e=Math.min(e,Math.floor((this.height-t[0]-t[2])/(this.leading+this._charSize.height))+1));var i=this.scrollY/(this._charSize.height+this.leading)|0,s=this.graphics;s.clear(!0);var r=this._getContextFont();c.Browser.context.font=r;var a=t[3],n="left",h=this._lines,o=this.leading+this._charSize.height,l=this._style.currBitmapFont;l&&(o=this.leading+l.getMaxHeight());var u=t[0];!l&&this._width>0&&this._textWidth<=this._width&&(this.align=="right"?(n="right",a=this._width-t[1]):this.align=="center"&&(n="center",a=this._width*.5+t[3]-t[1]));let _=1;if(l&&l.autoScaleSize&&(_=l.fontSize/this.fontSize),this._height>0){var f=this._textHeight>this._height?"top":this.valign;f==="middle"?u=(this._height-e/_*o)*.5+t[0]-t[2]:f==="bottom"&&(u=this._height-e/_*o-t[2])}if(this._clipPoint){if(s.save(),l&&l.autoScaleSize){var p,m;this._width?p=this._width-t[3]-t[1]:p=this._textWidth,this._height?m=this._height-t[0]-t[2]:m=this._textHeight,p*=_,m*=_,s.clipRect(t[3],t[0],p,m)}else s.clipRect(t[3],t[0],this._width?this._width-t[3]-t[1]:this._textWidth,this._height?this._height-t[0]-t[2]:this._textHeight);this.repaint()}var g=this._style,y=g.asPassword;"prompt"in this&&this.prompt==this._text&&(y=!1);for(var C=0,w=0,M=Math.min(this._lines.length,e+i)||1,R=i;R0;z--)B+="\u25CF"}if(B==null&&(B=""),C=a-(this._clipPoint?this._clipPoint.x:0),w=u+2+o*R-(this._clipPoint?this._clipPoint.y:0),this.underline&&this._drawUnderline(n,C,w,R),l){var S=this.width;l.autoScaleSize&&(S=this.width*_,C*=_,w*=_),l._drawText(B,this,C,w,this.align,S)}else this._words||(this._words=[]),this._words.length>R-i?k=this._words[R-i]:(k=new Bi,this._words.push(k)),k.setText(B),k.splitRender=this._singleCharRender,g.stroke?s.fillBorderText(k,C,w,r,this.color,n,g.stroke,g.strokeColor):s.fillText(k,C,w,r,this.color,n)}if(l&&l.autoScaleSize){var dt=1/_;this.scale(dt,dt)}this._clipPoint&&s.restore(),this._startX=a,this._startY=u}_drawUnderline(t,e,i,s){var r=this._lineWidths[s];switch(t){case"center":e-=r/2;break;case"right":e-=r;break}i+=this._charSize.height,this._graphics.drawLine(e,i,e+r,i,this.underlineColor||this.color,1)}typeset(){if(this._isChanged=!1,!this._text){this._clipPoint=null,this._textWidth=this._textHeight=0,this.graphics.clear(!0);return}c.Render.isConchApp?window.conchTextCanvas.font=this._getContextFont():c.Browser.context.font=this._getContextFont(),this._lines.length=0,this._lineWidths.length=0,this._isPassWordMode()?this._parseLines(this._getPassWordTxt(this._text)):this._parseLines(this._text),this._evalTextSize(),this._checkEnabledViewportOrNot()?this._clipPoint||(this._clipPoint=new Tt(0,0)):this._clipPoint=null,this._renderText()}_evalTextSize(){var t,e;t=Math.max.apply(this,this._lineWidths);let i=this._style.currBitmapFont;if(i){let s=i.getMaxHeight();i.autoScaleSize&&(s=this.fontSize),e=this._lines.length*(s+this.leading)+this.padding[0]+this.padding[2]}else e=this._lines.length*(this._charSize.height+this.leading)+this.padding[0]+this.padding[2],this._lines.length&&(e-=this.leading);(t!=this._textWidth||e!=this._textHeight)&&(this._textWidth=t,this._textHeight=e)}_checkEnabledViewportOrNot(){return this.overflow==st.SCROLL&&(this._width>0&&this._textWidth>this._width||this._height>0&&this._textHeight>this._height)}changeText(t){this._text!==t&&(this.lang(t+""),this._graphics&&this._graphics.replaceText(this._text)||this.typeset())}_parseLines(t){var e=this.wordWrap||this.overflow==st.HIDDEN;if(e)var i=this._getWordWrapWidth();var s=this._style.currBitmapFont;if(s)this._charSize.width=s.getMaxWidth(),this._charSize.height=s.getMaxHeight();else{var r=null;c.Render.isConchApp?r=window.conchTextCanvas.measureText(st._testWord):r=c.Browser.context.measureText(st._testWord),r||(r={width:100}),this._charSize.width=r.width,this._charSize.height=r.height||this.fontSize}for(var a=t.replace(/\r\n/g,` `).split(` `),n=0,h=a.length;ne){if(this.wordWrap){var l=t.substring(n,h),u=l.charCodeAt(l.length-1);if(u<19968||u>40869){var _=/(?:[^\s\!-\/])+$/.exec(l);_&&(h=_.index+n,_.index==0?h+=l.length:l=t.substring(n,h))}if(i.push(l),this._lineWidths.push(a-r),n=h,h+sthis._textWidth?this._textWidth:t,this._renderText())}get scrollX(){return this._clipPoint?this._clipPoint.x:0}set scrollY(t){this.overflow!=st.SCROLL||this.textHeightthis._textHeight?this._textHeight:t,this._renderText())}get scrollY(){return this._clipPoint?this._clipPoint.y:0}get maxScrollX(){return this.textWidth-1&&(t=t.replace("^^","")),this._restrictPattern=new RegExp(t,"g")):this._restrictPattern=null}set editable(t){this._editable=t,c.Render.isConchApp&&N.input.setForbidEdit(!t)}get editable(){return this._editable}get maxChars(){return this._maxChars}set maxChars(t){t<=0&&(t=1e5),this._maxChars=t}get prompt(){return this._prompt}set prompt(t){!this._text&&t&&super.set_color(this._promptColor),this.promptColor=this._promptColor,this._text?super.set_text(this._text==this._prompt?t:this._text):super.set_text(t),this._prompt=st.langPacks&&st.langPacks[t]?st.langPacks[t]:t}get promptColor(){return this._promptColor}set promptColor(t){this._promptColor=t,this._content||super.set_color(t)}get type(){return this._type}set type(t){t==="password"?this._getTextStyle().asPassword=!0:this._getTextStyle().asPassword=!1,this._type=t}}N.TYPE_TEXT="text",N.TYPE_PASSWORD="password",N.TYPE_EMAIL="email",N.TYPE_URL="url",N.TYPE_NUMBER="number",N.TYPE_RANGE="range",N.TYPE_DATE="date",N.TYPE_MONTH="month",N.TYPE_WEEK="week",N.TYPE_TIME="time",N.TYPE_DATE_TIME="datetime",N.TYPE_DATE_TIME_LOCAL="datetime-local",N.TYPE_SEARCH="search",N.IOS_IFRAME=!1,N.inputHeight=45,N.isInputting=!1,Y.regClass("laya.display.Input",N),Y.regClass("Laya.Input",N);class It{constructor(){this.preOvers=[],this.preDowns=[],this.preRightDowns=[],this.enable=!0,this._event=new T,this._lastClickTime=0}_clearTempArrs(){It._oldArr.length=0,It._newArr.length=0,It._tEleArr.length=0}getTouchFromArr(t,e){var i,s;s=e.length;var r;for(i=0;i=0;i--)e[i].id==t&&e.splice(i,1)}createTouchO(t,e){var i;return i=D.getItem("TouchData")||{},i.id=e,i.tar=t,i}onMouseDown(t,e,i=!1){if(this.enable){var s,r,a;s=this.getTouchFromArr(e,this.preOvers),a=this.getEles(t,null,It._tEleArr),s?s.tar=t:(r=this.createTouchO(t,e),this.preOvers.push(r)),x.onMobile&&this.sendEvents(a,T.MOUSE_OVER);var n;n=i?this.preDowns:this.preRightDowns,s=this.getTouchFromArr(e,n),s?s.tar=t:(r=this.createTouchO(t,e),n.push(r)),this.sendEvents(a,i?T.MOUSE_DOWN:T.RIGHT_MOUSE_DOWN),this._clearTempArrs()}}sendEvents(t,e){var i,s;s=t.length,this._event._stoped=!1;var r;for(r=t[0],i=0;i=0){o.splice(l,o.length-l);break}else r.push(s);r.length>0&&this.sendEvents(r,T.MOUSE_OUT),o.length>0&&this.sendEvents(o,T.MOUSE_OVER)}}}onMouseMove(t,e){if(this.enable){var i;i=this.getTouchFromArr(e,this.preOvers);var s;i?(this.checkMouseOutAndOverOfMove(t,i.tar),i.tar=t,s=this.getEles(t,null,It._tEleArr)):(s=this.getEles(t,null,It._tEleArr),this.sendEvents(s,T.MOUSE_OVER),this.preOvers.push(this.createTouchO(t,e))),this.sendEvents(s,T.MOUSE_MOVE),this._clearTempArrs()}}getLastOvers(){return It._tEleArr.length=0,this.preOvers.length>0&&this.preOvers[0].tar?this.getEles(this.preOvers[0].tar,null,It._tEleArr):(It._tEleArr.push(c.stage),It._tEleArr)}stageMouseOut(){var t;t=this.getLastOvers(),this.preOvers.length=0,this.sendEvents(t,T.MOUSE_OUT)}onMouseUp(t,e,i=!1){if(this.enable){var s,r,a,n,h,o,l,u=x.onMobile;r=this.getEles(t,null,It._tEleArr),this.sendEvents(r,i?T.MOUSE_UP:T.RIGHT_MOUSE_UP);var _;if(_=i?this.preDowns:this.preRightDowns,s=this.getTouchFromArr(e,_),s){var f,p=x.now();if(f=p-this._lastClickTime<300,this._lastClickTime=p,t==s.tar)l=r;else for(a=this.getEles(s.tar,null,It._oldArr),l=It._newArr,l.length=0,h=a.length,n=0;n=0&&l.push(o);l.length>0&&this.sendEvents(l,i?T.CLICK:T.RIGHT_CLICK),i&&f&&this.sendEvents(l,T.DOUBLE_CLICK),this.removeTouchFromArr(e,_),s.tar=null,D.recover("TouchData",s)}s=this.getTouchFromArr(e,this.preOvers),s&&u&&(l=this.getEles(s.tar,null,l),l&&l.length>0&&this.sendEvents(l,T.MOUSE_OUT),this.removeTouchFromArr(e,this.preOvers),s.tar=null,D.recover("TouchData",s)),this._clearTempArrs()}}}It.I=new It,It._oldArr=[],It._newArr=[],It._tEleArr=[];class yt{constructor(){this.mouseX=0,this.mouseY=0,this.disableMouseEvent=!1,this.mouseDownTime=0,this.mouseMoveAccuracy=2,this._event=new T,this._captureSp=null,this._captureChain=[],this._captureExlusiveMode=!1,this._hitCaputreSp=!1,this._point=new Tt,this._rect=new tt,this._lastMoveTimer=0,this._prePoint=new Tt,this._touchIDs={},this._curTouchID=NaN,this._id=1}__init__(t,e){this._stage=t;var i=this;e.oncontextmenu=function(s){if(yt.enabled)return!1},e.addEventListener("mousedown",function(s){yt.enabled&&(x.onIE||s.cancelable&&s.preventDefault(),i.mouseDownTime=x.now(),i.runEvent(s))}),e.addEventListener("mouseup",function(s){yt.enabled&&(s.cancelable&&s.preventDefault(),i.mouseDownTime=-x.now(),i.runEvent(s))},!0),e.addEventListener("mousemove",function(s){if(yt.enabled){s.cancelable&&s.preventDefault();var r=x.now();if(r-i._lastMoveTimer<10)return;i._lastMoveTimer=r,i.runEvent(s)}},!0),e.addEventListener("mouseout",function(s){yt.enabled&&i.runEvent(s)}),e.addEventListener("mouseover",function(s){yt.enabled&&i.runEvent(s)}),e.addEventListener("touchstart",function(s){yt.enabled&&(!yt._isFirstTouch&&!N.isInputting&&s.cancelable&&s.preventDefault(),i.mouseDownTime=x.now(),i.runEvent(s))}),e.addEventListener("touchend",function(s){yt.enabled?(!yt._isFirstTouch&&!N.isInputting&&s.cancelable&&s.preventDefault(),yt._isFirstTouch=!1,i.mouseDownTime=-x.now(),i.runEvent(s)):i._curTouchID=NaN},!0),e.addEventListener("touchmove",function(s){yt.enabled&&(s.cancelable&&s.preventDefault(),i.runEvent(s))},!0),e.addEventListener("touchcancel",function(s){yt.enabled?(s.cancelable&&s.preventDefault(),i.runEvent(s)):i._curTouchID=NaN},!0),e.addEventListener("mousewheel",function(s){yt.enabled&&i.runEvent(s)}),e.addEventListener("DOMMouseScroll",function(s){yt.enabled&&i.runEvent(s)})}initEvent(t,e=null){var i=this;i._event._stoped=!1,i._event.nativeEvent=e||t,i._target=null,this._point.setTo(t.pageX||t.clientX,t.pageY||t.clientY),this._stage._canvasTransform&&(this._stage._canvasTransform.invertTransformPoint(this._point),i.mouseX=this._point.x,i.mouseY=this._point.y),i._event.touchId=t.identifier||0,this._tTouchID=i._event.touchId;var s;s=It.I._event,s._stoped=!1,s.nativeEvent=i._event.nativeEvent,s.touchId=i._event.touchId}checkMouseWheel(t){this._event.delta=t.wheelDelta?t.wheelDelta*.025:-t.detail;for(var e=It.I.getLastOvers(),i=0,s=e.length;i-1;a--){var n=t._children[a];if(!n.destroyed&&n._mouseState>1&&n._visible&&this.check(n,e,i,s))return!0}for(a=t._extUIChild.length-1;a>=0;a--){var h=t._extUIChild[a];if(!h.destroyed&&h._mouseState>1&&h._visible&&this.check(h,e,i,s))return!0}}var o=t.hitTestPrior&&!t.mouseThrough&&!this.disableMouseEvent?!0:this.hitTest(t,e,i);return o?(this._target=t,s.call(this,t),this._target==this._hitCaputreSp&&(this._hitCaputreSp=!0)):s===this.onMouseUp&&t===this._stage&&(this._target=this._stage,s.call(this,this._target)),o}hitTest(t,e,i){var s=!1;t.scrollRect&&(e-=t._style.scrollRect.x,i-=t._style.scrollRect.y);var r=t._style.hitArea;return r&&r._hit?r.contains(e,i):((t.width>0&&t.height>0||t.mouseThrough||r)&&(t.mouseThrough?s=t.getGraphicBounds().contains(e,i):s=(r||this._rect.setTo(0,0,t.width,t.height)).contains(e,i)),s)}_checkAllBaseUI(t,e,i){var s=this.handleExclusiveCapture(this.mouseX,this.mouseY,i);return s?!0:(s=this.check(this._stage,this.mouseX,this.mouseY,i),this.handleCapture(this.mouseX,this.mouseY,i)||s)}check3DUI(t,e,i){for(var s=this._stage._3dUI,r=0,a=!1;r1&&n._visible&&(a=a||this.check(n,this.mouseX,this.mouseY,i))}return this._stage._curUIBase=this._stage,a}handleExclusiveCapture(t,e,i){if(this._captureExlusiveMode&&this._captureSp&&this._captureChain.length>0){var s;this._point.setTo(t,e);for(var r=0;r0){var s;this._point.setTo(t,e);for(var r=0;r=this.mouseMoveAccuracy&&(this._prePoint.x=t.clientX,this._prePoint.y=t.clientY,this.initEvent(t),this._checkAllBaseUI(this.mouseX,this.mouseY,this.onMouseMove));break;case"touchstart":yt._isTouchRespond=!0,this._isLeftMouse=!0;var r=t.changedTouches;for(e=0,i=r.length;e0){for(let i=0,s=e-1;i<=s;i++){let r=t[i];this._map[r.key]=null,r.method!==null&&(r.run(),r.clear()),this._pool.push(r),i===s&&(s=t.length-1)}t.length=0}}_getHandler(t,e){var i=t?t.$_GID||(t.$_GID=c.Utils.getGID()):0,s=e.$_TID||(e.$_TID=c.Timer._mid++);return this._map[i+"."+s]}callLater(t,e,i=null){if(this._getHandler(t,e)==null){let a;this._pool.length?a=this._pool.pop():a=new tr,a.caller=t,a.method=e,a.args=i;var s=t?t.$_GID:0,r=e.$_TID;a.key=s+"."+r,this._map[a.key]=a,this._laters.push(a)}}runCallLater(t,e){var i=this._getHandler(t,e);i&&i.method!=null&&(this._map[i.key]=null,i.run(),i.clear())}}Ye.I=new Ye;class tr{clear(){this.caller=null,this.method=null,this.args=null}run(){var t=this.caller;if(t&&t.destroyed)return this.clear();var e=this.method,i=this.args;e!=null&&(i?e.apply(t,i):e.call(t))}}class Ni{}Ni.createShaderCondition=function(v){var t="(function() {return "+v+";})";return window.Laya._runScript(t)},Ni.changeWebGLSize=function(v,t){Ce.onStageResize(v,t)};class Ut{static setPerformanceDataTool(t){this.performanceTool=t}static begainSample(t){this.performanceTool&&this.performanceTool.enable&&this.performanceTool.BegainSample(t)}static endSample(t){return this.performanceTool&&this.performanceTool.enable?this.performanceTool.EndSample(t):0}static expoertFile(t){if(this.performanceTool)return this.performanceTool.enable?this.performanceTool.exportPerformanceFile():null}static showFunSampleFun(t){this.performanceTool.showFunSampleFun(t)}static set enable(t){this.performanceTool&&(this.performanceTool.enable=t)}static get enable(){return this.performanceTool?this._enable:!1}static set enableDataExport(t){this.performanceTool&&(this.performanceTool.enableDataExport=t)}static get enableDataExport(){return this.performanceTool?this.performanceTool.enableDataExport:!1}}Ut.performanceTool=null,Ut._enable=!1,Ut.PERFORMANCE_LAYA="Laya",Ut.PERFORMANCE_LAYA_3D="Laya/3D",Ut.PERFORMANCE_LAYA_2D="Laya/2D",Ut.PERFORMANCE_LAYA_3D_PRERENDER="Laya/3D/PreRender",Ut.PERFORMANCE_LAYA_3D_UPDATESCRIPT="Laya/3D/UpdateScript",Ut.PERFORMANCE_LAYA_3D_PHYSICS="Laya/3D/Physics",Ut.PERFORMANCE_LAYA_3D_PHYSICS_SIMULATE="Laya/3D/Physics/simulate",Ut.PERFORMANCE_LAYA_3D_PHYSICS_CHARACTORCOLLISION="Laya/3D/Physics/updataCharacters&Collisions",Ut.PERFORMANCE_LAYA_3D_PHYSICS_EVENTSCRIPTS="Laya/3D/Physics/eventScripts",Ut.PERFORMANCE_LAYA_3D_RENDER="Laya/3D/Render",Ut.PERFORMANCE_LAYA_3D_RENDER_SHADOWMAP="Laya/3D/Render/ShadowMap",Ut.PERFORMANCE_LAYA_3D_RENDER_CLUSTER="Laya/3D/Render/Cluster",Ut.PERFORMANCE_LAYA_3D_RENDER_CULLING="Laya/3D/Render/Culling",Ut.PERFORMANCE_LAYA_3D_RENDER_RENDERDEPTHMDOE="Laya/3D/Render/RenderDepthMode",Ut.PERFORMANCE_LAYA_3D_RENDER_RENDEROPAQUE="Laya/3D/Render/RenderOpaque",Ut.PERFORMANCE_LAYA_3D_RENDER_RENDERCOMMANDBUFFER="Laya/3D/Render/RenderCommandBuffer",Ut.PERFORMANCE_LAYA_3D_RENDER_RENDERTRANSPARENT="Laya/3D/Render/RenderTransparent",Ut.PERFORMANCE_LAYA_3D_RENDER_POSTPROCESS="Laya/3D/Render/PostProcess",window.PerformancePlugin=Ut;class Z extends zt{constructor(){super(),this.offset=new Tt,this._frameRate="fast",this.designWidth=0,this.designHeight=0,this.canvasRotation=!1,this.canvasDegree=0,this.renderingEnabled=!0,this.screenAdaptationEnabled=!0,this._canvasTransform=new et,this._screenMode="none",this._scaleMode="noscale",this._alignV="top",this._alignH="left",this._bgColor="black",this._mouseMoveTime=0,this._renderCount=0,this._safariOffsetY=0,this._frameStartTime=0,this._previousOrientation=x.window.orientation,this._wgColor=[0,0,0,1],this._scene3Ds=[],this._globalRepaintSet=!1,this._globalRepaintGet=!1,this._3dUI=[],this._curUIBase=null,this.useRetinalCanvas=!1,super.set_transform(this._createTransform()),this.mouseEnabled=!0,this.hitTestPrior=!0,this.autoSize=!1,this._setBit(Q.DISPLAYED_INSTAGE,!0),this._setBit(Q.ACTIVE_INHIERARCHY,!0),this._isFocused=!0,this._isVisibility=!0,this.useRetinalCanvas=Dt.useRetinalCanvas;var t=x.window;t.addEventListener("focus",()=>{this._isFocused=!0,this.event(T.FOCUS),this.event(T.FOCUS_CHANGE)}),t.addEventListener("blur",()=>{this._isFocused=!1,this.event(T.BLUR),this.event(T.FOCUS_CHANGE),this._isInputting()&&(N.inputElement.target.focus=!1)});var e="visibilityState",i="visibilitychange",s=t.document;typeof s.hidden<"u"?(i="visibilitychange",e="visibilityState"):typeof s.mozHidden<"u"?(i="mozvisibilitychange",e="mozVisibilityState"):typeof s.msHidden<"u"?(i="msvisibilitychange",e="msVisibilityState"):typeof s.webkitHidden<"u"&&(i="webkitvisibilitychange",e="webkitVisibilityState"),t.document.addEventListener(i,()=>{x.document[e]=="hidden"?(this._isVisibility=!1,this._isInputting()&&(N.inputElement.target.focus=!1)):this._isVisibility=!0,this.renderingEnabled=this._isVisibility,this.event(T.VISIBILITY_CHANGE)}),t.addEventListener("resize",()=>{var r=x.window.orientation;r!=null&&r!=this._previousOrientation&&this._isInputting()&&(N.inputElement.target.focus=!1),this._previousOrientation=r,!this._isInputting()&&(x.onSafari&&!x.onChrome&&(this._safariOffsetY=(x.window.__innerHeight||x.document.body.clientHeight||x.document.documentElement.clientHeight)-x.window.innerHeight),this._resetCanvas())}),t.addEventListener("orientationchange",r=>{this._resetCanvas()}),this.on(T.MOUSE_MOVE,this,this._onmouseMove),x.onMobile&&this.on(T.MOUSE_DOWN,this,this._onmouseMove)}_isInputting(){return x.onMobile&&N.isInputting}set width(t){this.designWidth=t,super.set_width(t),c.systemTimer.callLater(this,this._changeCanvasSize)}get width(){return super.get_width()}set height(t){this.designHeight=t,super.set_height(t),c.systemTimer.callLater(this,this._changeCanvasSize)}get height(){return super.get_height()}set transform(t){super.set_transform(t)}get transform(){return this._tfChanged&&this._adjustTransform(),this._transform=this._transform||this._createTransform()}get isFocused(){return this._isFocused}get isVisibility(){return this._isVisibility}_changeCanvasSize(){this.setScreenSize(x.clientWidth*x.pixelRatio,x.clientHeight*x.pixelRatio)}_resetCanvas(){this.screenAdaptationEnabled&&this._changeCanvasSize()}setScreenSize(t,e){var i=!1;if(this._screenMode!==Z.SCREEN_NONE){var s=t/e<1?Z.SCREEN_VERTICAL:Z.SCREEN_HORIZONTAL;if(i=s!==this._screenMode,i){var r=e;e=t,t=r}}this.canvasRotation=i;var a=j._mainCanvas,n=this._canvasTransform.identity(),h=this._scaleMode,o=t/this.designWidth,l=e/this.designHeight,u=this.useRetinalCanvas?t:this.designWidth,_=this.useRetinalCanvas?e:this.designHeight,f=t,p=e,m=x.pixelRatio;switch(this._width=this.designWidth,this._height=this.designHeight,h){case Z.SCALE_NOSCALE:o=l=1,f=this.designWidth,p=this.designHeight;break;case Z.SCALE_SHOWALL:o=l=Math.min(o,l),u=f=Math.round(this.designWidth*o),_=p=Math.round(this.designHeight*l);break;case Z.SCALE_NOBORDER:o=l=Math.max(o,l),f=Math.round(this.designWidth*o),p=Math.round(this.designHeight*l);break;case Z.SCALE_FULL:o=l=1,this._width=u=t,this._height=_=e;break;case Z.SCALE_FIXED_WIDTH:l=o,this._height=_=Math.round(e/o);break;case Z.SCALE_FIXED_HEIGHT:o=l,this._width=u=Math.round(t/l);break;case Z.SCALE_FIXED_AUTO:t/e0?1:-1:t}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode=t,c.systemTimer.callLater(this,this._changeCanvasSize)}get alignH(){return this._alignH}set alignH(t){this._alignH=t,c.systemTimer.callLater(this,this._changeCanvasSize)}get alignV(){return this._alignV}set alignV(t){this._alignV=t,c.systemTimer.callLater(this,this._changeCanvasSize)}get bgColor(){return this._bgColor}set bgColor(t){this._bgColor=t,t?this._wgColor=lt.create(t).arrColor:this._wgColor=null,Z._setStyleBgColor(t)}static _setStyleBgColor(t){t?j.canvas.style.background=t:j.canvas.style.background="none"}get mouseX(){return Math.round(yt.instance.mouseX/this.clientScaleX)}get mouseY(){return Math.round(yt.instance.mouseY/this.clientScaleY)}getMousePoint(){return Tt.TEMP.setTo(this.mouseX,this.mouseY)}get clientScaleX(){return this._transform?this._transform.getScaleX():1}get clientScaleY(){return this._transform?this._transform.getScaleY():1}get screenMode(){return this._screenMode}set screenMode(t){this._screenMode=t}repaint(t=P.REPAINT_CACHE){this._repaint|=t}parentRepaint(t=P.REPAINT_CACHE){}_loop(){return this._globalRepaintGet=this._globalRepaintSet,this._globalRepaintSet=!1,this.render(j._context,0,0),!0}getFrameTm(){return this._frameStartTime}_onmouseMove(t){this._mouseMoveTime=x.now()}getTimeFromFrameStart(){return x.now()-this._frameStartTime}set visible(t){this.visible!==t&&(super.set_visible(t),Z._setVisibleStyle(t))}static _setVisibleStyle(t){var e=j._mainCanvas.source.style;e.visibility=t?"visible":"hidden"}get visible(){return super.visible}render(t,e,i){if(window.conch){this.renderToNative(t,e,i);return}if(this._frameRate===Z.FRAME_SLEEP){var s=x.now();if(s-this._frameStartTime>=1e3)this._frameStartTime=s;else return}else{if(!this._visible){this._renderCount++,this._renderCount%5===0&&(Ye.I._update(),F.loopCount++,ae.loopCount=F.loopCount,this._updateTimers());return}this._frameStartTime=x.now(),ae.loopStTm=this._frameStartTime}this._renderCount++;var r=this._frameRate===Z.FRAME_MOUSE?this._frameStartTime-this._mouseMoveTime<2e3?Z.FRAME_FAST:Z.FRAME_SLOW:this._frameRate,a=r!==Z.FRAME_SLOW,n=this._renderCount%2===0;if(F.renderSlow=!a,!(!a&&!n)){if(Ye.I._update(),F.loopCount++,ae.loopCount=F.loopCount,Ut.begainSample(Ut.PERFORMANCE_LAYA),this.renderingEnabled){for(var h=0,o=this._scene3Ds.length;h=0||this._3dUI.push(e)}remove3DUI(t){var e=t.rootView,i=this._3dUI.indexOf(e);return i>=0?(this._3dUI.splice(i,1),!0):!1}}Z.SCALE_NOSCALE="noscale",Z.SCALE_EXACTFIT="exactfit",Z.SCALE_SHOWALL="showall",Z.SCALE_NOBORDER="noborder",Z.SCALE_FULL="full",Z.SCALE_FIXED_WIDTH="fixedwidth",Z.SCALE_FIXED_HEIGHT="fixedheight",Z.SCALE_FIXED_AUTO="fixedauto",Z.ALIGN_LEFT="left",Z.ALIGN_RIGHT="right",Z.ALIGN_CENTER="center",Z.ALIGN_TOP="top",Z.ALIGN_MIDDLE="middle",Z.ALIGN_BOTTOM="bottom",Z.SCREEN_NONE="none",Z.SCREEN_HORIZONTAL="horizontal",Z.SCREEN_VERTICAL="vertical",Z.FRAME_FAST="fast",Z.FRAME_SLOW="slow",Z.FRAME_MOUSE="mouse",Z.FRAME_SLEEP="sleep",Z.clear=function(v){K.set2DRenderConfig();var t=I.instance;U.worldScissorTest&&t.disable(t.SCISSOR_TEST);var e=j.context,i=e._submits._length==0||Dt.preserveDrawingBuffer?lt.create(v).arrColor:c.stage._wgColor;i?e.clearBG(i[0],i[1],i[2],i[3]):e.clearBG(0,0,0,0),U.clear()},Y.regClass("laya.display.Stage",Z),Y.regClass("Laya.Stage",Z);class ie{static __init__(){ie._addEvent("keydown"),ie._addEvent("keypress"),ie._addEvent("keyup")}static _addEvent(t){c.Browser.document.addEventListener(t,function(e){ie._dispatch(e,t)},!0)}static _dispatch(t,e){if(ie.enabled){ie._event._stoped=!1,ie._event.nativeEvent=t,ie._event.keyCode=t.keyCode||t.which||t.charCode,e==="keydown"?ie._pressKeys[ie._event.keyCode]=!0:e==="keyup"&&(ie._pressKeys[ie._event.keyCode]=null);for(var i=c.stage.focus&&c.stage.focus.event!=null&&c.stage.focus.displayedInStage?c.stage.focus:c.stage,s=i;s;)s.event(e,ie._event.setTo(e,s,i)),s=s.parent}}static hasKeyDown(t){return ie._pressKeys[t]}}ie._pressKeys={},ie.enabled=!0,ie._event=new T;class Ji extends $t{constructor(){super(...arguments),this.isStopped=!1}set volume(t){}get volume(){return 1}get position(){return 0}get duration(){return 0}play(){}stop(){this.completeHandler&&this.completeHandler.runWith(!1)}pause(){}resume(){}__runComplete(t){t&&t.runWith(!0)}}class Fs extends Ji{constructor(t){super(),this._audio=null,this._onEnd=this.__onEnd.bind(this),this._resumePlay=this.__resumePlay.bind(this),t.addEventListener("ended",this._onEnd),this._audio=t}__onEnd(t){if(this.loops==1){this.completeHandler&&(c.systemTimer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),this.event(T.COMPLETE);return}this.loops>0&&this.loops--,this.startTime=0,this.play()}__resumePlay(){if(this._audio&&this._audio.removeEventListener("canplay",this._resumePlay),!this.isStopped)try{this._audio.currentTime=this.startTime,x.container.appendChild(this._audio),this._audio.play()}catch{this.event(T.ERROR)}}play(){this.isStopped=!1;try{this._audio.playbackRate=c.SoundManager.playbackRate,this._audio.currentTime=this.startTime}catch{this._audio.addEventListener("canplay",this._resumePlay);return}c.SoundManager.addChannel(this),x.container.appendChild(this._audio),"play"in this._audio&&this._audio.play()}get position(){return this._audio?this._audio.currentTime:0}get duration(){return this._audio?this._audio.duration:0}stop(){super.stop(),this.isStopped=!0,c.SoundManager.removeChannel(this),this.completeHandler=null,this._audio&&("pause"in this._audio&&c.Render.isConchApp&&this._audio.stop(),this._audio.pause(),this._audio.removeEventListener("ended",this._onEnd),this._audio.removeEventListener("canplay",this._resumePlay),c.Browser.onIE||this._audio!=c.AudioSound._musicAudio&&c.Pool.recover("audio:"+this.url,this._audio),x.removeElement(this._audio),this._audio=null,c.SoundManager.autoReleaseSound&&c.SoundManager.disposeSoundLater(this.url))}pause(){this.isStopped=!0,c.SoundManager.removeChannel(this),this._audio&&("pause"in this._audio&&this._audio.pause(),c.SoundManager.autoReleaseSound&&c.SoundManager.disposeSoundLater(this.url))}resume(){var t=this._audio;t&&(this.isStopped=!1,t.readyState==0&&(t.src=this.url,t.addEventListener("canplay",this._resumePlay),t.load&&t.load()),c.SoundManager.addChannel(this),"play"in t&&t.play())}set volume(t){this._audio&&(this._audio.volume=t)}get volume(){return this._audio?this._audio.volume:1}}class wt extends $t{constructor(){super(...arguments),this.loaded=!1}dispose(){var t=wt._audioCache[this.url];D.clearBySign("audio:"+this.url),t&&(j.isConchApp||(t.src=""),delete wt._audioCache[this.url])}static _initMusicAudio(){wt._musicAudio||(wt._musicAudio||(wt._musicAudio=x.createElement("audio")),j.isConchApp||x.document.addEventListener("mousedown",wt._makeMusicOK))}static _makeMusicOK(){x.document.removeEventListener("mousedown",wt._makeMusicOK),wt._musicAudio.src?wt._musicAudio.play():(wt._musicAudio.src="",wt._musicAudio.load())}load(t){t=$.formatURL(t),this.url=t;var e;if(t==c.SoundManager._bgMusic?(wt._initMusicAudio(),e=wt._musicAudio,e.src!=t&&(delete wt._audioCache[e.src],e=null)):e=wt._audioCache[t],e&&e.readyState>=2){this.event(T.COMPLETE);return}e||(t==c.SoundManager._bgMusic?(wt._initMusicAudio(),e=wt._musicAudio):e=x.createElement("audio"),wt._audioCache[t]=e,e.src=t),e.addEventListener("canplaythrough",s),e.addEventListener("error",r);var i=this;function s(){a(),i.loaded=!0,i.event(T.COMPLETE)}function r(){e.load=null,a(),i.event(T.ERROR)}function a(){e.removeEventListener("canplaythrough",s),e.removeEventListener("error",r)}this.audio=e,e.load?e.load():r()}play(t=0,e=0){if(!this.url)return null;var i;if(this.url==c.SoundManager._bgMusic?(i=wt._musicAudio,i.src!=""&&i.src!=this.url&&(delete wt._audioCache[i.src],wt._audioCache[this.url]=i)):i=wt._audioCache[this.url],!i)return null;var s;s=D.getItem("audio:"+this.url),j.isConchApp?s||(s=x.createElement("audio"),s.src=this.url):this.url==c.SoundManager._bgMusic?(wt._initMusicAudio(),s=wt._musicAudio,s.src=this.url):s=s||i.cloneNode(!0);var r=new Fs(s);return r.url=this.url,r.loops=e,r.startTime=t,r.play(),c.SoundManager.addChannel(r),r}get duration(){var t;return t=wt._audioCache[this.url],t?t.duration:0}}wt._audioCache={};class Oe extends Ji{constructor(){super(),this.bufferSource=null,this._currentTime=0,this._volume=1,this._startTime=0,this._pauseTime=0,this.context=c.WebAudioSound.ctx,this._onPlayEnd=J.bind(this.__onPlayEnd,this),this.context.createGain?this.gain=this.context.createGain():this.gain=this.context.createGainNode()}play(){if(c.SoundManager.addChannel(this),this.isStopped=!1,this._clearBufferSource(),!!this.audioBuffer){if(this.startTime>=this.duration)return this.stop();var t=this.context,e=this.gain,i=t.createBufferSource();this.bufferSource=i,i.buffer=this.audioBuffer,i.connect(e),e&&e.disconnect(),e.connect(t.destination),i.onended=this._onPlayEnd,this._startTime=x.now(),this.gain.gain.setTargetAtTime?this.gain.gain.setTargetAtTime(this._volume,this.context.currentTime,Oe.SetTargetDelay):this.gain.gain.value=this._volume,this.loops==0&&(i.loop=!0),i.playbackRate.setTargetAtTime?i.playbackRate.setTargetAtTime(c.SoundManager.playbackRate,this.context.currentTime,Oe.SetTargetDelay):i.playbackRate.value=c.SoundManager.playbackRate,i.start(0,this.startTime),this._currentTime=0}}__onPlayEnd(){if(this.loops==1){this.completeHandler&&(c.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),this.event(T.COMPLETE);return}this.loops>0&&this.loops--,this.startTime=0,this.play()}get position(){return this.bufferSource?(x.now()-this._startTime)/1e3+this.startTime:0}get duration(){return this.audioBuffer?this.audioBuffer.duration:0}_clearBufferSource(){if(this.bufferSource){var t=this.bufferSource;t.stop?t.stop(0):t.noteOff(0),t.disconnect(0),t.onended=null,Oe._tryCleanFailed||this._tryClearBuffer(t),this.bufferSource=null}}_tryClearBuffer(t){try{t.buffer=null}catch{Oe._tryCleanFailed=!0}}stop(){super.stop(),this._clearBufferSource(),this.audioBuffer=null,this.gain&&this.gain.disconnect(),this.isStopped=!0,c.SoundManager.removeChannel(this),this.completeHandler=null,c.SoundManager.autoReleaseSound&&c.SoundManager.disposeSoundLater(this.url)}pause(){this.isStopped||(this._pauseTime=this.position),this._clearBufferSource(),this.gain&&this.gain.disconnect(),this.isStopped=!0,c.SoundManager.removeChannel(this),c.SoundManager.autoReleaseSound&&c.SoundManager.disposeSoundLater(this.url)}resume(){this.startTime=this._pauseTime,this.play()}set volume(t){this._volume=t,!this.isStopped&&(this.gain.gain.setTargetAtTime?this.gain.gain.setTargetAtTime(t,this.context.currentTime,Oe.SetTargetDelay):this.gain.gain.value=t)}get volume(){return this._volume}}Oe._tryCleanFailed=!1,Oe.SetTargetDelay=.001;class q extends $t{constructor(){super(...arguments),this.loaded=!1,this._disposed=!1}static decode(){q.buffs.length<=0||q.isDecoding||(q.isDecoding=!0,q.tInfo=q.buffs.shift(),q.ctx.decodeAudioData(q.tInfo.buffer,q._done,q._fail))}static _done(t){q.e.event("loaded:"+q.tInfo.url,t),q.isDecoding=!1,q.decode()}static _fail(){q.e.event("err:"+q.tInfo.url,null),q.isDecoding=!1,q.decode()}static _playEmptySound(){if(q.ctx!=null){var t=q.ctx.createBufferSource();t.buffer=q._miniBuffer,t.connect(q.ctx.destination),t.start(0,0,0)}}static _unlock(){q._unlocked||(q._playEmptySound(),q.ctx.state=="running"&&(window.document.removeEventListener("mousedown",q._unlock,!0),window.document.removeEventListener("touchend",q._unlock,!0),window.document.removeEventListener("touchstart",q._unlock,!0),q._unlocked=!0))}static initWebAudio(){q.ctx.state!="running"&&(q._unlock(),window.document.addEventListener("mousedown",q._unlock,!0),window.document.addEventListener("touchend",q._unlock,!0),window.document.addEventListener("touchstart",q._unlock,!0))}load(t){var e=this;if(t=$.formatURL(t),this.url=t,this.audioBuffer=q._dataCache[t],this.audioBuffer){this._loaded(this.audioBuffer);return}if(q.e.on("loaded:"+t,this,this._loaded),q.e.on("err:"+t,this,this._err),!q.__loadingSound[t]){q.__loadingSound[t]=!0;var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){if(e._disposed){e._removeLoadEvents();return}e.data=i.response,q.buffs.push({buffer:e.data,url:e.url}),q.decode()},i.onerror=function(s){e._err()},i.send()}}_err(){this._removeLoadEvents(),q.__loadingSound[this.url]=!1,this.event(T.ERROR)}_loaded(t){this._removeLoadEvents(),!this._disposed&&(this.audioBuffer=t,q._dataCache[this.url]=this.audioBuffer,this.loaded=!0,this.event(T.COMPLETE))}_removeLoadEvents(){q.e.off("loaded:"+this.url,this,this._loaded),q.e.off("err:"+this.url,this,this._err)}__playAfterLoaded(){if(this.__toPlays){var t,e,i;i=this.__toPlays,e=i.length;var s;for(t=0;t=0||b._channels.push(t)}static removeChannel(t){var e;for(e=b._channels.length-1;e>=0;e--)b._channels[e]==t&&b._channels.splice(e,1)}static disposeSoundLater(t){b._lastSoundUsedTimeDic[t]=c.Browser.now(),b._isCheckingDispose||(b._isCheckingDispose=!0,c.timer.loop(5e3,null,b._checkDisposeSound))}static _checkDisposeSound(){var t,e=c.Browser.now(),i=!1;for(t in b._lastSoundUsedTimeDic)e-b._lastSoundUsedTimeDic[t]>3e4?(delete b._lastSoundUsedTimeDic[t],b.disposeSoundIfNotUsed(t)):i=!0;i||(b._isCheckingDispose=!1,c.timer.clear(null,b._checkDisposeSound))}static disposeSoundIfNotUsed(t){var e;for(e=b._channels.length-1;e>=0;e--)if(b._channels[e].url==t)return;b.destroySound(t)}static set autoStopMusic(t){c.stage.off(T.BLUR,null,b._stageOnBlur),c.stage.off(T.FOCUS,null,b._stageOnFocus),c.stage.off(T.VISIBILITY_CHANGE,null,b._visibilityChange),b._autoStopMusic=t,t&&(c.stage.on(T.BLUR,null,b._stageOnBlur),c.stage.on(T.FOCUS,null,b._stageOnFocus),c.stage.on(T.VISIBILITY_CHANGE,null,b._visibilityChange))}static get autoStopMusic(){return b._autoStopMusic}static _visibilityChange(){c.stage.isVisibility?b._stageOnFocus():b._stageOnBlur()}static _stageOnBlur(){b._isActive=!1,b._musicChannel&&(b._musicChannel.isStopped||(b._blurPaused=!0,b._musicChannel.pause())),b.stopAllSound(),c.stage.once(T.MOUSE_DOWN,null,b._stageOnFocus)}static _recoverWebAudio(){q.ctx&&q.ctx.state!="running"&&q.ctx.resume&&q.ctx.resume()}static _stageOnFocus(){b._isActive=!0,b._recoverWebAudio(),c.stage.off(T.MOUSE_DOWN,null,b._stageOnFocus),b._blurPaused&&b._musicChannel&&b._musicChannel.isStopped&&(b._blurPaused=!1,b._musicChannel.resume())}static set muted(t){t!=b._muted&&(t&&b.stopAllSound(),b.musicMuted=t,b._muted=t)}static get muted(){return b._muted}static set soundMuted(t){b._soundMuted=t}static get soundMuted(){return b._soundMuted}static set musicMuted(t){t!=b._musicMuted&&(t?(b._bgMusic&&b._musicChannel&&!b._musicChannel.isStopped?c.Render.isConchApp?b._musicChannel._audio&&(b._musicChannel._audio.muted=!0):b._musicChannel.pause():b._musicChannel=null,b._musicMuted=t):(b._musicMuted=t,b._bgMusic&&b._musicChannel&&(c.Render.isConchApp?b._musicChannel._audio&&(b._musicChannel._audio.muted=!1):b._musicChannel.resume())))}static get musicMuted(){return b._musicMuted}static get useAudioMusic(){return b._useAudioMusic}static set useAudioMusic(t){b._useAudioMusic=t,t?b._musicClass=wt:b._musicClass=null}static playSound(t,e=1,i=null,s=null,r=0){if(!b._isActive||!t||b._muted)return null;if(b._recoverWebAudio(),t=$.formatURL(t),t==b._bgMusic){if(b._musicMuted)return null}else{if(c.Render.isConchApp){var a=J.getFileExtension(t);if(a!="wav"&&a!="ogg")return alert("The sound only supports wav or ogg format,for optimal performance reason,please refer to the official website document."),null}if(b._soundMuted)return null}var n;x._isMiniGame||(n=c.loader.getRes(t)),s||(s=b._soundClass),n||(n=new s,n.load(t),x._isMiniGame||c.Loader.cacheRes(t,n));var h;return h=n.play(r,e),h?(h.url=t,h.volume=t==b._bgMusic?b.musicVolume:b.soundVolume,h.completeHandler=i,h):null}static destroySound(t){var e=c.loader.getRes(t);e&&(c.Loader.clearRes(t),e.dispose())}static playMusic(t,e=0,i=null,s=0){return t=$.formatURL(t),b._bgMusic=t,b._musicChannel&&b._musicChannel.stop(),b._musicChannel=b.playSound(t,e,i,b._musicClass,s)}static stopSound(t){t=$.formatURL(t);var e,i;for(e=b._channels.length-1;e>=0;e--)i=b._channels[e],i.url==t&&i.stop()}static stopAll(){b._bgMusic=null;var t,e;for(t=b._channels.length-1;t>=0;t--)e=b._channels[t],e.stop()}static stopAllSound(){var t,e;for(t=b._channels.length-1;t>=0;t--)e=b._channels[t],e.url!=b._bgMusic&&e.stop()}static stopMusic(){b._musicChannel&&b._musicChannel.stop(),b._bgMusic=null}static setSoundVolume(t,e=null){if(e)e=$.formatURL(e),b._setVolume(e,t);else{b.soundVolume=t;var i,s;for(i=b._channels.length-1;i>=0;i--)s=b._channels[i],s.url!=b._bgMusic&&(s.volume=t)}}static setMusicVolume(t){b.musicVolume=t,b._setVolume(b._bgMusic,t)}static _setVolume(t,e){t=$.formatURL(t);var i,s;for(i=b._channels.length-1;i>=0;i--)s=b._channels[i],s.url==t&&(s.volume=e)}}b.musicVolume=1,b.soundVolume=1,b.playbackRate=1,b._useAudioMusic=!0,b._muted=!1,b._soundMuted=!1,b._musicMuted=!1,b._bgMusic=null,b._musicChannel=null,b._channels=[],b._blurPaused=!1,b._isActive=!0,b._lastSoundUsedTimeDic={},b._isCheckingDispose=!1,b.autoReleaseSound=!0;class _s{create(){return this.json?c.SceneUtils.createByData(null,this.json):null}}class ts{constructor(){this._fontCharDic={},this._fontWidthMap={},this._maxWidth=0,this._spaceWidth=10,this.fontSize=12,this.autoScaleSize=!1,this.letterSpacing=0}loadFont(t,e){if(this._path=t,this._complete=e,!t||t.indexOf(".fnt")===-1){console.error('Bitmap font configuration information must be a ".fnt" file');return}c.loader.load([{url:t,type:c.Loader.XML},{url:t.replace(".fnt",".png"),type:c.Loader.IMAGE}],mt.create(this,this._onLoaded))}_onLoaded(){this.parseFont(c.Loader.getRes(this._path),c.Loader.getRes(this._path.replace(".fnt",".png"))),this._complete&&this._complete.run()}parseFont(t,e){if(!(t==null||e==null)){this._texture=e;var i=1,s=t.getElementsByTagName("info");if(!s[0].getAttributeNode)return this.parseFont2(t,e);this.fontSize=parseInt(s[0].getAttributeNode("size").nodeValue);var r=s[0].getAttributeNode("padding").nodeValue,a=r.split(",");this._padding=[parseInt(a[0]),parseInt(a[1]),parseInt(a[2]),parseInt(a[3])];var n=t.getElementsByTagName("char"),h=0;for(h=0;h=0?"/":"\\",n=this._url.lastIndexOf(a),h=n>=0?this._url.substr(0,n+1):"",o=null;x.onAndroid&&t.meta.compressTextureAndroid&&(o=".ktx"),x.onIOS&&t.meta.compressTextureIOS&&(t.meta.astc?o=".ktx":o=".pvr");for(var l=0,u=r.length;l0){this.event(T.PROGRESS,.3+1/this._data.toLoads.length*.6);var _=$.formatURL(this._data.toLoads.pop()),i=J.getFileExtension(_),e=E.IMAGE;return(i=="pvr"||i=="ktx")&&(e=E.BUFFER),this._loadResourceFilter(e,_)}var f=this._data.frames,p=this._url.split("?")[0],m=this._data.meta&&this._data.meta.prefix?this._data.meta.prefix:p.substring(0,p.lastIndexOf("."))+"/",g=this._data.pics,y=$.formatURL(this._url),C=E.atlasMap[y]||(E.atlasMap[y]=[]);C.dir=m;var w=1;if(this._data.meta&&this._data.meta.scale&&this._data.meta.scale!=1){w=parseFloat(this._data.meta.scale);for(var M in f){var R=f[M],B=g[R.frame.idx?R.frame.idx:0];_=m+M,B.scaleRate=w;var k;k=ut._create(B,R.frame.x,R.frame.y,R.frame.w,R.frame.h,R.spriteSourceSize.x,R.spriteSourceSize.y,R.sourceSize.w,R.sourceSize.h,E.getRes(_)),E.cacheTexture(_,k),k.url=_,C.push(_)}}else for(M in f)R=f[M],B=g[R.frame.idx?R.frame.idx:0],_=m+M,k=ut._create(B,R.frame.x,R.frame.y,R.frame.w,R.frame.h,R.spriteSourceSize.x,R.spriteSourceSize.y,R.sourceSize.w,R.sourceSize.h,E.getRes(_)),E.cacheTexture(_,k),k.url=_,C.push(_);delete this._data.pics,this.complete(this._data)}else if(e===E.FONT)if(t._source){var z=new ts;z.parseFont(this._data,new ut(t));var S=this._url.split(".fnt")[0].split("/"),dt=S[S.length-1];st.registerBitmapFont(dt,z),this._data=z,this.complete(this._data)}else return this._data=t,this.event(T.PROGRESS,.5),this._loadResourceFilter(E.IMAGE,this._url.replace(".fnt",".png"));else if(e===E.PREFAB){var Mt=new _s;Mt.json=t,this.complete(Mt)}else this.complete(t)}parsePLFData(t){var e,i,s;for(e in t)switch(s=t[e],e){case"json":case"text":for(i in s)E.preLoadedMap[$.formatURL(i)]=s[i];break;default:for(i in s)E.preLoadedMap[$.formatURL(i)]=s[i]}}parsePLFBData(t){var e;e=new de(t);var i,s;for(s=e.getInt32(),i=0;iE.maxTimeOut){console.warn("loader callback cost a long time:"+(x.now()-t)+" url="+E._loaders[E._startIndex-1].url),c.systemTimer.frameOnce(1,null,E.checkNext);return}E._loaders.length=0,E._startIndex=0,E._isWorking=!1}endLoad(t=null){t&&(this._data=t),this._cache&&E.cacheRes(this._url,this._data),this.event(T.PROGRESS,1),this.event(T.COMPLETE,this.data instanceof Array?[this.data]:this.data)}get url(){return this._url}get type(){return this._type}get cache(){return this._cache}get data(){return this._data}static clearRes(t){t=$.formatURL(t);var e=E.getAtlas(t);if(e){for(var i=0,s=e.length;i0)e.forEach(function(s){var r=E.getRes(s);r instanceof ut&&r.disposeBitmap()});else{var i=E.getRes(t);i instanceof ut&&i.disposeBitmap()}}static getRes(t){var e=E.textureMap[$.formatURL(t)];return e||E.loadedMap[$.formatURL(t)]}static getAtlas(t){return E.atlasMap[$.formatURL(t)]}static cacheRes(t,e){t=$.formatURL(t),E.loadedMap[t]!=null?console.warn("Resources already exist,is repeated loading:",t):e instanceof ut?(E.loadedMap[t]=e.bitmap,E.textureMap[t]=e):E.loadedMap[t]=e}static cacheResForce(t,e){E.loadedMap[t]=e}static cacheTexture(t,e){t=$.formatURL(t),E.textureMap[t]!=null?console.warn("Resources already exist,is repeated loading:",t):E.textureMap[t]=e}static setGroup(t,e){E.groupMap[e]||(E.groupMap[e]=[]),E.groupMap[e].push(t)}static clearResByGroup(t){if(E.groupMap[t]){var e=E.groupMap[t],i,s=e.length;for(i=0;i=this.maxLoader)){for(var t=0;t0;){var i=e.shift();if(i)return this._doLoad(i)}this._loaderCount||this.event(T.COMPLETE)}}_doLoad(t){this._loaderCount++;var e=this._loaders.length?this._loaders.pop():new E;e.on(T.COMPLETE,null,s),e.on(T.PROGRESS,null,function(r){t.event(T.PROGRESS,r)}),e.on(T.ERROR,null,function(r){s(null)});var i=this;function s(r=null){e.offAll(),e._data=null,e._customParse=!1,i._loaders.push(e),i._endLoad(t,r instanceof Array?[r]:r),i._loaderCount--,i._next()}e._constructParams=t.createConstructParams,e._propertyParams=t.createPropertyParams,e._createCache=t.createCache,e.load(t.url,t.type,t.cache,t.group,t.ignoreCache,t.useWorkerLoader)}_endLoad(t,e){var i=t.url;if(e==null){var s=this._failRes[i]||0;if(s-1;i--){var s=e[i];s&&(s.offAll(),this._infoPool.push(s))}e.length=0}this._loaderCount=0,ce._resMap={}}cancelLoadByUrls(t){if(t)for(var e=0,i=t.length;e-1;s--){var r=i[s];r&&r.url===t&&(i[s]=null,r.offAll(),this._infoPool.push(r))}ce._resMap[t]&&delete ce._resMap[t]}_loadAssets(t,e=null,i=null,s=null,r=1,a=!0,n=null){for(var h=t.length,o=0,l=0,u=[],_=!0,f=0;f0&&r0&&r0&&r=this._duration)return this.complete();for(var s=i>0?this._ease(i,0,1,this._duration):0,r=this._props,a=0,n=r.length;a=this.repeat?(this.clear(),i&&i.run()):this.restart()}}pause(){c.timer.clear(this,this._beginLoop),c.timer.clear(this,this._doEase),c.timer.clear(this,this.firstStart);var t=x.now(),e;e=t-this._startTimer-this._delay,e<0&&(this._usedTimer=e)}setStartTime(t){this._startTimer=t}static clearAll(t){if(!(!t||!t.$_GID)){var e=qt.tweenMap[t.$_GID];if(e){for(var i=0,s=e.length;i=this._duration||(this._startTimer=x.now()-this._usedTimer-this._delay,this._delayParam?this._usedTimer<0?c.timer.once(-this._usedTimer,this,this.firstStart,this._delayParam):this.firstStart.apply(this,this._delayParam):this._beginLoop())}static easeNone(t,e,i,s){return i*t/s+e}}qt.tweenMap=[];class Bs{constructor(){this.ratio=.92,this.maxOffset=60,this._dragging=!1,this._clickOnly=!0}start(t,e,i,s,r,a,n,h=.92){this.clearTimer(),this.target=t,this.area=e,this.hasInertia=i,this.elasticDistance=e?s:0,this.elasticBackTime=r,this.data=a,this._disableMouseEvent=n,this.ratio=h,this._parent=t.parent,this._clickOnly=!0,this._dragging=!0,this._elasticRateX=this._elasticRateY=1,this._lastX=this._parent.mouseX,this._lastY=this._parent.mouseY,c.stage.on(T.MOUSE_UP,this,this.onStageMouseUp),c.stage.on(T.MOUSE_OUT,this,this.onStageMouseUp),c.systemTimer.frameLoop(1,this,this.loop)}clearTimer(){c.systemTimer.clear(this,this.loop),c.systemTimer.clear(this,this.tweenMove),this._tween&&(this._tween.recover(),this._tween=null)}stop(){this._dragging&&(yt.instance.disableMouseEvent=!1,c.stage.off(T.MOUSE_UP,this,this.onStageMouseUp),c.stage.off(T.MOUSE_OUT,this,this.onStageMouseUp),this._dragging=!1,this.target&&this.area&&this.backToArea(),this.clear())}loop(){var t=this._parent.getMousePoint(),e=t.x,i=t.y,s=e-this._lastX,r=i-this._lastY;if(this._clickOnly)if(Math.abs(s*c.stage._canvasTransform.getScaleX())>1||Math.abs(r*c.stage._canvasTransform.getScaleY())>1)this._clickOnly=!1,this._offsets||(this._offsets=[]),this._offsets.length=0,this.target.event(T.DRAG_START,this.data),yt.instance.disableMouseEvent=this._disableMouseEvent;else return;else this._offsets.push(s,r);s===0&&r===0||(this._lastX=e,this._lastY=i,this.target.x+=s*this._elasticRateX,this.target.y+=r*this._elasticRateY,this.area&&this.checkArea(),this.target.event(T.DRAG_MOVE,this.data))}checkArea(){if(this.elasticDistance<=0)this.backToArea();else{if(this.target._xthis.area.x+this.area.width?t=this.target._x-this.area.x-this.area.width:t=0;if(this._elasticRateX=Math.max(0,1-t/this.elasticDistance),this.target._ythis.area.y+this.area.height?e=this.target._y-this.area.y-this.area.height:e=0;this._elasticRateY=Math.max(0,1-e/this.elasticDistance)}}backToArea(){this.target.x=Math.min(Math.max(this.target._x,this.area.x),this.area.x+this.area.width),this.target.y=Math.min(Math.max(this.target._y,this.area.y),this.area.y+this.area.height)}onStageMouseUp(t){if(yt.instance.disableMouseEvent=!1,c.stage.off(T.MOUSE_UP,this,this.onStageMouseUp),c.stage.off(T.MOUSE_OUT,this,this.onStageMouseUp),c.systemTimer.clear(this,this.loop),!(this._clickOnly||!this.target))if(this.hasInertia){this._offsets.length<1&&this._offsets.push(this._parent.mouseX-this._lastX,this._parent.mouseY-this._lastY),this._offsetX=this._offsetY=0;for(var e=this._offsets.length,i=Math.min(e,6),s=this._offsets.length-i,r=e-1;r>s;r--)this._offsetY+=this._offsets[r--],this._offsetX+=this._offsets[r];this._offsetX=this._offsetX/i*2,this._offsetY=this._offsetY/i*2,Math.abs(this._offsetX)>this.maxOffset&&(this._offsetX=this._offsetX>0?this.maxOffset:-this.maxOffset),Math.abs(this._offsetY)>this.maxOffset&&(this._offsetY=this._offsetY>0?this.maxOffset:-this.maxOffset),c.systemTimer.frameLoop(1,this,this.tweenMove)}else this.elasticDistance>0?this.checkElastic():this.clear()}checkElastic(){var t=NaN,e=NaN;if(this.target.xthis.area.x+this.area.width&&(t=this.area.x+this.area.width),this.target.ythis.area.y+this.area.height&&(e=this.area.y+this.area.height),!isNaN(t)||!isNaN(e)){var i={};isNaN(t)||(i.x=t),isNaN(e)||(i.y=e),this._tween=qt.to(this.target,i,this.elasticBackTime,Wt.sineOut,mt.create(this,this.clear),0,!1,!1)}else this.clear()}tweenMove(){this._offsetX*=this.ratio*this._elasticRateX,this._offsetY*=this.ratio*this._elasticRateY,this.target.x+=this._offsetX,this.target.y+=this._offsetY,this.area&&this.checkArea(),this.target.event(T.DRAG_MOVE,this.data),(Math.abs(this._offsetX)<1&&Math.abs(this._offsetY)<1||this._elasticRateX<.5||this._elasticRateY<.5)&&(c.systemTimer.clear(this,this.tweenMove),this.elasticDistance>0?this.checkElastic():this.clear())}clear(){if(this.target){this.clearTimer();var t=this.target;this.target=null,this._parent=null,t.event(T.DRAG_END,this.data)}}}class Ei{constructor(){this._id=J.getGID(),this._resetComp()}get id(){return this._id}get enabled(){return this._enabled}set enabled(t){this._enabled!=t&&(this._enabled=t,this.owner&&(t?this.owner.activeInHierarchy&&this._onEnable():this.owner.activeInHierarchy&&this._onDisable()))}get isSingleton(){return!0}get destroyed(){return this._destroyed}_isScript(){return!1}_resetComp(){this._indexInList=-1,this._enabled=!0,this._awaked=!1,this.owner=null}_getIndexInList(){return this._indexInList}_setIndexInList(t){this._indexInList=t}_onAdded(){}_onAwake(){}_onEnable(){}_onDisable(){}_onDestroy(){}onReset(){}_parse(t,e=null){}_parseInteractive(t=null,e=null){}_cloneTo(t){}_setActive(t){t?(this._awaked||(this._awaked=!0,this._onAwake()),this._enabled&&this._onEnable()):this._enabled&&this._onDisable()}destroy(){this.owner&&this.owner._destroyComponent(this)}_destroy(){this.owner.activeInHierarchy&&this._enabled&&this._setActive(!1),this._onDestroy(),this._destroyed=!0,this.onReset!==Ei.prototype.onReset?(this.onReset(),this._resetComp(),D.recoverByClass(this)):this._resetComp()}}class we extends zt{constructor(){super(),this.wrapMode=0,this._interval=Dt.animationInterval,this._isReverse=!1,this._frameRateChanged=!1,this._setBitUp(Q.DISPLAY)}play(t=0,e=!0,i=""){this._isPlaying=!0,this._actionName=i,this.index=typeof t=="string"?this._getFrameByLabel(t):t,this.loop=e,this._isReverse=this.wrapMode===we.WRAP_REVERSE,this.index==0&&this._isReverse&&(this.index=this.count-1),this.interval>0&&this.timerLoop(this.interval,this,this._frameLoop,null,!0,!0)}get interval(){return this._interval}set interval(t){this._interval!=t&&(this._frameRateChanged=!0,this._interval=t,this._isPlaying&&t>0&&this.timerLoop(t,this,this._frameLoop,null,!0,!0))}_getFrameByLabel(t){for(var e=0;e-1)return e}return 0}_frameLoop(){if(!this._controlNode||this._controlNode.destroyed){this.clearTimer(this,this._frameLoop);return}if(this._isReverse){if(this._index--,this._index<0)if(this.loop)this.wrapMode==we.WRAP_PINGPONG?(this._index=this._count>0?1:0,this._isReverse=!1):this._index=this._count-1,this.event(T.COMPLETE);else{this._index=0,this.stop(),this.event(T.COMPLETE);return}}else if(this._index++,this._index>=this._count)if(this.loop)this.wrapMode==we.WRAP_PINGPONG?(this._index=this._count-2>=0?this._count-2:0,this._isReverse=!0):this._index=0,this.event(T.COMPLETE);else{this._index--,this.stop(),this.event(T.COMPLETE);return}this.index=this._index}_setControlNode(t){this._controlNode&&(this._controlNode.off(T.DISPLAY,this,this._resumePlay),this._controlNode.off(T.UNDISPLAY,this,this._resumePlay)),this._controlNode=t,t&&t!=this&&(t.on(T.DISPLAY,this,this._resumePlay),t.on(T.UNDISPLAY,this,this._resumePlay))}_setDisplay(t){super._setDisplay(t),this._resumePlay()}_resumePlay(){this._isPlaying&&(this._controlNode.displayedInStage?this.play(this._index,this.loop,this._actionName):this.clearTimer(this,this._frameLoop))}stop(){this._isPlaying=!1,this.clearTimer(this,this._frameLoop)}get isPlaying(){return this._isPlaying}addLabel(t,e){this._labels||(this._labels={}),this._labels[e]||(this._labels[e]=[]),this._labels[e].push(t)}removeLabel(t){if(!t)this._labels=null;else if(this._labels)for(var e in this._labels)this._removeLabelFromList(this._labels[e],t)}_removeLabelFromList(t,e){if(t)for(var i=t.length-1;i>=0;i--)t[i]==e&&t.splice(i,1)}gotoAndStop(t){this.index=typeof t=="string"?this._getFrameByLabel(t):t,this.stop()}get index(){return this._index}set index(t){if(this._index=t,this._displayToIndex(t),this._labels&&this._labels[t])for(var e=this._labels[t],i=0,s=e.length;i1e-6?(g=Math.acos(y),C=Math.sin(g),w=Math.sin((1-r)*g)/C,M=Math.sin(r*g)/C):(w=1-r,M=r),a[n+0]=w*h+M*_,a[n+1]=w*o+M*f,a[n+2]=w*l+M*p,a[n+3]=w*u+M*m,a}static getRotation(t,e,i,s){return Math.atan2(s-e,i-t)/Math.PI*180}static sortBigFirst(t,e){return t==e?0:e>t?1:-1}static sortSmallFirst(t,e){return t==e?0:e>t?-1:1}static sortNumBigFirst(t,e){return parseFloat(e)-parseFloat(t)}static sortNumSmallFirst(t,e){return parseFloat(t)-parseFloat(e)}static sortByKey(t,e=!1,i=!0){var s;return e?s=i?Ai.sortNumBigFirst:Ai.sortBigFirst:s=i?Ai.sortNumSmallFirst:Ai.sortSmallFirst,function(r,a){return s(r[t],a[t])}}}class Ne extends we{constructor(){super(),Ne._sortIndexFun===void 0&&(Ne._sortIndexFun=Ai.sortByKey("index",!1,!0))}static _sortIndexFun(t,e){return t.index-e.index}_setUp(t,e){this._targetDic=t,this._animationData=e,this.interval=1e3/e.frameRate,e.parsed?(this._count=e.count,this._labels=e.labels,this._usedFrames=e.animationNewFrames):(this._usedFrames=[],this._calculateDatas(),e.parsed=!0,e.labels=this._labels,e.count=this._count,e.animationNewFrames=this._usedFrames)}clear(){return super.clear(),this._targetDic=null,this._animationData=null,this}_displayToIndex(t){if(this._animationData){t<0&&(t=0),t>this._count&&(t=this._count);var e=this._animationData.nodes,i,s=e.length;for(i=0;ie?h=n[e]:h=n[n.length-1],s[a]=h;var _=t.funkeys;u=_.length;var f;if(u!=0)for(l=0;lthis._count&&(this._count=o.index)}}}}resetNodes(){if(this._targetDic&&this._animationData){var t=this._animationData.nodes,e,i=t.length,s,r;for(e=0;ethis._count&&(this._count=n),t.tween)for(r=Wt[t.tweenMethod],r==null&&(r=Wt.linearNone),s=a;s0&&e.props.hitTestPrior==null&&!t.mouseThrough&&(t.hitTestPrior=!0),i.beginLoad(t),t}static createInitTool(){return es.create()}static createComp(t,e=null,i=null,s=null,r=null){if(t.type=="Scene3D"||t.type=="Sprite3D"){var a=[],n=c.Laya.Utils3D._createSceneByJsonForMaker(t,a,r);return t.type=="Sprite3D"?c.Laya.StaticBatchManager.combine(n,a):c.Laya.StaticBatchManager.combine(null,a),n}if(e=e||Vt.getCompInstance(t),!e)return t.props&&t.props.runtime?console.warn("runtime not found:"+t.props.runtime):console.warn("can not create:"+t.type),null;var h=t.child;if(h)for(var o=e._$componentType=="List",l=0,u=h.length;l=0||y.indexOf("@Prefab:")>=0)?r&&r.addNodeRef(e,g,y):Vt.setCompValue(e,g,y,i,s)}return e._afterInited&&e._afterInited(),t.compId&&r&&r._idMap&&(r._idMap[t.compId]=e),e}static setCompValue(t,e,i,s=null,r=null){if(typeof i=="string"&&i.indexOf("${")>-1){if(Vt._sheet||(Vt._sheet=c.ClassUtils.getClass("laya.data.Table")),!Vt._sheet){console.warn("Can not find class Sheet");return}if(r)r.push(t,e,i);else if(s){i.indexOf("].")==-1&&(i=i.replace(".","[0]."));var a=new er(t,e,i);a.exe(s);for(var n,h,o=i.replace(/\[.*?\]\./g,".");(n=Vt._parseWatchData.exec(o))!=null;){for(var l=n[1];(h=Vt._parseKeyWord.exec(l))!=null;){var u=h[0],_=s._watchMap[u]||(s._watchMap[u]=[]);_.push(a),Vt._sheet.I.notifer.on(u,s,s.changeData,[u])}_=s._watchMap[l]||(s._watchMap[l]=[]),_.push(a),Vt._sheet.I.notifer.on(l,s,s.changeData,[l])}}return}e==="var"&&s?s[i]=t:t[e]=i==="true"?!0:i==="false"?!1:i}static getCompInstance(t){if(t.type=="UIView"&&t.props&&t.props.pageData)return Vt.createByData(null,t.props.pageData);var e=t.props&&t.props.runtime||t.type,i=c.ClassUtils.getClass(e);if(!i)throw"Can not find class "+e;if(t.type==="Script"&&i.prototype._doAwake){var s=D.createByClass(i);return s._destroyed=!1,s}return t.props&&"renderType"in t.props&&t.props.renderType=="instance"?(i.instance||(i.instance=new i),i.instance):new i}}Vt._parseWatchData=/\${(.*?)}/g,Vt._parseKeyWord=/[a-zA-Z_][a-zA-Z0-9_]*(?:(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+)/g;class er{constructor(t,e,i){this.comp=t,this.prop=e,this.value=i}exe(t){var e=Vt.getBindFun(this.value);this.comp[this.prop]=e.call(this,t)}}class es{reset(){this._nodeRefList=null,this._initList=null,this._idMap=null,this._loadList=null,this._scene=null}recover(){this.reset(),D.recover("InitTool",this)}static create(){var t=D.getItemByClass("InitTool",es);return t._idMap={},t}addLoadRes(t,e=null){this._loadList||(this._loadList=[]),!c.loader.getRes(t)&&(e?this._loadList.push({url:t,type:e}):this._loadList.push(t))}addNodeRef(t,e,i){this._nodeRefList||(this._nodeRefList=[]),this._nodeRefList.push([t,e,i]),i.indexOf("@Prefab:")>=0&&this.addLoadRes(i.replace("@Prefab:",""),E.PREFAB)}setNodeRef(){if(this._nodeRefList){if(!this._idMap){this._nodeRefList=null;return}var t,e;e=this._nodeRefList.length;var i;for(t=0;t=0){var e;return e=E.getRes(t.replace("@Prefab:","")),e}else if(t.indexOf("@arr:")>=0){t=t.replace("@arr:","");var i;i=t.split(",");var s,r,a;for(r=i.length,s=0;s0?Math.floor(1e3/F.FPS).toString():" ";F._fpsStr=F.FPS+(F.renderSlow?" slow":"")+" "+i,F._spriteStr=F.spriteCount+(F.spriteRenderUseCacheCount?"/"+F.spriteRenderUseCacheCount:""),F._canvasStr=F.canvasReCache+"/"+F.canvasNormal+"/"+F.canvasBitmap,F.cpuMemory=gt.cpuMemory,F.gpuMemory=gt.gpuMemory,this._useCanvas?this.renderInfoPre():this.renderInfo(),F.clear()}F._count=0,F._timer=t}}renderInfoPre(){var t=0,e,i;if(this._canvas){var s=this._ctx;for(s.clearRect(this._first?0:this._vx,0,this._width,this._height),t=0;t3e4;this._delta=(e-this._lastTimer)*this.scale;var s=this.currTimer=this.currTimer+this._delta;this._lastTimer=e;var r=this._handlers;this._count=0;for(var a=0,n=r.length;a=h.exeTime)if(h.repeat)if(!h.jumpFrame||i)h.exeTime+=h.delay,h.run(!1),o>h.exeTime&&(h.exeTime+=Math.ceil((o-h.exeTime)/h.delay)*h.delay);else for(;o>=h.exeTime;)h.exeTime+=h.delay,h.run(!1);else h.run(!0)}else this._count++}(this._count>30||t%200===0)&&this._clearHandlers()}_clearHandlers(){for(var t=this._handlers,e=0,i=t.length;e0?Jt._pool.pop():new ir,h.repeat=e,h.userFrame=t,h.delay=i,h.caller=s,h.method=r,h.args=a,h.exeTime=i+(t?this.currFrame:this.currTimer+Date.now()-this._lastTimer),this._indexHandler(h),this._handlers.push(h),h}_indexHandler(t){var e=t.caller,i=t.method,s=e?e.$_GID||(e.$_GID=c.Utils.getGID()):0,r=i.$_TID||(i.$_TID=Jt._mid++);t.key=s+"_"+r,this._map[t.key]=t}once(t,e,i,s=null,r=!0){this._create(!1,!1,t,e,i,s,r)}loop(t,e,i,s=null,r=!0,a=!1){var n=this._create(!1,!0,t,e,i,s,r);n&&(n.jumpFrame=a)}frameOnce(t,e,i,s=null,r=!0){this._create(!0,!1,t,e,i,s,r)}frameLoop(t,e,i,s=null,r=!0){this._create(!0,!0,t,e,i,s,r)}toString(){return" handlers:"+this._handlers.length+" pool:"+Jt._pool.length}clear(t,e){var i=this._getHandler(t,e);i&&i.clear()}clearAll(t){if(t)for(var e=0,i=this._handlers.length;e=0&&(e+=this.funs[i]);return e}}class Ii{constructor(t){this.childs=[],this.text="",this.useFuns="",this.z=0,this.includefiles=t}setParent(t){t.childs.push(this),this.z=t.z+1,this.parent=t}setCondition(t,e){t&&(this.conditionType=e,t=t.replace(/(\s*$)/g,""),this.condition=function(){return this[t]},this.condition.__condition=t)}toscript(t,e){return this._toscript(t,e,++Ii.__id)}_toscript(t,e,i){if(this.childs.length<1&&!this.text)return e;var s=e.length;if(this.condition){var r=!!this.condition.call(t);if(this.conditionType===c.ShaderCompile.IFDEF_ELSE&&(r=!r),!r)return e}if(this.noCompile&&this.text&&e.push(this.text),this.childs.length>0&&this.childs.forEach(function(o,l,u){o._toscript(t,e,i)}),this.includefiles.length>0&&this.useFuns.length>0)for(var a,n=0,h=this.includefiles.length;n0&&(this.includefiles[n].curUseID=i,e[0]=a+e[0]));return e}}Ii.__id=1;class ft{constructor(t,e,i){this.defs={};let s=this;function r(n){n=n.replace(ft._clearCR,"");var h=[],o=new Ii(h);return s._compileToTree(o,n.split(` `),0,h,s.defs),o}var a=Date.now();this._VS=r(t),this._PS=r(e),this._nameMap=i,Date.now()-a>2&&console.log("ShaderCompile use time:"+(Date.now()-a)+" size:"+t.length+"/"+e.length)}static __init__(){var t=I.instance;ft.shaderParamsMap={float:t.FLOAT,int:t.INT,bool:t.BOOL,vec2:t.FLOAT_VEC2,vec3:t.FLOAT_VEC3,vec4:t.FLOAT_VEC4,ivec2:t.INT_VEC2,ivec3:t.INT_VEC3,ivec4:t.INT_VEC4,bvec2:t.BOOL_VEC2,bvec3:t.BOOL_VEC3,bvec4:t.BOOL_VEC4,mat2:t.FLOAT_MAT2,mat3:t.FLOAT_MAT3,mat4:t.FLOAT_MAT4,sampler2D:t.SAMPLER_2D,samplerCube:t.SAMPLER_CUBE}}static _parseOne(t,e,i,s,r,a){var n={type:ft.shaderParamsMap[i[s+1]],name:i[s+2],size:isNaN(parseInt(i[s+3]))?1:parseInt(i[s+3])};return a&&(r=="attribute"?t.push(n):e.push(n)),i[s+3]==":"&&(n.type=i[s+4],s+=2),s+=2,s}static addInclude(t,e){if(!e||e.length===0)throw new Error("add shader include file err:"+t);if(ft.includes[t])throw new Error("add shader include file err, has add:"+t);ft.includes[t]=new Gs(e)}static preGetParams(t,e){var i=[t,e],s={},r=[],a=[],n={},h={};s.attributes=r,s.uniforms=a,s.defines=n;for(var o,l,u=0;u<2;u++){i[u]=i[u].replace(ft._removeAnnotation,"");var _=i[u].match(ft._reg),f;for(o=0,l=_.length;o()'",;`.indexOf(s)>=0){if(r>=0&&n-r>1&&(a=t.substr(r,n-r),i.push(a)),s=='"'||s=="'"){var o=t.indexOf(s,n+1);if(o<0)throw"Sharder err:"+t;i.push(t.substr(n+1,o-n-1)),n=o,r=-1;continue}s=="("&&e&&i.length>0&&(a=i[i.length-1]+";","vec4;main;".indexOf(a)<0&&(e.useFuns+=a)),r=-1;continue}r<0&&(r=n)}return r1&&(a=t.substr(r,h-r),i.push(a)),i}_compileToTree(t,e,i,s,r){var a,n,h,o,l,u,_,f,p,m,g;for(p=i;p=0&&(h=h.substr(0,u)),a=f||new Ii(s),f=null,a.text=h,a.noCompile=!0,(u=h.indexOf("#"))>=0){for(o="#",g=u+1,m=h.length;g]/)!=null,a.noCompile?console.log("function():Boolean{return "+h.substr(u+a.name.length)+"}"):(_=h.replace(/^\s*/,"").split(/\s+/),a.setCondition(_[1],o==="#ifdef"?ft.IFDEF_YES:ft.IFDEF_ELSE),a.text="//"+a.text),a.setParent(t),t=a,r)for(_=h.substr(g).split(ft._splitToWordExps3),g=0;g<_.length;g++)h=_[g],h.length&&(r[h]=!0);continue;case"#if":if(a.src=h,a.noCompile=!0,a.setParent(t),t=a,r)for(_=h.substr(g).split(ft._splitToWordExps3),g=0;g<_.length;g++)h=_[g],h.length&&h!="defined"&&(r[h]=!0);continue;case"#else":a.src=h,t=t.parent,n=t.childs[t.childs.length-1],a.noCompile=n.noCompile,a.noCompile||(a.condition=n.condition,a.conditionType=n.conditionType==ft.IFDEF_YES?ft.IFDEF_ELSE:ft.IFDEF_YES,a.text="//"+a.text+" "+n.text+" "+a.conditionType),a.setParent(t),t=a;continue;case"#endif":t=t.parent,n=t.childs[t.childs.length-1],a.noCompile=n.noCompile,a.noCompile||(a.text="//"+a.text),a.setParent(t);continue;case"#include":_=ft.splitToWords(h,null);var C=ft.includes[_[1]];if(!C)throw"ShaderCompile error no this include file:"+_[1];if((u=_[0].indexOf("?"))<0){a.setParent(t),h=C.getWith(_[2]=="with"?_[3]:null),this._compileToTree(a,h.split(` `),0,s,r),a.text="";continue}a.setCondition(_[0].substr(u+1),ft.IFDEF_YES),a.text=C.getWith(_[2]=="with"?_[3]:null);break;case"#import":_=ft.splitToWords(h,null),l=_[1],s.push({node:a,file:ft.includes[l],ofs:a.text.length});continue}}else{if(n=t.childs[t.childs.length-1],n&&!n.name){s.length>0&&ft.splitToWords(h,n),f=a,n.text+=` `+h;continue}s.length>0&&ft.splitToWords(h,a)}a.setParent(t)}}createShader(t,e,i,s){var r={},a="";if(t)for(var n in t)a+="#define "+n+` `,r[n]=!0;var h=this._VS.toscript(r,[]),o=this._PS.toscript(r,[]);return(i||bt.create)(a+h.join(` `),a+o.join(` `),e,this._nameMap,s)}}ft.IFDEF_NO=0,ft.IFDEF_YES=1,ft.IFDEF_ELSE=2,ft.IFDEF_PARENT=3,ft._removeAnnotation=new RegExp(`(/\\*([^*]|[\\r\\ ]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)`,"g"),ft._reg=new RegExp(`(".*")|('.*')|([#\\w\\*-\\.+/()=<>{}\\\\]+)|([,;:\\\\])`,"g"),ft._splitToWordExps=new RegExp(`[(".*")]+|[('.*')]+|([ \\t=\\+\\-*/&%!<>!%(),;])`,"g"),ft.includes={},ft._clearCR=new RegExp("\r","g"),ft._splitToWordExps3=new RegExp("[ \\t=\\+\\-*/&%!<>!%(),;\\|]","g");class Ft extends $t{constructor(){super(),this.worker=new Worker(Ft.workerPath);let t=this;this.worker.onmessage=function(e){t.workerMessage(e.data)}}static __init__(){return Ft._preLoadFun!=null||!Worker?!1:(Ft._preLoadFun=E.prototype._loadImage,E.prototype._loadImage=Ft.prototype._loadImage,Ft.I||(Ft.I=new Ft),!0)}static workerSupported(){return!!Worker}static enableWorkerLoader(){Ft._tryEnabled||(Ft.enable=!0,Ft._tryEnabled=!0)}static set enable(t){Ft._enable!=t&&(Ft._enable=t,t&&Ft._preLoadFun==null&&(Ft._enable=Ft.__init__()))}static get enable(){return Ft._enable}workerMessage(t){if(t)switch(t.type){case"Image":this.imageLoaded(t);break;case"Disable":Ft.enable=!1;break}}imageLoaded(t){if(!t.dataType||t.dataType!="imageBitmap"){this.event(t.url,null);return}var e=t.imageBitmap;console.log("load:",t.url),this.event(t.url,e)}loadImage(t){this.worker.postMessage(t)}_loadImage(t){var e=this;let i=e.type;if(!this._useWorkerLoader||!Ft._enable){Ft._preLoadFun.call(e,t);return}t=$.formatURL(t);function s(){Ft.I.off(t,e,r)}var r=function(a){if(s(),a){var n=a;i!=="nativeimage"&&(n=new _t,n.wrapModeU=d.WarpMode.Clamp,n.wrapModeV=d.WarpMode.Clamp,n.loadImageSource(a,!0)),e.onLoaded(n)}else Ft._preLoadFun.call(e,t)};Ft.I.on(t,e,r),Ft.I.loadImage(t)}}Ft.workerPath="libs/workerloader.js",Ft._enable=!1,Ft._tryEnabled=!1;class Te{static set cursor(t){Te._style.cursor=t}static get cursor(){return Te._style.cursor}static __init__(){Te._style=x.document.body.style}static hide(){Te.cursor!="none"&&(Te._preCursor=Te.cursor,Te.cursor="none")}static show(){Te.cursor=="none"&&(Te._preCursor?Te.cursor=Te._preCursor:Te.cursor="auto")}}class Ee extends We{constructor(t){super(Ee.const_stride,t*4*Ee.const_stride,4),this.canReuse=!0,this.setAttributes(Ee._fixattriInfo),this.createQuadIB(t),this._quadNum=t}static __init__(){var t=I.instance;Ee._fixattriInfo=[t.FLOAT,4,0,t.FLOAT,3,16,t.FLOAT,3,28,t.FLOAT,4,40,t.FLOAT,4,56,t.FLOAT,3,72,t.FLOAT,2,84,t.FLOAT,4,92,t.FLOAT,1,108,t.FLOAT,1,112]}setMaxParticleNum(t){this._vb._resizeBuffer(t*4*Ee.const_stride,!1),this.createQuadIB(t)}static getAMesh(t){if(Ee._POOL.length){var e=Ee._POOL.pop();return e.setMaxParticleNum(t),e}return new Ee(t)}releaseMesh(){this._vb.setByteLength(0),this.vertNum=0,this.indexNum=0,Ee._POOL.push(this)}destroy(){this._ib.destroy(),this._vb.destroy(),this._vb.deleteBuffer()}}Ee.const_stride=116,Ee._POOL=[];class ps extends zi{}ps.create=function(v,t,e){var i=new _t(v,t,e,!1,!1);return i.wrapModeU=d.WarpMode.Clamp,i.wrapModeV=d.WarpMode.Clamp,i};class G{static __init(t){t.forEach(function(e){e.__init$&&e.__init$()})}static init(t,e,...i){if(!G._isinit){G._isinit=!0,ArrayBuffer.prototype.slice||(ArrayBuffer.prototype.slice=G._arrayBufferSlice),x.__init__();var s=x.mainCanvas=new je(!0);if(G._setStyleInfo(s),!x.onKGMiniGame&&!x.onAlipayMiniGame&&x.container.appendChild(s.source),x.canvas=new je(!0),x.context=x.canvas.getContext("2d"),x.supportWebAudio=b.__init__(),x.supportLocalStorage=he.__init__(),G.systemTimer=new Jt(!1),d.systemTimer=Jt.gSysTimer=G.systemTimer,G.startTimer=new Jt(!1),G.physicsTimer=new Jt(!1),G.updateTimer=new Jt(!1),G.lateTimer=new Jt(!1),G.timer=new Jt(!1),d.startTimer=c.startTimer=G.startTimer,d.lateTimer=c.lateTimer=G.lateTimer,d.updateTimer=c.updateTimer=G.updateTimer,c.systemTimer=G.systemTimer,d.timer=c.timer=G.timer,d.physicsTimer=c.physicsTimer=G.physicsTimer,G.loader=new ce,c.Laya=G,d.loader=c.loader=G.loader,re.__init__(),Vt.__init(),Te.__init__(),Ce.inner_enable(),i)for(var r=0,a=i.length;r=a.length&&(i=a.length-1),t[e][i]}return e in r?r[e]:s}_getNodeGraphicData(t,e,i){i||(i=new cr),i.transform?i.transform.identity():i.transform=new et;var s=this.getNodeDataByID(t);if(!s)return i;var r=s.frames,a=this._getParams(r,Gt._drawTextureCmd,e,this._nodeDefaultProps[t]),n=a[0],h,o,l=a[5],u=a[6],_=a[13],f=a[14],p=a[7],m=a[8],g=a[9],y=a[11],C=a[12];h=a[3],o=a[4],(h==0||o==0)&&(n=null),h==-1&&(h=0),o==-1&&(o=0);var w;i.skin=n,i.width=h,i.height=o,n&&(w=this._getTextureByUrl(n),w?(h||(h=w.sourceWidth),o||(o=w.sourceHeight)):console.warn("lost skin:",n,",you may load pics first")),i.alpha=a[10];var M=i.transform;_!=0&&(l=_*h),f!=0&&(u=f*o),(l!=0||u!=0)&&M.translate(-l,-u);var R=null;if(g||p!==1||m!==1||y||C){R=Gt._tempMt,R.identity(),R._bTransform=!0;var B=(g-y)*.0174532922222222,k=(g+C)*.0174532922222222,z=Math.cos(k),S=Math.sin(k),dt=Math.sin(B),Mt=Math.cos(B);R.a=p*z,R.b=p*S,R.c=-m*dt,R.d=m*Mt,R.tx=R.ty=0}return R&&(M=et.mul(M,R,M)),M.translate(a[1],a[2]),i}_getTextureByUrl(t){return E.getRes(t)}setAniData(t,e=null){if(t.animations){this._nodeDefaultProps={},this._nodeGDic={},this._nodeList&&(this._nodeList.length=0),this._rootNode=t,this._parseNodeList(t);var i={},s=[],r=t.animations,a,n=r.length,h;for(a=0;a.01&&this._frames&&super._frameLoop()}_displayToIndex(t){this._frames&&(this.graphics=this._frames[t])}get frames(){return this._frames}set frames(t){this._frames=t,t&&(this._count=t.length,this._actionName&&this._setFramesFromCache(this._actionName,!0),this.index=this._index)}set source(t){t.indexOf(".ani")>-1?this.loadAnimation(t):t.indexOf(".json")>-1||t.indexOf("als")>-1||t.indexOf("atlas")>-1?this.loadAtlas(t):this.loadImages(t.split(","))}set autoAnimation(t){this.play(0,!0,t)}set autoPlay(t){t?this.play():this.stop()}clear(){return super.clear(),this.stop(),this.graphics=null,this._frames=null,this._labels=null,this}loadImages(t,e=""){return this._url="",this._setFramesFromCache(e)||(this.frames=Ht.framesMap[e]?Ht.framesMap[e]:Ht.createFrames(t,e)),this}loadAtlas(t,e=null,i=""){this._url="";var s=this;if(!s._setFramesFromCache(i)){let r=function(a){t===a&&(s.frames=Ht.framesMap[i]?Ht.framesMap[i]:Ht.createFrames(t,i),e&&e.run())};E.getAtlas(t)?r(t):c.loader.load(t,mt.create(null,r,[t]),null,E.ATLAS)}return this}loadAnimation(t,e=null,i=null){this._url=t;var s=this;return this._actionName||(this._actionName=""),s._setFramesFromCache(this._actionName)?(s._setFramesFromCache(this._actionName,!0),this.index=0,e&&e.run()):!i||E.getAtlas(i)?this._loadAnimationData(t,e,i):c.loader.load(i,mt.create(this,this._loadAnimationData,[t,e,i]),null,E.ATLAS),this}_loadAnimationData(t,e=null,i=null){if(i&&!E.getAtlas(i)){console.warn("atlas load fail:"+i);return}var s=this;function r(a){if(!E.getRes(a)){Ht.framesMap[t+"#"]&&(s._setFramesFromCache(s._actionName,!0),s.index=0,s._resumePlay(),e&&e.run());return}if(t===a){var n;if(Ht.framesMap[t+"#"])s._setFramesFromCache(s._actionName,!0),s.index=0,s._resumePlay();else{var h=Gt.parseAnimationData(E.getRes(t));if(!h)return;var o=h.animationList,l,u=o.length,_;for(l=0;lthis._count&&(t=this._count);var e=this._animationData.nodes,i,s=e.length;for(s=s>1?1:s,i=0;ie?h=n[e]:h=n[n.length-1],s[a]=h}}_calculateKeyFrames(t){super._calculateKeyFrames(t);var e=t.keyframes,i,s,r=t.target,a={};t.secondFrames=a;for(i in e)s=e[i],s.length<=1?a[i]=-1:a[i]=s[1].index}}Ze.EFFECT_BEGIN="effectbegin",Y.regClass("laya.display.EffectAnimation",Ze),Y.regClass("Laya.EffectAnimation",Ze);class Ue extends $t{constructor(){super(),this._completeHandler=new mt(this,this.onOneLoadComplete),this.reset()}reset(){this._toLoadList=[],this._isLoading=!1,this.totalCount=0}get leftCount(){return this._isLoading?this._toLoadList.length+1:this._toLoadList.length}get loadedCount(){return this.totalCount-this.leftCount}load(t,e=!1,i=!0){if(t instanceof Array){var s,r;for(r=t.length,s=0;s=0||E.getRes(t)||(e?this._toLoadList.push({url:t}):this._toLoadList.push(t),this.totalCount++)}_checkNext(){if(!this._isLoading){if(this._toLoadList.length==0){this.event(T.COMPLETE);return}var t;t=this._toLoadList.pop(),typeof t=="string"?this.loadOne(t):this.loadOne(t.url,!0)}}loadOne(t,e=!1){this._curUrl=t;var i=J.getFileExtension(this._curUrl);e?c.loader.create(t,this._completeHandler):Ue.LoadableExtensions[i]?c.loader.load(t,this._completeHandler,null,Ue.LoadableExtensions[i]):t!=Qe.getFileLoadPath(t)||Ue.No3dLoadTypes[i]||!ce.createMap[i]?c.loader.load(t,this._completeHandler):c.loader.create(t,this._completeHandler)}onOneLoadComplete(){this._isLoading=!1,E.getRes(this._curUrl)||console.log("Fail to load:",this._curUrl);var t=J.getFileExtension(this._curUrl);if(Ue.LoadableExtensions[t]){var e;e=E.getRes(this._curUrl),e&&e instanceof _s&&(e=e.json),e&&(e.loadList&&this.load(e.loadList,!1,!1),e.loadList3D&&this.load(e.loadList3D,!0,!1))}t=="sk"&&this.load(this._curUrl.replace(".sk",".png"),!1,!1),this.event(T.PROGRESS,this.getProgress()),this._checkNext()}getProgress(){return this.loadedCount/this.totalCount}}Ue.LoadableExtensions={scene:E.JSON,scene3d:E.JSON,ani:E.JSON,ui:E.JSON,prefab:E.PREFAB},Ue.No3dLoadTypes={png:!0,jpg:!0,txt:!0};class ct extends zt{constructor(t=!0){super(),this.autoDestroyAtClosed=!1,this.url=null,this._viewCreated=!1,this._idMap=null,this._$componentType="Scene",ct.unDestroyedScenes.push(this),this._scene=this,t&&this.createChildren()}createChildren(){}static setUIMap(t){let e=c.loader.getRes(t);if(e)for(let i in e)c.Loader.loadedMap[$.formatURL(i+".scene")]=e[i];else throw"\u8BF7\u63D0\u524D\u52A0\u8F7Duimap\u7684json\uFF0C\u518D\u4F7F\u7528\u8BE5\u63A5\u53E3\u8BBE\u7F6E\uFF01"}loadScene(t){var e=t.indexOf(".")>-1?t:t+".scene",i=c.loader.getRes(e);if(i)this.createView(i);else{this._setBit(Q.NOT_READY,!0),c.loader.resetProgress();var s=new Ue;s.on(T.COMPLETE,this,this._onSceneLoaded,[e]),s.load(e)}}_onSceneLoaded(t){this.createView(c.Loader.getRes(t))}createView(t){t&&!this._viewCreated&&(this._viewCreated=!0,Vt.createByData(this,t))}getNodeByID(t){return this._idMap?this._idMap[t]:null}open(t=!0,e=null){t&&ct.closeAll(),ct.root.addChild(this),this.onOpened(e)}onOpened(t){}close(t=null){this.onClosed(t),this.autoDestroyAtClosed?this.destroy():this.removeSelf()}onClosed(t=null){}destroy(t=!0){this._idMap=null,super.destroy(t);for(var e=ct.unDestroyedScenes,i=e.length-1;i>-1;i--)if(e[i]===this){e.splice(i,1);return}}set scaleX(t){super.get_scaleX()!=t&&(super.set_scaleX(t),this.event(T.RESIZE))}get scaleX(){return super.scaleX}set scaleY(t){super.get_scaleY()!=t&&(super.set_scaleY(t),this.event(T.RESIZE))}get scaleY(){return super.scaleY}get width(){if(this._width)return this._width;for(var t=0,e=this.numChildren-1;e>-1;e--){var i=this.getChildAt(e);i._visible&&(t=Math.max(i._x+i.width*i.scaleX,t))}return t}set width(t){super.get_width()!=t&&(super.set_width(t),this.callLater(this._sizeChanged))}get height(){if(this._height)return this._height;for(var t=0,e=this.numChildren-1;e>-1;e--){var i=this.getChildAt(e);i._visible&&(t=Math.max(i._y+i.height*i.scaleY,t))}return t}set height(t){super.get_height()!=t&&(super.set_height(t),this.callLater(this._sizeChanged))}_sizeChanged(){this.event(T.RESIZE)}static get root(){return ct._root||(ct._root=c.stage.addChild(new zt),ct._root.name="root",c.stage.on("resize",null,()=>{ct._root.size(c.stage.width,c.stage.height),ct._root.event(T.RESIZE)}),ct._root.size(c.stage.width,c.stage.height),ct._root.event(T.RESIZE)),ct._root}get timer(){return this._timer||c.timer}set timer(t){this._timer=t}static load(t,e=null,i=null){c.loader.resetProgress();var s=new Ue;s.on(T.PROGRESS,null,r),s.once(T.COMPLETE,null,a),s.load(t);function r(n){ct._loadPage&&ct._loadPage.event("progress",n),i&&i.runWith(n)}function a(){s.off(T.PROGRESS,null,r);var n=c.Loader.getRes(t);if(!n)throw"Can not find scene:"+t;if(!n.props)throw"Scene data is error:"+t;var h=n.props.runtime?n.props.runtime:n.type,o=c.ClassUtils.getClass(h);if(n.props.renderType=="instance")var l=o.instance||(o.instance=new o);else l=new o;if(l&&l instanceof ge)l.url=t,l._viewCreated?e&&e.runWith(l):(l.on("onViewCreated",null,function(){e&&e.runWith(l)}),l.createView(n)),ct.hideLoadingPage();else throw"Can not find scene:"+h}}static open(t,e=!0,i=null,s=null,r=null){if(i instanceof mt){var a=s;s=i,i=a}ct.showLoadingPage(),ct.load(t,mt.create(null,this._onSceneLoaded,[e,s,i]),r)}static _onSceneLoaded(t,e,i,s){s.open(t,i),e&&e.runWith(s)}static close(t,e=""){for(var i=!1,s=ct.unDestroyedScenes,r=0,a=s.length;r0&&(s=I.UPLOAD_SHADER_UNIFORM_TYPE_DATA);var r=i._data;return I.instance.uploadShaderUniforms(e,r,s)}}class at{constructor(){}static getMCDName(t){return at._typeToNameDic[t]}static showRenderTypeInfo(t,e=!1){if(!(!e&&at.showedDic[t])){if(at.showedDic[t]=!0,!at._rendertypeToStrDic[t]){var i=[],s;for(s=1;s<=t;)s&t&&i.push(at.getMCDName(s&t)),s=s<<1;at._rendertypeToStrDic[t]=i.join(",")}console.log("cmd:",at._rendertypeToStrDic[t])}}static __init__(){at._typeToNameDic[P.ALPHA]="ALPHA",at._typeToNameDic[P.TRANSFORM]="TRANSFORM",at._typeToNameDic[P.TEXTURE]="TEXTURE",at._typeToNameDic[P.GRAPHICS]="GRAPHICS",at._typeToNameDic[P.ONECHILD]="ONECHILD",at._typeToNameDic[P.CHILDS]="CHILDS",at._typeToNameDic[P.TRANSFORM|P.ALPHA]="TRANSFORM|ALPHA",at._typeToNameDic[P.CANVAS]="CANVAS",at._typeToNameDic[P.BLEND]="BLEND",at._typeToNameDic[P.FILTERS]="FILTERS",at._typeToNameDic[P.MASK]="MASK",at._typeToNameDic[P.CLIP]="CLIP",at._typeToNameDic[P.LAYAGL3D]="LAYAGL3D"}render(t,e,i){at._addType(this._renderType),at.showRenderTypeInfo(this._renderType),xt.renders[this._renderType]._fun(this,t,e+this._x,i+this._y),this._repaint=0}_stageRender(t,e,i){at._countStart(),at._PreStageRender.call(c.stage,t,e,i),at._countEnd()}static _countStart(){var t;for(t in at._countDic)at._countDic[t]=0}static _countEnd(){at._i++,at._i>60&&(at.showCountInfo(),at._i=0)}static _addType(t){at._countDic[t]?at._countDic[t]+=1:at._countDic[t]=1}static showCountInfo(){console.log("===================");var t;for(t in at._countDic)console.log("count:"+at._countDic[t]),at.showRenderTypeInfo(t,!0)}static enableQuickTest(){at.__init__(),zt.prototype.render=at.prototype.render,at._PreStageRender=Z.prototype.render,Z.prototype.render=at.prototype._stageRender}}at.showedDic={},at._rendertypeToStrDic={},at._typeToNameDic={},at._countDic={},at._i=0;class gr extends $t{load(t){}play(t=0,e=0){return null}get duration(){return 0}dispose(){}}class ys extends zt{constructor(){super(),this.visible=!1,this.on(T.ADDED,this,this._onParentChange),this.on(T.REMOVED,this,this._onParentChange)}_onParentChange(){this.target=this.parent}play(t=1,e=null){isNaN(t)&&(t=1),this.url&&(this.stop(),this._channel=b.playSound(this.url,t,e))}stop(){this._channel&&!this._channel.isStopped&&this._channel.stop(),this._channel=null}_setPlayAction(t,e,i,s=!0){this[i]&&t&&(s?t.on(e,this,this[i]):t.off(e,this,this[i]))}_setPlayActions(t,e,i,s=!0){if(t&&e){var r=e.split(","),a,n;for(n=r.length,a=0;a0&&e<65535&&this.connect(t,e)}get input(){return this._input}get output(){return this._output}get connected(){return this._connected}get endian(){return this._endian}set endian(t){this._endian=t,this._input!=null&&(this._input.endian=t),this._output!=null&&(this._output.endian=t)}connect(t,e){var i="ws://"+t+":"+e;this.connectByUrl(i)}connectByUrl(t){this._socket!=null&&this.close(),this._socket&&this.cleanSocket(),!this.protocols||this.protocols.length==0?this._socket=new x.window.WebSocket(t):this._socket=new x.window.WebSocket(t,this.protocols),this._socket.binaryType="arraybuffer",this._output=new this._byteClass,this._output.endian=this.endian,this._input=new this._byteClass,this._input.endian=this.endian,this._addInputPosition=0,this._socket.onopen=e=>{this._onOpen(e)},this._socket.onmessage=e=>{this._onMessage(e)},this._socket.onclose=e=>{this._onClose(e)},this._socket.onerror=e=>{this._onError(e)}}cleanSocket(){this.close(),this._connected=!1,this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null,this._socket=null}close(){if(this._socket!=null)try{this._socket.close()}catch{}}_onOpen(t){this._connected=!0,this.event(T.OPEN,t)}_onMessage(t){if(!(!t||!t.data)){var e=t.data;if(this.disableInput&&e){this.event(T.MESSAGE,e);return}this._input.length>0&&this._input.bytesAvailable<1&&(this._input.clear(),this._addInputPosition=0);var i=this._input.pos;!this._addInputPosition&&(this._addInputPosition=0),this._input.pos=this._addInputPosition,e&&(typeof e=="string"?this._input.writeUTFBytes(e):this._input.writeArrayBuffer(e),this._addInputPosition=this._input.pos,this._input.pos=i),this.event(T.MESSAGE,e)}}_onClose(t){this._connected=!1,this.event(T.CLOSE,t)}_onError(t){this.event(T.ERROR,t)}send(t){this._socket.send(t)}flush(){if(this._output&&this._output.length>0){var t;try{this._socket&&this._socket.send(this._output.__getBuffer().slice(0,this._output.length))}catch(e){t=e}this._output.endian=this.endian,this._output.clear(),t&&this.event(T.ERROR,t)}}}ki.LITTLE_ENDIAN="littleEndian",ki.BIG_ENDIAN="bigEndian",function(v){v[v.Normal=0]="Normal",v[v.RGBM=1]="RGBM"}(d.TextureDecodeFormat||(d.TextureDecodeFormat={}));class Wi extends Nt{constructor(){var t=I.instance;super(t.RGB,!1),this._glTextureType=t.TEXTURE_2D,this._width=1,this._height=1,this._wrapModeU=this._wrapModeV=d.WarpMode.Clamp,this._filterMode=d.FilterMode.Bilinear,this._setWarpMode(t.TEXTURE_WRAP_S,this._wrapModeU),this._setWarpMode(t.TEXTURE_WRAP_T,this._wrapModeV),this._setFilterMode(this._filterMode),this._needUpdate=!1,this._readyed=!0,Wi._videoTexturePool.push(this)}static _update(){for(var t=Wi._videoTexturePool,e=0,i=t.length;e=St.maxCount&&St.clear(),St._count++,St._logdiv.innerText+=t+` `,St.autoScrollToBottom&&St._logdiv.scrollHeight-St._logdiv.scrollTop-St._logdiv.clientHeight<50&&(St._logdiv.scrollTop=St._logdiv.scrollHeight))}static clear(){St._logdiv.innerText="",St._count=0}}St._count=0,St.maxCount=50,St.autoScrollToBottom=!0;let Ys=300;class Vs{constructor(t,e,i,s){this.scale=1,this.datas=new Array(Ys),this.datapos=0,this.id=t,this.color=e,this.name=i,this.scale=s}addData(t){this.datas[this.datapos]=t,this.datapos++,this.datapos%=Ys}}class _e extends zt{constructor(){super(),this.datas=[],this.xdata=new Array(_e.DATANUM),this.ydata=new Array(_e.DATANUM),this.hud_width=800,this.hud_height=200,this.gMinV=0,this.gMaxV=100,this.textSpace=40,this.sttm=0,_e.inst=this,this._renderType|=P.CUSTOM,this._setRenderType(this._renderType),this._setCustomRender(),this.addDataDef(0,16777215,"frame",1),this.addDataDef(1,65280,"update",1),this.addDataDef(2,16711680,"flush",1),_e._now=performance?performance.now.bind(performance):Date.now}now(){return _e._now()}start(){this.sttm=_e._now()}end(t){var e=_e._now()-this.sttm;this.updateValue(t,e)}config(t,e){this.hud_width=t,this.hud_height=e}addDataDef(t,e,i,s){this.datas[t]=new Vs(t,e,i,s)}updateValue(t,e){this.datas[t].addData(e)}v2y(t){var e=this._y+this.hud_height*(1-(t-this.gMinV)/this.gMaxV);return this._y+this.hud_height*(1-(t-this.gMinV)/this.gMaxV)}drawHLine(t,e,i,s){var r=this._x,a=this._x+this.hud_width,n=this.v2y(e);t.fillText(s,r,n-6,null,"green",null),r+=this.textSpace,t.fillStyle=i,t.fillRect(r,n,this._x+this.hud_width,1,null)}customRender(t,e,i){var s=performance.now();_e._lastTm<=0&&(_e._lastTm=s),this.updateValue(0,s-_e._lastTm),_e._lastTm=s,t.save(),t.fillRect(this._x,this._y,this.hud_width,this.hud_height+4,"#000000cc"),t.globalAlpha=.9,this.drawHLine(t,0,"green"," 0"),this.drawHLine(t,10,"green"," 10"),this.drawHLine(t,16.667,"red"," "),this.drawHLine(t,20,"green","50|20"),this.drawHLine(t,16.667*2,"yellow",""),this.drawHLine(t,16.667*3,"yellow",""),this.drawHLine(t,16.667*4,"yellow",""),this.drawHLine(t,50,"green","20|50"),this.drawHLine(t,100,"green","10|100");for(var r=0,a=this.datas.length;rthis.maxCount&&e.splice(this.maxCount,e.length-this.maxCount)}static addPoolCacheManager(t,e=100){var i;i=new Es,i.sign=t,i.maxCount=e,Yt.regCacheByFunction(J.bind(i.tryDispose,i),J.bind(i.getCacheList,i))}}class hs extends $t{constructor(){super(...arguments),this._tweenDic={},this._tweenDataList=[],this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this._gidIndex=0,this._firstTweenDic={},this._startTimeSort=!1,this._endTimeSort=!1,this._loopKey=!1,this.scale=1,this._frameRate=60,this._frameIndex=0,this._total=0}static to(t,e,i,s=null,r=0){return new hs().to(t,e,i,s,r)}static from(t,e,i,s=null,r=0){return new hs().from(t,e,i,s,r)}to(t,e,i,s=null,r=0){return this._create(t,e,i,s,r,!0)}from(t,e,i,s=null,r=0){return this._create(t,e,i,s,r,!1)}_create(t,e,i,s,r,a){var n=D.getItemByClass("tweenData",Hs);return n.isTo=a,n.type=0,n.target=t,n.duration=i,n.data=e,n.startTime=this._startTime+r,n.endTime=n.startTime+n.duration,n.ease=s,this._startTime=Math.max(n.endTime,this._startTime),this._tweenDataList.push(n),this._startTimeSort=!0,this._endTimeSort=!0,this}addLabel(t,e){var i=D.getItemByClass("tweenData",Hs);return i.type=1,i.data=t,i.endTime=i.startTime=this._startTime+e,this._labelDic||(this._labelDic={}),this._labelDic[t]=i,this._tweenDataList.push(i),this}removeLabel(t){if(this._labelDic&&this._labelDic[t]){var e=this._labelDic[t];if(e){var i=this._tweenDataList.indexOf(e);i>-1&&this._tweenDataList.splice(i,1)}delete this._labelDic[t]}}gotoTime(t){if(!(this._tweenDataList==null||this._tweenDataList.length==0)){var e,i;for(var s in this._firstTweenDic)if(i=this._firstTweenDic[s],i)for(var r in i)r in i.diyTarget&&(i.diyTarget[r]=i[r]);for(s in this._tweenDic)e=this._tweenDic[s],e.clear(),delete this._tweenDic[s];this._index=0,this._gidIndex=0,this._currTime=t,this._lastTime=x.now();var a;if(this._endTweenDataList==null||this._endTimeSort){let _=function(f,p){return f.endTime>p.endTime?1:f.endTime=n.endTime){this._index=Math.max(this._index,h+1);var l=n.data;if(n.isTo)for(var u in l)n.target[u]=l[u]}else break;for(h=0,o=this._tweenDataList.length;h=n.startTime&&t_.startTime?1:u.startTime<_.startTime?-1:0};this._startTimeSort=!1,this._tweenDataList.sort(l);for(var i=0,s=this._tweenDataList.length;i=this._startTime)if(this._loopKey){if(this._complete(),!this._tweenDataList)return;this.gotoTime(0)}else{for(var t in this._tweenDic)r=this._tweenDic[t],r.complete();this.pause(),this._complete();return}var e=x.now(),i=e-this._lastTime,s=this._currTime+=i*this.scale;this._lastTime=e;for(t in this._tweenDic)r=this._tweenDic[t],r._updateEase(s);var r;if(this._tweenDataList.length!=0&&this._index=a.startTime&&(this._index++,a.type==0?(this._gidIndex++,r=D.getItemByClass("tween",qt),r._create(a.target,a.data,a.duration,a.ease,mt.create(this,this._animComplete,[this._gidIndex]),0,!1,a.isTo,!0,!1),r.setStartTime(s),r.gid=this._gidIndex,this._tweenDic[this._gidIndex]=r,r._updateEase(s)):this.event(T.LABEL,a.data))}}_animComplete(t){var e=this._tweenDic[t];e&&delete this._tweenDic[t]}_complete(){this.event(T.COMPLETE)}get index(){return this._frameIndex}set index(t){this._frameIndex=t,this.gotoTime(this._frameIndex/this._frameRate*1e3)}get total(){return this._total=Math.floor(this._startTime/1e3*this._frameRate),this._total}reset(){var t;if(this._labelDic)for(t in this._labelDic)delete this._labelDic[t];var e;for(t in this._tweenDic)e=this._tweenDic[t],e.clear(),delete this._tweenDic[t];for(t in this._firstTweenDic)delete this._firstTweenDic[t];if(this._endTweenDataList=null,this._tweenDataList&&this._tweenDataList.length){var i,s;for(s=this._tweenDataList.length,i=0;i-1)return String.fromCharCode(jt.charsMap[e][0]);for(e=0;e-1)return String.fromCharCode(jt.combCharsMap[e][0][0])+String.fromCharCode(jt.combCharsMap[e][0][1]);return String.fromCharCode(t)}convertArabic(t){for(var e,i,s="",r=0;r=0&&this.isTransparent(t.charCodeAt(o));--o);for(n=o>=0?t.charCodeAt(o):null,e=n?this.getCharRep(n):!1,(!e||e[2]==null&&e[3]==null)&&(n=null);l