diff --git a/package.json b/package.json index abcc114..9c2ab8c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@riophae/vue-treeselect": "0.4.0", "axios": "0.24.0", "clipboard": "2.0.8", - "core-js": "3.25.3", + "core-js": "^3.33.2", "echarts": "5.4.0", "element-ui": "2.15.13", "file-saver": "2.0.5", diff --git a/public/Model.js b/public/Model.js new file mode 100644 index 0000000..3f7dd1b --- /dev/null +++ b/public/Model.js @@ -0,0 +1,38 @@ +var AMRT=function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function n(e){for(var n=1;n=0;--r){var a=this.tryEntries[r],o=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;M(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:B(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t,n,i,r,a,o){try{var s=e[a](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var o=e.apply(t,n);function s(e){a(o,i,r,s,l,"next",e)}function l(e){a(o,i,r,s,l,"throw",e)}s(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}Array.prototype.insert=function(e,t){this.splice(t,0,e)},Array.prototype.removeAt=function(e){return!(isNaN(e)||e>=this.length)&&this.splice(e,1)[0]},Array.prototype.remove=function(e){var t=this.indexOf(e);t>-1&&this.splice(t,1)},"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e}),"function"!=typeof String.prototype.endsWith&&(String.prototype.endsWith=function(e){return-1!==this.indexOf(e,this.length-e.length)}),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>8&255]+qe[e>>16&255]+qe[e>>24&255]+"-"+qe[255&t]+qe[t>>8&255]+"-"+qe[t>>16&15|64]+qe[t>>24&255]+"-"+qe[63&n|128]+qe[n>>8&255]+"-"+qe[n>>16&255]+qe[n>>24&255]+qe[255&i]+qe[i>>8&255]+qe[i>>16&255]+qe[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*et.DEG2RAD},radToDeg:function(e){return e*et.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){var t=Math.log(e)/Math.LN2;return t=t-Math.floor(t)<=.5?Math.floor(t):Math.ceil(t),Math.pow(2,t)}};function tt(e,t){this.x=e||0,this.y=t||0}function nt(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}Object.defineProperties(tt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(tt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?this.addVectors(e,t):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?this.subVectors(e,t):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,n){return this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}}),Object.assign(nt,{slerp:function(e,t,n,i){return n.copy(e).slerp(t,i)},slerpFlat:function(e,t,n,i,r,a,o){var s=n[i+0],l=n[i+1],A=n[i+2],c=n[i+3],h=r[a+0],u=r[a+1],d=r[a+2],f=r[a+3];if(c!==f||s!==h||l!==u||A!==d){var p=1-o,m=s*h+l*u+A*d+c*f,v=m>=0?1:-1,g=1-m*m;if(g>Number.EPSILON){var y=Math.sqrt(g),w=Math.atan2(y,m*v);p=Math.sin(p*w)/y,o=Math.sin(o*w)/y}var x=o*v;if(s=s*p+h*x,l=l*p+u*x,A=A*p+d*x,c=c*p+f*x,p===1-o){var b=1/Math.sqrt(s*s+l*l+A*A+c*c);s*=b,l*=b,A*=b,c*=b}}e[t]=s,e[t+1]=l,e[t+2]=A,e[t+3]=c}}),Object.defineProperties(nt.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(nt.prototype,{isQuaternion:!0,set:function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,i=e._y,r=e._z,a=e.order,o=Math.cos,s=Math.sin,l=o(n/2),A=o(i/2),c=o(r/2),h=s(n/2),u=s(i/2),d=s(r/2);return"XYZ"===a?(this._x=h*A*c+l*u*d,this._y=l*u*c-h*A*d,this._z=l*A*d+h*u*c,this._w=l*A*c-h*u*d):"YXZ"===a?(this._x=h*A*c+l*u*d,this._y=l*u*c-h*A*d,this._z=l*A*d-h*u*c,this._w=l*A*c+h*u*d):"ZXY"===a?(this._x=h*A*c-l*u*d,this._y=l*u*c+h*A*d,this._z=l*A*d+h*u*c,this._w=l*A*c-h*u*d):"ZYX"===a?(this._x=h*A*c-l*u*d,this._y=l*u*c+h*A*d,this._z=l*A*d-h*u*c,this._w=l*A*c+h*u*d):"YZX"===a?(this._x=h*A*c+l*u*d,this._y=l*u*c+h*A*d,this._z=l*A*d-h*u*c,this._w=l*A*c-h*u*d):"XZY"===a&&(this._x=h*A*c-l*u*d,this._y=l*u*c-h*A*d,this._z=l*A*d+h*u*c,this._w=l*A*c+h*u*d),!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],l=n[9],A=n[2],c=n[6],h=n[10],u=i+s+h;return u>0?(t=.5/Math.sqrt(u+1),this._w=.25/t,this._x=(c-l)*t,this._y=(a-A)*t,this._z=(o-r)*t):i>s&&i>h?(t=2*Math.sqrt(1+i-s-h),this._w=(c-l)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(a+A)/t):s>h?(t=2*Math.sqrt(1+s-i-h),this._w=(a-A)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(l+c)/t):(t=2*Math.sqrt(1+h-i-s),this._w=(o-r)/t,this._x=(a+A)/t,this._y=(l+c)/t,this._z=.25*t),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var n=e.dot(t)+1;return n<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(et.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var i=Math.min(1,t/n);return this.slerp(e,i),this},inverse:function(){return this.conjugate()},invert:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,l=t._z,A=t._w;return this._x=n*A+a*o+i*l-r*s,this._y=i*A+a*s+r*o-n*l,this._z=r*A+a*l+n*s-i*o,this._w=a*A-n*o-i*s-r*l,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,a=this._w,o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;var s=1-o*o;if(s<=Number.EPSILON){var l=1-t;return this._w=l*a+t*this._w,this._x=l*n+t*this._x,this._y=l*i+t*this._y,this._z=l*r+t*this._z,this.normalize(),this._onChangeCallback(),this}var A=Math.sqrt(s),c=Math.atan2(A,o),h=Math.sin((1-t)*c)/A,u=Math.sin(t*c)/A;return this._w=a*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},slerpQuaternions:function(e,t,n){return this.copy(e).slerp(t,n)},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var it=new at,rt=new nt;function at(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(at.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(rt.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(rt.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*i-o*n,A=s*n+o*t-r*i,c=s*i+r*n-a*t,h=-r*t-a*n-o*i;return this.x=l*s+h*-r+A*-o-c*-a,this.y=A*s+h*-a+c*-r-l*-o,this.z=c*s+h*-o+l*-a-A*-r,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(e){return it.copy(this).projectOnVector(e),this.sub(it)},reflect:function(e){return this.sub(it.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());0===t&&console.error("Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(e)/t;return Math.acos(et.clamp(n,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,n){var i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}});var ot,st=new at;function lt(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.assign(lt.prototype,{isMatrix3:!0,set:function(e,t,n,i,r,a,o,s,l){var A=this.elements;return A[0]=e,A[1]=i,A[2]=o,A[3]=t,A[4]=r,A[5]=s,A[6]=n,A[7]=a,A[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(e){for(var t=0,n=e.count;t2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},ct=0;function ht(e,t,n,i,r,a,o,s,l,A){Object.defineProperty(this,"id",{value:ct++}),this.uuid=et.generateUUID(),this.name="",this.image=void 0!==e?e:ht.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:ht.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:j,this.wrapT=void 0!==i?i:j,this.magFilter=void 0!==r?r:Z,this.minFilter=void 0!==a?a:q,this.anisotropy=void 0!==l?l:1,this.format=void 0!==o?o:ce,this.type=void 0!==s?s:$,this.offset=new tt(0,0),this.repeat=new tt(1,1),this.center=new tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new lt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==A?A:Oe,this.version=0,this.onUpdate=null}function ut(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function dt(e,t,n){this.width=e,this.height=t,this.scissor=new ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t),n=n||{},this.texture=new ht(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Z,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function ft(e,t,n){dt.call(this,e,t,n),this.samples=4}ht.DEFAULT_IMAGE=void 0,ht.DEFAULT_MAPPING=O,ht.prototype=Object.assign(Object.create(Je.prototype),{constructor:ht,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=et.generateUUID()),!t&&void 0===e.images[i.uuid]){var r;if(Array.isArray(i)){r=[];for(var a=0,o=i.length;a1)switch(this.wrapS){case V:e.x=e.x-Math.floor(e.x);break;case j:e.x=e.x<0?0:1;break;case W:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case V:e.y=e.y-Math.floor(e.y);break;case j:e.y=e.y<0?0:1;break;case W:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(ht.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties(ut.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(ut.prototype,{isVector4:!0,set:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?this.addVectors(e,t):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?this.subVectors(e,t):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,n,i,r,a=.01,o=.1,s=e.elements,l=s[0],A=s[4],c=s[8],h=s[1],u=s[5],d=s[9],f=s[2],p=s[6],m=s[10];if(Math.abs(A-h)g&&v>y?vy?g0&&console.error("Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(bt.prototype,{isMatrix4:!0,set:function(e,t,n,i,r,a,o,s,l,A,c,h,u,d,f,p){var m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=s,m[2]=l,m[6]=A,m[10]=c,m[14]=h,m[3]=u,m[7]=d,m[11]=f,m[15]=p,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new bt).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,n=e.elements,i=1/pt.setFromMatrixColumn(e,0).length(),r=1/pt.setFromMatrixColumn(e,1).length(),a=1/pt.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),A=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){var h=a*A,u=a*c,d=o*A,f=o*c;t[0]=s*A,t[4]=-s*c,t[8]=l,t[1]=u+d*l,t[5]=h-f*l,t[9]=-o*s,t[2]=f-h*l,t[6]=d+u*l,t[10]=a*s}else if("YXZ"===e.order){var p=s*A,m=s*c,v=l*A,g=l*c;t[0]=p+g*o,t[4]=v*o-m,t[8]=a*l,t[1]=a*c,t[5]=a*A,t[9]=-o,t[2]=m*o-v,t[6]=g+p*o,t[10]=a*s}else if("ZXY"===e.order){p=s*A,m=s*c,v=l*A,g=l*c;t[0]=p-g*o,t[4]=-a*c,t[8]=v+m*o,t[1]=m+v*o,t[5]=a*A,t[9]=g-p*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){h=a*A,u=a*c,d=o*A,f=o*c;t[0]=s*A,t[4]=d*l-u,t[8]=h*l+f,t[1]=s*c,t[5]=f*l+h,t[9]=u*l-d,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var y=a*s,w=a*l,x=o*s,b=o*l;t[0]=s*A,t[4]=b-y*c,t[8]=x*c+w,t[1]=c,t[5]=a*A,t[9]=-o*A,t[2]=-l*A,t[6]=w*c+x,t[10]=y-b*c}else if("XZY"===e.order){y=a*s,w=a*l,x=o*s,b=o*l;t[0]=s*A,t[4]=-c,t[8]=l*A,t[1]=y*c+b,t[5]=a*A,t[9]=w*c-x,t[2]=x*c-w,t[6]=o*A,t[10]=b*c+y}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(vt,e,gt)},lookAt:function(e,t,n){var i=this.elements;return xt.subVectors(e,t),0===xt.lengthSq()&&(xt.z=1),xt.normalize(),yt.crossVectors(n,xt),0===yt.lengthSq()&&(1===Math.abs(n.z)?xt.x+=1e-4:xt.z+=1e-4,xt.normalize(),yt.crossVectors(n,xt)),yt.normalize(),wt.crossVectors(xt,yt),i[0]=yt.x,i[4]=wt.x,i[8]=xt.x,i[1]=yt.y,i[5]=wt.y,i[9]=xt.y,i[2]=yt.z,i[6]=wt.z,i[10]=xt.z,this},multiply:function(e,t){return void 0!==t?(console.warn("Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],A=n[1],c=n[5],h=n[9],u=n[13],d=n[2],f=n[6],p=n[10],m=n[14],v=n[3],g=n[7],y=n[11],w=n[15],x=i[0],b=i[4],M=i[8],C=i[12],B=i[1],E=i[5],S=i[9],T=i[13],_=i[2],I=i[6],L=i[10],F=i[14],k=i[3],P=i[7],U=i[11],D=i[15];return r[0]=a*x+o*B+s*_+l*k,r[4]=a*b+o*E+s*I+l*P,r[8]=a*M+o*S+s*L+l*U,r[12]=a*C+o*T+s*F+l*D,r[1]=A*x+c*B+h*_+u*k,r[5]=A*b+c*E+h*I+u*P,r[9]=A*M+c*S+h*L+u*U,r[13]=A*C+c*T+h*F+u*D,r[2]=d*x+f*B+p*_+m*k,r[6]=d*b+f*E+p*I+m*P,r[10]=d*M+f*S+p*L+m*U,r[14]=d*C+f*T+p*F+m*D,r[3]=v*x+g*B+y*_+w*k,r[7]=v*b+g*E+y*I+w*P,r[11]=v*M+g*S+y*L+w*U,r[15]=v*C+g*T+y*F+w*D,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(e){for(var t=0,n=e.count;t1){for(var t=0;t1){for(var t=0;t0){i.children=[];for(s=0;s0&&(n.geometries=h),u.length>0&&(n.materials=u),d.length>0&&(n.textures=d),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=i,n;function p(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(this.viewer&&this.viewer.renderManager.render(),void 0===t&&(t=!0),this.name=e.name,this.lastUUID=e.uuid,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,e.ID&&(this.ID=e.ID),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;ns)return!1}return!0}Object.assign(tn.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,l=e.length;sr&&(r=A),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,l=e.count;sr&&(r=A),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("Box3: .getParameter() target is now required"),t=new at),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,Ht),Ht.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Jt),qt.subVectors(this.max,Jt),jt.subVectors(e.a,Jt),Wt.subVectors(e.b,Jt),Xt.subVectors(e.c,Jt),Yt.subVectors(Wt,jt),Kt.subVectors(Xt,Wt),Zt.subVectors(jt,Xt);var t=[0,-Yt.z,Yt.y,0,-Kt.z,Kt.y,0,-Zt.z,Zt.y,Yt.z,0,-Yt.x,Kt.z,0,-Kt.x,Zt.z,0,-Zt.x,-Yt.y,Yt.x,0,-Kt.y,Kt.x,0,-Zt.y,Zt.x,0];return!!nn(t,jt,Wt,Xt,qt)&&(!!nn(t=[1,0,0,0,1,0,0,0,1],jt,Wt,Xt,qt)&&($t.crossVectors(Yt,Kt),nn(t=[$t.x,$t.y,$t.z],jt,Wt,Xt,qt)))},clampPoint:function(e,t){return void 0===t&&(console.warn("Box3: .clampPoint() target is now required"),t=new at),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Ht.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Ht).length(),e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()||(Gt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gt)),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var rn=new tn;function an(e,t){this.center=void 0!==e?e:new at,this.radius=void 0!==t?t:0}Object.assign(an.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var n=this.center;void 0!==t?n.copy(t):rn.setFromPoints(e).getCenter(n);for(var i=0,r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(e=new tn),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var on=new at,sn=new at,ln=new at,An=new at,cn=new at,hn=new at,un=new at;function dn(e,t){this.origin=void 0!==e?e:new at,this.direction=void 0!==t?t:new at(0,0,-1)}Object.assign(dn.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(t=new at),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,on)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("Ray: .closestPointToPoint() target is now required"),t=new at),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=on.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(on.copy(this.direction).multiplyScalar(t).add(this.origin),on.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,i){sn.copy(e).add(t).multiplyScalar(.5),ln.copy(t).sub(e).normalize(),An.copy(this.origin).sub(sn);var r,a,o,s,l=.5*e.distanceTo(t),A=-this.direction.dot(ln),c=An.dot(this.direction),h=-An.dot(ln),u=An.lengthSq(),d=Math.abs(1-A*A);if(d>0)if(a=A*c-h,s=l*d,(r=A*h-c)>=0)if(a>=-s)if(a<=s){var f=1/d;o=(r*=f)*(r+A*(a*=f)+2*c)+a*(A*r+a+2*h)+u}else a=l,o=-(r=Math.max(0,-(A*a+c)))*r+a*(a+2*h)+u;else a=-l,o=-(r=Math.max(0,-(A*a+c)))*r+a*(a+2*h)+u;else a<=-s?o=-(r=Math.max(0,-(-A*l+c)))*r+(a=r>0?-l:Math.min(Math.max(-l,-h),l))*(a+2*h)+u:a<=s?(r=0,o=(a=Math.min(Math.max(-l,-h),l))*(a+2*h)+u):o=-(r=Math.max(0,-(A*l+c)))*r+(a=r>0?l:Math.min(Math.max(-l,-h),l))*(a+2*h)+u;else a=A>0?-l:l,o=-(r=Math.max(0,-(A*a+c)))*r+a*(a+2*h)+u;return n&&n.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(ln).multiplyScalar(a).add(sn),o},intersectSphere:function(e,t){on.subVectors(e.center,this.origin);var n=on.dot(this.direction),i=on.dot(on)-n*n,r=e.radius*e.radius;if(i>r)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,i,r,a,o,s,l=1/this.direction.x,A=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),A>=0?(r=(e.min.y-h.y)*A,a=(e.max.y-h.y)*A):(r=(e.max.y-h.y)*A,a=(e.min.y-h.y)*A),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(e.min.z-h.z)*c,s=(e.max.z-h.z)*c):(o=(e.max.z-h.z)*c,s=(e.min.z-h.z)*c),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,on)},intersectTriangle:function(e,t,n,i,r){cn.subVectors(t,e),hn.subVectors(n,e),un.crossVectors(cn,hn);var a,o=this.direction.dot(un);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}An.subVectors(this.origin,e);var s=a*this.direction.dot(hn.crossVectors(An,hn));if(s<0)return null;var l=a*this.direction.dot(cn.cross(An));if(l<0)return null;if(s+l>o)return null;var A=-a*An.dot(un);return A<0?null:this.at(A/o,r)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var fn=new at,pn=new at,mn=new lt;function vn(e,t){this.normal=void 0!==e?e:new at(1,0,0),this.constant=void 0!==t?t:0}Object.assign(vn.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,n){var i=fn.subVectors(n,t).cross(pn.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("Plane: .projectPoint() target is now required"),t=new at),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("Plane: .intersectLine() target is now required"),t=new at);var n=e.delta(fn),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?void 0:t.copy(n).multiplyScalar(r).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("Plane: .coplanarPoint() target is now required"),e=new at),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var n=t||mn.getNormalMatrix(e),i=this.coplanarPoint(fn).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var gn=new at,yn=new at,wn=new at,xn=new at,bn=new at,Mn=new at,Cn=new at,Bn=new at,En=new at,Sn=new at;function Tn(e,t,n){this.a=void 0!==e?e:new at,this.b=void 0!==t?t:new at,this.c=void 0!==n?n:new at}Object.assign(Tn,{getNormal:function(e,t,n,i){void 0===i&&(i=new at),i.subVectors(n,t),gn.subVectors(e,t),i.cross(gn);var r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)},getBarycoord:function(e,t,n,i,r){gn.subVectors(i,t),yn.subVectors(n,t),wn.subVectors(e,t);var a=gn.dot(gn),o=gn.dot(yn),s=gn.dot(wn),l=yn.dot(yn),A=yn.dot(wn),c=a*l-o*o;if(void 0===r&&(r=new at),0===c)return r.set(-2,-1,-1);var h=1/c,u=(l*s-o*A)*h,d=(a*A-o*s)*h;return r.set(1-u-d,d,u)},containsPoint:function(e,t,n,i){return Tn.getBarycoord(e,t,n,i,xn),xn.x>=0&&xn.y>=0&&xn.x+xn.y<=1},getUV:function(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,xn),s.set(0,0),s.addScaledVector(r,xn.x),s.addScaledVector(a,xn.y),s.addScaledVector(o,xn.z),s},isFrontFacing:function(e,t,n,i){return gn.subVectors(n,t),yn.subVectors(e,t),gn.cross(yn).dot(i)<0}}),Object.assign(Tn.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return gn.subVectors(this.c,this.b),yn.subVectors(this.a,this.b),.5*gn.cross(yn).length()},getMidpoint:function(e){return void 0===e&&(e=new at),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return Tn.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(e=new vn),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return Tn.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,n,i,r){return Tn.getUV(e,this.a,this.b,this.c,t,n,i,r)},containsPoint:function(e){return Tn.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return Tn.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(t=new at);var n,i,r=this.a,a=this.b,o=this.c;bn.subVectors(a,r),Mn.subVectors(o,r),Bn.subVectors(e,r);var s=bn.dot(Bn),l=Mn.dot(Bn);if(s<=0&&l<=0)return t.copy(r);En.subVectors(e,a);var A=bn.dot(En),c=Mn.dot(En);if(A>=0&&c<=A)return t.copy(a);var h=s*c-A*l;if(h<=0&&s>=0&&A<=0)return n=s/(s-A),t.copy(r).addScaledVector(bn,n);Sn.subVectors(e,o);var u=bn.dot(Sn),d=Mn.dot(Sn);if(d>=0&&u<=d)return t.copy(o);var f=u*l-s*d;if(f<=0&&l>=0&&d<=0)return i=l/(l-d),t.copy(r).addScaledVector(Mn,i);var p=A*d-u*c;if(p<=0&&c-A>=0&&u-d>=0)return Cn.subVectors(o,a),i=(c-A)/(c-A+(u-d)),t.copy(a).addScaledVector(Cn,i);var m=1/(p+f+h);return n=f*m,i=h*m,t.copy(r).addScaledVector(bn,n).addScaledVector(Mn,i)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var _n={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},In={h:0,s:0,l:0},Ln={h:0,s:0,l:0};function Fn(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function kn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Pn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Un(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function Dn(e,t,n,i,r,a){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new at,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new Fn,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==a?a:0}Object.assign(Fn.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(e,t,n){if(e=et.euclideanModulo(e,1),t=et.clamp(t,0,1),n=et.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=kn(r,i,e+1/3),this.g=kn(r,i,e),this.b=kn(r,i,e-1/3)}return this},setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("Color: Alpha component of "+e+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,r=n[1],a=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var A=n[1],c=A.length;if(3===c)return this.r=parseInt(A.charAt(0)+A.charAt(0),16)/255,this.g=parseInt(A.charAt(1)+A.charAt(1),16)/255,this.b=parseInt(A.charAt(2)+A.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(A.charAt(0)+A.charAt(1),16)/255,this.g=parseInt(A.charAt(2)+A.charAt(3),16)/255,this.b=parseInt(A.charAt(4)+A.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=_n[e];return void 0!==t?this.setHex(t):console.warn("Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=Pn(e.r),this.g=Pn(e.g),this.b=Pn(e.b),this},copyLinearToSRGB:function(e){return this.r=Un(e.r),this.g=Un(e.g),this.b=Un(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,n,i=this.r,r=this.g,a=this.b,o=Math.max(i,r,a),s=Math.min(i,r,a),l=(s+o)/2;if(s===o)t=0,n=0;else{var A=o-s;switch(n=l<=.5?A/(o+s):A/(2-o-s),o){case i:t=(r-a)/A+(rt&&(t=e[n]);return t}On.prototype=Object.assign(Object.create(Je.prototype),{constructor:On,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n)if("shading"!==t){var i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(this.type+": '"+t+"' is not a property of this material.")}else console.warn(this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;else console.warn("Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),0!==this.side&&(n.side=this.side),0!==this.vertexColors&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){var r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,n=null;if(null!==t){var i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(On.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Nn.prototype=Object.create(On.prototype),Nn.prototype.constructor=Nn,Nn.prototype.isMeshBasicMaterial=!0,Nn.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},Object.defineProperty(zn.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(zn.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(var i=0,r=this.itemSize;i0,o=r[1]&&r[1].length>0,s=e.morphTargets,l=s.length;if(l>0){t=[];for(var A=0;A0){c=[];for(A=0;A0&&0===n.length&&console.error("DirectGeometry: Faceless geometries are not supported.");for(A=0;A65535?Xn:jn)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var n=this.attributes.normal;void 0!==n&&((new lt).getNormalMatrix(e).applyToBufferAttribute(n),n.needsUpdate=!0);var i=this.attributes.tangent;void 0!==i&&((new lt).getNormalMatrix(e).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},applyMatrix4:function(e){return this.applyMatrix(e),this},rotateX:function(e){return ei.makeRotationX(e),this.applyMatrix(ei),this},rotateY:function(e){return ei.makeRotationY(e),this.applyMatrix(ei),this},rotateZ:function(e){return ei.makeRotationZ(e),this.applyMatrix(ei),this},translate:function(e,t,n){return ei.makeTranslation(e,t,n),this.applyMatrix(ei),this},scale:function(e,t,n){return ei.makeScale(e,t,n),this.applyMatrix(ei),this},lookAt:function(e){return ti.lookAt(e),ti.updateMatrix(),this.applyMatrix(ti.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(ni).negate(),this.translate(ni.x,ni.y,ni.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var n=new Yn(3*t.vertices.length,3),i=new Yn(3*t.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(t.vertices)),this.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var r=new Yn(t.lineDistances.length,1);this.setAttribute("lineDistance",r.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],n=0,i=e.length;n0){var n=new Float32Array(3*e.normals.length);this.setAttribute("normal",new zn(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.setAttribute("color",new zn(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var r=new Float32Array(2*e.uvs.length);this.setAttribute("uv",new zn(r,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.setAttribute("uv2",new zn(a,2).copyVector2sArray(e.uvs2))}for(var o in this.groups=e.groups,e.morphTargets){for(var s=[],l=e.morphTargets[o],A=0,c=l.length;A0){var d=new Yn(4*e.skinIndices.length,4);this.setAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new Yn(4*e.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new tn);var e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var n=0,i=t.length;n.01&&oi.y>.01&&oi.z<.01?this.boundingBox.max.z+=.01:oi.x>.01&&oi.y<.01&&oi.z>.01?this.boundingBox.max.y+=.01:oi.x<.01&&oi.y>.01&&oi.z>.01&&(this.boundingBox.max.x+=.01),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new an);var e=this.attributes.position,t=this.morphAttributes.position;if(e){var n=this.boundingSphere.center;if(ii.setFromBufferAttribute(e),t)for(var i=0,r=t.length;i0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var i=this.index;null!==i&&(e.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)});var r=this.attributes;for(var n in r){var a=(u=r[n]).toJSON();""!==u.name&&(a.name=u.name),e.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var l=this.morphAttributes[n],A=[],c=0,h=l.length;c0&&(o[n]=A,s=!0)}s&&(e.data.morphAttributes=o,e.data.morphTargetsRelative=this.morphTargetsRelative);var d=this.groups;d.length>0&&(e.data.groups=JSON.parse(JSON.stringify(d)));var f=this.boundingSphere;return null!==f&&(e.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),e},clone:function(){return(new si).copy(this)},copy:function(e){var t,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.clone());var a=e.attributes;for(t in a){var o=a[t];this.setAttribute(t,o.clone())}var s=e.morphAttributes;for(t in s){var l=[],A=s[t];for(n=0,i=A.length;n=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});var Ai=new bt,ci=new dn,hi=new an,ui=new at,di=new at,fi=new at,pi=new at,mi=new at,vi=new at,gi=new at,yi=new at,wi=new at,xi=new tt,bi=new tt,Mi=new tt,Ci=new at,Bi=new at;function Ei(e,t){zt.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new si,this.material=void 0!==t?t:new Nn({color:16777215*Math.random()}),this.drawMode=0,this.updateMorphTargets()}Ei.prototype=Object.assign(Object.create(zt.prototype),{constructor:Ei,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return zt.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,n,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,a=Object.keys(r);if(a.length>0){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0&&console.error("Mesh.updateMorphTargets() no longer supports Geometry. Use BufferGeometry instead.")}},raycast:function(e,t){var n,i=this.geometry,r=this.material,a=this.matrixWorld;if(void 0!==r&&(null===i.boundingSphere&&i.computeBoundingSphere(),hi.copy(i.boundingSphere),hi.applyMatrix4(a),!1!==e.ray.intersectsSphere(hi)&&(Ai.getInverse(a),ci.copy(e.ray).applyMatrix4(Ai),null===i.boundingBox||!1!==ci.intersectsBox(i.boundingBox))))if(0===this.drawMode){if(i.isBufferGeometry){var o,s,l,A,c,h,u,d,f,p=i.index,m=i.attributes.position,v=i.morphAttributes.position,g=i.morphTargetsRelative,y=i.attributes.uv,w=i.attributes.uv2,x=i.groups,b=i.drawRange;if(null!==p)if(Array.isArray(r))for(A=0,h=x.length;A0&&(E=I);for(var L=0,F=_.length;Ln.far?null:{distance:l,point:Bi.clone(),object:e}},checkBufferGeometryIntersection:function(e,t,n,i,r,a,o,s,l,A,c,h){this.getVertexByIndex(ui,r,A),this.getVertexByIndex(di,r,c),this.getVertexByIndex(fi,r,h);var u=e.morphTargetInfluences;if(t.morphTargets&&a&&u){gi.set(0,0,0),yi.set(0,0,0),wi.set(0,0,0);for(var d=0,f=a.length;d0)for(A=0;A0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,i,r;for(n=0,i=this.faces.length;n=0;n--){var f=u[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,m=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,g=d.vertexColors.length>0,y=0;if(y=M(y,0,0),y=M(y,1,!0),y=M(y,2,!1),y=M(y,3,f),y=M(y,4,p),y=M(y,5,m),y=M(y,6,v),y=M(y,7,g),o.push(y),o.push(d.a,d.b,d.c),o.push(d.materialIndex),f){var w=this.faceVertexUvs[0][r];o.push(E(w[0]),E(w[1]),E(w[2]))}if(p&&o.push(C(d.normal)),m){var x=d.vertexNormals;o.push(C(x[0]),C(x[1]),C(x[2]))}if(v&&o.push(B(d.color)),g){var b=d.vertexColors;o.push(B(b[0]),B(b[1]),B(b[2]))}}function M(e,t,n){return n?e|1<0&&(e.data.colors=A),h.length>0&&(e.data.uvs=[h]),e.data.faces=o,e},clone:function(){return(new Li).copy(this)},copy:function(e){var t,n,i,r,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,n=s.length;t0?1:-1,d.push(_.x,_.y,_.z),f.push(g/l),f.push(1-y/A),S+=1}}for(y=0;y0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var r={};for(var a in this.extensions)!0===this.extensions[a]&&(r[a]=!0);return Object.keys(r).length>0&&(t.extensions=r),t},Oi.prototype=Object.assign(Object.create(zt.prototype),{constructor:Oi,isCamera:!0,copy:function(e,t){return zt.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("Camera: .getWorldDirection() target is now required"),e=new at),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){zt.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverseR.getInverse(this.matrixWorld.clone().multiply(this.rotateMatrix)),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Ni.prototype=Object.assign(Object.create(Oi.prototype),{constructor:Ni,isPerspectiveCamera:!0,copy:function(e,t){return Oi.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*et.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*et.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*et.RAD2DEG*Math.atan(Math.tan(.5*et.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*et.DEG2RAD*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/o,t-=a.offsetY*n/s,i*=a.width/o,n*=a.height/s}var l=this.filmOffset;0!==l&&(r+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=zt.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var zi=90;function Qi(e,t,n,i){zt.call(this),this.type="CubeCamera";var r=new Ni(zi,1,e,t);r.up.set(0,-1,0),r.lookAt(new at(1,0,0)),this.add(r);var a=new Ni(zi,1,e,t);a.up.set(0,-1,0),a.lookAt(new at(-1,0,0)),this.add(a);var o=new Ni(zi,1,e,t);o.up.set(0,0,1),o.lookAt(new at(0,1,0)),this.add(o);var s=new Ni(zi,1,e,t);s.up.set(0,0,-1),s.lookAt(new at(0,-1,0)),this.add(s);var l=new Ni(zi,1,e,t);l.up.set(0,-1,0),l.lookAt(new at(0,0,1)),this.add(l);var A=new Ni(zi,1,e,t);A.up.set(0,-1,0),A.lookAt(new at(0,0,-1)),this.add(A),i=i||{format:Ae,magFilter:Z,minFilter:Z},this.renderTarget=new Gi(n,n,i),this.renderTarget.texture.name="CubeCamera",this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var n=e.getRenderTarget(),i=this.renderTarget,c=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,a),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=c,e.setRenderTarget(i,5),e.render(t,A),e.setRenderTarget(n)},this.clear=function(e,t,n,i){for(var r=e.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)e.setRenderTarget(a,o),e.clear(t,n,i);e.setRenderTarget(r)}}function Gi(e,t,n){dt.call(this,e,t,n)}function Hi(e,t,n,i,r,a,o,s,l,A,c,h){ht.call(this,null,a,o,s,l,A,i,r,c,h),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==l?l:X,this.minFilter=void 0!==A?A:X,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Qi.prototype=Object.create(zt.prototype),Qi.prototype.constructor=Qi,Gi.prototype=Object.create(dt.prototype),Gi.prototype.constructor=Gi,Gi.prototype.isWebGLRenderTargetCube=!0,Gi.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var n=new Qt,i={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},r=new Ri({type:"CubemapFromEquirect",uniforms:Pi(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;var a=new Ei(new ki(5,5,5),r);n.add(a);var o=new Qi(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(e,n),a.geometry.dispose(),a.material.dispose(),this},Hi.prototype=Object.create(ht.prototype),Hi.prototype.constructor=Hi,Hi.prototype.isDataTexture=!0;var Vi=new an,ji=new at;function Wi(e,t,n,i,r,a){this.planes=[void 0!==e?e:new vn,void 0!==t?t:new vn,void 0!==n?n:new vn,void 0!==i?i:new vn,void 0!==r?r:new vn,void 0!==a?a:new vn]}Object.assign(Wi.prototype,{set:function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6],c=n[7],h=n[8],u=n[9],d=n[10],f=n[11],p=n[12],m=n[13],v=n[14],g=n[15];return t[0].setComponents(o-i,c-s,f-h,g-p).normalize(),t[1].setComponents(o+i,c+s,f+h,g+p).normalize(),t[2].setComponents(o+r,c+l,f+u,g+m).normalize(),t[3].setComponents(o-r,c-l,f-u,g-m).normalize(),t[4].setComponents(o-a,c-A,f-d,g-v).normalize(),t[5].setComponents(o+a,c+A,f+d,g+v).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Vi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Vi)},intersectsSprite:function(e){return Vi.center.set(0,0,0),Vi.radius=.7071067811865476,Vi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vi)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,ji.y=i.normal.y>0?e.max.y:e.min.y,ji.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ji)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0},toArray:function(){for(var e=[],t=0;t<6;t++){var n=this.planes[t].normal.toArray();e.push.apply(e,n),n=null,e.push(this.planes[t].constant)}return e},setFromProjectionMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6],c=n[7],h=n[8],u=n[9],d=n[10],f=n[11],p=n[12],m=n[13],v=n[14],g=n[15];return t[0].setComponents(o-i,c-s,f-h,g-p).normalize(),t[1].setComponents(o+i,c+s,f+h,g+p).normalize(),t[2].setComponents(o+r,c+l,f+u,g+m).normalize(),t[3].setComponents(o-r,c-l,f-u,g-m).normalize(),t[4].setComponents(o-a,c-A,f-d,g-v).normalize(),t[5].setComponents(o+a,c+A,f+d,g+v).normalize(),this}});var Xi={alphamap_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",alphamap_pars_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",alphatest_fragment:"\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n",aomap_fragment:"\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n",aomap_pars_fragment:"\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n",bsdfs:'\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick \'94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n',bumpmap_pars_fragment:"\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n",clipping_planes_fragment:"\nfloat clipping_opacity = 1.0;\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w && clippingTransparent ) clipping_opacity= 0.3;\n if ( dot( vViewPosition, plane.xyz ) > plane.w && !clippingTransparent ) discard;\n\t\t\n\t}\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t\n\n\t\t}\n\n\t\tif ( clipped ){\n\t\t if(clippingTransparent)\n\t\t clipping_opacity= 0.3;\n\t\t else\n\t\t discard;\n\t\t}\n\n\t#endif\n\n#endif\n",clipping_planes_pars_fragment:"\n#if NUM_CLIPPING_PLANES > 0\n\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n",clipping_planes_pars_vertex:"\n#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"\n#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n",color_pars_fragment:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_pars_vertex:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_vertex:"\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n",common:"\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\n// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\n \nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n",cube_uv_reflection_fragment:"\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_textureSize (1024.0)\n\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\n\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\t// Clamp the value to the max mip level counts. hard coded to 6 mips\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\n\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\t// float powScale = exp2(roughnessLevel + mipLevel);\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\t// float scale = 1.0 / exp2(roughnessLevel + 2.0 + mipLevel);\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\t// float mipOffset = 0.75*(1.0 - 1.0/exp2(mipLevel))/exp2(roughnessLevel);\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\n\tfloat rcpPowScale = 1.0 / powScale;\n\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\n\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\n\t// round to nearest mipmap if we are not interpolating.\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\n\t// Tri linear interpolation.\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\n\tvec4 result = mix(color10, color20, t);\n\n\treturn vec4(result.rgb, 1.0);\n}\n\nvec4 textureCubeUVSample( sampler2D envMap, vec3 reflectedDirection) {\n\n\tvec2 uv_10 = getCubeUV(reflectedDirection, 0.0, 0.0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\n\treturn color10;\n}\n\n#endif\n",defaultnormal_vertex:"\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n",displacementmap_pars_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n",displacementmap_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n",emissivemap_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n",emissivemap_pars_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n",encodings_fragment:"\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n",envmap_fragment:"\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\tvec2 sampleUV;\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\tenvColor = envMapTexelToLinear( envColor );\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n",envmap_common_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n",envmap_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n",envmap_pars_vertex:"\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n",envmap_physical_pars_fragment:"\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n \n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n",envmap_vertex:"\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n",fog_pars_vertex:"\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n",fog_fragment:"\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n",fog_pars_fragment:"\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n",gradientmap_pars_fragment:"\n#ifdef TOON\n\n\tuniform sampler2D gradientMap;\n\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t\t// dotNL will be from -1.0 to 1.0\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t\t#ifdef USE_GRADIENTMAP\n\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t\t#else\n\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t\t#endif\n\n\n\t}\n\n#endif\n",lightmap_fragment:"\n#ifdef USE_LIGHTMAP\n\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n",lightmap_pars_fragment:"\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n",lights_lambert_vertex:"\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\n#endif\n",lights_pars_begin:"\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n",lights_phong_fragment:"\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t#ifdef TOON\n\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#else\n\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\n\t#endif\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = saturate( clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n\n#endif\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n",lights_physical_pars_fragment:"\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n",lights_fragment_begin:"\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_fragment_maps:"\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n",lights_fragment_end:"\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n \n#endif\n",logdepthbuf_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n",logdepthbuf_pars_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n",logdepthbuf_pars_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n",logdepthbuf_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n",map_fragment:"\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n",map_pars_fragment:"\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n",map_particle_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n",map_particle_pars_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",metalnessmap_fragment:"\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n",metalnessmap_pars_fragment:"\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n",morphnormal_vertex:"\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n",morphtarget_pars_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n",morphtarget_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n",normal_fragment_begin:"\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n",normal_fragment_maps:"\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n",normalmap_pars_fragment:"\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n",clearcoat_normal_fragment_begin:"\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n",clearcoat_normal_fragment_maps:"\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n",clearcoat_normalmap_pars_fragment:"\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n",packing:"\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpack2HalfToRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\n\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\n\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n",project_vertex:"\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n",dithering_pars_fragment:"\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n",roughnessmap_fragment:"\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n",roughnessmap_pars_fragment:"\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n",shadowmap_pars_fragment:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpack2HalfToRGBA( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\n\t\tvec2 f = fract( uv * size + 0.5 );\n\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\n\t\treturn c;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n",shadowmap_pars_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n",shadowmap_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\n\t}\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n",shadowmask_pars_fragment:"\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLight directionalLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLight spotLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLight pointLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n",skinbase_vertex:"\n#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif\n",skinning_pars_vertex:"\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",skinning_vertex:"\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n",skinnormal_vertex:"\n#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n",specularmap_fragment:"\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n",specularmap_pars_fragment:"\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n",tonemapping_fragment:"\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n",tonemapping_pars_fragment:"\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\n\t// John Hable's filmic operator from Uncharted 2 video game\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n\n}\n\n// source: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n\n}\n",uv_pars_fragment:"\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n",uv_pars_vertex:"\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n",uv_vertex:"\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n",uv2_pars_fragment:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n",uv2_pars_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n#endif\n",uv2_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = uv2;\n\n#endif\n",worldpos_vertex:"\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n",amrt_aomap_fragment:"\n#if defined(USE_AOMAP)\n float ambientOcclusion = mix(1.0, aoMapTexelToLinear(texture2D( aoMap, vUvAO )).g, aoScale);\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n#endif\n",amrt_emissivemap_fragment:"\n#if defined(USE_EMISSIVEMAP)\n vec4 emissiveColor = texture2D( emissiveMap, vUvEmissive );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",amrt_map_fragment:"\n#if defined( USE_ALBEDO )\n vec4 texelColor = texture2D( albedo, vUvAlbedo );\n texelColor = albedoTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif\n",amrt_map_pars_fragment:"\n\n// struct MapData\n// {\n// vec3 Normal;\n// vec3 Albedo;\n// float Emission;\n// float Metallic;\n// float Smoothness;\n// float Occlusion;\n// float Alpha;\n// };\n\n#ifdef USE_ALBEDO\n\n\tuniform sampler2D albedo;\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform float normalScale;\n\n#endif\n\n#ifdef USE_NORMALMAP2\n\n\tuniform sampler2D normalMap2;\n\tuniform float normalScale2;\n\n#endif\n\n#ifdef USE_METALLICMAP\n\n\tuniform sampler2D metallicMap;\n\n#endif\n\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoScale;\n\n#endif\n\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n\n#ifdef USE_REFLECTMAP\n #ifdef USE_REFLECTMAP_UV\n uniform sampler2D reflectMap;\n #else\n uniform samplerCube reflectMap;\n #endif\n\tuniform float reflectIntensity;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n\n#ifdef USE_DISSOLVE\n uniform vec3 dissolveColor;\n uniform float dissolveRatio;\n\tuniform sampler2D dissolveMap;\n#endif\n\n",amrt_metalnessmap_fragment:"\nfloat metalnessFactor = metalness;\n#if defined(USE_METALLICMAP)\n metalnessFactor = metallicMapTexelToLinear(texture2D( metallicMap, vUvMetal )).r;\n#endif\n",amrt_alphamap_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tgl_FragColor.a = texture2D( alphaMap, vUvAlpha ).g;\n\n#endif\n",amrt_normal_fragment_maps:"\n\n#if defined( USE_NORMALMAP ) || defined( USE_NORMALMAP2 )\n\n #if defined( USE_NORMALMAP ) && defined( USE_NORMALMAP2 )\n vec3 mapN = BlendNormals( UnpackScaleNormal( normalMapTexelToLinear(texture2D( normalMap, vUvNormal )), normalScale ) , UnpackScaleNormal( normalMap2TexelToLinear(texture2D( normalMap2, vUvNormal2 )), normalScale2 ) );\n #elif defined( USE_NORMALMAP )\n vec3 mapN = normalize(UnpackScaleNormal( normalMapTexelToLinear(texture2D( normalMap, vUvNormal )), normalScale));\n #elif defined( USE_NORMALMAP2 )\n vec3 mapN = normalize(UnpackScaleNormal( normalMap2TexelToLinear(texture2D( normalMap2, vUvNormal2 )), normalScale2));\n #endif\n \n #ifdef USE_TANGENT\n \n normal = normalize( vTBN * mapN );\n \n #else\n \n normal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n \n #endif\n \n#endif\n",amrt_roughnessmap_fragment:"\n#if defined(USE_ROUGHNESSMAP)\n roughnessFactor = roughnessMapTexelToLinear(texture2D( roughnessMap, vUvRough )).r;\n#endif\n",amrt_uv_pars_fragment:"\n\n#ifdef USE_ALBEDO\n\n\tvarying vec2 vUvAlbedo;\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n\tvarying vec2 vUvNormal;\n\n#endif\n\n#ifdef USE_NORMALMAP2\n\n\tvarying vec2 vUvNormal2;\n\n#endif\n\n#ifdef USE_METALLICMAP\n\n\tvarying vec2 vUvMetal;\n\n#endif\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvarying vec2 vUvRough;\n\n#endif\n\n#ifdef USE_AOMAP\n\n\tvarying vec2 vUvAO;\n\n#endif\n\n#ifdef USE_EMISSIVEMAP\n\n\tvarying vec2 vUvEmissive;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tvarying vec2 vUvAlpha;\n\n#endif\n\n#ifdef USE_DISSOLVE\n\n varying vec2 vUv;\n \n#endif\n",amrt_uv_pars_vertex:"\n\nattribute vec2 uv2;\n\n#ifdef USE_ALBEDO\n\n\tvarying vec2 vUvAlbedo;\n\tuniform mat3 albedoUVTransform;\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n\tvarying vec2 vUvNormal;\n\tuniform mat3 normalUVTransform;\n\n#endif\n\n#ifdef USE_NORMALMAP2\n\n\tvarying vec2 vUvNormal2;\n\tuniform mat3 normal2UVTransform;\n\n#endif\n\n#ifdef USE_METALLICMAP\n\n\tvarying vec2 vUvMetal;\n\tuniform mat3 metalUVTransform;\n\n#endif\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvarying vec2 vUvRough;\n\tuniform mat3 roughUVTransform;\n\n#endif\n\n#ifdef USE_AOMAP\n\n\tvarying vec2 vUvAO;\n\tuniform mat3 aoUVTransform;\n\n#endif\n\n#ifdef USE_EMISSIVEMAP\n\n\tvarying vec2 vUvEmissive;\n\tuniform mat3 emissiveUVTransform;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tvarying vec2 vUvAlpha;\n uniform mat3 alphaUVTransform;\n\n#endif\n\n#ifdef USE_DISSOLVE\n\n\tvarying vec2 vUv;\n\n#endif\n\n",amrt_uv_vertex:"\n\n#ifdef USE_ALBEDO\n\t\n\t#ifdef ALBEDO_UV1\n\n\t\tvUvAlbedo = ( albedoUVTransform * vec3( uv, 1 ) ).xy;\n\n\t#else\n\n\t\tvUvAlbedo = ( albedoUVTransform * vec3( uv2, 1 ) ).xy;\n\n\t#endif\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n vUvNormal = ( normalUVTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_NORMALMAP2\n\n vUvNormal2 = ( normal2UVTransform * vec3( uv2, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_METALLICMAP\n\n vUvMetal = ( metalUVTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_ROUGHNESSMAP\n \n vUvRough = ( roughUVTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n \n vUvAlpha = ( alphaUVTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_AOMAP\n\t\n\t#ifdef AO_UV1\n\n\t\tvUvAO = ( aoUVTransform * vec3( uv, 1 ) ).xy;\n\n\t#else\n\n\t\tvUvAO = ( aoUVTransform * vec3( uv2, 1 ) ).xy;\n\n\t#endif\n\n#endif\n\n#ifdef USE_EMISSIVEMAP\n\t\n\t#ifdef EMISSIVE_UV1\n\n\t\tvUvEmissive = ( emissiveUVTransform * vec3( uv, 1 ) ).xy;\n\n\t#else\n\n\t\tvUvEmissive = ( emissiveUVTransform * vec3( uv2, 1 ) ).xy;\n\n\t#endif\n\n#endif\n\n#ifdef USE_DISSOLVE\n\n vUv = uv;\n \n#endif\n",amrt_worldpos_vertex:"\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_REFLECTMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n#endif\n",amrt_envmap_physical_pars_fragment:"\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n \n\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n \n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n\n float sigma = PI * roughness * roughness / ( 1.0 + roughness ) + 0.000001;\n float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n // clamp to allowable LOD ranges.\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n \n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in float rroughness,const in int maxMIPLevel ) {\n \n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n #ifdef ENVMAP_TYPE_CUBE_UV\n\t\t reflectVec = inverseTransformDirection( reflectVec, viewMatrixR );\n #else\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n #endif\n \n reflectVec *= envYMatrix;\n \n float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\t\n vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\t\t\n\t\t\n\t\tenvMapColor = LinearTosRGB(envMapColor);\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n",amrt_cube_uv_reflection_fragment:"\n#if defined(ENVMAP_TYPE_CUBE_UV) || defined(USE_REFLECTMAP_UV)\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\nvec3 bilinearCubeUVR(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = reflectMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = reflectMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = reflectMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = reflectMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n\nvec4 textureCubeUVR(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUVR(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUVR(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n",amrt_lights_fragment_maps:"\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness,roughnessFactor, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_REFLECTMAP )\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n \n #ifdef USE_REFLECTMAP_UV\n reflectVec = inverseTransformDirection( reflectVec, viewMatrixR ); \n vec4 reflectdiffuse = textureCubeUVR( reflectMap, reflectVec, 0.0 );\n reflectdiffuse = LinearTosRGB(reflectdiffuse);\n radiance += reflectdiffuse.rgb * reflectIntensity;\n #else\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n reflectVec = vec3( -1.0 * reflectVec.x, reflectVec.yz );\n vec4 reflectdiffuse = textureCube( reflectMap, reflectVec );\n reflectdiffuse.rgb = reflectMapTexelToLinear(reflectdiffuse).rgb;\n reflectdiffuse = LinearTosRGB(reflectdiffuse);\n radiance += reflectdiffuse.rgb * reflectIntensity;\n #endif\n#endif\n",amrt_bsdfs:'\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick \'94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n',amrt_lights_physical_fragment:"\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\n#if defined( USE_REFLECTMAP )\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n \n #ifdef USE_REFLECTMAP_UV\n reflectVec = inverseTransformDirection( reflectVec, viewMatrixR );\n reflectVec*=reflecYMatrix;\n vec4 reflectdiffuse = textureCubeUVR( reflectMap, reflectVec, 0.0 );\n reflectdiffuse = LinearTosRGB(reflectdiffuse);\n diffuseColor.rgb += reflectdiffuse.rgb * reflectIntensity;\n #else\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n reflectVec = vec3( -1.0 * reflectVec.x, reflectVec.yz );\n reflectVec*=reflecYMatrix;\n vec4 reflectdiffuse = textureCube( reflectMap, reflectVec );\n reflectdiffuse.rgb = reflectMapTexelToLinear(reflectdiffuse).rgb;\n reflectdiffuse = LinearTosRGB(reflectdiffuse);\n diffuseColor.rgb += reflectdiffuse.rgb * reflectIntensity;\n #endif\n#endif\n\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ) * 0.779083699;\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = saturate( clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n\n#endif\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n #ifdef TRANSPARENCY\n directLight.color *= (1.0 - transparency);\n #endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n #ifdef TRANSPARENCY\n directLight.color *= (1.0 - transparency);\n #endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n #ifdef TRANSPARENCY\n directLight.color *= (1.0 - transparency);\n #endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#ifdef TRANSPARENCY\n irradiance *= (1.0 - transparency);\n #endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness,roughnessFactor, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n",amrt_dissolve_fragment:"\n#if defined( USE_DISSOLVE )\n vec4 dissove = texture2D( dissolveMap, vUv );\n if(dissove.r < dissolveRatio) discard;\n if(abs(dissove.r - dissolveRatio) < 0.05){\n gl_FragColor.rgb = dissolveColor;\n }\n#endif\n",background_frag:"\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n",background_vert:"\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n",cube_frag:"\nuniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nuniform float brightness;\nvarying vec3 vWorldDirection;\n\nvoid main() {\n\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n gl_FragColor *= brightness;\n\tgl_FragColor.a *= opacity;\n\n\t#include \n\t#include \n\n}\n",cube_vert:"\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n",depth_frag:"\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\n\t#endif\n\n}\n",depth_vert:"\n#include \n#include \n#include \n#include \n//#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t//#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t//#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t//#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",distanceRGBA_frag:"\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main () {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include \n\t#include \n\t#include \n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n",distanceRGBA_vert:"\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n",equirect_frag:"\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV;\n\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n",equirect_vert:"\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n}\n",linedashed_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",linedashed_vert:"\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvLineDistance = scale * lineDistance;\n\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n",meshbasic_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include \n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshbasic_vert:"\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifdef USE_ENVMAP\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshlambert_frag:"\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include \n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshmatcap_frag:"\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshmatcap_vert:"\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n",meshphong_frag:"\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshphong_vert:"\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshphysical_frag:"\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",meshphysical_vert:"\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n",normal_frag:"\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n",normal_vert:"\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n//#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t//#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t//#include \n\t//#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t//#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n",points_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",points_vert:"\nuniform float size;\nuniform float scale;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",shadow_frag:"\nuniform vec3 color;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include \n\n}\n",shadow_vert:"\n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n",sprite_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\n}\n",sprite_vert:"\nuniform float rotation;\nuniform vec2 center;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n",amrtbasic_vert:"\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n",amrtbasic_frag:"\n\nprecision mediump sampler2D;\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n#define REFLECTIVITY\n//#define TRANSPARENCY\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float smoothness;\nuniform float metalness;\nuniform float opacity;\nuniform mat3 envYMatrix;\nuniform mat3 reflecYMatrix;\nuniform bool clippingTransparent;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\nvec3 BlendNormals(vec3 n1, vec3 n2)\n{\n return normalize(vec3(n1.xy + n2.xy, n1.z*n2.z));\n}\n\nvec3 UnpackScaleNormal(vec4 packednormal, float bumpScale)\n{\n vec3 normal = packednormal.xyz * 2.0 - 1.0;\n normal.xy *= bumpScale;\n return normal;\n}\nfloat Pow5( const in float x ) { float x2 = x*x; return x2*x2*x; }\n#include \n#include \n#include \n#include \n\n\nvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n \n vec2 vUvs;\n #if defined( USE_NORMALMAP2 )\n vUvs = vUvNormal2;\n #elif defined( USE_NORMALMAP )\n vUvs = vUvNormal;\n #endif\n \n vec2 st0 = dFdx( vUvs.st );\n vec2 st1 = dFdy( vUvs.st );\n\n float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n vec3 N = normalize( surf_norm );\n\n mat3 tsn = mat3( S, T, N );\n\n mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n return normalize( tsn * mapN );\n\n}\n\n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\nvoid main() {\n\n float roughnessFactor = 1.0 - smoothness;\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t\n\t#include \n\n \n\n\t// accumulation\n\t#include \n\t// #include \n\t// #include \n\t#include \n\n\t// modulation\n\t#include \n\t\n\t//ssr\n\t#include \n\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n \n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1.0 - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular));\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n #include \n #include \n \n if(clippingTransparent)gl_FragColor.a *= clipping_opacity;\n}\n",amrtshadow_vert:"\n#include \n#include \n#include \n#include \n\nuniform vec4 shadowPlane;\nuniform vec3 lightDirection;\nuniform vec3 center;\n\nvarying vec4 worldPosition;\nvarying vec3 projectionPosition;\nvarying vec3 projectionCenter;\n\nvoid main() {\n vec3 objectNormal = vec3( normal );\n vec3 transformed = vec3( position );\n\n #include \n\t#include \n #include \n\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n\n worldPosition = modelMatrix * mvPosition;\n\n #ifdef USE_SKINNING\n projectionCenter = (shadowSkinMatrix * vec4(center, 1.0)).xyz;\n #else\n projectionCenter = center;\n #endif\n\n projectionCenter = projectOnPlane(projectionCenter, shadowPlane.xyz * shadowPlane.w, shadowPlane.xyz);\n\n projectionPosition = linePlaneIntersect(worldPosition.xyz, -lightDirection, shadowPlane.xyz * shadowPlane.w, shadowPlane.xyz);\n gl_Position = projectionMatrix * viewMatrix * vec4(projectionPosition, 1.0);\n \n\t#include \n}\n",amrtshadow_frag:"\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n\nuniform vec3 color;\nuniform vec4 shadowPlane;\nuniform float shadowLength;\nuniform float shadowStrength;\nuniform vec3 lightDirection;\n\nvarying vec4 worldPosition;\nvarying vec3 projectionPosition;\nvarying vec3 projectionCenter;\n\nvoid main() {\n\n if(sideOfPlane(cameraPosition, shadowPlane.xyz * shadowPlane.w, shadowPlane.xyz) > 0.0) discard;\n if(dot(lightDirection, shadowPlane.xyz) < 0.0) discard;\n\n #include \n\n float dis = distance(projectionPosition, projectionCenter) / shadowLength;\n dis = smoothstep(0.05, 0.9, dis);\n\n gl_FragColor = vec4(color, pow(max(1.0 - dis, 0.0), 2.0) * shadowStrength);\n\n\t#include \n}\n",acf_vert:"\n#ifdef USE_UV\n varying vec2 vUv;\n#endif\n\nvoid main() {\n\n\t#ifdef USE_UV\n\n vUv = uv;\n \n #endif\n\n\tvec4 mvPosition = vec4( position, 1.0 );\n \n mvPosition = modelViewMatrix * mvPosition;\n \n gl_Position = projectionMatrix * mvPosition;\n}\n",acf_frag:"\nuniform vec3 diffuse;\n\n#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n\nvoid main() {\n\n\tvec4 diffuseColor = vec4( diffuse, 1.0 );\n\n\t#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n diffuseColor *= texelColor;\n #endif\n \n\tgl_FragColor = diffuseColor;\n}\n",amrt_skinbase_vertex:"\n#ifdef USE_SKINNING\n\n mat4 boneMatX = getBoneMatrix( skinIndex_4.x );\n mat4 boneMatY = getBoneMatrix( skinIndex_4.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex_4.z );\n mat4 boneMatW = getBoneMatrix( skinIndex_4.w );\n \n \n #ifdef BONE_8\n mat4 boneMatX_8 = getBoneMatrix( skinIndex_8.x );\n mat4 boneMatY_8 = getBoneMatrix( skinIndex_8.y );\n mat4 boneMatZ_8 = getBoneMatrix( skinIndex_8.z );\n mat4 boneMatW_8 = getBoneMatrix( skinIndex_8.w );\n #endif\n \n #ifdef BONE_12\n mat4 boneMatX_12 = getBoneMatrix( skinIndex_12.x );\n mat4 boneMatY_12 = getBoneMatrix( skinIndex_12.y );\n mat4 boneMatZ_12 = getBoneMatrix( skinIndex_12.z );\n mat4 boneMatW_12 = getBoneMatrix( skinIndex_12.w );\n #endif\n \n #ifdef BONE_16\n mat4 boneMatX_16 = getBoneMatrix( skinIndex_16.x );\n mat4 boneMatY_16 = getBoneMatrix( skinIndex_16.y );\n mat4 boneMatZ_16 = getBoneMatrix( skinIndex_16.z );\n mat4 boneMatW_16 = getBoneMatrix( skinIndex_16.w );\n #endif\n\n#endif\n",amrt_skinning_pars_vertex:"\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t\n attribute vec4 skinIndex_4;\n\tattribute vec4 skinWeight_4;\n\t\n\t#ifdef BONE_8\n attribute vec4 skinIndex_8;\n attribute vec4 skinWeight_8;\n \n\t#endif\n\t\n\t#ifdef BONE_12\n attribute vec4 skinIndex_12;\n attribute vec4 skinWeight_12;\n\t#endif\n\t\n\t#ifdef BONE_16\n attribute vec4 skinIndex_16;\n attribute vec4 skinWeight_16;\n\t#endif\n\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\t\t\n\t\tvec4 getSkinVertex(vec4 skinVertex, vec4 skinIndexTmp,vec4 skinWeightTmp){\n\t\t\n\t\t mat4 boneMatX = getBoneMatrix( skinIndexTmp.x );\n mat4 boneMatY = getBoneMatrix( skinIndexTmp.y );\n mat4 boneMatZ = getBoneMatrix( skinIndexTmp.z );\n mat4 boneMatW = getBoneMatrix( skinIndexTmp.w );\n \n vec4 skinned = vec4( 0.0 );\n\n skinned += boneMatX * skinVertex * skinWeightTmp.x;\n skinned += boneMatY * skinVertex * skinWeightTmp.y;\n skinned += boneMatZ * skinVertex * skinWeightTmp.z;\n skinned += boneMatW * skinVertex * skinWeightTmp.w;\n return skinned;\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",amrt_skinning_vertex:"\n\n#ifdef USE_SKINNING\n\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n \n vec4 skinned = vec4( 0.0 );\n \n skinned += boneMatX * skinVertex * skinWeight_4.x;\n skinned += boneMatY * skinVertex * skinWeight_4.y;\n skinned += boneMatZ * skinVertex * skinWeight_4.z;\n skinned += boneMatW * skinVertex * skinWeight_4.w;\n \n #ifdef BONE_8\n skinned += boneMatX_8 * skinVertex * skinWeight_8.x;\n skinned += boneMatY_8 * skinVertex * skinWeight_8.y;\n skinned += boneMatZ_8 * skinVertex * skinWeight_8.z;\n skinned += boneMatW_8 * skinVertex * skinWeight_8.w;\n\n #endif\n \n #ifdef BONE_12\n skinned += boneMatX_12 * skinVertex * skinWeight_12.x;\n skinned += boneMatY_12 * skinVertex * skinWeight_12.y;\n skinned += boneMatZ_12 * skinVertex * skinWeight_12.z;\n skinned += boneMatW_12 * skinVertex * skinWeight_12.w;\n #endif\n \n #ifdef BONE_16\n skinned += boneMatX_16 * skinVertex * skinWeight_16.x;\n skinned += boneMatY_16 * skinVertex * skinWeight_16.y;\n skinned += boneMatZ_16 * skinVertex * skinWeight_16.z;\n skinned += boneMatW_16 * skinVertex * skinWeight_16.w;\n #endif\n \n transformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n",amrt_skinnormal_vertex:"\n#ifdef USE_SKINNING\n\n\t mat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight_4.x * boneMatX;\n\tskinMatrix += skinWeight_4.y * boneMatY;\n\tskinMatrix += skinWeight_4.z * boneMatZ;\n\tskinMatrix += skinWeight_4.w * boneMatW;\n\t\n\t#ifdef BONE_8\n skinMatrix += skinWeight_8.x * boneMatX_8;\n skinMatrix += skinWeight_8.y * boneMatY_8;\n skinMatrix += skinWeight_8.z * boneMatZ_8;\n skinMatrix += skinWeight_8.w * boneMatW_8;\n\t#endif\n\t\n\t#ifdef BONE_12\n skinMatrix += skinWeight_12.x * boneMatX_12;\n skinMatrix += skinWeight_12.y * boneMatY_12;\n skinMatrix += skinWeight_12.z * boneMatZ_12;\n skinMatrix += skinWeight_12.w * boneMatW_12;\n\t#endif\n\t\n\t#ifdef BONE_16\n skinMatrix += skinWeight_16.x * boneMatX_16;\n skinMatrix += skinWeight_16.y * boneMatY_16;\n skinMatrix += skinWeight_16.z * boneMatZ_16;\n skinMatrix += skinWeight_16.w * boneMatW_16;\n\t#endif\n\t\n mat4 shadowSkinMatrix = skinMatrix;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\t\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n",amrt_ssr_uniform_fragment:"\n\n#ifdef USE_SSR\n\t\nuniform sampler2D ssrTexture;\nuniform sampler2D tDepth;\nuniform float maxDistance;\nuniform float ssrOpacity;\nuniform float fresnelCoe;\nuniform float virtualCameraNear;\nuniform float virtualCameraFar;\nuniform mat4 virtualCameraProjectionMatrix;\nuniform mat4 virtualCameraProjectionMatrixInverse;\nuniform mat4 virtualCameraMatrixWorld;\nuniform vec2 resolution;\nvarying vec4 ssrUV;\nuniform float planeOffset;\n\n\nfloat getDepth( const in vec2 uv ) {\n return texture2D( tDepth, uv ).x;\n}\nfloat getViewZ( const in float depth ) {\n return perspectiveDepthToViewZ( depth, virtualCameraNear, virtualCameraFar );\n}\nvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n vec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n clipPosition *= clipW; //clip\n return ( virtualCameraProjectionMatrixInverse * clipPosition ).xyz;//view\n}\n\n#define ssr_maxMipLevel 8.0\n#define ssr_minMipLevel 4.0\n// #define ssr_maxTileSize 256.0\n// #define ssr_minTileSize 16.0\n#define MAXSIZE 1024.0\n\nvec3 sampleTexture(sampler2D envMap,vec2 uv,vec2 xRange,vec2 yRange){\n\n float sx = 0.5 / MAXSIZE;\n float maxY = (MAXSIZE + MAXSIZE / 2.0);\n float sy = 0.5 / maxY;\n if(uv.x > xRange.y){\n uv.x = xRange.y - sx;\n }\n if(uv.y > yRange.y - sy){\n uv.y = yRange.y - sy;\n // return vec3(1.0,0.0,0.0);\n }\n\n return texture2D(envMap, uv).rgb;\n}\n\nvec3 ssrbilinearCubeUV(sampler2D envMap,vec2 vUv, float mipInt) {\n\n float maxY = (MAXSIZE + MAXSIZE / 2.0);\n vUv = fract(vUv);\n vec2 uv = vUv;\n float expInt = mipInt;\n if(mipInt > 4.0){\n expInt = 4.0;\n }\n float e = exp2(expInt);\n \n float texSize = MAXSIZE / e;\n \n vec2 xRange = vec2(0.0,1.0);\n vec2 yRange = vec2(0.0,1.0);\n\n if(mipInt == 0.0 ){\n float uvx = vUv.x;\n float uvy = vUv.y * (texSize / maxY);\n yRange.y = texSize / maxY;\n uv = vec2(uvx,uvy);\n }\n else\n {\n xRange.x = (MAXSIZE - 2.0 * texSize) / MAXSIZE;\n xRange.y = xRange.x + texSize / MAXSIZE;\n float uvx = xRange.x + (texSize / MAXSIZE) * vUv.x;\n float uvy = vUv.y;\n if(mipInt < 5.0){\n yRange.x = MAXSIZE / maxY;\n yRange.y = yRange.x + texSize / maxY;\n uvy = yRange.x + texSize / maxY * vUv.y;\n }\n if(mipInt > 4.0){\n yRange.x = (MAXSIZE + (mipInt - 4.0) * texSize) / maxY;\n yRange.y = yRange.x + texSize / maxY;\n uvy = yRange.x + texSize / maxY * vUv.y;\n }\n uv = vec2(uvx,uvy);\n }\n\n float sx = 0.5 / MAXSIZE;\n float sy = 0.5 / maxY;\n\n float maxx = uv.x / sx;\n float maxy = uv.y / sy;\n\n float fx = fract(maxx);\n float fy = fract(maxy);\n \n vec3 mx0 = sampleTexture(envMap, uv,xRange,yRange).rgb;\n // return mx0;\n vec3 mx1 = sampleTexture(envMap, uv + vec2(sx,0.0),xRange,yRange).rgb;\n\n vec3 my0 = sampleTexture(envMap, uv + vec2(0.0,sy),xRange,yRange).rgb;\n vec3 my1 = sampleTexture(envMap, uv + vec2(sx,sy),xRange,yRange).rgb;\n vec3 tm = mix(mx0,mx1,fx);\n vec3 tm1 = mix(my0,my1,fx);\n\n return mix(tm,tm1,fy);\n}\n\n\nfloat ssrroughnessToMip(float roughness) {\n float mip = 0.0;\n\n if(roughness >= 0.8){\n mip = 9.0 + (roughness - 0.8) / 0.2;\n }else if(roughness >= 0.4){\n mip = 6.0 + 3.0 * (roughness - 0.4) / 0.4;\n }else if(roughness >= 0.305){\n mip = 5.0 + (roughness - 0.305) / 0.095;\n }else if(roughness >= 0.21){\n mip = 4.0 + (roughness - 0.21) / 0.095;\n }else{\n mip = 4.0 * roughness / 0.21;\n }\n\n return mip;\n}\n\nvec4 ssrtextureCubeUV(sampler2D envMap, vec2 vUv,float roughness) {\n float mip = ssrroughnessToMip(roughness);//clamp(ssrroughnessToMip(roughness), ssrm0, ssr_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n // vec3 color11 = ssrbilinearCubeUV(envMap, vUv,10.0);\n // return vec4(color11,1.0);\n\n vec3 color0 = ssrbilinearCubeUV(envMap, vUv,mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = ssrbilinearCubeUV(envMap, vUv,mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n\n",amrt_ssr_fragment:"\n\n#ifdef USE_SSR\n\t\n \n vec2 newssrUV = vec2(ssrUV.x / ssrUV.w,ssrUV.y / ssrUV.w);\n // vec4 ssrColor = texture2D(ssrTexture,newssrUV);\n // // // vec4 ssrColor = texture2DProj( ssrTexture, ssrUV );\n // reflectedLight.indirectSpecular = ssrColor.rgb;\n\n vec4 ssrColor = ssrtextureCubeUV(ssrTexture,newssrUV,material.specularRoughness);\n vec2 uv=(gl_FragCoord.xy-.5)/resolution.xy;\n uv.x=1.-uv.x;\n float depth = texture2DProj( tDepth, ssrUV ).r;\n float viewZ = getViewZ( depth );\n float clipW = virtualCameraProjectionMatrix[2][3] * viewZ+virtualCameraProjectionMatrix[3][3];\n vec3 viewPosition=getViewPosition( uv, depth, clipW );\n vec3 worldPosition=(virtualCameraMatrixWorld*vec4(viewPosition,1)).xyz;\n float ratio= saturate(1.0 - (abs(worldPosition.y - planeOffset)/maxDistance));\n float attenuation=ratio*ratio;\n float op = ssrOpacity*attenuation;// * fresnelCoe;\n reflectedLight.indirectSpecular = ssrColor.rgb * op; // * op\n \n\n\n#endif\n\n",amrt_ssr_uv_vertex:"\n\n#ifdef USE_SSR\n\t\nvarying vec4 ssrUV;\nuniform mat4 ssrTextureMatrix;\n\n#endif\n\n",amrt_ssr_vertex:"\n#ifdef USE_SSR\n ssrUV = ssrTextureMatrix * vec4( position, 1.0 );\n#endif\n\n"},Yi={common:{diffuse:{value:new Fn(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new lt},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Fn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new Fn(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new lt}},sprite:{diffuse:{value:new Fn(15658734)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new lt}},amrtbasic:{diffuse:{value:new Fn(.5,.5,.5)},opacity:{value:1},emissive:{value:new Fn(0)},smoothness:{value:.5},metalness:{value:.5},transparency:{value:0},cutout:{value:1},albedo:{value:null},normalMap:{value:null},normalScale:{value:1},normalMap2:{value:null},normalScale2:{value:1},metallicMap:{value:null},roughnessMap:{value:null},aoMap:{value:null},aoScale:{value:1},emissiveMap:{value:null},reflectMap:{value:null},reflectIntensity:{value:0},envMapIntensity:{value:1},alphaMap:{value:null},dissolveMap:{value:null},dissolveRatio:{value:1},dissolveColor:{value:new Fn(0)},ssrTextureMatrix:{value:new bt},ssrTexture:{value:null},maxDistance:{value:10},ssrOpacity:{value:1},fresnelCoe:{value:0},virtualCameraNear:{value:.1},virtualCameraFar:{value:1e3},virtualCameraMatrixWorld:{value:new bt},virtualCameraProjectionMatrix:{value:new bt},virtualCameraProjectionMatrixInverse:{value:new bt},resolution:{value:new tt},tDepth:{value:null},albedoUVTransform:{value:new lt},normalUVTransform:{value:new lt},normal2UVTransform:{value:new lt},metalUVTransform:{value:new lt},roughUVTransform:{value:new lt},aoUVTransform:{value:new lt},emissiveUVTransform:{value:new lt},alphaUVTransform:{value:new lt},clippingTransparent:{value:!1},planeOffset:{value:0}},amrtshadow:{color:{value:new Fn(0)},shadowPlane:{value:new vn(new at(0,-1),0)},shadowStrength:{value:1},lightDirection:{value:new at(-1,-1,-1)},shadowLength:{value:1},center:{value:new at(0,0,0)}}},Ki={basic:{uniforms:Ui([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.fog]),vertexShader:Xi.meshbasic_vert,fragmentShader:Xi.meshbasic_frag},lambert:{uniforms:Ui([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.fog,Yi.lights,{emissive:{value:new Fn(0)}}]),vertexShader:Xi.meshlambert_vert,fragmentShader:Xi.meshlambert_frag},phong:{uniforms:Ui([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.gradientmap,Yi.fog,Yi.lights,{emissive:{value:new Fn(0)},specular:{value:new Fn(1118481)},shininess:{value:30}}]),vertexShader:Xi.meshphong_vert,fragmentShader:Xi.meshphong_frag},standard:{uniforms:Ui([Yi.common,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.roughnessmap,Yi.metalnessmap,Yi.fog,Yi.lights,{emissive:{value:new Fn(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Xi.meshphysical_vert,fragmentShader:Xi.meshphysical_frag},matcap:{uniforms:Ui([Yi.common,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.fog,{matcap:{value:null}}]),vertexShader:Xi.meshmatcap_vert,fragmentShader:Xi.meshmatcap_frag},points:{uniforms:Ui([Yi.points,Yi.fog]),vertexShader:Xi.points_vert,fragmentShader:Xi.points_frag},dashed:{uniforms:Ui([Yi.common,Yi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xi.linedashed_vert,fragmentShader:Xi.linedashed_frag},depth:{uniforms:Ui([Yi.common,Yi.displacementmap]),vertexShader:Xi.depth_vert,fragmentShader:Xi.depth_frag},normal:{uniforms:Ui([Yi.common,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,{opacity:{value:1}}]),vertexShader:Xi.normal_vert,fragmentShader:Xi.normal_frag},sprite:{uniforms:Ui([Yi.sprite,Yi.fog]),vertexShader:Xi.sprite_vert,fragmentShader:Xi.sprite_frag},background:{uniforms:{uvTransform:{value:new lt},t2D:{value:null}},vertexShader:Xi.background_vert,fragmentShader:Xi.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1},brightness:{value:1}},vertexShader:Xi.cube_vert,fragmentShader:Xi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xi.equirect_vert,fragmentShader:Xi.equirect_frag},distanceRGBA:{uniforms:Ui([Yi.common,Yi.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xi.distanceRGBA_vert,fragmentShader:Xi.distanceRGBA_frag},shadow:{uniforms:Ui([Yi.lights,Yi.fog,{color:{value:new Fn(0)},opacity:{value:1}}]),vertexShader:Xi.shadow_vert,fragmentShader:Xi.shadow_frag},acf:{uniforms:{diffuse:{value:new Fn(0)},map:{value:null}},vertexShader:Xi.acf_vert,fragmentShader:Xi.acf_frag}};function Zi(){var e=null,t=!1,n=null;function i(r,a){!1!==t&&(n(r,a),e.requestAnimationFrame(i))}return{start:function(){!0!==t&&null!==n&&(e.requestAnimationFrame(i),t=!0)},stop:function(){t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Ji(e){var t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){n.isInterleavedBufferAttribute&&(n=n.data);var r=t.get(n);void 0===r?t.set(n,function(t,n){var i=t.array,r=t.usage,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback();var o=e.FLOAT;return i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(n,i)):r.version0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(console.warn("WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===n.logarithmicDepthBuffer,A=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),u=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),p=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=c>0,g=a||!!t.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==i)return i;var n=t.get("EXT_texture_filter_anisotropic");return i=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:A,maxVertexTextures:c,maxTextureSize:h,maxCubemapSize:u,maxAttributes:d,maxVertexUniforms:f,maxVaryings:p,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:v&&g,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function ir(){var e=this,t=null,n=0,i=!1,r=!1,a=new vn,o=new lt,s={value:null,needsUpdate:!1};function l(){s.value!==t&&(s.value=t,s.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function A(t,n,i,r){var l=null!==t?t.length:0,A=null;if(0!==l){if(A=s.value,!0!==r||null===A){var c=i+4*l,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===A||A.length65535?Xn:jn)(i,1);f.version=s,t.update(f,e.ELEMENT_ARRAY_BUFFER);var p=r.get(n);p&&t.remove(p),r.set(n,f)}return{get:function(e,t){var r=i.get(t);return r||(t.addEventListener("dispose",a),t.isBufferGeometry?r=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new si).setFromObject(e)),r=t._bufferGeometry),i.set(t,r),n.memory.geometries++,r)},update:function(n){var i=n.index,r=n.attributes;for(var a in null!==i&&t.update(i,e.ELEMENT_ARRAY_BUFFER),r)t.update(r[a],e.ARRAY_BUFFER);var o=n.morphAttributes;for(var a in o)for(var s=o[a],l=0,A=s.length;l0)return e;var r=t*n,a=gr[r];if(void 0===a&&(a=new Float32Array(r),gr[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function Cr(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n/gm;function ga(e){return e.replace(va,ya)}function ya(e,t){var n=Xi[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return ga(n)}var wa=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function xa(e){return e.replace(wa,ba)}function ba(e,t,n,i){for(var r="",a=parseInt(t);a0?e.gammaFactor:1,w=a.isWebGL2?"":function(e,t,n){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||!t.vertexTangents?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":"",n.get("OES_texture_half_float")?"#extension OES_texture_half_float : enable":""].filter(fa).join("\n")}(i.extensions,a,t),x=function(e){var t=[];for(var n in e){var i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(u),b=h.createProgram(),M=a.numMultiviewViews;if(i.isRawShaderMaterial?((o=[x].filter(fa).join("\n")).length>0&&(o+="\n"),(s=[w,x].filter(fa).join("\n")).length>0&&(s+="\n")):(o=[Ma(a),"#define SHADER_NAME "+r.name,x,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+y,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+v:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.dissolveMap?"#define USE_DISSOLVE":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+p:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",a.albedo?"#define USE_ALBEDO":"",1===a.albedoUV?"#define ALBEDO_UV2":"#define ALBEDO_UV1",a.normalMap2?"#define USE_NORMALMAP2":"",a.metallicMap?"#define USE_METALLICMAP":"",1===a.aoUV?"#define AO_UV2":"#define AO_UV1",1===a.emissiveUV?"#define EMISSIVE_UV2":"#define EMISSIVE_UV1",a.reflectMap?"#define USE_REFLECTMAP":"",a.boneNum>4?"#define BONE_8":"",a.boneNum>8?"#define BONE_12":"",a.boneNum>12?"#define BONE_16":"",a.ssrTexture?"#define USE_SSR":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","\n"].filter(fa).join("\n"),s=[w,Ma(a),"#define SHADER_NAME "+r.name,x,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+y,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+m:"",a.envMap?"#define "+v:"",a.envMap?"#define "+g:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.dissolveMap?"#define USE_DISSOLVE":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+p:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensions&&i.extensions.shaderTextureLOD||a.envMap||a.reflectMap)&&(a.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform mat4 viewMatrixR;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==a.toneMapping?"#define TONE_MAPPING":"",0!==a.toneMapping?Xi.tonemapping_pars_fragment:"",0!==a.toneMapping?da("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?Xi.encodings_pars_fragment:"",a.mapEncoding?ua("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?ua("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?ua("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?ua("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(l="linearToOutputTexel",A=a.outputEncoding,c=ca(A),"vec4 "+l+"( vec4 value ) { return LinearTo"+c[0]+c[1]+"; }"):"",a.albedoEncoding?ua("albedoTexelToLinear",a.albedoEncoding):"",a.normalMapEncoding?ua("normalMapTexelToLinear",a.normalMapEncoding):"",a.normalMap2Encoding?ua("normalMap2TexelToLinear",a.normalMap2Encoding):"",a.metallicMapEncoding?ua("metallicMapTexelToLinear",a.metallicMapEncoding):"",a.roughnessMapEncoding?ua("roughnessMapTexelToLinear",a.roughnessMapEncoding):"",a.aoMapEncoding?ua("aoMapTexelToLinear",a.aoMapEncoding):"",a.reflectMapEncoding?ua("reflectMapTexelToLinear",a.reflectMapEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",a.albedo?"#define USE_ALBEDO":"",1===a.albedoUV?"#define ALBEDO_UV2":"#define ALBEDO_UV1",a.normalMap2?"#define USE_NORMALMAP2":"",a.metallicMap?"#define USE_METALLICMAP":"",1===a.aoUV?"#define AO_UV2":"#define AO_UV1",1===a.emissiveUV?"#define EMISSIVE_UV2":"#define EMISSIVE_UV1",a.reflectMap?"#define USE_REFLECTMAP":"",a.reflectMapUV?"#define USE_REFLECTMAP_UV":"",a.transparency?"#define TRANSPARENCY":"",a.ssrTexture?"#define USE_SSR":"","\n"].filter(fa).join("\n")),d=ma(d=pa(d=ga(d),a),a),f=ma(f=pa(f=ga(f),a),a),d=xa(d),f=xa(f),a.isWebGL2&&!i.isRawShaderMaterial){var C=!1,B=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==d.match(B)&&null!==f.match(B)&&(C=!0,d=d.replace(B,""),f=f.replace(B,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",C?"":"out highp vec4 pc_fragColor;",C?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,M>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+M+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+M+"];","uniform mat4 projectionMatrices["+M+"];","uniform mat4 viewMatrices["+M+"];","uniform mat3 normalMatrices["+M+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+M+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var E,S,T=o+d,_=s+f,I=la(h,h.VERTEX_SHADER,T),L=la(h,h.FRAGMENT_SHADER,_);if(h.attachShader(b,I),h.attachShader(b,L),void 0!==i.index0AttributeName?h.bindAttribLocation(b,0,i.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(b,0,"position"),h.linkProgram(b),e.debug.checkShaderErrors){var F=h.getProgramInfoLog(b).trim(),k=h.getShaderInfoLog(I).trim(),P=h.getShaderInfoLog(L).trim(),U=!0,D=!0;if(!1===h.getProgramParameter(b,h.LINK_STATUS)){U=!1;var R=ha(h,I,"vertex"),O=ha(h,L,"fragment");console.error("WebGLProgram: shader error: ",h.getError(),"gl.VALIDATE_STATUS",h.getProgramParameter(b,h.VALIDATE_STATUS),"gl.getProgramInfoLog",F,R,O)}else""!==F?console.warn("WebGLProgram: gl.getProgramInfoLog()",F):""!==k&&""!==P||(D=!1);D&&(this.diagnostics={runnable:U,material:i,programLog:F,vertexShader:{log:k,prefix:o},fragmentShader:{log:P,prefix:s}})}return h.deleteShader(I),h.deleteShader(L),this.getUniforms=function(){return void 0===E&&(E=new sa(h,b)),E},this.getAttributes=function(){return void 0===S&&(S=function(e,t){for(var n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),r=0;r0,maxBones:g,useVertexTexture:o,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numDirLightShadows:i.directionalShadowMap.length,numPointLightShadows:i.pointShadowMap.length,numSpotLightShadows:i.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:p,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:t.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:2===t.side,flipSided:1===t.side,depthPacking:void 0!==t.depthPacking&&t.depthPacking,albedo:!!t.albedo,albedoUV:t.albedoUV,normalMap2:!!t.normalMap2,metallicMap:!!t.metallicMap,aoUV:t.aoUV,emissiveUV:t.emissiveUV,reflectMap:!!t.reflectMap,reflectMapUV:!!t.reflectMap&&!t.reflectMap.isCubeTexture,aoMapEncoding:u(t.aoMap,e.gammaInput),roughnessMapEncoding:u(t.roughnessMap,e.gammaInput),metallicMapEncoding:u(t.metallicMap,e.gammaInput),normalMapEncoding:u(t.normalMap,e.gammaInput),normalMap2Encoding:u(t.normalMap2,e.gammaInput),albedoEncoding:u(t.albedo,e.gammaInput),reflectMapEncoding:u(t.reflectMap,e.gammaInput),transparency:void 0!==t.transparency&&t.transparency>0,boneNum:y,dissolveMap:!!t.dissolveMap,dissolveRatio:t.dissolveRatio,ssrTexture:!!t.ssrTexture}},this.getProgramCacheKey=function(t,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var a=0;a1&&n.sort(Sa),i.length>1&&i.sort(Ta)}}}function Ia(){var e=new WeakMap;function t(n){var i=n.target;i.removeEventListener("dispose",t),e.delete(i)}return{get:function(n,i){var r,a=e.get(n);return void 0===a?(r=new _a,e.set(n,new WeakMap),e.get(n).set(i,r),n.addEventListener("dispose",t)):void 0===(r=a.get(i))&&(r=new _a,a.set(i,r)),r},dispose:function(){e=new WeakMap}}}function La(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new at,color:new Fn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"SpotLight":n={position:new at,direction:new at,color:new Fn,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new tt};break;case"PointLight":n={position:new at,color:new Fn,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new tt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new at,skyColor:new Fn,groundColor:new Fn};break;case"RectAreaLight":n={color:new Fn,position:new at,halfWidth:new at,halfHeight:new at}}return e[t.id]=n,n}}}var Fa=0;function ka(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Pa(){for(var e=new La,t={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)t.probe.push(new at);var i=new at,r=new bt,a=new bt;return{setup:function(n,o,s){for(var l=0,A=0,c=0,h=0;h<9;h++)t.probe[h].set(0,0,0);var u=0,d=0,f=0,p=0,m=0,v=0,g=0,y=0,w=s.matrixWorldInverse;n.sort(ka),h=0;for(var x=n.length;h\n\nvoid main() {\n\n float mean = 0.0;\n float squared_mean = 0.0;\n\n\t// This seems totally useless but it's a crazy work around for a Adreno compiler bug\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\n #ifdef HORIZONAL_PASS\n\n vec2 distribution = unpack2HalfToRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\n #else\n\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n\n #endif\n\n }\n\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n\n float std_dev = sqrt( squared_mean - mean * mean );\n\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n\n}\n"}),u=h.clone();u.defines.HORIZONAL_PASS=1;var d=new si;d.setAttribute("position",new zn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var f=new Ei(d,h),p=this;function m(n,i){var r=t.update(f);h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,h,f,null),u.uniforms.shadow_pass.value=n.mapPass.texture,u.uniforms.resolution.value=n.mapSize,u.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,u,f,null)}function v(e,t,n){var i=e<<0|t<<1|n<<2,r=s[i];return void 0===r&&(r=new Ra({depthPacking:je,morphTargets:e,skinning:t}),s[i]=r),r}function g(e,t,n){var i=e<<0|t<<1|n<<2,r=l[i];return void 0===r&&(r=new Oa({morphTargets:e,skinning:t}),l[i]=r),r}function y(t,n,i,r,a,o){var s=t.geometry,l=null,h=v,u=t.customDepthMaterial;if(!0===i.isPointLight&&(h=g,u=t.customDistanceMaterial),void 0===u){var d=!1;!0===n.morphTargets&&(!0===s.isBufferGeometry?d=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:!0===s.isGeometry&&(d=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===t.isSkinnedMesh&&!0===n.skinning&&(f=!0),l=h(d,f,!0===t.isInstancedMesh)}else l=u;if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var p=l.uuid,m=n.uuid,y=A[p];void 0===y&&(y={},A[p]=y);var w=y[m];void 0===w&&(w=l.clone(),y[m]=w),l=w}return l.visible=n.visible,l.wireframe=n.wireframe,l.side=3===o?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:c[n.side],l.clipShadows=n.clipShadows,l.clippingPlanes=n.clippingPlanes,l.clipIntersection=n.clipIntersection,l.wireframeLinewidth=n.wireframeLinewidth,l.linewidth=n.linewidth,!0===i.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(i.matrixWorld),l.nearDistance=r,l.farDistance=a),l}function w(n,r,a,o,s){if(!1!==n.visible){if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var l=t.update(n),A=n.material;if(Array.isArray(A))for(var c=l.groups,h=0,u=c.length;hn||r.y>n)&&(console.warn("WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),r.x>n&&(a.x=Math.floor(n/y.x),r.x=a.x*y.x,g.mapSize.x=a.x),r.y>n&&(a.y=Math.floor(n/y.y),r.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&3===this.type){var x={minFilter:Z,magFilter:Z,format:ce};g.map=new dt(r.x,r.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new dt(r.x,r.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:X,magFilter:X,format:ce};g.map=new dt(r.x,r.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}e.setRenderTarget(g.map),e.clear();for(var b=g.getViewportCount(),M=0;M=1):-1!==Q.indexOf("OpenGL ES")&&(z=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(Q)[1]),N=z>=2);var G=null,H={},V=new ut,j=new ut;function W(t,n,i){var r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?et.floorPowerOfTwo:Math.floor,o=a(r*e.width),s=a(r*e.height);void 0===A&&(A=g(o,s));var l=n?g(o,s):A;return l.width=o,l.height=s,l.getContext("2d").drawImage(e,0,0,o,s),console.warn("Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),l}return"data"in e&&console.warn("Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function w(e){return et.isPowerOfTwo(e.width)&&et.isPowerOfTwo(e.height)}function x(e,t){return e.generateMipmaps&&t&&e.minFilter!==X&&e.minFilter!==Z}function b(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,a))*Math.LOG2E}function M(n,i){if(!1===h)return n;var r=n;return n===e.RED&&(i===e.FLOAT&&(r=e.R32F),i===e.HALF_FLOAT&&(r=e.R16F),i===e.UNSIGNED_BYTE&&(r=e.R8)),n===e.RGB&&(i===e.FLOAT&&(r=e.RGB32F),i===e.HALF_FLOAT&&(r=e.RGB16F),i===e.UNSIGNED_BYTE&&(r=e.RGB8)),n===e.RGBA&&(i===e.FLOAT&&(r=e.RGBA32F),i===e.HALF_FLOAT&&(r=e.RGBA16F),i===e.UNSIGNED_BYTE&&(r=e.RGBA8)),r===e.R16F||r===e.R32F||r===e.RGBA16F||r===e.RGBA32F?t.get("EXT_color_buffer_float"):r!==e.RGB16F&&r!==e.RGB32F||console.warn("Floating point textures with RGB format not supported. Please use RGBA instead."),r}function C(t){return t===X||t===Y||t===K?e.NEAREST:e.LINEAR}function B(t){var n=t.target;n.removeEventListener("dispose",B),function(t){var n=i.get(t);if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture),i.remove(t)}(n),n.isVideoTexture&&m.delete(n),o.memory.textures--}function E(t){var n=t.target;n.removeEventListener("dispose",E),function(t){var n=i.get(t),r=i.get(t.texture);if(!t)return;void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);if(t.isWebGLMultiviewRenderTarget){e.deleteTexture(n.__webglColorTexture),e.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&a.__version!==t.version){var s=t.image;if(void 0===s)console.warn("Texture marked for update but image is undefined");else if(!1!==s.complete)return void U(a,t,r)}n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function _(t,r){if(6===t.image.length){var o=i.get(t);if(t.version>0&&o.__version!==t.version){P(o,t),n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var s=t&&t.isCompressedTexture,l=t.image[0]&&t.image[0].isDataTexture,A=[],c=0;c<6;c++)A[c]=s||l?l?t.image[c].image:t.image[c]:y(t.image[c],!1,!0,d);var u,f=A[0],p=w(f)||h,m=a.convert(t.format),v=a.convert(t.type),g=M(m,v);if(k(e.TEXTURE_CUBE_MAP,t,p),s){for(c=0;c<6;c++){u=A[c].mipmaps;for(var C=0;C1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function P(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",B),t.__webglTexture=e.createTexture(),o.memory.textures++)}function U(t,i,r){var o=e.TEXTURE_2D;i.isDataTexture2DArray&&(o=e.TEXTURE_2D_ARRAY),i.isDataTexture3D&&(o=e.TEXTURE_3D),P(t,i),n.activeTexture(e.TEXTURE0+r),n.bindTexture(o,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var s=function(e){return!h&&(e.wrapS!==j||e.wrapT!==j||e.minFilter!==X&&e.minFilter!==Z)}(i)&&!1===w(i.image),l=y(i.image,s,!1,f),A=w(l)||h,c=a.convert(i.format),u=a.convert(i.type),d=M(c,u);k(o,i,A);var p,m=i.mipmaps;if(i.isDepthTexture){if(d=e.DEPTH_COMPONENT,i.type===ne){if(!1===h)throw new Error("Float Depth Texture only supported in WebGL2.0");d=e.DEPTH_COMPONENT32F}else h&&(d=e.DEPTH_COMPONENT16);i.format===fe&&d===e.DEPTH_COMPONENT&&i.type!==ee&&i.type!==te&&(console.warn("Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=ee,u=a.convert(i.type)),i.format===pe&&(d=e.DEPTH_STENCIL,i.type!==se&&(console.warn(" Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=se,u=a.convert(i.type))),n.texImage2D(e.TEXTURE_2D,0,d,l.width,l.height,0,c,u,null)}else if(i.isDataTexture)if(m.length>0&&A){for(var v=0,g=m.length;v0&&A){for(v=0,g=m.length;v=u&&console.warn("Trying to use "+e+" texture units while this GPU supports only "+u),S+=1,e},this.resetTextureUnits=function(){S=0},this.setTexture2D=T,this.setTexture2DArray=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?U(a,t,r):(n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture))},this.setTexture3D=function(t,r){var a=i.get(t);t.version>0&&a.__version!==t.version?U(a,t,r):(n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_3D,a.__webglTexture))},this.setTextureCube=_,this.setTextureCubeDynamic=I,this.setupRenderTarget=function(r){var s=i.get(r),l=i.get(r.texture);r.addEventListener("dispose",E),l.__webglTexture=e.createTexture(),o.memory.textures++;var A=!0===r.isWebGLRenderTargetCube,c=!0===r.isWebGLMultisampleRenderTarget,u=!0===r.isWebGLMultiviewRenderTarget,d=w(r)||h;if(A){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=e.createFramebuffer()}else if(s.__webglFramebuffer=e.createFramebuffer(),c)if(h){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer);var p=M(a.convert(r.texture.format),a.convert(r.texture.type)),m=N(r);e.renderbufferStorageMultisample(e.RENDERBUFFER,m,p,r.width,r.height),e.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,s.__webglColorRenderbuffer),e.bindRenderbuffer(e.RENDERBUFFER,null),r.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),R(s.__webglDepthRenderbuffer,r,!0)),e.bindFramebuffer(e.FRAMEBUFFER,null)}else console.warn("WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(u){var v=r.width,g=r.height,y=r.numViews;e.bindFramebuffer(e.FRAMEBUFFER,s.__webglFramebuffer);var C=t.get("OVR_multiview2");o.memory.textures+=2;var B=e.createTexture();e.bindTexture(e.TEXTURE_2D_ARRAY,B),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage3D(e.TEXTURE_2D_ARRAY,0,e.RGBA8,v,g,y,0,e.RGBA,e.UNSIGNED_BYTE,null),C.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,B,0,0,y);var S=e.createTexture();e.bindTexture(e.TEXTURE_2D_ARRAY,S),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D_ARRAY,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage3D(e.TEXTURE_2D_ARRAY,0,e.DEPTH24_STENCIL8,v,g,y,0,e.DEPTH_STENCIL,e.UNSIGNED_INT_24_8,null),C.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,S,0,0,y);var T=new Array(y);for(f=0;fh)return!1;for(var n=1,i=t.length;n=0){var A=r[s];if(void 0!==A){var c=A.normalized,h=A.itemSize;if(void 0===(M=w.get(A)))continue;var u=M.buffer,v=M.type,g=M.bytesPerElement;if(A.isInterleavedBufferAttribute){var y=A.data,x=y.stride,b=A.offset;y&&y.isInstancedInterleavedBuffer?(m.enableAttributeAndDivisor(l,y.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=y.meshPerAttribute*y.count)):m.enableAttribute(l),d.bindBuffer(d.ARRAY_BUFFER,u),d.vertexAttribPointer(l,h,v,c,x*g,b*g)}else A.isInstancedBufferAttribute?(m.enableAttributeAndDivisor(l,A.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=A.meshPerAttribute*A.count)):m.enableAttribute(l),d.bindBuffer(d.ARRAY_BUFFER,u),d.vertexAttribPointer(l,h,v,c,0,0)}else if("instanceMatrix"===s){if(void 0===e.instanceMatrix)continue;var M;if(void 0===(M=w.get(e.instanceMatrix)))continue;u=M.buffer,v=M.type;m.enableAttributeAndDivisor(l+0,1),m.enableAttributeAndDivisor(l+1,1),m.enableAttributeAndDivisor(l+2,1),m.enableAttributeAndDivisor(l+3,1),d.bindBuffer(d.ARRAY_BUFFER,u),d.vertexAttribPointer(l+0,4,v,!1,64,0),d.vertexAttribPointer(l+1,4,v,!1,64,16),d.vertexAttribPointer(l+2,4,v,!1,64,32),d.vertexAttribPointer(l+3,4,v,!1,64,48)}else if(void 0!==o){var C=o[s];if(void 0!==C)switch(C.length){case 2:d.vertexAttrib2fv(l,C);break;case 3:d.vertexAttrib3fv(l,C);break;case 4:d.vertexAttrib4fv(l,C);break;default:d.vertexAttrib1fv(l,C)}}}}m.disableUnusedAttributes()}(r,n,i,s),null!==A&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.buffer));var g=1/0;null!==A?g=A.count:void 0!==c&&(g=c.count);var y=n.drawRange.start*u,b=n.drawRange.count*u,M=null!==a?a.start*u:0,C=null!==a?a.count*u:1/0,B=Math.max(y,M),E=Math.min(g,y+b,M+C)-1,I=Math.max(0,E-B+1);if(0!==I){if(r.isMesh)if(!0===i.wireframe)m.setLineWidth(i.wireframeLinewidth*oe()),v.setMode(d.LINES);else switch(r.drawMode){case 0:v.setMode(d.TRIANGLES);break;case 1:v.setMode(d.TRIANGLE_STRIP);break;case 2:v.setMode(d.TRIANGLE_FAN)}else if(r.isLine){var L=i.linewidth;void 0===L&&(L=1),m.setLineWidth(L*oe()),r.isLineSegments?v.setMode(d.LINES):r.isLineLoop?v.setMode(d.LINE_LOOP):v.setMode(d.LINE_STRIP)}else r.isPoints?v.setMode(d.POINTS):r.isSprite&&v.setMode(d.TRIANGLES);r.isInstancedMesh?v.renderInstances(n,B,I,r.count):n.isInstancedBufferGeometry?v.renderInstances(n,B,I,n.maxInstancedCount):v.render(B,I)}}},this.compile=function(e,t){(u=B.get(e,t)).init(),e.traverse((function(e){e.isLight&&(u.pushLight(e),e.castShadow&&u.pushShadow(e))})),u.setupLights(t),e.traverse((function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(f=0;f=0&&e.numSupportedMorphNormals++}var p=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=q.numPlanes,i.numIntersection=q.numIntersection,p.clippingPlanes=q.uniform),i.fog=t,i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isAMRTBasicMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=o,i.needsLights&&(p.ambientLightColor.value=r.state.ambient,p.lightProbe.value=r.state.probe,p.directionalLights.value=r.state.directional,p.spotLights.value=r.state.spot,p.rectAreaLights.value=r.state.rectArea,p.pointLights.value=r.state.point,p.hemisphereLights.value=r.state.hemi,p.directionalShadowMap.value=r.state.directionalShadowMap,p.directionalShadowMatrix.value=r.state.directionalShadowMatrix,p.spotShadowMap.value=r.state.spotShadowMap,p.spotShadowMatrix.value=r.state.spotShadowMatrix,p.pointShadowMap.value=r.state.pointShadowMap,p.pointShadowMatrix.value=r.state.pointShadowMatrix);var m=i.program.getUniforms(),v=sa.seqWithValue(m.seq,p);i.uniformsList=v}function Be(e,t,n,i){y.resetTextureUnits();var r=g.get(n),a=u.state.lights;if(ee&&(te||e!==z)){var o=e===z&&n.id===O;q.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,r,o)}n.version===r.__version&&(void 0===r.program||n.fog&&r.fog!==t||r.needsLights&&r.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===r.numClippingPlanes||r.numClippingPlanes===q.numPlanes&&r.numIntersection===q.numIntersection||(n.needsUpdate=!0)),n.version!==r.__version&&(Ce(n,t,i),r.__version=n.version);var s,l,A=!1,c=!1,h=!1,f=r.program,v=f.getUniforms(),w=r.shader.uniforms;if(m.useProgram(f.program)&&(A=!0,c=!0,h=!0),n.id!==O&&(O=n.id,c=!0),A||z!==e){if(f.numMultiviewViews>0?ue.updateCameraProjectionMatricesUniform(e,v):v.setValue(d,"projectionMatrix",e.projectionMatrix),p.logarithmicDepthBuffer&&v.setValue(d,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),z!==e&&(z=e,c=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isAMRTBasicMaterial||n.isACFBasicMaterial||n.isAMRTShadowMaterial||n.envMap){var x=v.map.cameraPosition;void 0!==x&&x.setValue(d,ae.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isAMRTBasicMaterial||n.isACFBasicMaterial||n.isShaderMaterial)&&v.setValue(d,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isAMRTBasicMaterial||n.isACFBasicMaterial||n.isShaderMaterial||n.skinning||n.isAMRTShadowMaterial)&&(f.numMultiviewViews>0?ue.updateCameraViewMatricesUniform(e,v):(v.setValue(d,"viewMatrix",e.matrixWorldInverse),v.setValue(d,"viewMatrixR",e.matrixWorldInverseR)))}if(n.skinning){v.setOptional(d,i,"bindMatrix"),v.setOptional(d,i,"bindMatrixInverse");var b=i.skeleton;if(b){var M=b.bones;if(p.floatVertexTextures){if(void 0===b.boneTexture){var C=Math.sqrt(4*M.length);C=et.ceilPowerOfTwo(C),C=Math.max(C,4);var B=new Float32Array(C*C*4);B.set(b.boneMatrices);var E=new Hi(B,C,C,ce,ne);b.boneMatrices=B,b.boneTexture=E,b.boneTextureSize=C}v.setValue(d,"boneTexture",b.boneTexture,y),v.setValue(d,"boneTextureSize",b.boneTextureSize)}else v.setOptional(d,b,"boneMatrices")}}return(c||r.receiveShadow!==i.receiveShadow)&&(r.receiveShadow=i.receiveShadow,v.setValue(d,"receiveShadow",i.receiveShadow)),c&&(v.setValue(d,"toneMappingExposure",L.toneMappingExposure),v.setValue(d,"toneMappingWhitePoint",L.toneMappingWhitePoint),r.needsLights&&(l=h,(s=w).ambientLightColor.needsUpdate=l,s.lightProbe.needsUpdate=l,s.directionalLights.needsUpdate=l,s.pointLights.needsUpdate=l,s.spotLights.needsUpdate=l,s.rectAreaLights.needsUpdate=l,s.hemisphereLights.needsUpdate=l),t&&n.fog&&function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}(w,t),n.isMeshBasicMaterial?Ee(w,n):n.isMeshLambertMaterial?(Ee(w,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(Ee(w,n),n.isMeshToonMaterial?function(e,t){Se(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(w,n):Se(w,n)):n.isMeshStandardMaterial?(Ee(w,n),n.isMeshPhysicalMaterial?function(e,t){Te(e,t),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen);t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate());e.transparency.value=t.transparency}(w,n):Te(w,n)):n.isAMRTBasicMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.emissive.value.copy(t.emissive),e.smoothness.value=t.smoothness,e.metalness.value=t.metallic,e.reflectivity.value=t.reflectivity,e.transparency.value=t.transparency,e.envYMatrix.value.copy(t.envYMatrix),e.reflecYMatrix.value.copy(t.reflecYMatrix),e.clippingTransparent.value=t.clippingTransparent,e.planeOffset.value=t.planeOffset,t.albedo&&(e.albedo.value=t.albedo,!0===t.albedo.matrixAutoUpdate&&t.albedo.updateMatrix(),e.albedoUVTransform.value.copy(t.albedo.matrix));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value=t.normalScale,!0===t.normalMap.matrixAutoUpdate&&t.normalMap.updateMatrix(),e.normalUVTransform.value.copy(t.normalMap.matrix));t.normalMap2&&(e.normalMap2.value=t.normalMap2,e.normalScale2.value=t.normalScale2,!0===t.normalMap2.matrixAutoUpdate&&t.normalMap2.updateMatrix(),e.normal2UVTransform.value.copy(t.normalMap2.matrix));t.metallicMap&&(e.metallicMap.value=t.metallicMap,!0===t.metallicMap.matrixAutoUpdate&&t.metallicMap.updateMatrix(),e.metalUVTransform.value.copy(t.metallicMap.matrix));t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,!0===t.roughnessMap.matrixAutoUpdate&&t.roughnessMap.updateMatrix(),e.roughUVTransform.value.copy(t.roughnessMap.matrix));t.aoMap&&(e.aoMap.value=t.aoMap,e.aoScale.value=t.aoScale,!0===t.aoMap.matrixAutoUpdate&&t.aoMap.updateMatrix(),e.aoUVTransform.value.copy(t.aoMap.matrix));t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap,!0===t.emissiveMap.matrixAutoUpdate&&t.emissiveMap.updateMatrix(),e.emissiveUVTransform.value.copy(t.emissiveMap.matrix));t.reflectMap&&(e.reflectMap.value=t.reflectMap,e.reflectIntensity.value=t.reflectIntensity);e.cutout.value=t.cutout,t.envMap&&(e.envMap.value=t.envMap,e.envMapIntensity.value=t.envMapIntensity,e.flipEnvMap.value=t.envMap.isCubeTexture?-1:1,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=8);t.alphaMap&&(e.alphaMap.value=t.alphaMap,!0===t.alphaMap.matrixAutoUpdate&&t.alphaMap.updateMatrix(),e.alphaUVTransform.value.copy(t.alphaMap.matrix));t.dissolveMap&&(e.dissolveMap.value=t.dissolveMap,e.dissolveRatio.value=t.dissolveRatio,e.dissolveColor.value=t.dissolveColor,!0===t.dissolveMap.matrixAutoUpdate&&t.dissolveMap.updateMatrix());t.ssrTexture&&(e.ssrTexture.value=t.ssrTexture,e.ssrTextureMatrix.value=t.ssrTextureMatrix,e.maxDistance.value=t.maxDistance,e.ssrOpacity.value=t.ssrOpacity,e.fresnelCoe.value=t.fresnelCoe,e.virtualCameraNear.value=t.virtualCameraNear,e.virtualCameraFar.value=t.virtualCameraFar,e.virtualCameraMatrixWorld.value=t.virtualCameraMatrixWorld,e.virtualCameraProjectionMatrix.value=t.virtualCameraProjectionMatrix,e.virtualCameraProjectionMatrixInverse.value=t.virtualCameraProjectionMatrixInverse,e.resolution.value=t.resolution,e.tDepth.value=t.depthTexture,!0===t.ssrTexture.matrixAutoUpdate&&t.ssrTexture.updateMatrix())}(w,n):n.isAMRTShadowMaterial?function(e,t){e.color.value=t.color,e.shadowPlane.value=t.shadowPlane,e.lightDirection.value=t.lightDirection,e.shadowLength.value=t.shadowLength,e.center.value=t.center,e.shadowStrength.value=t.shadowStrength}(w,n):n.isMeshMatcapMaterial?(Ee(w,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(w,n)):n.isMeshDepthMaterial?(Ee(w,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(Ee(w,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(w,n)):n.isMeshNormalMaterial?(Ee(w,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(w,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(w,n)):n.isPointsMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*X,e.scale.value=.5*W,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial?(w.color.value.copy(n.color),w.opacity.value=n.opacity):n.isACFBasicMaterial&&(n.color&&w.diffuse.value.copy(n.color),n.map&&(w.map.value=n.map)),void 0!==w.ltc_1&&(w.ltc_1.value=Yi.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=Yi.LTC_2),sa.upload(d,r.uniformsList,w,y),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(sa.upload(d,r.uniformsList,w,y),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&v.setValue(d,"center",i.center),f.numMultiviewViews>0?ue.updateObjectMatricesUniforms(i,e,v):(v.setValue(d,"modelViewMatrix",i.modelViewMatrix),v.setValue(d,"normalMatrix",i.normalMatrix)),v.setValue(d,"modelMatrix",i.matrixWorld),f}function Ee(e,t){var n;e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=g.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function Se(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Te(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}ye.setAnimationLoop((function(e){he.isPresenting()||ge&&ge(e)})),"undefined"!=typeof window&&ye.setContext(window),this.setAnimationLoop=function(e){ge=e,he.setAnimationLoop(e),ye.start()},this.render=function(e,t){var n,i;if(void 0!==arguments[2]&&(console.warn("the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("the forceClear argument has been removed. Use .clear() instead."),i=arguments[3]),t&&t.isCamera){if(!F){N.geometry=null,N.program=null,N.wireframe=!1,O=-1,z=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),he.enabled&&he.isPresenting()&&(t=he.getCamera(t)),(u=B.get(e,t)).init(),e.onBeforeRender(L,e,t,n||D),re.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),J.setFromMatrix(re),te=this.localClippingEnabled,ee=q.init(this.clippingPlanes,te,t),(h=C.get(e,t)).init(),xe(e,t,0,L.sortObjects),!0===L.sortObjects&&h.sort(),ee&&q.beginShadows();var r=u.state.shadowsArray;de.render(r,e,t),u.setupLights(t),ee&&q.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),he.enabled&&ue.isAvailable()&&ue.attachCamera(t),E.render(h,e,t,i);var a=h.opaque,o=h.transparent;if(e.overrideMaterial){var s=e.overrideMaterial;a.length&&be(a,e,t,s),o.length&&be(o,e,t,s)}else a.length&&be(a,e,t),o.length&&be(o,e,t);e.onAfterRender(L,e,t),null!==D&&(y.updateRenderTargetMipmap(D),y.updateMultisampleRenderTarget(D)),m.buffers.depth.setTest(!0),m.buffers.depth.setMask(!0),m.buffers.color.setMask(!0),m.setPolygonOffset(!1),he.enabled&&(ue.isAvailable()&&ue.detachCamera(t),he.submitFrame()),h=null,u=null}}else console.error("camera is not an instance of Camera.")},this.renderArray=function(e,t,n){if(!F){N.geometry=null,N.program=null,N.wireframe=!1,O=-1,z=null,null===n.parent&&n.updateMatrixWorld(),(u=B.get(t,n)).init(),re.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),J.setFromMatrix(re),te=this.localClippingEnabled,ee=q.init(this.clippingPlanes,te,n),(h=C.get(t,n)).init();for(var i=0;i=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&d.readPixels(t,n,i,r,I.convert(c),I.convert(h),a):console.error("readPixels from renderTarget failed. Framebuffer not complete.")}finally{l&&d.bindFramebuffer(d.FRAMEBUFFER,R)}}}else console.error("renderTarget is not WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,n){void 0===n&&(n=0);var i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i),o=I.convert(t.format);y.setTexture2D(t,0),d.copyTexImage2D(d.TEXTURE_2D,n,o,e.x,e.y,r,a,0),m.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i){var r=t.image.width,a=t.image.height,o=I.convert(n.format),s=I.convert(n.type);y.setTexture2D(n,0),t.isDataTexture?d.texSubImage2D(d.TEXTURE_2D,i||0,e.x,e.y,r,a,o,s,t.image.data):d.texSubImage2D(d.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image),m.unbindTexture()},this.initTexture=function(e){y.setTexture2D(e,0),m.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function eo(e,t){this.name="",this.color=new Fn(e),this.density=void 0!==t?t:25e-5}function to(e,t,n){this.name="",this.color=new Fn(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function no(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Xe,this.updateRange={offset:0,count:-1},this.version=0}function io(e,t,n,i){this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===i}function ro(e){On.call(this),this.type="SpriteMaterial",this.color=new Fn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}Object.assign(Ja.prototype,Je.prototype),Object.assign(qa.prototype,Je.prototype),Object.assign(eo.prototype,{isFogExp2:!0,clone:function(){return new eo(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(to.prototype,{isFog:!0,clone:function(){return new to(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(no.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(no.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(var i=0,r=this.stride;ie.far||t.push({distance:s,point:ao.clone(),uv:Tn.getUV(ao,ho,uo,fo,po,mo,vo,new tt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return zt.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var wo=new at,xo=new at;function bo(){zt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}bo.prototype=Object.assign(Object.create(zt.prototype),{constructor:bo,isLOD:!0,copy:function(e){zt.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n0){for(var n=1,i=t.length;n0){wo.setFromMatrixPosition(this.matrixWorld);var n=e.ray.origin.distanceTo(wo);this.getObjectForDistance(n).raycast(e,t)}},update:function(e){var t=this.levels;if(t.length>1){wo.setFromMatrixPosition(e.matrixWorld),xo.setFromMatrixPosition(this.matrixWorld);var n=wo.distanceTo(xo);t[0].object.visible=!0;for(var i=1,r=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(;i=n.count)&&this.geometry.attributes.skinIndex_4){Co.set(n.array[3*e],n.array[3*e+1],n.array[3*e+2]);var i=t;i||(i=new at(0,0,0)),Co.applyMatrix4(this.bindMatrix);var r=this.geometry.attributes.skinIndex_4.array,a=this.geometry.attributes.skinWeight_4.array;return i.copy(this.getVertexByWeight(r[4*e],a[4*e],Co)),i.add(this.getVertexByWeight(r[4*e+1],a[4*e+1],Co)),i.add(this.getVertexByWeight(r[4*e+2],a[4*e+2],Co)),i.add(this.getVertexByWeight(r[4*e+3],a[4*e+3],Co)),this.boneNum>4&&(r=this.geometry.attributes.skinIndex_8.array,a=this.geometry.attributes.skinWeight_8.array,i.add(this.getVertexByWeight(r[4*e],a[4*e],Co)),i.add(this.getVertexByWeight(r[4*e+1],a[4*e+1],Co)),i.add(this.getVertexByWeight(r[4*e+2],a[4*e+2],Co)),i.add(this.getVertexByWeight(r[4*e+3],a[4*e+3],Co))),i.applyMatrix4(this.bindMatrixInverse),i}},getVertexByWeight:function(e,t,n){if(e=3?n.getInverse(this.bones[e].offsetMatrix):n.getInverse(this.bones[e].matrixWorld))}else this.bones[e].version>=3?n.getInverse(this.bones[e].offsetMatrix):n.getInverse(this.bones[e].matrixWorld);this.boneInverses.push(n)}},pose:function(){var e,t,n;for(t=0,n=this.bones.length;t0&&(Fo[0].instanceId=r,Fo[0].object=this,t.push(Fo[0]),Fo.length=0)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,16*e),0===e?(this.geometry.boundingBox.copy((new tn).copy(Po).applyMatrix4(t)),null==this.geometry.boundingSphere&&(this.geometry.boundingSphere=new an)):this.geometry.boundingBox.union((new tn).copy(Po).applyMatrix4(t)),this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere)},updateMorphTargets:function(){}}),Do.prototype=Object.create(On.prototype),Do.prototype.constructor=Do,Do.prototype.isLineBasicMaterial=!0,Do.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this};var Ro=new at,Oo=new at,No=new bt,zo=new dn,Qo=new an;function Go(e,t,n){1===n&&console.error("Line: parameter LinePieces no longer supported. Use LineSegments instead."),zt.call(this),this.type="Line",this.geometry=void 0!==e?e:new si,this.material=void 0!==t?t:new Do({color:16777215*Math.random()})}Go.prototype=Object.assign(Object.create(zt.prototype),{constructor:Go,isLine:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[0],i=1,r=t.count;io))c.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(c))e.far||t.push({distance:x,point:A.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}else for(p=0,m=d.length/3-1;po))c.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(c))e.far||t.push({distance:x,point:A.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}}else if(i.isGeometry){var y=i.vertices,w=y.length;for(p=0;po))c.applyMatrix4(this.matrixWorld),(x=e.ray.origin.distanceTo(c))e.far||t.push({distance:x,point:A.clone().applyMatrix4(this.matrixWorld),index:p,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Ho=new at,Vo=new at;function jo(e,t){Go.call(this,e,t),this.type="LineSegments"}function Wo(e,t){Go.call(this,e,t),this.type="LineLoop"}function Xo(e){On.call(this),this.type="PointsMaterial",this.color=new Fn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}jo.prototype=Object.assign(Object.create(Go.prototype),{constructor:jo,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[],i=0,r=t.count;ir.far)return;a.push({distance:A,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:o})}}function es(e,t,n,i,r,a,o,s,l,A,c,h){ht.call(this,null,a,o,s,l,A,i,r,c,h),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function ts(e,t,n,i,r,a,o,s,l){ht.call(this,e,t,n,i,r,a,o,s,l),this.needsUpdate=!0}function ns(e,t,n,i,r,a,o,s,l,A){if((A=void 0!==A?A:fe)!==fe&&A!==pe)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&A===fe&&(n=ee),void 0===n&&A===pe&&(n=se),ht.call(this,null,i,r,a,o,s,A,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:X,this.minFilter=void 0!==s?s:X,this.flipY=!1,this.generateMipmaps=!1}function is(e){si.call(this),this.type="WireframeGeometry";var t,n,i,r,a,o,s,l,A,c,h=[],u=[0,0],d={},f=["a","b","c"];if(e&&e.isGeometry){var p=e.faces;for(t=0,i=p.length;t=0?(e(v-A,m,u),d.subVectors(h,u)):(e(v+A,m,u),d.subVectors(u,h)),m-A>=0?(e(v,m-A,u),f.subVectors(h,u)):(e(v,m+A,u),f.subVectors(u,h)),c.crossVectors(d,f).normalize(),s.push(c.x,c.y,c.z),l.push(v,m)}}for(i=0;i.9&&o<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Yn(r,3)),this.setAttribute("normal",new Yn(r.slice(),3)),this.setAttribute("uv",new Yn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function ls(e,t){Li.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new As(e,t)),this.mergeVertices()}function As(e,t){ss.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function cs(e,t){Li.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new hs(e,t)),this.mergeVertices()}function hs(e,t){ss.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function us(e,t){Li.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ds(e,t)),this.mergeVertices()}function ds(e,t){var n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];ss.call(this,i,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function fs(e,t){Li.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new ps(e,t)),this.mergeVertices()}function ps(e,t){var n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i];ss.call(this,r,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function ms(e,t,n,i,r,a){Li.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},void 0!==a&&console.warn("TubeGeometry: taper has been removed.");var o=new vs(e,t,n,i,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function vs(e,t,n,i,r){si.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},t=t||64,n=n||1,i=i||8,r=r||!1;var a=e.computeFrenetFrames(t,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,l=new at,A=new at,c=new tt,h=new at,u=[],d=[],f=[],p=[];function m(r){h=e.getPointAt(r/t,h);var o=a.normals[r],c=a.binormals[r];for(s=0;s<=i;s++){var f=s/i*Math.PI*2,p=Math.sin(f),m=-Math.cos(f);A.x=m*o.x+p*c.x,A.y=m*o.y+p*c.y,A.z=m*o.z+p*c.z,A.normalize(),d.push(A.x,A.y,A.z),l.x=h.x+n*A.x,l.y=h.y+n*A.y,l.z=h.z+n*A.z,u.push(l.x,l.y,l.z)}}!function(){for(o=0;o0){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0&&console.error("Points.updateMorphTargets() does not support Geometry. Use BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),es.prototype=Object.create(ht.prototype),es.prototype.constructor=es,es.prototype.isCompressedTexture=!0,ts.prototype=Object.create(ht.prototype),ts.prototype.constructor=ts,ts.prototype.isCanvasTexture=!0,ns.prototype=Object.create(ht.prototype),ns.prototype.constructor=ns,ns.prototype.isDepthTexture=!0,is.prototype=Object.create(si.prototype),is.prototype.constructor=is,rs.prototype=Object.create(Li.prototype),rs.prototype.constructor=rs,as.prototype=Object.create(si.prototype),as.prototype.constructor=as,os.prototype=Object.create(Li.prototype),os.prototype.constructor=os,ss.prototype=Object.create(si.prototype),ss.prototype.constructor=ss,ls.prototype=Object.create(Li.prototype),ls.prototype.constructor=ls,As.prototype=Object.create(ss.prototype),As.prototype.constructor=As,cs.prototype=Object.create(Li.prototype),cs.prototype.constructor=cs,hs.prototype=Object.create(ss.prototype),hs.prototype.constructor=hs,us.prototype=Object.create(Li.prototype),us.prototype.constructor=us,ds.prototype=Object.create(ss.prototype),ds.prototype.constructor=ds,fs.prototype=Object.create(Li.prototype),fs.prototype.constructor=fs,ps.prototype=Object.create(ss.prototype),ps.prototype.constructor=ps,ms.prototype=Object.create(Li.prototype),ms.prototype.constructor=ms,vs.prototype=Object.create(si.prototype),vs.prototype.constructor=vs,vs.prototype.toJSON=function(){var e=si.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},gs.prototype=Object.create(Li.prototype),gs.prototype.constructor=gs,ys.prototype=Object.create(si.prototype),ys.prototype.constructor=ys,ws.prototype=Object.create(Li.prototype),ws.prototype.constructor=ws,xs.prototype=Object.create(si.prototype),xs.prototype.constructor=xs;var bs=function(e,t,n){n=n||2;var i,r,a,o,s,l,A,c=t&&t.length,h=c?t[0]*n:e.length,u=Ms(e,0,h,n,!0),d=[];if(!u||u.next===u.prev)return d;if(c&&(u=function(e,t,n,i){var r,a,o,s=[];for(r=0,a=t.length;r80*n){i=a=e[0],r=o=e[1];for(var f=n;fa&&(a=s),l>o&&(o=l);A=0!==(A=Math.max(a-i,o-r))?1/A:0}return Bs(u,d,n,i,r,A),d};function Ms(e,t,n,i,r){var a,o;if(r===function(e,t,n,i){for(var r=0,a=t,o=n-i;a0)for(a=t;a=t;a-=i)o=Qs(a,e[a],e[a+1],o);return o&&Rs(o,o.next)&&(Gs(o),o=o.next),o}function Cs(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!Rs(i,i.next)&&0!==Ds(i.prev,i,i.next))i=i.next;else{if(Gs(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Bs(e,t,n,i,r,a,o){if(e){!o&&a&&function(e,t,n,i){var r=e;do{null===r.z&&(r.z=Fs(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,n,i,r,a,o,s,l,A=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,A*=2}while(o>1)}(r)}(e,i,r,a);for(var s,l,A=e;e.prev!==e.next;)if(s=e.prev,l=e.next,a?Ss(e,i,r,a):Es(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Gs(e),e=l.next,A=l.next;else if((e=l)===A){o?1===o?Bs(e=Ts(e,t,n),t,n,i,r,a,2):2===o&&_s(e,t,n,i,r,a):Bs(Cs(e),t,n,i,r,a,1);break}}}function Es(e){var t=e.prev,n=e,i=e.next;if(Ds(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(Ps(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Ds(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Ss(e,t,n,i){var r=e.prev,a=e,o=e.next;if(Ds(r,a,o)>=0)return!1;for(var s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,c=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,h=Fs(s,l,t,n,i),u=Fs(A,c,t,n,i),d=e.prevZ,f=e.nextZ;d&&d.z>=h&&f&&f.z<=u;){if(d!==e.prev&&d!==e.next&&Ps(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ds(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==e.prev&&f!==e.next&&Ps(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ds(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d!==e.prev&&d!==e.next&&Ps(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Ds(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=u;){if(f!==e.prev&&f!==e.next&&Ps(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Ds(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Ts(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!Rs(r,a)&&Os(r,i,i.next,a)&&Ns(r,a)&&Ns(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Gs(i),Gs(i.next),i=e=a),i=i.next}while(i!==e);return i}function _s(e,t,n,i,r,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Us(o,s)){var l=zs(o,s);return o=Cs(o,o.next),l=Cs(l,l.next),Bs(o,t,n,i,r,a),void Bs(l,t,n,i,r,a)}s=s.next}o=o.next}while(o!==e)}function Is(e,t){return e.x-t.x}function Ls(e,t){if(t=function(e,t){var n,i=t,r=e.x,a=e.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=c&&r!==i.x&&Ps(an.x)&&Ns(i,e)&&(n=i,u=l),i=i.next;return n}(e,t),t){var n=zs(t,e);Cs(n,n.next)}}function Fs(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ks(e){var t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function Us(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Os(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&Ns(e,t)&&Ns(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)}function Ds(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Rs(e,t){return e.x===t.x&&e.y===t.y}function Os(e,t,n,i){return!!(Rs(e,n)&&Rs(t,i)||Rs(e,i)&&Rs(n,t))||Ds(e,t,n)>0!=Ds(e,t,i)>0&&Ds(n,i,e)>0!=Ds(n,i,t)>0}function Ns(e,t){return Ds(e.prev,e,e.next)<0?Ds(e,t,e.next)>=0&&Ds(e,e.prev,t)>=0:Ds(e,t,e.prev)<0||Ds(e,e.next,t)<0}function zs(e,t){var n=new Hs(e.i,e.x,e.y),i=new Hs(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Qs(e,t,n,i){var r=new Hs(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Gs(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Hs(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Vs={area:function(e){for(var t=e.length,n=0,i=t-1,r=0;r2&&e[t-1].equals(e[0])&&e.pop()}function Ws(e,t){for(var n=0;nNumber.EPSILON){var u=Math.sqrt(c),d=Math.sqrt(l*l+A*A),f=t.x-s/u,p=t.y+o/u,m=((n.x-A/d-f)*A-(n.y+l/d-p)*l)/(o*A-s*l),v=(i=f+o*m-e.x)*i+(r=p+s*m-e.y)*r;if(v<=2)return new tt(i,r);a=Math.sqrt(v/2)}else{var g=!1;o>Number.EPSILON?l>Number.EPSILON&&(g=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(g=!0):Math.sign(s)===Math.sign(A)&&(g=!0),g?(i=-s,r=o,a=Math.sqrt(c)):(i=o,r=s,a=Math.sqrt(c/2))}return new tt(i/a,r/a)}for(var z=[],Q=0,G=_.length,H=G-1,V=Q+1;Q=0;L--){for(k=L/d,P=c*Math.cos(k*Math.PI/2),F=h*Math.sin(k*Math.PI/2)+u,Q=0,G=_.length;Q=0;){n=Q,(i=Q-1)<0&&(i=e.length-1);var r=0,a=s+2*d;for(r=0;r0)&&f.push(b,M,B),(l!==n-1||A0&&v(!0),t>0&&v(!1)),this.setIndex(A),this.setAttribute("position",new Yn(c,3)),this.setAttribute("normal",new Yn(h,3)),this.setAttribute("uv",new Yn(u,2))}function hl(e,t,n,i,r,a,o){Al.call(this,0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function ul(e,t,n,i,r,a,o){cl.call(this,0,e,t,n,i,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function dl(e,t,n,i){Li.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new fl(e,t,n,i)),this.mergeVertices()}function fl(e,t,n,i){si.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,a,o=[],s=[],l=[],A=[],c=new at,h=new tt;for(s.push(0,0,0),l.push(0,0,1),A.push(.5,.5),a=0,r=3;a<=t;a++,r+=3){var u=n+a/t*i;c.x=e*Math.cos(u),c.y=e*Math.sin(u),s.push(c.x,c.y,c.z),l.push(0,0,1),h.x=(s[r]/e+1)/2,h.y=(s[r+1]/e+1)/2,A.push(h.x,h.y)}for(r=1;r<=t;r++)o.push(r,r+1,0);this.setIndex(o),this.setAttribute("position",new Yn(s,3)),this.setAttribute("normal",new Yn(l,3)),this.setAttribute("uv",new Yn(A,2))}Js.prototype=Object.create(Li.prototype),Js.prototype.constructor=Js,qs.prototype=Object.create(Ys.prototype),qs.prototype.constructor=qs,$s.prototype=Object.create(Li.prototype),$s.prototype.constructor=$s,el.prototype=Object.create(si.prototype),el.prototype.constructor=el,tl.prototype=Object.create(Li.prototype),tl.prototype.constructor=tl,nl.prototype=Object.create(si.prototype),nl.prototype.constructor=nl,il.prototype=Object.create(Li.prototype),il.prototype.constructor=il,rl.prototype=Object.create(si.prototype),rl.prototype.constructor=rl,al.prototype=Object.create(Li.prototype),al.prototype.constructor=al,al.prototype.toJSON=function(){var e=Li.prototype.toJSON.call(this);return sl(this.parameters.shapes,e)},ol.prototype=Object.create(si.prototype),ol.prototype.constructor=ol,ol.prototype.toJSON=function(){var e=si.prototype.toJSON.call(this);return sl(this.parameters.shapes,e)},ll.prototype=Object.create(si.prototype),ll.prototype.constructor=ll,Al.prototype=Object.create(Li.prototype),Al.prototype.constructor=Al,cl.prototype=Object.create(si.prototype),cl.prototype.constructor=cl,hl.prototype=Object.create(Al.prototype),hl.prototype.constructor=hl,ul.prototype=Object.create(cl.prototype),ul.prototype.constructor=ul,dl.prototype=Object.create(Li.prototype),dl.prototype.constructor=dl,fl.prototype=Object.create(si.prototype),fl.prototype.constructor=fl;var pl=Object.freeze({__proto__:null,WireframeGeometry:is,ParametricGeometry:rs,ParametricBufferGeometry:as,TetrahedronGeometry:ls,TetrahedronBufferGeometry:As,OctahedronGeometry:cs,OctahedronBufferGeometry:hs,IcosahedronGeometry:us,IcosahedronBufferGeometry:ds,DodecahedronGeometry:fs,DodecahedronBufferGeometry:ps,PolyhedronGeometry:os,PolyhedronBufferGeometry:ss,TubeGeometry:ms,TubeBufferGeometry:vs,TorusKnotGeometry:gs,TorusKnotBufferGeometry:ys,TorusGeometry:ws,TorusBufferGeometry:xs,TextGeometry:Js,TextBufferGeometry:qs,SphereGeometry:$s,SphereBufferGeometry:el,RingGeometry:tl,RingBufferGeometry:nl,PlaneGeometry:qi,PlaneBufferGeometry:$i,LatheGeometry:il,LatheBufferGeometry:rl,ShapeGeometry:al,ShapeBufferGeometry:ol,ExtrudeGeometry:Xs,ExtrudeBufferGeometry:Ys,EdgesGeometry:ll,ConeGeometry:hl,ConeBufferGeometry:ul,CylinderGeometry:Al,CylinderBufferGeometry:cl,CircleGeometry:dl,CircleBufferGeometry:fl,BoxGeometry:Fi,BoxBufferGeometry:ki});function ml(e){On.call(this),this.type="ShadowMaterial",this.color=new Fn(0),this.transparent=!0,this.setValues(e)}function vl(e){Ri.call(this,e),this.type="RawShaderMaterial"}function gl(e){On.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Fn(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function yl(e){gl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new tt(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(e)}function wl(e){On.call(this),this.type="MeshPhongMaterial",this.color=new Fn(16777215),this.specular=new Fn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function xl(e){wl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function bl(e){On.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ml(e){On.call(this),this.type="MeshLambertMaterial",this.color=new Fn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Cl(e){On.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Fn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new tt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Bl(e){Do.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function El(e){On.call(this),this.defines={STANDARD:""},this.type="AMRTBasicMaterial",this.color=new Fn(16777215),this.albedo=null,this.albedoUV=0,this.normalMap=null,this.normalScale=1,this.normalMap2=null,this.normalScale2=1,this.metallicMap=null,this.metallic=0,this.roughnessMap=null,this.smoothness=0,this.aoMap=null,this.aoScale=1,this.aoUV=0,this.emissive=new Fn(0),this.emissiveMap=null,this.emissiveUV=0,this.reflectMap=null,this.reflectIntensity=0,this.cutout=.5,this.reflectivity=1,this.transparency=0,this.opacity=1,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.vertexTangents=!0,this.normalMapType=0,this.envRotateY=0,this.envYMatrix=new lt,this.reflectRotateY=0,this.reflecYMatrix=new lt,this.dissolveMap=null,this.dissolveRatio=0,this.dissolveColor=new Fn(16774921),this.ssrTextureMatrix=new bt,this.ssrTexture=null,this.maxDistance=10,this.ssrOpacity=1,this.fresnelCoe=0,this.depthTexture=null,this.planeOffset=0,this.virtualCameraNear=.1,this.virtualCameraFar=1e3,this.virtualCameraMatrixWorld=new bt,this.virtualCameraProjectionMatrix=new bt,this.virtualCameraProjectionMatrixInverse=new bt,this.resolution=new tt,this.setValues(e),this.__defineSetter__("envRotateY",(function(e){this.envYMatrix=(new lt).rotateY(e)})),this.__defineSetter__("reflectRotateY",(function(e){this.reflecYMatrix=(new lt).rotateY(e)}))}function Sl(e){On.call(this),this.type="AMRTShadowMaterial",this.color=new Fn(0),this.shadowPlane=new vn(new at(0,-1,0),0),this.lightDirection=new at(-1,-1,-1),this.shadowLength=1,this.center=new at(0,0,0),this.shadowStrength=1,this.skinning=!1,this.morphTargets=!1,this.transparent=!0,this.depthWrite=!1,this.stencilWrite=!0,this.stencilRef=0,this.stencilFunc=514,this.stencilFail=We,this.stencilZFail=We,this.stencilZPass=7682,this.setValues(e)}ml.prototype=Object.create(On.prototype),ml.prototype.constructor=ml,ml.prototype.isShadowMaterial=!0,ml.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this},vl.prototype=Object.create(Ri.prototype),vl.prototype.constructor=vl,vl.prototype.isRawShaderMaterial=!0,gl.prototype=Object.create(On.prototype),gl.prototype.constructor=gl,gl.prototype.isMeshStandardMaterial=!0,gl.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},yl.prototype=Object.create(gl.prototype),yl.prototype.constructor=yl,yl.prototype.isMeshPhysicalMaterial=!0,yl.prototype.copy=function(e){return gl.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearcoat=e.clearcoat,this.clearcoatRoughness=e.clearcoatRoughness,e.sheen?this.sheen=(this.sheen||new Fn).copy(e.sheen):this.sheen=null,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.transparency=e.transparency,this},wl.prototype=Object.create(On.prototype),wl.prototype.constructor=wl,wl.prototype.isMeshPhongMaterial=!0,wl.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},xl.prototype=Object.create(wl.prototype),xl.prototype.constructor=xl,xl.prototype.isMeshToonMaterial=!0,xl.prototype.copy=function(e){return wl.prototype.copy.call(this,e),this.gradientMap=e.gradientMap,this},bl.prototype=Object.create(On.prototype),bl.prototype.constructor=bl,bl.prototype.isMeshNormalMaterial=!0,bl.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ml.prototype=Object.create(On.prototype),Ml.prototype.constructor=Ml,Ml.prototype.isMeshLambertMaterial=!0,Ml.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Cl.prototype=Object.create(On.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isMeshMatcapMaterial=!0,Cl.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Bl.prototype=Object.create(Do.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isLineDashedMaterial=!0,Bl.prototype.copy=function(e){return Do.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},El.prototype=Object.create(On.prototype),El.prototype.constructor=El,El.prototype.isAMRTBasicMaterial=!0,El.prototype.clone=function(){return(new this.constructor).copy(this)},El.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.albedo=e.albedo,this.albedoUV=e.albedoUV,this.normalMap=e.normalMap,this.normalScale=e.normalScale,this.normalMap2=e.normalMap2,this.normalScale2=e.normalScale2,this.metallicMap=e.metallicMap,this.metallic=e.metallic,this.roughnessMap=e.roughnessMap,this.smoothness=e.smoothness,this.aoMap=e.aoMap,this.aoScale=e.aoScale,this.aoUV=e.aoUV,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveUV=e.emissiveUV,this.reflectMap=e.reflectMap,this.reflectIntensity=e.reflectIntensity,this.cutout=e.cutout,this.reflectivity=e.reflectivity,this.transparency=e.transparency,this.opacity=e.opacity,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.vertexTangents=e.vertexTangents,this.normalMapType=e.normalMapType,this.envRotateY=e.envRotateY,this.envYMatrix=e.envYMatrix,this.reflectRotateY=e.reflectRotateY,this.reflecYMatrix=e.reflecYMatrix,this},El.prototype.dispose=function(){On.prototype.dispose.call(this),this.albedo&&this.albedo.dispose(),this.metallicMap&&this.metallicMap.dispose(),this.roughnessMap&&this.roughnessMap.dispose(),this.aoMap&&this.aoMap.dispose(),this.emissiveMap&&this.emissiveMap.dispose(),this.reflectMap&&this.reflectMap.dispose(),this.envMap&&this.envMap.dispose()},Object.defineProperty(El.prototype,"alphaMap",{get(){return this._alphaMap||null},set(e){this._alphaMap=e,e&&(this.transparent=!0)}}),Sl.prototype=Object.create(On.prototype),Sl.prototype.constructor=Sl,Sl.prototype.isAMRTShadowMaterial=!0,Sl.prototype.clone=function(){return(new this.constructor).copy(this)},Sl.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.color.copy(e.color),this.shadowPlane=e.shadowPlane.clone(),this.lightDirection.copy(e.lightDirection),this.shadowLength=e.shadowLength,this.shadowStrength=e.shadowStrength,this.center.copy(e.center),this};var Tl=Object.freeze({__proto__:null,ShadowMaterial:ml,SpriteMaterial:ro,RawShaderMaterial:vl,ShaderMaterial:Ri,PointsMaterial:Xo,MeshPhysicalMaterial:yl,MeshStandardMaterial:gl,MeshPhongMaterial:wl,MeshToonMaterial:xl,MeshNormalMaterial:bl,MeshLambertMaterial:Ml,MeshDepthMaterial:Ra,MeshDistanceMaterial:Oa,MeshBasicMaterial:Nn,MeshMatcapMaterial:Cl,LineDashedMaterial:Bl,LineBasicMaterial:Do,AMRTBasicMaterial:El,AMRTShadowMaterial:Sl,Material:On}),_l={arraySlice:function(e,t,n){return _l.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,n=new Array(t),i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){for(var i=e.length,r=new e.constructor(i),a=0,o=0;o!==i;++a)for(var s=n[a]*t,l=0;l!==t;++l)r[o++]=e[s+l];return r},flattenJSON:function(e,t,n,i){for(var r=1,a=e[0];void 0!==a&&void 0===a[i];)a=e[r++];if(void 0!==a){var o=a[i];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[i])&&(t.push(a.time),n.push.apply(n,o)),a=e[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[i])&&(t.push(a.time),o.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{void 0!==(o=a[i])&&(t.push(a.time),n.push(o)),a=e[r++]}while(void 0!==a)}},subclip:function(e,t,n,i,r){r=r||30;var a=e.clone();a.name=t;for(var o=[],s=0;s=i)){c.push(l.times[u]);for(var f=0;fa.tracks[s].times[0]&&(p=a.tracks[s].times[0]);for(s=0;s=r)break e;var s=t[1];e=(r=t[--n-1]))break t}a=n,n=0}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=_l.arraySlice(n,r,a),this.values=_l.arraySlice(this.values,r*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,i=this.values,r=n.length;0===r&&(console.error("KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==r;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==i&&_l.isTypedArray(i)){o=0;for(var l=i.length;o!==l;++o){var A=i[o];if(isNaN(A)){console.error("KeyframeTrack: Value is not a valid number.",this,o,A),e=!1;break}}}return e},optimize:function(){for(var e=this.times,t=this.values,n=this.getValueSize(),i=this.getInterpolation()===Pe,r=1,a=e.length-1,o=1;o0){e[r]=e[a];for(f=a*n,p=r*n,u=0;u!==n;++u)t[p+u]=t[f+u];++r}return r!==e.length&&(this.times=_l.arraySlice(e,0,r),this.values=_l.arraySlice(t,0,r*n)),this},clone:function(){var e=_l.arraySlice(this.times,0),t=_l.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}),Ul.prototype=Object.assign(Object.create(Pl.prototype),{constructor:Ul,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Fe,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Dl.prototype=Object.assign(Object.create(Pl.prototype),{constructor:Dl,ValueTypeName:"color"}),Rl.prototype=Object.assign(Object.create(Pl.prototype),{constructor:Rl,ValueTypeName:"number"}),Ol.prototype=Object.assign(Object.create(Il.prototype),{constructor:Ol,interpolate_:function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=(n-t)/(i-t),A=s+o;s!==A;s+=4)nt.slerpFlat(r,0,a,s-o,a,s,l);return r}}),Nl.prototype=Object.assign(Object.create(Pl.prototype),{constructor:Nl,ValueTypeName:"quaternion",DefaultInterpolation:ke,InterpolantFactoryMethodLinear:function(e){return new Ol(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),zl.prototype=Object.assign(Object.create(Pl.prototype),{constructor:zl,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Fe,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ql.prototype=Object.assign(Object.create(Pl.prototype),{constructor:Ql,ValueTypeName:"vector"}),Object.assign(Gl,{parse:function(e){for(var t=[],n=e.tracks,i=1/(e.fps||1),r=0,a=n.length;r!==a;++r)t.push(Hl(n[r]).scale(i));return new Gl(e.name,e.duration,t)},toJSON:function(e){for(var t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},r=0,a=n.length;r!==a;++r)t.push(Pl.toJSON(n[r]));return i},CreateFromMorphTargetSequence:function(e,t,n,i){for(var r=t.length,a=[],o=0;o1){var A=i[h=l[1]];A||(i[h]=A=[]),A.push(s)}}var c=[];for(var h in i)c.push(Gl.CreateFromMorphTargetSequence(h,i[h],t,n));return c},parseAnimation:function(e,t){if(!e)return console.error("AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var a=[],o=[];_l.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],l=0;l-1&&(e=e.substring(0,e.indexOf("?time="))),this.files[e]=t)},get:function(e){if(!1!==this.enabled)return e.indexOf("?time=")>-1&&(e=e.substring(0,e.indexOf("?time="))),this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Yl={};function Kl(e){Wl.call(this,e)}function Zl(e){Wl.call(this,e)}function Jl(e){Wl.call(this,e)}function ql(e){Wl.call(this,e)}function $l(e){Wl.call(this,e)}function eA(e){Wl.call(this,e)}function tA(e){Wl.call(this,e)}function nA(){this.type="Curve",this.arcLengthDivisions=200}function iA(e,t,n,i,r,a,o,s){nA.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function rA(e,t,n,i,r,a){iA.call(this,e,t,n,n,i,r,a),this.type="ArcCurve"}function aA(){var e=0,t=0,n=0,i=0;function r(r,a,o,s){e=r,t=o,n=-3*r+3*a-2*o-s,i=2*r-2*a+o+s}return{initCatmullRom:function(e,t,n,i,a){r(t,n,a*(n-e),a*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,a,o,s){var l=(t-e)/a-(n-e)/(a+o)+(n-t)/o,A=(n-t)/o-(i-t)/(o+s)+(i-n)/s;r(t,n,l*=o,A*=o)},calc:function(r){var a=r*r;return e+t*r+n*a+i*(a*r)}}}Kl.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Kl,load:function(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var r=this;if(void 0===Yl[e]){var a=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(a){var o=a[1],s=!!a[2],l=a[3];l=decodeURIComponent(l),s&&(l=atob(l));try{var A,c=(this.responseType||"").toLowerCase();switch(c){case"arraybuffer":case"blob":for(var h=new Uint8Array(l.length),u=0;u0||0===e.search(/^data\:image\/jpeg/);r.format=i?Ae:ce,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}),Object.assign(nA.prototype,{getPoint:function(){return console.warn("Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n,i=[],r=this.getPoint(0),a=0;for(i.push(0),n=1;n<=e;n++)a+=(t=this.getPoint(n/e)).distanceTo(r),i.push(a),r=t;return this.cacheArcLengths=i,i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];for(var o,s=0,l=a-1;s<=l;)if((o=i[r=Math.floor(s+(l-s)/2)]-n)<0)s=r+1;else{if(!(o>0)){l=r;break}l=r-1}if(i[r=l]===n)return r/(a-1);var A=i[r];return(r+(n-A)/(i[r+1]-A))/(a-1)},getTangent:function(e){var t=1e-4,n=e-t,i=e+t;n<0&&(n=0),i>1&&(i=1);var r=this.getPoint(n);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,i,r,a=new at,o=[],s=[],l=[],A=new at,c=new bt;for(n=0;n<=e;n++)i=n/e,o[n]=this.getTangentAt(i),o[n].normalize();s[0]=new at,l[0]=new at;var h=Number.MAX_VALUE,u=Math.abs(o[0].x),d=Math.abs(o[0].y),f=Math.abs(o[0].z);for(u<=h&&(h=u,a.set(1,0,0)),d<=h&&(h=d,a.set(0,1,0)),f<=h&&a.set(0,0,1),A.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],A),l[0].crossVectors(o[0],s[0]),n=1;n<=e;n++)s[n]=s[n-1].clone(),l[n]=l[n-1].clone(),A.crossVectors(o[n-1],o[n]),A.length()>Number.EPSILON&&(A.normalize(),r=Math.acos(et.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(c.makeRotationAxis(A,r))),l[n].crossVectors(o[n],s[n]);if(!0===t)for(r=Math.acos(et.clamp(s[0].dot(s[e]),-1,1)),r/=e,o[0].dot(A.crossVectors(s[0],s[e]))>0&&(r=-r),n=1;n<=e;n++)s[n].applyMatrix4(c.makeRotationAxis(o[n],r*n)),l[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:l}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),iA.prototype=Object.create(nA.prototype),iA.prototype.constructor=iA,iA.prototype.isEllipseCurve=!0,iA.prototype.getPoint=function(e,t){for(var n=t||new tt,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(c)/l)+1)*l:0===h&&c===l-1&&(c=l-2,h=1),this.closed||c>0?n=s[(c-1)%l]:(oA.subVectors(s[0],s[1]).add(s[0]),n=oA),i=s[c%l],r=s[(c+1)%l],this.closed||c+2i.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(hA(o,s.x,l.x,A.x,c.x),hA(o,s.y,l.y,A.y,c.y)),n},wA.prototype.copy=function(e){nA.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var r=n[i]-t,a=this.curves[i],o=a.getLength(),s=0===o?0:1-r/o;return a.getPointAt(s)}i++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){nA.prototype.copy.call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t0){var A=l.getPoint(0);A.equals(this.currentPoint)||this.lineTo(A.x,A.y)}this.curves.push(l);var c=l.getPoint(1);return this.currentPoint.copy(c),this},copy:function(e){return bA.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=bA.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return bA.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),CA.prototype=Object.assign(Object.create(MA.prototype),{constructor:CA,getPointsHoles:function(e){for(var t=[],n=0,i=this.holes.length;n0){var a=new $l(new Vl(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0?new Bo(o,s):new Ei(o,s);break;case"InstancedMesh":o=r(e.geometry),s=a(e.material);var l=e.count,A=e.instanceMatrix;(i=new Uo(o,s,l)).instanceMatrix=new zn(new Float32Array(A.array),16);break;case"LOD":i=new bo;break;case"Line":i=new Go(r(e.geometry),a(e.material),e.mode);break;case"LineLoop":i=new Wo(r(e.geometry),a(e.material));break;case"LineSegments":i=new jo(r(e.geometry),a(e.material));break;case"PointCloud":case"Points":i=new qo(r(e.geometry),a(e.material));break;case"Sprite":i=new go(a(e.material));break;case"Group":i=new ja;break;default:i=new zt}if(i.uuid=e.uuid,void 0!==e.name&&(i.name=e.name),void 0!==e.matrix?(i.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(i.matrixAutoUpdate=e.matrixAutoUpdate),i.matrixAutoUpdate&&i.matrix.decompose(i.position,i.quaternion,i.scale)):(void 0!==e.position&&i.position.fromArray(e.position),void 0!==e.rotation&&i.rotation.fromArray(e.rotation),void 0!==e.quaternion&&i.quaternion.fromArray(e.quaternion),void 0!==e.scale&&i.scale.fromArray(e.scale)),void 0!==e.castShadow&&(i.castShadow=e.castShadow),void 0!==e.receiveShadow&&(i.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(i.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(i.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&i.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(i.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.frustumCulled&&(i.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(i.renderOrder=e.renderOrder),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.layers&&(i.layers.mask=e.layers),void 0!==e.drawMode&&i.setDrawMode(e.drawMode),void 0!==e.children)for(var c=e.children,h=0;hNumber.EPSILON){if(A<0&&(o=t[a],l=-l,s=t[r],A=-A),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var c=A*(e.x-o.x)-l*(e.y-o.y);if(0===c)return!0;if(c<0)continue;i=!i}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return i}var r=Vs.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);var o,s,l,A=[];if(1===a.length)return s=a[0],(l=new CA).curves=s.curves,A.push(l),A;var c=!r(a[0].getPoints());c=e?!c:c;var h,u,d=[],f=[],p=[],m=0;f[m]=void 0,p[m]=[];for(var v=0,g=a.length;v1){for(var y=!1,w=[],x=0,b=f.length;x0&&(y||(p=d))}v=0;for(var T=f.length;v0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var a=0;a!==r;++a)e[t+a]=e[n+a]},_slerp:function(e,t,n,i){nt.slerpFlat(e,t,e,t,e,n,i)},_lerp:function(e,t,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*i}}});var bc="\\[\\]\\.:\\/",Mc=new RegExp("[\\[\\]\\.:\\/]","g"),Cc="[^\\[\\]\\.:\\/]",Bc="[^"+bc.replace("\\.","")+"]",Ec=/((?:WC+[\/:])*)/.source.replace("WC",Cc),Sc=/(WCOD+)?/.source.replace("WCOD",Bc),Tc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cc),_c=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cc),Ic=new RegExp("^"+Ec+Sc+Tc+_c+"$"),Lc=["material","materials","bones"];function Fc(e,t,n){var i=n||kc.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function kc(e,t,n){this.path=t,this.parsedPath=n||kc.parseTrackName(t),this.node=kc.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Pc(){this.uuid=et.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function Uc(e,t,n){this._mixer=e,this._clip=t,this._localRoot=n||null;for(var i=t.tracks,r=i.length,a=new Array(r),o={endingStart:Ue,endingEnd:Ue},s=0;s!==r;++s){var l=i[s].createInterpolant(null);a[s]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Le,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Dc(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Rc(e){"string"==typeof e&&(console.warn("Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function Oc(e,t,n){no.call(this,e,t),this.meshPerAttribute=n||1}function Nc(e,t,n,i){this.ray=new dn(e,t),this.near=n||0,this.far=i||1/0,this.camera=null,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function zc(e,t){return e.distance-t.distance}function Qc(e,t,n,i){if(!1!==e.visible&&!e.locked&&(e.raycast(t,n),!0===i))for(var r=e.children,a=0,o=r.length;a=t){var c=t++,h=e[c];n[h.uuid]=A,e[A]=h,n[l]=c,e[c]=s;for(var u=0,d=r;u!==d;++u){var f=i[u],p=f[c],m=f[A];f[A]=p,f[c]=m}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,a=r.length,o=0,s=arguments.length;o!==s;++o){var l=arguments[o],A=l.uuid,c=i[A];if(void 0!==c)if(delete i[A],c0)for(var l=this._interpolants,A=this._propertyBindings,c=0,h=l.length;c!==h;++c)l[c].evaluate(o),A[c].accumulate(i,s)}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,n=this._clip.duration,i=this.loop,r=this._loopCount,a=2202===i;if(0===e)return-1===r?t:a&&1==(1&r)?n-t:t;if(i===Ie){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=n)t=n;else{if(!(t<0)){this.time=t;break e}t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=n||t<0){var o=Math.floor(t/n);t-=n*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?n:0,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=t,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=t;if(a&&1==(1&r))return n-t}return t},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=De,i.endingEnd=De):(i.endingStart=e?this.zeroSlopeAtStart?De:Ue:Re,i.endingEnd=t?this.zeroSlopeAtEnd?De:Ue:Re)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}),Dc.prototype=Object.assign(Object.create(Je.prototype),{constructor:Dc,_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,A=l[s];void 0===A&&(A={},l[s]=A);for(var c=0;c!==r;++c){var h=i[c],u=h.name,d=A[u];if(void 0!==d)a[c]=d;else{if(void 0!==(d=a[c])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,u));continue}var f=t&&t._propertyBindings[c].binding.parsedPath;++(d=new xc(kc.create(n,u,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(d,s,u),a[c]=d}o[c].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(t=new tt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(t=new tt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Vc.copy(e).clamp(this.min,this.max).sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var Wc=new at,Xc=new at;function Yc(e,t){this.start=void 0!==e?e:new at,this.end=void 0!==t?t:new at}function Kc(e){zt.call(this),this.material=e,this.render=function(){}}Object.assign(Yc.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("Line3: .getCenter() target is now required"),e=new at),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("Line3: .delta() target is now required"),e=new at),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("Line3: .at() target is now required"),t=new at),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){Wc.subVectors(e,this.start),Xc.subVectors(this.end,this.start);var n=Xc.dot(Xc),i=Xc.dot(Wc)/n;return t&&(i=et.clamp(i,0,1)),i},closestPointToPoint:function(e,t,n){var i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("Line3: .closestPointToPoint() target is now required"),n=new at),this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Kc.prototype=Object.create(zt.prototype),Kc.prototype.constructor=Kc,Kc.prototype.isImmediateRenderObject=!0;var Zc=new at,Jc=new at,qc=new lt,$c=["a","b","c"];function eh(e,t,n,i){this.object=e,this.size=void 0!==t?t:1;var r=void 0!==n?n:16711680,a=void 0!==i?i:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var l=new si,A=new Yn(2*o*3,3);l.setAttribute("position",A),jo.call(this,l,new Do({color:r,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}eh.prototype=Object.create(jo.prototype),eh.prototype.constructor=eh,eh.prototype.update=function(){this.object.updateMatrixWorld(!0),qc.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,t=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var i=n.vertices,r=n.faces,a=0,o=0,s=r.length;o1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}},Ah.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var ch=new at,hh=new Fn,uh=new Fn;function dh(e,t,n){zt.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var i=new hs(t);i.rotateY(.5*Math.PI),this.material=new Nn({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=2);var r=i.getAttribute("position"),a=new Float32Array(3*r.count);i.setAttribute("color",new zn(a,3)),this.add(new Ei(i,this.material)),this.update()}function fh(e,t){this.lightProbe=e,this.size=t;var n={GAMMA_OUTPUT:""},i=new Ri({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),r=new el(1,32,16);Ei.call(this,r,i),this.onBeforeRender()}function ph(e,t,n,i){e=e||10,t=t||10,n=new Fn(void 0!==n?n:4473924),i=new Fn(void 0!==i?i:8947848);for(var r=t/2,a=e/t,o=e/2,s=[],l=[],A=0,c=0,h=-o;A<=t;A++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var u=A===r?n:i;u.toArray(l,c),c+=3,u.toArray(l,c),c+=3,u.toArray(l,c),c+=3,u.toArray(l,c),c+=3}var d=new si;d.setAttribute("position",new Yn(s,3)),d.setAttribute("color",new Yn(l,3));var f=new Do({vertexColors:2});jo.call(this,d,f)}function mh(e,t,n,i,r,a){e=e||10,t=t||16,n=n||8,i=i||64,r=new Fn(void 0!==r?r:4473924),a=new Fn(void 0!==a?a:8947848);var o,s,l,A,c,h,u,d=[],f=[];for(A=0;A<=t;A++)l=A/t*(2*Math.PI),o=Math.sin(l)*e,s=Math.cos(l)*e,d.push(0,0,0),d.push(o,0,s),u=1&A?r:a,f.push(u.r,u.g,u.b),f.push(u.r,u.g,u.b);for(A=0;A<=n;A++)for(u=1&A?r:a,h=e-e/n*A,c=0;c.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Dh.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Dh,t)}},Rh.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},Rh.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},Rh.prototype.copy=function(e){return zt.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},Rh.prototype.clone=function(){return(new this.constructor).copy(this)},Oh.prototype=Object.create(jo.prototype),Oh.prototype.constructor=Oh;var Nh=function(e){ql.call(this,e),this.type=$};Nh.prototype=Object.assign(Object.create(ql.prototype),{constructor:Nh,parse:function(e){var t=function(e,t){switch(e){case 1:console.error("RGBELoader Read Error: "+(t||""));break;case 2:console.error("RGBELoader Write Error: "+(t||""));break;case 3:console.error("RGBELoader Bad File Format: "+(t||""));break;default:console.error("RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;for(var i=e.pos,r=-1,a=0,o="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));0>(r=s.indexOf("\n"))&&a>16&32768,a=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?r|=((a|=2048)>>114-o)+(a>>113-o&1):(r|=o-112<<10|a>>1,r+=1&a)}return function(e,t,i,r){var a=e[t+3],o=Math.pow(2,a-128)/255;i[r+0]=n(e[t+0]*o),i[r+1]=n(e[t+1]*o),i[r+2]=n(e[t+2]*o)}}(),a=new Uint8Array(e);a.pos=0;var o=function(e){var i,r,a=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,l=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,A={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=e.byteLength||!(i=n(e)))return t(1,"no header found");if(!(r=i.match(/^#\?(\S+)$/)))return t(3,"bad initial token");for(A.valid|=1,A.programtype=r[1],A.string+=i+"\n";!1!==(i=n(e));)if(A.string+=i+"\n","#"!==i.charAt(0)){if((r=i.match(a))&&(A.gamma=parseFloat(r[1],10)),(r=i.match(o))&&(A.exposure=parseFloat(r[1],10)),(r=i.match(s))&&(A.valid|=2,A.format=r[1]),(r=i.match(l))&&(A.valid|=4,A.height=parseInt(r[1],10),A.width=parseInt(r[2],10)),2&A.valid&&4&A.valid)break}else A.comments+=i+"\n";return 2&A.valid?4&A.valid?A:t(3,"missing image size specifier"):t(3,"missing format specifier")}(a);if(-1!==o){var s=o.width,l=o.height,A=function(e,n,i){var r,a,o,s,l,A,c,h,u,d,f,p,m,v=n,g=i;if(v<8||v>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(v!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");if(!(r=new Uint8Array(4*n*i))||!r.length)return t(4,"unable to allocate buffer space");for(a=0,o=0,h=4*v,m=new Uint8Array(4),A=new Uint8Array(h);g>0&&oe.byteLength)return t(1);if(m[0]=e[o++],m[1]=e[o++],m[2]=e[o++],m[3]=e[o++],2!=m[0]||2!=m[1]||(m[2]<<8|m[3])!=v)return t(3,"bad rgbe scanline format");for(c=0;c128)&&(s-=128),0===s||c+s>h)return t(3,"bad scanline data");if(p)for(l=e[o++],u=0;u>8&255]+zh[e>>16&255]+zh[e>>24&255]+"-"+zh[255&t]+zh[t>>8&255]+"-"+zh[t>>16&15|64]+zh[t>>24&255]+"-"+zh[63&n|128]+zh[n>>8&255]+"-"+zh[n>>16&255]+zh[n>>24&255]+zh[255&i]+zh[i>>8&255]+zh[i>>16&255]+zh[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(Gh=e%2147483647),((Gh=16807*Gh%2147483647)-1)/2147483646},degToRad:function(e){return e*Hh.DEG2RAD},radToDeg:function(e){return e*Hh.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){var a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),A=a((t+i)/2),c=o((t+i)/2),h=a((t-i)/2),u=o((t-i)/2),d=a((i-t)/2),f=o((i-t)/2);switch(r){case"XYX":e.set(s*c,l*h,l*u,s*A);break;case"YZY":e.set(l*u,s*c,l*h,s*A);break;case"ZXZ":e.set(l*h,l*u,s*c,s*A);break;case"XZX":e.set(s*c,l*f,l*d,s*A);break;case"YXY":e.set(l*d,s*c,l*f,s*A);break;case"ZYZ":e.set(l*f,l*d,s*c,s*A);break;default:console.warn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};function Vh(e){return void 0===e&&(e=[]),console.warn("MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,e.materials=e,e.clone=function(){return e.slice()},e}function jh(e){console.warn("ClosedSplineCurve3 has been deprecated. Use CatmullRomCurve3 instead."),cA.call(this,e),this.type="catmullrom",this.closed=!0}function Wh(e){console.warn("SplineCurve3 has been deprecated. Use CatmullRomCurve3 instead."),cA.call(this,e),this.type="catmullrom"}function Xh(e){console.warn("Spline has been removed. Use CatmullRomCurve3 instead."),cA.call(this,e),this.type="catmullrom"}nA.create=function(e,t){return console.log("Curve.create() has been deprecated"),e.prototype=Object.create(nA.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(bA.prototype,{createPointsGeometry:function(e){console.warn("CurvePath: .createPointsGeometry() has been removed. Use new Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("CurvePath: .createSpacedPointsGeometry() has been removed. Use new Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("CurvePath: .createGeometry() has been removed. Use new Geometry().setFromPoints( points ) instead.");for(var t=new Li,n=0,i=e.length;nNumber.EPSILON){var u=Math.sqrt(c),d=Math.sqrt(l*l+A*A),f=t.x-s/u,p=t.y+o/u,m=((n.x-A/d-f)*A-(n.y+l/d-p)*l)/(o*A-s*l),v=(i=f+o*m-e.x)*i+(r=p+s*m-e.y)*r;if(v<=2)return new tt(i,r);a=Math.sqrt(v/2)}else{var g=!1;o>Number.EPSILON?l>Number.EPSILON&&(g=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(g=!0):Math.sign(s)===Math.sign(A)&&(g=!0),g?(i=-s,r=o,a=Math.sqrt(c)):(i=o,r=s,a=Math.sqrt(c/2))}return new tt(i/a,r/a)}for(var N=[],z=0,Q=_.length,G=Q-1,H=z+1;z=0;L--){for(k=L/d,P=c*Math.cos(k*Math.PI/2),F=h*Math.sin(k*Math.PI/2)+u,z=0,Q=_.length;z=0;){n=z,(i=z-1)<0&&(i=e.length-1);var r=0,a=s+2*d;for(r=0;r=t&&(f=t-1);var p=e[f];u.push(p[r?2:0]+n),u.push(p[1]+n),u.push(p[r?0:2]+n)}o%2==1&&(o+=2);for(var m=0;mS&&(S=I,l=x,A=b,c=M,h=C);break}}}if(S>0)J(T-6,T-5,T-4,l,A,!0),J(T-3,T-2,T-1,c,h,!1);else{console.log("Error: 没有找到平行边!!!");var k=[];for(_=0;_<3;_++){g=2==_?T-6:T-6+_+1,x=new tt(i[3*(v=T-6+_)],i[3*v+1]),b=new tt(i[3*g],i[3*g+1]);I=(B=new tt(b.x-x.x,b.y-x.y)).length();k.push([I,x,b])}var P=function(e,t){return e[0]t[0]?1:0};k.sort(P),J(T-6,T-5,T-4,k[1][1],k[1][2],!0),k=[];for(L=3;L<6;L++){w=5==L?T-3:T-6+L+1,M=new tt(i[3*(y=T-6+L)],i[3*y+1]),C=new tt(i[3*w],i[3*w+1]),E=new tt(C.x-M.x,C.y-M.y);I=B.length();k.push([I,M,C])}k.sort(P),J(T-3,T-2,T-1,k[1][1],k[1][2],!1)}}}function J(e,t,r,a,o,s){var l=p.generateTopUV(n,i,e,t,r,a,o,s);ee(l[0]),ee(l[1]),ee(l[2])}function q(e,t,r,a){$(e),$(t),$(a),$(t),$(r),$(a);var o=i.length/3,s=p.generateSideWallUV(n,i,o-6,o-3,o-2,o-1);ee(s[0]),ee(s[1]),ee(s[3]),ee(s[1]),ee(s[2]),ee(s[3])}function $(e){i.push(a[3*e+0]),i.push(a[3*e+1]),i.push(a[3*e+2])}function ee(e){r.push(e.x),r.push(e.y)}!function(){var e=i.length/3;if(A){var t=0;Z(T,R,D*t,!0),Z(T,R,D*(t=s+2*d),!1)}else{Z(T,R,0,!0),Z(T,R,D*s,!1)}n.addGroup(e,i.length/3-e,0)}(),function(){var e=i.length/3,t=0;for(Y(_,t),t+=_.length,b=0,M=S.length;b0;(M&&x>Math.PI/2||!M&&xt?1:0}));for(var l=[],A=0;A<2;A++)for(var c=0;c=0&&(h=!0);var f=(u=Math.abs(u))+(d=Math.abs(d)),p=d/f,m=u/f;if(h)return[new tt(t[o[0]]*m+t[o[0]+1]*p,1-t[o[0]+2]),new tt(t[o[1]]*m+t[o[1]+1]*p,1-t[o[1]+2]),new tt(t[o[2]]*m+t[o[2]+1]*p,1-t[o[2]+2]),new tt(t[o[3]]*m+t[o[3]+1]*p,1-t[o[3]+2])];for(c=0;c>2]>>8*(3-i%4)+4&15)+t.charAt(e[i>>2]>>8*(3-i%4)&15);return n}(function(e){for(var t=e,n=Array(80),i=1732584193,r=-271733879,a=-1732584194,o=271733878,s=-1009589776,l=0;l>6),n=new Array(16*t),i=0;i<16*t;i++)n[i]=0;for(i=0;i>2]|=e.charCodeAt(i)<<24-8*(3&i);return n[i>>2]|=128<<24-8*(3&i),n[16*t-1]=8*e.length,n}(e)))}function tu(e,t,n,i){return e<20?t&n|~t&i:e<40?t^n^i:e<60?t&n|t&i|n&i:t^n^i}function nu(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}function iu(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function ru(e,t){return e<>>32-t}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:T}}));var au={};function ou(){}ou.prototype=Object.assign(ou.prototype,{constructor:ou,load:function(e,t,n,i){if(void 0===au[e]){au[e]=[],au[e].push({onLoad:t,onProgress:n,onError:i});var r=new XMLHttpRequest;return r.open("GET",e,!0),r.addEventListener("load",(function(t){var n=this.response,i=au[e];if(delete au[e],200===this.status||0===this.status)for(var a=0,o=i.length;a0&&void 0!==arguments[0]?arguments[0]:{};void 0===e.async&&(e.async=!0);var t=new XMLHttpRequest;if(e.async&&(t.responseType="json"),t.open("POST",e.url,e.async),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.onreadystatechange=function(){4==t.readyState&&200==t.status&&e.onSuccess&&e.onSuccess(t.response)},t.onerror=function(t){e.onFaild&&e.onFaild(t)},t.send(e.body),!e.async)return JSON.parse(t.response)}},{key:"get",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0===e.async&&(e.async=!0);var t=new XMLHttpRequest;if(e.async&&(t.responseType="json"),t.open("GET",e.url,e.async),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.onreadystatechange=function(){4===t.readyState&&200===t.status&&e.onSuccess&&e.onSuccess(t.response)},t.onerror=function(t){e.onFaild&&e.onFaild(t)},t.send(),!e.async)try{return JSON.parse(t.response)}catch(e){return 4===t.readyState&&200===t.status}}},{key:"setLocalPath",value:function(e,t){return e.m.forEach((function(n,i){e.m[i]=t+"m/"+n})),e.mat.forEach((function(n,i){e.mat[i]=t+"mat/"+n})),void 0!==e.scene&&""!=e.scene&&(e.scene=t+e.scene),void 0!==e.nodes&&""!=e.nodes&&(e.nodes=t+"nodes/"+e.nodes),void 0!==e.i&&""!=e.i&&(e.i=t+"instance/"+e.i),void 0!==e.ii&&e.ii.forEach((function(n,i){e.ii[i]=t+"instance/"+n})),e.localPath=t+"Texture/",e.bim&&(e.bim=t+e.bim),e}},{key:"setOnlinePath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:su;return e.m.forEach((function(n,i){e.m[i]=t+n})),e.mat.forEach((function(n,i){e.mat[i]=t+n})),void 0!==e.scene&&""!=e.scene&&(e.scene=t+e.scene),void 0!==e.nodes&&""!=e.nodes&&(e.nodes=t+e.nodes),void 0!==e.i&&""!=e.i&&(e.i=t+e.i),void 0!==e.ii&&e.ii.forEach((function(n,i){e.ii[i]=t+n})),e.localPath=t,e}},{key:"getFileList",value:function(e){try{var t=this.get({url:e+"fileList.json",method:"GET",async:!1});return Array.isArray(t.addition)&&(t.addition=t.addition.map((function(t){return e+t}))),Array.isArray(t.a)&&(t.a=t.a.map((function(t){return e+t}))),Array.isArray(t.m)&&(t.m=t.m.map((function(t){return e+t}))),Array.isArray(t.mat)&&(t.mat=t.mat.map((function(t){return e+t}))),Array.isArray(t.instance)&&(t.instance=t.instance.map((function(t){return e+t}))),Array.isArray(t.skin)&&(t.skin=t.skin.map((function(t){return e+t}))),Array.isArray(t.bone)&&(t.bone=t.bone.map((function(t){return e+t}))),t.scene&&(t.scene=e+t.scene),t.sky&&(t.sky.a=e+t.sky.a,t.sky.b=e+t.sky.b),t.bim&&(t.bim=e+t.bim),t.sceneData&&(t.sceneData=e+t.sceneData),t}catch(e){console.error("获取本地fileList.json失败")}}},{key:"hasMRCBFile",value:function(e){try{return this.get({url:e+"conf.mrcb",method:"GET",async:!1})}catch(e){}}},{key:"getCoordsByAddressOrCityCode",value:function(t,n,i){var r='https://api.tianditu.gov.cn/administrative?postStr={"searchWord":"'.concat(void 0!==t?t:n,'","searchType":"').concat(void 0!==t?1:0,'","needSubInfo":"false","needAll":"false","needPolygon":"true","needPre":"true"}&tk=')+Ck.token;e.get({url:r,async:!0,onSuccess:function(e){"ok"===e.msg&&(e.data[0].coord=[e.data[0].lnt,e.data[0].lat],i(e.data[0]))}})}},{key:"getCoordsByCityCode",value:function(t,n){e.getCoordsByAddressOrCityCode(void 0,t,n)}},{key:"getCoordsByAddress",value:function(t,n){e.getCoordsByAddressOrCityCode(t,void 0,n)}}]),e}(),Au=function(){function e(){s(this,e),this.token=null}return A(e,[{key:"init",value:function(e){this.options=e}},{key:"checkDevloper",value:function(){if(!this.options.appkey||""===this.options.appkey)throw new Error("开发者参数[appkey]缺失!");if(!this.options.appsecret||""===this.options.appsecret)throw new Error("开发者参数[appsecret]缺失!");var e=(new Date).getTime(),t=parseInt(1e6*Math.random()),n=eu(this.options.appsecret+e+t),i="appkey="+this.options.appkey+"&random="+t+"&sign="+n+"&source=3&timeStamp="+e;return lu.authorization(i)}},{key:"offlineValidation",value:function(e){var t=this;try{callRuntimeCallbacks&&callRuntimeCallbacks([function(n){n.onRuntimeInitialized=function(){var i=0;n&&n.ccall&&(i=n.ccall("WEB_API_CheckLicenseData","number",["string","string","string","string"],[t.options.developerID,t.options.appID,t.options.secretKey,t.options.offlinekey])),e(i)}}])}catch(t){e(0)}}}]),e}(),cu=new Au;function hu(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}Object.assign(hu.prototype,{setSize:function(){},render:function(){console.error("Pass: .render() must be implemented in derived pass.")}}),hu.FullScreenQuad=function(){var e=new FA(-1,1,1,-1,0,1),t=new $i(2,2),n=function(e){this._mesh=new Ei(t,e)};return Object.defineProperty(n.prototype,"material",{get:function(){return this._mesh.material},set:function(e){this._mesh.material=e}}),Object.assign(n.prototype,{render:function(t){t.render(this._mesh,e)}}),n}();var uu=function(e,t,n,i,r){hu.call(this),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1};uu.prototype=Object.assign(Object.create(hu.prototype),{constructor:uu,render:function(e,t,n){var i,r,a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(i=e.getClearColor().getHex(),r=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(i,r),this.scene.overrideMaterial=null,e.autoClear=a}}),"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:T}}));var du={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tgl_FragColor = opacity * texel;","}"].join("\n")},fu=function(e,t){hu.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof Ri?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Di.clone(e.uniforms),this.material=new Ri({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new hu.FullScreenQuad(this.material)};fu.prototype=Object.assign(Object.create(hu.prototype),{constructor:fu,render:function(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}});var pu=function(e,t){hu.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1};pu.prototype=Object.assign(Object.create(hu.prototype),{constructor:pu,render:function(e,t,n){var i,r,a=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0),this.inverse?(i=0,r=1):(i=1,r=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.buffers.stencil.setFunc(a.ALWAYS,i,4294967295),o.buffers.stencil.setClear(r),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(a.EQUAL,1,4294967295),o.buffers.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),o.buffers.stencil.setLocked(!0)}});var mu=function(){hu.call(this),this.needsSwap=!1};mu.prototype=Object.create(hu.prototype),Object.assign(mu.prototype,{render:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}});var vu=function(e,t){if(this.renderer=e,void 0===t){var n={minFilter:Z,magFilter:Z,format:ce,stencilBuffer:!0},i=e.getSize(new tt);this._pixelRatio=e.getPixelRatio(),this._width=i.width,this._height=i.height,(t=new dt(this._width*this._pixelRatio,this._height*this._pixelRatio,n)).texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===du&&console.error("EffectComposer relies on CopyShader"),void 0===fu&&console.error("EffectComposer relies on ShaderPass"),this.copyPass=new fu(du),this.clock=new lc};Object.assign(vu.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},insertPass:function(e,t){this.passes.splice(t,0,e)},isLastEnabledPass:function(e){for(var t=e+1;t= edgeVert;"," FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;","/*--------------------------------------------------------------------------*/"," if(!horzSpan) lumaN = lumaW;"," if(!horzSpan) lumaS = lumaE;"," if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;"," FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;","/*--------------------------------------------------------------------------*/"," FxaaFloat gradientN = lumaN - lumaM;"," FxaaFloat gradientS = lumaS - lumaM;"," FxaaFloat lumaNN = lumaN + lumaM;"," FxaaFloat lumaSS = lumaS + lumaM;"," FxaaBool pairN = abs(gradientN) >= abs(gradientS);"," FxaaFloat gradient = max(abs(gradientN), abs(gradientS));"," if(pairN) lengthSign = -lengthSign;"," FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posB;"," posB.x = posM.x;"," posB.y = posM.y;"," FxaaFloat2 offNP;"," offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;"," offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;"," if(!horzSpan) posB.x += lengthSign * 0.5;"," if( horzSpan) posB.y += lengthSign * 0.5;","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posN;"," posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;"," posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;"," FxaaFloat2 posP;"," posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;"," posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;"," FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;"," FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));"," FxaaFloat subpixE = subpixC * subpixC;"," FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));","/*--------------------------------------------------------------------------*/"," if(!pairN) lumaNN = lumaSS;"," FxaaFloat gradientScaled = gradient * 1.0/4.0;"," FxaaFloat lumaMM = lumaM - lumaNN * 0.5;"," FxaaFloat subpixF = subpixD * subpixE;"," FxaaBool lumaMLTZero = lumaMM < 0.0;","/*--------------------------------------------------------------------------*/"," lumaEndN -= lumaNN * 0.5;"," lumaEndP -= lumaNN * 0.5;"," FxaaBool doneN = abs(lumaEndN) >= gradientScaled;"," FxaaBool doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;"," FxaaBool doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;","/*--------------------------------------------------------------------------*/"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 3)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 4)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 5)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 6)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 7)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 8)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 9)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 10)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 11)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 12)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }","/*--------------------------------------------------------------------------*/"," FxaaFloat dstN = posM.x - posN.x;"," FxaaFloat dstP = posP.x - posM.x;"," if(!horzSpan) dstN = posM.y - posN.y;"," if(!horzSpan) dstP = posP.y - posM.y;","/*--------------------------------------------------------------------------*/"," FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;"," FxaaFloat spanLength = (dstP + dstN);"," FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;"," FxaaFloat spanLengthRcp = 1.0/spanLength;","/*--------------------------------------------------------------------------*/"," FxaaBool directionN = dstN < dstP;"," FxaaFloat dst = min(dstN, dstP);"," FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;"," FxaaFloat subpixG = subpixF * subpixF;"," FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;"," FxaaFloat subpixH = subpixG * fxaaQualitySubpix;","/*--------------------------------------------------------------------------*/"," FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;"," FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);"," if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;"," if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;"," #if (FXAA_DISCARD == 1)"," return FxaaTexTop(tex, posM);"," #else"," return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);"," #endif","}","/*==========================================================================*/","#endif","","void main() {"," gl_FragColor = FxaaPixelShader("," vUv,"," vec4(0.0),"," tDiffuse,"," tDiffuse,"," tDiffuse,"," resolution,"," vec4(0.0),"," vec4(0.0),"," vec4(0.0),"," 0.75,"," 0.166,"," 0.0833,"," 0.0,"," 0.0,"," 0.0,"," vec4(0.0)"," );",""," // TODO avoid querying texture twice for same texel"," gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join("\n")},wu={defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new tt(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","void SMAAEdgeDetectionVS( vec2 texcoord ) {","\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );","\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );","\tvOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 );","}","void main() {","\tvUv = uv;","\tSMAAEdgeDetectionVS( vUv );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {","\tvec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );","\tvec4 delta;","\tvec3 C = texture2D( colorTex, texcoord ).rgb;","\tvec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;","\tvec3 t = abs( C - Cleft );","\tdelta.x = max( max( t.r, t.g ), t.b );","\tvec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;","\tt = abs( C - Ctop );","\tdelta.y = max( max( t.r, t.g ), t.b );","\tvec2 edges = step( threshold, delta.xy );","\tif ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )","\t\tdiscard;","\tvec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;","\tt = abs( C - Cright );","\tdelta.z = max( max( t.r, t.g ), t.b );","\tvec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;","\tt = abs( C - Cbottom );","\tdelta.w = max( max( t.r, t.g ), t.b );","\tfloat maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );","\tvec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;","\tt = abs( C - Cleftleft );","\tdelta.z = max( max( t.r, t.g ), t.b );","\tvec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;","\tt = abs( C - Ctoptop );","\tdelta.w = max( max( t.r, t.g ), t.b );","\tmaxDelta = max( max( maxDelta, delta.z ), delta.w );","\tedges.xy *= step( 0.5 * maxDelta, delta.xy );","\treturn vec4( edges, 0.0, 0.0 );","}","void main() {","\tgl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );","}"].join("\n")},xu={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new tt(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 3 ];","varying vec2 vPixcoord;","void SMAABlendingWeightCalculationVS( vec2 texcoord ) {","\tvPixcoord = texcoord / resolution;","\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 );","\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 );","\tvOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );","}","void main() {","\tvUv = uv;","\tSMAABlendingWeightCalculationVS( vUv );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )","uniform sampler2D tDiffuse;","uniform sampler2D tArea;","uniform sampler2D tSearch;","uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[3];","varying vec2 vPixcoord;","#if __VERSION__ == 100","vec2 round( vec2 x ) {","\treturn sign( x ) * floor( abs( x ) + 0.5 );","}","#endif","float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {","\te.r = bias + e.r * scale;","\treturn 255.0 * texture2D( searchTex, e, 0.0 ).r;","}","float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","\tvec2 e = vec2( 0.0, 1.0 );","\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;","\t\ttexcoord -= vec2( 2.0, 0.0 ) * resolution;","\t\tif ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;","\t}","\ttexcoord.x += 0.25 * resolution.x;","\ttexcoord.x += resolution.x;","\ttexcoord.x += 2.0 * resolution.x;","\ttexcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);","\treturn texcoord.x;","}","float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","\tvec2 e = vec2( 0.0, 1.0 );","\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;","\t\ttexcoord += vec2( 2.0, 0.0 ) * resolution;","\t\tif ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;","\t}","\ttexcoord.x -= 0.25 * resolution.x;","\ttexcoord.x -= resolution.x;","\ttexcoord.x -= 2.0 * resolution.x;","\ttexcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );","\treturn texcoord.x;","}","float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","\tvec2 e = vec2( 1.0, 0.0 );","\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;","\t\ttexcoord += vec2( 0.0, 2.0 ) * resolution;","\t\tif ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;","\t}","\ttexcoord.y -= 0.25 * resolution.y;","\ttexcoord.y -= resolution.y;","\ttexcoord.y -= 2.0 * resolution.y;","\ttexcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 );","\treturn texcoord.y;","}","float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {","\tvec2 e = vec2( 1.0, 0.0 );","\tfor ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {","\t\te = texture2D( edgesTex, texcoord, 0.0 ).rg;","\t\ttexcoord -= vec2( 0.0, 2.0 ) * resolution;","\t\tif ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;","\t}","\ttexcoord.y += 0.25 * resolution.y;","\ttexcoord.y += resolution.y;","\ttexcoord.y += 2.0 * resolution.y;","\ttexcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 );","\treturn texcoord.y;","}","vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {","\tvec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;","\ttexcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );","\ttexcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;","\treturn texture2D( areaTex, texcoord, 0.0 ).rg;","}","vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {","\tvec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );","\tvec2 e = texture2D( edgesTex, texcoord ).rg;","\tif ( e.g > 0.0 ) {","\t\tvec2 d;","\t\tvec2 coords;","\t\tcoords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );","\t\tcoords.y = offset[ 1 ].y;","\t\td.x = coords.x;","\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).r;","\t\tcoords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );","\t\td.y = coords.x;","\t\td = d / resolution.x - pixcoord.x;","\t\tvec2 sqrt_d = sqrt( abs( d ) );","\t\tcoords.y -= 1.0 * resolution.y;","\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;","\t\tweights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );","\t}","\tif ( e.r > 0.0 ) {","\t\tvec2 d;","\t\tvec2 coords;","\t\tcoords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );","\t\tcoords.x = offset[ 0 ].x;","\t\td.x = coords.y;","\t\tfloat e1 = texture2D( edgesTex, coords, 0.0 ).g;","\t\tcoords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );","\t\td.y = coords.y;","\t\td = d / resolution.y - pixcoord.y;","\t\tvec2 sqrt_d = sqrt( abs( d ) );","\t\tcoords.y -= 1.0 * resolution.y;","\t\tfloat e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;","\t\tweights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );","\t}","\treturn weights;","}","void main() {","\tgl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );","}"].join("\n")},bu={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new tt(1/1024,1/512)}},vertexShader:["uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 2 ];","void SMAANeighborhoodBlendingVS( vec2 texcoord ) {","\tvOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );","\tvOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );","}","void main() {","\tvUv = uv;","\tSMAANeighborhoodBlendingVS( vUv );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform sampler2D tColor;","uniform vec2 resolution;","varying vec2 vUv;","varying vec4 vOffset[ 2 ];","vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {","\tvec4 a;","\ta.xz = texture2D( blendTex, texcoord ).xz;","\ta.y = texture2D( blendTex, offset[ 1 ].zw ).g;","\ta.w = texture2D( blendTex, offset[ 1 ].xy ).a;","\tif ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {","\t\treturn texture2D( colorTex, texcoord, 0.0 );","\t} else {","\t\tvec2 offset;","\t\toffset.x = a.a > a.b ? a.a : -a.b;","\t\toffset.y = a.g > a.r ? -a.g : a.r;","\t\tif ( abs( offset.x ) > abs( offset.y )) {","\t\t\toffset.y = 0.0;","\t\t} else {","\t\t\toffset.x = 0.0;","\t\t}","\t\tvec4 C = texture2D( colorTex, texcoord, 0.0 );","\t\ttexcoord += sign( offset ) * resolution;","\t\tvec4 Cop = texture2D( colorTex, texcoord, 0.0 );","\t\tfloat s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );","\t\tC.xyz = pow(C.xyz, vec3(2.2));","\t\tCop.xyz = pow(Cop.xyz, vec3(2.2));","\t\tvec4 mixed = mix(C, Cop, s);","\t\tmixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));","\t\treturn mixed;","\t}","}","void main() {","\tgl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );","}"].join("\n")},Mu=function(e,t){hu.call(this),this.edgesRT=new dt(e,t,{depthBuffer:!1,generateMipmaps:!1,minFilter:Z,format:Ae}),this.edgesRT.texture.name="SMAAPass.edges",this.weightsRT=new dt(e,t,{depthBuffer:!1,generateMipmaps:!1,minFilter:Z,format:ce}),this.weightsRT.texture.name="SMAAPass.weights";var n,i,r=this;(n=new Image).src=this.getAreaTexture(),n.onload=function(){r.areaTexture.needsUpdate=!0},this.areaTexture=new ht,this.areaTexture.name="SMAAPass.area",this.areaTexture.image=n,this.areaTexture.format=Ae,this.areaTexture.minFilter=Z,this.areaTexture.generateMipmaps=!1,this.areaTexture.flipY=!1,(i=new Image).src=this.getSearchTexture(),i.onload=function(){r.searchTexture.needsUpdate=!0},this.searchTexture=new ht,this.searchTexture.name="SMAAPass.search",this.searchTexture.image=i,this.searchTexture.magFilter=X,this.searchTexture.minFilter=X,this.searchTexture.generateMipmaps=!1,this.searchTexture.flipY=!1,void 0===wu&&console.error("SMAAPass relies on SMAAShader"),this.uniformsEdges=Di.clone(wu.uniforms),this.uniformsEdges.resolution.value.set(1/e,1/t),this.materialEdges=new Ri({defines:Object.assign({},wu.defines),uniforms:this.uniformsEdges,vertexShader:wu.vertexShader,fragmentShader:wu.fragmentShader}),this.uniformsWeights=Di.clone(xu.uniforms),this.uniformsWeights.resolution.value.set(1/e,1/t),this.uniformsWeights.tDiffuse.value=this.edgesRT.texture,this.uniformsWeights.tArea.value=this.areaTexture,this.uniformsWeights.tSearch.value=this.searchTexture,this.materialWeights=new Ri({defines:Object.assign({},xu.defines),uniforms:this.uniformsWeights,vertexShader:xu.vertexShader,fragmentShader:xu.fragmentShader}),this.uniformsBlend=Di.clone(bu.uniforms),this.uniformsBlend.resolution.value.set(1/e,1/t),this.uniformsBlend.tDiffuse.value=this.weightsRT.texture,this.materialBlend=new Ri({uniforms:this.uniformsBlend,vertexShader:bu.vertexShader,fragmentShader:bu.fragmentShader}),this.needsSwap=!1,this.fsQuad=new hu.FullScreenQuad(null)};Mu.prototype=Object.assign(Object.create(hu.prototype),{constructor:Mu,render:function(e,t,n){this.uniformsEdges.tDiffuse.value=n.texture,this.fsQuad.material=this.materialEdges,e.setRenderTarget(this.edgesRT),this.clear&&e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialWeights,e.setRenderTarget(this.weightsRT),this.clear&&e.clear(),this.fsQuad.render(e),this.uniformsBlend.tColor.value=n.texture,this.fsQuad.material=this.materialBlend,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))},setSize:function(e,t){this.edgesRT.setSize(e,t),this.weightsRT.setSize(e,t),this.materialEdges.uniforms.resolution.value.set(1/e,1/t),this.materialWeights.uniforms.resolution.value.set(1/e,1/t),this.materialBlend.uniforms.resolution.value.set(1/e,1/t)},getAreaTexture:function(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9A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fvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="},getSearchTexture:function(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}});var Cu=A((function e(){s(this,e)}));Cu.FXAA="FXAA",Cu.SMAA="SMAA",Cu.MSAA="MSAA",Cu.SSAA="SSAA";var Bu=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,e),this.options=t,this.pass={enabled:!0},this.antiAliasing=t.antialias||Cu.FXAA,this.isPostProcessing=!0}return A(e,[{key:"init",value:function(){}},{key:"render",value:function(){}},{key:"enabled",get:function(){this.pass.enabled},set:function(e){this.pass.enabled=e}},{key:"setSize",value:function(e,t){}}]),e}(),Eu=function(e,t,n,i){this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new Fn(1,1,1),this.hiddenEdgeColor=new Fn(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,hu.call(this),this.resolution=void 0!==e?new tt(e.x,e.y):new tt(256,256);var r={minFilter:Z,magFilter:Z,format:ce},a=Math.round(this.resolution.x/this.downSampleRatio),o=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new Nn({color:16777215}),this.maskBufferMaterial.side=2,this.renderTargetMaskBuffer=new dt(this.resolution.x,this.resolution.y,r),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Ra,this.depthMaterial.side=2,this.depthMaterial.depthPacking=je,this.depthMaterial.blending=0,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){var n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new dt(this.resolution.x,this.resolution.y,r),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new dt(a,o,r),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new dt(a,o,r),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new dt(Math.round(a/2),Math.round(o/2),r),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new dt(a,o,r),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new dt(Math.round(a/2),Math.round(o/2),r),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new tt(a,o),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new tt(Math.round(a/2),Math.round(o/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial(),void 0===du&&console.error("OutlinePass relies on CopyShader");var s=du;this.copyUniforms=Di.clone(s.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Ri({uniforms:this.copyUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Fn,this.oldClearAlpha=1,this.fsQuad=new hu.FullScreenQuad(null),this.tempPulseColor1=new Fn,this.tempPulseColor2=new Fn,this.textureMatrix=new bt};Eu.prototype=Object.assign(Object.create(hu.prototype),{constructor:Eu,dispose:function(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()},setSize:function(e,t){this.renderTargetMaskBuffer.setSize(e,t);var n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value=new tt(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value=new tt(n,i)},changeVisibilityOfSelectedObjects:function(e){function t(t){t.isMesh&&(e?(t.visible=t.userData.oldVisible,delete t.userData.oldVisible):(t.userData.oldVisible=t.visible,t.visible=e))}for(var n=0;n0){this.showTransform=!1,this.renderScene.getObjectByName("ObjectControls")&&this.renderScene.getObjectByName("ObjectControls").visible&&(this.showTransform=!0,this.renderScene.getObjectByName("ObjectControls").visible=!1),this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);var o=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value=new tt(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),this.toggleVisibleOfSelectedObjects(!0),e.render(this.renderScene,this.renderCamera),this.toggleVisibleOfSelectedObjects(!1),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this.renderScene.background=o,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){var s=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(s),this.tempPulseColor2.multiplyScalar(s)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new tt(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Eu.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Eu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Eu.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Eu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e)),this.showTransform&&(this.renderScene.getObjectByName("ObjectControls").visible=!0)},getPrepareMaskMaterial:function(){return new Ri({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new tt(.5,.5)},textureMatrix:{value:new bt}},vertexShader:["varying vec4 projTexCoord;","varying vec4 vPosition;","uniform mat4 textureMatrix;","void main() {","\tvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tprojTexCoord = textureMatrix * worldPosition;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec4 vPosition;","varying vec4 projTexCoord;","uniform sampler2D depthTexture;","uniform vec2 cameraNearFar;","void main() {","\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));","\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );","\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;","\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);","}"].join("\n")})},getEdgeDetectionMaterial:function(){return new Ri({uniforms:{maskTexture:{value:null},texSize:{value:new tt(.5,.5)},visibleEdgeColor:{value:new at(1,1,1)},hiddenEdgeColor:{value:new at(1,1,1)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec3 visibleEdgeColor;\t\t\t\tuniform vec3 hiddenEdgeColor;\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\t\t\t\t}"})},getSeperableBlurMaterial:function(e){return new Ri({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new tt(.5,.5)},direction:{value:new tt(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tuniform sampler2D colorTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tuniform float kernelRadius;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\t\t\t\t\tvec2 uvOffset = delta;\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\t\t\t\t\t\tweightSum += (2.0 * w);\t\t\t\t\t\tuvOffset += delta;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\t\t\t\t}"})},getOverlayMaterial:function(){return new Ri({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform sampler2D edgeTexture1;\t\t\t\tuniform sampler2D edgeTexture2;\t\t\t\tuniform sampler2D patternTexture;\t\t\t\tuniform float edgeStrength;\t\t\t\tuniform float edgeGlow;\t\t\t\tuniform bool usePatternTexture;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\t\t\t\t\tif(usePatternTexture)\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\t\t\t\t\tgl_FragColor = finalColor;\t\t\t\t}",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}),Eu.BlurDirectionX=new tt(1,0),Eu.BlurDirectionY=new tt(0,1);var Su=function(e,t,n,i){this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new Fn(1,1,1),this.hiddenEdgeColor=new Fn(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,hu.call(this),this.resolution=void 0!==e?new tt(e.x,e.y):new tt(256,256);var r={minFilter:Z,magFilter:Z,format:ce},a=Math.round(this.resolution.x/this.downSampleRatio),o=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new dt(this.resolution.x,this.resolution.y,r),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){var n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetMaskDownSampleBuffer=new dt(a,o,r),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new dt(a,o,r),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new dt(Math.round(a/2),Math.round(o/2),r),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new dt(a,o,r),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new dt(Math.round(a/2),Math.round(o/2),r),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new tt(a,o),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new tt(Math.round(a/2),Math.round(o/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial(),void 0===du&&console.error("OutlinePass relies on CopyShader");var s=du;this.copyUniforms=Di.clone(s.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Ri({uniforms:this.copyUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Fn,this.oldClearAlpha=1,this.fsQuad=new hu.FullScreenQuad(null),this.tempPulseColor1=new Fn,this.tempPulseColor2=new Fn,this.textureMatrix=new bt};Su.prototype=Object.assign(Object.create(hu.prototype),{constructor:Su,dispose:function(){this.renderTargetMaskBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()},setSize:function(e,t){this.renderTargetMaskBuffer.setSize(e,t);var n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value=new tt(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value=new tt(n,i)},changeVisibilityOfSelectedObjects:function(e){function t(t){t.isMesh&&(e?(t.visible=t.userData.oldVisible,delete t.userData.oldVisible):(t.userData.oldVisible=t.visible,t.visible=e))}for(var n=0;n0){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1);var o=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.prepareMaskMaterial,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.renderArray(this.selectedObjects,this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.renderScene.background=o,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){var s=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(s),this.tempPulseColor2.multiplyScalar(s)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new tt(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Su.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Su.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Su.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Su.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e)),this.showTransform&&(this.renderScene.getObjectByName("ObjectControls").visible=!0)},getPrepareMaskMaterial:function(){return new Ri({uniforms:{},vertexShader:["#include ","void main() {","\t#include ","\t#include ","\t#include ","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 );","}"].join("\n"),fragmentShader:["void main() {","\tgl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);","}"].join("\n")})},getEdgeDetectionMaterial:function(){return new Ri({uniforms:{maskTexture:{value:null},texSize:{value:new tt(.5,.5)},visibleEdgeColor:{value:new at(1,1,1)},hiddenEdgeColor:{value:new at(1,1,1)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec3 visibleEdgeColor;\t\t\t\tuniform vec3 hiddenEdgeColor;\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\t\t\t\t}"})},getSeperableBlurMaterial:function(e){return new Ri({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new tt(.5,.5)},direction:{value:new tt(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tuniform sampler2D colorTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tuniform float kernelRadius;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\t\t\t\t\tvec2 uvOffset = delta;\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\t\t\t\t\t\tweightSum += (2.0 * w);\t\t\t\t\t\tuvOffset += delta;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\t\t\t\t}"})},getOverlayMaterial:function(){return new Ri({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform sampler2D edgeTexture1;\t\t\t\tuniform sampler2D edgeTexture2;\t\t\t\tuniform sampler2D patternTexture;\t\t\t\tuniform float edgeStrength;\t\t\t\tuniform float edgeGlow;\t\t\t\tuniform bool usePatternTexture;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\t\t\t\t\tif(usePatternTexture)\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\t\t\t\t\tgl_FragColor = finalColor;\t\t\t\t}",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}),Su.BlurDirectionX=new tt(1,0),Su.BlurDirectionY=new tt(0,1);var Tu=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).antiAliasing=Cu.SMAA,i.selectedColor=e.color||"#fff709",i.objects=[],null==e.strength&&(e.strength=6.5),null==e.glow&&(e.glow=1),null==e.thickness&&(e.thickness=2),i}return A(n,[{key:"init",value:function(e){this.pass=new Su(new tt(e.width,e.height),e.scene,e.camera),this.pass.edgeStrength=this.options.strength,this.pass.edgeGlow=this.options.glow,this.pass.edgeThickness=this.options.thickness,this.pass.visibleEdgeColor.set(this.selectedColor),this.pass.hiddenEdgeColor.set(this.selectedColor),this.pass.downSampleRatio=window.devicePixelRatio,this.pass.selectedObjects=this.objects,b(u(n.prototype),"init",this).call(this)}},{key:"add",value:function(e){var t=this;this.objects.includes(e)||(this.objects.push(e),e.traverse((function(e){e.isMesh&&!t.pass.selectedObjects.includes(e)&&t.pass.selectedObjects.push(e)})))}},{key:"remove",value:function(e){if(this.objects.includes(e)){this.objects.splice(this.objects.indexOf(e),1);var t=[];e.traverse((function(e){e.isMesh&&t.push(e)}));for(var n=this.pass.selectedObjects.length-1;n>=0;n--)t.includes(this.pass.selectedObjects[n])&&this.pass.selectedObjects.splice(n,1)}}},{key:"clear",value:function(){this.objects=[],this.pass.selectedObjects&&(this.pass.selectedObjects=[])}}]),n}(Bu),_u={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new Fn(0)},defaultOpacity:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 defaultColor;","uniform float defaultOpacity;","uniform float luminosityThreshold;","uniform float smoothWidth;","varying vec2 vUv;","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tvec3 luma = vec3( 0.299, 0.587, 0.114 );","\tfloat v = dot( texel.xyz, luma );","\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );","\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );","\tgl_FragColor = mix( outputColor, texel, alpha );","}"].join("\n")},Iu=function(e,t,n,i){hu.call(this),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=i,this.resolution=void 0!==e?new tt(e.x,e.y):new tt(256,256),this.clearColor=new Fn(0,0,0);var r={minFilter:Z,magFilter:Z,format:ce};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new dt(a,o,r),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat fSigma = float(SIGMA);\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\t\t\t\t\t\tfloat x = float(i);\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\t\t\t\t\t\tweightSum += 2.0 * w;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})},getCompositeMaterial:function(e){return new Ri({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D blurTexture1;\t\t\t\tuniform sampler2D blurTexture2;\t\t\t\tuniform sampler2D blurTexture3;\t\t\t\tuniform sampler2D blurTexture4;\t\t\t\tuniform sampler2D blurTexture5;\t\t\t\tuniform sampler2D dirtTexture;\t\t\t\tuniform float bloomStrength;\t\t\t\tuniform float bloomRadius;\t\t\t\tuniform float bloomFactors[NUM_MIPS];\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\t\t\t\t\t\t\t\tfloat lerpBloomFactor(const in float factor) { \t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\t\t\t\t}"})}}),Iu.BlurDirectionX=new tt(1,0),Iu.BlurDirectionY=new tt(0,1);var Lu=function(e,t,n,i){hu.call(this),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==i?i:0,void 0===du&&console.error("SSAARenderPass relies on CopyShader");var r=du;this.copyUniforms=Di.clone(r.uniforms),this.copyMaterial=new Ri({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuad=new hu.FullScreenQuad(this.copyMaterial)};Lu.prototype=Object.assign(Object.create(hu.prototype),{constructor:Lu,dispose:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)},setSize:function(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)},render:function(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=new dt(n.width,n.height,{minFilter:Z,magFilter:Z,format:ce}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");var i=Lu.JitterVectors[Math.max(0,Math.min(this.sampleLevel,5))],r=e.autoClear;e.autoClear=!1;var a=e.getClearColor().getHex(),o=e.getClearAlpha(),s=1/i.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture,n.width,n.height;for(var l=0;lo&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Y"!==r.name&&"XYZY"!==r.name||Math.abs(R.copy(V).applyQuaternion(t).dot(this.eye))>o&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Z"!==r.name&&"XYZZ"!==r.name||Math.abs(R.copy(j).applyQuaternion(t).dot(this.eye))>o&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XY"===r.name&&Math.abs(R.copy(j).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"YZ"===r.name&&Math.abs(R.copy(H).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XZ"===r.name&&Math.abs(R.copy(V).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),-1!==r.name.search("X")&&(R.copy(H).applyQuaternion(t).dot(this.eye)<0?"fwd"===r.tag?r.visible=!1:r.scale.x*=-1:"bwd"===r.tag&&(r.visible=!1)),-1!==r.name.search("Y")&&(R.copy(V).applyQuaternion(t).dot(this.eye)<0?"fwd"===r.tag?r.visible=!1:r.scale.y*=-1:"bwd"===r.tag&&(r.visible=!1)),-1!==r.name.search("Z")&&(R.copy(j).applyQuaternion(t).dot(this.eye)<0?"fwd"===r.tag?r.visible=!1:r.scale.z*=-1:"bwd"===r.tag&&(r.visible=!1))}else"rotate"===this.mode&&(Q.copy(t),R.copy(this.eye).applyQuaternion(z.copy(t).inverse()),-1!==r.name.search("E")&&r.quaternion.setFromRotationMatrix(N.lookAt(this.eye,O,V)),"X"===r.name&&(z.setFromAxisAngle(H,Math.atan2(-R.y,R.z)),z.multiplyQuaternions(Q,z),r.quaternion.copy(z)),"Y"===r.name&&(z.setFromAxisAngle(V,Math.atan2(R.x,R.z)),z.multiplyQuaternions(Q,z),r.quaternion.copy(z)),"Z"===r.name&&(z.setFromAxisAngle(j,Math.atan2(R.y,R.x)),z.multiplyQuaternions(Q,z),r.quaternion.copy(z)));r.visible=r.visible&&(-1===r.name.indexOf("X")||this.showX),r.visible=r.visible&&(-1===r.name.indexOf("Y")||this.showY),r.visible=r.visible&&(-1===r.name.indexOf("Z")||this.showZ),r.visible=r.visible&&(-1===r.name.indexOf("E")||this.showX&&this.showY&&this.showZ),r.material._opacity=r.material._opacity||r.material.opacity,r.material._color=r.material._color||r.material.color.clone(),r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled?this.axis&&(r.name===this.axis||this.axis.split("").some((function(e){return r.name===e}))?(r.material.opacity=1,r.material.color.lerp(new Fn(1,1,1),.5)):(r.material.opacity*=.25,r.material.color.lerp(new Fn(1,1,1),.5))):(r.material.opacity*=.5,r.material.color.lerp(new Fn(1,1,1),.5))}else r.visible=!1,"AXIS"===r.name?(r.position.copy(this.worldPositionStart),r.visible=!!this.axis,"X"===this.axis&&(z.setFromEuler(D.set(0,0,0)),r.quaternion.copy(t).multiply(z),Math.abs(R.copy(H).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),"Y"===this.axis&&(z.setFromEuler(D.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(z),Math.abs(R.copy(V).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),"Z"===this.axis&&(z.setFromEuler(D.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(z),Math.abs(R.copy(j).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),"XYZE"===this.axis&&(z.setFromEuler(D.set(0,Math.PI/2,0)),R.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(N.lookAt(O,R,V)),r.quaternion.multiply(z),r.visible=this.dragging),"E"===this.axis&&(r.visible=!1)):"START"===r.name?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):"END"===r.name?(r.position.copy(this.worldPosition),r.visible=this.dragging):"DELTA"===r.name?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),U.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),U.applyQuaternion(this.worldQuaternionStart.clone().inverse()),r.scale.copy(U),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=-1!==this.axis.search(r.name)))}zt.prototype.updateMatrixWorld.call(this)}};ku.prototype=Object.assign(Object.create(zt.prototype),{constructor:ku,isTransformControlsGizmo:!0});var Pu=function(){Ei.call(this,new $i(1e5,1e5,2,2),new Nn({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1})),this.type="TransformControlsPlane";var e=new at(1,0,0),t=new at(0,1,0),n=new at(0,0,1),i=new at,r=new at,a=new at,o=new bt,s=new nt;this.updateMatrixWorld=function(){var l=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(l="local"),e.set(1,0,0).applyQuaternion("local"===l?this.worldQuaternion:s),t.set(0,1,0).applyQuaternion("local"===l?this.worldQuaternion:s),n.set(0,0,1).applyQuaternion("local"===l?this.worldQuaternion:s),a.copy(t),this.mode){case"translate":case"scale":switch(this.axis){case"X":a.copy(this.eye).cross(e),r.copy(e).cross(a);break;case"Y":a.copy(this.eye).cross(t),r.copy(t).cross(a);break;case"Z":a.copy(this.eye).cross(n),r.copy(n).cross(a);break;case"XY":r.copy(n);break;case"YZ":r.copy(e);break;case"XZ":a.copy(n),r.copy(t);break;case"XYZ":case"E":r.set(0,0,0)}break;default:r.set(0,0,0)}0===r.length()?this.quaternion.copy(this.cameraQuaternion):(o.lookAt(i.set(0,0,0),r,a),this.quaternion.setFromRotationMatrix(o)),zt.prototype.updateMatrixWorld.call(this)}};Pu.prototype=Object.assign(Object.create(Ei.prototype),{constructor:Pu,isTransformControlsPlane:!0});var Uu,Du=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this,e))._hideObjects=[],r.antiAliasing=Cu.SMAA,r.options.strength=void 0!==r.options.strength?r.options.strength:1,r.options.radius=void 0!==r.options.radius?r.options.radius:0,r.options.threshold=void 0!==r.options.threshold?r.options.threshold:0,r._bloomPass={},r._materials={},r._darkMaterial=new Nn({color:"black"}),r._lastSelected=null,r._objects=[],r.isUnrealBloom=!0,r.viewer=i,r}return A(n,[{key:"init",value:function(e){var t=new tt(e.width,e.height);this._bloomPass=new Iu(t,this.options.strength,this.options.radius,this.options.threshold),this._bloomLayer=new Et,this._bloomLayer.set(1),this._composer=new vu(e.renderer),this._composer.renderToScreen=!1;var i=new Lu(e.scene,e.camera);i.sampleLevel=4,this._composer.addPass(i),this._composer.addPass(new fu(du)),this._composer.addPass(this._bloomPass),this.pass=new fu(new Ri({uniforms:{baseTexture:{value:null},bloomTexture:{value:this._composer.renderTarget2.texture}},vertexShader:"varying vec2 vUv;\n\t\t\t void main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t }",fragmentShader:"uniform sampler2D baseTexture;\n uniform sampler2D bloomTexture;\n varying vec2 vUv;\n vec4 getTexture( sampler2D texelToLinearTexture ) {\n return mapTexelToLinear( texture2D( texelToLinearTexture , vUv ) );\n }\n void main() {\n gl_FragColor = ( getTexture( baseTexture ) + vec4( 1.0 ) * getTexture( bloomTexture ) );\n }",defines:{}}),"baseTexture"),this.pass.needsSwap=!0,b(u(n.prototype),"init",this).call(this)}},{key:"setSize",value:function(e,t){this._composer.setSize(e,t)}},{key:"setStrength",value:function(e){this._bloomPass.strength=e,this.viewer.renderManager.render()}},{key:"getStrength",value:function(){return this._bloomPass.strength}},{key:"setRadius",value:function(e){this._bloomPass.radius=e,this.viewer.renderManager.render()}},{key:"getRadius",value:function(){return this._bloomPass.radius}},{key:"setThreshold",value:function(e){this._bloomPass.threshold=e,this.viewer.renderManager.render()}},{key:"getThreshold",value:function(){return this._bloomPass.threshold}},{key:"setExposure",value:function(e){this._bloomPass.exposure=e}},{key:"getExposure",value:function(){return this._bloomPass.exposure||1}},{key:"add",value:function(e){console.log(e);var t=this._objects;function n(e){t.includes(e)||(e.layers.mask=3,e.bloom=!0,t.push(e))}this._lastSelected=e,"Mesh"!==e.type&&"SkinnedMesh"!==e.type||n(e),"Object3D"!==e.type&&"Group"!==e.type||e.traverse((function(e){("Mesh"===e.type||"SkinnedMesh"===e.type)&&n(e)}))}},{key:"remove",value:function(e){var t=this._objects;function n(e){t.includes(e)&&(e.layers.mask=1,delete e.bloom,t.splice(t.indexOf(e),1))}"Mesh"!==e.type&&"SkinnedMesh"!==e.type||n(e),"Object3D"!==e.type&&"Group"!==e.type||e.traverse((function(e){("Mesh"===e.type||"SkinnedMesh"===e.type)&&n(e)}))}},{key:"clear",value:function(){this._objects.map((function(e){e.layers.mask=1,delete e.bloom})),this._objects=[]}},{key:"render",value:function(){var e,t,n=this;this.viewer.scene.traverse((function(i){n._darkenNonBloomed(i),"_shadow.mesh"==i.name&&(e=i),i.constructor===Fu&&i.visible&&(t=i)}));var i=this.viewer.scene.background;this.viewer.scene.background=null,e&&(e.visible=!1),t&&this.viewer.root.remove(t),this._composer.render(),this.viewer.scene.background=i,e&&(e.visible=!0),t&&this.viewer.root.add(t),this.viewer.scene.traverse((function(e){n._restoreMaterial(e)})),this._hideObjects.map((function(e){return e.visible=!0})),this._hideObjects.length=0}},{key:"_darkenNonBloomed",value:function(e){if(e.isAmrtAlphaHotSpotEntity&&e.isAmrtAlphaHotSpotEntity.visible)return e.visible=!1,void this._hideObjects.push(e);if((e.isMesh||e.isSprite)&&!1===this._bloomLayer.test(e.layers)){if(Array.isArray(e.material)){if(e.material.find((function(e){return e.transparent}))&&e.visible)return e.visible=!1,void this._hideObjects.push(e)}else if(e.material.opacity<1&&e.visible)return e.visible=!1,void this._hideObjects.push(e);this._materials[e.uuid]=e.material,e.material=this._darkMaterial}}},{key:"_restoreMaterial",value:function(e){this._materials[e.uuid]&&(e.material=this._materials[e.uuid],delete this._materials[e.uuid])}}]),n}(Bu),Ru={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float maxblur;","uniform float aperture;","uniform float nearClip;","uniform float farClip;","uniform float focus;","uniform float aspect;","#include ","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );","\t#else","\treturn orthographicDepthToViewZ( depth, nearClip, farClip );","\t#endif","}","void main() {","\tvec2 aspectcorrect = vec2( 1.0, aspect );","\tfloat viewZ = getViewZ( getDepth( vUv ) );","\tfloat factor = ( focus + viewZ );","\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );","\tvec2 dofblur9 = dofblur * 0.9;","\tvec2 dofblur7 = dofblur * 0.7;","\tvec2 dofblur4 = dofblur * 0.4;","\tvec4 col = vec4( 0.0 );","\tcol += texture2D( tColor, vUv.xy );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );","\tgl_FragColor = col / 41.0;","\tgl_FragColor.a = 1.0;","}"].join("\n")},Ou=function(e,t,n){hu.call(this),this.scene=e,this.camera=t,this.apertureScale=1,this.focus=void 0!==n.focus?n.focus:1,this.aspect=void 0!==n.aspect?n.aspect:t.aspect,this.aperture=void 0!==n.aperture?n.aperture:.025,this.maxblur=void 0!==n.maxblur?n.maxblur:1;var i=n.width||window.innerWidth||1,r=n.height||window.innerHeight||1;this.renderTargetDepth=new dt(i,r,{minFilter:X,magFilter:X}),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new Ra,this.materialDepth.depthPacking=je,this.materialDepth.blending=0,void 0===Ru&&console.error("BokehPass relies on BokehShader");var a=Ru,o=Di.clone(a.uniforms);o.tDepth.value=this.renderTargetDepth.texture,o.focus.value=this.focus,o.aspect.value=this.aspect,o.aperture.value=this.aperture,o.maxblur.value=this.maxblur,o.nearClip.value=t.near,o.farClip.value=t.far,this.materialBokeh=new Ri({defines:Object.assign({},a.defines),uniforms:o,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.uniforms=o,this.needsSwap=!1,this.fsQuad=new hu.FullScreenQuad(this.materialBokeh),this.oldClearColor=new Fn};Ou.prototype=Object.assign(Object.create(hu.prototype),{constructor:Ou,render:function(e,t,n){this.scene.overrideMaterial=this.materialDepth,this.oldClearColor.copy(e.getClearColor());var i=e.getClearAlpha(),r=e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.focus.value=this.focus,this.focus>.1?this.apertureScale=.1/this.focus:this.apertureScale=1,this.uniforms.aspect.value=this.aspect,this.uniforms.aperture.value=this.aperture*this.apertureScale,this.uniforms.maxblur.value=this.maxblur,this.uniforms.tColor.value=n.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),this.scene.overrideMaterial=null,e.setClearColor(this.oldClearColor),e.setClearAlpha(i),e.autoClear=r}});var Nu=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,n),(e=t.call(this)).antiAliasing=null,e.focus=i.focus||500,e.aperture=i.aperture||1,e.maxblur=i.maxblur||.01,e.apertureScale=1,e}return A(n,[{key:"init",value:function(e){Uu||(Uu=new Ou(e.scene,e.camera,{focus:this.focus,aperture:this.aperture,maxblur:this.maxblur}),this.pass=Uu),b(u(n.prototype),"init",this).call(this)}},{key:"setFocus",value:function(e){this.focus=e,this.pass.focus=e}},{key:"setAperture",value:function(e){this.aperture=e,this.pass.aperture=e}},{key:"setMaxblur",value:function(e){this.maxblur=e,this.pass.maxblur=.001*e}},{key:"setAspect",value:function(e){this.pass.uniforms.aspect.value=e}}]),n}(Bu),zu=function(e,t,n){hu.call(this),this.h=e,this.s=t,this.v=n,this.uniform={h:{value:0},s:{value:0},v:{value:0},t2D:{value:null}},this.material=new Ri({uniforms:this.uniform,vertexShader:"\nvarying vec2 vUv;\n//uniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = uv;\n\t//vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n\n",fragmentShader:"\n\n float lerpFloat(float a,float b,float f){\n return a * (1.0 - f) + b * f;\n }\n\n vec3 lerp(vec3 a,vec3 b,float f){\n vec3 final = vec3(0.0,0.0,0.0);\n final.x = lerpFloat(a.x,b.x,f);\n final.y = lerpFloat(a.y,b.y,f);\n final.z = lerpFloat(a.z,b.z,f);\n return final;\n }\n\n vec4 lerp4(vec4 a,vec4 b,float f){\n vec4 final = vec4(0.0,0.0,0.0,0.0);\n final.x = lerpFloat(a.x,b.x,f);\n final.y = lerpFloat(a.y,b.y,f);\n final.z = lerpFloat(a.z,b.z,f);\n final.w = lerpFloat(a.w,b.w,f);\n return final;\n }\n\n vec3 HSV2RGB(vec3 c)\n {\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);\n }\n\n vec3 RgbToHsv(vec3 c)\n {\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = lerp4(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = lerp4(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n }\n\n float RotateHue(float value, float low, float hi)\n {\n return (value < low)? value + hi : (value > hi)? value - hi : value;\n }\n\n float Luminance(vec3 linearRgb)\n {\n return dot(linearRgb, vec3(0.2126729, 0.7151522, 0.0721750));\n } \n\n vec3 Saturation(vec3 c, float sat)\n {\n vec3 satV = vec3(sat,sat,sat);\n float luma = Luminance(c);\n vec3 lumaV = vec3(luma,luma,luma);\n return lumaV.xxx + satV.xxx * (c - lumaV.xxx);\n }\n\n uniform sampler2D t2D;\n\n uniform float h;\n uniform float s;\n uniform float v;\n\n varying vec2 vUv;\n\n\n void main() {\n\n vec4 texColor = texture2D( t2D, vUv );\n\n vec3 hsv = RgbToHsv(texColor.rgb);\n float hue = hsv.x + h;\n hsv.x = RotateHue(hue, 0.0, 1.0);\n //hsv.y+=s;\n hsv.z+=v;\n texColor.rgb = HSV2RGB(hsv);\n texColor.rgb = Saturation(texColor.rgb, 1.0 + s);\n\n gl_FragColor = mapTexelToLinear( texColor );\n\n #include \n #include \n\n }\n\n"}),this.fsQuad=new hu.FullScreenQuad(this.material)};zu.prototype=Object.assign(Object.create(hu.prototype),{constructor:zu,render:function(e,t,n,i){this.uniform.h.value=this.h,this.uniform.s.value=this.s,this.uniform.v.value=this.v,this.uniform.t2D.value=n.texture,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))}});var Qu=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).h=0,i.s=0,i.v=0,i.pass=new zu(i.h,i.s,i.v),i}return A(n,[{key:"getHue",value:function(){return this.pass.h}},{key:"setHue",value:function(e){this.pass.h=e}},{key:"getContrast",value:function(){return this.pass.s}},{key:"setContrast",value:function(e){this.pass.s=e}},{key:"getVibrance",value:function(){return this.pass.v}},{key:"setVibrance",value:function(e){this.pass.v=e}}]),n}(Bu),Gu=function(e){null==e&&(e=Math),this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(var t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(t=0;t<512;t++)this.perm[t]=this.p[255&t];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]};Gu.prototype.dot=function(e,t,n){return e[0]*t+e[1]*n},Gu.prototype.dot3=function(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i},Gu.prototype.dot4=function(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r},Gu.prototype.noise=function(e,t){var n,i,r=(e+t)*(.5*(Math.sqrt(3)-1)),a=Math.floor(e+r),o=Math.floor(t+r),s=(3-Math.sqrt(3))/6,l=(a+o)*s,A=e-(a-l),c=t-(o-l);A>c?(n=1,i=0):(n=0,i=1);var h=A-n+s,u=c-i+s,d=A-1+2*s,f=c-1+2*s,p=255&a,m=255&o,v=this.perm[p+this.perm[m]]%12,g=this.perm[p+n+this.perm[m+i]]%12,y=this.perm[p+1+this.perm[m+1]]%12,w=.5-A*A-c*c,x=.5-h*h-u*u,b=.5-d*d-f*f;return 70*((w<0?0:(w*=w)*w*this.dot(this.grad3[v],A,c))+(x<0?0:(x*=x)*x*this.dot(this.grad3[g],h,u))+(b<0?0:(b*=b)*b*this.dot(this.grad3[y],d,f)))},Gu.prototype.noise3d=function(e,t,n){var i,r,a,o,s,l,A=(e+t+n)*(1/3),c=Math.floor(e+A),h=Math.floor(t+A),u=Math.floor(n+A),d=1/6,f=(c+h+u)*d,p=e-(c-f),m=t-(h-f),v=n-(u-f);p>=m?m>=v?(i=1,r=0,a=0,o=1,s=1,l=0):p>=v?(i=1,r=0,a=0,o=1,s=0,l=1):(i=0,r=0,a=1,o=1,s=0,l=1):mT?32:0)+(S>_?16:0)+(T>_?8:0)+(S>I?4:0)+(T>I?2:0)+(_>I?1:0),F=S-(r=v[L][0]>=3?1:0)+w,k=T-(a=v[L][1]>=3?1:0)+w,P=_-(o=v[L][2]>=3?1:0)+w,U=I-(s=v[L][3]>=3?1:0)+w,D=S-(l=v[L][0]>=2?1:0)+2*w,R=T-(A=v[L][1]>=2?1:0)+2*w,O=_-(c=v[L][2]>=2?1:0)+2*w,N=I-(h=v[L][3]>=2?1:0)+2*w,z=S-(u=v[L][0]>=1?1:0)+3*w,Q=T-(d=v[L][1]>=1?1:0)+3*w,G=_-(f=v[L][2]>=1?1:0)+3*w,H=I-(p=v[L][3]>=1?1:0)+3*w,V=S-1+4*w,j=T-1+4*w,W=_-1+4*w,X=I-1+4*w,Y=255&b,K=255&M,Z=255&C,J=255&B,q=g[Y+g[K+g[Z+g[J]]]]%32,$=g[Y+r+g[K+a+g[Z+o+g[J+s]]]]%32,ee=g[Y+l+g[K+A+g[Z+c+g[J+h]]]]%32,te=g[Y+u+g[K+d+g[Z+f+g[J+p]]]]%32,ne=g[Y+1+g[K+1+g[Z+1+g[J+1]]]]%32,ie=.6-S*S-T*T-_*_-I*I,re=.6-F*F-k*k-P*P-U*U,ae=.6-D*D-R*R-O*O-N*N,oe=.6-z*z-Q*Q-G*G-H*H,se=.6-V*V-j*j-W*W-X*X;return 27*((ie<0?0:(ie*=ie)*ie*this.dot4(m[q],S,T,_,I))+(re<0?0:(re*=re)*re*this.dot4(m[$],F,k,P,U))+(ae<0?0:(ae*=ae)*ae*this.dot4(m[ee],D,R,O,N))+(oe<0?0:(oe*=oe)*oe*this.dot4(m[te],z,Q,G,H))+(se<0?0:(se*=se)*se*this.dot4(m[ne],V,j,W,X)))};var Hu={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new tt},cameraProjectionMatrix:{value:new bt},cameraInverseProjectionMatrix:{value:new bt},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tDepth;","uniform sampler2D tNoise;","uniform vec3 kernel[ KERNEL_SIZE ];","uniform vec2 resolution;","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float kernelRadius;","uniform float minDistance;","uniform float maxDistance;","varying vec2 vUv;","#include ","float getDepth( const in vec2 screenPosition ) {","\treturn texture2D( tDepth, screenPosition ).x;","}","float getLinearDepth( const in vec2 screenPosition ) {","\t#if PERSPECTIVE_CAMERA == 1","\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;","\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );","\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );","\t#else","\t\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","\tclipPosition *= clipW; // unprojection.","\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec2 screenPosition ) {","\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","}","void main() {","\tfloat depth = getDepth( vUv );","\tfloat viewZ = getViewZ( depth );","\tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );","\tvec3 viewNormal = getViewNormal( vUv );"," vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );","\tvec3 random = texture2D( tNoise, vUv * noiseScale ).xyz;","\tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );","\tvec3 bitangent = cross( viewNormal, tangent );","\tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );"," float occlusion = 0.0;"," for ( int i = 0; i < KERNEL_SIZE; i ++ ) {","\t\tvec3 sampleVector = kernelMatrix * kernel[ i ];","\t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius );","\t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 );","\t\tsamplePointNDC /= samplePointNDC.w;","\t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5;","\t\tfloat realDepth = getLinearDepth( samplePointUv );","\t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar );","\t\tfloat delta = sampleDepth - realDepth;","\t\tif ( delta > minDistance && delta < maxDistance ) {","\t\t\tocclusion += 1.0;","\t\t}","\t}","\tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );","\tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );","}"].join("\n")},Vu={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDepth;","uniform float cameraNear;","uniform float cameraFar;","varying vec2 vUv;","#include ","float getLinearDepth( const in vec2 screenPosition ) {","\t#if PERSPECTIVE_CAMERA == 1","\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;","\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );","\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );","\t#else","\t\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","void main() {","\tfloat depth = getLinearDepth( vUv );","\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );","}"].join("\n")},ju={uniforms:{tDiffuse:{value:null},resolution:{value:new tt}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","void main() {","\tvec2 texelSize = ( 1.0 / resolution );","\tfloat result = 0.0;","\tfor ( int i = - 2; i <= 2; i ++ ) {","\t\tfor ( int j = - 2; j <= 2; j ++ ) {","\t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;","\t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;","\t\t}","\t}","\tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );","}"].join("\n")},Wu=function(e,t,n,i){hu.call(this),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this.generateSampleKernel(),this.generateRandomKernelRotations();var r=new ns;r.type=ee,r.minFilter=X,r.maxFilter=X,this.beautyRenderTarget=new dt(this.width,this.height,{minFilter:Z,magFilter:Z,format:ce,depthTexture:r,depthBuffer:!0,stencilBuffer:!0}),this.normalRenderTarget=new dt(this.width,this.height,{minFilter:X,magFilter:X,format:ce,stencilBuffer:!0}),this.ssaoRenderTarget=new dt(this.width,this.height,{minFilter:Z,magFilter:Z,format:ce,stencilBuffer:!0}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new Ri({defines:Object.assign({},Hu.defines),uniforms:Di.clone(Hu.uniforms),vertexShader:Hu.vertexShader,fragmentShader:Hu.fragmentShader,blending:0,stencilWrite:!0}),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.normalMaterial=new bl,this.normalMaterial.blending=0,this.normalMaterial.stencilWrite=!0,this.blurMaterial=new Ri({defines:Object.assign({},ju.defines),uniforms:Di.clone(ju.uniforms),vertexShader:ju.vertexShader,fragmentShader:ju.fragmentShader,stencilWrite:!0}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new Ri({defines:Object.assign({},Vu.defines),uniforms:Di.clone(Vu.uniforms),vertexShader:Vu.vertexShader,fragmentShader:Vu.fragmentShader,blending:0,stencilWrite:!0}),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new Ri({uniforms:Di.clone(du.uniforms),vertexShader:du.vertexShader,fragmentShader:du.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:R,blendDst:L,blendEquation:I,blendSrcAlpha:D,blendDstAlpha:L,blendEquationAlpha:I,stencilWrite:!0}),this.fsQuad=new hu.FullScreenQuad(null),this.originalClearColor=new Fn};Wu.prototype=Object.assign(Object.create(hu.prototype),{constructor:Wu,dispose:function(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.quad.geometry.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose()},toggleBackgroundVisible:function(e){e?(this.scene.background=this.scene._background,this.scene._shadow&&(this.scene._shadow.visible=!0),delete this.scene._background,delete this.scene._shadow):(this.scene._background=this.scene.background,this.scene.background=null,this.scene._shadow&&(this.scene._shadow.visible=!1))},render:function(e,t,n,i,r){switch(this.beautyRenderTarget=n,this.toggleBackgroundVisible(!1),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.toggleBackgroundVisible(!0),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case Wu.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=0,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Wu.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=0,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Wu.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=0,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Wu.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Wu.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=0,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Wu.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=0,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=5,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("SSAOPass: Unknown output type.")}},renderPass:function(e,t,n,i,r){this.originalClearColor.copy(e.getClearColor());var a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=o,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)},renderOverride:function(e,t,n,i,r){this.originalClearColor.copy(e.getClearColor());var a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)},setSize:function(e,t){this.width=e,this.height=t,this.beautyRenderTarget.setSize(e,t),this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.blurMaterial.uniforms.resolution.value.set(e,t)},generateSampleKernel:function(){for(var e=this.kernelSize,t=this.kernel,n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return s(this,n),e=t.call(this,i),null==i.darkness&&(i.darkness=.5),null==i.offset&&(i.offset=.5),e}return A(n,[{key:"init",value:function(e){this.pass=new Yu(Ku),this.pass.enabled=!0,this.pass.uniforms.darkness.value=this.options.darkness,this.pass.uniforms.offset.value=this.options.offset,b(u(n.prototype),"init",this).call(this)}},{key:"getDarkness",value:function(){return this.pass.uniforms.darkness.value}},{key:"setDarkness",value:function(e){this.pass.uniforms.darkness.value=e}},{key:"getOffset",value:function(){return this.pass.uniforms.offset.value}},{key:"setOffset",value:function(e){this.pass.uniforms.offset.value=e}}]),n}(Bu),Ju=function(e,t,n,i){hu.call(this),this.renderScene=e,this.renderCamera=t,this.oldClearColor=new Fn,this.oldClearAlpha=1,i=i||{},this.center=i.center?(new at).copy(i.center):new at(0,0,0),this.maxRange=i.maxRange?i.maxRange:50;var r=i.speed?i.speed:30;this.frameSpeed=r/60,this.radius=i.radius?i.radius:5,this.innerRadius=-this.radius,this.outerRadius=0,this.fillType=0==i.fillType?0:1,this.fillColor=i.fillColor?i.fillColor:new Fn("#ffff00");var a={minFilter:Z,magFilter:Z,format:ce,stencilBuffer:!0};n.antialias=!0,n.alpha=!0;var o=n.getSize(new tt),s=n.getPixelRatio(),l=o.width,A=o.height;this.depthTarget=new dt(l*s,A*s,a),this.depthTarget.depthBuffer=!0,this.depthTarget.depthTexture=new ns;var c=this.getShaderOptions();this.depthMaterial=new Ri(c),this.fsQuad=new hu.FullScreenQuad(this.depthMaterial)};Ju.prototype=Object.assign(Object.create(hu.prototype),{constructor:Ju,render:function(e,t,n,i,r){this.updateUniforms(n),this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var a=e.autoClear;e.autoClear=!1,e.setRenderTarget(t),this.fsQuad.render(e),e.setRenderTarget(this.depthTarget),e.render(this.renderScene,this.renderCamera),e.setRenderTarget(null),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=a},calCameraVectors:function(){var e=this.renderCamera,t=e.near,n=e.fov,i=e.aspect,r=Math.tan(this.ang2rad(n/2))*t,a=r*i,o=new at(0,0,1).applyMatrix4(e.matrixWorld.clone());o.sub(e.position.clone()),o.normalize();var s=new at(-1,0,0).applyMatrix4(e.matrixWorld.clone());s.sub(e.position.clone()),s.normalize();var l=new at(0,-1,0).applyMatrix4(e.matrixWorld.clone());l.sub(e.position.clone()),l.normalize();var A=s.multiplyScalar(a),c=l.multiplyScalar(r),h=o.clone().multiplyScalar(t).add(c.clone()).sub(A.clone()),u=h.length()/t;h.normalize(),h.multiplyScalar(-u);var d=o.clone().multiplyScalar(t).add(A.clone()).add(c.clone());d.normalize(),d.multiplyScalar(-u);var f=o.clone().multiplyScalar(t).sub(c.clone()).sub(A.clone());f.normalize(),f.multiplyScalar(-u);var p=o.clone().multiplyScalar(t).add(A.clone()).sub(c.clone());p.normalize(),p.multiplyScalar(-u),this.topLeftVec=h,this.topRightVec=d,this.bottomLeftVec=f,this.bottomRightVec=p},updateUniforms:function(e){this.calCameraVectors(),this.depthMaterial.uniforms.colorTexture.value=e.texture,this.depthMaterial.uniforms.cameraPos.value=this.renderCamera.position,this.depthMaterial.uniforms.topLeftVec.value=this.topLeftVec,this.depthMaterial.uniforms.topRightVec.value=this.topRightVec,this.depthMaterial.uniforms.bottomLeftVec.value=this.bottomLeftVec,this.depthMaterial.uniforms.bottomRightVec.value=this.bottomRightVec,this.depthMaterial.uniforms.center.value=this.center,this.depthMaterial.uniforms.fillType.value=this.fillType,this.depthMaterial.uniforms.fillColor.value=this.fillColor,this.depthMaterial.uniforms.innerRadius.value>this.maxRange&&(this.depthMaterial.uniforms.innerRadius.value=-this.radius,this.depthMaterial.uniforms.outerRadius.value=0),this.depthMaterial.uniforms.innerRadius.value+=this.frameSpeed,this.depthMaterial.uniforms.outerRadius.value=this.depthMaterial.uniforms.innerRadius.value+this.radius},ang2rad:function(e){return e*Math.PI/180},getShaderOptions:function(){var e={transparent:!0};return e.uniforms={colorTexture:{value:null},depthTexture:{value:this.depthTarget.depthTexture},cameraFar:{value:this.renderCamera.far},cameraNear:{value:this.renderCamera.near},cameraPos:{value:this.renderCamera.position.clone()},topLeftVec:{value:this.topLeftVec},topRightVec:{value:this.topRightVec},bottomLeftVec:{value:this.bottomLeftVec},bottomRightVec:{value:this.bottomRightVec},center:{value:this.center.clone()},innerRadius:{value:this.innerRadius},outerRadius:{value:this.outerRadius},fillType:{value:this.fillType},fillColor:{value:this.fillColor}},e.vertexShader="\n precision highp float;\n uniform vec3 topLeftVec;\n uniform vec3 topRightVec;\n uniform vec3 bottomLeftVec;\n uniform vec3 bottomRightVec;\n \n varying vec2 vUv;\n varying vec3 cameraVec;\n \n void main() {\n vUv = uv;\n if(uv.x < 0.5 && uv.y < 0.5) { // bottom left \n cameraVec = bottomLeftVec;\n }else if(uv.x < 0.5 && uv.y > 0.5) { // top left\n cameraVec = topLeftVec;\n }else if(uv.x > 0.5 && uv.y > 0.5) { // top right\n cameraVec = topRightVec;\n }else { // bottom right \n cameraVec = bottomRightVec;\n }\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",e.fragmentShader="\n #include \n varying vec2 vUv;\n varying vec3 cameraVec;\n \n uniform float cameraFar;\n uniform float cameraNear;\n uniform vec3 cameraPos;\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n \n uniform vec3 center;\n uniform float innerRadius;\n uniform float outerRadius;\n uniform int fillType;\n uniform vec3 fillColor;\n \n float readClipZ( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n return perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar ); // 返回相机空间的 viewZ(相对于相机空间的实际z)\n }\n \n void main() {\n // gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n // return;\n float clipZ = readClipZ( depthTexture, vUv );\n \n vec4 diff = texture2D( colorTexture, vUv);\n vec3 wP = cameraPos + (cameraVec)*abs(clipZ);\n \n float dis = distance(wP, center);\n float circleWidth = outerRadius - innerRadius;\n if(dis < outerRadius && dis > innerRadius) {\n if(fillType == 1) { // pure: 0 - linear: 1\n gl_FragColor = vec4(mix(diff.xyz, fillColor, (dis - innerRadius)/circleWidth), 1.0);\n }else {\n gl_FragColor = vec4(mix(diff.xyz, fillColor, 0.5), 1.0);\n }\n }else {\n gl_FragColor = diff;\n }\n }",e}});var qu=function(e){h(n,e);var t=y(n);function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,n),t.call(this,e)}return A(n,[{key:"init",value:function(e){this.pass=new Ju(e.scene,e.camera,e.renderer,this.options),this.pass.enabled=!0,b(u(n.prototype),"init",this).call(this)}},{key:"getSpeed",value:function(){return this.pass.frameSpeed}},{key:"setSpeed",value:function(e){if(e){var t=e/60;this.pass.frameSpeed=t}}},{key:"getRadius",value:function(){return this.pass.radius}},{key:"setRadius",value:function(e){e&&(this.pass.radius=e)}},{key:"getMaxRange",value:function(){return this.pass.maxRange}},{key:"setMaxRange",value:function(e){e&&(this.pass.maxRange=e)}},{key:"getCenter",value:function(){return this.pass.radius}},{key:"setCenter",value:function(e){e&&(this.pass.center=(new at).copy(e))}},{key:"getFillType",value:function(){return this.pass.fillType}},{key:"setFillType",value:function(e){this.pass.fillType=0==e?0:1}},{key:"getFillColor",value:function(){return this.pass.fillColor}},{key:"setFillColor",value:function(e){e&&(this.pass.fillColor=new Fn(e))}}]),n}(Bu),$u=function(e){h(n,e);var t=y(n);function n(e){var i,r=e.renderer,a=e.scene,o=e.camera,l=e.groundReflector;return s(this,n),(i=t.call(this)).renderer=r,i.scene=a,i.camera=o,i.groundReflector=l,i.needsSwap=!1,i}return A(n,[{key:"dispose",value:function(){}},{key:"render",value:function(e,t,n,i,r){this.groundReflector.doRender(this.renderer,this.scene,this.camera),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(n),e.render(this.scene,this.camera)}},{key:"setSize",value:function(e,t){this.width=e,this.height=t,this.groundReflector.resize(e,t)}}]),n}(hu),ed=5+[.125,.215,.35,.446,.526,.582].length,td=new FA,nd=[.0205,.0855,.232,.324,.232,.0855,.0205],id=function(){function e(t){s(this,e),this._renderer=t,this._oldTarget=null,this.srcWidth=512,this.srcHeight=512,this.renderTexture=null,this._pingPongRenderTexture=null,this._lodPlanes=[],this._sizeLods=[],this.isInit=!1}return A(e,[{key:"init",value:function(){this.isInit||(this.isInit=!0,this._createPlanes(),this._blurMaterial=this._getTextureBlurShader(7),this._compileMaterial(this._blurMaterial),this._material=this._getTextureShader(),this._compileMaterial(this._material))}},{key:"dispose",value:function(){this.renderTexture&&this.renderTexture.dispose(),this._pingPongRenderTexture&&this._pingPongRenderTexture.dispose(),this._lodPlanes=[],this._sizeLods=[],this.isInit=!1,this._blurMaterial&&this._blurMaterial.dispose(),this._material&&this._material.dispose()}},{key:"fromTexture",value:function(e){return this._oldTarget=this._renderer.getRenderTarget(),this.srcWidth=e.image.width,this.srcHeight=this.srcWidth,this.init(),this.createTargets(e),this.textureUV(e),this._applyMipmap(),this.renderTexture}},{key:"textureUV",value:function(e){var t=new Qt;t.add(new Ei(this._lodPlanes[0],this._material)),this._material.uniforms.envMap.value=e,this._setViewport(this.renderTexture,0,0,this.srcWidth,this.srcHeight),this._renderer.setRenderTarget(this.renderTexture),this._renderer.render(t,td)}},{key:"_applyMipmap",value:function(){var e=this._renderer.autoClear;this._renderer.autoClear=!1;for(var t=1;t=9?t/10:t>=6?.4+(t-6)/3*.5:t>=5?.305+.095*(t-5):t>=4?.21+.095*(t-4):t/4*.21}},{key:"_halfBlur",value:function(e,t,n,i,r){var a=new Qt;a.add(new Ei(this._lodPlanes[i],this._blurMaterial));var o=this._blurMaterial.uniforms;o.envMap.value=e.texture,o.weights.value=nd,o.mipInt.value=n,o.isVertical.value=r,o.roughness.value=this.getRoughness(n)/this.getRoughness(n-1);var s=this._sizeLods[i];o.texSize.value=this._sizeLods[n],o.maxSize.value=this.srcWidth;var l=Math.max(0,this.srcWidth-2*s),A=(0===i?0:this.srcWidth)+s*(i>4?i-8+4:0);this._setViewport(t,l,A,s,s),this._renderer.setRenderTarget(t),this._renderer.render(a,td)}},{key:"_createPlanes",value:function(){for(var e=this.srcWidth,t=0;tthis.srcWidth/16&&(e/=2)}}},{key:"createTargets",value:function(e){var t={magFilter:X,minFilter:X,generateMipmaps:!1,type:e?e.type:$,format:e?e.format:de,encoding:e?e.encoding:Qe,depthBuffer:!1,stencilBuffer:!1};this.renderTexture||(this.renderTexture=this.createRenderTexture(t),this.renderTexture.depthBuffer=!e),this._pingPongRenderTexture||(this._pingPongRenderTexture=this.createRenderTexture(t))}},{key:"createRenderTexture",value:function(e){var t=new dt(this.srcWidth,this.srcWidth+this.srcWidth/2,e);return t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}},{key:"_setViewport",value:function(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}},{key:"_compileMaterial",value:function(e){var t=new Qt;t.add(new Ei(this._lodPlanes[0],e)),this._renderer.compile(t,td)}},{key:"_getTextureBlurShader",value:function(e){var t=new vl({uniforms:{envMap:{value:null},weights:{value:new Float32Array(e)},mipInt:{value:0},texSize:{value:0},maxSize:{value:0},isVertical:{value:0},roughness:{value:1}},vertexShader:this._getTextureCommonVertex(),fragmentShader:"\n precision mediump float;\n precision mediump int;\n varying vec2 vUv;\n uniform sampler2D envMap;\n uniform float weights[7];\n uniform float mipInt;\n uniform float texSize;\n uniform float maxSize;\n uniform int isVertical;\n uniform float roughness;\n\n vec3 sampleTexture(sampler2D envMap,vec2 uv,vec2 xRange,vec2 yRange){\n\n float xpercent = 1.0 / maxSize;\n float maxY = (maxSize + maxSize / 2.0);\n float ypercent = 1.0 / maxY;\n if(uv.x > xRange.y){\n uv.x = xRange.y - xpercent;\n }\n if(uv.x < xRange.x){\n uv.x = xRange.x + xpercent;\n }\n if(uv.y > yRange.y){\n uv.y = yRange.y - ypercent;;// - ypercent;\n }\n if(uv.y < yRange.x){\n uv.y = yRange.x + ypercent;\n }\n\n return texture2D(envMap,uv).rgb;\n }\n \n vec3 bilinearCubeUV(sampler2D envMap, float mipInt) {\n\n float maxY = (maxSize + maxSize / 2.0);\n vec2 uv = vUv;\n vec2 xRange = vec2(0.0,1.0);\n vec2 yRange = vec2(0.0,1.0);\n if(mipInt == 0.0 ){\n float uvx = vUv.x;\n float uvy = vUv.y * (texSize / maxY);\n uv = vec2(uvx,uvy);\n yRange.y = texSize / maxY;\n }\n else\n {\n xRange.x = (maxSize - 2.0 * texSize) / maxSize;\n xRange.y = xRange.x + texSize / maxSize;\n\n float uvx = xRange.x + (texSize / maxSize) * vUv.x;\n float uvy = vUv.y;\n if(mipInt < 5.0){\n yRange.x = maxSize / maxY;\n yRange.y = maxSize / maxY + texSize / maxY;\n uvy = yRange.x + texSize / maxY * vUv.y;\n }\n if(mipInt > 4.0){\n yRange.x = (maxSize + (mipInt - 4.0) * texSize) / maxY;\n yRange.y = (maxSize + (mipInt - 4.0) * texSize) / maxY + texSize / maxY;\n uvy = yRange.x + texSize / maxY * vUv.y;\n }\n uv = vec2(uvx,uvy);\n }\n\n float xpercent = 1.0 / maxSize;\n float ypercent = 1.0 / maxY;\n vec3 finalCol = vec3(0.0,0.0,0.0);\n float offset = 1.0;\n if(isVertical == 1){\n finalCol += sampleTexture(envMap, uv - vec2(0.0,ypercent * offset * 3.0),xRange,yRange).rgb * weights[0];\n finalCol += sampleTexture(envMap, uv - vec2(0.0,ypercent * offset * 2.0),xRange,yRange).rgb * weights[1];\n finalCol += sampleTexture(envMap, uv - vec2(0.0,ypercent * offset * 1.0),xRange,yRange).rgb * weights[2];\n finalCol += sampleTexture(envMap, uv,xRange,yRange).rgb * weights[3];\n finalCol += sampleTexture(envMap, uv + vec2(0.0,ypercent * offset * 3.0),xRange,yRange).rgb * weights[4];\n finalCol += sampleTexture(envMap, uv + vec2(0.0,ypercent * offset * 2.0),xRange,yRange).rgb * weights[5];\n finalCol += sampleTexture(envMap, uv + vec2(0.0,ypercent * offset * 1.0),xRange,yRange).rgb * weights[6];\n }else{\n finalCol += sampleTexture(envMap, uv - vec2(xpercent * offset * 3.0,0.0),xRange,yRange).rgb * weights[0];\n finalCol += sampleTexture(envMap, uv - vec2(xpercent * offset * 2.0,0.0),xRange,yRange).rgb * weights[1];\n finalCol += sampleTexture(envMap, uv - vec2(xpercent * offset * 1.0,0.0),xRange,yRange).rgb * weights[2];\n finalCol += sampleTexture(envMap, uv,xRange,yRange).rgb * weights[3];\n finalCol += sampleTexture(envMap, uv + vec2(xpercent * offset * 3.0,0.0),xRange,yRange).rgb * weights[4];\n finalCol += sampleTexture(envMap, uv + vec2(xpercent * offset * 2.0,0.0),xRange,yRange).rgb * weights[5];\n finalCol += sampleTexture(envMap, uv + vec2(xpercent * offset * 1.0,0.0),xRange,yRange).rgb * weights[6];\n }\n // finalCol = texture2D(envMap,uv).rgb;\n return finalCol * roughness;\n }\n \n void main() {\n gl_FragColor = vec4(1.0,1.0,1.0,1.0);\n gl_FragColor.rgb = bilinearCubeUV(envMap, mipInt);\n return;\n \n }\n ",blending:0,side:2,depthTest:!1,depthWrite:!1});return t.type="SphericalGaussianBlur",t}},{key:"_getTextureShader",value:function(){var e=new vl({uniforms:{envMap:{value:null},texelSize:{value:new tt(1,1)}},vertexShader:this._getTextureCommonVertex(),fragmentShader:"\n precision mediump float;\n precision mediump int;\n varying vec2 vUv;\n uniform sampler2D envMap;\n void main() {\n gl_FragColor = texture2D(envMap, vUv);\n }\n ",blending:0,depthTest:!1,depthWrite:!1});return e.type="EquirectangularToCubeUV",e}},{key:"_getTextureCommonVertex",value:function(){return"\n precision mediump float;\n precision mediump int;\n attribute vec3 position;\n attribute vec2 uv;\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = vec4( position, 1.0 );\n }\n "}}]),e}(),rd=A((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,e),this.type="ReflectorForSSRPass",this.renderer=t.renderer,this.scene=t.scene;var n=this,i=t.textureWidth||512,r=t.textureHeight||512,a=!0===t.useDepthTexture,o=new at(0,1,0),l=new at,A=new at;this.pmremGenerator=new id(this.renderer),this.maxDistance=180,this.opacity=1,n.resolution=t.resolution||new tt(window.innerWidth,window.innerHeight);var c,h=new at,u=new at,d=new at,f=new bt,p=new at(0,0,-1),m=new at,v=new at,g=new bt,y=new Ni;a&&((c=new ns).type=ee,c.minFilter=X,c.magFilter=X);var w={depthTexture:a?c:null,magFilter:X,minFilter:X,generateMipmaps:!1},x=new dt(i,r,w);this.reflectTexture=null,this.objects=[],this.planes=[],this.mainPlane=null;var b=new at;this.doRender=function(e,t,n){if(this.mainPlane&&(l.copy(n.position).normalize(),A.copy(l).reflect(o),u.setFromMatrixPosition(this.mainPlane.matrixWorld),d.setFromMatrixPosition(n.matrixWorld),f.extractRotation(this.mainPlane.matrixWorld),h.set(0,0,1),h.applyMatrix4(f),m.subVectors(u,d),!(m.dot(h)>0))){m.reflect(h).negate(),m.add(u),f.extractRotation(n.matrixWorld),p.set(0,0,-1),p.applyMatrix4(f),p.add(d),v.subVectors(u,p),v.reflect(h).negate(),v.add(u),y.position.copy(m),y.up.set(0,1,0),y.up.applyMatrix4(f),y.up.reflect(h),y.lookAt(v),y.far=n.far,y.updateMatrixWorld(),y.projectionMatrix.copy(n.projectionMatrix),g.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),g.multiply(y.projectionMatrix),g.multiply(y.matrixWorldInverse),g.multiply(this.mainPlane.matrixWorld);var i=e.getRenderTarget();this.setPlaneVisible(!1),e.setRenderTarget(x),e.state.buffers.depth.setMask(!0),!1===e.autoClear&&e.clear(),this.visibleObject(t,!1),e.render(t,y),this.visibleObject(t,!0),this.reflectTexture=this.pmremGenerator.fromTexture(x.texture).texture,this.setPlaneVisible(!0),this.refreshPlaneMaterial(n,y),e.setRenderTarget(i);var r=n.viewport;void 0!==r&&e.state.viewport(r)}},this.visibleObject=function(e,t){var n=this;0!==this.objects.length&&e.traverse((function(e){e.isMesh&&!n.objects.includes(e)&&(t?e.visible=e.cacheVisible:(e.cacheVisible=e.visible,e.visible=!1))}))},this.getRenderTarget=function(){return x},this.setPlaneVisible=function(e){for(var t=0;t0}},{key:"domElement",get:function(){return this.composer.renderer.domElement}},{key:"enableOutline",get:function(){return this._enableOutline},set:function(e){this.enableDof||this._enableOutline!=Boolean(e)&&(e?(this.add(this.outline),this.outline.clear()):this.remove(this.outline),this._enableOutline=e)}},{key:"enableUnrealBloom",get:function(){return this._enableUnrealBloom},set:function(e){this._enableUnrealBloom!=Boolean(e)&&(e?(this.add(this.unrealBloom),this.unrealBloom.clear()):this.remove(this.unrealBloom),this._enableUnrealBloom=e)}},{key:"enableDof",get:function(){return this._enableDof},set:function(e){this._enableDof!=Boolean(e)&&(e?this.add(this.dof):this.remove(this.dof),this._enableDof=e)}},{key:"enableColorAdjustment",get:function(){return this._enableColorAdjustment},set:function(e){this._enableColorAdjustment!==Boolean(e)&&(e?this.add(this.colorAdjustment):this.remove(this.colorAdjustment),this._enableColorAdjustment=Boolean(e))}},{key:"enableSSAO",get:function(){return this._enableSSAO},set:function(e){this._enableSSAO!==Boolean(e)&&(this.ssao.setMaxDistance(.001),this.ssao.setMinDistance(1e-4),this.ssao.setRadius(16),e?this.add(this.ssao):this.remove(this.ssao),this._enableSSAO=Boolean(e))}},{key:"enableVignette",get:function(){return this._enableVignette},set:function(e){this._enableVignette!=Boolean(e)&&(e?this.add(this.vignette):this.remove(this.vignette),this._enableVignette=e)}},{key:"enableCircleSweep",get:function(){return this._enableCircleSweep},set:function(e){this._enableCircleSweep!=Boolean(e)&&(e?this.add(this.circleSweep):this.remove(this.circleSweep),this._enableCircleSweep=e)}},{key:"enableSSR",get:function(){return this._enableSSR},set:function(e){this._enableSSR!=Boolean(e)&&(e?this.add(this.ssr):this.remove(this.ssr),this._enableSSR=e)}},{key:"_initComposer",value:function(){this.renderPass=new uu(this.scene,this.camera),this.composer=new vu(this.renderer),this.FXAA=new fu(yu),this.FXAA.uniforms.resolution.value.set(1/this.width,1/this.height);var e=this.renderer.getPixelRatio();this.SMAA=new Mu(this.width*e,this.height*e)}},{key:"add",value:function(e){var t;e&&this.processArray.indexOf(e)<0&&(this.composer||this._initComposer(),e.inited||(e.init({camera:this.camera,renderer:this.renderer,scene:this.scene,width:this.width,height:this.height,viewer:this.viewer}),e.inited=!0),this.composer.passes.length=0,this.composer.addPass(this.renderPass),(this.processArray.includes(this.ssao)||e===this.ssao)&&this.composer.addPass(this.ssao.pass),(this.processArray.includes(this.ssr)||e===this.ssr)&&this.composer.addPass(this.ssr.pass),(this.processArray.includes(this.colorAdjustment)||e===this.colorAdjustment)&&this.composer.addPass(this.colorAdjustment.pass),(this.processArray.includes(this.colorGradient)||e===this.colorGradient)&&this.composer.addPass(this.colorGradient.pass),(this.processArray.includes(this.outline)||e===this.outline)&&this.composer.addPass(this.outline.pass),(this.processArray.includes(this.unrealBloom)||e===this.unrealBloom)&&this.composer.addPass(this.unrealBloom.pass),(this.processArray.includes(this.vignette)||e===this.vignette)&&this.composer.addPass(this.vignette.pass),(this.processArray.includes(this.circleSweep)||e===this.circleSweep)&&this.composer.addPass(this.circleSweep.pass),(this.processArray.includes(this.dof)||e===this.dof)&&(this.composer.addPass(this.dof.pass),t=!0),t||this.composer.addPass(this.FXAA),this.processArray.push(e));this.enabled&&this.viewer.renderManager.setRenderer(this),setTimeout(this.viewer.renderManager.render,20)}},{key:"remove",value:function(e){e&&this.processArray.includes(e)&&(this.composer.passes.remove(e.pass),this.processArray.remove(e),e.dispose&&e.dispose()),this.enabled||this.viewer.renderManager.setRenderer(),this.viewer.renderManager.render()}},{key:"render",value:function(){this.onBeforeRender(),this.processArray.forEach((function(e){e.render()})),this.composer.render(),this.onAfterRender()}},{key:"onBeforeRender",value:function(){this.processArray.includes(this.ssao)&&(this.shadow=!1)}},{key:"onAfterRender",value:function(){this.processArray.includes(this.ssao)}},{key:"resize",value:function(e,t){this.width=e,this.height=t,this.composer.setSize(e,t),this.processArray.forEach((function(n){n.setSize(e,t)})),this.FXAA&&this.FXAA.uniforms.resolution.value.set(1/e,1/t),this.SMAA&&this.SMAA.setSize(e,t)}},{key:"dispose",value:function(){this.processArray.length=0,this.composer=null}}]),e}();function sd(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)}var ld={UPDATE:"update",CHANGE:"change",ENDED:"ended",LOOP:"loop",MAP_INIT:"map_init",MAP_LOADED:"map_loaded",MESH_LOADED:"mesh_loaded",MESH_LOAD_ERROR:"mesh_load_error"};ld.MESH_LOAD_ERROR="mesh_load_error",ld.MATERIAL_LOADED="material_loaded",ld.MATERIAL_LOAD_ERROR="material_load_error",ld.ANIMATION_LOADED="animation_loaded",ld.ANIMATION_LOAD_ERROR="animation_load_error",ld.MODEL_UPDATE="model_update",ld.START=sd()?"touchstart":"mousedown",ld.MOVE=sd()?"touchmove":"mousemove",ld.END=sd()?"touchend":"mouseup",ld.MESSAGE="message",ld.TEXTURE_LOADED="texture_loaded",ld.CLICK="click",ld.CAMERA_MOVED="camera-moved";var Ad={click:"click",rightClick:"rightClick",centerClick:"centerClick",doubleClick:"doubleClick",mousemove:"mousemove",mouseDown:"mousedown",mouseUp:"mouseup"},cd=function(){this._tweens={},this._tweensAddedDuringUpdate={},this._tweens={},this._tweensAddedDuringUpdate={}};cd.prototype={getAll:function(){return Object.keys(this._tweens).map(function(e){return this._tweens[e]}.bind(this))},removeAll:function(){this._tweens={}},add:function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},remove:function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},update:function(e,t){var n=Object.keys(this._tweens);if(0===n.length)return!1;for(e=void 0!==e?e:ud.now();n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?1:n,i=this._easingFunction(n),this._valuesEnd)if(void 0!==this._valuesStart[t]){var r=this._valuesStart[t]||0,a=this._valuesEnd[t];a instanceof Array?this._object[t]=this._interpolationFunction(a,i):("string"==typeof a&&(a="+"===a.charAt(0)||"-"===a.charAt(0)?r+parseFloat(a):parseFloat(a)),"number"==typeof a&&(this._object[t]=r+(a-r)*i))}if(null!==this._onUpdateCallback&&this._onUpdateCallback(this._object,n),1===n){if(this._repeat>0){for(t in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat){if("string"==typeof this._valuesEnd[t]&&(this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(this._valuesEnd[t])),this._yoyo){var o=this._valuesStartRepeat[t];this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=o}this._valuesStart[t]=this._valuesStartRepeat[t]}return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,null!==this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var s=0,l=this._chainedTweens.length;s1?a(e[n],e[n-1],n-i):a(e[r],e[r+1>n?n:r+1],i-r)},Bezier:function(e,t){for(var n=0,i=e.length-1,r=Math.pow,a=ud.Interpolation.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-t,i-o)*r(t,o)*e[o]*a(i,o);return n},CatmullRom:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),a=ud.Interpolation.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(r=Math.floor(i=n*(1+t))),a(e[(r-1+n)%n],e[r],e[(r+1)%n],e[(r+2)%n],i-r)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],i-n)-e[n]):a(e[r?r-1:0],e[r],e[n1;n--)t*=n;return hd[e]=t,t}),CatmullRom:function(e,t,n,i,r){var a=.5*(n-e),o=.5*(i-t),s=r*r;return(2*t-2*n+a+o)*(r*s)+(-3*t+3*n-2*a-o)*s+a*r+t}}};var dd=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,n),(i=t.call(this)).clock=new lc,i._renderer=null,i._defaultRenderer=null,i.container=null,i.containerRect=null,i.renderEnabled=!1,i.scene=null,i.camera=null,i.defaultCamera=null,i.animationFrameHandler=null,i.beforeRenderQueue=[],i.afterRenderQueue=[],i.needsUpdate=!0,i.loop=!0,i.viewer=e,i.needsUpdate=!0,i.loop=!0,i.container=e.container,i.containerRect=i.container.getBoundingClientRect();var a={antialias:!0,alpha:!0,logarithmicDepthBuffer:Boolean(r.logarithmicDepthBuffer)};return(i.container.nodeName&&"CANVAS"===i.container.nodeName.toUpperCase()||i.container.tagName&&"CANVAS"===i.container.tagName.toUpperCase())&&(a.canvas=i.container),i._renderer=new $a(a),i._renderer.setClearAlpha(0),i._renderer.setPixelRatio(window.devicePixelRatio),i._renderer.setSize(i.containerRect.width,i.containerRect.height),i._defaultRenderer=i._renderer,i.domElement.style.backgroundColor="#000",void 0===a.canvas&&i.container.appendChild(i.domElement),i}return A(n,[{key:"domElement",get:function(){return this.getRenderer().domElement}},{key:"defaultRenderer",get:function(){return this._defaultRenderer}},{key:"renderer",get:function(){return this._renderer}},{key:"setRenderer",value:function(e){this._renderer=void 0!==e?e:this._defaultRenderer}},{key:"getRenderer",value:function(){return this._renderer||(this._renderer=this.defaultRenderer),this._renderer.isPostProcessingManager?this._renderer.composer.renderer:this._renderer}},{key:"setCamera",value:function(e){this.camera=void 0!==e?e:this.defaultCamera}},{key:"setLoop",value:function(e){this.loop=e,this.animate()}},{key:"render",value:function(e){this.renderEnabled=!0,e&&this.animate()}},{key:"render2",value:function(e,t){var n=this;e||(e=this.scene),t||(t=this.camera);var i=this.clock.getDelta();this.moduleManager.update(i),this._onBeforeRender(i),this.beforeRenderQueue.map((function(r){"function"==typeof r&&r(n._renderer,e,t,i)})),this._renderer.render(e,t),this.afterRenderQueue.map((function(r){"function"==typeof r&&r(n._renderer,e,t,i)})),ud.update(),this._onAfterRender(i),this.animationFrameHandler&&cancelAnimationFrame(this.animationFrameHandler),this.loop&&(this.animationFrameHandler=requestAnimationFrame((function(){n.animate()}))),this.dispatchEvent({type:ld.UPDATE})}},{key:"animate",value:function(){var e=this;if(this.renderEnabled&&this.needsUpdate){var t=this.clock.getDelta();this.moduleManager.update(t),this._onBeforeRender(t),this.beforeRenderQueue.map((function(n){"function"==typeof n&&n(e._renderer,e.scene,e.camera,t)})),this._renderer.render(this.scene,this.camera),this.afterRenderQueue.map((function(n){"function"==typeof n&&n(e._renderer,e.scene,e.camera,t)})),ud.update(),this._onAfterRender(t),this.animationFrameHandler&&cancelAnimationFrame(this.animationFrameHandler),this.loop&&(this.animationFrameHandler=requestAnimationFrame((function(){e.animate()}))),this.dispatchEvent({type:ld.UPDATE})}}},{key:"addBeforeRenderTask",value:function(e){this.beforeRenderQueue.includes(e)||this.beforeRenderQueue.push(e)}},{key:"removeBeforeRenderTask",value:function(e){this.beforeRenderQueue.includes(e)&&this.beforeRenderQueue.remove(e)}},{key:"addAfterRenderTask",value:function(e){this.afterRenderQueue.includes(e)||this.afterRenderQueue.push(e)}},{key:"removeAfterRenderTask",value:function(e){this.afterRenderQueue.includes(e)&&this.afterRenderQueue.remove(e)}},{key:"_onBeforeRender",value:function(e){var t=this,n=this.getRenderer();this.scene.getObjectByName("root").traverse((function(i){i.onBeforeRender&&i.onBeforeRender(n,t.scene,t.camera,e)}))}},{key:"_onAfterRender",value:function(e){var t=this,n=this.getRenderer();this.scene.getObjectByName("root").traverse((function(i){i.update&&i.update(e),i.onAfterRender&&i.onAfterRender(n,t.scene,t.camera,e)}))}},{key:"resize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=this.container.getBoundingClientRect(),this.containerRect=e,this.getRenderer().setSize(e.width,e.height),this._renderer.composer&&this._renderer.resize(e.width,e.height),this.render()}},{key:"disabled",value:function(){this.needsUpdate=!1}},{key:"dispose",value:function(){cancelAnimationFrame(this.animationFrameHandler),this.setRenderer(),this._renderer.dispose(),this._renderer.forceContextLoss(),this._renderer=null,this.disabled()}}]),n}(Je),fd=function(){function e(){s(this,e)}return A(e,null,[{key:"create",value:function(t,n){var i=new dd(t,n);return e.RenderManagerArray.push(i),i}},{key:"render",value:function(t){for(var n=0;n=this._endTime&&(this.setCurrentTime(this._endTime),this.pause(),this._playTime=this._startTime)),this._mixer.update(e)}}},{key:"hasAnimation",value:function(){return this._animNameList.length>0}},{key:"list",value:function(){return this._animNameList}},{key:"playByTime",value:function(e,t,n){this._startTime=t,this._endTime=n,this._playTime=this._startTime,this._isSection=!0,this._play(e,this._loop,this._speed),this.setCurrentTime(this._startTime)}},{key:"clone",value:function(e){var t=this,i=new n(e);return i._speed=this._speed,i._paused=this._paused,i._clock=new lc,i._stopped=this._stopped,i.loop=this.loop,i.setAnimationList(this.getList()),this._clipMap.forEach((function(n){var r=n._clip;i.addClip(t.cloneAnimationClip(r,e))})),i}},{key:"cloneAnimationClip",value:function(e,t){if(e&&e.tracks){var n="BinLoader";n=t.modelPath.indexOf(".mbin")>-1||t.modelPath.indexOf(".mrmb")>-1?"BinLoader":"NewLoader";for(var i=[],r=0;r4&&void 0!==arguments[4]?arguments[4]:"#FFFFFF";return s(this,n),(o=t.call(this)).length=i,o.width=r,o.height=a,o.color=l,e&&(o.object=e,o._draw(i,r,a)),o}return A(n,[{key:"_draw",value:function(e,t,n){var i;i=this.object.isBox3?this.object:(new tn).setFromObject(this.object);var r=new at;i.getSize(r),this.maxLength=Math.max(r.x,r.y,r.z),this.textScale=2,this.textMeshScale=.002*this.maxLength,this.fontSize=20*this.textScale;var a=new at;i.getCenter(a);var o=.03*this.maxLength,s=.2*this.maxLength,l=.5*this.fontSize*this.textMeshScale/this.textScale,A=new at(i.min.x,i.max.y+s,a.z),c=new at(i.max.x,i.max.y+s,a.z);void 0!==e&&""!==e||(e=A.distanceTo(c).toFixed(4));var h=this._drawLine(A,c);h.rotation.z=Math.PI/2;var u=new at(A.x,A.y+l,A.z),d=new at(A.x,A.y-l,A.z);h=this._drawLine(u,d),u.set(c.x,c.y+l,c.z),d.set(c.x,c.y-l,c.z),h=this._drawLine(u,d);var f=this._drawText(e,new at(a.x,i.max.y+o+s,a.z)),p=f.clone();this.add(p),p.rotation.y=Math.PI,this.lengthMesh=f,this.lengthMesh.back=p,A.set(i.min.x-s,i.min.y,(i.max.z+i.min.z)/2),c.set(i.min.x-s,i.max.y,(i.max.z+i.min.z)/2),h=this._drawLine(A,c),void 0!==n&&""!==n||(n=A.distanceTo(c).toFixed(4)),u.set(A.x+l,A.y,A.z),d.set(A.x-l,A.y,A.z),(h=this._drawLine(u,d)).rotation.z=Math.PI/2,u.set(c.x+l,c.y,c.z),d.set(c.x-l,c.y,c.z),(h=this._drawLine(u,d)).rotation.z=Math.PI/2;var m=this._drawText(n,new at(i.min.x-o-s,a.y,a.z)),v=m.clone();this.add(v),v.position.x-=o/2,m.rotation.z=v.rotation.z=Math.PI/2,v.rotation.y=Math.PI,this.heightMesh=m,this.heightMesh.back=v,A.set(i.max.x+s,a.y,i.min.z),c.set(i.max.x+s,a.y,i.max.z),(h=this._drawLine(A,c)).rotation.x=Math.PI/2,void 0!==t&&""!==t||(t=A.distanceTo(c).toFixed(4)),u.set(A.x,A.y+l,A.z),d.set(A.x,A.y-l,A.z),h=this._drawLine(u,d),u.set(c.x,c.y+l,c.z),d.set(c.x,c.y-l,c.z),h=this._drawLine(u,d);var g=this._drawText(t,new at(i.max.x+s,a.y+o,a.z)),y=g.clone();this.add(y),g.rotation.y=y.rotation.y=Math.PI/2,y.rotation.y=-Math.PI/2,this.widthMesh=g,this.widthMesh.back=y}},{key:"updateSize",value:function(e,t,n){this.lengthMesh&&void 0!==e&&""!==e&&this._updateTextMesh(this.lengthMesh,e),this.widthMesh&&void 0!==t&&""!==t&&this._updateTextMesh(this.widthMesh,t),this.heightMesh&&void 0!==n&&""!==n&&this._updateTextMesh(this.heightMesh,n)}},{key:"_updateTextMesh",value:function(e,t){var n=e.material,i=n.map.image;this._fillText(n.map.image,t),n.map.needsUpdate=!0,n.needsUpdate=!0,e.back.material.map.needsUpdate=!0,e.back.material.needsUpdate=!0,e.back.geometry.dispose(),e.geometry.dispose(),e.back.geometry=e.geometry=new $i(i.width*this.textMeshScale/this.textScale,i.height*this.textMeshScale/this.textScale)}},{key:"_drawLine",value:function(e,t){var n=.005*this.maxLength*.5,i=new Ei(new ki(n,e.distanceTo(t),n),new Nn({color:this.color,side:2}));return i.position.copy(e.clone().add(t).multiplyScalar(.5)),i.renderOrder=5e3,this.add(i),i}},{key:"_drawText",value:function(e,t){var n=document.createElement("canvas");n.height=this.fontSize,this._fillText(n,e);var i=new $i(n.width*this.textMeshScale/this.textScale,n.height*this.textMeshScale/this.textScale),r=new ts(n);r.anisotropy=16;var a=new Nn({map:r,transparent:!0});a.depthTest=!1;var o=new Ei(i,a);return o.position.copy(t),this.add(o),o}},{key:"_fillText",value:function(e,t){var n=this.fontSize+"px 宋体";e.width=this._measureTextWidth(n,t);var i=e.getContext("2d");i.clearRect(0,0,e.width,e.height),i.font=n,i.fillStyle=this.color,i.textAlign="left",i.textBaseline="top",i.fillText(t,0,0)}},{key:"_measureTextWidth",value:function(e,t){this._measureCanvas||(this._measureCanvas=document.createElement("canvas"),this._measureCanvas.height=100,this._measureCanvas.width=100);var n=this._measureCanvas.getContext("2d");return n.font=e,n.measureText(t).width}},{key:"show",value:function(e,t,n,i){e&&this.object!==e&&(this.object=e),this.object&&this._draw(t,n,i),this.object.viewer.renderManager.render(!0)}},{key:"dispose",value:function(){}}]),n}(zt),Ld=function(e){h(n,e);var t=y(n);function n(e,i){var r;s(this,n),(r=t.call(this)).object=e,r.options=i||{},void 0===r.options.exposeFactor&&(r.options.exposeFactor=2),void 0===r.options.exposeByPart&&(r.options.exposeByPart=!1),void 0===r.options.exposeType&&(r.options.exposeType="NORMAL"),r.segments=3,r.prePercent=0,r.allModels=[];var a=r.object.getObjectByName("shadow");return r.options.exposeByPart?a.parent.children.forEach((function(e){e===a||e.isHotSpotEntity||e.children.forEach((function(e){r.allModels.push(e)}))})):r.object.traverse((function(e){e.geometry&&"shadow"!==e.name&&!e.isHotSpotEntity&&r.allModels.push(e)})),r.setMode(r.options.exposeType),r.object.viewer.renderManager.render(),r.exposeType=r.options.exposeType,r}return A(n,[{key:"setMode",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NORMAL",n=new at,i=new at,r=(new tn).setFromObject(this.object);switch(r.getCenter(n),r.getSize(i),t){case"SPHERE":var a=this.allModels.length,o=Math.ceil(Math.sqrt(a)),s=this._genSphereGeo(o,a),l=s.length,A=[],c=Math.max(i.x,i.y,i.z);this.allModels.forEach((function(t){var n=e._getRandom(l,A);A.push(n);var i=s[n].clone().normalize();t.direct=i.clone().multiplyScalar(c*e.options.exposeFactor)}));break;case"SEGMENT":var h=i.y/this.segments;this.allModels.forEach((function(t){var n=(new tn).setFromObject(t);t.direct||(t.direct=new at),n.getCenter(t.direct),n&&n.getCenter&&t.direct.set(0,h*Math.floor(t.direct.y/h),0).multiplyScalar(e.options.exposeFactor)}));break;default:this.allModels.forEach((function(i){var r=(new tn).setFromObject(i);i.direct||(i.direct=new at),r.getCenter(i.direct),r&&r.getCenter&&(i.direct.sub(n).multiplyScalar(e.options.exposeFactor),"VERTICAL"===t&&(i.direct.x=i.direct.z=0),"HORIZONTAL"===t&&(i.direct.y=i.direct.z=0))}))}this.exposeType=t}},{key:"applyScalar",value:function(e){var t=e-this.prePercent;this.prePercent=e,this.allModels.forEach((function(e){if(e.parent&&e.direct&&!e.isAmrtAlphaHotSpotEntity){var n=e.getWorldPosition(new at);n.add(e.direct.clone().multiplyScalar(t));var i=e.parent.worldToLocal(n);e.position.copy(i)}})),this.object.viewer.renderManager.render(),this.dispatchEvent(ld.CHANGE,e)}},{key:"setSegment",value:function(e){this.stop(),this.segments=e,"SEGMENT"==this.exposeType&&this.setMode(this.exposeType)}},{key:"play",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.stop();var n={t:0};this.tween=new ud.Tween(n).to({t:1},t.time||3e3).onUpdate((function(){e.applyScalar(n.t)})).onComplete((function(){t.onComplete&&t.onComplete()})).repeat(void 0!==t.loop&&null!==t.loop?t.loop-1:0).start()}},{key:"stop",value:function(){this.tween&&this.tween.stop(),this.applyScalar(0)}},{key:"_getRandom",value:function(e,t){var n=Math.floor(Math.random()*e);return t.indexOf(n)>-1?this._getRandom(e,t):n}},{key:"_genSphereGeo",value:function(e,t){var n=new $s(1,e,e),i=this._removeRepeat(n.vertices);return i.length=45*et.DEG2RAD&&(r.isPen=!0)}else{var a=this.getEdgeKey(t,e),o={normal:n,startPoint:e,endPoint:t,isRecommend:1};this.triangleMap.set(i,o),this.triangleMap.set(a,o)}}},{key:"getEdgeKey",value:function(e,t){return e.x+"_"+e.y+"_"+e.z+"_"+t.x+"_"+t.y+"_"+t.z}},{key:"getPenEdge",value:function(){var e=[];return this.triangleMap.forEach((function(t){if(!t.isResolve&&(t.isPen||1===t.isRecommend)){t.isResolve=!0;e.push({s:t.startPoint,p:[t.startPoint.x,t.startPoint.y,t.startPoint.z,t.endPoint.x,t.endPoint.y,t.endPoint.z],e:t.endPoint})}})),e}}]),e}(),Pd=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e))._isCombine=!0,i.lineRoots=[],i._color=null,i._isHideModel=!1,i}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.lineMat=new Do({color:this._color||255}),this.setFromObject()}},{key:"isCombine",set:function(e){this._isCombine=e,this._isInit&&this.setFromObject()}},{key:"isHideModel",set:function(e){this._isHideModel=e,this._isInit&&this.visible&&this.setModelActive(this._isHideModel)}},{key:"color",set:function(e){this._color=e,this._isInit&&(this.lineMat.color.set(this._color),this.lineMat.needsUpdate=!0)}},{key:"setFromObject",value:function(){this.destory();for(var e=[],t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,n),(i=t.call(this,e)).lineRoots=[],i._color=null,i._isHideModel=!1,r.width||(r.width=100),r.height||(r.height=100),r.radius||(r.radius=10),r.colorStops||(r.colorStops={1:"#f00",.8:"#e2fa00",.6:"#33f900",.3:"#0349df",0:"#fff"}),!r.data){r.data=[];for(var a=0;a<100;a++)r.data.push({coord:[100*Math.random()-50,0,100*Math.random()-50],value:20*Math.random()})}return i.options=r,i}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.streamerMaterial=this.getMaterial(),this.destory()}},{key:"setVisible",value:function(e){var t=this;b(u(n.prototype),"setVisible",this).call(this,e),this.objects.forEach((function(n){e?t._setMat(n):t._resetMat(n)}))}},{key:"_setMat",value:function(e){var t=this;if(e.material1=e.material,Array.isArray(e.material)){var n=[];e.material.forEach((function(e){n.push(t.streamerMaterial.clone())})),e.material=n}else e.material=this.streamerMaterial.clone()}},{key:"_resetMat",value:function(e){e.material=e.material1,e.material1=null}},{key:"getMaterial",value:function(e){if(!this._streamerMaterial||e){var t=this.getMap();t.wrapS=t.wrapT=V,t.repeat.set(1,1),t.needsUpdate=!0,this._streamerMaterial=new Nn({map:t,transparent:!0}),this._color&&(this._streamerMaterial.color=new Fn(this._color))}return this._streamerMaterial}},{key:"getMap",value:function(){return new ts(this.draw())}},{key:"draw",value:function(){var e=this,t=this.options.radius,n=this.options.data;this._convertPoints(n);var i=this.options.width,r=this.options.height,a=document.createElement("canvas");a.width=i,a.height=r;var o=a.getContext("2d");o.fillStyle="#00ff00",o.fillRect(0,0,i,r),o.clearRect(0,0,i,r);var s=n.reduce((function(e,t){return Math.max(e,t.value)}),0);n.forEach((function(n){e._drawRadiation(o,{x:n.x,y:n.y,radius:t,weight:Math.max(Math.min((n.value-0)/(s-0),1),0),value:n.value})}));for(var l=this._createPalette(),A=o.getImageData(0,0,i,r),c=A.data,h=3;h0?t.x+=50:0==t.x?t.x=50:t.x<0&&(t.x=50+t.x),t.y>0?t.y+=50:0==t.y?t.y=50:t.y<0&&(t.y=50+t.y),e[n]=t}))}},{key:"_drawRadiation",value:function(e,t){var n=t.x,i=t.y,r=t.radius,a=t.weight;r=Math.round(r*a);var o=e.createRadialGradient(n,i,0,n,i,r);o.addColorStop(0,"rgba(25, 0, 0, 1)"),o.addColorStop(1,"rgba(0, 255, 0, 0)"),e.fillStyle=o,e.beginPath(),e.arc(n,i,r,0,2*Math.PI),e.closePath(),e.fill()}},{key:"start",value:function(){b(u(n.prototype),"start",this).call(this)}},{key:"disable",value:function(){b(u(n.prototype),"disable",this).call(this)}},{key:"setObjects",value:function(e){b(u(n.prototype),"setObjects",this).call(this,e)}},{key:"destory",value:function(){b(u(n.prototype),"destory",this).call(this),this._isInit&&this.setVisible(!1)}}]),n}(Fd),Dd=0,Rd=1,Od=2,Nd=3,zd=4,Qd=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).lineRoots=[],i._color=null,i._isHideModel=!1,i}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.uvSpeed=.01,this.speed=1,this.texture="img/streamer.png",this.destory()}},{key:"color",set:function(e){this._color=e,this._isInit&&(this.streamerMaterial.color.set(this._color),this.streamerMaterial.needsUpdate=!0)}},{key:"speed",get:function(){return this._speed},set:function(e){this._speed=e?e*this.uvSpeed:this.uvSpeed}},{key:"texture",get:function(){return this._texture},set:function(e){e&&(this._texture=e,this.streamerMaterial=this.getMaterial(!0))}},{key:"setVisible",value:function(e){var t=this;b(u(n.prototype),"setVisible",this).call(this,e),this.objects.forEach((function(n){e?t._moveUv(n):t._resetUv(n)}))}},{key:"_moveUv",value:function(e){var t=this;if(e.material1=e.material,Array.isArray(e.material)){var n=[];e.material.forEach((function(e){n.push(t.streamerMaterial.clone())})),e.material=n}else e.material=this.streamerMaterial.clone();e.onBeforeRender1=e.onBeforeRender,e.onBeforeRender=function(e,n,i,r,a){a&&a.map&&(a.map.offset.x-=t.speed)}}},{key:"onBeforeRenderFunc",value:function(e,t,n,i,r){r&&r.map&&(r.map.offset.x-=this.speed)}},{key:"_resetUv",value:function(e){e.material=e.material1,e.material1=null,e.onBeforeRender1?(e.onBeforeRender=e.onBeforeRender1,e.onBeforeRender1=null):e.onBeforeRender=function(){}}},{key:"getMaterial",value:function(e){if(!this._streamerMaterial||e){var t=(new tA).load(this.texture);t.wrapS=t.wrapT=V,t.repeat.set(1,1),t.needsUpdate=!0,this._streamerMaterial=new Nn({map:t,transparent:!0}),this._color&&(this._streamerMaterial.color=new Fn(this._color))}return this._streamerMaterial}},{key:"start",value:function(){b(u(n.prototype),"start",this).call(this)}},{key:"disable",value:function(){b(u(n.prototype),"disable",this).call(this)}},{key:"setObjects",value:function(e){b(u(n.prototype),"setObjects",this).call(this,e)}},{key:"destory",value:function(){b(u(n.prototype),"destory",this).call(this),this._isInit&&this.setVisible(!1)}}]),n}(Fd),Gd=null;var Hd,Vd,jd,Wd,Xd,Yd=function(){function e(){s(this,e),this.material=new Ri,this.material.data=this,this.initParams(),this.initMaterial()}return A(e,[{key:"transparent",set:function(e){this.material.transparent=e,this.material.depthWrite=!e}},{key:"initParams",value:function(){}},{key:"initMaterial",value:function(){}},{key:"updateMaterial",value:function(){}}]),e}(),Kd=function(e){h(n,e);var t=y(n);function n(){return s(this,n),t.call(this)}return A(n,[{key:"initParams",value:function(){this.t2D=null,this.color=new Fn(1,1,1),this.alpha=1}},{key:"initMaterial",value:function(){var e={};e.t2D={value:this.t2D},e.color={value:this.color},e.alpha={value:this.alpha},this.material.uniforms=e,this.material.vertexShader="\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n\n }\n\n",this.material.fragmentShader="\n uniform sampler2D t2D;\n uniform vec3 color;\n uniform float alpha;\n varying vec2 vUv;\n\n void main() {\n\n vec4 texColor = texture2D( t2D, vUv );\n gl_FragColor = vec4(texColor.rgb * color,alpha * texColor.a);\n\n }\n\n"}},{key:"updateMaterial",value:function(){b(u(n.prototype),"updateMaterial",this).call(this),this.t2D?this.material.uniforms.t2D.value=this.t2D:this.material.uniforms.t2D.value=Gd||(Gd=(new tA).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE6WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC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IDw/eHBhY2tldCBlbmQ9InIiPz4LrjbLAAAAEklEQVQI12P8//8/AwwwEscBAG1XC/mlMMwsAAAAAElFTkSuQmCC")),this.material.uniforms.color.value=this.color,this.material.uniforms.alpha.value=this.alpha,this.material.needsUpdate=!0}}]),n}(Yd),Zd=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).edgeEffect=new Pd(i.model),i._lineColor=5371391,i._color=5422335,i._alpha=.3,i._texture=null,i}return A(n,[{key:"setObjects",value:function(e){b(u(n.prototype),"setObjects",this).call(this,e),this.edgeEffect.setObjects(this.objects)}},{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.material=new Kd,this.material.transparent=!0,this.edgeEffect.color=this._lineColor,this.material.color.set(this._color),this.material.alpha=this._alpha,this.material.t2D=this._texture,this.material.updateMaterial()}},{key:"start",value:function(){b(u(n.prototype),"start",this).call(this),this.replaceMaterial(!1)}},{key:"disable",value:function(){b(u(n.prototype),"disable",this).call(this),this.replaceMaterial(!0)}},{key:"destory",value:function(){b(u(n.prototype),"destory",this).call(this),this.edgeEffect.destory(),this.replaceMaterial(!0),this.material=null}},{key:"setVisible",value:function(e){this.edgeEffect.visible=this._visible}},{key:"replaceMaterial",value:function(e){for(var t=0;t0){n.material=[];for(var i=0;i0&&(this.mesh=this.objects[0],this.video=document.createElement("video"),this.video.src=this._url,this.video.loop=this.isLoop,this._coverTexUrl&&(console.log(this._coverTexUrl),this.video.poster=this._coverTexUrl),this.videoTexture=new li(this.video),this.videoTexture.minFilter=Z,this.videoTexture.magFilter=Z,this.videoTexture.format=Ae,this.videoTexture.image.setAttribute("crossorigin","anonymous"),Array.isArray(this.mesh.material)?this.material=this.mesh.material[0]:this.material=this.mesh.material,this._srcTexture=this.material.albedo,this._srcColor=this.material.color.getHex(),this.material.color.setRGB(this._brightness,this._brightness,this._brightness),this._coverTexture&&(this.material.albedo=this._coverTexture),this.material.needsUpdate=!0)}},{key:"disable",value:function(){this.reset()}},{key:"destory",value:function(){this.videoTexture&&this.videoTexture.dispose(),this._coverTexture&&this._coverTexture.dispose(),this.videoTexture=null,this.video=null}},{key:"setUrl",value:function(e,t){if(this._coverTexUrl!==t&&(this._coverTexUrl=t,this._coverTexture&&this._coverTexture.dispose(),this._coverTexUrl)){var n=new tA;this._coverTexture=n.load(this._coverTexUrl)}this._url!==e&&(this._url=e,this.video&&(this.video.src=this._url))}},{key:"play",value:function(){this.visible=!0,this.video&&(this.material&&(this.material.color.setRGB(this._brightness,this._brightness,this._brightness),this.material.albedo=this.videoTexture,this.material.needsUpdate=!0),this.video.currentTime=0,this.video.play())}},{key:"pause",value:function(){this.video&&this.video.pause()}},{key:"resume",value:function(){this.video&&this.video.play()}},{key:"stop",value:function(){this._coverTexture&&(this.material.albedo=this._coverTexture),this.video&&(this.video.pause(),this.video.currentTime=0)}},{key:"reset",value:function(){this.material&&(this.material.color.set(this._srcColor),this.material.albedo=this._srcTexture,this.material.needsUpdate=!0),this.video&&(this.video.pause(),this.video.currentTime=0)}},{key:"clear",value:function(){this.visible=!1}}]),n}(Fd),qd=function(){function e(t){s(this,e),this.model=t,this.effectMap=new Map,this.effectNodeArray=[],this.effectLifeTime=10}return A(e,[{key:"tick",value:function(e){var t=this;this.effectMap.forEach((function(n,i){!n.visible&&n.IsInit&&(n.time+=e,n.time>=t.effectLifeTime&&n.destory())}));for(var n=0;n=this.effectLifeTime&&(i.destory(),this.effectNodeArray.splice(n,1),n--))}}},{key:"getEffect",value:function(e){var t=this.effectMap.get(e);return t||(t=this.createEffect(e),this.effectMap.set(e,t)),t}},{key:"createEffect",value:function(e){var t={};return e===Dd?t=new Pd(this.model):e===Rd?t=new Zd(this.model):e===Od?t=new Qd(this.model):e===Nd?t=new Jd(this.model):e===zd&&(t=new Ud(this.model,this.heatMapData)),t.type=t,t}},{key:"getMeshByNames",value:function(e){var t=[];if(Array.isArray(e))for(var n=0;n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t","\n#define ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n// These defines must match with PMREMGenerator\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfor (int dir = -1; dir < 2; dir += 2) {\n\t\t\tif (i == 0 && dir == 1)\n\t\t\t\tcontinue;\n\t\t\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\t\t\tif (all(equal(axis, vec3(0.0))))\n\t\t\t\taxis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);\n\t\t\taxis = normalize(axis);\n\t\t\tfloat theta = dTheta * float(dir * i);\n\t\t\tfloat cosTheta = cos(theta);\n\t\t\t// Rodrigues' axis-angle rotation\n\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t\t\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\t\t\tgl_FragColor.rgb +=\n\t\t\t\t\tweights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);\n\t\t}\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:0,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",Xd),of=null,sf=null,lf=function(){for(var e=[],t=[],n=[],i=8,r=0;r4?o=ef[r-8+4-1]:0==r&&(o=0),n.push(o);for(var s=1/(a-1),l=-s/2,A=1+s/2,c=[l,l,A,l,A,A,l,l,A,A,l,A],h=new Float32Array(108),u=new Float32Array(72),d=new Float32Array(36),f=0;f<6;f++){var p=f%3*2/3-1,m=f>2?0:-1,v=[p,m,0,p+2/3,m,0,p+2/3,m+1,0,p,m,0,p+2/3,m+1,0,p,m+1,0];h.set(v,18*f),u.set(c,12*f);var g=[f,f,f,f,f,f];d.set(g,6*f)}var y=new si;y.setAttribute("position",new zn(h,3)),y.setAttribute("uv",new zn(u,2)),y.setAttribute("faceIndex",new zn(d,1)),e.push(y),i>4&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Af=lf._lodPlanes,cf=lf._sizeLods,hf=lf._sigmas,uf=null,df=null,ff=null,pf=(1+Math.sqrt(5))/2,mf=1/pf,vf=[new at(1,1,1),new at(-1,1,1),new at(1,1,-1),new at(-1,1,-1),new at(0,pf,mf),new at(0,pf,-mf),new at(mf,0,pf),new at(-mf,0,pf),new at(pf,mf,0),new at(-pf,mf,0)];function gf(e){df=e,bf(af)}function yf(e){var t={magFilter:X,minFilter:X,generateMipmaps:!1,type:e?e.type:$,format:e?e.format:de,encoding:e?e.encoding:Qe,depthBuffer:!1,stencilBuffer:!1},n=Mf(t);return n.depthBuffer=!e,uf=Mf(t),n}function wf(e){uf.dispose(),df.setRenderTarget(ff),e.scissorTest=!1,e.setSize(e.width,e.height)}function xf(e,t,n,i){var r=new Ni(90,1,t,n),a=[1,1,1,1,-1,1],o=[1,1,-1,-1,-1,1],s=df.outputEncoding,l=df.toneMapping,A=df.toneMappingExposure,c=df.getClearColor(),h=df.getClearAlpha();df.toneMapping=1,df.toneMappingExposure=1,df.outputEncoding=Oe,e.scale.z*=-1;var u=e.background;if(u&&u.isColor){u.convertSRGBToLinear();var d=Math.max(u.r,u.g,u.b),f=Math.min(Math.max(Math.ceil(Math.log2(d)),-128),127);u=u.multiplyScalar(Math.pow(2,-f));var p=(f+128)/255;df.setClearColor(u,p),e.background=null}for(var m=0;m<6;m++){var v=m%3;0==v?(r.up.set(0,a[m],0),r.lookAt(o[m],0,0)):1==v?(r.up.set(0,0,a[m]),r.lookAt(0,o[m],0)):(r.up.set(0,a[m],0),r.lookAt(0,0,o[m])),Cf(i,v*$d,m>2?$d:0,$d,$d),df.setRenderTarget(i),df.render(e,r)}df.toneMapping=l,df.toneMappingExposure=A,df.outputEncoding=s,df.setClearColor(c,h),e.scale.z*=-1}function bf(e){var t=new Qt;t.add(new Ei(Af[0],e)),df.compile(t,rf)}function Mf(e){var t=new dt(3*$d,3*$d,e);return t.texture.mapping=G,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Cf(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Bf(e){var t=df.autoClear;df.autoClear=!1;for(var n=1;n8&&console.warn("sigmaRadians, ".concat(r,", is too large and will clip, as it requested ").concat(u," samples when the maximum is set to ").concat(8));for(var d=[],f=0,p=0;p<8;++p){var m=p/h,v=Math.exp(-m*m/2);d.push(v),0==p?f+=v:p4?i-8+4:0),3*g,2*g),df.setRenderTarget(t),df.render(s,rf)}function Tf(){var e=new vl({uniforms:{envMap:{value:null},texelSize:{value:new tt(1,1)},inputEncoding:{value:nf[3e3]},outputEncoding:{value:nf[3e3]}},vertexShader:"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t",fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n".concat("\nuniform int inputEncoding;\nuniform int outputEncoding;\n#include \nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t","\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:0,depthTest:!1,depthWrite:!1});return e.type="EquirectangularToCubeUV",e}function _f(){var e=new vl({uniforms:{envMap:{value:null},inputEncoding:{value:nf[3e3]},outputEncoding:{value:nf[3e3]}},vertexShader:"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t",fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n".concat("\nuniform int inputEncoding;\nuniform int outputEncoding;\n#include \nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t","\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:0,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}gf.prototype={constructor:gf,fromScene:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;ff=df.getRenderTarget();var r=yf();return xf(e,n,i,r),t>0&&Ef(r,0,0,t),Bf(r),wf(r),r},fromEquirectangular:function(e){return e.magFilter=X,e.minFilter=X,e.generateMipmaps=!1,this.fromCubemap(e)},fromCubemap:function(e){ff=df.getRenderTarget();var t=yf(e);return function(e,t){var n=new Qt;e.isCubeTexture?null==sf&&(sf=_f()):null==of&&(of=Tf());var i=e.isCubeTexture?sf:of;n.add(new Ei(Af[0],i));var r=i.uniforms;r.envMap.value=e,e.isCubeTexture||r.texelSize.value.set(1/e.image.width,1/e.image.height);r.inputEncoding.value=nf[e.encoding],r.outputEncoding.value=nf[e.encoding],Cf(t,0,0,3*$d,2*$d),df.setRenderTarget(t),df.render(n,rf)}(e,t),Bf(t),wf(t),t},compileCubemapShader:function(){null==sf&&bf(sf=_f())},compileEquirectangularShader:function(){null==of&&bf(of=Tf())},dispose:function(){af.dispose(),null!=sf&&sf.dispose(),null!=of&&of.dispose();for(var e=0;e0?e.touches[0]:e.changedTouches&&e.changedTouches.length>0?e.changedTouches[0]:e}},{key:"isIOS",get:function(){return navigator.userAgent.indexOf("Android")>-1||navigator.userAgent.indexOf("Adr")>-1}},{key:"isAndroid",get:function(){return!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)}},{key:"isMobile",get:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)}},{key:"stringToArrayBuffer",value:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),i=0,r=e.length;i1&&void 0!==arguments[1]?arguments[1]:256,n="rgba("+255*(e=new Fn(e)).r+","+255*e.g+","+255*e.b+",",i=document.createElement("canvas");i.width=i.height=t;var r=i.getContext("2d"),a=t/2;r.beginPath(),r.arc(a,a,a,0,2*Math.PI,!0),r.closePath();var o=r.createRadialGradient(a,a,1,a,a,a);o.addColorStop(0,n+"1)"),o.addColorStop(.2,n+"0)"),o.addColorStop(.4,n+"1)"),o.addColorStop(.6,n+"0)"),o.addColorStop(.8,n+"1)"),o.addColorStop(1,n+"0)"),r.fillStyle=o,r.fill();var s=new ts(i);return s.minFilter=Z,s.needsUpdate=!0,s}},{key:"segmentIntersection",value:function(e,t,n,i){e=new tt(e.x,e.z),t=new tt(t.x,t.z),n=new tt(n.x,n.z),i=new tt(i.x,i.z);var r=(t.y-e.y)/(t.x-e.x),a=t.y-r*t.x,o=(i.y-n.y)/(i.x-n.x),s=i.y-o*i.x;return{x:(s-a)/(r-o),y:r*((s-a)/(r-o))+a}}},{key:"convertTexture",value:function(e,t){if(!t)return e;var n=new gf(t),i=e.image.src;return e.constructor===hr?(n.compileCubemapShader(),e=n.fromCubemap(e).texture):(n.compileEquirectangularShader(),e=n.fromEquirectangular(e).texture),n.dispose(),e.image.src=i,e}},{key:"getDecoderPath",value:function(){var e="js/";if(document.getElementById("AMRT")){var t=document.getElementById("AMRT").src;e=t.slice(0,t.lastIndexOf("/"))+"/"}else for(var n=0;ne}}]),e}();function Lf(e,t,n){this.objects=[],this.tmpGeometry=e.clone(),Uo.call(this,e,t,n),this.frustumCulled=!1}Lf.prototype=Object.assign(Object.create(Uo.prototype),{constructor:Lf,isInstancedMesh:!0,deleteItem:function(e){if(e&&0!=e.length){var t=new Float32Array(16*(this.count-e.length));e.push(this.count);for(var n=0,i=0,r=0;r0&&void 0!==arguments[0])||arguments[0];e?this.materialViewer.applyWireFrame.bind(this._materialViewer)():this.materialViewer.resetMaterial.bind(this._materialViewer)()}},{key:"update",value:function(){this.effect.tick(this.clock.getDelta())}},{key:"recalculationBound",value:function(){this.boundingBox.setFromObject(this),this.boundingBox.getBoundingSphere(this.boundingSphere)}},{key:"add",value:function(e){b(u(i.prototype),"add",this).call(this,e)}},{key:"remove",value:function(e){b(u(i.prototype),"remove",this).call(this,e)}},{key:"replace",value:function(e,t){e.position.copy(t.localToWorld(t.position.clone())),e.rotation.copy(t.rotation),t.parent.add(e),t.parent.remove(t)}},{key:"setPosition",value:function(e,t,n){this.position.set(e,t,n)}},{key:"setRotation",value:function(e,t,n){this.rotation.set(e,t,n)}},{key:"setScale",value:function(e,t,n){this.scale.set(e,t,n)}},{key:"setEnvMap",value:function(e,t,n){var i=this;return e?e.isTexture?(this.envMap=e,this.materials.forEach((function(t){t.envMap=e,t.needsUpdate=!0})),t&&t(),e):this.mapLoader.loadEnvMap(e,(function(e){i.envMap=e,i.materials.forEach((function(t){t.envMap=e,t.needsUpdate=!0})),t&&t()}),n):(this.envMap=null,this.materials.forEach((function(e){e.envMap=null,e.needsUpdate=!0})),null)}},{key:"getEnvMap",value:function(){if(this.envMap)return this.envMap.image.src}},{key:"setEnvMapRotation",value:function(e){this.envMapRotation=e,this.materials.forEach((function(t){t.envMap&&(t.envRotateY=Math.PI/180*e,t.needsUpdate=!0)}))}},{key:"getEnvMapRotation",value:function(){return this.envMapRotation||0}},{key:"setEnvMapIntensity",value:function(e){null==e||null==e?(e=.7,this.materials.forEach((function(t){t.envMapIntensity=e,t.needsUpdate=!0}))):(this.materials.forEach((function(t){t.envMapIntensity=e,t.needsUpdate=!0})),this.envMapIntensity=e)}},{key:"getEnvMapIntensity",value:function(){return null==this.envMapIntensity||null==this.envMapIntensity?.7:this.envMapIntensity}},{key:"clearEnvMap",value:function(){this.envMap=null,this.materials.forEach((function(e){e.envMap=null,e.needsUpdate=!0}))}},{key:"hasAnimation",value:function(){return this.animation.hasAnimation()}},{key:"adapt",value:function(){this.update(),this.updateWorldMatrix(!1,!0);var e=(new at).subVectors(this.boundingBox.getCenter(),this.position);this.children.forEach((function(t){t.position.x-=e.x,t.position.y-=e.y,t.position.z-=e.z})),this.update(),this.viewer.sceneManager.fitCamera(this,this.boundingBox)}},{key:"getSize",value:function(){return this.boundingBox.getSize()}},{key:"showDimension",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#FFFFFF";this.dimension&&this.viewer.sceneManager.root.remove(this.dimension),this.dimension=new Id(this,e,t,n,i),this.viewer.sceneManager.root.add(this.dimension)}},{key:"hideDimension",value:function(){this.dimension&&(this.viewer.sceneManager.root.remove(this.dimension),this.dimension=null)}},{key:"exploding",get:function(){return this._exploding||(this._exploding=new Ld(this)),this._exploding}},{key:"setExploding",value:function(e){this.exploding.applyScalar(parseFloat(e))}},{key:"setExplodingMode",value:function(e){this.exploding.applyScalar(0),this.exploding.setMode(e)}},{key:"onBeforeRender",value:function(e,t,n){}},{key:"onAfterRender",value:function(e,t,n){}},{key:"on",value:function(e,t){"click"==e&&(this.clickCallback.push(t),this.viewer.modelManager.intersectObjects.click.includes(this)||this.viewer.modelManager.intersectObjects.click.push(this)),"dblclick"==e&&(this.dblclickCallback.push(t),this.viewer.modelManager.intersectObjects.dblclick.includes(this)||this.viewer.modelManager.intersectObjects.dblclick.push(this)),"mousedown"==e&&(this.mousedownCallback.push(t),this.viewer.modelManager.intersectObjects.mousedown.includes(this)||this.viewer.modelManager.intersectObjects.mousedown.push(this)),"mousemove"==e&&(this.mousemoveCallback.push(t),this.viewer.modelManager.intersectObjects.mousemove.includes(this)||this.viewer.modelManager.intersectObjects.mousemove.push(this))}},{key:"off",value:function(e,t){"click"==e&&(this.clickCallback.includes(t)&&this.clickCallback.remove(t),0==this.clickCallback.length&&this.viewer.modelManager.intersectObjects.click.includes(this)&&this.viewer.modelManager.intersectObjects.click.remove(this)),"dblclick"==e&&(this.dblclickCallback.includes(t)&&this.dblclickCallback.remove(t),0==this.dblclickCallback.length&&this.viewer.modelManager.intersectObjects.dblclick.includes(this)&&this.viewer.modelManager.intersectObjects.dblclick.remove(this)),"mousedown"==e&&(this.mousedownCallback.includes(t)&&this.mousedownCallback.remove(t),0==this.mousedownCallback.length&&this.viewer.modelManager.intersectObjects.mousedown.includes(this)&&this.viewer.modelManager.intersectObjects.mousedown.remove(this)),"mousemove"==e&&(this.mousemoveCallback.includes(t)&&this.mousemoveCallback.remove(t),0==this.mousemoveCallback.length&&this.viewer.modelManager.intersectObjects.mousemove.includes(this)&&this.viewer.modelManager.intersectObjects.mousemove.remove(this))}},{key:"clear",value:function(){var e=this;this.clickCallback.map((function(t){e.viewer.modelManager.intersectObjects.click.remove(t)})),this.dblclickCallback.map((function(t){e.viewer.modelManager.intersectObjects.dblclick.remove(t)})),this.mousemoveCallback.map((function(t){e.viewer.modelManager.intersectObjects.mousemove.remove(t)})),this.mousedownCallback.map((function(t){e.viewer.modelManager.intersectObjects.mousedown.remove(t)})),this.clickCallback=[],this.dblclickCallback=[],this.mousemoveCallback=[],this.mousedownCallback=[]}},{key:"dispose",value:function(){this.traverse((function(e){if(e.isMesh){e.geometry&&e.geometry.dispose(),e.geometry=null;for(var t=Array.isArray(e.material)?e.material:[e.material],n=0;n1&&void 0!==arguments[1]?arguments[1]:1;this.selectedMaterial=this._getMaterialByName(e),this._applyParams("opacity",t),this._updateTransparent()}},{key:"setAlbedoMap",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;this.selectedMaterial=this._getMaterialByName(e),this._applyParams("albedo",t,"map"),this.selectedMaterial.albedo&&(this.selectedMaterial.albedo.repeat.set(i,i),this.selectedMaterial.albedo.offset.set(n,n),this.selectedMaterial.needsUpdate=!0)}},{key:"setNormalMap",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;this.selectedMaterial=this._getMaterialByName(e),this._applyParams("normalMap",t,"map"),this._applyParams("normalScale",n),this.selectedMaterial.normalMap&&(this.selectedMaterial.normalMap.repeat.set(r,r),this.selectedMaterial.normalMap.offset.set(i,i),this.selectedMaterial.needsUpdate=!0)}},{key:"_updateTransparent",value:function(){this.selectedMaterial&&(this.selectedMaterial.opacity<1||this.selectedMaterial.transparency>0?this.selectedMaterial.transparent=!0:1==this.selectedMaterial.opacity&&0==this.selectedMaterial.transparency&&(this.selectedMaterial.transparent=!1))}},{key:"_getMaterialByName",value:function(e){var t=this.materials.find((function(t){return t.sname==e}));if(!t)throw new Error("找不到该材质");return t}},{key:"_applyParams",value:function(e,t,n){var i=this;if(this._cacheMaterials[this.selectedMaterial.name]||(this._cacheMaterials[this.selectedMaterial.name]=this.selectedMaterial.clone()),"map"===n){var r=this.selectedMaterial[e];if(void 0===this.selectedMaterial[e+"0"]&&(this.selectedMaterial[e+"0"]=r||null),t){var a=t;t=this.mapLoader.load(t,(function(t){"reflectMap"!==e&&"envMap"!==e||((t=i.mapLoader.convertTexture(t)).image.src=a,i.selectedMaterial[e]=t,i.selectedMaterial.needsUpdate=!0)})),"envMap"===e?t.custom=!0:t.wrapS=t.wrapT=1e3}else t=null;this.selectedMaterial[e]=t}else"color"===n?this.selectedMaterial[e].set(t):this.selectedMaterial[e]=t;this.selectedMaterial.needsUpdate=!0}},{key:"applyMaterialFile",value:function(e){var t=this,n=e.url,i=e.onTextureLoad,r=e.env,a=e.fromOthers,o=e.localPath;this.loader&&(this.splitCache&&(this.splitCache.map((function(e){var n=t.objects.find((function(t){return t.id===e.a})),i=t.materials.find((function(t){return t.name===e.c}));i&&(n.material[e.b]=i)})),this.splitCache=[]),this.loader.loader.extraMaterial={},o&&this.loader.mapLoader.setBaseUrl(o),this.loader.loader.replaceMaterials({url:n,fromOthers:a,onTextureLoad:i,onLoad:function(){t.mapLoader.setBaseUrl(!1),r&&t.setEnvMap(t.envMap)}}))}},{key:"dissolve",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this,n=this.viewer,i=e.target,r=e.speed,a=e.type,o=e.color,s=e.onComplete,l=e.start,A=e.end;if(void 0===i&&(i=this.objects),!Array.isArray(i))return new Error("param.target 必须为一个节点/网格类型数组, 默认使用整个Model下所有子节点");void 0===a&&(a="Perlin");var c=["Perlin","Radial","Linner"].includes(a)?Ff[a]:a;if(!c.isTexture)return new Error("param.type 必须为一'Perlin', 'Radial', 'Linner'中一个, 或者使用自定义Texture对象");r=r||1,l=l||0,A=A||1,o=new Fn(o||16774921);var h=[],u=new WeakMap,d=[];Array.isArray(i)&&i.map((function(e){e.isMesh&&!h.includes(e)&&h.push(e),e.isObject3D&&e.traverse((function(e){e.isMesh&&!h.includes(e)&&h.push(e)}))})),h.map((function(e){return m(e)})),n.addEventListener(ld.UPDATE,p);var f=l;function p(){f>=A&&(n.removeEventListener(ld.UPDATE,p),s&&s(),p=null),f+=.005*r,d.map((function(e){u.get(e).dissolveRatio=f}))}function m(e){e.material=e.material.map((function(e){if(e.isAMRTShadowMaterial)return e;if(e.dissolveMap&&(e=t._cache.get(e)),u.has(e))return u.get(e);var n=(new El).copy(e);return n.dissolveMap=c,n.dissolveRatio=l,n.dissolveColor=o,t._cache.set(n,e),u.set(e,n),d.push(e),n}))}}},{key:"clearDissolve",value:function(){var e=this;this.objects.map((function(t){t.material=t.material.map((function(t){return e._cache.has(t)?e._cache.get(t):t}))})),this._cache=new WeakMap}},{key:"showSkeleton",value:function(){this.skeleton?this.skeleton.visible=!0:(this.skeleton=new sh(this),this.skeleton.visible=!0,this.add(this.skeleton))}},{key:"hideSkeleton",value:function(){this.skeleton&&(this.skeleton.visible=!1),this.skeleton=null}},{key:"getNodeTree",value:function(){var e={};return this._getNodeTree(this.children[0],e),e}},{key:"_getNodeTree",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n.ID=e.ID,n.id=e.id,n.name=e.name,n.children=[],e.children&&e.children.length>0&&e.children.forEach((function(e){n.children.push(t._getNodeTree(e))})),n}},{key:"onMouseOver",value:function(e,t){e&&t&&(this._findListener(this.mouseoverListeners,e,t)||(e._targetRoot=!0,this.mouseoverListeners.push({target:e,handle:t})))}},{key:"offMouseOver",value:function(e,t){var n=this._findListener(this.mouseoverListeners,e,t);n&&(this.mouseoverListeners.remove(n),delete n.target._targetRoot)}},{key:"onMouseOut",value:function(e,t){e&&t&&(this._findListener(this.mouseoutListeners,e,t)||(e._targetRoot=!0,this.mouseoutListeners.push({target:e,handle:t})))}},{key:"offMouseOut",value:function(e,t){var n=this._findListener(this.mouseoutListeners,e,t);n&&(this.mouseoutListeners.remove(n),delete n.target._targetRoot)}},{key:"_mousemoveHandler",value:function(e){var t=this;if(this.mouseoverListeners.length+this.mouseoutListeners.length>0){var n=[];this.mouseoverListeners.forEach((function(e){n.includes(e.target)||n.push(e.target)}));var i=this.viewer.modelManager.picker.intersectObject(e,n,!0),r=null;if(i){var a=function(e){e._targetRoot&&(t.mouseoverListeners.forEach((function(n){n.target===e&&n.target!==t.currentIntersectTarget&&n.handle(n.target)})),r=e)};i.object._targetRoot?a(i.object):i.object.traverseAncestors(a)}for(var o=0;o-1&&this.loadComponentFile(i,t)}}},{key:"loadComponentFile",value:function(e,t){var n=this,i="gz"===this.extension?e.a+"."+this.extension:e.a;(new Uf).load(this.basePath+i,(function(e){n.parseComponentFile(JSON.parse(e)),t()})),e.loaded=!0}},{key:"parseComponentFile",value:function(e,t){var n=this;e.forEach((function(e){var t={id:e.a,pid:e.b,name:e.c,data:e.d};if(n.nodeTree){var i=n.nodeArray.find((function(t){return t.CID==e.a}));i&&(i.bim=t)}else{var r=n.getObjectByProperty("CID",e.a);r&&(r.userData.bim=t)}}))}},{key:"onComplete",value:function(){var e=this;this.objects=[],this.traverse((function(t){if(t.isMesh&&e.objects.push(t),t.name.indexOf("##")>-1){var n=t.name.split("##");t.name=n[0],t.CID=parseInt(n[1])}}))}},{key:"getNodeByFace",value:function(e){return this.nodeArray.find((function(t){return e>=t.face[0]&&e<=t.face[1]}))}},{key:"getComponentInfoByFace",value:function(e,t){var n=this.faceMap.find((function(t){return t.a==e.object.ID}));if(n){for(var i=null,r=0,a=n.b.length;r=n.b[r]&&e.faceIndex<=n.b[r+1]){i=n.b[r+2];break}if(null!==i)return this.nodeArray.find((function(e){return e.a==i}))}}},{key:"getFaceRange",value:function(e){var t=this.faceMap.find((function(t){return t.a==e.object.ID}));if(t){for(var n=0,i=t.b.length;n=t.b[n]&&e.faceIndex<=t.b[n+1])return{face:[t.b[n],t.b[n+1]],id:t.b[n+2],node:this.nodeTree[t.b[n+2]]};return null}}},{key:"setMaterialByFace",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#00f9ff",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=this.getFaceRange(e),r=e.object,a=r.material[0].clone();a.color.setStyle(t),a.opacity=n,r.changeNodes[i.id]={node:i,mat:a},this._resetMaterial(r)}},{key:"_resetMaterial",value:function(e){var t=e.geometry.index.count,n=[],i=[];e.geometry.index.array=[],e.material=[e.material[0]];var r=Object.values(e.changeNodes),a=r.length;r.forEach((function(e){n.push([]),n[n.length-1].mat=e.mat}));for(var o=0;o=c&&o=h&&s1){var r=n._findNodeParent(i.nodes[0].node);i.nodes=[{mesh:i.mesh,id:r.a,node:r,face:[i.nodes[0].face[0],i.nodes[i.nodes.length-1].face[1]]}]}n.setNodeVisible(i.mesh,i.nodes,t),t||n.hideNodes[e].push(i)})),console.timeEnd("setFace"),console.timeEnd("总耗时")}}},{key:"_findNodeByCID",value:function(e){return this.nodeArray.find((function(t){return t.CID==e}))}},{key:"_findMeshByCID",value:function(e){var t=this._findNodeByCID(e);return t?this._findMeshByNode(t):null}},{key:"_findMeshByNode",value:function(e){var t=e.target||this._findMeshByNodeID(e.a);if(t)return e.target=t,t.node=e,t;e.children||this._findNodeChildren(e);for(var n=0,i=e.children.length;n0)for(var i=0,r=n.children.length;i6&&void 0!==arguments[6]&&arguments[6];n||(n=Rf(matName)),void 0!==e.a&&(n.name=e.a,n.ID=e.a,n.sname=e.ee);var s=0,l=0;function A(){++s===l&&(n.needsUpdate=!0,r&&r instanceof Function&&r())}if(!o)if(void 0!==e.b?n.color=(new Fn).fromArray(e.b):n.color.set(16777215),void 0!==e.c&&t[e.c]){l++;var c=t[e.c];a.load(c,(function(t){null!=e.t&&t.repeat.set(e.t[0],e.t[1]),null!=e.x&&t.offset.set(e.x[0],e.x[1]),null!=e.ff&&(t.rotation=e.ff),null!=e.ad&&(n.albedoUV=e.ad),n.albedo=t,void 0!==e.c?n.useDefault=e.useDefault:n.useDefault=!0,A()}),null,(function(e){console.error("贴图加载出错"),A()}))}else n.albedo=null,n.albedoUV=null,n.needsUpdate=!0;if(e.d){var h=(new Fn).fromArray(e.d);n.emissive=h}if(void 0!==e.e&&(n.aoScale=parseFloat(e.e)),void 0!==e.f&&n.color.multiplyScalar(parseFloat(e.f)),void 0!==e.g&&(n.smoothness=parseFloat(e.g)),void 0!==e.h&&(n.metallic=parseFloat(e.h)),void 0!==e.i&&(n.normalScale=parseFloat(e.i)),void 0!==e.j&&(n.opacity=parseFloat(e.j)),void 0!==e.gg&&(n.transparency=parseFloat(e.gg)),(n.opacity<1||n.transparency>0)&&(n.transparent=!0),void 0!==e.hh&&(n.alphaTest=parseFloat(e.hh)),void 0!==e.ii&&(n.reflectIntensity=parseFloat(e.ii)),void 0!==e.si&&(n.side=e.si),void 0!==e.q&&t[e.q]?(l++,a.load(t[e.q],(function(t){void 0!==e.u?t.repeat.set(e.u[0],e.u[1]):t.repeat.set(1,1),void 0!==e.mm&&t.offset.set(e.mm[0],e.mm[1]),void 0!==e.nn&&(t.rotation=e.nn),n.normalMap=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))):(n.normalMap=null,n.needsUpdate=!0),void 0!==e.cf&&t[e.cf]?(l++,a.load(t[e.cf],(function(t){void 0!==e.cb?t.repeat.set(e.cb[0],e.cb[1]):t.repeat.set(1,1),void 0!==e.cg&&t.offset.set(e.cg[0],e.cg[1]),void 0!==e.cn&&(t.rotation=e.cn),void 0!==e.ca&&(n.normalScale2=parseFloat(e.ca)),n.normalMap2=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))):(n.normalMap2=null,n.needsUpdate=!0),void 0!==e.r&&t[e.r]&&void 0!==e.fd){l++;var u=t[e.r];Of[u]?(n.aoMap=Of[u],n.aoUV=e.fd,Of[u+"_mats"].push(n),A()):(n.aoMap=Of[u]=a.load(t[e.r],(function(t){void 0!==e.v?t.repeat.set(e.v[0],e.v[1]):t.repeat.set(1,1),void 0!==e.oo&&t.offset.set(e.oo[0],e.oo[1]),void 0!==e.ss&&(t.rotation=e.ss),n.aoUV=e.fd,Of[u+"_mats"]&&Of[u+"_mats"].map((function(e){return e.needsUpdate=!0})),A()}),null,(function(e){console.error("贴图加载出错"),A()})),Of[u+"_mats"]=[n])}else n.aoMap=null,n.needsUpdate=!0;if(void 0!==e.y&&t[e.y]?(l++,a.load(t[e.y],(function(t){void 0!==e.bb?t.repeat.set(e.bb[0],e.bb[1]):t.repeat.set(1,1),void 0!==e.pp&&t.offset.set(e.pp[0],e.pp[1]),void 0!==e.tt&&(t.rotation=e.tt),n.metallicMap=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))):(n.metallicMap=null,n.needsUpdate=!0),void 0!==e.z&&t[e.z]?(l++,a.load(t[e.z],(function(t){void 0!==e.cc?t.repeat.set(e.cc[0],e.cc[1]):t.repeat.set(1,1),void 0!==e.qq&&t.offset.set(e.qq[0],e.qq[1]),void 0!==e.uu&&(t.rotation=e.uu),n.roughnessMap=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))):(n.roughnessMap=null,n.needsUpdate=!0),void 0!==e.aa&&t[e.aa]?(l++,a.load(t[e.aa],(function(t){void 0!==e.dd?t.repeat.set(e.dd[0],e.dd[1]):t.repeat.set(1,1),void 0!==e.rr&&t.offset.set(e.rr[0],e.rr[1]),void 0!==e.vv&&(t.rotation=e.vv),void 0!==e.gd&&(n.emissiveUV=e.gd),n.emissiveMap=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))):(n.emissiveMap=null,n.needsUpdate=!0),void 0!==e.ll&&t[e.ll]){l++;var d=t[e.ll];void 0!==e.yy&&(n.reflectRotateY=e.yy),a.load(d,(function(e){var t=e.image;e.wrapS=e.wrapT=1e3,0===e.image.width||0===e.image.height?setTimeout((function(){e=a.convertTexture(e),n.reflectMap=e,e.image=t,A()}),500):(e=a.convertTexture(e),n.reflectMap=e,e.image=t,A())}),null,(function(e){console.error("贴图加载出错"),A()}))}else n.reflectMap=null,n.needsUpdate=!0;if(void 0!==e.zz&&t[e.zz]){l++;var f=t[e.zz];a.load(f,(function(t){void 0!==e.bb?t.repeat.set(e.zx[0],e.zx[1]):t.repeat.set(1,1),void 0!==e.pp&&t.offset.set(e.zc[0],e.zc[1]),void 0!==e.zv&&(t.rotation=e.zv),n.alphaMap=t,A()}),null,(function(e){console.error("贴图加载出错"),A()}))}else n.reflectMap=null,n.needsUpdate=!0;return n.retainMap=!0,void 0!==e.jj&&(n.retainMap=Boolean(e.ii)),void 0!==e.kk&&!0!==e.kk?n.renderOrder=Number(e.kk):n.renderOrder=n.opacity<1?Ke:Ze,null!=e.jr&&(n.reflectivity=e.jr),null!=e.l&&(n.wireframe=e.l),null!=e.o&&(n.skinning=e.o),null!=e.p&&(n.vertexTangents=e.p),null!=e.qn&&(n.normalMapType=e.qn),null!=e.rm&&(n.morphTargets=e.rm),null!=e.transparent&&(n.transparent=e.transparent),void 0!==e.re&&(n.re=e.re),void 0!==e.dt&&(n.depthTest=e.dt),void 0!==e.dw&&(n.depthWrite=e.dw),n.needsUpdate=!0,i&&i instanceof Function&&i(n),0===l&&r&&r instanceof Function&&r(n),n}},{key:"export",value:function(e,t){if(void 0!==e.re)return{a:e.ID||e.name,re:e.re};var n=Object.keys(t).length,i={a:e.ID||e.name,b:e.color.toArray(),d:e.emissive.toArray(),e:e.aoScale,g:e.smoothness,h:e.metallic,i:e.normalScale,j:e.opacity,gg:e.transparency,hh:e.alphaTest,ii:e.reflectIntensity,jj:e.retainMap,kk:e.renderOrder,ee:e.sname,useDefault:e.useDefault,transparent:e.transparent,si:e.side,jr:e.reflectivity,lw:e.wireframe,os:e.skinning,pv:e.vertexTangents,qn:e.normalMapType,rm:e.morphTargets,dw:e.depthWrite,dt:e.depthTest};return e.albedo&&(i.t=e.albedo.repeat.toArray(),i.x=e.albedo.offset.toArray(),i.ff=e.albedo.rotation,i.ad=e.albedoUV,e.albedo.image&&(i.c=n,t[n]=e.albedo.image.src,n++)),e.normalMap&&(i.u=e.normalMap.repeat.toArray(),i.mm=e.normalMap.offset.toArray(),i.nn=e.normalMap.rotation,e.normalMap.image&&(i.q=n,t[n]=e.normalMap.image.src,n++)),e.normalMap2&&(i.cb=e.normalMap2.repeat.toArray(),i.cg=e.normalMap2.offset.toArray(),i.cn=e.normalMap2.rotation,i.ca=e.normalMap2.normalScale2,e.normalMap2.image&&(i.cf=n,t[n]=e.normalMap2.image.src,n++)),e.aoMap&&(i.v=e.aoMap.repeat.toArray(),i.oo=e.aoMap.offset.toArray(),i.ss=e.aoMap.rotation,i.fd=e.aoUV,e.aoMap.image&&(i.r=n,t[n]=e.aoMap.image.src,n++)),e.metallicMap&&(i.bb=e.metallicMap.repeat.toArray(),i.pp=e.metallicMap.offset.toArray(),i.tt=e.metallicMap.rotation,e.metallicMap.image&&(i.y=n,t[n]=e.metallicMap.image.src,n++)),e.roughnessMap&&(i.cc=e.roughnessMap.repeat.toArray(),i.qq=e.roughnessMap.offset.toArray(),i.uu=e.roughnessMap.rotation,e.roughnessMap.image&&(i.z=n,t[n]=e.roughnessMap.image.src,n++)),e.emissiveMap&&(i.dd=e.emissiveMap.repeat.toArray(),i.rr=e.emissiveMap.offset.toArray(),i.vv=e.emissiveMap.rotation,i.gd=e.emissiveUV,e.emissiveMap.image&&(i.aa=n,t[n]=e.emissiveMap.image.src,n++)),e.reflectMap&&e.reflectMap.image&&(i.yy=e.reflectRotateY,i.ll=n,t[n]=e.reflectMap.image.src,n++),e.alphaMap&&(i.zx=e.alphaMap.repeat.toArray(),i.zc=e.alphaMap.offset.toArray(),i.zv=e.alphaMap.rotation,e.alphaMap.image&&(i.zz=n,t[n]=e.alphaMap.image.src,n++)),i}},{key:"merge",value:function(e,t){var n=0;if(e.b&&(n=Object.keys(e.b).length,t.b))for(var i in t.b)i=parseInt(i),e.b[i+n]=t.b[i];Array.isArray(t.a)&&(t.a=t.a.filter((function(e){return void 0===e.re})),e.a.map((function(i,r){if(i.ee){var a=t.a.find((function(e){return e.ee===i.ee}));for(var o in a)["c","q","cf","r","y","z","aa","ll","zz"].includes(o)&&(a[o]=a[o]+n);a&&(a.a=i.a,e.a[r]=Object.assign({},a))}})))}}]),e}(),zf=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;s(this,e),this.viewer=n,this.cacheMats=[],this.queryMats={},this.cacheMeshes=[],this.cacheMesheIds=[],this.cacheAnimations=[],this.cacheActions=[],this.cacheSkyboxs={},this.cacheSkinnedMeshs=[],this.cacheSkinnedMeshIds=[],this.cacheEnvMap={},this.cacheAoMap={},this.instances=null,this.extraMaterial={},this.cacheExtraMat=[],this.scene=null,this.hasSkinnedAnimation=!1,this.model=t.isBIM?new Df(this.viewer):new kf(this.viewer),this.model.objects=this.cacheMeshes,this.model.materials=this.cacheMats,this.animNameMap=new Map}return A(e,[{key:"load",value:function(e,t,n,i){var r=this;"undefined"!=typeof Worker?(this.workerLoader=new Md,this.workerLoader.loadMesh(e,(function(e){t(r.parse(e))}),n,(function(e){console.error("网格文件解析出错!"),i&&i(e)}))):(new Kl).load(e,(function(e){try{r.parse(JSON.parse(e))}catch(e){console.error("网格文件解析出错!",e),i&&i(e)}t(r.model)}),n,i)}},{key:"loadNodes",value:function(e,t,n){var i=this;(new Kl).load(e,(function(e){i.generateNodes(JSON.parse(e)),t()}),void 0,(function(t){console.error("节点文件加载失败:"+e,t)}))}},{key:"generateNodes",value:function(e){var t=this;e.forEach((function(e){var n=new ja;if(n.ID=e.a,n.name=e.b,-1==e.c)t.model.add(n);else{var i=t.model.getObjectByProperty("ID",e.c);i&&i.add(n)}n.applyMatrix((new bt).fromArray(e.d)),t.addToCache(n)}))}},{key:"bindSkeleton",value:function(){}},{key:"initSkeletonTransform",value:function(){}},{key:"loadMeshComplete",value:function(){}},{key:"parse",value:function(e){var t=this.model;Array.isArray(e)||(e=[e]);for(var n=[],i=function(t){e.find((function(n,i){return n.a===e[t].a&&t!=i}))&&(e[t].a+=e[t].b)},r=0;r0){var n=this.generateGeometry(e);t=new Ei(n,this.generateMaterial(n))}else t=new zt;return t.name=e.a,t.ID=e.b,t.parentID=e.c,t.applyMatrix((new bt).fromArray(e.d)),t}},{key:"generateSkinnedMesh",value:function(e){var t;if(e.h){var n=this.generateGeometry(e),i=this.generateMaterial(n,!0);e.ff&&e.ff.length>0?(i.skinning=!0,n.setAttribute("skinIndex",new jn(e.ff,4)),n.setAttribute("skinWeight",new Yn(e.gg,4)),(t=new Bo(n,i)).xIDs=e.hh):t=new Ei(n,i)}else t=new _o;return t.name=e.a,t.ID=e.b,t.applyMatrix((new bt).fromArray(e.d)),this.cacheSkinnedMeshs[e.b]=t,this.model.add(t),this.model.updateMatrixWorld(!0),t}},{key:"generateGeometry",value:function(e){var t=new si;t.name=e.a;var n=new bt;if(e.e&&n.fromArray(e.e),!(e.h&&e.h.length>0))return null;var i=new Yn(e.h,3);if(n.applyToBufferAttribute(i),t.setAttribute("position",i),e.j&&e.j.length>0){var r=new Yn(e.j,3);(new lt).getNormalMatrix(n).applyToBufferAttribute(r),t.setAttribute("normal",r)}else console.warn("无法线");e.k&&e.k.length>0?t.setAttribute("uv",new Yn(e.k,2)):console.warn("无UV"),e.l&&e.l.length>0&&t.setAttribute("uv2",new Yn(e.l,2)),t.setIndex(e.i),e.j&&0!=e.j.length||t.computeVertexNormals(),t.clearGroups(),e.k&&e.k.length>0&&pd(t);for(var a=[],o=0;o0){var a=0,o=0,s=e.a.length;e.a.forEach((function(l){r.parseMaterial({config:l,maps:e.b,onLoad:function(){++a===s&&(r._initMaterial(),t&&t instanceof Function&&t())},onTextureLoad:function(){++o===s&&n&&n instanceof Function&&n()},onError:i,edited:!1})}))}else t&&t instanceof Function&&t()}},{key:"parseMaterial",value:function(e){var t=e.config,n=e.maps,i=e.onLoad,r=e.onTextureLoad;e.onError;var a=e.edited,o=t.a,s=this.queryMats[o];if(void 0===s&&o&&o.toString().indexOf("_")>-1){var l=o.split("_")[0],A=this.queryMats[l],c=this.cacheMats[A],h=this.cacheMeshes.find((function(e){return e.name===t.mn})),u=c.clone();u.name=t.ee||o,u.sname=c.sname,u.ID=o,this.cacheMats.push(u),s=this.cacheMats.length-1,this.queryMats[o]=s,h.material[h.material.indexOf(c)]=u}var d=this.cacheMats[s];d||(d=this._createBaseMaterial(o),this.cacheMats.push(d),this.queryMats[o]=this.cacheMats.length-1),Nf.parseAmrtMaterial(t,n,d,i,r,this.mapLoader,a)}},{key:"loadAnimationComplete",value:function(e){this.model.animation.setAnimationList(["take 01"])}},{key:"loadAnimation",value:function(e,t){var n=this;(new Kl).load(e,(function(e){try{n.hasSkinnedAnimation?n.parseSkinnedAnimation(JSON.parse(e)):n.parseAnimation(JSON.parse(e))}catch(e){console.error("动画文件解析出错!",e)}t&&t()}))}},{key:"parseAnimation",value:function(e){for(var t=0,n=[],i=0;it&&(t=o)}var s=new Gl("take 01",t,n);this.model.animation.addClip(s)}},{key:"parseSkinnedAnimation",value:function(e){for(var t=[],n=0,i=0;in&&(n=r.d);for(var c=0;ct&&(t=e[n]);return t},_createGeometry:function(e,t,n){if("mbin"===n.fileType){if(n.bComplete&&(this.workerStateById[t]=1),null===(c=n.geometry)||null==c)return;if(c.chunkType,2===c.chunkType){var i=new si;if(i.custom_data={},i.custom_data.id=c.id,i.custom_data.parentId=c.parentId,i.custom_data.matrix=c.matrix,i.custom_data.bIsNodel=c.bIsNodel,i.custom_data.nodeType=c.nodeType,i.custom_data.version=c.version,void 0!==c.materialIndex){i.clearGroups(),i.custom_data.materialIndex=[];for(var r=c.materialIndex.length/3,a=0;a65535?Xn:jn)(c.index.array,1),delete c.index.array,c.index=null);for(a=0;at._taskLoad?-1:1}));return(i=n.workerPool[n.workerPool.length-1])._taskCosts[e]=t,i._taskLoad+=t,i})).catch((function(e){console.log(e)}))},_releaseTask:function(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]},debug:function(){console.log("Task load: ",this.workerPool.map((function(e){return e._taskLoad})))},dispose:function(){for(var e=0;e0){var x;this.dracoLoadCount++;var b=e.getArrayBuffer(w);s.Init(new Int8Array(b),b.byteLength),t.decodeType=4;for(var M,C=f(n,i,s,t),B=C.attributes.length,E=0;EA&&(A=M.length)}}else for(var L=0;LA&&(A=F.frameNum),null!==F&&l.boneId2Anim.push(F)}e.setOffset(y+g)}else{for(var k=e.getUint32(),P=(g=e.getUint32(),y=e.getOffset(),0);PA&&(A=D.frameNum),D.meshId=U,null!==D&&(5==m?l.animType2Anim.transAnim.push(D):7==m&&l.animType2Anim.scaleAnim.push(D));else if(6==m){var D;(D=o(e,d,t,n,i,s)).frameNum>A&&(A=D.frameNum),D.meshId=U,null!==D&&l.animType2Anim.rotAnim.push(D)}else console.log("Error: chunkType errror!!!!")}e.setOffset(y+g)}}return e.setOffset(h+c),A<2?null:l}function r(e){var t={};t.boneId=e.getUint32(),t.frameNum=e.getUint32(),t.frameTimes=e.getFloat32Array(t.frameNum),t.frameVals=new Array(t.frameNum);for(var n=0;n=5){var s=e.getUint32();if(s>0){var l=e.getArrayBuffer(s);a.Init(new Int8Array(l),l.byteLength),n.decodeType=5;var A=f(i,r,a,n);o.frameTimes=A.attributes[0].array,o.frameVals=A.attributes[1].array}}else o.frameTimes=e.getFloat32Array(o.frameNum),o.frameVals=e.getFloat32Array(3*o.frameNum);return o}function o(e,t,n,i,r,a){var o={};if(o.frameNum=e.getUint32(),t&&o.frameNum>=5){var s=e.getUint32(),l=e.getArrayBuffer(s);a.Init(new Int8Array(l),l.byteLength),n.decodeType=5;var A=f(i,r,a,n);o.frameTimes=A.attributes[0].array,o.frameVals=A.attributes[1].array}else o.frameTimes=e.getFloat32Array(o.frameNum),o.frameVals=e.getFloat32Array(4*o.frameNum);return o}function s(e,t,n,i,r,a){var o={meshId:0,boneIds:[],boneIndices:[],boneWeights:[]},s=e.getUint32(),l=e.getOffset();o.meshId=e.getUint32();for(var A=e.getUint32(),c=[],h=0;h0?parseInt(b/4)+1:parseInt(b/4));if(t){var C=e.getUint32();if(C>0){var B=e.getArrayBuffer(C);a.Init(new Int8Array(B),B.byteLength),n.decodeType=3;var E=f(i,r,a,n),S=E.attributes[0].array,T=E.attributes[1].array;S.length;for(var _=0;_0){o.loadedState[0]=0;var u=e.getArrayBuffer(m);r.Init(new Int8Array(u),u.byteLength),t.decodeType=1,(d=f(n,i,r,t)).attributes[0].name="position",o.attributes.push(d.attributes[0])}else o.vertexNum=0,o.loadedState[0]=1;if((m=e.getUint32())>0){o.loadedState[1]=0;u=e.getArrayBuffer(m);r.Init(new Int8Array(u),u.byteLength),t.decodeType=2;var d=f(n,i,r,t);o.index={array:d.attributes[0].array},o.faceNum=d.attributes[0].array.length/3}else o.faceNum=0,o.loadedState[1]=1}else o.vertexNum=e.getUint32(),o.vertexs=e.getFloat32Array(3*o.vertexNum),o.attributes.push({name:"position",array:o.vertexs,itemSize:3}),o.faceNum=e.getUint32(),o.faceVerIndexs=e.getUint32Array(3*o.faceNum),o.index={array:o.faceVerIndexs};if(o.bHaveUVData)if(o.bUseDraco){if((m=e.getUint32())>0){o.loadedState[2]=0;u=e.getArrayBuffer(m);r.Init(new Int8Array(u),u.byteLength),t.decodeType=1,(d=f(n,i,r,t)).attributes[0].name="uv",o.attributes.push(d.attributes[0])}else o.UVNum=0,o.loadedState[2]=1;if(o.bUseCompose)if((m=e.getUint32())>0){o.loadedState[3]=0;u=e.getArrayBuffer(m);this.dracoLoadCount++,dracoLoader.decodeDracoFile(u,(function(e){o.faceComposedUVIndexs=e.attributes[0].array,o.loadedState[3]=1,a.dracoOnLoad()}),null,null,2)}else o.loadedState[3]=1;else o.loadedState[3]=1}else o.UVNum=e.getUint32(),o.uvData=e.getFloat32Array(2*o.UVNum),o.attributes.push({name:"uv",array:o.uvData,itemSize:2}),o.bUseCompose&&(o.faceComposedUVIndexs=e.getUint32Array(3*o.faceNum)),o.loadedState[3]=1;else o.loadedState[2]=1,o.loadedState[3]=1;if(o.bHaveUV2Data)if(o.bUseDraco){if((m=e.getUint32())>0){o.loadedState[4]=0;u=e.getArrayBuffer(m);r.Init(new Int8Array(u),u.byteLength),t.decodeType=1,(d=f(n,i,r,t)).attributes[0].name="uv2",o.attributes.push(d.attributes[0])}else o.UV2Num=0,o.loadedState[4]=1;if(o.bUseCompose)if((m=e.getUint32())>0){o.loadedState[5]=0;u=e.getArrayBuffer(m);this.dracoLoadCount++,dracoLoader.decodeDracoFile(u,(function(e){o.faceComposedUV2Indexs=e.attributes[0].array,o.loadedState[5]=1,a.dracoOnLoad()}),null,null,2)}else o.loadedState[5]=1;else o.loadedState[5]=1}else o.UV2Num=e.getUint32(),o.uv2Data=e.getFloat32Array(2*o.UV2Num),o.loadedState[4]=1,o.attributes.push({name:"uv2",array:o.uv2Data,itemSize:2}),o.bUseCompose&&(o.faceComposedUV2Indexs=e.getUint32Array(3*o.faceNum)),o.loadedState[5]=1;else o.loadedState[4]=1,o.loadedState[5]=1;o.materialNum=e.getUint32(),o.materialIndex=new Array(o.materialNum);for(var p=0;p0){o.loadedState[6]=0;u=e.getArrayBuffer(m);r.Init(new Int8Array(u),u.byteLength),t.decodeType=1,(d=f(n,i,r,t)).attributes[0].name="normal",o.attributes.push(d.attributes[0])}else o.normalNum=0,o.loadedState[6]=1;if(o.bUseCompose)if((m=e.getUint32())>0){o.loadedState[7]=0;u=e.getArrayBuffer(m);this.dracoLoadCount++,dracoLoader.decodeDracoFile(u,(function(e){o.faceComposedNormalIndexs=e.attributes[0].array,o.loadedState[7]=1,a.dracoOnLoad()}),null,null,2)}else o.loadedState[7]=1;else o.loadedState[7]=1}else o.normalNum=e.getUint32(),o.normals=e.getFloat32Array(3*o.normalNum),o.loadedState[6]=1,o.attributes.push({name:"normal",array:o.normals,itemSize:3}),o.bUseCompose&&(o.faceComposedNormalIndexs=e.getUint32Array(3*o.faceNum)),o.loadedState[7]=1;else o.loadedState[6]=1,o.loadedState[7]=1}var v=e.getUint8();return o.name=e.getString(v),function(e){var t=e.getUint8();e.getString(t)}(e),o}onmessage=function(r){var a=r.data;switch(a.type){case"init":e=a.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"clear_data":console.log("clear_data");break;case"decode":var o=a.buffer,u=a.taskConfig;t.then((function(e){var t=e.draco,r=new t.Decoder,p=new t.DecoderBuffer;try{var m=c(o,0,4);if("MBIN"===m)(function(e,t,i,r,a,o){if(function(e){var t="MBIN",n=4,i=c(e,0,n);return e.byteLength>=n&&t===i}(t)){var u=new d(t);for(u.skip(4),n=u.getUint32();u.offset=5){var k=u.getUint32();B.newBoneData=[];for(var P=0;P=5){var W=u.getUint32();if(W>0){var X=u.getArrayBuffer(W);o.Init(new Int8Array(X),X.byteLength),i.decodeType=6;var Y=(B=f(r,a,o,i)).attributes[0].array;for(y=0;y=4)0!==u.getUint8()&&(se.matrix=u.getMatrix4());B.packdata.push(se)}self.postMessage({type:"decode",id:e.id,fileType:"addbin",bComplete:!0,geometry:B})}else u.skip(v);u.setOffset(g+v)}}u=null}else console.log("mbin file format error!!!!!!!!")})(a,o,u,t,r,p);else if("ABIN"===m)(function(e,t,n,r,a,o){if(function(e){var t="ABIN",n=4,i=c(e,0,n);return e.byteLength>=n&&t===i}(t)){var s=new d(t);if(s.skip(4),s.getUint32(),8===s.getUint32()){var l=s.getUint32(),A=s.getUint32(),h=s.getOffset();if(0==l)return void self.postMessage({type:"decode",id:e.id,fileType:"abin",bComplete:!0,geometry:null});for(var u=0;u=0&&(t=t.slice(0,i)),t}}},e.taskCache=new WeakMap,e.setDecoderPath=function(){console.warn("DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.")},e.setDecoderConfig=function(){console.warn("DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.")},e.releaseDecoderModule=function(){console.warn("DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.")},e.getDecoderModule=function(){console.warn("DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.")},t.prototype={constructor:t,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1==(1&this.getUint8())},getBooleanArray:function(e){for(var t=[],n=0;n=0&&(t=t.slice(0,i)),OA.decodeText(new Uint8Array(t))}},e}();function Gf(e){On.call(this),this.defines={STANDARD:""},this.type="AMRTBasicMaterial",this.color=new Fn(16777215),this.albedo=null,this.albedoUV=0,this.normalMap=null,this.normalScale=1,this.normalMap2=null,this.normalScale2=1,this.metallicMap=null,this.metallic=0,this.roughnessMap=null,this.smoothness=0,this.aoMap=null,this.aoScale=1,this.aoUV=0,this.emissive=new Fn(0),this.emissiveMap=null,this.emissiveUV=0,this.reflectMap=null,this.reflectIntensity=0,this.cutout=.5,this.reflectivity=1,this.transparency=0,this.opacity=1,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.vertexTangents=!0,this.normalMapType=0,this.envRotateY=0,this.envYMatrix=new lt,this.reflectRotateY=0,this.reflecYMatrix=new lt,this.dissolveMap=null,this.dissolveRatio=0,this.dissolveColor=new Fn(16774921),this.ssrTextureMatrix=new bt,this.ssrTexture=null,this.maxDistance=10,this.ssrOpacity=1,this.fresnelCoe=0,this.depthTexture=null,this.planeOffset=0,this.virtualCameraNear=.1,this.virtualCameraFar=1e3,this.virtualCameraMatrixWorld=new bt,this.virtualCameraProjectionMatrix=new bt,this.virtualCameraProjectionMatrixInverse=new bt,this.resolution=new tt,this.setValues(e),this.__defineSetter__("envRotateY",(function(e){this.envYMatrix=(new lt).rotateY(e)})),this.__defineSetter__("reflectRotateY",(function(e){this.reflecYMatrix=(new lt).rotateY(e)}))}Gf.prototype=Object.create(On.prototype),Gf.prototype.constructor=Gf,Gf.prototype.isAMRTBasicMaterial=!0,Gf.prototype.clone=function(){return(new this.constructor).copy(this)},Gf.prototype.copy=function(e){return On.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.albedo=e.albedo,this.albedoUV=e.albedoUV,this.normalMap=e.normalMap,this.normalScale=e.normalScale,this.normalMap2=e.normalMap2,this.normalScale2=e.normalScale2,this.metallicMap=e.metallicMap,this.metallic=e.metallic,this.roughnessMap=e.roughnessMap,this.smoothness=e.smoothness,this.aoMap=e.aoMap,this.aoScale=e.aoScale,this.aoUV=e.aoUV,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveUV=e.emissiveUV,this.reflectMap=e.reflectMap,this.reflectIntensity=e.reflectIntensity,this.cutout=e.cutout,this.reflectivity=e.reflectivity,this.transparency=e.transparency,this.opacity=e.opacity,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.vertexTangents=e.vertexTangents,this.normalMapType=e.normalMapType,this.envRotateY=e.envRotateY,this.envYMatrix=e.envYMatrix,this.reflectRotateY=e.reflectRotateY,this.reflecYMatrix=e.reflecYMatrix,this},Gf.prototype.dispose=function(){On.prototype.dispose.call(this),this.albedo&&this.albedo.dispose(),this.metallicMap&&this.metallicMap.dispose(),this.roughnessMap&&this.roughnessMap.dispose(),this.aoMap&&this.aoMap.dispose(),this.emissiveMap&&this.emissiveMap.dispose(),this.reflectMap&&this.reflectMap.dispose(),this.envMap&&this.envMap.dispose()},Object.defineProperty(Gf.prototype,"alphaMap",{get:function(){return this._alphaMap||null},set:function(e){this._alphaMap=e,e&&(this.transparent=!0)}});var Hf=[];function Vf(){this.geometry=null,this._material=null,this.instanceIndex=0,this._instanceMesh=null,this.rootInverse=new bt,this.material0=null,this._mesh=null,zt.call(this),Object.defineProperty(this,"instanceMesh",{get:function(){return this._instanceMesh},set:function(e){this._instanceMesh!=e&&(this._instanceMesh=e,this.geometry=this._instanceMesh.tmpGeometry,this._material=this._instanceMesh.material[0],this.material0=this._material,this._mesh=new Ei(this.geometry,this._material),this._mesh.name=this.name)}}),Object.defineProperty(this,"material",{get:function(){return null==this._instanceMesh?null:(this._material===this._instanceMesh.material[0]&&this.createMesh(),this._material)},set:function(e){console.log("set"),this._material=e,this._mesh.material=this._material,this._mesh.material0=this._material,null==this._mesh.parent&&this.add(this._mesh)}})}Vf.prototype=Object.assign(Object.create(zt.prototype),{constructor:Vf,intanceObject:!0,setDirty:function(){this.refreshInstanceMesh()},refreshInstanceMesh:function(){null!=this._instanceMesh&&(this._instanceMesh.updateMatrixWorld(!0),this.rootInverse.getInverse(this._instanceMesh.matrixWorld),this._instanceMesh.setMatrixAt(this.instanceIndex,this.rootInverse.multiply(this.matrixWorld)),this._instanceMesh.instanceMatrix.needsUpdate=!0)},createMesh:function(){if(null==this._mesh.parent){var e=new Gf;e.copy(this._material),this._material=e,this.material0=this._material,this._mesh.material=this._material,this._mesh.material0=this._material,this._instanceMesh.deleteItem([this.instanceIndex]),this.add(this._mesh)}},raycast:function(e,t){null!=this._mesh&&(this._mesh.matrixWorld=this.matrixWorld,this._mesh.raycast(e,Hf),Hf.length>0&&(this.createMesh(),Hf[0].object=this,t.push(Hf[0])),Hf.length=0)}});var jf=function(e){Wl.call(this,e)};jf.prototype=Object.assign(Object.create(Wl.prototype),{constructor:jf,load:function(e,t,n,i){var r=this,a=new ht,o=new Kl(this.manager);return o.setResponseType("arraybuffer"),o.setPath(this.path),o.load(e,(function(e){a.image=r.parse(e),a.needsUpdate=!0,void 0!==t&&t(a)}),n,i),a},parse:function(e){var t=0,n=1,i=2,r=3,a=9,o=10,s=11,l=48,A=4,c=0,h=1,u=2,d=3;e.length<19&&console.error("TGALoader: Not enough data to contain header.");var f=new Uint8Array(e),p=0,m={id_length:f[p++],colormap_type:f[p++],image_type:f[p++],colormap_index:f[p++]|f[p++]<<8,colormap_length:f[p++]|f[p++]<<8,colormap_size:f[p++],origin:[f[p++]|f[p++]<<8,f[p++]|f[p++]<<8],width:f[p++]|f[p++]<<8,height:f[p++]|f[p++]<<8,pixel_size:f[p++],flags:f[p++]};!function(e){switch(e.image_type){case n:case a:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("TGALoader: Invalid type colormap data for indexed type.");break;case i:case r:case o:case s:e.colormap_type&&console.error("TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("TGALoader: No data.");default:console.error('TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('TGALoader: Invalid pixel size "%s".',e.pixel_size)}(m),m.id_length+p>e.length&&console.error("TGALoader: No data."),p+=m.id_length;var v=!1,g=!1,y=!1;switch(m.image_type){case a:v=!0,g=!0;break;case n:g=!0;break;case o:v=!0;break;case i:break;case s:v=!0,y=!0;break;case r:y=!0}var w=document.createElement("canvas");w.width=m.width,w.height=m.height;var x=w.getContext("2d"),b=x.createImageData(m.width,m.height),M=function(e,t,n,i,r){var a,o,s,l;if(o=n.pixel_size>>3,s=n.width*n.height*o,t&&(l=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){var A,c,h;a=new Uint8Array(s);for(var u=0,d=new Uint8Array(o);u>A){default:case u:a=0,s=1,p=t,o=0,f=1,v=n;break;case c:a=0,s=1,p=t,o=n-1,f=-1,v=-1;break;case d:a=t-1,s=-1,p=-1,o=0,f=1,v=n;break;case h:a=t-1,s=-1,p=-1,o=n-1,f=-1,v=-1}if(y)switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s){var l,A,c,h=0,u=m.width;for(c=t;c!==i;c+=n)for(A=r;A!==o;A+=a,h++)l=s[h],e[4*(A+u*c)+0]=l,e[4*(A+u*c)+1]=l,e[4*(A+u*c)+2]=l,e[4*(A+u*c)+3]=255}(e,o,f,v,a,s,p,i);break;case 16:!function(e,t,n,i,r,a,o,s){var l,A,c=0,h=m.width;for(A=t;A!==i;A+=n)for(l=r;l!==o;l+=a,c+=2)e[4*(l+h*A)+0]=s[c+0],e[4*(l+h*A)+1]=s[c+0],e[4*(l+h*A)+2]=s[c+0],e[4*(l+h*A)+3]=s[c+1]}(e,o,f,v,a,s,p,i);break;default:console.error("TGALoader: Format not supported.")}else switch(m.pixel_size){case 8:!function(e,t,n,i,r,a,o,s,l){var A,c,h,u=l,d=0,f=m.width;for(h=t;h!==i;h+=n)for(c=r;c!==o;c+=a,d++)A=s[d],e[4*(c+f*h)+3]=255,e[4*(c+f*h)+2]=u[3*A+0],e[4*(c+f*h)+1]=u[3*A+1],e[4*(c+f*h)+0]=u[3*A+2]}(e,o,f,v,a,s,p,i,r);break;case 16:!function(e,t,n,i,r,a,o,s){var l,A,c,h=0,u=m.width;for(c=t;c!==i;c+=n)for(A=r;A!==o;A+=a,h+=2)l=s[h+0]+(s[h+1]<<8),e[4*(A+u*c)+0]=(31744&l)>>7,e[4*(A+u*c)+1]=(992&l)>>2,e[4*(A+u*c)+2]=(31&l)>>3,e[4*(A+u*c)+3]=32768&l?0:255}(e,o,f,v,a,s,p,i);break;case 24:!function(e,t,n,i,r,a,o,s){var l,A,c=0,h=m.width;for(A=t;A!==i;A+=n)for(l=r;l!==o;l+=a,c+=3)e[4*(l+h*A)+3]=255,e[4*(l+h*A)+2]=s[c+0],e[4*(l+h*A)+1]=s[c+1],e[4*(l+h*A)+0]=s[c+2]}(e,o,f,v,a,s,p,i);break;case 32:!function(e,t,n,i,r,a,o,s){var l,A,c=0,h=m.width;for(A=t;A!==i;A+=n)for(l=r;l!==o;l+=a,c+=4)e[4*(l+h*A)+2]=s[c+0],e[4*(l+h*A)+1]=s[c+1],e[4*(l+h*A)+0]=s[c+2],e[4*(l+h*A)+3]=s[c+3]}(e,o,f,v,a,s,p,i);break;default:console.error("TGALoader: Format not supported.")}}(b.data,m.width,m.height,M.pixel_data,M.palettes),x.putImageData(b,0,0),w}});var Wf=new WeakMap,Xf=function(e){h(i,e);var t=y(i);function i(e){var n;return s(this,i),(n=t.call(this,e)).transcoderPath="",n.transcoderBinary=null,n.transcoderPending=null,n.workerLimit=4,n.workerPool=[],n.workerNextTaskID=1,n.workerSourceURL="",n.workerConfig=null,n}return A(i,[{key:"setTranscoderPath",value:function(e){return this.transcoderPath=e,this}},{key:"setWorkerLimit",value:function(e){return this.workerLimit=e,this}},{key:"detectSupport",value:function(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}},{key:"load",value:function(e,t,n,i){var r=this,a=new Kl(this.manager);a.setResponseType("arraybuffer"),a.setWithCredentials(this.withCredentials);var o=new es;return a.load(e,(function(e){r.loadFromBuffer(e,t,i,o)}),n,i),o}},{key:"loadFromBuffer",value:function(e,t,n,i){return void 0===i&&(i=new es),Wf.has(e)?Wf.get(e).promise.then(t).catch(n):(this._createTexture([e]).then((function(e){i.copy(e),i.needsUpdate=!0,t&&t(i)})).catch(n),i)}},{key:"parseInternalAsync",value:function(e){for(var t=e.levels,i=new Set,r=0;r1&&void 0!==arguments[1]?arguments[1]:{},a=r,o=0,s=0;st._taskLoad?-1:1}));return(n=t.workerPool[t.workerPool.length-1])._taskLoad+=e,n}))}},{key:"dispose",value:function(){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:function(){},i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,s=function(t){console.error("贴图加载失败:"+e,t),r&&r(t)};if(e.constructor===String){if(6===e.split(",").length){e=e.split(",");for(var l=0;l-1||navigator.userAgent.indexOf("Firefox")>-1||navigator.userAgent.indexOf("Safari")>-1&&-1==navigator.userAgent.indexOf("Chrome"))&&(c=$),e=this._rebuildUrl(e),(new Nh).setDataType(o||c).load(e,(function(t){t.image.src=e,n(t)}),i,s);case"TGA":return e=this._rebuildUrl(e),(new jf).load(e,(function(t){t.image.src=e,n(t)}),i,s);case"BASIS":case"MRTB":return e=this._rebuildUrl(e),this.basisLoader||(this.basisLoader=new Xf,this.basisLoader.setWorkerLimit(8),this.basisLoader.setTranscoderPath(If.getDecoderPath()),this.basisLoader.detectSupport(this.renderer),Yf.push(this.basisLoader)),this.count++,this.basisLoader.load(e,(function(i){i.wrapS=V,i.wrapT=V,n(i),i.image.src=e,i.flipY=!0,t.loaded++,t.loaded>=t.count&&t.basisLoader.dispose()}),(function(e){}),(function(e){console.error(e)}));default:var h=e;return h=this.RESIZE?this._resize(h,a):this._rebuildUrl(h),(new tA).load(h,(function(e){et.isPowerOfTwo(e.image.width)&&et.isPowerOfTwo(e.image.height),e.wrapS=V,e.wrapT=V,n(e)}),i,s)}}else if(Array.isArray(e)&&6===e.length){for(var u=0;u-1?e+="&"+n:e+="?"+n,e}if(If.isMobile){var i="x-image-process=image/resize,w_"+(t=2048)+",h_"+t+"/quality,q_100/marker,u_plus";e.indexOf("?")>-1?e+="&"+i:e+="?"+i}return e}},{key:"_rename",value:function(e){return e=e.split("?")[0],encodeURIComponent(e.slice(e.lastIndexOf("/")+1))}},{key:"_rebuildUrl",value:function(e){return this.RENAME&&(e=this._rename(e)),e.startsWith("http")||e.startsWith("data:")?e:this.BASE_URL+e}}]),e}(),Zf=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;s(this,e),this.viewer=n,this.cacheMats=[],this.queryMats={},this.cacheMeshes=[],this.cacheMesheIds=[],this.cacheAnimations=[],this.cacheActions=[],this.cacheSkinnedMeshs=[],this.cacheSkinnedMeshIds=[],this.cacheEnvMap={},this.cacheAoMap={},this.hasSkinnedAnimation=!1,this.model=t.isBIM?new Df(this.viewer):new kf(this.viewer),this.model.objects=this.cacheMeshes,this.model.materials=this.cacheMats,this.instances=null,this.ref=[],this.sref=[],this.boneListByMeshMap=new Map,this.boneListMap=new Map,this.meshLoader=new Qf,this.extraMaterial={},this.cacheExtraMat=[],this.instanceMap=new Map,this.loadCount=0,this.currentLoadCount=0,this.meshLoader.setDecoderPath(If.getDecoderPath()),this.meshLoader.setWorkerLimit(8),this.isOpenInstance=t.instance||!1,this.isOpenInstance&&console.log("开启实例化"),this.meshGroupDic=new Map,this.materialConfig=null,this.animNameMap=new Map,this.mapLoader=new Kf(this.viewer),this.additionPackData={}}return A(e,[{key:"setLoadCount",value:function(e){this.loadCount=e}},{key:"load",value:function(e,t,n,i){var r=this;this.meshLoader.load(e,(function(e){if(e){var t;e.attributes.normal||e.computeVertexNormals(),e.attributes.uv&&pd(e);var n=r.instanceMap.get(e.custom_data.id);if(n){if(!0!==r.isOpenInstance){for(var i=0;i=5?(t.initMatrix=s,t.visible=!1):t.offsetMatrix&&t.version>=3?(t.hasPose=!0,t.initMatrix=s,t.visible=!1):t.applyMatrix(s)}t.sid=e.custom_data.id,t.parentId=n?-1:e.custom_data.parentId,t.materialIndex=e.custom_data.materialIndex,t.nodeType=e.custom_data.nodeType,t.name=e.name,delete e.custom_data,r._assembly(t)}}),(function(){if(r.currentLoadCount++,r.loadCount===r.currentLoadCount&&!0===r.isOpenInstance){var e=new bt;e.getInverse(r.model.matrixWorld);var n,i=S(r.instanceMap);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(r.ref[a[0]]){var o=r.ref[a[0]],s=a[1];if(s){for(var l=0;l0&&i.groups.length>0){var v=n.groups[n.groups.length-1];if(e.materialIndex[v.materialIndex]==t.materialIndex[0])v.count+=i.groups[0].count;else{e.material.push(t.material[0]),e.materialIndex.push(t.materialIndex[0]);var g=v.start+v.count;n.addGroup(g,i.groups[0].count,e.materialIndex.length-1)}}}},{key:"mergeBufferGeometry",value:function(e,t,n){for(var i=e.getAttribute(n).array,r=t.getAttribute(n).array,a=i.length,o=r.length,s=new Float32Array(a+o),l=0;l0){var a=0,o=0,s=e.a.length,l=new Map;e.a.forEach((function(A){var c=A;if(void 0!==c.re){var h=c.a,u=c.re;(c=l.get(u))?(c=JSON.parse(JSON.stringify(c))).re=u:c={},c.a=h}else l.set(c.a,c);r.parseMaterial({config:c,maps:e.b,onLoad:function(){++a===s&&(r._initMaterial(),t&&t instanceof Function&&t())},onTextureLoad:function(){++o===s&&n&&n instanceof Function&&n()},onError:i,edited:!1})})),l.clear()}else t&&t instanceof Function&&t()}},{key:"parseMaterial",value:function(e){var t=e.config,n=e.maps,i=e.onLoad,r=e.onTextureLoad;e.onError,e.edited;var a=t.a,o=this.queryMats[a];if(void 0===o&&a&&a.toString().indexOf("_")>-1){var s=a.split("_")[0],l=this.queryMats[s],A=this.cacheMats[l],c=this.cacheMeshes.find((function(e){return e.name===t.mn})),h=A.clone();h.name=t.ee||a,h.sname=A.sname,h.ID=a,this.cacheMats.push(h),o=this.cacheMats.length-1,this.queryMats[a]=o,c.material[c.material.indexOf(A)]=h}var u=this.cacheMats[o];u||(u=this._createBaseMaterial(a),this.cacheMats.push(u),this.queryMats[a]=this.cacheMats.length-1),Nf.parseAmrtMaterial(t,n,u,i,r,this.mapLoader)}},{key:"addToCache",value:function(e){this.cacheMeshes.push(e),this.cacheMesheIds.push(e.ID)}},{key:"loadAnimationComplete",value:function(e){for(var t=[],n=0;n0&&(r=r.concat(n.parseSkinAnimation(i)));var o=new Gl(i.name,i.Duration,r);n.model.animation.addClip(o),n.animNameMap.set(e,i.name)}}catch(e){console.error("动画文件解析出错!",e)}t&&t()}),(function(){i.dispose()}))}},{key:"parseSkinAnimation",value:function(e){if(e.boneId2Anim){var t=new bt,n=new at,i=new nt,r=new at;e.Duration;for(var a=[],o=0;oi&&(i=a.d);for(var h=0;h=0&&this.cacheMats.splice(o,1)}}}},{key:"replaceMaterials",value:function(e){var t=e.url,n=e.onload,i=e.onTextureLoad;this.extraMaterial={},this.loadMaterials({url:t,onload:n,onTextureLoad:i})}},{key:"_createDracoLoader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4,t=new Qf;return t.setDecoderPath(If.getDecoderPath()),t.setWorkerLimit(e),t}}]),e}(),Jf=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this)).logId="",i.viewer=e,i.mapLoader=new Kf(e),i}return A(n,[{key:"load",value:function(e,t,n,i){var r=this,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return this.paths=e,void 0!==e.localPath&&this.mapLoader.setBaseUrl(e.localPath),this._onLoad=t,this._onProgress=n,this._onError=i,this.logId=!!a.log&&a.log.toString(),e.m[0].indexOf(".mbin")>-1||e.m[0].indexOf(".mrmb")>-1?this.loader=new Zf(a,this.viewer):this.loader=new zf(a,this.viewer),this.loader.mapLoader=this.mapLoader,this.paths.nodes?this.loader.loadNodes(this.paths.nodes,(function(){r._loadMultiMesh()})):this._loadAdditionPack((function(){if(r.paths.instance&&r.paths.instance.length>0)for(var e=0;e0)for(var t=0;t0?this.paths.addition.forEach((function(n){n&&t.loader.loadAdditionPack(n,e)})):e()}},{key:"_loadComplete",value:function(e){var t=this;e.objects=[],e.traverse((function(t){t.isMesh&&e.objects.push(t)})),e.recalculationBound(),e.update(),this.loader.bindSkeleton(),this.loader.loadMeshComplete();var n=!1;this.paths.skin&&this.paths.skin.length>0?(n=!0,this._loadSkin(this.paths.skin,(function(){t.loader.initSkeletonTransform(),t._loadAnimations(),t._loadMaterials(t.paths.mat),t._onProgress&&t._onProgress(100),t.dispatchEvent(ld.MESH_LOADED,e),t._onLoad&&t._onLoad(e)}))):this._loadAnimations(),this.paths.a&&this.paths.a.length,n||(this._loadMaterials(this.paths.mat),this._onProgress&&this._onProgress(100),this.dispatchEvent(ld.MESH_LOADED,e),this._onLoad&&this._onLoad(e)),this.loader.meshLoader&&this.loader.meshLoader.dispose()}},{key:"_loadSkin",value:function(e,t){for(var n=0;n=t&&(e.logId&&console.timeEnd("网格加载用时(".concat(e.logId,")")),e.paths.i&&e.paths.ii?e.loadInstanceMesh((function(){e._loadComplete(e.loader.model)})):e._loadComplete(e.loader.model))},l=function(t){e._onError&&e._onError(t),e.dispatchEvent(ld.MESH_LOAD_ERROR)},A=function(n){e.loader.setLoadCount&&e.loader.setLoadCount(t);for(var A=function(t){var n=e.paths.m[o];e.loader.load(n,s,(function(n){!function(t,n){var o=e.paths.ms&&e.paths.ms[n];if(e._onProgress){if(r[n]=o||t.total,!r[n])return;i[n]=t.loaded,a[n]=i[n]/r[n];var s=a.reduce((function(e,t){return e+t}),0)/a.length;e._onProgress(parseInt(100*s))}}(n,t)}),l),o++},c=0;c0?A(Math.min(t,20)):s()}},{key:"_preloadMaterial",value:function(){var e=this;void 0!==this.paths.localPath&&(this.mapLoader.RESIZE=!1),this.paths.mat.forEach((function(t){(new Kl).load(t,(function(t){for(var n in(t=JSON.parse(t)).b)e.mapLoader.load(t.b[n])}))}))}},{key:"loadInstanceMesh",value:function(e){var t=this;(new Kl).load(this.paths.i,(function(n){var i=JSON.parse(n);t.loader.instances=i;var r=t.paths.ii.length,a=0;t.paths.ii.forEach((function(n){t.loader.load(n,(function(n){(n=n[0]).parent&&n.parent.remove(n);var o=[];i.forEach((function(e,t){e.c==n.iid&&o.push(e)}));var s=new El;s.name=name,s.color=new Fn("#cccccc");var l=[s],A=new Lf(n.geometry,l,o.length);t.loader.model.add(A);var c=new bt;c.getInverse(t.loader.model.matrixWorld),o.forEach((function(e,n){var i=new Vf;i.name=e.b,i.instanceMesh=A,i.instanceIndex=n,i.applyMatrix((new bt).fromArray(e.d));var r=t.loader.model.getObjectByProperty("ID",e.e)||t.loader.model;r&&(r.add(i),t.loader.addToCache(i)),i.updateMatrixWorld(!0);var a=new bt;A.setMatrixAt(n,a.multiplyMatrices(c,i.matrixWorld)),A.objects.push(i)})),A.instanceMatrix.needsUpdate=!0,++a>=r&&e()}))}))}),void 0,(function(){console.error("实例化数据文件加载失败"),e()}))}},{key:"preloadMap",value:function(e,t,n){this.loader.preloadMap(e,t,void 0,n)}},{key:"dispatchEvent",value:function(e,t){b(u(n.prototype),"dispatchEvent",this).call(this,{type:e,data:t})}},{key:"addEventListener",value:function(e,t){return b(u(n.prototype),"addEventListener",this).call(this,e,t),this}}]),n}(Je),qf=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).isBIMLoader=!0,i}return A(n,[{key:"load",value:function(e,t,i,r){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return a.isBIM=!0,b(u(n.prototype),"load",this).call(this,e,t,i,r,a),this.loadConfig(this.paths.bim),this.paths.bimNode&&this.loadNodeTree(this.paths.bimNode),this.loader.model}},{key:"loadNodeTree",value:function(e){var t=this;(new Kl).setResponseType("json").load(e,(function(e){console.time("nodeTree");var n={};e.forEach((function(e){if(e.b.indexOf("##")>-1){var t=e.b.split("##");e.b=t[0],e.CID=parseInt(t[1])}n[e.a]=e}));for(var i={},r={children:{}},a=0;a1&&void 0!==arguments[1]?arguments[1]:{};this.modelGroup.add(e),this.dispatchEvent({type:ld.MODEL_UPDATE}),(1===this.modelGroup.children.length||t.fitCamera||void 0===t.fitCamera)&&(e.boundingBox?this.viewer.sceneManager.fitCamera(e):(t.box&&!t.box.isBox3&&(t.box=(new tn).setFromArray(t.box.min.concat(t.box.max))),this.viewer.sceneManager.fitCamera(e,t.box))),this.viewer.renderManager.render()}},{key:"fitCamera",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.dispatchEvent({type:ld.MODEL_UPDATE}),(1===this.modelGroup.children.length||t.fitCamera||void 0===t.fitCamera)&&(e.boundingBox||t.box&&!t.box.isBox3&&(t.box=(new tn).setFromArray(t.box.min.concat(t.box.max)))),this.viewer.renderManager.render()}},{key:"removeModel",value:function(e){e.parent&&e.parent.remove(e),this.dispatchEvent({type:ld.MODEL_UPDATE}),this.viewer.renderManager.render()}},{key:"removeCache",value:function(e){this.cacheModels.delete(e)}},{key:"modelClone",value:function(e,t){var n=t.model,i=t.options;n.copy(e),n.visible=0!=e.initVisible,i.onLoad&&i.onLoad(n),i.onProgress&&i.onProgress(),i.onError&&i.onError(),i.onMatLoad&&i.onMatLoad(),i.onAnimeLoad&&i.onAnimeLoad(n),i.onSceneLoad&&i.onSceneLoad(),i.onTextureLoad&&i.onTextureLoad(n),i.onPostProcessingLoad&&i.onPostProcessingLoad(),i.onComplete&&i.onComplete(n)}},{key:"actionClone",value:function(e){var t=e.get("model"),n=e.get("optionsList");e.set("optionsList",[]);for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{},i={},r=new Map;if(this.cacheModels.get(e)){r=this.cacheModels.get(e);var a=new kf(this.viewer);if(r.get("model")){var o=r.get("model"),s={options:n,model:a};this.modelClone(o,s)}else{var l=r.get("optionsList"),A={options:n,model:a};l.push(A)}return a}r.set("path",e),r.set("optionsList",[]),this.cacheModels.set(e,r);var c=e;if(n.background=n.background||void 0===n.background,n.env=n.env||void 0===n.env,n.focus=n.focus||void 0===n.focus,n.addModel=n.addModel||void 0===n.addModel,n.postprocessing=n.postprocessing||void 0===n.postprocessing,e&&n.offline){if(!(c=lu.getFileList(e)))return(c=lu.hasMRCBFile(e))?(i.onload=0,this.viewer.largeSceneLoader2.load(e,(function(e){e.coordinate=c.coordinate,n.onLoad&&n.onLoad(e),i.onload=1,t.actionComplete(e,n.onComplete,i)}),n)):(this.actionComplete(null,n.onComplete,i),null);c.localPath=e+"Texture/"}else{if(/^\d{19}/.test(e)){n.id=n.id||e;try{c=n.local?lu.getLocalModelById(e):lu.getModelById(e),n.local&&lu.setOnlinePath(c)}catch(e){return n.onError&&n.onError(e),void this.actionComplete(e,n.onComplete,i)}}n.baseURL&&(c=lu.setLocalPath(c,n.baseURL))}if(cu.options&&cu.options.offline){var h=!1,u=function(e){var t=c[e];if(Array.isArray(t)){if(t.find((function(e){return t&&t.includes&&e.includes("https://laozi-auto-east.obs.cn-east-2.myhuaweicloud.com")})))throw h=!0,new Error("离线模式下不允许加载线上资源")}else if(t&&t.includes&&t.includes("https://laozi-auto-east.obs.cn-east-2.myhuaweicloud.com"))throw h=!0,new Error("离线模式下不允许加载线上资源")};for(var d in c)u(d);if(h)return}if(c.levelUrl)return this.cacheModels.delete(e),c.levelUrl.endsWith("AMRT-L")?(i.onload=0,this.viewer.largeSceneLoader2.load(c.levelUrl,(function(e){e.coordinate=c.coordinate,n.onLoad&&n.onLoad(e),i.onload=1,t.actionComplete(e,n.onComplete,i)}),{focus:n.focus,doubeside:n.doubeside,transparent:n.transparent,alhpaTest:n.alhpaTest,isOnline:!0})):(i.onload=0,this.viewer.largeSceneLoader.load(c.levelUrl,(function(e){e.coordinate=c.coordinate,n.onLoad&&n.onLoad(e),i.onload=1,t.actionComplete(e,n.onComplete,i)})));i.onload=0,i.onPostProcessingLoad=0;var f=c.bim?new qf(this.viewer):new Jf(this.viewer),p=f.load(c,(function(e){if(c.fitCamera=n.focus,n.addModel&&(t.modelGroup.add(e),e.initVisible=e.visible,e.visible=!1),n.offline||c.sceneData&&c.sceneData.endsWith(".json"))c.sceneData?t.loadSceneData(p,c.sceneData,c):t.setCameraView(e,null,c);else if(c.sceneData){var r=JSON.parse(c.sceneData);if(r.rotation&&(e.rotation.fromArray(r.rotation),e.updateMatrix(),e.boundingBox.setFromObject(e)),!r.shadow)return;t.viewer.sceneManager.enableShadow=r.shadow.visible,t.viewer.sceneManager.shadowDecay=r.shadow.decay||1,t.viewer.sceneManager.shadowStrength=r.shadow.strength/10,t.viewer.sceneManager.shadowOffset=(r.shadow.offset||0)*e.boundingBox.getSize(new at).y*2,t.setCameraView(e,r,c)}else t.setCameraView(e,null,c);n.onLoad&&n.onLoad(e),e.onComplete&&e.onComplete(),i.onload=1,t.actionComplete(e,n.onComplete,i)}),(function(e){n.onProgress&&n.onProgress(e)}),(function(e){n.onError&&n.onError(e),t.actionComplete(e,n.onComplete,i)}),n);p.viewer=this.viewer,p.modelPath=c.m[0],i.onSceneLoad=0;var v=n.localPath||c.localPath||"";return f.addEventListener(ld.MATERIAL_LOADED,(function(){c.scene?t.viewer.sceneManager.loadSceneFile(c.scene,{localPath:v,onLoad:function(e){n.env&&e.e?(t.mapLoader.loadEnvMap(v+e.e,(function(r){p.materials.map((function(t){t.envMap=r,t.envMapIntensity=null==e.ei||null==e.ei?.7:e.ei,t.envRotateY=Math.PI/180*(e.ea||0),t.needsUpdate=!0})),n.onSceneLoad&&n.onSceneLoad(e),i.onSceneLoad=1,t.actionComplete(p,n.onComplete,i),setTimeout((function(){n.postprocessing&&t.viewer.sceneManager.loadPostProcessing(p),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,t.actionComplete(p,n.onComplete,i)}),1e3)})),t.viewer.sceneManager.setEnvMapIntensity(e.ei),t.viewer.sceneManager.setEnvMapRotation(e.ea||0),t.viewer.sceneManager.envMapUrl=e.e):(n.onSceneLoad&&n.onSceneLoad(e),i.onSceneLoad=1,t.actionComplete(p,n.onComplete,i),setTimeout((function(){n.postprocessing&&t.viewer.sceneManager.loadPostProcessing(p),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,t.actionComplete(p,n.onComplete,i)}),1e3))},background:n.background},p):c.sky?(c.sky.b&&n.background&&t.viewer.sceneManager.setSkyBox(c.sky.b),c.sky.a&&n.env?(t.mapLoader.loadEnvMap(c.sky.a,(function(e){p.setEnvMap(e),n.onSceneLoad&&n.onSceneLoad({a:{aa:"#FFFFFF",ab:.7},b:{ba:"#FFFFFF",bb:.7,bc:[0,.7,.7]},c:1,ca:c.sky.b,cb:.5,e:c.sky.a,ea:0,ei:.7}),i.onSceneLoad=1,t.actionComplete(p,n.onComplete,i)})),t.viewer.sceneManager.envMapUrl=c.sky.a):(i.onSceneLoad=1,t.actionComplete(p,n.onComplete,i)),n.onPostProcessingLoad&&n.onPostProcessingLoad(null),i.onPostProcessingLoad=1,t.actionComplete(p,n.onComplete,i)):(n.onSceneLoad&&n.onSceneLoad({a:{aa:"#FFFFFF",ab:.7},b:{ba:"#FFFFFF",bb:.7,bc:[0,.7,.7]},c:2,ca:"#000000"}),n.onPostProcessingLoad&&n.onPostProcessingLoad(null),i.onSceneLoad=1,t.actionComplete(p,n.onComplete,i),i.onPostProcessingLoad=1,t.actionComplete(p,n.onComplete,i)),!n.env&&t.viewer.sceneManager.envMapUrl&&n.onLoad&&n.onLoad(m).setEnvMap(t.viewer.sceneManager.envMapUrl),n.onMatLoad&&n.onMatLoad()})),c.a&&c.a.length>0&&(i.onAnimeLoad=0),f.addEventListener(ld.ANIMATION_LOADED,(function(){n.onAnimeLoad&&n.onAnimeLoad(p),i.onAnimeLoad=1,t.actionComplete(p,n.onComplete,i)})),i.onTextureLoad=0,f.addEventListener(ld.TEXTURE_LOADED,(function(){r.set("model",p),p.cacheKey=r.get("path"),t.actionClone(r),n.onTextureLoad&&n.onTextureLoad(p),i.onTextureLoad=1,t.actionComplete(p,n.onComplete,i)})),p.options=n,p.loader=f,p}},{key:"loadModel_miniprogram",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={},r=e,a=this;if(n.background=n.background||void 0===n.background,n.env=n.env||void 0===n.env,n.focus=n.focus||void 0===n.focus,n.addModel=n.addModel||void 0===n.addModel,n.postprocessing=n.postprocessing||void 0===n.postprocessing,e.constructor!==String&&isNaN(e))n.baseURL&&(r=lu.setLocalPath(e,n.baseURL)),s();else{n.id=n.id||e;var o=n.local?lu.getLocalModelById:lu.getModelById;o(e).then((function(t){if(r=t,"无权访问该模型"!=t){if("token不存在或已失效"===t)return cu.token=cu.checkDevloper(),void(cu.token&&lu.getModelById(e).then((function(e){r=e,n.local&&lu.setOnlinePath(r),s()})));n.local&&lu.setOnlinePath(r),s()}})).catch((function(e){n.onError&&n.onError(e),t.actionComplete(e,n.onComplete,i)}))}function s(){var e=r.bim?new qf(a.viewer):new Jf(a.viewer);i.onLoad=0,i.onPostProcessingLoad=0;var t=e.load(r,(function(e){r.fitCamera=void 0===n.focus||n.focus,!1!==n.addModel&&(a.modelGroup.add(e),e.visible=!1),n.onLoad&&n.onLoad(e),i.onLoad=1,a.actionComplete(e,n.onComplete,i)}),(function(e){n.onProgress&&n.onProgress(e)}),(function(e){n.onError&&n.onError(e),a.actionComplete(e,n.onComplete,i)}),n);return t.viewer=a.viewer,i.onMatLoad=0,e.addEventListener(ld.MATERIAL_LOADED,(function(){n.onMatLoad&&n.onMatLoad(),i.onMatLoad=1,a.actionComplete(t,n.onComplete,i),r.scene?(i.onSceneLoad=0,a.viewer.sceneManager.loadSceneFile(r.scene,{onLoad:function(e){n.env&&e.e?(a.mapLoader.loadEnvMap(e.e,(function(n){t.materials.map((function(t){t.envMap=n,null==e.ei||null==e.ei?t.envMapIntensity=.7:t.envMapIntensity=Number(e.ei),e.ea&&0!==e.ea?t.envRotateY=Math.PI/180*Number(e.ea):t.envRotateY=0,t.needsUpdate=!0}))})),n.onSceneLoad&&n.onSceneLoad(e),i.onSceneLoad=1,a.actionComplete(t,n.onComplete,i),setTimeout((function(){n.postprocessing&&a.viewer.sceneManager.loadPostProcessing(t),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,a.actionComplete(t,n.onComplete,i)}),1e3)):setTimeout((function(){n.postprocessing&&a.viewer.sceneManager.loadPostProcessing(t),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,a.actionComplete(t,n.onComplete,i)}),1e3)},background:n.background})):r.sky?(r.sky.b&&n.background&&a.viewer.sceneManager.setSkyBox(r.sky.b),r.sky.a&&n.env?(a.mapLoader.loadEnvMap(r.sky.a,(function(e){t.setEnvMap(e)})),n.onSceneLoad&&n.onSceneLoad(config),setTimeout((function(){n.postprocessing&&a.viewer.sceneManager.loadPostProcessing(t),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,a.actionComplete(t,n.onComplete,i)}),1e3)):setTimeout((function(){n.postprocessing&&a.viewer.sceneManager.loadPostProcessing(t),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,a.actionComplete(t,n.onComplete,i)}),1e3)):setTimeout((function(){n.postprocessing&&a.viewer.sceneManager.loadPostProcessing(t),n.onPostProcessingLoad&&n.onPostProcessingLoad(),i.onPostProcessingLoad=1,a.actionComplete(t,n.onComplete,i)}),1e3),!n.env&&a.viewer.sceneManager.envMapUrl&&m.setEnvMap(a.viewer.sceneManager.envMapUrl)})),r.a&&r.a.length>0&&(i.onAnimeLoad=0),e.addEventListener(ld.ANIMATION_LOADED,(function(){n.onAnimeLoad&&n.onAnimeLoad(t),i.onAnimeLoad=1,a.actionComplete(error,n.onComplete,i)})),t.loader=e,t}}},{key:"loadSingleMaterial",value:function(e,t){var n=new Zf(this,this.viewer);if(t.mapRoot){var i=e.b;for(var r in i)i[r].startsWith("http")&&(i[r]=i[r].slice(i[r].lastIndexOf("/")+1)),i[r]=t.mapRoot+i[r]}n.parseMaterials(e,(function(){t.onLoad&&t.onLoad(n.cacheMats)}))}},{key:"loadSceneData",value:function(e,t,n){var i=this;(new ou).load(t,(function(t){try{var r=JSON.parse(t);if(r.rotation&&(e.rotation.fromArray(r.rotation),e.updateMatrix(),e.boundingBox.setFromObject(e)),!r.shadow)return;i.viewer.sceneManager.enableShadow=r.shadow.visible,i.viewer.sceneManager.shadowDecay=r.shadow.decay||1,i.viewer.sceneManager.shadowStrength=r.shadow.strength/10,i.viewer.sceneManager.shadowOffset=(r.shadow.offset||0)*Math.ceil(e.boundingBox.getSize(new at).y)*2,i.setCameraView(e,r,n)}catch(e){console.warn("加载配置数据出错")}}))}},{key:"setCameraView",value:function(e,t,n){if(this.dispatchEvent({type:ld.MODEL_UPDATE}),n.fitCamera||void 0===n.fitCamera)if(t&&t.view){var i=t.view.target,r=t.view.position,a=e.boundingBox.getSize(new at),o=1.5*a.length(),s=e.boundingBox.getCenter(new at),l=s.x-i[0],A=s.y-i[1],c=s.z-i[2],h=[r[0]+l,r[1]+A,r[2]+c],u=[s.x,s.y,s.z],d=new at(h[0]-u[0],h[1]-u[1],h[2]-u[2]).normalize(),f=s.clone().addScaledVector(d,o),p=[f.x,f.y,f.z];this.viewer.controls.setView({position:p,target:u});var m=Math.max(a.x,a.y,a.z),v=Math.min(a.x,a.y,a.z);this.viewer.camera.near=.05*v,20*m>this.viewer.camera.far&&(this.viewer.camera.far=20*m),this.viewer.camera.far<5e3&&(this.viewer.camera.far=5e3),this.viewer.camera.updateProjectionMatrix()}else e.boundingBox?this.viewer.sceneManager.fitCamera(e):(n.box&&!n.box.isBox3&&(n.box=(new tn).setFromArray(n.box.min.concat(n.box.max))),this.viewer.sceneManager.fitCamera(e,n.box));this.viewer.renderManager.render(!0)}}]),n}(Je);function tp(e){var t=new Qt;t.viewer=e;var n=new ki;n.deleteAttribute("uv");var i=new gl({side:1}),r=new gl,a=new LA(16777215,5,28,2);a.position.set(.418,16.199,.3),t.add(a);var o=new Ei(n,i);o.position.set(-.757,13.219,.717),o.scale.set(31.713,28.305,28.591),t.add(o);var s=new Ei(n,r);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),t.add(s);var l=new Ei(n,r);l.position.set(-5.607,-.754,-.758),l.rotation.set(0,.994,0),l.scale.set(1.97,1.534,3.955),t.add(l);var A=new Ei(n,r);A.position.set(6.167,.857,7.803),A.rotation.set(0,.561,0),A.scale.set(3.927,6.285,3.687),t.add(A);var c=new Ei(n,r);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),t.add(c);var h=new Ei(n,r);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),t.add(h);var u=new Ei(n,r);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),t.add(u);var d=new Ei(n,y(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),t.add(d);var f=new Ei(n,y(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),t.add(f);var p=new Ei(n,y(17));p.position.set(14.904,12.198,-1.832),p.scale.set(.15,4.265,6.331),t.add(p);var m=new Ei(n,y(43));m.position.set(-.462,8.89,14.52),m.scale.set(4.38,5.441,.088),t.add(m);var v=new Ei(n,y(20));v.position.set(3.235,11.486,-12.541),v.scale.set(2.5,2,.1),t.add(v);var g=new Ei(n,y(100));function y(e){var t=new Nn;return t.color.setScalar(e),t}return g.position.set(0,20,0),g.scale.set(1,.1,1),t.add(g),t}function np(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;zt.call(this),this.name="BoxClippingHelper",this.box=e,this.boxSize=new at,this.line=new Fh(e,t),this.add(this.line);var n=new ki(1,1,1);this.mesh=new Ei(n,new Nn({transparent:!0,opacity:.25,color:t})),this.box.getSize(this.boxSize),this.mesh.scale.set(this.boxSize.x,this.boxSize.y,this.boxSize.z),this.box.getCenter(this.mesh.position),this.add(this.mesh)}np.prototype=Object.create(zt.prototype),np.prototype.update=function(){this.box.getSize(this.boxSize),this.mesh.scale.set(this.boxSize.x,this.boxSize.y,this.boxSize.z),this.box.getCenter(this.mesh.position)};var ip=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return s(this,n),(i=t.call(this))._mode=-1,i._enabled=!1,i._empty=Object.freeze([]),i._clipPlane=new vn(new at(-1,0,0),0),i._boxClipPlane=[],i._root=new zt,i._showHelper=!0,i.target=r||e.modelGroup,i.viewer=e,i.viewer.renderer.localClippingEnabled=!0,i.viewer.add(i._root),i._init(),i.mode=n.Mode.Plane,i}return A(n,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e=Boolean(e),this.mode==n.Mode.Plane&&(this._control.visible=e),this._root.visible=e,this._updateClippingPlanes()}},{key:"mode",get:function(){return this._mode},set:function(e){var t,i;if(e!==this._mode){switch(e){case n.Mode.Plane:this._control.enabled=!0,(t=this._root).remove.apply(t,C(this._root.children)),this._root.add(this._planeHelper),this.viewer.add(this._control),this._clipPlanes=[this._clipPlane],this._updateClippingPlanes();break;case n.Mode.Box:this._control.enabled=!1,this.viewer.remove(this._control),(i=this._root).remove.apply(i,C(this._root.children)),this._root.add(this._boxHelper),this._clipPlanes=this._boxClipPlane,this._updateClippingPlanes()}this._mode=e}}},{key:"showHelper",get:function(){return this._showHelper},set:function(e){(e=Boolean(e))!==this._showHelper&&(this._boxHelper.visible=e,this._planeHelper.visible=e,this._showHelper=e)}},{key:"_init",value:function(){var e=this;this.target.traverse((function(t){t.isMesh&&(Array.isArray(t.material)?t.material:[t.material]).forEach((function(t){t.clippingPlanes=e._empty}))})),this._initPlaneHelper(),this._initBoxHelper()}},{key:"_initBoxHelper",value:function(){var e=this,t=(new tn).setFromObject(this.target),i=new at;t.getSize(i),t.expandByVector(new at(i.x/100,i.y/100,i.z/100));var r=(new tn).copy(t);this._boxClipPlane.push(new vn(new at(1,0,0),-t.min.x)),this._boxClipPlane.push(new vn(new at(-1,0,0),t.max.x)),this._boxClipPlane.push(new vn(new at(0,1,0),-t.min.y)),this._boxClipPlane.push(new vn(new at(0,-1,0),t.max.y)),this._boxClipPlane.push(new vn(new at(0,0,1),-t.min.z)),this._boxClipPlane.push(new vn(new at(0,0,-1),t.max.z)),this._boxHelper=new np(t,this.color);var a,o=new Nc,s=new at,l={},A=new tt,c=new tt,h=new ut,u=!1;this.viewer.domElement.addEventListener("mousedown",(function(i){if(e.mode===n.Mode.Box&&(o.setFromCamera(If.getDomMouse(i,e.viewer.domElement),e.viewer.camera),o.ray.intersectBox(t,s))){switch(a=e._getIntersectFaceInBox(t,s),l.pageX=i.pageX,l.pageY=i.pageY,u=!0,e.viewer.controls.enabled=!1,a){case 0:h.set(1,0,0,0);break;case 1:h.set(-1,0,0,0);break;case 2:h.set(0,1,0,0);break;case 3:h.set(0,-1,0,0);break;case 4:h.set(0,0,1,0);break;case 5:h.set(0,0,-1,0)}h.applyMatrix4(e.viewer.camera.matrixWorldInverse).applyMatrix4(e.viewer.camera.projectionMatrix),A.set(-h.x,h.y)}})),this.viewer.domElement.addEventListener("mousemove",(function(h){if(e.mode===n.Mode.Box){if(c.set(h.pageX-l.pageX,h.pageY-l.pageY).normalize(),u){var d=0;switch(a){case 0:if(d=c.dot(A)*i.x/100,t.min.x-d>=r.max.x||t.min.x-d=r.max.x||t.max.x+d=r.max.y||t.min.y-d=r.max.y||t.max.y+d=r.max.z||t.min.z-d=r.max.z||t.max.z+d2&&void 0!==arguments[2]?arguments[2]:"";e&&(0===e.indexOf("#")?(this.scene.background=(new Fn).setStyle(e),t&&t()):(new tA).setPath(i).load(e,(function(e){e.minFilter=Z,n.scene.background=e,t&&t()})))}},{key:"clearBackground",value:function(){this.scene.background=null,this.viewer.renderManager.render()}},{key:"setLightness",value:function(e){this.ambientLight.intensity=e,this.viewer.renderManager.render()}},{key:"getLightness",value:function(){return this.ambientLight.intensity}},{key:"getLightColor",value:function(){return"#"+this.ambientLight.color.getHexString()}},{key:"setLightColor",value:function(e){this.ambientLight.color.setStyle(e),this.viewer.renderManager.render()}},{key:"setDirectLightLightness",value:function(e){this.directLight.intensity=e,this.viewer.renderManager.render()}},{key:"getDirectLightLightness",value:function(){return this.directLight.intensity}},{key:"getDirectLightColor",value:function(){return"#"+this.directLight.color.getHexString()}},{key:"setDirectLightPosition",value:function(e,t,n){e.isVector3?this.directLight.position.copy(e):(void 0!==e&&(this.directLight.position.x=e),void 0!==t&&(this.directLight.position.y=t),void 0!==n&&(this.directLight.position.z=n)),this.viewer.renderManager.render(),this.enableShadow&&this.updateShadowMaterial()}},{key:"getDirectLightPosition",value:function(){return this.directLight.position}},{key:"setDirectLightColor",value:function(e){this.directLight.color.setStyle(e),this.viewer.renderManager.render()}},{key:"addSpotLight",value:function(e){if(e.position){var t=new _A(e.color||16777215,e.intensity||1,e.distance||100,e.angle||Math.PI/8,e.penumbra||.5,e.decay||.5);return Array.isArray(e.position)?t.position.fromArray(e.position):t.position.copy(e.position),e.target&&(t.target=e.target),this.root.add(t),t}console.warn("addSpotLight需要指定position")}},{key:"saveSceneData",value:function(){var e={};e.a={aa:this.getLightColor(),ab:this.getLightness()},e.b={ba:this.getDirectLightColor(),bb:this.getDirectLightLightness()},this.lightFollow||(e.b.bc=this.directLight.position.toArray()),e.b.bv=this.directLight.visible;var t=this.scene.background||this._prevBackground;return t&&(t.sky?(e.c=1,e.ca=t.sky,e.cb=this.backgroundBrightness):t.isTexture?(e.c=2,e.ca=[t.image.src,t.image.src].join(",")):t.isColor&&(e.c=2,e.ca="#"+t.getHexString())),this.envMapUrl&&(e.e=this.envMapUrl,e.ea=this.envMapRotation||0,e.ei=this.envMapIntensity),e.v=Boolean(this.backgroundVisible),e.u={v:!1,s:0,r:0},this.viewer.composer.enableUnrealBloom&&(e.u.v=!0,e.u.s=this.viewer.composer.unrealBloom.getStrength(),e.u.r=this.viewer.composer.unrealBloom.getRadius(),e.u.t=this.viewer.composer.unrealBloom.getThreshold(),this.viewer.composer.unrealBloom._lastSelected&&this.viewer.composer.unrealBloom._lastSelected.isMesh&&(e.u.o=this.viewer.composer.unrealBloom._objects.map((function(e){return e.ID})))),e.k={v:!1,h:0,s:0,b:0},this.viewer.composer.enableColorAdjustment&&(e.k.v=!0,e.k.h=this.viewer.composer.colorAdjustment.getHue(),e.k.s=this.viewer.composer.colorAdjustment.getContrast(),e.k.b=this.viewer.composer.colorAdjustment.getVibrance()),e.f={v:!1,a:0,b:0},this.viewer.composer.enableDof&&(e.f.v=!0,e.f.a=this.viewer.composer.dof.aperture,e.f.b=this.viewer.composer.dof.maxblur),e.s={v:!1,r:0,s:0},this.viewer.composer.enableSSAO&&(e.s.v=!0,e.s.r=this.viewer.composer.ssao.getRadius(),e.s.s=this.viewer.composer.ssao.getStrength()),e.g={v:!1,d:0,o:0},this.viewer.composer.enableVignette&&(e.g.v=!0,e.g.d=this.viewer.composer.vignette.getDarkness(),e.g.o=this.viewer.composer.vignette.getOffset()),e.q={v:!1,c:[],r:[],d:0,o:1},this.viewer.composer.enableSSR&&(e.q.v=!0,e.q.c=this.viewer.composer.ssr.objects.map((function(e){return e.ID})),e.q.r=this.viewer.composer.ssr.planeObjects.map((function(e){return e.ID})),e.q.d=this.viewer.composer.ssr.maxDistance,e.q.o=this.viewer.composer.ssr.opacity),e}},{key:"loadSceneData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0,r=void 0===n.background||n.background,a=n.localPath||"";e=JSON.parse(e);var o=Boolean(e.v)||void 0===e.v;return this._data=e,r?(this.setLightColor(e.a.aa),this.setLightness(e.a.ab),this.setDirectLightColor(e.b.ba),this.setDirectLightLightness(e.b.bb),Array.isArray(e.b.bc)?this.directLight.position.fromArray(e.b.bc):this.lightFollow=!0,!1===e.b.bv&&(this.directLight.visible=!1),1==e.c&&this.setSkyBox(a+e.ca,(function(){t.backgroundVisible=o,t.backgroundBrightness=e.cb||.5,i&&i(e)})),2==e.c&&(Array.isArray(e.ca)||(e.ca=e.ca.split(",")),1==e.ca.length?(this.setBackground(e.ca[0]),e.ca=e.ca[0],this.backgroundVisible=o,i&&i(e)):2==e.ca.length&&(If.isMobile?this.setBackground(e.ca[1]+"?time="+Date.now(),(function(){t.backgroundVisible=o,i&&i(e)}),a):this.setBackground(e.ca[0]+"?time="+Date.now(),(function(){t.backgroundVisible=o,i&&i(e)}),a)))):i&&i(e),e}},{key:"loadSceneFile",value:function(e,t){var n=this;(new Kl).load(e,(function(e){n.loadSceneData(e,t,(function(e){n._sceneData=e,t.onLoad&&t.onLoad(e)}))}))}},{key:"loadPostProcessing",value:function(e){var t=this,n=this._sceneData;if(n)return n.k&&n.k.v&&(this.viewer.composer.enableColorAdjustment=!0,this.viewer.composer.colorAdjustment.setHue(n.k.h),this.viewer.composer.colorAdjustment.setContrast(n.k.s),this.viewer.composer.colorAdjustment.setVibrance(n.k.b)),n.f&&n.f.v&&(this.viewer.composer.enableDof=!0,this.viewer.composer.dof.setAperture(n.f.a),this.viewer.composer.dof.setMaxblur(n.f.b),this.enableClickDof=!0),n.s&&n.s.v&&(this.viewer.composer.enableSSAO=!0,this.viewer.composer.ssao.setStrength(n.s.s),this.viewer.composer.ssao.setRadius(n.s.r)),n.u&&n.u.v&&(this.viewer.composer.enableUnrealBloom=!0,this.viewer.composer.unrealBloom.setStrength(n.u.s),this.viewer.composer.unrealBloom.setRadius(n.u.r),this.viewer.composer.unrealBloom.setThreshold(n.u.t),n.u.o?n.u.o.map((function(n){return t.viewer.composer.unrealBloom.add(e.getObjectByID(n))})):this.viewer.composer.unrealBloom.add(e)),n.g&&n.g.v&&(this.viewer.composer.enableVignette=!0,this.viewer.composer.vignette.setDarkness(n.g.d),this.viewer.composer.vignette.setOffset(n.g.o)),n.q&&n.q.v&&(this.viewer.composer.enableSSR=!0,n.q.c&&n.q.c.length>0&&n.q.c.map((function(n){return t.viewer.composer.ssr.addObject(e.getObjectByID(n))})),n.q.r&&n.q.r.length>0&&n.q.r.map((function(n){return t.viewer.composer.ssr.addPlane(e.getObjectByID(n))})),this.viewer.composer.ssr.maxDistance=n.q.d,this.viewer.composer.ssr.opacity=n.q.o),{colorAdjustment:this.viewer.composer.enableColorAdjustment,dof:this.viewer.composer.enableDof,ssao:this.viewer.composer.enableSSAO,unrealBloom:this.viewer.composer.enableUnrealBloom}}},{key:"hidePostprocessing",value:function(){this.viewer.composer.enableUnrealBloom=!1,this.viewer.composer.enableColorAdjustment=!1,this.viewer.composer.enableDof=!1,this.viewer.composer.enableSSAO=!1,this.viewer.composer.enableVignette=!1,this.enableClickDof=!1}},{key:"showFog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#ffffff",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;this.scene.fog=new to(e,t,n)}},{key:"showFogExp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#ffffff",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;t*=5e-5,this.scene.fog=new eo(e,t)}},{key:"setFogDensity",value:function(e){this.scene.fog&&(this.scene.fog.density=5e-5*e)}},{key:"clearFog",value:function(){this.scene.fog=null}},{key:"showGridHelp",value:function(e,t,n){this.gridHelp?this.gridHelp.visible=!0:(this.gridHelp=new ph(e,t,n,n),this.root.add(this.gridHelp))}},{key:"hideGridHelp",value:function(){this.gridHelp&&(this.gridHelp.visible=!1)}},{key:"showAxesHelper",value:function(e){if(this.axesHelper&&this.root.remove(this.axesHelper),!e){var t=(new tn).setFromObject(this.modelGroup);e=Math.max(t.getSize().x,t.getSize().y,t.getSize().z)}this.axesHelper=new Oh(e),this.root.add(this.axesHelper)}},{key:"hideAxesHelper",value:function(){this.axesHelper&&this.root.remove(this.axesHelper)}},{key:"fitCamera",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.modelGroup,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n&&n.isBox3?e=n:(e=new tn).expandByObject(t);var i=e.getCenter(new at);t===this.modelGroup&&(t.translateX(-i.x),t.translateY(-i.y),t.translateZ(-i.z),i.x=i.y=i.z=0),this.modelGroup.traverse((function(e){e._shadow&&(t.updateMatrixWorld(),t.matrixWorld.decompose(e._shadow.parent.position,e._shadow.parent.quaternion,e._shadow.parent.scale))}));var r=1.5,a=.8,o=.05,s=this.viewer.renderManager.container.getBoundingClientRect();s.widththis.camera.far&&(this.camera.far=20*A),this.camera.far<5e3&&(this.camera.far=5e3),this.camera.near<.01&&(this.camera.near=.01),this.camera.defaultPos.copy(this.camera.position);var d=new at(i.x,i.y+h*a,i.z+h*r);this.camera.controller?(this.camera.controller.setPosition(d.x,d.y,d.z),this.camera.controller.setTarget(i.x,i.y,i.z)):(this.camera.position.z=d.z,this.camera.position.y=d.y,this.camera.lookAt(i.x,i.y,i.z)),this.camera.updateProjectionMatrix()}},{key:"dispose",value:function(){this.scene.traverse((function(e){e.isMesh&&(e.geometry&&e.geometry.dispose(),(Array.isArray(e.material)?e.material:[e.material]).forEach((function(e){e.map&&e.map.dispose(),e.dispose()})))})),this.scene.background&&this.scene.background.dispose&&this.scene.background.dispose(),this.scene.dispose(),this.scene.background=null}},{key:"updateShadowMaterial",value:function(){var e=this;op.setFromObject(this.modelGroup);var t=new ut(0,-1,0,-op.min.y+this.shadowOffset),n=this.shadowDecay,i=this.shadowStrength;this.modelGroup.traverse((function(r){r.isModel&&(e._enableShadow?(op.setFromObject(r),r.shadowMaterial?(r.shadowMaterial.lightDirection.copy((new at).sub(e.directLight.position)),r.shadowMaterial.shadowPlane=t,r.shadowMaterial.shadowLength=op.getSize(sp).length()*n,r.shadowMaterial.shadowStrength=i,op.getCenter(r.shadowMaterial.center)):r.shadowMaterial=new Sl({lightDirection:(new at).sub(e.directLight.position),shadowPlane:t,shadowLength:op.getSize(sp).length()*n,color:new Fn(0),shadowStrength:i,center:op.getCenter(sp)})):r.shadowMaterial=null)}))}}]),n}(Je);function up(e){var t=this;if(cp&&!(Date.now()-cp>200)){var n=e.offsetX,i=e.offsetY;this.icon.style.left=n-15+"px",this.icon.style.top=i-15+"px",this.icon.style.opacity=1,this.icon.style["-webkit-user-drag"]="none",Ap&&clearTimeout(Ap),Ap=setTimeout((function(){return t.icon.style.opacity=0}),1e3);var r=If.getDomMouse(e,this.viewer.domElement);ap.setFromCamera(r,this.viewer.renderManager.camera);var a=ap.intersectObject(this.modelGroup,!0);if(a[0]){var o=a[0].distance;this.viewer.composer.dof.setFocus(o)}}}function dp(e){cp=Date.now()}function fp(e){this.viewer=e;var t=this.object=e.camera;this.domElement=void 0!==e.renderer.domElement?e.renderer.domElement:document,this.enabled=!0,this.target=new at,this._minDistance=0,this.minDistance=0,this._maxDistance=1/0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this._minPolarAngle=0,this._maxPolarAngle=Math.PI,this._minAzimuthAngle=-1/0,this._maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this._enableZoom=!0,this.zoomSpeed=1,this._enableRotate=!0,this.rotateSpeed=1,this._enablePan=!0,this.leftPan=!1,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:_.LEFT,MIDDLE:_.MIDDLE,RIGHT:_.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._rotateLeft=function(e){C(e)},this._rotateUp=function(e){B(e)},this.panLeft=function(e){S(e,n.object.matrix)},this.panRight=function(e){S(-e,n.object.matrix)},this.panUp=function(e){T(e,n.object.matrix)},this.panDown=function(e){T(-e,n.object.matrix)},this.dollyIn=function(t){L(t,!0),e.renderManager.render()},this.dollyOut=function(t){F(t,!0),e.renderManager.render()},this.zoom=function(e){e<0?F(M()):e>0&&L(M()),n._update()},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){u.set(0,0,0),n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(i),n._update(),s=o.NONE},this._update=function(){var e=new at,r=(new nt).setFromUnitVectors(t.up,new at(0,1,0)),a=r.clone().inverse(),f=new at,p=new nt;return function(){n.cachePosition&&(n.setPosition(n.cachePosition.x,n.cachePosition.y,n.cachePosition.z),n.cachePosition=null),n.cacheTarget&&(n.setTarget(n.cacheTarget.x,n.cacheTarget.y,n.cacheTarget.z),n.cacheTarget=null);var t=n.object.position;e.copy(t).sub(n.target),e.applyQuaternion(r),A.setFromVector3(e),n.autoRotate&&s===o.NONE&&C(2*Math.PI/60/60*n.autoRotateSpeed),A.theta+=c.theta,A.phi+=c.phi,A.theta=Math.max(n._minAzimuthAngle,Math.min(n._maxAzimuthAngle,A.theta)),A.phi=Math.max(n._minPolarAngle,Math.min(n._maxPolarAngle,A.phi)),A.makeSafe(),A.radius*=h,A.radius=Math.max(n.minDistance,Math.min(n.maxDistance,A.radius)),n.target.add(u),e.setFromSpherical(A),e.applyQuaternion(a),t.equals(n.target.clone().add(e))||t.copy(n.target).add(e),n.object.lookAt(n.target);var m=!1;return u.equals(new at)||(m=!0),!0===n.enableDamping?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0)),h=1,!!(d||f.distanceToSquared(n.object.position)>l||8*(1-p.dot(n.object.quaternion))>l)&&(m?i.data="pan":delete i.data,n.dispatchEvent(i),f.copy(n.object.position),p.copy(n.object.quaternion),d=!1,!0)}}(),this.computePosition=function(e,t,i,r){var a=(new nt).setFromUnitVectors(n.object.up,new at(0,1,0)),o=a.clone().inverse(),s=new at;return s.copy(e).sub(t),s.applyQuaternion(a),A.setFromVector3(s),void 0!==i?A.theta=i:A.theta+=c.theta,void 0!==r?A.phi=r:A.phi+=c.phi,A.theta=Math.max(n._minAzimuthAngle,Math.min(n._maxAzimuthAngle,A.theta)),A.phi=Math.max(n._minPolarAngle,Math.min(n._maxPolarAngle,A.phi)),A.makeSafe(),A.radius*=h,A.radius=Math.max(n.minDistance,Math.min(n.maxDistance,A.radius)),s.setFromSpherical(A),s.applyQuaternion(o),e.copy(t).add(s),e},this.dispose=function(){n.domElement.removeEventListener("contextmenu",G,!1),n.domElement.removeEventListener("mousedown",P,!1),n.domElement.removeEventListener("wheel",R,!1),n.domElement.removeEventListener("touchstart",N,!1),n.domElement.removeEventListener("touchend",Q,!1),n.domElement.removeEventListener("touchmove",z,!1),document.removeEventListener("mousemove",U,!1),document.removeEventListener("mouseup",D,!1),window.removeEventListener("keydown",O,!1)};var n=this,i={type:"change"},r={type:"start"},a={type:"end"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},s=o.NONE,l=1e-6,A=new Gc,c=new Gc;this.sphericalDelta=c;var h=1,u=new at,d=!1,f=new tt,p=new tt,m=new tt,v=new tt,g=new tt,y=new tt,w=new tt,x=new tt,b=new tt;function M(){return Math.pow(.95,n.zoomSpeed)}function C(t){c.theta-=t,e.renderManager.render()}function B(t){c.phi-=t,e.renderManager.render()}this.spherical=A;var E,S=function(){var t=new at;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),u.add(t),e.renderManager.render()}}(),T=function(){var t=new at;return function(i,r){!0===n.screenSpacePanning?t.setFromMatrixColumn(r,1):(t.setFromMatrixColumn(r,0),t.crossVectors(n.object.up,t)),t.multiplyScalar(i),u.add(t),e.renderManager.render()}}(),I=(E=new at,function(e,t){var i=n.domElement===document?n.domElement.body:n.domElement;if(n.object.isPerspectiveCamera){var r=n.object.position;E.copy(r).sub(n.target);var a=E.length();a*=Math.tan(n.object.fov/2*Math.PI/180),S(2*e*a/i.clientHeight,n.object.matrix),T(2*t*a/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(S(e*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),T(t*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n._enablePan=!1)});function L(e,t){n.object.isPerspectiveCamera?t?h=e:h/=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n._enableZoom=!1)}function F(e,t){n.object.isPerspectiveCamera?t?h=e:h*=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),d=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n._enableZoom=!1)}function k(e){v.set(e.clientX,e.clientY)}function P(e){if(!1!==n.enabled){switch(e.preventDefault(),n.domElement.focus?n.domElement.focus():window.focus(),e.button){case n.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey||n.leftPan){if(!1===n._enablePan)return;k(e),s=o.PAN}else{if(!1===n._enableRotate)return;!function(e){f.set(e.clientX,e.clientY)}(e),s=o.ROTATE}break;case n.mouseButtons.MIDDLE:if(!1===n._enableZoom)return;!function(e){w.set(e.clientX,e.clientY)}(e),s=o.DOLLY;break;case n.mouseButtons.RIGHT:if(!1===n._enablePan)return;k(e),s=o.PAN}s!==o.NONE&&(document.addEventListener("mousemove",U,!1),document.addEventListener("mouseup",D,!1),n.dispatchEvent(r))}}function U(e){if(!1!==n.enabled)switch(e.preventDefault(),s){case o.ROTATE:if(!1===n._enableRotate)return;!function(e){p.set(e.clientX,e.clientY),m.subVectors(p,f).multiplyScalar(n.rotateSpeed);var t=n.domElement===document?n.domElement.body:n.domElement;C(2*Math.PI*m.x/t.clientHeight),B(2*Math.PI*m.y/t.clientHeight),f.copy(p),n._update()}(e);break;case o.DOLLY:if(!1===n._enableZoom)return;!function(e){x.set(e.clientX,e.clientY),b.subVectors(x,w),b.y>0?L(M()):b.y<0&&F(M()),w.copy(x),n._update()}(e);break;case o.PAN:if(!1===n._enablePan)return;!function(e){g.set(e.clientX,e.clientY),y.subVectors(g,v).multiplyScalar(n.panSpeed),I(y.x,y.y),v.copy(g),n._update()}(e)}}function D(e){!1!==n.enabled&&(document.removeEventListener("mousemove",U,!1),document.removeEventListener("mouseup",D,!1),n.dispatchEvent(a),s=o.NONE)}function R(e){!1===n.enabled||!1===n._enableZoom||s!==o.NONE&&s!==o.ROTATE||(e.preventDefault(),n.dispatchEvent(r),function(e){e.deltaY<0?F(M()):e.deltaY>0&&L(M()),n._update()}(e),n.dispatchEvent(a))}function O(e){!1!==n.enabled&&!1!==n.enableKeys&&!1!==n._enablePan&&function(e){var t=!1;switch(e.keyCode){case n.keys.UP:I(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:I(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:I(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:I(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n._update())}(e)}function N(e){if(!1!==n.enabled){switch(e.preventDefault(),e.touches.length){case 1:if(!1===n._enableRotate)return;!function(e){f.set(e.touches[0].pageX,e.touches[0].pageY)}(e),s=o.TOUCH_ROTATE;break;case 2:if(!1===n._enableZoom&&!1===n._enablePan)return;!function(e){if(n._enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+i*i);w.set(0,r)}if(n._enablePan){var a=.5*(e.touches[0].pageX+e.touches[1].pageX),o=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(a,o)}}(e),s=o.TOUCH_DOLLY_PAN;break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(r)}}function z(e){if(!1!==n.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===n._enableRotate)return;if(s!==o.TOUCH_ROTATE)return;!function(e){p.set(e.touches[0].pageX,e.touches[0].pageY),m.subVectors(p,f).multiplyScalar(n.rotateSpeed);var t=n.domElement===document?n.domElement.body:n.domElement;C(2*Math.PI*m.x/t.clientHeight),B(2*Math.PI*m.y/t.clientHeight),f.copy(p),n._update()}(e);break;case 2:if(!1===n._enableZoom&&!1===n._enablePan)return;if(s!==o.TOUCH_DOLLY_PAN)return;!function(e){if(n._enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+i*i);x.set(0,r),b.set(0,Math.pow(x.y/w.y,n.zoomSpeed)),L(b.y),w.copy(x)}if(n._enablePan){var a=.5*(e.touches[0].pageX+e.touches[1].pageX),o=.5*(e.touches[0].pageY+e.touches[1].pageY);g.set(a,o),y.subVectors(g,v).multiplyScalar(n.panSpeed),I(y.x,y.y),v.copy(g)}n._update()}(e);break;default:s=o.NONE}}function Q(e){s=o.NONE,!1!==n.enabled&&(n.dispatchEvent(a),s=o.NONE)}function G(e){!1!==n.enabled&&e.preventDefault()}n.domElement.addEventListener("contextmenu",G,!1),n.domElement.addEventListener("mousedown",P,!1),n.domElement.addEventListener("wheel",R,!1),n.domElement.addEventListener("touchstart",N,!1),n.domElement.addEventListener("touchend",Q,!1),n.domElement.addEventListener("touchmove",z,!1),window.addEventListener("keydown",O,!1),this._update()}fp.prototype=Object.create(Je.prototype),fp.prototype.constructor=fp,Object.defineProperties(fp.prototype,{center:{get:function(){return console.warn("OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this._enableZoom},set:function(e){console.warn("OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this._enableZoom=!e}},noRotate:{get:function(){return console.warn("OrbitControls: .noRotate has been deprecated. Use ._enableRotate instead."),!this._enableRotate},set:function(e){console.warn("OrbitControls: .noRotate has been deprecated. Use ._enableRotate instead."),this._enableRotate=!e}},noPan:{get:function(){return console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}},minDistance:{set:function(e){isNaN(e)&&(e=0),this._minDistance=e},get:function(){return isNaN(this._minDistance)&&(this._minDistance=0),this._minDistance}},maxDistance:{set:function(e){isNaN(e)&&(e=1/0),this._maxDistance=e},get:function(){return isNaN(this._maxDistance)&&(this._maxDistance=1/0),this._maxDistance}}});var pp={TOP:"top",NORMAL:"normal",MAP:"map",ROAM_FREE:"roam_free",ROAM_AUTO:"roam_auto",ORBIT:"orbit",GLOBE:"globe",PLANAR:"planar",FLY:"fly",DRIVE:"drive"},mp=function(e){h(n,e);var t=y(n);function n(e,i,r,a){var o;return s(this,n),(o=t.call(this)).object=e,o.camera=i,o.tween=r,o.controls=a,o}return A(n,[{key:"setCameraFloor",value:function(e){this.cameraPos=this.camera.position.clone(),this.controls.enabled=!1,e&&(e.z*=-1,this.camera.position.copy(e)),this.camera.lookAt(new at),this.object.add(this.camera)}},{key:"stopCameraFloor",value:function(){this.controls.enabled=!0,this.camera.parent==this.object&&this.object.remove(this.camera),this.cameraPos&&this.camera.position.copy(this.cameraPos)}},{key:"stopMoving",value:function(){this.tween.stop(),this.stopCameraFloor()}}]),n}(Je),vp={type:ld.CHANGE},gp={type:"move"},yp=function(e){h(n,e);var t=y(n);function n(e){var i,r,a;return s(this,n),(a=t.call(this,e))._viewMode=pp.NORMAL,a._rotateTween=null,a.viewer=e,a.object=e.camera,a.camera=e.camera,e.camera.controller=v(a),b((i=v(a),u(n.prototype)),"addEventListener",i).call(i,"change",(function(){return a.dispatchEvent(gp)})),b((r=v(a),u(n.prototype)),"addEventListener",r).call(r,"end",(function(){return a.dispatchEvent(vp)})),a}return A(n,[{key:"viewMode",get:function(){return this._viewMode},set:function(e){this._viewMode=e,this.dispatchEvent({type:"view_change",data:e})}},{key:"getView",value:function(){return{position:this.object.position.toArray(),target:this.target.toArray()}}},{key:"setView",value:function(e){void 0!==e&&(void 0!==e.position&&(Array.isArray(e.position)?this.object.position.fromArray(e.position):this.object.position.copy(e.position)),void 0!==e.target&&this.target&&(Array.isArray(e.position)?this.target.fromArray(e.target):this.target.copy(e.target))),this.viewer.renderManager.render(!0)}},{key:"enablePan",get:function(){return this._enablePan},set:function(e){this._enablePan=e}},{key:"enableRotate",get:function(){return this._enableRotate},set:function(e){this._enableRotate=e}},{key:"enableZoom",get:function(){return this._enableZoom},set:function(e){this._enableZoom=e}},{key:"maxPolarAngle",get:function(){return this._maxPolarAngle/(Math.PI/180)},set:function(e){this._maxPolarAngle=Math.PI/180*e}},{key:"minPolarAngle",get:function(){return this._minPolarAngle/(Math.PI/180)},set:function(e){this._minPolarAngle=Math.PI/180*e}},{key:"maxAzimuthAngle",get:function(){return this._maxAzimuthAngle/(Math.PI/180)},set:function(e){this._maxAzimuthAngle=Math.PI/180*e}},{key:"minAzimuthAngle",get:function(){return this._minAzimuthAngle/(Math.PI/180)},set:function(e){this._minAzimuthAngle=Math.PI/180*e}},{key:"flyTo",value:function(e){var t,n,i=this,r=[ud.Easing.Linear.None,ud.Easing.Quadratic.InOut,ud.Easing.Quadratic.Out,ud.Easing.Cubic.InOut,ud.Easing.Cubic.Out,ud.Easing.Sinusoidal.InOut,ud.Easing.Sinusoidal.Out,ud.Easing.Exponential.InOut,ud.Easing.Exponential.Out,ud.Easing.Circular.InOut,ud.Easing.Circular.Out,ud.Easing.Elastic.InOut,ud.Easing.Elastic.Out,ud.Easing.Back.InOut,ud.Easing.Back.Out,ud.Easing.Bounce.InOut,ud.Easing.Bounce.Out],a=e&&e.type?r[e.type]:r[10];if(void 0!==(e=e||{}).position&&(t=Array.isArray(e.position)?(new at).fromArray(e.position):(new at).copy(e.position)),void 0!==e.target&&(n=Array.isArray(e.target)?(new at).fromArray(e.target):(new at).copy(e.target)),e.object&&(e.object.isObject3D||e.object.isMesh)&&(n=e.object.parent.localToWorld(e.object.position.clone()),t=this._fitCamera(e.object).add(n),e.yAngle&&(t.x=0,t.applyAxisAngle(new at(0,1,0),Math.PI/180*e.yAngle).add(n)),e.xAngle)){var o=this._fitCamera(e.object).add(n);o.applyAxisAngle(new at(1,0,0),Math.PI/180*e.xAngle*-1),t.copy(o),e.yAngle&&(t.x=0,t.applyAxisAngle(new at(0,1,0),Math.PI/180*e.yAngle).add(n))}if(t){if(this.viewer.firstPersonControls.enabled&&this.object.isCamera){var s=this.object.getWorldPosition(),l=this.object.getWorldDirection();this.target=s.clone().addScaledVector(l,10)}n&&n.distanceTo(this.target)>0&&new ud.Tween(this.target).easing(a).to(n,e.time+100||600).onUpdate((function(){i.object.lookAt(i.target)})).start(),new ud.Tween(this.object.position).easing(a).to(t,e.time||500).onUpdate((function(){i._dispatchEvent(vp)})).onComplete((function(){e.complete&&e.complete()})).start()}}},{key:"fit",value:function(e){if(e.isMesh||e.isObject3D){this.viewer.renderManager.render(!0);var t=e.parent.localToWorld(e.position.clone()),n=this._fitCamera(e).add(t);this.object.position.copy(n),this.target.copy(t),this._dispatchEvent(vp)}}},{key:"setPosition",value:function(e,t,n){this.object.position.set(e,t,n),this._dispatchEvent(vp)}},{key:"setTarget",value:function(e,t,n){this.target.set(e,t,n),this._dispatchEvent(vp)}},{key:"moveForward",value:function(e){var t=new at;this.object.getWorldDirection(t),this.object.position.add(t.multiplyScalar(e)),this._dispatchEvent(vp)}},{key:"moveBackward",value:function(e){var t=new at;this.object.getWorldDirection(t),this.object.position.add(t.multiplyScalar(-e)),this._dispatchEvent(vp)}},{key:"moveLeft",value:function(e){this.panLeft(e)}},{key:"moveRight",value:function(e){this.panRight(e)}},{key:"moveUp",value:function(e){this.panUp(e)}},{key:"moveDown",value:function(e){this.panDown(e)}},{key:"rotateLeft",value:function(e){e=Math.PI/180*e,this._rotateLeft(e)}},{key:"rotateUp",value:function(e){e=Math.PI/180*e,this._rotateUp(e)}},{key:"zoomIn",value:function(){this.zoom(-1)}},{key:"zoomOut",value:function(){this.zoom(1)}},{key:"rotateAround",value:function(e){var t,n=this,i=e.target,r=e.object;r&&(r.isMesh||r.isObject3D)?t=r.parent.localToWorld(r.position.clone()):i&&void 0!==i.x&&void 0!==i.y&&void 0!==i.z&&(t=(new at).copy(i)),this.stopRotateAround();var a=function(){if(e.yAngle){var t=0,i={angle:0};n._rotateTween=new ud.Tween(i).to({angle:e.yAngle},e.time).onUpdate((function(){n.rotateLeft(i.angle-t),t=i.angle})).start().repeat(e.loop||1)}if(e.xAngle){var r=0,a={angle:0};n._rotateTween=new ud.Tween(a).to({angle:e.xAngle},e.time).onUpdate((function(){n.rotateUp(a.angle-r),r=a.angle})).start().repeat(e.loop||1)}};t.distanceTo(this.target)>0?new ud.Tween(this.target).to(t,500).onUpdate((function(){n.object.lookAt(n.target),n._dispatchEvent(vp)})).onComplete((function(){a()})).start():a()}},{key:"stopRotateAround",value:function(){this._rotateTween&&this._rotateTween.stop()}},{key:"movePath",value:function(e){var t,n=[];e.path.forEach((function(e){n.push((new at).copy(e))}));var i=new cA(n);i.curveType="catmullrom",i.tension=0,i.getPoints(50);var r,a={t:0},o=new at,s=new ud.Tween(a).to({t:1},e.time).onUpdate((function(){var t=new at;i.getPoint(a.t,t),o.copy(t),r&&i.getPoint(a.t+.01,o),r=a.t,e.object.lookAt(o.clone()),e.object.position.copy(t.clone())})).onComplete((function(){t.stopCameraFloor()})).repeat(e.loop||1).start();return t=new mp(e.object,this.object,s,this)}},{key:"_fitCamera",value:function(e){var t=new tn;t.makeEmpty(),t.expandByObject(e);var n=1.5;this.viewer.containerRect.width0&&void 0!==arguments[0]?arguments[0]:2;this.autoRotateSpeed=e,this.autoRotate=!0}},{key:"stopAutoRotate",value:function(){this.autoRotate=!1}},{key:"follow",value:function(e,t){var n=this;e||console.error("缺少参数object"),this.followTask=function(){var i=n._fitCamera(e),r=new at(0,0,0);t&&(i.add(t),r.add(t)),n.setPosition(e.position.x+i.x,e.position.y+i.y,e.position.z+i.z),n.setTarget(e.position.x+r.x,e.position.y+r.y,e.position.z+r.z)}.bind(this),this.viewer.addEventListener("update",this.followTask)}},{key:"stopFollow",value:function(){this.viewer.removeEventListener("update",this.followTask)}}]),n}(fp);yp.VIEW_CHANGE="view_change";var wp="#DDDDDD",xp="#F2F5CE",bp="#FFFFFF",Mp=256,Cp=[],Bp=[],Ep=[],Sp=[],Tp=[],_p=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,o=arguments.length>3?arguments[3]:void 0;s(this,n),A(),(i=t.call(this)).cubeSize=r,i.edgeSize=a,i._cube=new Ip({size:i.cubeSize,edge:i.edgeSize,outline:!0,bgColor:wp,hoverColor:xp,outlineColor:bp}),i._animation=null,i._handleMouseMove=i._handleMouseMove.bind(v(i)),i._handleMouseClick=i._handleMouseClick.bind(v(i)),i._controls=o,i._renderer=new $a({antialias:!0,alpha:!0}),i._renderer.setPixelRatio(window.devicePixelRatio),i._renderer.setSize(150,150),i._renderer.setClearAlpha(0),i._renderer.domElement.style.position="absolute",i._renderer.domElement.style.right="0px",i._renderer.domElement.style.top="0px",e.appendChild(i._renderer.domElement),i.domElement=i._renderer.domElement,i._listen(),i._scene=new Qt,i._scene.add(i._cube),i._camera=new Ni(50,1,.1,1e3);var l=new UA(16777215,1);function A(){Bp=[{name:Up.FRONT,map:Pp("前",{fontSize:Mp,font:"Arial Narrow, sans-serif"})},{name:Up.RIGHT,map:Pp("右",{fontSize:Mp,font:"Arial Narrow, sans-serif"})},{name:Up.BACK,map:Pp("后",{fontSize:Mp,font:"Arial Narrow, sans-serif"})},{name:Up.LEFT,map:Pp("左",{fontSize:Mp,font:"Arial Narrow, sans-serif"})},{name:Up.TOP,map:Pp("上",{fontSize:Mp,font:"Arial Narrow, sans-serif"})},{name:Up.BOTTOM,map:Pp("下",{fontSize:Mp,font:"Arial Narrow, sans-serif"})}],Ep=[{name:Up.TOP_FRONT_RIGHT_CORNER},{name:Up.TOP_BACK_RIGHT_CORNER},{name:Up.TOP_BACK_LEFT_CORNER},{name:Up.TOP_FRONT_LEFT_CORNER},{name:Up.BOTTOM_BACK_RIGHT_CORNER},{name:Up.BOTTOM_FRONT_RIGHT_CORNER},{name:Up.BOTTOM_FRONT_LEFT_CORNER},{name:Up.BOTTOM_BACK_LEFT_CORNER}],Sp=[{name:Up.TOP_FRONT_EDGE},{name:Up.TOP_RIGHT_EDGE},{name:Up.TOP_BACK_EDGE},{name:Up.TOP_LEFT_EDGE},{name:Up.BOTTOM_BACK_EDGE},{name:Up.BOTTOM_RIGHT_EDGE},{name:Up.BOTTOM_FRONT_EDGE},{name:Up.BOTTOM_LEFT_EDGE}],Tp=[{name:Up.FRONT_RIGHT_EDGE},{name:Up.BACK_RIGHT_EDGE},{name:Up.BACK_LEFT_EDGE},{name:Up.FRONT_LEFT_EDGE}],Cp=[].concat(C(Bp),C(Ep),C(Sp),C(Tp))}return i._scene.add(l),i._camera.position.set(0,0,70),i._camera.lookAt(0,0,0),i}return A(n,[{key:"_listen",value:function(){var e=this;this.domElement.addEventListener("mousemove",this._handleMouseMove),this.domElement.addEventListener("click",this._handleMouseClick),this._controls.addEventListener(ld.CHANGE,(function(){var t=-1*(e._controls.spherical.phi-Math.PI/2),n=-e._controls.spherical.theta;e._cube.rotation.set(t,n,0)}))}},{key:"_handleMouseClick",value:function(e){var t=e.offsetX/e.target.clientWidth*2-1,n=-e.offsetY/e.target.clientHeight*2+1;this._checkSideTouch(t,n)}},{key:"_checkSideTouch",value:function(e,t){var n=this,i=new Nc;i.setFromCamera({x:e,y:t},this._camera);var r=[];this._cube.children.forEach((function(e){e!=n._cube.model&&r.push(e)}));var a=i.intersectObjects(r,!0);if(a.length){var o,s=S(a);try{for(s.s();!(o=s.n()).done;){var l=o.value.object;if(l.name){this._rotateTheCube(l.name),this._rotateTheCamera(l.name);break}}}catch(e){s.e(e)}finally{s.f()}}}},{key:"_rotateTheCamera",value:function(e){var t=new at;switch(e){case Up.FRONT:t.set(0,0,1);break;case Up.BACK:t.set(0,0,-1);break;case Up.LEFT:t.set(-1,0,0);break;case Up.RIGHT:t.set(1,0,0);break;case Up.TOP:t.set(0,1,0);break;case Up.BOTTOM:t.set(0,-1,0);break;case Up.TOP_FRONT_EDGE:t.set(0,1,1);break;case Up.TOP_BACK_EDGE:t.set(0,1,-1);break;case Up.TOP_RIGHT_EDGE:t.set(1,1,0);break;case Up.TOP_LEFT_EDGE:t.set(-1,1,0);break;case Up.BOTTOM_FRONT_EDGE:t.set(0,-1,1);break;case Up.BOTTOM_BACK_EDGE:t.set(0,-1,-1);break;case Up.BOTTOM_RIGHT_EDGE:t.set(1,-1,0);break;case Up.BOTTOM_LEFT_EDGE:t.set(-1,-1,0);break;case Up.FRONT_RIGHT_EDGE:t.set(1,0,1);break;case Up.FRONT_LEFT_EDGE:t.set(-1,0,1);break;case Up.BACK_RIGHT_EDGE:t.set(1,0,-1);break;case Up.BACK_LEFT_EDGE:t.set(-1,0,-1);break;case Up.TOP_FRONT_RIGHT_CORNER:t.set(1,1,1);break;case Up.TOP_FRONT_LEFT_CORNER:t.set(-1,1,1);break;case Up.TOP_BACK_RIGHT_CORNER:t.set(1,1,-1);break;case Up.TOP_BACK_LEFT_CORNER:t.set(-1,1,-1);break;case Up.BOTTOM_FRONT_RIGHT_CORNER:t.set(1,-1,1);break;case Up.BOTTOM_FRONT_LEFT_CORNER:t.set(-1,-1,1);break;case Up.BOTTOM_BACK_RIGHT_CORNER:t.set(1,-1,-1);break;case Up.BOTTOM_BACK_LEFT_CORNER:t.set(-1,-1,-1)}t.clone();var n=this._controls.target.distanceTo(this._controls.object.position),i=t.normalize().multiplyScalar(n).add(this._controls.target);this._controls.camera.rotation.set(0,0,0),this._controls.flyTo({position:i,rotation:new at})}},{key:"_rotateTheCube",value:function(e){switch(e){case Up.FRONT:this._setCubeAngles(0,0,0);break;case Up.RIGHT:this._setCubeAngles(0,-90,0);break;case Up.BACK:this._setCubeAngles(0,-180,0);break;case Up.LEFT:this._setCubeAngles(0,-270,0);break;case Up.TOP:this._setCubeAngles(90,0,0);break;case Up.BOTTOM:this._setCubeAngles(-90,0,0);break;case Up.TOP_FRONT_EDGE:this._setCubeAngles(45,0,0);break;case Up.TOP_RIGHT_EDGE:this._setCubeAngles(45,-90,0);break;case Up.TOP_BACK_EDGE:this._setCubeAngles(45,-180,0);break;case Up.TOP_LEFT_EDGE:this._setCubeAngles(45,-270,0);break;case Up.BOTTOM_FRONT_EDGE:this._setCubeAngles(-45,0,0);break;case Up.BOTTOM_RIGHT_EDGE:this._setCubeAngles(-45,-90,0);break;case Up.BOTTOM_BACK_EDGE:this._setCubeAngles(-45,-180,0);break;case Up.BOTTOM_LEFT_EDGE:this._setCubeAngles(-45,-270,0);break;case Up.FRONT_RIGHT_EDGE:this._setCubeAngles(0,-45,0);break;case Up.BACK_RIGHT_EDGE:this._setCubeAngles(0,-135,0);break;case Up.BACK_LEFT_EDGE:this._setCubeAngles(0,-225,0);break;case Up.FRONT_LEFT_EDGE:this._setCubeAngles(0,-315,0);break;case Up.TOP_FRONT_RIGHT_CORNER:this._setCubeAngles(45,-45,0);break;case Up.TOP_BACK_RIGHT_CORNER:this._setCubeAngles(45,-135,0);break;case Up.TOP_BACK_LEFT_CORNER:this._setCubeAngles(45,-225,0);break;case Up.TOP_FRONT_LEFT_CORNER:this._setCubeAngles(45,-315,0);break;case Up.BOTTOM_FRONT_RIGHT_CORNER:this._setCubeAngles(-45,-45,0);break;case Up.BOTTOM_BACK_RIGHT_CORNER:this._setCubeAngles(-45,-135,0);break;case Up.BOTTOM_BACK_LEFT_CORNER:this._setCubeAngles(-45,-225,0);break;case Up.BOTTOM_FRONT_LEFT_CORNER:this._setCubeAngles(-45,-315,0)}}},{key:"_setCubeAngles",value:function(e,t,n){var i=this._cube.rotation;this._animation={base:{x:i.x,y:i.y,z:i.z},delta:{x:kp(i.x,e*Lp),y:kp(i.y,t*Lp),z:kp(i.z,n*Lp)},duration:500,time:Date.now()}}},{key:"_handleMouseMove",value:function(e){var t=e.offsetX/e.target.clientWidth*2-1,n=-e.offsetY/e.target.clientHeight*2+1;this._checkSideOver(t,n)}},{key:"_checkSideOver",value:function(e,t){var n=this,i=new Nc;i.setFromCamera({x:e,y:t},this._camera);var r=[],a=this._cube.model;this._cube.children.forEach((function(e){e!=n._cube.model&&r.push(e)}));var o=i.intersectObjects(r,!0);if(this._cube.children.forEach((function(e){e!=a&&e.traverse((function(e){e.name&&e.material.color.setStyle(e.material.color0)}))})),o.length){var s,l=S(o);try{var A=function(){var e=s.value.object;if(e.name){Cp.find((function(t){return t.name===e.name}));return e.parent.children.forEach((function(t){t!=a&&t.name===e.name&&(t.material.color0||(t.material.color0="#"+t.material.color.getHexString()),t.material.color.setStyle(xp))})),"break"}};for(l.s();!(s=l.n()).done;){if("break"===A())break}}catch(e){l.e(e)}finally{l.f()}}}},{key:"update",value:function(){this._animate(),this._renderer.render(this._scene,this._camera)}},{key:"_animate",value:function(){if(this._animation){var e=Date.now(),t=this._animation,n=t.duration,i=t.time,r=Math.min((e-i)/n,1);this._animateCubeRotation(this._animation,r),1==r&&(this._animation=null),this.dispatchEvent({type:"angle-change",quaternion:this._cube.quaternion.clone()})}}},{key:"_animateCubeRotation",value:function(e,t){var n=e.base,i=e.delta,r=.5*(Math.sin((2*t-1)*Math.PI*.5)+1),a=-Fp+n.x+i.x*r,o=-Fp+n.y+i.y*r,s=-Fp+n.z+i.z*r;this._cube.rotation.set(a%Fp,o%Fp,s%Fp)}},{key:"setQuaternion",value:function(e){this._cube.setRotationFromQuaternion(e)}},{key:"getObject",value:function(){return this._cube}}]),n}(Je),Ip=function(e){h(n,e);var t=y(n);function n(e){var i,r=e.size,a=void 0===r?60:r,o=e.edge,l=void 0===o?5:o,A=e.outline,c=void 0===A||A,h=e.bgColor,u=void 0===h?"#CCCCCC":h,d=e.hoverColor,f=void 0===d?"#FFFFFF":d,p=e.outlineColor,m=void 0===p?"#999999":p,v=e.cornerColor,g=void 0===v?"#ffffff":v;return s(this,n),(i=t.call(this))._cubeSize=a,i._edgeSize=l,i._outline=c,i._bgColor=u,i._hoverColor=f,i._outlineColor=m,i._cornerColor=g,i._build(),i}return A(n,[{key:"_build",value:function(){var e,t=this._cubeSize-2*this._edgeSize,n=this._cubeSize/2,i=this._edgeSize,r=this._createCubeFaces(t,n),a=S(Bp.entries());try{for(a.s();!(e=a.n()).done;){var o=M(e.value,2),s=o[0],l=o[1];r.children[s].name=l.name,r.children[s].material.color.setStyle(this._bgColor),r.children[s].material.map=l.map}}catch(e){a.e(e)}finally{a.f()}this.add(r);var A,c=[],h=S(Ep.entries());try{for(h.s();!(A=h.n()).done;){var u=M(A.value,2),d=u[0],f=u[1],p=this._createCornerFaces(i,n,f.name,{color:this._bgColor});p.rotateOnAxis(new at(0,1,0),d%4*90*Lp),c.push(p)}}catch(e){h.e(e)}finally{h.f()}var m=new ja,v=new ja;this.add(m.add.apply(m,C(c.slice(0,4)))),this.add(v.add.apply(v,C(c.slice(4))).rotateOnAxis(new at(1,0,0),180*Lp));var g,y=[],w=S(Sp.entries());try{for(w.s();!(g=w.n()).done;){var x=M(g.value,2),b=x[0],B=x[1],E=this._createHorzEdgeFaces(t,i,n,B.name,{color:this._bgColor});E.rotateOnAxis(new at(0,1,0),b%4*90*Lp),y.push(E)}}catch(e){w.e(e)}finally{w.f()}var T=new ja,_=new ja;this.add(T.add.apply(T,C(y.slice(0,4)))),this.add(_.add.apply(_,C(y.slice(4))).rotateOnAxis(new at(1,0,0),180*Lp));var I,L=new ja,F=S(Tp.entries());try{for(F.s();!(I=F.n()).done;){var k=M(I.value,2),P=k[0],U=k[1],D=this._createVertEdgeFaces(i,t,n,U.name,{color:this._bgColor});D.rotateOnAxis(new at(0,1,0),90*P*Lp),L.add(D)}}catch(e){F.e(e)}finally{F.f()}this.add(L),this._outline&&this.add(this._createCubeOutline(this._cubeSize))}},{key:"addModel",value:function(e){if(this.removeModel(),this.traverse((function(e){"Mesh"==e.type?(e.material.transparent=!0,e.material.opacity=.01):"LineSegments"==e.type&&(e.material.transparent=!0,e.material.opacity=.1)})),e){e.scale1=e.scale.clone(),e.position1=e.position.clone();var t=this._cubeSize/(2*e.boundingSphere.radius);e.scale.set(t,t,t);var n=e.boundingSphere.center.clone().negate().multiplyScalar(t);e.position.copy(n),this.add(e),this.model=e}}},{key:"removeModel",value:function(){this.model&&(model.scale.copy(model.scale1),model.position.copy(model.position1),model.scale1=null,model.position1=null,this.remove(this.model),this.model=null),this.traverse((function(e){("Mesh"==e.type||"LineSegments"==e.type)&&(e.material.transparent=!1,e.material.opacity=1)}))}},{key:"_createFace",value:function(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.axis,a=void 0===r?[0,1,0]:r,o=i.angle,s=void 0===o?0:o,l=i.name,A=void 0===l?"":l,c=i.matProps,h=void 0===c?{}:c;Array.isArray(e)||(e=[e,e]);var u=new Nn(h),d=new qi(e[0],e[1]),f=new Ei(d,u);return f.name=A,f.rotateOnAxis(p(at,C(a)),s*Lp),(n=f.position).set.apply(n,C(t)),f}},{key:"_createCubeFaces",value:function(e,t){var n=new zt;return n.add(this._createFace(e,[0,0,t],{axis:[0,1,0],angle:0})),n.add(this._createFace(e,[t,0,0],{axis:[0,1,0],angle:90})),n.add(this._createFace(e,[0,0,-t],{axis:[0,1,0],angle:180})),n.add(this._createFace(e,[-t,0,0],{axis:[0,1,0],angle:270})),n.add(this._createFace(e,[0,t,0],{axis:[1,0,0],angle:-90})),n.add(this._createFace(e,[0,-t,0],{axis:[1,0,0],angle:90})),n}},{key:"_createCornerFaces",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=new zt,a=t-e/2;return r.add(this._createFace(e,[a,a,t],{axis:[0,1,0],angle:0,matProps:i,name:n})),r.add(this._createFace(e,[t,a,a],{axis:[0,1,0],angle:90,matProps:i,name:n})),r.add(this._createFace(e,[a,t,a],{axis:[1,0,0],angle:-90,matProps:i,name:n})),r}},{key:"_createHorzEdgeFaces",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=new zt,o=n-t/2;return a.add(this._createFace([e,t],[0,o,n],{axis:[0,1,0],angle:0,name:i,matProps:r})),a.add(this._createFace([e,t],[0,n,o],{axis:[1,0,0],angle:-90,name:i,matProps:r})),a}},{key:"_createVertEdgeFaces",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=new zt,o=n-e/2;return a.add(this._createFace([e,t],[o,0,n],{axis:[0,1,0],angle:0,name:i,matProps:r})),a.add(this._createFace([e,t],[n,0,o],{axis:[0,1,0],angle:90,name:i,matProps:r})),a}},{key:"_createCubeOutline",value:function(e){return new jo(new ll(new Fi(e,e,e)),new Do({color:this._outlineColor,linewidth:1}))}},{key:"_createCubeOutline2",value:function(e){return new jo(new ll(new Fi(e.x,e.y,e.z)),new Do({color:this._outlineColor,linewidth:1}))}}]),n}(zt),Lp=Math.PI/180,Fp=2*Math.PI;function kp(e,t){var n=t-e,i=n-Fp,r=n+Fp;return Math.abs(n)>Math.abs(i)?i:Math.abs(n)>Math.abs(r)?r:n}function Pp(e,t){var n=t.font||"Helvetica",i=t.fontSize||30,r=t.width||512,a=t.height||512,o=t.color?t.bgColor.join(", "):"255, 255, 255, 1.0",s=t.color?t.color.join(", "):"0, 0, 0, 1.0",l=document.createElement("canvas");l.width=r,l.height=a;var A=l.getContext("2d");A.font="bold ".concat(i,"px ").concat(n),A.fillStyle="rgba(".concat(o,")"),A.fillRect(0,0,r,a);var c=A.measureText(e).width;A.fillStyle="rgba(".concat(s,")"),A.fillText(e,r/2-c/2,a/2+i/2-2);var h=new ts(l);return h.minFilter=1008,h.needsUpdate=!0,h.anisotropy=2,h}var Up={TOP:1,FRONT:2,RIGHT:3,BACK:4,LEFT:5,BOTTOM:6,TOP_FRONT_EDGE:7,TOP_RIGHT_EDGE:8,TOP_BACK_EDGE:9,TOP_LEFT_EDGE:10,FRONT_RIGHT_EDGE:11,BACK_RIGHT_EDGE:12,BACK_LEFT_EDGE:13,FRONT_LEFT_EDGE:14,BOTTOM_FRONT_EDGE:15,BOTTOM_RIGHT_EDGE:16,BOTTOM_BACK_EDGE:17,BOTTOM_LEFT_EDGE:18,TOP_FRONT_RIGHT_CORNER:19,TOP_BACK_RIGHT_CORNER:20,TOP_BACK_LEFT_CORNER:21,TOP_FRONT_LEFT_CORNER:22,BOTTOM_FRONT_RIGHT_CORNER:23,BOTTOM_BACK_RIGHT_CORNER:24,BOTTOM_BACK_LEFT_CORNER:25,BOTTOM_FRONT_LEFT_CORNER:26},Dp=function(){function e(t){s(this,e),this.viewer=t}return A(e,[{key:"init",value:function(){}},{key:"update",value:function(e){}},{key:"destory",value:function(){}}]),e}(),Rp=function(){function e(t,n){s(this,e),this.isHotSpotEntity=!0,this.options=n,this.name=t,this.init(),this.load()}return A(e,[{key:"init",value:function(){this.object=null,this.material=null,this.name=this.name,this.position=new at(0,0,0),this.options.pos&&3===this.options.pos.length?this.localPosition=new at(this.options.pos[0],this.options.pos[1],this.options.pos[2]):this.localPosition=new at(0,0,0),this.scale=new at(1,1,1),this.color=new ut(1,1,1),this.width=0,this.height=0,this.hoverColor=null}},{key:"load",value:function(){this.object=new zt}},{key:"setColor",value:function(e,t,n){this.color.x=e,this.color.y=t,this.color.z=n,this.material&&(this.material.needsUpdate=!0)}},{key:"setAlpha",value:function(e){this.color.w=e,this.material&&(this.material.needsUpdate=!0)}},{key:"onEnterHover",value:function(){this.hoverColor&&this.material&&(this.material.uniforms.color.value=this.hoverColor,this.material.needsUpdate=!0)}},{key:"onExitHover",value:function(){this.hoverColor&&this.material&&(this.material.uniforms.color.value=this.color,this.material.needsUpdate=!0)}},{key:"dispose",value:function(){this.material&&this.material.dispose(),this.material=null,this.object&&this.object.parent&&this.object.parent.remove(this.object),this.object=null}}]),e}(),Op=function(e){h(n,e);var t=y(n);function n(e,i){return s(this,n),t.call(this,e,i)}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.width=this.options.scale[0],this.height=this.options.scale[1],this.url=this.options.url,this.options.color&&4===this.options.color.length&&(this.color=new ut(this.options.color[0],this.options.color[1],this.options.color[2],this.options.color[3])),this.options.hoverColor&&4===this.options.hoverColor.length&&(this.hoverColor=new ut(this.options.hoverColor[0],this.options.hoverColor[1],this.options.hoverColor[2],this.options.hoverColor[3]))}},{key:"load",value:function(){this.createMesh(this.width,this.height,this.url)}},{key:"createMesh",value:function(e,t,n){var i=(new tA).load(n),r=e/2,a=t/2,o=[-r,-a,0,-r,a,0,r,a,0,r,-a,0],s=new si;s.setAttribute("position",new Yn(o,3)),s.setAttribute("uv",new Yn([0,0,0,1,1,1,1,0],2)),s.setIndex([0,1,2,2,3,0]);var l={};l.mainTex={value:i},l.color={value:this.color},this.material=new Ri({uniforms:l,vertexShader:this.getVertShader(),fragmentShader:this.getFragmentShader(),transparent:!0,depthWrite:!1,side:2}),s.addGroup(0,6,0),this.object=new Ei(s,[this.material]),this.object.isHotSpotEntity=!0,this.object.position.set(this.localPosition.x,this.localPosition.y,this.localPosition.z)}},{key:"getVertShader",value:function(){return"\n varying vec2 vUv;\n void main()\n {\n vUv = uv;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n }\n "}},{key:"getFragmentShader",value:function(){return"\n uniform sampler2D mainTex;\n uniform vec4 color;\n varying vec2 vUv;\n void main()\n {\n vec4 texColor = texture2D(mainTex,vUv.xy);\n vec4 col = texColor * color;\n gl_FragColor = col;\n }\n "}},{key:"dispose",value:function(){this.material&&(this.material.uniforms.mainTex&&this.material.uniforms.mainTex.value.dispose(),this.material.dispose()),this.material=null,this.object&&this.object.parent&&this.object.parent.remove(this.object),this.object=null}}]),n}(Rp),Np=function(e){h(n,e);var t=y(n);function n(e,i){return s(this,n),t.call(this,e,i)}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.backMaterial=null,this.options.backColor&&4===this.options.backColor.length?this.backColor=new ut(this.options.backColor[0],this.options.backColor[1],this.options.backColor[2],this.options.backColor[3]):this.backColor=new ut(1,1,1,1),this.options.backHoverColor&&4===this.options.backHoverColor.length&&(this.backHoverColor=new ut(this.options.backHoverColor[0],this.options.backHoverColor[1],this.options.backHoverColor[2],this.options.backHoverColor[3]))}},{key:"load",value:function(){b(u(n.prototype),"load",this).call(this);var e={};e.mainTex={value:this.material.uniforms.mainTex.value},e.color={value:this.backColor},this.backMaterial=new Ri({uniforms:e,vertexShader:this.getVertShader(),fragmentShader:this.getFragmentShader(),transparent:!0,depthWrite:!1,side:2,depthFunc:6}),this.object.geometry.addGroup(0,6,1),this.object.material.push(this.backMaterial)}},{key:"onEnterHover",value:function(){b(u(n.prototype),"onEnterHover",this).call(this),this.backHoverColor&&this.backMaterial&&(this.backMaterial.uniforms.color.value=this.backHoverColor,this.backMaterial.needsUpdate=!0)}},{key:"onExitHover",value:function(){b(u(n.prototype),"onExitHover",this).call(this),this.backHoverColor&&this.backMaterial&&(this.backMaterial.uniforms.color.value=this.backColor,this.backMaterial.needsUpdate=!0)}},{key:"dispose",value:function(){this.material&&(this.material.uniforms.mainTex&&this.material.uniforms.mainTex.value.dispose(),this.material.dispose()),this.material=null,this.backMaterial&&this.backMaterial.dispose(),this.backMaterial=null,this.object&&this.object.parent&&this.object.parent.remove(this.object),this.object=null}}]),n}(Op),zp=new(function(){function e(){s(this,e),this.fontDic=new Map}return A(e,[{key:"getFont",value:function(e,t){var n=this,i=this.fontDic.get(e);i?t(i):(new qA).load(e,(function(i){return n.fontDic.set(e,i),t(i),i}))}}]),e}()),Qp=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this,e,i)).texObj=null,r}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.text="",this.font=null,this.length=0,this.options.size?this.fontSize=this.options.size:this.fontSize=1,this.options.color&&4===this.options.color.length&&(this.color=new ut(this.options.color[0],this.options.color[1],this.options.color[2],this.options.color[3])),this.options.hoverColor&&4===this.options.hoverColor.length&&(this.hoverColor=new ut(this.options.hoverColor[0],this.options.hoverColor[1],this.options.hoverColor[2],this.options.hoverColor[3]))}},{key:"load",value:function(){this.object=new zt,this.object.name=this.name,this.refresh()}},{key:"setText",value:function(e){this.text=e+"",this.refresh()}},{key:"setFont",value:function(e){var t=this;this.fontPath=e,zp.getFont(this.fontPath,(function(e){t.font=e,t.refresh()}))}},{key:"setFontSize",value:function(e){this.fontSize=e,this.refresh()}},{key:"refresh",value:function(){if(this.font){var e=new ol(this.font.generateShapes(this.text,this.fontSize),void 0,!0);e.computeBoundingBox(),this.refreshGeometry(e),this.length=e.boundingBox.max.x-e.boundingBox.min.x,this.texObj?this.texObj.geometry=e:this.createTextMesh(e);var t=-this.length/2-e.boundingBox.min.x,n=-this.fontSize/2;this.texObj.position.set(t,n,this.fontSize/100),this.width=e.boundingBox.max.x-e.boundingBox.min.x,this.height=e.boundingBox.max.y-e.boundingBox.min.y}else this.setFont("https://sdk-localresource.laozicloud.com/helvetiker_regular.typeface.json")}},{key:"createTextMesh",value:function(e){var t={};t.color={value:this.color},this.material=new Ri({uniforms:t,vertexShader:this.getVertShader(),fragmentShader:this.getFragmentShader(),side:2,transparent:!0}),this.texObj=new Ei(e,[this.material]),this.texObj.isHotSpotEntity=!0,this.object.add(this.texObj),this.object.position.set(this.localPosition.x,this.localPosition.y,this.localPosition.z)}},{key:"refreshGeometry",value:function(e){e.addGroup(0,e.index.count,0)}},{key:"getVertShader",value:function(){return"\n varying vec2 vUv;\n void main()\n {\n vUv = uv;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n }\n "}},{key:"getFragmentShader",value:function(){return"\n uniform vec4 color;\n void main()\n {\n gl_FragColor = color;\n //gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n }\n "}}]),n}(Rp),Gp=function(e){h(n,e);var t=y(n);function n(e,i){return s(this,n),t.call(this,e,i)}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.backMaterial=null,this.options.backColor&&4===this.options.backColor.length?this.backColor=new ut(this.options.backColor[0],this.options.backColor[1],this.options.backColor[2],this.options.backColor[3]):this.backColor=new ut(1,1,1,1),this.options.backHoverColor&&4===this.options.backHoverColor.length&&(this.backHoverColor=new ut(this.options.backHoverColor[0],this.options.backHoverColor[1],this.options.backHoverColor[2],this.options.backHoverColor[3]))}},{key:"createTextMesh",value:function(e){b(u(n.prototype),"createTextMesh",this).call(this,e);var t={};t.color={value:this.backColor},this.backMaterial=new Ri({uniforms:t,vertexShader:this.getVertShader(),fragmentShader:this.getFragmentShader(),transparent:!0,depthWrite:!1,side:2,depthFunc:6}),this.texObj.material.push(this.backMaterial)}},{key:"refreshGeometry",value:function(e){b(u(n.prototype),"refreshGeometry",this).call(this,e),e.addGroup(0,e.index.count,1)}},{key:"onEnterHover",value:function(){b(u(n.prototype),"onEnterHover",this).call(this),this.backHoverColor&&this.backMaterial&&(this.backMaterial.uniforms.color.value=this.backHoverColor,this.backMaterial.needsUpdate=!0)}},{key:"onExitHover",value:function(){b(u(n.prototype),"onExitHover",this).call(this),this.backHoverColor&&this.backMaterial&&(this.backMaterial.uniforms.color.value=this.backColor,this.backMaterial.needsUpdate=!0)}},{key:"dispose",value:function(){b(u(n.prototype),"dispose",this).call(this),this.backMaterial&&this.backMaterial.dispose(),this.backMaterial=null}}]),n}(Qp),Hp=new at,Vp=new bt,jp=new at,Wp=new at,Xp=function(e){h(n,e);var t=y(n);function n(){var e;return s(this,n),(e=t.call(this)).objects=[],e.click=null,e.viewMatrx=new bt,e.isAutoScale=!1,e.autoZ=0,e.ishover=!1,e.box=new tn(new at(0,0,0),new at(1,1,1)),e.hotRaycast=new Nc,e.depth=0,e.isBulletionBoard=!0,e.bindMesh=null,e.bindMeshIndex=0,e.bindOffsetPoint=null,e._tmpBindPosition=new at,e}return A(n,[{key:"getObjectByName",value:function(e){for(var t=0;t=jp.x&&t.x<=Wp.x&&t.y>=jp.y&&t.y<=Wp.y}}},{key:"onclick",value:function(){this.click&&this.click()}},{key:"onEnterHover",value:function(){this.ishover=!0;for(var e=0;e0?(m=!1,v=!0):(m=!0,v=!1),o.y<0?(p=!1,f=!0):(p=!0,f=!1),o.multiplyScalar(50),i.style.left=o.x+50+"px",i.style.top=o.y+50+"px")}))}():D&&(D.style.display="none")}}});var A=this,c={type:"change"},h=new Bt(0,0,0,"YXZ"),u=Math.PI/2,d=new at,f=!1,p=!1,m=!1,v=!1,g=!1,y=!1,w=performance.now(),x=new at,b=new at,M=new Nc;function C(){A.character.min.set(-1,-a/2,-1),A.character.max.set(1,a/2,1),A.character.translate(t.position)}function B(e){switch(e.keyCode){case 38:case 87:f=!0;break;case 37:case 65:m=!0;break;case 40:case 83:p=!0;break;case 39:case 68:v=!0;break;case 82:g=!0;break;case 70:y=!0;break;case 32:A.jump()}}function E(e){switch(e.keyCode){case 38:case 87:f=!1;break;case 37:case 65:m=!1;break;case 40:case 83:p=!1;break;case 39:case 68:v=!1;break;case 82:g=!1;break;case 70:y=!1}}function S(e){0===e.button&&document.addEventListener(ld.MOVE,_,!1)}function T(){document.removeEventListener(ld.MOVE,_,!1)}function _(e){if(!1!==A.enabled){var n=e.movementX||e.mozMovementX||e.webkitMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||0;l.set(n,i,0),0!=A.rotationAngle&&l.applyAxisAngle(new AMRT.Vector3(0,0,1),A.rotationAngle*Hh.DEG2RAD),h.setFromQuaternion(t.quaternion),h.y-=l.x*A.rotateSpeed,h.x-=l.y*A.rotateSpeed,h.x=Math.max(-u,Math.min(u,h.x)),t.quaternion.setFromEuler(h),A.dispatchEvent(c)}}C();var I=new tn,L=new at;function F(e,n){if(Math.abs(n)>0){var i=t.position.clone();i.addScaledVector(e,n),L.set(0,0,0),L.addScaledVector(e,n),I.copy(A.character),I.translate(L);var r=(new at).subVectors(i,t.position).normalize();return!(A.detectEnabled&&A.collider&&function(e,t){if(M.set(e.clone(),t),M.far=A.detectDistance,(Array.isArray(A.collider)?M.intersectObjects(A.collider,!0):M.intersectObject(A.collider,!0)).length>0)return!0}(i.clone(),r))&&(t.position.copy(i),A.useGravity&&I.intersectsPlane(A.floor)?(t.position.y=-A.floor.constant+A.height/2+.1,!1):(A.movingRegion&&(t.position.x=Math.max(Math.min(t.position.x,A.movingRegion.max.x),A.movingRegion.min.x),t.position.z=Math.max(Math.min(t.position.z,A.movingRegion.max.z),A.movingRegion.min.z)),C(),!0))}}function k(e){this.preX=e.targetTouches[0].clientX,this.preY=e.targetTouches[0].clientY,document.addEventListener("touchmove",U,!1)}function P(){document.removeEventListener("touchmove",U,!1)}function U(e){if(!1!==A.enabled){var n=e.targetTouches[0].clientX-this.preX||0,i=e.targetTouches[0].clientY-this.preY||0;l.set(n,i,0),0!=A.rotationAngle&&l.applyAxisAngle(new AMRT.Vector3(0,0,1),A.rotationAngle*Hh.DEG2RAD),h.setFromQuaternion(t.quaternion),h.y-=l.x*A.rotateSpeed,h.x-=l.y*A.rotateSpeed,h.x=Math.max(-u,Math.min(u,h.x)),t.quaternion.setFromEuler(h),A.dispatchEvent(c),this.preX=e.targetTouches[0].clientX,this.preY=e.targetTouches[0].clientY}}this.setCollider=function(e){var t=this;this.collider=e;var n=Array.isArray(this.collider)?this.collider:[this.collider];this.targets=[],n.forEach((function(e){e.traverse((function(e){e.isMesh&&t.targets.push(e)}))}))},this.setRegion=function(e){A.movingRegion.setFromArray(e)},this.setFloorHeight=function(e){A.floor.constant=-e},this.setView=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.position&&(Array.isArray(e.position)?t.position.fromArray(e.position):t.position.copy(e.position)),void 0!==e.rotation&&(Array.isArray(e.rotation)?t.rotation.fromArray(e.rotation):t.rotation.setFromVector3(e.rotation)),C()},this.getView=function(){return{position:t.position.toArray(),rotation:t.rotation.toArray()}},this.connect=function(){document.addEventListener(ld.START,S,!1),document.addEventListener(ld.END,T,!1),document.addEventListener("keydown",B,!1),document.addEventListener("keyup",E,!1),document.addEventListener("touchstart",k,!1),document.addEventListener("touchend",P,!1)},this.disconnect=function(){document.removeEventListener(ld.START,S,!1),document.removeEventListener(ld.END,T,!1),document.removeEventListener("keydown",B,!1),document.removeEventListener("keyup",E,!1),document.removeEventListener("touchstart",k,!1),document.removeEventListener("touchend",P,!1)},this.getDirection=function(){var e=new at(0,0,-1);return function(n){return n.copy(e).applyQuaternion(t.quaternion)}}(),this.moveForward=function(e){d.setFromMatrixColumn(t.matrix,0),d.crossVectors(t.up,d),F(d,e)},this.moveRight=function(e){d.setFromMatrixColumn(t.matrix,0),F(d,e)},this.moveUp=function(e){return d.copy(t.up),F(d,e)},this.jump=function(){x.y+=50};var D,R=function(){if(!0===A.enabled){var e=performance.now(),n=(e-w)/1e3;x.x-=10*x.x*n,x.z-=10*x.z*n,x.y-=10*x.y*n,b.z=Number(f)-Number(p),b.x=Number(v)-Number(m),b.y=Number(y)-Number(g),b.normalize(),(f||p)&&(x.z-=b.z*A.moveSpeed*n,this.moveForward(-x.z*n)),(m||v)&&(x.x-=b.x*A.moveSpeed*n,this.moveRight(-x.x*n)),this.useGravity?(x.y-=98*n,this.moveUp(x.y*n)||(x.y=0)):(g||y)&&(x.y-=b.y*A.moveSpeed*n,this.lockHeight||(t.position.y+=x.y*n,t.position.y0?(C=!1,B=!0):(C=!0,B=!1),o.y<0?(M=!1,b=!0):(M=!0,b=!1),o.multiplyScalar(50),i.style.left=o.x+50+"px",i.style.top=o.y+50+"px")}))}():Y&&(Y.style.display="none")}}});var v=this,g={type:"change"},y=new Bt(0,0,0,"YXZ"),w=Math.PI/2,x=new at,b=!1,M=!1,C=!1,B=!1,E=!1,S=!1,T=performance.now(),_=new at,I=new at,L=new Nc;function F(){v.character.min.set(-1,-d/2,-1),v.character.max.set(1,d/2,1),v.character.translate(s.position)}function k(e){switch(e.keyCode){case 38:case 87:b=!0;break;case 37:case 65:C=!0;break;case 40:case 83:M=!0;break;case 39:case 68:B=!0;break;case 82:E=!0;break;case 70:S=!0;break;case 32:v.jump()}}function P(e){switch(e.keyCode){case 38:case 87:b=!1;break;case 37:case 65:C=!1;break;case 40:case 83:M=!1;break;case 39:case 68:B=!1;break;case 82:E=!1;break;case 70:S=!1}}function U(e){0===e.button&&document.addEventListener(ld.MOVE,R,!1)}function D(){document.removeEventListener(ld.MOVE,R,!1)}function R(e){if(!1!==v.enabled){var n=e.movementX||e.mozMovementX||e.webkitMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||0;m.set(n,i,0),0!=v.rotationAngle&&m.applyAxisAngle(new AMRT.Vector3(0,0,1),v.rotationAngle*Hh.DEG2RAD),y.setFromQuaternion(t.quaternion),y.y+=m.x*v.rotateSpeed,y.x-=m.y*v.rotateSpeed,y.x=Math.max(-w,Math.min(w,y.x)),t.quaternion.setFromEuler(y);var r=t.getWorldDirection(new at),a=s.getWorldPosition(new at).clone().addScaledVector(r,-l);v.dispatchEvent(g),t.position.copy(a)}}function O(e){!1!==v.enabled&&(e.deltaY<0?(--l0&&(++l>c&&(l=c),N()))}function N(e){e||(e=t.getWorldDirection(new at).negate());var n=s.getWorldPosition(new at),i=n.clone().addScaledVector(e,l);t.position.copy(i),t.lookAt(n)}F(),new tn;var z,Q=new at,G=new at;function H(e,n,i){if(Math.abs(n)>0){i=i||e,s.recalculationBound();var r=s.boundingBox,a=s.position.clone(),o=a.clone().addScaledVector(i,n*l*1e4);a.addScaledVector(e,n),Q.set(0,0,0),Q.addScaledVector(e,n),r.copy(v.character),r.translate(Q);var A=(new at).subVectors(a,s.position).normalize();if(v.detectEnabled&&v.collider&&function(e,t){if(L.set(e.clone(),t),L.far=v.detectDistance,(Array.isArray(v.collider)?L.intersectObjects(v.collider,!0):L.intersectObject(v.collider,!0)).length>0)return!0}(a.clone(),A))return!1;var c=a.clone().sub(s.position);return s.position.copy(a),t.position.add(c),t.lookAt(a),v.useGravity&&r.intersectsPlane(v.floor)?(s.position.y=-v.floor.constant+v.height/2+.1,!1):(v.movingRegion&&(s.position.x=Math.max(Math.min(s.position.x,v.movingRegion.max.x),v.movingRegion.min.x),s.position.z=Math.max(Math.min(s.position.z,v.movingRegion.max.z),v.movingRegion.min.z)),s.lookAt(o),F(),!0)}}function V(e){this.preX=e.targetTouches[0].clientX,this.preY=e.targetTouches[0].clientY,document.addEventListener("touchmove",W,!1)}function j(){document.removeEventListener("touchmove",W,!1)}function W(e){if(!1!==v.enabled){var n=e.targetTouches[0].clientX-this.preX||0,i=e.targetTouches[0].clientY-this.preY||0;m.set(n,i,0),0!=v.rotationAngle&&m.applyAxisAngle(new AMRT.Vector3(0,0,1),v.rotationAngle*Hh.DEG2RAD),y.setFromQuaternion(t.quaternion),y.y-=m.x*v.rotateSpeed,y.x-=m.y*v.rotateSpeed,y.x=Math.max(-w,Math.min(w,y.x)),t.quaternion.setFromEuler(y);var r=t.getWorldDirection(new at),a=s.getWorldPosition(new at).clone().addScaledVector(r,-l);v.dispatchEvent(g),t.position.copy(a),this.preX=e.targetTouches[0].clientX,this.preY=e.targetTouches[0].clientY}}function X(e){if(s)if(e){if(e!=z)switch(e){case"run":s.animation.play(i);break;case"up":s.animation.play(a);break;case"down":s.animation.play(o);break;case"jump":s.animation.play(r);break;default:s.animation.stop()}}else s.animation.stop();z=e}this.setCollider=function(e){var t=this;this.collider=e;var n=Array.isArray(this.collider)?this.collider:[this.collider];this.targets=[],n.forEach((function(e){e.traverse((function(e){e.isMesh&&t.targets.push(e)}))}))},this.setRegion=function(e){v.movingRegion.setFromArray(e)},this.setFloorHeight=function(e){v.floor.constant=-e},this.setView=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==t.position&&(Array.isArray(t.position)?s.position.fromArray(t.position):s.position.copy(t.position)),void 0!==t.rotation&&(Array.isArray(t.rotation)?s.rotation.fromArray(t.rotation):s.rotation.setFromVector3(t.rotation)),void 0!==t.cameraDirection?(e=Array.isArray(t.cameraDirection)?(new at).fromArray(t.cameraDirection):(new at).copy(t.cameraDirection)).normalize().negate():((e=s.getWorldDirection(new at)).y-=.4,e.normalize().negate()),t.distance&&(l=t.distance),t.minDistance&&(A=t.minDistance),t.maxDistance&&(c=t.maxDistance),N(e),F()},this.getView=function(){return{position:s.position.toArray(),rotation:s.rotation.toArray(),cameraDirection:t.getWorldDirection(new at),distance:l,minDistance:A,maxDistance:c}},this.connect=function(){document.addEventListener(ld.START,U,!1),document.addEventListener(ld.END,D,!1),document.addEventListener("keydown",k,!1),document.addEventListener("keyup",P,!1),document.addEventListener("touchstart",V,!1),document.addEventListener("touchend",j,!1),document.addEventListener("wheel",O,!1)},this.disconnect=function(){document.removeEventListener(ld.START,U,!1),document.removeEventListener(ld.END,D,!1),document.removeEventListener("keydown",k,!1),document.removeEventListener("keyup",P,!1),document.removeEventListener("touchstart",V,!1),document.removeEventListener("touchend",j,!1),document.removeEventListener("wheel",O,!1)},this.getDirection=function(){var e=new at(0,0,-1);return function(n){return n.copy(e).applyQuaternion(t.quaternion)}}(),this.moveForward=function(e){x.setFromMatrixColumn(t.matrix,2),x.y=0,x.normalize().negate(),H(x,e)},this.moveRight=function(e){x.setFromMatrixColumn(t.matrix,0),x.y=0,x.normalize().negate(),H(x,-e)},this.moveUp=function(e){return x.set(0,1,0),G.setFromMatrixColumn(t.matrix,2),G.y=0,G.normalize().negate(),H(x,e,G)},this.jump=function(){_.y+=50};var Y,K=function(){if(!0===v.enabled){var e=performance.now(),t=(e-T)/1e3;_.x-=10*_.x*t,_.z-=10*_.z*t,_.y-=10*_.y*t,I.z=Number(b)-Number(M),I.x=Number(B)-Number(C),I.y=Number(S)-Number(E),I.normalize(),b||M||C||B?((b||M)&&(_.z-=I.z*v.moveSpeed*t,this.moveForward(-_.z*t)),(C||B)&&(_.x-=I.x*v.moveSpeed*t,this.moveRight(-_.x*t)),X("run")):this.useGravity||E||S?this.useGravity?(_.y-=98*t,this.moveUp(_.y*t)||(_.y=0),X("jump")):(E||S)&&(_.y-=I.y*v.moveSpeed*t,this.lockHeight||(this.moveUp(_.y*t),s.position.y0?X("up"):X("down"))):X("stop"),T=e}}.bind(this)}$p.prototype=Object.create(Je.prototype),$p.prototype.constructor=$p,em.prototype=Object.create(Je.prototype),em.prototype.constructor=em;var tm=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,n),(i=t.call(this)).containerRect=null,i.camera=null,i.renderManager=null,i.sceneManager=null,i.disposed=!1,i.composer=null,i.moduleManager=null,i.controls=null,i.onControlsChange=null,i._options=r,e.constructor===String&&(e=document.querySelector("#"+e)||document.querySelector("."+e)),i.container=e||document.body,!r.nv){if(cu.init(r),r.offline)return g(i);if(void 0!==r.offlinekey)cu.offlineValidation((function(e){if(!e)throw new Error("授权失败!请检查您的开发者凭证。")}));else{var a=cu.checkDevloper();a?cu.token=a:i.dispose()}}return Object.defineProperty(window,"__viewer",{writable:!0,value:v(i)}),i}return A(n,[{key:"renderer",get:function(){return this.renderManager.defaultRenderer}},{key:"render",get:function(){return this.renderManager.render.bind(this.renderManager)}},{key:"domElement",get:function(){return this.renderManager.domElement}},{key:"scene",get:function(){return this.sceneManager.scene}},{key:"root",get:function(){return this.sceneManager.root}},{key:"modelGroup",get:function(){return this.sceneManager.modelGroup}},{key:"setSkyBox",get:function(){return this.sceneManager.setSkyBox.bind(this.sceneManager)}},{key:"setBackground",get:function(){return this.sceneManager.setBackground.bind(this.sceneManager)}},{key:"clearBackground",get:function(){return this.sceneManager.clearBackground.bind(this.sceneManager)}},{key:"loadSceneData",get:function(){return this.sceneManager.loadSceneData.bind(this.sceneManager)}},{key:"saveSceneData",get:function(){return this.sceneManager.saveSceneData.bind(this.sceneManager)}},{key:"fitCamera",get:function(){return this.sceneManager.fitCamera.bind(this.sceneManager)}},{key:"add",get:function(){return this.modelManager.add.bind(this.modelManager)}},{key:"remove",get:function(){return this.modelManager.remove.bind(this.modelManager)}},{key:"loadModel",get:function(){return this.modelManager.loadModel.bind(this.modelManager)}},{key:"initialize",value:function(e){var t=this;this.containerRect=this.container.getBoundingClientRect(),this.camera=new Ni(50,this.containerRect.width/this.containerRect.height,1,5e3),this.camera.position.set(0,0,1),this.renderManager=fd.create(this,e),this.renderManager.setCamera(this.camera),this.moduleManager=new qp(this),this.moduleManager.init(),this.renderManager.moduleManager=this.moduleManager,this.sceneManager=lp.create(this),this.modelManager=$f.create(this),this.renderManager.scene=this.scene,this.renderManager.camera=this.camera,this.renderManager.defaultCamera=this.camera,this.sceneManager.camera=this.camera,this.composer=new od(this),e.isMap?(this.renderer.domElement.style.pointerEvents="none",this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.top=0,this.renderer.domElement.style.left=0,this.renderManager.setLoop(!1)):(this.renderManager.render(!0),this._initControls(),window.addEventListener("resize",(function(){t.resize()}),!1),this.container.addEventListener("resize",(function(){t.resize()}),!1)),this._proxyEvent()}},{key:"_initControls",value:function(){var e=this;this.controls=new yp(this),this.controls.screenSpacePanning=!0,this.controls.addEventListener(ld.CHANGE,(function(){e.sceneManager.lightFollow&&(e.sceneManager.directLight.position.copy(e.camera.position),e.sceneManager.updateShadowMaterial()),e.onControlsChange&&e.onControlsChange()})),this.controls.addEventListener(yp.VIEW_CHANGE,(function(t){e.controls.setViewMode(t.data)})),this.camera.defaultPos=this.camera.position.clone(),this.renderManager.addAfterRenderTask(this.controls.update.bind(this.controls)),this.firstPersonControls=new $p(this),this.threePersonControls=new em(this),this.viewCubeControls=new _p(this.container,30,5,this.controls),this.viewCubeControlsUpdate=this.viewCubeControls.update.bind(this.viewCubeControls),this.hideViewCube()}},{key:"_proxyEvent",value:function(){var e=this;this.renderManager.addEventListener(ld.UPDATE,(function(){e.controls.update(),e.dispatchEvent(ld.UPDATE)})),this.modelManager.addEventListener(ld.MODEL_UPDATE,(function(){e.dispatchEvent(ld.MODEL_UPDATE)}));var t=new tt,n=new tt;this.domElement.addEventListener("mousedown",(function(e){t.set(e.clientX,e.clientY)})),this.domElement.addEventListener("mouseup",(function(i){n.set(i.clientX,i.clientY),t.distanceTo(n)<5&&e.dispatchEvent(ld.CLICK,i)}))}},{key:"resize",value:function(){this.containerRect=this.container.getBoundingClientRect(),this.camera.aspect=this.containerRect.width/this.containerRect.height,this.camera.updateProjectionMatrix(),this.domElement.style.width=this.containerRect.width+"px",this.domElement.style.height=this.containerRect.height+"px",this.renderManager.resize()}},{key:"dispatchEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;b(u(n.prototype),"dispatchEvent",this).call(this,{type:e,data:t})}},{key:"getComponentInfo",value:function(e,t){e.traverseAncestors((function(n){n.isBIM&&n.getComponentInfo(e,t)}))}},{key:"showViewCube",value:function(){this.viewCubeControls.domElement.style.display="block",this.renderManager.addAfterRenderTask(this.viewCubeControlsUpdate)}},{key:"hideViewCube",value:function(){this.viewCubeControls.domElement.style.display="none",this.renderManager.removeAfterRenderTask(this.viewCubeControlsUpdate)}},{key:"setViewCube",value:function(e){this.viewCubeControls._cube.addModel(e)}},{key:"resetViewCube",value:function(){this.viewCubeControls._cube.removeModel()}},{key:"dispose",value:function(){this.sceneManager.dispose(),this.renderManager.dispose(),this.controls.dispose(),this.composer.dispose(),this.disposed=!0,this.container.innerHTML=""}}]),n}(Je);function nm(e,t,n,i){if(e instanceof Oi){console.warn("DragControls: Constructor now expects ( objects, camera, domElement )");var r=e;e=t,t=r}var a=new vn,o=new Nc;new tt;var s=new at,l=new at,A=new at,c=new bt,h=null,u=this;function d(){n.addEventListener("mousemove",p,!1),n.addEventListener("mousedown",m,!1),n.addEventListener("mouseup",v,!1),n.addEventListener("mouseleave",v,!1),n.addEventListener("touchmove",p,!1),n.addEventListener("touchstart",m,!1),n.addEventListener("touchend",v,!1)}function f(){n.removeEventListener("mousemove",p,!1),n.removeEventListener("mousedown",m,!1),n.removeEventListener("mouseup",v,!1),n.removeEventListener("mouseleave",v,!1),n.removeEventListener("touchmove",p,!1),n.removeEventListener("touchstart",m,!1),n.removeEventListener("touchend",v,!1)}function p(e){if(e.preventDefault(),g(e),h&&u.enabled)return o.ray.intersectPlane(a,l)&&h.position.copy(l.sub(s).applyMatrix4(c)),void u.dispatchEvent({type:"drag",object:h})}function m(e){e.preventDefault(),g(e),function(e,i){e.length>0&&(h=e[0].object,r=h,d=A.setFromMatrixPosition(r.matrixWorld),a.setFromNormalAndCoplanarPoint(t.getWorldDirection(a.normal),d),o.ray.intersectPlane(a,l)&&(c.getInverse(h.parent.matrixWorld),s.copy(l).sub(A.setFromMatrixPosition(h.matrixWorld))),n.style.cursor="move",u.dispatchEvent({type:"dragstart",object:h}));var r,d}(i.intersectModels(e))}function v(e){e.preventDefault(),u.dispatchEvent({type:"dragend",object:h}),h=null,n.style.cursor="auto"}function g(e){e=If.getTouchByEvent(e);var i=If.getDomMouse(e,n);o.setFromCamera(i,t)}d(),this.enabled=!0,this.activate=d,this.deactivate=f,this.dispose=function(){f()}}nm.prototype=Object.create(Je.prototype),nm.prototype.constructor=nm;var im,rm,am,om=new at,sm=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this)).viewer=e,i._enabled=!1,i._enableDrag=!1,i._startPoint=new tt,i._selected=null,i.selectedColor="#b2ac00",i.objects=[],i.dragControls=new nm(i.viewer.modelGroup,i.viewer.camera,i.viewer.domElement,i.viewer),i.dragControls.deactivate(),i.dragControls.enabled=!1,i.onChange=function(){},i._initEvents(),i}return A(n,[{key:"single",set:function(e){this._single=!!e}},{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e,this._initData()}},{key:"enableDrag",get:function(){return this._enableDrag},set:function(e){this._enableDrag=e,this.dragControls.enabled=e,this._enableDrag?this.dragControls.activate():this.dragControls.deactivate()}},{key:"_initEvents",value:function(){var e=this;this.viewer.domElement.addEventListener(ld.START,(function(t){t.constructor===MouseEvent&&0!==t.button||(t=If.getTouchByEvent(t),e._startPoint.set(t.clientX,t.clientY))})),this.viewer.domElement.addEventListener(ld.END,(function(t){if(t.constructor!==MouseEvent||0===t.button){t=If.getTouchByEvent(t);var n=e._startPoint.distanceTo(new tt(t.clientX,t.clientY));e.enabled&&!e._enableDrag&&n<5&&e.viewer.intersectModels(t,e._rayCasterHandler,e,e.viewer.scene)}})),this.dragControls.addEventListener("dragstart",(function(t){e.enableDrag&&(e.selected=t.object,e.viewer.controls.enabled=!1,e.selected&&om.copy(e.selected.position))})),this.dragControls.addEventListener("dragend",(function(t){e.enableDrag&&(e.viewer.controls.enabled=!0,e.selected&&!om.equals(e.selected.position)&&(e.onChange(),om.copy(e.selected.position)))})),this.viewer.addEventListener(ld.MODEL_UPDATE,(function(){e._enabled&&e._initData()}))}},{key:"_rayCasterHandler",value:function(e){e.length>0&&this.selected!=e[0].object?e[0].object.isHotSpotEntity||(this.selected=e[0].object,this.dispatchEvent(ld.CHANGE,this.selected)):0===e.length&&this.selected&&(this.selected=null,this.dispatchEvent(ld.CHANGE,this.selected))}},{key:"selected",get:function(){return this._selected},set:function(e){var t=this;if(this.selected&&(this.selected.material=this.selected.material0,this.selected.transparent&&(this.selected.material=this._cloneMate(this.selected.material),this.transparent(this.selected))),this._selected=e,!this._selected)return this.viewer.composer.enableOutline=!1,this.viewer.composer.outline.pass.edgeThickness=2,void(this.viewer.composer.outline.pass.edgeStrength=6.5);(this.viewer.composer.enableOutline||(this.viewer.composer.enableOutline=!0,this.viewer.composer.outline.pass.edgeThickness=1,this.viewer.composer.outline.pass.edgeStrength=4.5),this._selected.isMesh||this._selected.intanceObject)&&(this._selected.material=this._cloneMate(this._selected.material),(Array.isArray(this._selected.material)?this._selected.material:[this._selected.material]).forEach((function(e){e.isAMRTBasicMaterial&&e.color.setStyle(t.selectedColor)})),this._selected.transparent&&this.transparent(this._selected),this.viewer.composer.outline.pass.selectedObjects=[this._selected])}},{key:"unSelected",value:function(e){e.isMesh&&(e.material=e.material0)}},{key:"toggleDisplay",value:function(){this.objects.forEach((function(e){e.visible=!e.visible})),this.viewer.renderManager.render(),this.onChange()}},{key:"hide",value:function(){this.selected&&(this.selected&&(this.selected.visible=!1),this.onChange())}},{key:"showAlone",value:function(){this.selected&&(this.objects.forEach((function(e){e.visible=!1})),this.selected.visible=!0,this.onChange())}},{key:"showAll",value:function(){this.objects.forEach((function(e){e.visible=!0})),this.onChange()}},{key:"transparent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selected;if(e){e.transparent=!0;var t=Array.isArray(e.material)?e.material:[e.material];t.forEach((function(e){e.isAMRTBasicMaterial&&(e.opacity0=void 0!==e.opacity0?e.opacity0:e.opacity,e.transparent0=void 0!==e.transparent0?e.transparent0:e.transparent,e.opacity=.15,e.transparent=!0)}))}this.onChange()}},{key:"unTransparent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selected;e&&(Array.isArray(e.material)?e.material.forEach((function(e){e.isAMRTBasicMaterial&&(e.opacity=e.opacity0,e.transparent=e.transparent0)})):(e.material.opacity=void 0!==e.material.opacity0?e.material.opacity0:1,e.material.transparent=e.material.transparent0),e.transparent=!1),this.onChange()}},{key:"translucenceOthers",value:function(e){var t=this;this.objects.forEach((function(n){n!==e&&n.visible&&t.transparent(n)}))}},{key:"restore",value:function(){var e=this;this.objects.forEach((function(t){e.restoreObject(t)})),this.onChange(),this.selected=null}},{key:"restoreObject",value:function(e){e&&(e.visible||(e.visible=!0),this.restoreMaterial(e),this.restorePosition(e),e.transparent=e.transparent0,e==this.selected&&(this.selected=null))}},{key:"restoreMaterial",value:function(e){e&&(e.material=e.material0,(Array.isArray(e.material)?e.material:[e.material]).forEach((function(e){e.isAMRTBasicMaterial&&(e.opacity=e.opacity0,e.transparent=e.transparent0)})),this.viewer.renderManager.render())}},{key:"restorePosition",value:function(e){e&&e.position.copy(e.position0)}},{key:"dispose",value:function(){this.dragControls.enabled=!1,this.dragControls.deactivate()}},{key:"_initData",value:function(){var e=this;this.objects=[],this.viewer.modelGroup.traverse((function(t){t.isMesh&&(e.objects.push(t),t.material0||(t.position0=t.position.clone(),(Array.isArray(t.material)?t.material:[t.material]).forEach((function(e){e.isAMRTBasicMaterial&&(e.opacity0=e.opacity,e.transparent0=e.transparent)})),t.material0=t.material))}))}},{key:"_cloneMate",value:function(e){var t;return Array.isArray(e)?(t=[],e.forEach((function(e){if(e.isAMRTBasicMaterial){var n=e.clone();n.opacity0=e.opacity0,n.transparent0=e.transparent0,t.push(n)}else t.push(e)}))):((t=e.clone()).opacity0=e.opacity0,t.transparent0=e.transparent0),t}}]),n}(Cd),lm=function(){var e=new Wi,t=new at,n=new at,i=new at,r=new at,a=new at,o=new at,s=new at,l=new at,A=new at,c=new at,h=new at,u=new at,d=new at,f=new at;function p(e,t,n){this.camera=e,this.scene=t,this.startPoint=new at,this.endPoint=new at,this.collection=[],this.deep=n||Number.MAX_VALUE}return p.prototype.select=function(t,n){return this.startPoint=t||this.startPoint,this.endPoint=n||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(e,this.scene),this.collection},p.prototype.updateFrustum=function(t,p){if(t=t||this.startPoint,p=p||this.endPoint,t.x===p.x&&(p.x+=Number.EPSILON),t.y===p.y&&(p.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera)n.copy(t),n.x=Math.min(t.x,p.x),n.y=Math.max(t.y,p.y),p.x=Math.max(t.x,p.x),p.y=Math.min(t.y,p.y),i.setFromMatrixPosition(this.camera.matrixWorld),r.copy(n),a.set(p.x,n.y,0),o.copy(p),s.set(n.x,p.y,0),r.unproject(this.camera),a.unproject(this.camera),o.unproject(this.camera),s.unproject(this.camera),u.copy(r).sub(i),d.copy(a).sub(i),f.copy(o).sub(i),u.normalize(),d.normalize(),f.normalize(),u.multiplyScalar(this.deep),d.multiplyScalar(this.deep),f.multiplyScalar(this.deep),u.add(i),d.add(i),f.add(i),(m=e.planes)[0].setFromCoplanarPoints(i,r,a),m[1].setFromCoplanarPoints(i,a,o),m[2].setFromCoplanarPoints(o,s,i),m[3].setFromCoplanarPoints(s,r,i),m[4].setFromCoplanarPoints(a,o,s),m[5].setFromCoplanarPoints(f,d,u),m[5].normal.multiplyScalar(-1);else if(this.camera.isOrthographicCamera){var m,v=Math.min(t.x,p.x),g=Math.max(t.y,p.y),y=Math.max(t.x,p.x),w=Math.min(t.y,p.y);r.set(v,g,-1),a.set(y,g,-1),o.set(y,w,-1),s.set(v,w,-1),l.set(v,g,1),A.set(y,g,1),c.set(y,w,1),h.set(v,w,1),r.unproject(this.camera),a.unproject(this.camera),o.unproject(this.camera),s.unproject(this.camera),l.unproject(this.camera),A.unproject(this.camera),c.unproject(this.camera),h.unproject(this.camera),(m=e.planes)[0].setFromCoplanarPoints(r,l,A),m[1].setFromCoplanarPoints(a,A,c),m[2].setFromCoplanarPoints(c,h,s),m[3].setFromCoplanarPoints(h,l,r),m[4].setFromCoplanarPoints(a,o,s),m[5].setFromCoplanarPoints(c,A,l),m[5].normal.multiplyScalar(-1)}else console.error("SelectionBox: Unsupported camera type.")},p.prototype.searchChildInFrustum=function(e,n){if("_shadow.mesh"!=n.name&&((n.isMesh||n.isLine||n.isPoints)&&void 0!==n.material&&(null===n.geometry.boundingSphere&&n.geometry.computeBoundingSphere(),t.copy(n.geometry.boundingSphere.center),t.applyMatrix4(n.matrixWorld),e.containsPoint(t)&&this.collection.push(n)),n.children.length>0))for(var i=0;i0&&(r.boxSelected.length=0,r.clearBoxSelected()),im.intersectModels(e,(function(e){if(r.enableMutilpeSelection){r._onChange(null);var t=e[0]?e[0].object:null;t&&(r.boxSelected.includes(t)?(t.material=t.material_0,r.boxSelected.remove(t)):(t.material=t.material.map((function(e){return e.isAMRTShadowMaterial?e:ym})),r.boxSelected.push(t)))}else r._onChange(e.length>0?e[0]:null)}),v(r)))}})),n&&n.isModel&&r.setTarget(n),r}return A(i,[{key:"newMaterials",get:function(){return um}},{key:"materials",get:function(){return dm}},{key:"mode",get:function(){return cm},set:function(e){cm=e,this.selectedMaterial=null,this.selected=null,im.composer.outline.pass.selectedObjects=pm=[]}},{key:"enabled",get:function(){return hm},set:function(e){hm!=e&&(e?(im.composer.enableOutline=!0,im.composer.outline.pass.edgeGlow=0,im.composer.outline.pass.edgeThickness=1,im.composer.outline.pass.edgeStrength=4.5):(im.composer.enableOutline=!1,im.composer.outline.pass.edgeGlow=1,im.composer.outline.pass.edgeThickness=2,im.composer.outline.pass.edgeStrength=6.5,this.selected=null,this.selectedMaterial=null,fm=[],dm=[],pm=[],mm={}),hm=e)}},{key:"enableBoxSelection",get:function(){return vm},set:function(e){e!==vm&&(e?(rm||(rm=new lm(im.camera,im.modelGroup)),am||(am=new Am(rm,im.renderer,"selectBox")),this.selectionBox=rm,am.enabled=!0,am.element.style.display="block",im.controls.enabled=!1):(am.enabled=!1,im.controls.enabled=!0,am.element.style.display="none"),vm=e)}},{key:"enableMutilpeSelection",get:function(){return gm},set:function(e){e!==gm&&(gm=e)}},{key:"clearBoxSelected",value:function(){fm.map((function(e){e.material[0]===ym&&e.material_0&&(e.material=e.material_0)}))}},{key:"_onChange",value:function(e){var t=e?e.object:null;if(t){var n,i=e.faceIndex;t.geometry.groups.forEach((function(e){i>=e.start&&i0&&this.boxSelected.map((function(e){return e.visible=!1})),e&&fm.map((function(t){t.material.forEach((function(n){e.id!==n.id&&e.ID!==n.re||(t.visible=!1)}))}))}},{key:"show",value:function(e){(this.selectedMaterial||e)&&(e=e?dm.find((function(t){return t.id===e.id})):this.selectedMaterial,fm.forEach((function(t){t.material.find((function(t){return t.id===e.id||t.re===e.ID}))&&(t.visible=!0,t.material.map((function(e){return e.visible=!0})))})))}},{key:"showAll",value:function(){fm.forEach((function(e){e.visible||(e.visible=!0)}))}},{key:"showIndependent",value:function(e){(this.selectedMaterial||e)&&(e=e?dm.find((function(t){return t.id===e.id})):this.selectedMaterial,fm.forEach((function(t){t.visible=Boolean(t.material.find((function(t){return t.id===e.id||t.re===e.ID})))})))}},{key:"toggleDisplay",value:function(){fm.forEach((function(e){e.visible=!e.visible}))}},{key:"setColor",value:function(e){this._applyParams("color",e,"color")}},{key:"getColor",value:function(){return this._getParams("color")}},{key:"setRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.albedo&&this.selectedMaterial.albedo.repeat.set(e,t),im.renderManager.render()}},{key:"getRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.albedo)return this.selectedMaterial.albedo.repeat}},{key:"setRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.albedo&&(this.selectedMaterial.albedo.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.albedo)return 180*this.selectedMaterial.albedo.rotation/Math.PI}},{key:"setOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.albedo&&this.selectedMaterial.albedo.offset.set(e,t),im.renderManager.render()}},{key:"getOffset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.albedo)return this.selectedMaterial.albedo.offset}},{key:"setAlbedoMap",value:function(e){this._applyParams("albedo",e,"map"),im.renderManager.render()}},{key:"getAlbedoMap",value:function(){return this._getParams("albedo")}},{key:"clearAlbedoMap",value:function(){this.selectedMaterial&&(this.selectedMaterial.albedo=null,this.selectedMaterial.needsUpdate=!0,im.renderManager.render())}},{key:"setAlbedoUV",value:function(e){this._applyParams("albedoUV",parseInt(e)),im.renderManager.render()}},{key:"getAlbedoUV",value:function(){return Number(this._getParams("albedoUV"))}},{key:"setNormalMap",value:function(e){this._applyParams("normalMap",e,"map")}},{key:"getNormalMap",value:function(){return this._getParams("normalMap")}},{key:"setNormalScale",value:function(e){this._applyParams("normalScale",e)}},{key:"getNormalScale",value:function(){return this._getParams("normalScale")}},{key:"setNormalRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.normalMap&&this.selectedMaterial.normalMap.repeat.set(e,t),im.renderManager.render()}},{key:"getNormalRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.normalMap)return this.selectedMaterial.normalMap.repeat}},{key:"setNormalRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.normalMap&&(this.selectedMaterial.normalMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getNormalRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.normalMap)return 180*this.selectedMaterial.normalMap.rotation/Math.PI}},{key:"setNormalOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.normalMap&&this.selectedMaterial.normalMap.offset.set(e,t),im.renderManager.render()}},{key:"getNormalOffset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.normalMap)return this.selectedMaterial.normalMap.offset}},{key:"setNormal2Map",value:function(e){this._applyParams("normalMap2",e,"map")}},{key:"getNormal2Map",value:function(){return this._getParams("normalMap2")}},{key:"setNormal2Scale",value:function(e){this._applyParams("normalScale2",e)}},{key:"getNormal2Scale",value:function(){return this._getParams("normalScale2")}},{key:"setNormal2Repeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.normalMap2&&this.selectedMaterial.normalMap2.repeat.set(e,t),im.renderManager.render()}},{key:"getNormal2Repeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.normalMap2)return this.selectedMaterial.normalMap2.repeat}},{key:"setNormal2Rotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.normalMap2&&(this.selectedMaterial.normalMap2.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"setSide",value:function(e){e<0||e>2||this._applyParams("side",e)}},{key:"getSide",value:function(){return this.selectedMaterial.side}},{key:"getNormal2Rotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.normalMap2)return 180*this.selectedMaterial.normalMap2.rotation/Math.PI}},{key:"setNormal2Offset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.normalMap2&&this.selectedMaterial.normalMap2.offset.set(e,t),im.renderManager.render()}},{key:"getNormal2Offset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.normalMap2)return this.selectedMaterial.normalMap2.offset}},{key:"setMetallicMap",value:function(e){this._applyParams("metallicMap",e,"map")}},{key:"setMetallicRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.metallicMap&&this.selectedMaterial.metallicMap.repeat.set(e,t),im.renderManager.render()}},{key:"getMetallicRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.metallicMap)return this.selectedMaterial.metallicMap.repeat}},{key:"setMetallicRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.metallicMap&&(this.selectedMaterial.metallicMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getMetallicRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.metallicMap)return 180*this.selectedMaterial.metallicMap.rotation/Math.PI}},{key:"setMetallicOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.metallicMap&&this.selectedMaterial.metallicMap.offset.set(e,t),im.renderManager.render()}},{key:"getMetallicOffset",value:function(e){this.selectedMaterial&&this.selectedMaterial.metallicMap&&this.selectedMaterial.metallicMap.offset}},{key:"setMetallic",value:function(e){this._applyParams("metallic",e)}},{key:"getMetallic",value:function(){return this._getParams("metallic")}},{key:"setRoughnessMap",value:function(e){this._applyParams("roughnessMap",e,"map")}},{key:"setRoughnessRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.roughnessMap&&this.selectedMaterial.roughnessMap.repeat.set(e,t),im.renderManager.render()}},{key:"getRoughnessRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.roughnessMap)return this.selectedMaterial.roughnessMap.repeat}},{key:"setRoughnessRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.roughnessMap&&(this.selectedMaterial.roughnessMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getRoughnessRotation",value:function(){return this.selectedMaterial&&this.selectedMaterial.roughnessMap?180*this.selectedMaterial.roughnessMap.rotation/Math.PI:null}},{key:"setRoughnessOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.roughnessMap&&this.selectedMaterial.roughnessMap.offset.set(e,t),im.renderManager.render()}},{key:"getRoughnessOffset",value:function(){return this.selectedMaterial&&this.selectedMaterial.roughnessMap?this.selectedMaterial.roughnessMap.offset:null}},{key:"setSmoothness",value:function(e){this._applyParams("smoothness",e)}},{key:"getSmoothness",value:function(){return this._getParams("smoothness")}},{key:"setAOMap",value:function(e,t){this._applyParams("aoMap",e,"map")}},{key:"clearAOMap",value:function(){this.selectedMaterial?(this.selectedMaterial.aoMap=null,this.selectedMaterial.needsUpdate=!0,im.renderManager.render()):this.onError("未选择材质对象")}},{key:"getAOMap",value:function(){return this._getParams("aoMap")}},{key:"setAORepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.aoMap&&this.selectedMaterial.aoMap.repeat.set(e,t),im.renderManager.render()}},{key:"getAORepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.aoMap)return this.selectedMaterial.aoMap.repeat}},{key:"setAORotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.aoMap&&(this.selectedMaterial.aoMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getAORotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.aoMap)return 180*this.selectedMaterial.aoMap.rotation/Math.PI}},{key:"setAOOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.aoMap&&this.selectedMaterial.aoMap.offset.set(e,t),im.renderManager.render()}},{key:"getAOOffset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.aoMap)return this.selectedMaterial.aoMap.offset}},{key:"setAOScale",value:function(e){this._applyParams("aoScale",e)}},{key:"getAOScale",value:function(){return this._getParams("aoScale")}},{key:"setAOUV",value:function(e){this._applyParams("aoUV",parseInt(e))}},{key:"getAOUV",value:function(){return this._getParams("aoUV")}},{key:"setEmissiveMap",value:function(e){this._applyParams("emissiveMap",e,"map")}},{key:"setEmissiveRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.emissiveMap&&this.selectedMaterial.emissiveMap.repeat.set(e,t),im.renderManager.render()}},{key:"getEmissiveRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.emissiveMap)return this.selectedMaterial.emissiveMap.repeat}},{key:"setEmissiveRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.emissiveMap&&(this.selectedMaterial.emissiveMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getEmissiveRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.emissiveMap)return 180*this.selectedMaterial.emissiveMap.rotation/Math.PI}},{key:"setEmissiveOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.emissiveMap&&this.selectedMaterial.emissiveMap.offset.set(e,t),im.renderManager.render()}},{key:"getEmissiveOffset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.emissiveMap)return this.selectedMaterial.emissiveMap.offset}},{key:"setEmissiveColor",value:function(e){this._applyParams("emissive",e,"color")}},{key:"getEmissiveColor",value:function(){return this._getParams("emissive")}},{key:"setEmissiveUV",value:function(e){this._applyParams("emissiveUV",e)}},{key:"getEmissiveUV",value:function(){return this._getParams("emissiveUV")}},{key:"setReflectMap",value:function(e){this._applyParams("reflectMap",e,"map")}},{key:"setReflectRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.reflectMap&&this.selectedMaterial.reflectMap.repeat.set(e,t),im.renderManager.render()}},{key:"getReflectRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.reflectMap)return this.selectedMaterial.reflectMap.repeat}},{key:"setReflectRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.reflectMap&&(this.selectedMaterial.reflectMap.rotation=Math.PI/180*e),im.renderManager.render()}},{key:"getReflectRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.reflectMap)return 180*this.selectedMaterial.reflectMap.rotation/Math.PI}},{key:"setReflectOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.reflectMap&&this.selectedMaterial.reflectMap.offset.set(e,t),im.renderManager.render()}},{key:"getReflectOffset",value:function(e){if(this.selectedMaterial&&this.selectedMaterial.reflectMap)return this.selectedMaterial.reflectMap.offset}},{key:"setReflectIntensity",value:function(e){this._applyParams("reflectIntensity",e)}},{key:"getReflectIntensity",value:function(){return this._getParams("reflectIntensity")}},{key:"setReflectivity",value:function(e){this._applyParams("reflectivity",e)}},{key:"getReflectivity",value:function(){return this._getParams("reflectivity")}},{key:"setAlphaMap",value:function(e){this._applyParams("alphaMap",e,"map")}},{key:"setAlphaMapRepeat",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.alphaMap&&this.selectedMaterial.alphaMap.repeat.set(e,t)}},{key:"getAlphaMapRepeat",value:function(){if(this.selectedMaterial&&this.selectedMaterial.alphaMap)return this.selectedMaterial.alphaMap.repeat}},{key:"setAlphaMapRotation",value:function(e){this.selectedMaterial&&this.selectedMaterial.alphaMap&&(this.selectedMaterial.alphaMap.rotation=Math.PI/180*e)}},{key:"getAlphaMapRotation",value:function(){if(this.selectedMaterial&&this.selectedMaterial.alphaMap)return 180*this.selectedMaterial.alphaMap.rotation/Math.PI}},{key:"setAlphaMapOffset",value:function(e,t){this.selectedMaterial&&this.selectedMaterial.alphaMap&&this.selectedMaterial.alphaMap.offset.set(e,t)}},{key:"getAlphaMapOffset",value:function(){if(this.selectedMaterial&&this.selectedMaterial.alphaMap)return this.selectedMaterial.alphaMap.offset}},{key:"setRefractionRatio",value:function(e){this._applyParams("refractionRatio",e)}},{key:"getRefractionRatio",value:function(){return this._getParams("refractionRatio")}},{key:"setTransparency",value:function(e){this._applyParams("transparency",e),this._updateTransparent()}},{key:"_updateTransparent",value:function(){this.selectedMaterial&&(this.selectedMaterial.opacity<1||this.selectedMaterial.transparency>0||this.selectedMaterial.alphaMap?this.selectedMaterial.transparent=!0:1!=this.selectedMaterial.opacity||0!=this.selectedMaterial.transparency||this.selectedMaterial.alphaMap||(this.selectedMaterial.transparent=!1))}},{key:"getTransparency",value:function(){return this._getParams("transparency")}},{key:"setOpacity",value:function(e){this._applyParams("opacity",e),this._updateTransparent()}},{key:"getOpacity",value:function(){return this._getParams("opacity")}},{key:"setTransparent",value:function(e){this._applyParams("transparent",Boolean(e))}},{key:"getTransparent",value:function(){return this._getParams("transparent")}},{key:"getAlphaTest",value:function(){return this._getParams("alphaTest")}},{key:"setAlphaTest",value:function(e){this._applyParams("alphaTest",e)}},{key:"getRetainMap",value:function(){if(this.selectedMaterial)return this.selectedMaterial.retainMap}},{key:"setRetainMap",value:function(e){if(this.selectedMaterial)return this.selectedMaterial.retainMap=e}},{key:"setRenderOrder",value:function(e){this.selectedMaterial&&(this._updateRenderOrderByMaterial(this.selectedMaterial,e),this.selectedMaterial.renderOrder=e,im.renderManager.render())}},{key:"getRenderOrder",value:function(){if(this.selected)return this.selected.renderOrder}},{key:"_getMeshByMaterial",value:function(e){var t=[];return fm.forEach((function(n){var i=n.material;(Array.isArray(i)?i:[i]).forEach((function(i){i==e&&t.push(n)}))})),t}},{key:"_updateRenderOrderByMaterial",value:function(e,t){e&&this._getMeshByMaterial(this.selectedMaterial).forEach((function(e){return e.renderOrder=t}))}},{key:"_applyParams",value:function(e,t,n){var i=this;if(this.selectedMaterial){if(mm[this.selectedMaterial.name]||(mm[this.selectedMaterial.name]=this.selectedMaterial.clone()),"map"===n){if(t){var r=t;this.mapLoader.setBaseUrl(""),t=this.mapLoader.load(t,(function(t){var n=r.substr(r.lastIndexOf(".")+1).split("?")[0].toUpperCase();"reflectMap"===e||"envMap"===e?((t=i.mapLoader.convertTexture(t)).image.src=r,i.selectedMaterial[e]=t,i.selectedMaterial.needsUpdate=!0):"BASIS"===n&&(i.selectedMaterial[e]=t,i.selectedMaterial.needsUpdate=!0)})),"envMap"===e?t.custom=!0:t.wrapS=t.wrapT=1e3}else t=null;this.selectedMaterial[e]=t,this.selectedMaterial.needsUpdate=!0}else"color"===n?this.selectedMaterial[e].setStyle(t):this.selectedMaterial[e]=t;this.selectedMaterial.needsUpdate=!0,dm.map((function(e){void 0!==e.re&&e.re===i.selectedMaterial.ID&&(e.copy(i.selectedMaterial),e.needsUpdate=!0)})),this.onEdit&&this.onEdit()}else this.onError("未选择材质对象")}},{key:"_getParams",value:function(e){if(this.selectedMaterial)return this.selectedMaterial[e]&&this.selectedMaterial[e].constructor===Fn?"#"+this.selectedMaterial[e].getHexString():this.selectedMaterial[e]&&this.selectedMaterial[e].constructor===ht?this.selectedMaterial[e].image.currentSrc||this.selectedMaterial[e].image.src:this.selectedMaterial[e];this.onError("未选择材质对象")}},{key:"replace",value:function(e,t){var i=this,r=this.selectedMaterial;if(r){mm[r.name]||(mm[r.name]=r.clone());for(var a=e.lod1,o={},s=0;st&&e.material[t].ID!==e.materialIndex[t]){var n=e.material[t].ID;r[n]||(r[n]=[]),r[n].push({a:e.ID,b:t})}}));var a={};for(var o in e){var s=e[o];".basis"!=s.slice(s.lastIndexOf("."))&&".mrtb"!=s.slice(s.lastIndexOf("."))||(s=this.model.originMaps[s]||""),e[o]&&e[o].startsWith("data:image")?e[o]="":a[o]=s}var l={a:t,b:e,c:r,ed:!0,z:a};return JSON.stringify(l)}},{key:"exportSingleMaterial",value:function(e){var t={},i=n({},e);delete i.re;var r=Nf.export(i,t);for(var a in delete r.a,delete r.ee,t)t[a]&&t[a].startsWith("data:image")&&(t[a]="");return{a:r,b:t}}},{key:"importSingleMaterial",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(n||(n=this.selectedMaterial),!n)return this.onError("请选则材质");Nf.parseAmrtMaterial(e.a,e.b,n,null,i,this.mapLoader,r),this.materials.map((function(a){return a.re===n.ID&&Nf.parseAmrtMaterial(e.a,e.b,a,null,i,t.mapLoader,r)}))}},{key:"rename",value:function(e,t){return t||(t=this.selectedMaterial),t?(t.sname=e,!0):(this.onError("请选则材质"),!1)}}]),i}(Cd),xm=function(){function e(t){s(this,e),this._rayCaster=null,this.viewer=t}return A(e,[{key:"rayCaster",get:function(){return this._rayCaster||(this._rayCaster=new Nc),this._rayCaster}},{key:"rayIntersect",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=t||this.viewer.sceneManager.root;var i=If.getDomMouse(e,this.viewer.domElement);return this.rayCaster.setFromCamera(i,this.viewer.renderManager.camera),Array.isArray(t)?this.rayCaster.intersectObjects(t,n):this.rayCaster.intersectObject(t,n)}},{key:"intersectObject",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e)return console.error("缺少事件对象: MouseEvent"),!1;t=t||this.viewer.sceneManager.modelGroup;var i=this.rayIntersect(e,t,n);return i.length>0?i[0]:null}},{key:"intersectObjects",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!e)return console.error("缺少事件对象: MouseEvent"),!1;t=t||this.viewer.sceneManager.modelGroup;var i=this.rayIntersect(e,t,n);return i}},{key:"intersectModels",value:function(e,t,n,i){var r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(!e)return console.error("缺少事件对象: MouseEvent"),!1;if(i=i||this.viewer.sceneManager.modelGroup,this.rayCaster.constructor===Nc){var a=this.rayIntersect(e,i,r);return t&&(n?t.call(n,a):t(a)),a}this.rayCaster.executeTest((function(e){t&&(n?t.call(n,e.intersects):t(e.intersects))}),!0)}},{key:"intersectBox",value:function(e,t){if(!e)return console.error("缺少事件对象: MouseEvent"),!1;var n=If.getDomMouse(e,this.viewer.domElement);this.rayCaster.setFromCamera(n,this.viewer.renderManager.camera);var i=(new tn).setFromObject(t);return this.rayCaster.ray.intersectBox(i)}},{key:"screenToVector",value:function(e){var t=this.intersectObject(e,this.viewer.sceneManager.root);return t?t.point:null}},{key:"vectorToScreen",value:function(e){var t=this.viewer.renderManager.container.getBoundingClientRect(),n=t.width/2,i=t.height/2,r=e.clone();return r.project(this.viewer.renderManager.camera),new tt(r.x*n+n,-r.y*i+i)}}]),e}(),bm=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),e.transform?g(i,e.transform):((i=t.call(this)).viewer=e,i._controls=new Fu(e.camera,e.container,!1),i._controls.addEventListener("dragging-changed",(function(e){i.viewer.controls.enabled=!e.value,i.dispatchEvent({type:"dragging-changed",data:i.target})})),i._controls.addEventListener("mouseDown",(function(){i.dispatchEvent({type:"mouseDown",data:i.target})})),i._controls.addEventListener("mouseUp",(function(){i.dispatchEvent({type:"mouseUp",data:i.target})})),i._controls.addEventListener("objectChange",(function(e){i.dispatchEvent({type:ld.CHANGE,data:i.target})})),i.target=null,e.transform=v(i),i)}return A(n,[{key:"setTarget",value:function(e){this.target=e,e?this._controls.attach(this.target):this._controls.detach(),this.viewer.renderManager.render()}},{key:"remove",value:function(){this._controls.detach(),this.target=null,this.viewer.renderManager.render()}},{key:"getTarget",value:function(){return this.target}},{key:"getMode",value:function(e){return this._controls.mode}},{key:"setMode",value:function(e){this._controls.setMode(e),this.viewer.renderManager.render()}},{key:"size",get:function(){return this._controls.size},set:function(e){this._controls.setSize(e),this.viewer.renderManager.render()}},{key:"enabled",get:function(){return this._controls.enabled},set:function(e){e?this.viewer.root.add(this._controls):this.viewer.root.remove(this._controls),this._controls.enabled=e,this.viewer.renderManager.render()}},{key:"showX",get:function(){return this._controls.showX},set:function(e){this._controls.showX=e,this.viewer.renderManager.render()}},{key:"showY",get:function(){return this._controls.showY},set:function(e){this._controls.showY=e,this.viewer.renderManager.render()}},{key:"showZ",get:function(){return this._controls.showZ},set:function(e){this._controls.showZ=e,this.viewer.renderManager.render()}},{key:"dispose",value:function(){this._controls.dispose(),this.viewer.renderManager.render()}}]),n}(Je),Mm=A((function e(){s(this,e)}));Mm.TRANSLATE="translate",Mm.ROTATE="rotate",Mm.SCALE="scale";var Cm=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,n),(e=t.call(this)).options=i,e.isEffect=!0,e.init(),e}return A(n,[{key:"init",value:function(){}},{key:"update",value:function(){}}]),n}(zt),Bm=" \n uniform float size; \n uniform float time; \n uniform float u_len; \n attribute float u_index;\n varying float u_opacitys;\n void main() { \n if( u_index < time + u_len && u_index > time){\n float u_scale = 1.0 - (time + u_len - u_index) /u_len;\n u_opacitys = u_scale;\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n gl_PointSize = size * u_scale * 1.0;\n } \n }\n ",Em=" \n uniform sampler2D u_map;\n uniform float u_opacity;\n uniform vec3 color;\n uniform float isTexture;\n varying float u_opacitys;\n void main() {\n vec4 u_color = vec4(color,u_opacity * u_opacitys);\n gl_FragColor = u_color;\n }",Sm=function(e){h(n,e);var t=y(n);function n(e,i,r,a){var o;return s(this,n),(o=t.call(this)).flyId=0,o.flyArr=[],o.baicSpeed=1,e=Array.isArray(e)?(new at).fromArray(e):(new at).copy(e),i=Array.isArray(i)?(new at).fromArray(i):(new at).copy(i),o.start=e,o.end=i,o.height=r||.3*e.distanceTo(i),o.color=a||"#02E6FF",o._baseScale=.1,o._opacity=1,o._init(),o}return A(n,[{key:"_initCurve",value:function(){var e=new yA(this.start,new at((this.start.x+this.end.x)/2,2*this.height,(this.start.z+this.end.z)/2),this.end);return this.curveLength=e.getLength(),e.getPoints(40*this.start.distanceTo(this.end))}},{key:"_init",value:function(){var e=this,t=this._initCurve(),n=new Li;n.vertices=t,this.baseLine=new Go(n,new Do({color:this.color})),this.add(this.baseLine),this._createFlyLine(t,this.color,{}),this.timer=setInterval((function(){e._createFlyLine(e._initCurve(),e.color,{}),e.flyArr.length>=3&&clearInterval(e.timer)}),3e3),this.pointMaterial=new Nn({map:If.createCircleMap(this.color),side:2,transparent:!0}),this.startPoint=new Ei(new dl(1,32),this.pointMaterial),this.startPoint.rotation.x=Math.PI/2,this.startPoint.position.copy(this.start),this.endPoint=new Ei(new dl(1,32),this.pointMaterial),this.endPoint.position.copy(this.end),this.endPoint.rotation.x=Math.PI/2,this.add(this.startPoint),this.add(this.endPoint)}},{key:"pointVisible",set:function(e){e=!!e,this.startPoint.visible=e,this.endPoint.visible=e}},{key:"_createGeometry",value:function(e,t){t=t||new si;var n=[],i=[];return e.forEach((function(e,t){n.push(e.x,e.y,e.z),i.push(t)})),t.setAttribute("position",new Yn(n,3)),t.setAttribute("u_index",new Yn(i,1)),t}},{key:"_createFlyLine",value:function(e,t,n){var i=n.width,r=void 0===i?3:i;n.length,n.speed;var a=n.repeat,o=void 0===a?1/0:a,s=new Ri({uniforms:{color:{value:new Fn(t).lerp(new Fn(1,1,1),.3),type:"v3"},size:{value:r,type:"f"},u_len:{value:10*this.curveLength,type:"f"},u_opacity:{value:.7,type:"f"},time:{value:-10*this.curveLength,type:"f"}},transparent:!0,depthTest:!1,vertexShader:Bm,fragmentShader:Em,defaultAttributeValues:{}}),l=this._createGeometry(e);this.points=new qo(l,s),this.points._speed=this.curveLength/3,this.points._repeat=o,this.points._been=0,this.points._total=e.length,this.flyId++,this.flyArr.push(this.points),this.add(this.points)}},{key:"update",value:function(e){var t=this;e>.2||(this.flyArr.forEach((function(n){if(n.parent)if(n._been>n._repeat)n.visible=!1,"function"==typeof n._callback&&n._callback(n),t.remove(n);else{var i=n.material.uniforms;i.time.value1?.2:this._baseScale,this.startPoint.scale.set(this._baseScale,this._baseScale,this._baseScale),this.endPoint.scale.copy(this.startPoint.scale))}},{key:"_updateLine",value:function(){var e=this;this.startPoint.position.copy(this.start),this.endPoint.position.copy(this.end);var t=this._initCurve(),n=new Li;n.vertices=t,this.baseLine.geometry.dispose(),this.baseLine.geometry=n,this.flyArr.forEach((function(n){e._createGeometry(t,n.geometry),n.geometry.verticesNeedUpdate=!0}))}},{key:"onAfterRender",value:function(){AMRT.needsUpdate=!0}},{key:"setHeight",value:function(e){e!=this.height&&(this.height=e,this._updateLine())}},{key:"setStartPoint",value:function(e){this.start=e,this._updateLine()}},{key:"setEndPoint",value:function(e){this.end=e,this._updateLine()}},{key:"setColor",value:function(e){this.color=e,this.baseLine.material.color.setStyle(this.color);var t=new Fn(e).lerp(new Fn(1,1,1),.3);this.flyArr.forEach((function(e){e.material.uniforms.color.value.copy(t)})),this.pointMaterial.map=If.createCircleMap(this.color),this.pointMaterial.map.needsUpdate=!0}},{key:"toJSON",value:function(){return{start:this.start,end:this.end,height:this.height,color:this.color}}},{key:"dispose",value:function(){for(;00&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#FFFF00";s(this,n),(e=t.call(this)).viewer=null,e.dotIndex=0,e.path=i,e.longlats=[],e.isClose=!1,e.lineColor=r;var a=new Li;return e.lineMaterial=new Do({color:r,depthTest:!1,depthWrite:!1}),e.line=new Go(a,e.lineMaterial),e.line.renderOrder=5e3,e.add(e.line),e.dotGroup=new zt,e.add(e.dotGroup),e.dotMaterial=e.createDotMaterial(),e}return A(n,[{key:"path",get:function(){return this._path},set:function(e){if(e){this._path=[];for(var t=0;t0&&(e.forEach((function(e){e&&t.pathPush(e)})),this.updateDot())}},{key:"addLongLats",value:function(e){var t=this;e&&e.length>0&&(e.forEach((function(n){n&&Array.isArray(n)&&t.viewer&&t.viewer.isGISViewer&&(t.longlats.push(e),t.pathPush(t.viewer.coordinatesToVector3(n)))})),this.updateDot())}},{key:"pathPush",value:function(e){var t=(new at).copy(e);this._path.push(t)}},{key:"removePoint",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.path.length>0&&(null!=e&&this.path[e]||(e=this.path.length-1),this.path.splice(e,1),this.longlats&&this.longlats[e]&&this.longlats.splice(e,1),this.updateDot())}},{key:"updatePath",value:function(){var e=this,t=[];if(this.dotGroup.children.forEach((function(e){t.push(e.position.clone())})),this.path=t,this.viewer&&this.viewer.isGISViewer){var n=[];this.path.forEach((function(t){n.push(e.viewer.coordinatesToVector3(t))})),this.longlats=n}this.updateLine()}},{key:"updateDot",value:function(){for(var e=this.path,t=this.dotGroup.children,n=Math.max(e.length,t.length),i=0;i0&&void 0!==arguments[0]?arguments[0]:null;e&&(this.path=e);var t=new Li;if(this.longlats&&this.longlats.length>0)t.vertices=this.detVector3();else{var n=[];this.path.forEach((function(e){n.push(e)})),this.isClose&&n.push(n[0]),t.vertices=n}this.line.geometry.dispose(),this.line.geometry=t,this.line.geometry.verticesNeedUpdate=!0}},{key:"createDot",value:function(e,t){var n=new go(this.dotMaterial.clone());return n.isPathPoint=!0,n.renderOrder=5e3,n.scale.set(.04,.04,1),e&&n.position.copy(e),n}},{key:"createDotMaterial",value:function(){var e=document.createElement("canvas");e.width=e.height=32;var t=e.getContext("2d");return t.beginPath(),t.arc(16,16,4,0,2*Math.PI),t.fillStyle=this.lineColor,t.fill(),new ro({map:new ts(e),sizeAttenuation:!1,depthTest:!1,depthWrite:!1})}},{key:"show",value:function(){this.visible=!0}},{key:"hide",value:function(){this.visible=!1}},{key:"detVector3",value:function(){var e=[];if(1===this.longlats.length)e.push(this.viewer.coordinatesToVector3(this.longlats[0]));else{var t=[];this.longlats.forEach((function(e){t.push(e)})),this.isClose&&t.push(t[0]);for(var n=0;n=2&&this.addDistancePanel();else if(this.type===n.TYPE_HEIGHT){this.pathEditor.isClose=!1;var i=this.computeHeightPoint(e,t);i&&this.pathEditor.addPoint(i),this.pathEditor.path.length>=2&&this.addHeightPanel()}else this.type===n.TYPE_ANGLE?(this.pathEditor.isClose=!1,e&&this.pathEditor.addPoint(e),this.pathEditor.path.length>=3&&this.addAnglePanel()):this.type===n.TYPE_AREA&&(this.pathEditor.isClose=!0,e&&this.pathEditor.addPoint(e),this.pathEditor.path.length>=3&&this.addAreaPanel())}},{key:"addPoints",value:function(e){var t=this;e.forEach((function(e){t.addPoint(e)}))}},{key:"addAreaPanel",value:function(){var e=this.pathEditor.path;this.clearPanel();var t=e[0],n=e[1],i=e[2],r=this.computePolyArea(e),a=new tn;a.setFromPoints(e);var o=a.getCenter(),s=a.max.distanceTo(a.min);this.maxLength=s,this.textScale=2,this.textMeshScale=.002*this.maxLength,this.fontSize=20*this.textScale;var l=n.distanceTo(t),A=n.distanceTo(i),c=.005*this.maxLength*.5*30,h=Math.min(l,A);c=c>3*h/4?3*h/4:c;var u=t.clone().sub(n).normalize(),d=i.clone().sub(n).normalize(),f=n.clone().addScaledVector(u,c),p=n.clone().addScaledVector(d,c),m=new at((f.x+p.x)/2,(f.y+p.y)/2,(f.z+p.z)/2).clone().sub(n),v=this._drawText2((r*this.magnification*this.magnification).toFixed(this.decimalPlaces)+this.showUnit+"2"),g=v.clone();g.geometry=v.geometry.clone(),g.selectMat=v.selectMat.clone(),g.unselectMat=v.unselectMat.clone(),this.panelNode.add(g);var y=m.clone().normalize(),w=u.clone().cross(d).normalize(),x=w.clone().cross(y);x.y<0&&(x.negate(),w.negate());var b=new bt;b.makeBasis(y,x,w),b.setPosition(o),v.geometry.applyMatrix(b);var M=new bt;M.makeBasis(y.clone().negate(),x.clone(),w.clone().negate()),M.setPosition(o.clone()),g.geometry.applyMatrix(M),this.lengthMesh=v,this.lengthMesh.back=g}},{key:"addAnglePanel",value:function(){var e=this.pathEditor.path;this.clearPanel();for(var t=0;t3*A/4?3*A/4:l;var c=n.clone().sub(i).normalize(),h=r.clone().sub(i).normalize(),u=180*c.angleTo(h)/Math.PI,d=i.clone().addScaledVector(c,l),f=i.clone().addScaledVector(h,l),p=new at((d.x+f.x)/2,(d.y+f.y)/2,(d.z+f.z)/2),m=p.clone().sub(i),v=p.addScaledVector(m,2),g=this._drawText2(u.toFixed(this.decimalPlaces)+"度"),y=g.clone();y.geometry=g.geometry.clone(),y.selectMat=g.selectMat.clone(),y.unselectMat=g.unselectMat.clone(),this.panelNode.add(y);var w=m.clone().normalize(),x=c.clone().cross(h).normalize(),b=x.clone().cross(w);b.y<0&&(b.negate(),x.negate());var M=new bt;M.makeBasis(w,b,x),M.setPosition(v),g.geometry.applyMatrix(M);var C=new bt;C.makeBasis(w.clone().negate(),b.clone(),x.clone().negate()),C.setPosition(v.clone()),y.geometry.applyMatrix(C),this.lengthMesh=g,this.lengthMesh.back=y}}},{key:"addHeightPanel",value:function(){var e=this.pathEditor.path;this.clearPanel();for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:null;this.pathEditor.removePoint(e)}},{key:"updatePath",value:function(){this.pathEditor.updatePath(),this.updatePanel()}},{key:"clearPanel",value:function(){for(;this.panelNode.children.length>0;)this.panelNode.remove(this.panelNode.children[0])}},{key:"updatePanel",value:function(){this.clearPanel();this.addPoint(null)}},{key:"_onComplete",value:function(){this.onComplete&&this.onComplete()}},{key:"close",value:function(e){e&&e()}},{key:"hide",value:function(){this.visible=!1}},{key:"show",value:function(){this.visible=!0}},{key:"_drawText2",value:function(e,t){var n=document.createElement("canvas"),i=this._getMaterial(n,e,this.unselectColor),r=document.createElement("canvas"),a=this._getMaterial(r,e,_m),o=new Ei(new $i(n.width*this.textMeshScale/this.textScale,n.height*this.textMeshScale/this.textScale),i);return o.renderOrder=Ke,o.name="Text",t&&o.position.copy(t),o.selectMat=a,o.unselectMat=i,this.panelNode.add(o),o}},{key:"_getMaterial",value:function(e,t,n){e.height=this.fontSize,this._fillText(e,t,n);var i=new ts(e);i.anisotropy=16;var r=new Nn({map:i,transparent:!0});return r.depthTest=!1,r}},{key:"_fillText",value:function(e,t,n){var i="normal bolder "+this.fontSize+"px 黑体";e.width=this._measureTextWidth(i,t);var r=e.getContext("2d");r.clearRect(0,0,e.width,e.height),r.font=i,r.fillStyle=n||this.unselectColor,r.textAlign="left",r.textBaseline="top",r.fillText(t,0,0)}},{key:"_measureTextWidth",value:function(e,t){this._measureCanvas||(this._measureCanvas=document.createElement("canvas"),this._measureCanvas.height=100,this._measureCanvas.width=100);var n=this._measureCanvas.getContext("2d");return n.font=e,n.measureText(t).width}},{key:"computePolyArea",value:function(e){for(var t=0,n=this.getFaces(e),i=0;if&&(n=a.clone().addScaledVector(A,m))}}else e&&(n=(new at).copy(e));return n}},{key:"getFaces",value:function(e){if(e.length<3)return[];for(var t,n,i,r,a,o,s=1e-4,l=!1,A=0;A0&&void 0!==arguments[0]?arguments[0]:"m";Im[e]&&(this._showUnit=e,this.magnification=Im[e])}},{key:"magnification",get:function(){return this._magnification},set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this._magnification=e}},{key:"decimalPlaces",get:function(){return this._decimalPlaces},set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;"string"==typeof e&&(e=parseInt(e)),"number"==typeof e&&e>=0&&(this._decimalPlaces=Math.round(e))}},{key:"earthsCoreVec",get:function(){return this._earthsCoreVec},set:function(e){e&&(this._earthsCoreVec=(new at).copy(e))}},{key:"toJSON",value:function(){return{type:this.type,points:this.pathEditor.path,color:this.unselectColor}}},{key:"loadJson",value:function(e){this.addPoints(e.points)}},{key:"reset",value:function(){for(var e=this.showUnit,t=this.decimalPlaces,n=this.toJSON();this.children.length>0;)this.remove(this.children[0]);this.init(),this.showUnit=e,this.decimalPlaces=t,this.loadJson(n)}},{key:"destroy",value:function(){}}]),n}(zt);Lm.TYPE_DISTANCE=0,Lm.TYPE_HEIGHT=1,Lm.TYPE_ANGLE=2,Lm.TYPE_AREA=3;var Fm=.001,km=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this)).unselectColor=i||"#FF4500",r.type=e||n.TYPE_RECT,r.decimalPlaces=3,r.init(),r}return A(n,[{key:"init",value:function(){this.hided=!1,this.pathEditor=new Tm([],this.unselectColor),this.pathEditor.isClose=!0,this.add(this.pathEditor),this.panelNode=new zt,this.add(this.panelNode)}},{key:"addPoint",value:function(e,t){if(this.type===n.TYPE_POLYGON)e&&(Array.isArray(e)?this.pathEditor.addLongLat(e):this.pathEditor.addPoint(e)),this.pathEditor.path.length>=3&&this.addAreaPanel(this.pathEditor.path);else if(this.type===n.TYPE_RECT){if(e)if(this.firstPoint){for(;this.pathEditor.path.length>0;)this.pathEditor.removePoint();if(Array.isArray(e)){var i=this.firstPoint,r=[e[0],e[1]],a=[i[0],e[1]],o=[e[0],i[1]];this.pathEditor.addLongLat(i),this.pathEditor.addLongLat(a),this.pathEditor.addLongLat(r),this.pathEditor.addLongLat(o)}else{var s=this.firstPoint.clone(),l=e,A=new at(s.x,s.y,l.z),c=new at(l.x,l.y,s.z);this.pathEditor.addPoint(s),this.pathEditor.addPoint(A),this.pathEditor.addPoint(l),this.pathEditor.addPoint(c)}this.addAreaPanel(this.pathEditor.path),t&&t()}else Array.isArray(e)?this.firstPoint=[e[0],e[1]]:this.firstPoint=(new at).copy(e)}else if(this.type===n.TYPE_CIRCULAR){if(e)if(this.firstPoint){for(;this.pathEditor.path.length>0;)this.pathEditor.removePoint();if(Array.isArray(e))for(var h=new tt(this.firstPoint[0],this.firstPoint[1]).distanceTo(new tt(e[0],e[1])),u=0;u<=360;u+=10){var d=u/180*Math.PI,f=this.firstPoint[0]+h*Math.cos(d),p=this.firstPoint[1]+h*Math.sin(d);this.pathEditor.addLongLat([f,p])}else{e.y=this.firstPoint.y;for(var m=this.firstPoint.distanceTo(e),v=0;v<=360;v+=10){var g=v/180*Math.PI,y=this.firstPoint.x+m*Math.cos(g),w=this.firstPoint.z+m*Math.sin(g);this.pathEditor.addPoint({x:y,y:this.firstPoint.y,z:w})}}this.addAreaPanel(this.pathEditor.path),t&&t()}else Array.isArray(e)?this.firstPoint=[e[0],e[1]]:this.firstPoint=(new at).copy(e);this.pathEditor.dotGroup.visible=!1}}},{key:"addPoints",value:function(e){var t=this;e.forEach((function(e){t.addPoint(e)}))}},{key:"addLongLats",value:function(e){var t=this;e.forEach((function(e){t.addLongLat(e)}))}},{key:"removePoint",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.pathEditor.removePoint(e)}},{key:"updatePath",value:function(){this.pathEditor.updatePath(),this.updatePanel()}},{key:"clearPanel",value:function(){for(;this.panelNode.children.length>0;)this.panelNode.remove(this.panelNode.children[0])}},{key:"updatePanel",value:function(){this.clearPanel();this.addPoint(null)}},{key:"close",value:function(e){e&&e()}},{key:"hide",value:function(){this.visible=!1}},{key:"show",value:function(){this.visible=!0}},{key:"filter",value:function(e,t){var n=this.getLoop(t);if(n.length>=3){var i=[];Array.isArray(e)?e.forEach((function(e){e.traverse((function(e){e.isMesh&&i.push(e)}))})):e.traverse((function(e){e.isMesh&&i.push(e)}));for(var r=0;rd.next.lineLen?(r.remove(d.next),u--,d.endPoint=d.next.endPoint.clone(),d.next=d.next.next,d.next.pre=d):(r.remove(d),u--,d.next.startPoint=d.startPoint.clone(),d.next.pre=d.pre,d.pre.next=d.next))}}return r}},{key:"pointAtLoop",value:function(e,t){for(var n=t.x,i=t.y,r={},a="out",o=0;oi&&d>i))if(n!=A||n!=u){if(!(n>A&&n>u||ni)){if(p==i)return a=n==A||n==u?"atpoint":"atline";if(n==A){if(s.endPoint.x>n&&s.pre.startPoint.x>n||s.endPoint.xn&&s.next.endPoint.x>n||s.startPoint.xd?(v=c,g=d):(v=d,g=c),i>=g&&i<=v)return a="atline";if(s.pre.startPoint.x>n&&s.next.endPoint.x>n||s.pre.startPoint.x0)this.type===n.TYPE_RECT&&t.length>3?e.longlats=[t[0],t[2]]:this.type===n.TYPE_CIRCULAR&&t.length>1?e.longlats=[this.firstPoint,t[0]]:this.type===n.TYPE_POLYGON&&t.length>3?e.longlats=t:e=null;else{var i=this.pathEditor.path;this.type===n.TYPE_RECT&&i.length>3?e.points=[i[0],i[2]]:this.type===n.TYPE_CIRCULAR&&i.length>1?e.points=[this.firstPoint,i[0]]:this.type===n.TYPE_POLYGON&&i.length>3?e.points=i:e=null}return e}},{key:"loadJson",value:function(e){e.longlats?this.addPoints(e.longlats):this.addPoints(e.points)}},{key:"reset",value:function(){for(var e=this.showUnit,t=this.decimalPlaces,n=this.toJSON();this.children.length>0;)this.remove(this.children[0]);this.init(),this.showUnit=e,this.decimalPlaces=t,this.loadJson(n)}},{key:"destroy",value:function(){}}]),n}(zt);km.TYPE_RECT=0,km.TYPE_CIRCULAR=1,km.TYPE_POLYGON=2;var Pm=function(){function e(t){s(this,e),this.viewer=t,this.modelNode=new zt,this.viewer.modelGroup.add(this.modelNode),this.basicModels=[],this.flyLines=[],this.pathEditors=[],this.measure3Ds=[],this.selections=[],this.allModels=[this.basicModels,this.flyLines,this.pathEditors,this.measure3Ds,this.selections]}return A(e,[{key:"addCube",value:function(e,t,n){var i={width:e,height:t,depth:n};return this.addCube2(i)}},{key:"addCube2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color);var i=new Fi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addSphere",value:function(e){var t={radius:e};return this.addSphere2(t)}},{key:"addSphere2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color);var i=new $s(e.radius,e.widthSegments,e.heightSegments),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addTorus",value:function(e,t){var n={radius:e,tube:t};return this.addTorus2(n)}},{key:"addTorus2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color);var i=new ws(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addCylinder",value:function(e,t,n){var i={radiusTop:e,radiusBottom:t,height:n};return this.addCylinder2(i)}},{key:"addCylinder2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color);var i=new Al(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addRectPlane",value:function(e,t){var n={width:e,height:t};return this.addRectPlane2(n)}},{key:"addRectPlane2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color),e.doubleSide&&(n.side=2);var i=new qi(e.width,e.height,e.widthSegments,e.heightSegments),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addCirclePlane",value:function(e){var t={radius:e};return this.addCirclePlane2(t)}},{key:"addCirclePlane2",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new kf(this.viewer),n={};e.color&&(n.color=e.color),e.doubleSide&&(n.side=2);var i=new dl(e.radius,e.segments,e.thetaStart,e.thetaLength),r=new Gf(n),a=new Ei(i,r);return t.add(a),e.position&&t.position.copy(e.position),e.parent?e.parent.add(t):this.viewer.modelGroup.add(t),this.basicModels.push(t),t.init(t),t}},{key:"addFlyLine",value:function(e,t,n,i){var r=new kf(this.viewer),a=new Sm(e,t,n,i);return r.add(a),this.viewer.modelGroup.add(r),this.flyLines.push(r),r}},{key:"addPathEditor",value:function(e,t){var n=new kf(this.viewer),i=new Tm([],t);return e&&e.length>0&&i.addPoints(e),n.add(i),this.viewer.modelGroup.add(n),this.pathEditors.push(n),n}},{key:"addMeasure3D",value:function(e,t,n){var i=new kf(this.viewer),r=new Lm(t,n);return e&&e.length>0&&r.addPoints(e),i.add(r),this.viewer.modelGroup.add(i),this.measure3Ds.push(i),i}},{key:"addSelection",value:function(e,t,n){var i=new kf(this.viewer),r=new km(t,n);return e&&e.length>0&&r.addPoints(e),i.add(r),this.viewer.modelGroup.add(i),this.selections.push(i),i}},{key:"show",value:function(){this.allModels.forEach((function(e){e.forEach((function(e){e.visible=!0}))})),this._consoleCallBack&&this._consoleCallBack("显示组")}},{key:"hide",value:function(){this.allModels.forEach((function(e){e.forEach((function(e){e.visible=!1}))})),this._consoleCallBack&&this._consoleCallBack("隐藏组")}},{key:"removeMesh",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(this.basicModels.length>0){-1===e&&(e=this.basicModels.length-1);var t=this.basicModels[e];t.parent.remove(t),this.basicModels.splice(e,1),this._consoleCallBack&&this._consoleCallBack("删除成功!")}}},{key:"clearAll",value:function(){var e=0;this.allModels.forEach((function(t){t.forEach((function(t){t.parent.remove(t),e++})),t.splice(0,t.length)})),this._consoleCallBack&&e>0&&this._consoleCallBack("清空组!")}},{key:"_onMouseUp",value:function(e){}},{key:"_onMouseMove",value:function(e){}},{key:"_onUpdate",value:function(){}},{key:"consoleCallBack",set:function(e){e&&(this._consoleCallBack=e)}}]),e}(),Um=function(){function e(t){s(this,e),this.viewer=t,this.type=e.TYPE_DRAW,this.pathsGroup=new zt,this.viewer.modelGroup.add(this.pathsGroup),this.curPathEditor=null,this.container=document.createElement("div"),this.viewer.container.appendChild(this.container),this._onClick=this._onClick.bind(this),this._onRightClick=this._onRightClick.bind(this),this._onMouseMove=this._onMouseMove.bind(this)}return A(e,[{key:"start",value:function(){this.curPathEditor||this.addPathEditor(),this.viewer.moduleManager.event.addEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.addEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.addEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="crosshair",this.container.style.display="block",this._consoleCallBack&&this._consoleCallBack("左键点击开始绘制!")}},{key:"end",value:function(){this.viewer.moduleManager.event.removeEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.removeEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.removeEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="auto",this.container.style.display="none",this.curPathEditor&&(this.curPathEditor.path.length<2&&this.pathsGroup.remove(this.curPathEditor),this.curPathEditor=null),this.viewer.enableTransform&&(this.viewer.enableTransform=!0),this.viewer.transform&&this.viewer.transform.setTarget(null),this.type=e.TYPE_DRAW,this._consoleCallBack&&this._consoleCallBack("结束绘制!")}},{key:"show",value:function(){!1===this.pathsGroup.visible&&(this.pathsGroup.visible=!0,this._consoleCallBack&&this._consoleCallBack("显示路径!"))}},{key:"hide",value:function(){!0===this.pathsGroup.visible&&(this.pathsGroup.visible=!1,this._consoleCallBack&&this._consoleCallBack("隐藏路径!"))}},{key:"addPathEditor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=t||this.pathEditorColor;return this.curPathEditor=new Tm([],n),this.curPathEditor.addPoints(e),this.pathsGroup.add(this.curPathEditor),this.curPathEditor}},{key:"getPathEditor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=null;return this.pathsGroup.children.length>0&&(-1==e&&(e=this.pathsGroup.children.length-1),t=this.pathsGroup.children[e]),t}},{key:"updatePathEditor",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:-1;this.pathsGroup.children.length>0&&(-1===e&&(e=this.pathsGroup.children.length-1),this.pathsGroup.children.splice(e,1),this.curPathEditor=null,this._consoleCallBack&&this._consoleCallBack("删除成功!"))}},{key:"clearPathEditor",value:function(){this.pathsGroup.children.splice(0,this.pathsGroup.children.length)}},{key:"enableEditor",value:function(){this.viewer.moduleManager.event.addEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.addEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.addEventListener(Ad.mousemove,this._onMouseMove),this.container.style.display="block",this.type=e.TYPE_EDIT,this._consoleCallBack&&this._consoleCallBack("选择路径节点进行编辑!右键结束编辑")}},{key:"loadJson",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"PathEditorData",t=localStorage.getItem(e);if(t){t=JSON.parse(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"PathEditorData",t=[],n=0;n0){var r={points:i.path,color:i.lineColor};t.push(r)}}return localStorage.setItem(e,JSON.stringify(t)),this._consoleCallBack&&this._consoleCallBack("保存路径!"),t}},{key:"_onClick",value:function(t){var n=this;if(this.type===e.TYPE_EDIT){var i=[];this.pathsGroup.children.forEach((function(e){i=i.concat(e.dotGroup)}));var r=this.viewer.picker.intersectModels(t.point,null,null,i);r&&r.length>0?(this.viewer.enableTransform||(this.viewer.enableTransform=!0),this.viewer.transform.setTarget(r[0].object)):this.viewer.transform&&this.viewer.transform.setTarget(null)}else if(this.curPathEditor){var a=[];this.viewer.modelGroup.children.forEach((function(e){e!=n.pathsGroup&&a.push(e)}));var o=this.viewer.picker.intersectObject(t.point,a);o&&this.curPathEditor.addPoint(o.point)}}},{key:"_onRightClick",value:function(){this.end()}},{key:"_onMouseMove",value:function(e){}},{key:"_onUpdate",value:function(){}},{key:"pathEditorColor",get:function(){return this._pathEditorColor},set:function(e){e&&(this._pathEditorColor=e)}},{key:"consoleCallBack",set:function(e){e&&(this._consoleCallBack=e)}}]),e}();Um.TYPE_DRAW=0,Um.TYPE_EDIT=1;var Dm=function(){function e(t){s(this,e),this.viewer=t,this.measuresGroup=new zt,this.viewer.modelGroup.add(this.measuresGroup),this.curMeasure3D=null,this.container=document.createElement("div"),this.viewer.container.appendChild(this.container),this.earthsCoreVec=new at,this._onClick=this._onClick.bind(this),this._onRightClick=this._onRightClick.bind(this),this._onMouseMove=this._onMouseMove.bind(this)}return A(e,[{key:"distanceMeasure",value:function(){this.start(Lm.TYPE_DISTANCE),this._consoleCallBack&&this._consoleCallBack("开始距离测量,点击右键即可完成!")}},{key:"heightMeasure",value:function(){this.start(Lm.TYPE_HEIGHT),this._consoleCallBack&&this._consoleCallBack("开始高度测量,点击右键即可完成!")}},{key:"angleMeasure",value:function(){this.start(Lm.TYPE_ANGLE),this._consoleCallBack&&this._consoleCallBack("开始角度测量,点击右键即可完成!")}},{key:"areaMeasure",value:function(){this.start(Lm.TYPE_AREA),this._consoleCallBack&&this._consoleCallBack("开始面积测量,点击右键即可完成!")}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Lm.TYPE_DISTANCE;this.curMeasure3D?this.curMeasure3D.type!=e&&(this.removeMeasure(),this.addMeasure(e)):this.addMeasure(e),this.viewer.moduleManager.event.addEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.addEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.addEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="crosshair",this.container.style.display="block"}},{key:"end",value:function(){if(this.viewer.moduleManager.event.removeEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.removeEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.removeEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="auto",this.container.style.display="none",this.curMeasure3D){var e=this.curMeasure3D.type,t=this.curMeasure3D.pathEditor.path.length;(e===Lm.TYPE_DISTANCE||e===Lm.TYPE_HEIGHT)&&t<2&&this.measuresGroup.remove(this.curMeasure3D),(e===Lm.TYPE_ANGLE||e===Lm.TYPE_AREA)&&t<3&&this.measuresGroup.remove(this.curMeasure3D),this.curMeasure3D=null}}},{key:"show",value:function(){!1===this.measuresGroup.visible&&(this.measuresGroup.visible=!0,this._consoleCallBack&&this._consoleCallBack("显示测量!"))}},{key:"hide",value:function(){!0===this.measuresGroup.visible&&(this.measuresGroup.visible=!1,this._consoleCallBack&&this._consoleCallBack("隐藏测量!"))}},{key:"addMeasure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Lm.TYPE_DISTANCE,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=t||this.measureColor;return this.curMeasure3D=new Lm(e,n),this.curMeasure3D.earthsCoreVec=this.earthsCoreVec,this.curMeasure3D.showUnit=this.measureUnit,this.curMeasure3D.decimalPlaces=this.measureDecimalPlaces,this.measuresGroup.add(this.curMeasure3D),this.curMeasure3D}},{key:"updateMeasure",value:function(){for(var e=[],t=0;t0&&void 0!==arguments[0]?arguments[0]:-1;this.measuresGroup.children.length>0&&(-1===e&&(e=this.measuresGroup.children.length-1),this.measuresGroup.children.splice(e,1),this.curMeasure3D=null,this._consoleCallBack&&this._consoleCallBack("删除成功!"))}},{key:"clearMeasure",value:function(){this.measuresGroup.children.splice(0,this.measuresGroup.children.length)}},{key:"loadJson",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"MeasureData",t=localStorage.getItem(e);if(t){t=JSON.parse(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"MeasureData",t=[],n=0;n0&&void 0!==arguments[0]?arguments[0]:km.TYPE_POLYGON;this.curSelection?this.curSelection.type!=e&&(this.removeSelection(),this.addSelection(e)):this.addSelection(e),this.viewer.moduleManager.event.addEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.addEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.addEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="crosshair",this.container.style.display="block"}},{key:"end",value:function(){this._endCallBack&&this._endCallBack(this.curSelection),this.curSelection&&(this.curSelection.pathEditor.path.length<3&&this.selectionsGroup.remove(this.curSelection),this.curSelection=null),this.viewer.moduleManager.event.removeEventListener(Ad.click,this._onClick),this.viewer.moduleManager.event.removeEventListener(Ad.rightClick,this._onRightClick),this.viewer.moduleManager.event.removeEventListener(Ad.mousemove,this._onMouseMove),this.viewer.domElement.style.cursor="auto",this.container.style.display="none"}},{key:"filter",value:function(e){if(e=e||this.viewer.sceneManager.modelGroup,this.curSelection&&this.end(),this.selectionsGroup.children.length>0){var t=this.selectionsGroup.children[this.selectionsGroup.children.length-1],n=this.viewer.camera.matrix.clone();n.setPosition(0,0,0);var i=(new bt).getInverse(n);t.filter(e,i)}this._consoleCallBack&&this._consoleCallBack("框选过滤完成!")}},{key:"show",value:function(){!1===this.selectionsGroup.visible&&(this.selectionsGroup.visible=!0,this._consoleCallBack&&this._consoleCallBack("显示框选!"))}},{key:"hide",value:function(){!0===this.selectionsGroup.visible&&(this.selectionsGroup.visible=!1,this._consoleCallBack&&this._consoleCallBack("隐藏框选!"))}},{key:"addSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:km.TYPE_POLYGON,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=t||this.selectionColor;return this.curSelection=new km(e,n),this.curSelection.viewer=this.viewer,this.selectionsGroup.add(this.curSelection),this.curSelection}},{key:"removeSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;this.selectionsGroup.children.length>0&&(-1===e&&(e=this.selectionsGroup.children.length-1),this.selectionsGroup.children.splice(e,1),this.curSelection=null,this._consoleCallBack&&this._consoleCallBack("删除成功!"))}},{key:"clearSelection",value:function(){this.selectionsGroup.children.splice(0,this.selectionsGroup.children.length)}},{key:"loadJson",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SelectionData",t=localStorage.getItem(e);if(t){t=JSON.parse(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"SelectionData",t=[],n=0;n0&&void 0!==arguments[0]?arguments[0]:-1;this.flyLinesGroup.children.length>0&&(-1===e&&(e=this.flyLinesGroup.children.length-1),this.flyLinesGroup.children.splice(e,1),this.curFlyLine=null,this._consoleCallBack&&this._consoleCallBack("删除成功!"))}},{key:"clearFlyLine",value:function(){this.flyLinesGroup.children.splice(0,this.flyLinesGroup.children.length)}},{key:"loadJson",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"FlyLineData",t=localStorage.getItem(e);if(t){t=JSON.parse(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"FlyLineData",t=[],n=0;n=3){var n=new kf(this.viewer),i=new CA;i.moveTo(t[0].x,t[0].z);for(var r=1;r=i?(r=o)*i>a.height&&(r=s):(r=s)*e>a.width&&(r=o)}n.orthographicCamera=new FA(n.viewer.domElement.width/-2,n.viewer.domElement.width/2,n.viewer.domElement.height/2,n.viewer.domElement.height/-2,.1,1e7),n.orthographicCamera.zoom=r,n.orthographicCamera.updateProjectionMatrix(),n.targetMesh=new Ei(new $i(e,i),new Nn({map:n.texture,transparent:!0})),t.renderer.render(n.targetMesh,n.orthographicCamera);var l=t.renderer.domElement.toDataURL(),A=new Image;A.src=l;var c=window.open("","_blank");c.document.write(A.outerHTML),c.document.close()}}}return A(e,[{key:"addPanel",value:function(t,n){var i=new e.Panel(t,n,"#0ff");return this.container.appendChild(i.dom),i}},{key:"update",value:function(){Gm++;var e=0,t=0,n=0,i=0,r=0,a=0,o=[],s=[];this.visible&&(this.viewer.scene.traverse((function(l){(n++,l.isMesh)&&(e++,l.isSkinnedMesh&&t++,s.includes(l.geometry)||s.push(l.geometry),l.geometry.attributes&&l.geometry.attributes.position?i+=l.geometry.attributes.position.count:l.geometry.vertices&&(i+=l.geometry.vertices.length),l.geometry.index?r+=l.geometry.index.count:l.geometry.faces&&(r+=l.geometry.faces.length),l.material&&(Array.isArray(l.material)?l.material:[l.material]).forEach((function(e){o.includes(e.id)||(a++,o.push(e.id))})))})),this.facePanel.update(r),this.verticesPanel.update(i),this.meshPanel.update(e),this.skinnedMeshPanel.update(t),this.materialPanel.update(a),this.nodePanel.update(n));var l=(performance||Date).now();if(this.msPanel.update(l-zm,!0),l>=Qm+1e3&&(this.fpsPanel.update(1e3*Gm/(l-Qm),!0),Qm=l,Gm=0,this.memPanel)){var A=performance.memory;this.memPanel.update(A.usedJSHeapSize/1048576,!0)}this.targetPanel.update(this.texture?"展示纹理":void 0),zm=l}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=e,this.container.style.display=e?"flex":"none"}},{key:"formatBytes",value:function(e,t){if(0===e)return"0 bytes";var n=t<0?0:t,i=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,i)).toFixed(n))+" "+["bytes","KB","MB"][i]}}]),e}();Hm.Panel=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i=1/0,r=0,a=Math.round,o=a(window.devicePixelRatio||1),s=140*o,l=20*o,A=3*o,c=4*o,h=document.createElement("canvas");h.width=s,h.height=l,h.style.cssText="width:140px;height:20px;";var u=h.getContext("2d");return u.font=12*o+"px Helvetica,Arial,sans-serif",u.textBaseline="top",u.clearRect(0,0,s,l),u.fillStyle=n,u.fillText(e,A,c),{dom:h,update:function(o,h){i=Math.min(i,o),r=Math.max(r,o),u.globalAlpha=1,u.clearRect(0,0,s,l),u.fillStyle=n,u.fillText((void 0!==o?e+(isNaN(o)?o:a(o)):"")+" "+t+(h?" ("+a(i)+"-"+a(r)+")":""),A,c)}}};var Vm,jm,Wm=function(){function e(t){var n=this;s(this,e),this.stream=t.captureStream(60),this.recorder=new MediaRecorder(this.stream,{mimeType:"video/webm;codecs=h264"}),this.allChunks=[],this.recorder.ondataavailable=function(e){n.allChunks.push(e.data)},this.element=document.createElement("div"),t.parentElement.appendChild(this.element),this.element.style.cssText="display: none;flex-direction: row;align-items: center;gap: 5px;background: #000000b5;position: absolute;top:0px;padding: 5px;left: 50%;transform: translateX(-50%);font-size: 12px;color: white;",this.element.innerHTML='正在录制 00:00',this.tip=this.element.querySelector("#label"),this.interval=null,this._timer=this._timer.bind(this),this.duration=0,this.timeLabel=""}return A(e,[{key:"start",value:function(){this._stop(),this.interval=setInterval(this._timer,1e3),this.tip.innerHTML="正在录制 00:00",this.duration=0,this.tipVisible=!0,this.allChunks=[],this.recorder.start(10)}},{key:"stop",value:function(){this._stop(),this.tip.innerHTML="录制完成 "+this.timeLabel}},{key:"_stop",value:function(){this.interval&&clearInterval(this.interval),"recording"===this.recorder.state&&this.recorder.stop()}},{key:"download",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"录屏";if(this.allChunks.length>0){var t=document.createElement("a");t.style.display="none";var n=new Blob(this.allChunks),i=window.URL.createObjectURL(n);t.href=i,t.download=e+".webm",document.body.appendChild(t),t.click(),t.remove()}else console.warn("无数据")}},{key:"preview",value:function(){if(this.allChunks.length>0){var e=new Blob(this.allChunks),t=window.URL.createObjectURL(e),n=document.createElement("video");n.style.cssText="max-width: 80%;max-height: 80%",n.controls=!0,n.src=t;var i=window.open("","_blank");i.document.write(n.outerHTML),i.document.close()}else console.warn("无数据")}},{key:"exit",value:function(){this.stop(),this.allChunks=[],this.tipVisible=!1}},{key:"_timer",value:function(){this.duration++,this.timeLabel="";var e=parseInt(this.duration/60),t=this.duration%60;this.timeLabel+=(e>9?e:"0"+e)+":",this.timeLabel+=t>9?t:"0"+t,this.tip.innerHTML="正在录制 "+this.timeLabel}},{key:"tipVisible",set:function(e){this.element.style.display=e?"flex":"none"}}]),e}(),Xm=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,e,r)).isViewer=!0,i._debug=!1,i._mapLoader=null,!r.isMap&&i.initialize(r),i}return A(n,[{key:"screenShot",get:function(){console.warn("viewer.screenShot has been removed, use AMRT.ScreenHelper.screenShot(viewer) instead.")}},{key:"encircleScreenShot",get:function(){console.warn("viewer.screenShot has been removed, use AMRT.ScreenHelper.encircleScreenShot(viewer) instead.")}},{key:"intersectObjects",get:function(){return this.picker.intersectObjects.bind(this.picker)}},{key:"intersectObject",get:function(){return this.picker.intersectObject.bind(this.picker)}},{key:"intersectModels",get:function(){return this.picker.intersectModels.bind(this.picker)}},{key:"screenToVector",get:function(){return this.picker.screenToVector.bind(this.picker)}},{key:"vectorToScreen",get:function(){return this.picker.vectorToScreen.bind(this.picker)}},{key:"enableOutline",get:function(){return this.composer.enableOutline},set:function(e){this.composer.enableOutline=e}},{key:"outline",get:function(){return this.composer.outline}},{key:"enableUnrealBloom",get:function(){return this.composer.enableUnrealBloom},set:function(e){this.composer.enableUnrealBloom=e}},{key:"unrealBloom",get:function(){return this.composer.unrealBloom}},{key:"enableDof",get:function(){return this.composer.enableDof},set:function(e){this.composer.enableDof=e}},{key:"dof",get:function(){return this.composer.dof}},{key:"enableSSAO",get:function(){return this.composer.enableSSAO},set:function(e){this.composer.enableSSAO=e}},{key:"ssao",get:function(){return this.composer.ssao}},{key:"enableColorAdjustment",get:function(){return this.composer.enableColorAdjustment},set:function(e){this.composer.enableColorAdjustment=e}},{key:"colorAdjustment",get:function(){return this.composer.colorAdjustment}},{key:"enableVignette",get:function(){return this.composer.enableVignette},set:function(e){this.composer.enableVignette=e}},{key:"vignette",get:function(){return this.composer.vignette}},{key:"enableCircleSweep",get:function(){return this.composer.enableCircleSweep},set:function(e){this.composer.enableCircleSweep=e}},{key:"circleSweep",get:function(){return this.composer.circleSweep}},{key:"enableSSR",get:function(){return this.composer.enableSSR},set:function(e){this.composer.enableSSR=e}},{key:"ssr",get:function(){return this.composer.ssr}},{key:"mapLoader",get:function(){return this._mapLoader||(this._mapLoader=new Kf(this)),this._mapLoader}},{key:"materialEditor",get:function(){return Vm||(Vm=new wm(this)),Vm}},{key:"operator",get:function(){return jm||(jm=new sm(this)),jm}},{key:"enableTransform",get:function(){return Boolean(this.transform&&this.transform.enabled)},set:function(e){e?(!this.transform&&(this.transform=new bm(this)),this.transform.enabled=!0,this.transform.setMode(Mm.TRANSLATE)):(this.transform.enabled=!1,this.transform.setTarget(null))}},{key:"hotspot",get:function(){return this.moduleManager.hotspot}},{key:"basicModel",get:function(){return this._basicModel||(this._basicModel=new Pm(this)),this._basicModel}},{key:"basicEditor",get:function(){return this._basicEditor||(this._basicEditor=new Nm(this)),this._basicEditor}},{key:"initialize",value:function(e){this.picker=new xm(this),b(u(n.prototype),"initialize",this).call(this,e)}},{key:"dispose",value:function(){this.enableOutline=!1,this.enableDof=!1,this.enableUnrealBloom=!1,b(u(n.prototype),"dispose",this).call(this)}},{key:"debug",get:function(){return this._debug},set:function(e){var t=this;this.debugPanel||(this.debugPanel=new Hm(this),this.addEventListener("update",(function(){t.debugPanel.update()}))),this.debugPanel.visible=this._debug=e}},{key:"recorder",get:function(){return this._recorder||(this._recorder=new Wm(this.domElement)),this._recorder}}]),n}(tm),Ym=A((function e(){s(this,e)}));Ym.CENTER="center",Ym.LEFT="left",Ym.RIGHT="right",Ym.TOP="top",Ym.BOTTOM="bottom",Ym.TOP_LEFT="top-left",Ym.TOP_RIGHT="top-right",Ym.BOTTOM_LEFT="bottom-left",Ym.BOTTOM_RIGHT="bottom-right";var Km=function(){function e(t){var n=this;s(this,e),this.position=t.position.clone(),this.objectId=t.objectId,this.worldPos=t.worldPos,this.cameraView=t.cameraView,this.cameraView&&this.cameraView.position&&this.cameraView.target&&(this.cameraView.position=Array.isArray(this.cameraView.position)?(new at).fromArray(this.cameraView.position):(new at).copy(this.cameraView.position),this.cameraView.target=Array.isArray(this.cameraView.target)?(new at).fromArray(this.cameraView.target):(new at).copy(this.cameraView.target)),this.element=t.element,this.onUpdate=t.onUpdate,this.userData=t.userData||{},this.screenCoord=void 0,this.onclick=t.onclick,this.anchor=t.anchor||Ym.BOTTOM,this.offset=t.offset||new tt,this.hided=!1,this.focus=function(){},this.complete=t.complete,this.flicker=t.flicker,this.flicker&&this.showFlicker(),this.element.onclick=function(e){n.focus(),n.onclick&&n.onclick(e)}}return A(e,[{key:"showFlicker",value:function(){var e=this;this.interval||(this.interval=setInterval((function(){e.element.parentElement&&!e.hided&&(e.element.style.display="none"==e.element.style.display?"block":"none")}),500))}},{key:"stopFlicker",value:function(){this.interval&&(clearInterval(this.interval),this.interval=null,this.element.style.display=this.hided?"none":"block")}},{key:"updateScreenCoords",value:function(e){if(e){this.screenCoord=e;var t=this._convertAnchor();this.element.style.left=e.x+t.x+this.offset.x+"px",this.element.style.top=e.y+t.y+this.offset.y+"px"}}},{key:"hide",value:function(){this.element.style.display="none",this.hided=!0}},{key:"show",value:function(){this.element.style.display="block",this.hided=!1}},{key:"remove",value:function(){this.element.parentElement&&this.element.parentElement.removeChild(this.element),this.stopFlicker()}},{key:"toJSON",value:function(){return{position:this.worldPos?this.worldPos.toArray():this.position.toArray(),objectId:this.objectId,cameraView:{position:this.cameraView&&this.cameraView.position?this.cameraView.position.toArray():null,target:this.cameraView&&this.cameraView.target?this.cameraView.target.toArray():null},element:(new XMLSerializer).serializeToString(this.element),userData:this.userData}}},{key:"_convertAnchor",value:function(){var e=this.element.getBoundingClientRect(),t=new tt;switch(this.anchor){case"center":t.set(-e.width/2,-e.height/2);break;case"top":t.set(-e.width/2,0);break;case"bottom":t.set(-e.width/2,-e.height);break;case"left":t.set(0,-e.height/2);break;case"right":t.set(-e.width,-e.height/2);break;case"top-left":t.set(0,0);break;case"top-right":t.set(-e.width,0);break;case"bottom-left":t.set(0,-e.height);break;case"bottom-right":t.set(-e.width,-e.height)}return t}}]),e}(),Zm=function(){function e(){s(this,e),this.spots=[],this._visible=!0,this.name=""}return A(e,[{key:"visible",get:function(){return this._visible},set:function(e){this._setVisible(e)}},{key:"hide",value:function(){this._setVisible(0)}},{key:"show",value:function(){this._setVisible(1)}},{key:"add",value:function(e){this.spots.push(e),e.parent=this}},{key:"remove",value:function(e){this.spots.remove(e),e.remove(),e.parent=null}},{key:"removeAll",value:function(){this.spots.forEach((function(e){e.remove()})),this.spots=[]}},{key:"_setVisible",value:function(e){this._visible=e,this.spots.forEach((function(t){e?t.show():t.hide()}))}},{key:"toJSON",value:function(){var e=[];return this.spots.forEach((function(t){e.push(t.toJSON())})),e}}]),e}();"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Jm(e){var t={exports:{}};return e(t,t.exports),t.exports +/*! + * html2canvas 1.4.1 + * Copyright (c) 2022 Niklas von Hertzen + * Released under MIT License + */}var qm=Jm((function(e,t){e.exports=function(){ +/*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ +var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=55296&&r<=56319&&n>10),o%1024+56320)),(r+1===n||i.length>16384)&&(a+=String.fromCharCode.apply(String,i),i.length=0)}return a},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="undefined"==typeof Uint8Array?[]:new Uint8Array(256),d=0;d>4,c[l++]=(15&i)<<4|r>>2,c[l++]=(3&r)<<6|63&a;return A},g=function(e){for(var t=e.length,n=[],i=0;i>w,C=(1<>w)+32,E=65536>>x,S=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>w])<>w)])<>x),t=this.index[t],t+=e>>w&S,t=((t=this.index[t])<U?(r.push(!0),o-=U):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return i.push(a),n.push(Z);if(o===N||o===j){if(0===a)return i.push(a),n.push(ce);var s=n[a-1];return-1===ke.indexOf(s)?(i.push(i[a-1]),n.push(s)):(i.push(a),n.push(ce))}return i.push(a),o===he?n.push("strict"===t?te:ve):o===be||o===Ae?n.push(ce):o===Me?e>=131072&&e<=196605||e>=196608&&e<=262141?n.push(ve):n.push(ce):void n.push(o)})),[i,n,r]},Re=function(e,t,n,i){var r=i[n];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var a=n;a<=i.length;){if((l=i[++a])===t)return!0;if(l!==V)break}if(r===V)for(a=n;a>0;){var o=i[--a];if(Array.isArray(e)?-1!==e.indexOf(o):e===o)for(var s=n;s<=i.length;){var l;if((l=i[++s])===t)return!0;if(l!==V)break}if(o!==V)break}return!1},Oe=function(e,t){for(var n=e;n>=0;){var i=t[n];if(i!==V)return i;n--}return 0},Ne=function(e,t,n,i,r){if(0===n[i])return Ee;var a=i-1;if(Array.isArray(r)&&!0===r[a])return Ee;var o=a-1,s=a+1,l=t[a],A=o>=0?t[o]:0,c=t[s];if(l===R&&c===O)return Ee;if(-1!==Ie.indexOf(l))return Be;if(-1!==Ie.indexOf(c))return Ee;if(-1!==Le.indexOf(c))return Ee;if(Oe(a,t)===G)return Se;if(Te.get(e[a])===j)return Ee;if((l===ue||l===de)&&Te.get(e[s])===j)return Ee;if(l===Q||c===Q)return Ee;if(l===H)return Ee;if(-1===[V,X,K].indexOf(l)&&c===H)return Ee;if(-1!==[J,q,$,re,le].indexOf(c))return Ee;if(Oe(a,t)===ne)return Ee;if(Re(ie,ne,a,t))return Ee;if(Re([J,q],te,a,t))return Ee;if(Re(W,W,a,t))return Ee;if(l===V)return Se;if(l===ie||c===ie)return Ee;if(c===Z||l===Z)return Se;if(-1!==[X,K,te].indexOf(c)||l===Y)return Ee;if(A===me&&-1!==Ue.indexOf(l))return Ee;if(l===le&&c===me)return Ee;if(c===ee)return Ee;if(-1!==_e.indexOf(c)&&l===ae||-1!==_e.indexOf(l)&&c===ae)return Ee;if(l===se&&-1!==[ve,ue,de].indexOf(c)||-1!==[ve,ue,de].indexOf(l)&&c===oe)return Ee;if(-1!==_e.indexOf(l)&&-1!==Fe.indexOf(c)||-1!==Fe.indexOf(l)&&-1!==_e.indexOf(c))return Ee;if(-1!==[se,oe].indexOf(l)&&(c===ae||-1!==[ne,K].indexOf(c)&&t[s+1]===ae)||-1!==[ne,K].indexOf(l)&&c===ae||l===ae&&-1!==[ae,le,re].indexOf(c))return Ee;if(-1!==[ae,le,re,J,q].indexOf(c))for(var h=a;h>=0;){if((u=t[h])===ae)return Ee;if(-1===[le,re].indexOf(u))break;h--}if(-1!==[se,oe].indexOf(c))for(h=-1!==[J,q].indexOf(l)?o:a;h>=0;){var u;if((u=t[h])===ae)return Ee;if(-1===[le,re].indexOf(u))break;h--}if(ge===l&&-1!==[ge,ye,fe,pe].indexOf(c)||-1!==[ye,fe].indexOf(l)&&-1!==[ye,we].indexOf(c)||-1!==[we,pe].indexOf(l)&&c===we)return Ee;if(-1!==Pe.indexOf(l)&&-1!==[ee,oe].indexOf(c)||-1!==Pe.indexOf(c)&&l===se)return Ee;if(-1!==_e.indexOf(l)&&-1!==_e.indexOf(c))return Ee;if(l===re&&-1!==_e.indexOf(c))return Ee;if(-1!==_e.concat(ae).indexOf(l)&&c===ne&&-1===Ce.indexOf(e[s])||-1!==_e.concat(ae).indexOf(c)&&l===q)return Ee;if(l===xe&&c===xe){for(var d=n[a],f=1;d>0&&t[--d]===xe;)f++;if(f%2!=0)return Ee}return l===ue&&c===de?Ee:Se},ze=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var n=De(e,t.lineBreak),i=n[0],r=n[1],a=n[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[ae,ce,be].indexOf(e)?ve:e})));var o="keep-all"===t.wordBreak?a.map((function(t,n){return t&&e[n]>=19968&&e[n]<=40959})):void 0;return[i,r,o]},Qe=function(){function e(e,t,n,i){this.codePoints=e,this.required=t===Be,this.start=n,this.end=i}return e.prototype.slice=function(){return c.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Ge=function(e,t){var n=A(e),i=ze(n,t),r=i[0],a=i[1],o=i[2],s=n.length,l=0,c=0;return{next:function(){if(c>=s)return{done:!0,value:null};for(var e=Ee;c=Ut&&e<=57},Xt=function(e){return e>=55296&&e<=57343},Yt=function(e){return Wt(e)||e>=Qt&&e<=Ht||e>=Dt&&e<=Ot},Kt=function(e){return e>=Dt&&e<=zt},Zt=function(e){return e>=Qt&&e<=jt},Jt=function(e){return Kt(e)||Zt(e)},qt=function(e){return e>=wt},$t=function(e){return e===Xe||e===Ze||e===Je},en=function(e){return Jt(e)||qt(e)||e===ot},tn=function(e){return en(e)||Wt(e)||e===st},nn=function(e){return e>=Tt&&e<=_t||e===It||e>=Lt&&e<=Ft||e===kt},rn=function(e,t){return e===Ke&&t!==Xe},an=function(e,t,n){return e===st?en(t)||rn(t,n):!!en(e)||!(e!==Ke||!rn(e,t))},on=function(e,t,n){return e===Mt||e===st?!!Wt(t)||t===St&&Wt(n):Wt(e===St?t:e)},sn=function(e){var t=0,n=1;e[t]!==Mt&&e[t]!==st||(e[t]===st&&(n=-1),t++);for(var i=[];Wt(e[t]);)i.push(e[t++]);var r=i.length?parseInt(c.apply(void 0,i),10):0;e[t]===St&&t++;for(var a=[];Wt(e[t]);)a.push(e[t++]);var o=a.length,s=o?parseInt(c.apply(void 0,a),10):0;e[t]!==Gt&&e[t]!==Rt||t++;var l=1;e[t]!==Mt&&e[t]!==st||(e[t]===st&&(l=-1),t++);for(var A=[];Wt(e[t]);)A.push(e[t++]);var h=A.length?parseInt(c.apply(void 0,A),10):0;return n*(r+s*Math.pow(10,-o))*Math.pow(10,l*h)},ln={type:2},An={type:3},cn={type:4},hn={type:13},un={type:8},dn={type:21},fn={type:9},pn={type:10},mn={type:11},vn={type:12},gn={type:14},yn={type:23},wn={type:1},xn={type:25},bn={type:24},Mn={type:26},Cn={type:27},Bn={type:28},En={type:29},Sn={type:31},Tn={type:32},_n=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(A(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Tn;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case qe:return this.consumeStringToken(qe);case et:var t=this.peekCodePoint(0),n=this.peekCodePoint(1),i=this.peekCodePoint(2);if(tn(t)||rn(n,i)){var r=an(t,n,i)?Ve:He;return{type:5,value:this.consumeName(),flags:r}}break;case tt:if(this.peekCodePoint(0)===$e)return this.consumeCodePoint(),hn;break;case it:return this.consumeStringToken(it);case rt:return ln;case at:return An;case bt:if(this.peekCodePoint(0)===$e)return this.consumeCodePoint(),gn;break;case Mt:if(on(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Ct:return cn;case st:var a=e,o=this.peekCodePoint(0),s=this.peekCodePoint(1);if(on(a,o,s))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(an(a,o,s))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(o===st&&s===ct)return this.consumeCodePoint(),this.consumeCodePoint(),bn;break;case St:if(on(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Ye:if(this.peekCodePoint(0)===bt)for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(l===bt&&(l=this.consumeCodePoint())===Ye)return this.consumeToken();if(l===Pt)return this.consumeToken()}break;case Bt:return Mn;case Et:return Cn;case At:if(this.peekCodePoint(0)===lt&&this.peekCodePoint(1)===st&&this.peekCodePoint(2)===st)return this.consumeCodePoint(),this.consumeCodePoint(),xn;break;case ht:var A=this.peekCodePoint(0),h=this.peekCodePoint(1),u=this.peekCodePoint(2);if(an(A,h,u))return{type:7,value:this.consumeName()};break;case ut:return Bn;case Ke:if(rn(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case dt:return En;case ft:if(this.peekCodePoint(0)===$e)return this.consumeCodePoint(),un;break;case pt:return mn;case vt:return vn;case Nt:case Vt:var d=this.peekCodePoint(0),f=this.peekCodePoint(1);return d!==Mt||!Yt(f)&&f!==mt||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case gt:if(this.peekCodePoint(0)===$e)return this.consumeCodePoint(),fn;if(this.peekCodePoint(0)===gt)return this.consumeCodePoint(),dn;break;case yt:if(this.peekCodePoint(0)===$e)return this.consumeCodePoint(),pn;break;case Pt:return Tn}return $t(e)?(this.consumeWhiteSpace(),Sn):Wt(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):en(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:c(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Yt(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var n=!1;t===mt&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n)return{type:30,start:parseInt(c.apply(void 0,e.map((function(e){return e===mt?Ut:e}))),16),end:parseInt(c.apply(void 0,e.map((function(e){return e===mt?Ht:e}))),16)};var i=parseInt(c.apply(void 0,e),16);if(this.peekCodePoint(0)===st&&Yt(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Yt(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:i,end:parseInt(c.apply(void 0,r),16)}}return{type:30,start:i,end:i}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&this.peekCodePoint(0)===rt?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===rt?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Pt)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===it||t===qe){var n=this.consumeStringToken(this.consumeCodePoint());return 0===n.type&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Pt||this.peekCodePoint(0)===at)?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),yn)}for(;;){var i=this.consumeCodePoint();if(i===Pt||i===at)return{type:22,value:c.apply(void 0,e)};if($t(i))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Pt||this.peekCodePoint(0)===at?(this.consumeCodePoint(),{type:22,value:c.apply(void 0,e)}):(this.consumeBadUrlRemnants(),yn);if(i===qe||i===it||i===rt||nn(i))return this.consumeBadUrlRemnants(),yn;if(i===Ke){if(!rn(i,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),yn;e.push(this.consumeEscapedCodePoint())}else e.push(i)}},e.prototype.consumeWhiteSpace=function(){for(;$t(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===at||e===Pt)return;rn(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t=5e4,n="";e>0;){var i=Math.min(t,e);n+=c.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),n},e.prototype.consumeStringToken=function(e){for(var t="",n=0;;){var i=this._value[n];if(i===Pt||void 0===i||i===e)return{type:0,value:t+=this.consumeStringSlice(n)};if(i===Xe)return this._value.splice(0,n),wn;if(i===Ke){var r=this._value[n+1];r!==Pt&&void 0!==r&&(r===Xe?(t+=this.consumeStringSlice(n),n=-1,this._value.shift()):rn(i,r)&&(t+=this.consumeStringSlice(n),t+=c(this.consumeEscapedCodePoint()),n=-1))}n++}},e.prototype.consumeNumber=function(){var e=[],t=je,n=this.peekCodePoint(0);for(n!==Mt&&n!==st||e.push(this.consumeCodePoint());Wt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);var i=this.peekCodePoint(1);if(n===St&&Wt(i))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=We;Wt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),i=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((n===Gt||n===Rt)&&((i===Mt||i===st)&&Wt(r)||Wt(i)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=We;Wt(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[sn(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],n=e[1],i=this.peekCodePoint(0),r=this.peekCodePoint(1),a=this.peekCodePoint(2);return an(i,r,a)?{type:15,number:t,flags:n,unit:this.consumeName()}:i===nt?(this.consumeCodePoint(),{type:16,number:t,flags:n}):{type:17,number:t,flags:n}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Yt(e)){for(var t=c(e);Yt(this.peekCodePoint(0))&&t.length<6;)t+=c(this.consumeCodePoint());$t(this.peekCodePoint(0))&&this.consumeCodePoint();var n=parseInt(t,16);return 0===n||Xt(n)||n>1114111?xt:n}return e===Pt?xt:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(tn(t))e+=c(t);else{if(!rn(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=c(this.consumeEscapedCodePoint())}}},e}(),In=function(){function e(e){this._tokens=e}return e.create=function(t){var n=new _n;return n.write(t),new e(n.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},n=this.consumeToken();;){if(32===n.type||Nn(n,e))return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue()),n=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var n=this.consumeToken();if(32===n.type||3===n.type)return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Tn:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Ln=function(e){return 15===e.type},Fn=function(e){return 17===e.type},kn=function(e){return 20===e.type},Pn=function(e){return 0===e.type},Un=function(e,t){return kn(e)&&e.value===t},Dn=function(e){return 31!==e.type},Rn=function(e){return 31!==e.type&&4!==e.type},On=function(e){var t=[],n=[];return e.forEach((function(e){if(4===e.type){if(0===n.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(n),void(n=[])}31!==e.type&&n.push(e)})),n.length&&t.push(n),t},Nn=function(e,t){return 11===t&&12===e.type||28===t&&29===e.type||2===t&&3===e.type},zn=function(e){return 17===e.type||15===e.type},Qn=function(e){return 16===e.type||zn(e)},Gn=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},Hn={type:17,number:0,flags:je},Vn={type:16,number:50,flags:je},jn={type:16,number:100,flags:je},Wn=function(e,t,n){var i=e[0],r=e[1];return[Xn(i,t),Xn(void 0!==r?r:i,n)]},Xn=function(e,t){if(16===e.type)return e.number/100*t;if(Ln(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Yn="deg",Kn="grad",Zn="rad",Jn="turn",qn={name:"angle",parse:function(e,t){if(15===t.type)switch(t.unit){case Yn:return Math.PI*t.number/180;case Kn:return Math.PI/200*t.number;case Zn:return t.number;case Jn:return 2*Math.PI*t.number}throw new Error("Unsupported angle type")}},$n=function(e){return 15===e.type&&(e.unit===Yn||e.unit===Kn||e.unit===Zn||e.unit===Jn)},ei=function(e){switch(e.filter(kn).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Hn,Hn];case"to top":case"bottom":return ti(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Hn,jn];case"to right":case"left":return ti(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[jn,jn];case"to bottom":case"top":return ti(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[jn,Hn];case"to left":case"right":return ti(270)}return 0},ti=function(e){return Math.PI*e/180},ni={name:"color",parse:function(e,t){if(18===t.type){var n=ci[t.name];if(void 0===n)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return n(e,t.values)}if(5===t.type){if(3===t.value.length){var i=t.value.substring(0,1),r=t.value.substring(1,2),a=t.value.substring(2,3);return ai(parseInt(i+i,16),parseInt(r+r,16),parseInt(a+a,16),1)}if(4===t.value.length){i=t.value.substring(0,1),r=t.value.substring(1,2),a=t.value.substring(2,3);var o=t.value.substring(3,4);return ai(parseInt(i+i,16),parseInt(r+r,16),parseInt(a+a,16),parseInt(o+o,16)/255)}if(6===t.value.length)return i=t.value.substring(0,2),r=t.value.substring(2,4),a=t.value.substring(4,6),ai(parseInt(i,16),parseInt(r,16),parseInt(a,16),1);if(8===t.value.length)return i=t.value.substring(0,2),r=t.value.substring(2,4),a=t.value.substring(4,6),o=t.value.substring(6,8),ai(parseInt(i,16),parseInt(r,16),parseInt(a,16),parseInt(o,16)/255)}if(20===t.type){var s=ui[t.value.toUpperCase()];if(void 0!==s)return s}return ui.TRANSPARENT}},ii=function(e){return 0==(255&e)},ri=function(e){var t=255&e,n=255&e>>8,i=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+i+","+n+","+t/255+")":"rgb("+r+","+i+","+n+")"},ai=function(e,t,n,i){return(e<<24|t<<16|n<<8|Math.round(255*i)<<0)>>>0},oi=function(e,t){if(17===e.type)return e.number;if(16===e.type){var n=3===t?1:255;return 3===t?e.number/100*n:Math.round(e.number/100*n)}return 0},si=function(e,t){var n=t.filter(Rn);if(3===n.length){var i=n.map(oi),r=i[0],a=i[1],o=i[2];return ai(r,a,o,1)}if(4===n.length){var s=n.map(oi),l=(r=s[0],a=s[1],o=s[2],s[3]);return ai(r,a,o,l)}return 0};function li(e,t,n){return n<0&&(n+=1),n>=1&&(n-=1),n<1/6?(t-e)*n*6+e:n<.5?t:n<2/3?6*(t-e)*(2/3-n)+e:e}var Ai=function(e,t){var n=t.filter(Rn),i=n[0],r=n[1],a=n[2],o=n[3],s=(17===i.type?ti(i.number):qn.parse(e,i))/(2*Math.PI),l=Qn(r)?r.number/100:0,A=Qn(a)?a.number/100:0,c=void 0!==o&&Qn(o)?Xn(o,1):1;if(0===l)return ai(255*A,255*A,255*A,1);var h=A<=.5?A*(l+1):A+l-A*l,u=2*A-h,d=li(u,h,s+1/3),f=li(u,h,s),p=li(u,h,s-1/3);return ai(255*d,255*f,255*p,c)},ci={hsl:Ai,hsla:Ai,rgb:si,rgba:si},hi=function(e,t){return ni.parse(e,In.create(t).parseComponentValue())},ui={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},di={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(kn(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},fi={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},pi=function(e,t){var n=ni.parse(e,t[0]),i=t[1];return i&&Qn(i)?{color:n,stop:i}:{color:n,stop:null}},mi=function(e,t){var n=e[0],i=e[e.length-1];null===n.stop&&(n.stop=Hn),null===i.stop&&(i.stop=jn);for(var r=[],a=0,o=0;oa?r.push(l):r.push(a),a=l}else r.push(null)}var A=null;for(o=0;oe.optimumDistance)?{optimumCorner:t,optimumDistance:s}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},xi=function(e,t,n,i,r){var a=0,o=0;switch(e.size){case 0:0===e.shape?a=o=Math.min(Math.abs(t),Math.abs(t-i),Math.abs(n),Math.abs(n-r)):1===e.shape&&(a=Math.min(Math.abs(t),Math.abs(t-i)),o=Math.min(Math.abs(n),Math.abs(n-r)));break;case 2:if(0===e.shape)a=o=Math.min(yi(t,n),yi(t,n-r),yi(t-i,n),yi(t-i,n-r));else if(1===e.shape){var s=Math.min(Math.abs(n),Math.abs(n-r))/Math.min(Math.abs(t),Math.abs(t-i)),l=wi(i,r,t,n,!0),A=l[0],c=l[1];o=s*(a=yi(A-t,(c-n)/s))}break;case 1:0===e.shape?a=o=Math.max(Math.abs(t),Math.abs(t-i),Math.abs(n),Math.abs(n-r)):1===e.shape&&(a=Math.max(Math.abs(t),Math.abs(t-i)),o=Math.max(Math.abs(n),Math.abs(n-r)));break;case 3:if(0===e.shape)a=o=Math.max(yi(t,n),yi(t,n-r),yi(t-i,n),yi(t-i,n-r));else if(1===e.shape){s=Math.max(Math.abs(n),Math.abs(n-r))/Math.max(Math.abs(t),Math.abs(t-i));var h=wi(i,r,t,n,!1);A=h[0],c=h[1],o=s*(a=yi(A-t,(c-n)/s))}}return Array.isArray(e.size)&&(a=Xn(e.size[0],i),o=2===e.size.length?Xn(e.size[1],r):a),[a,o]},bi=function(e,t){var n=ti(180),i=[];return On(t).forEach((function(t,r){if(0===r){var a=t[0];if(20===a.type&&"to"===a.value)return void(n=ei(t));if($n(a))return void(n=qn.parse(e,a))}var o=pi(e,t);i.push(o)})),{angle:n,stops:i,type:1}},Mi=function(e,t){var n=ti(180),i=[];return On(t).forEach((function(t,r){if(0===r){var a=t[0];if(20===a.type&&-1!==["top","left","right","bottom"].indexOf(a.value))return void(n=ei(t));if($n(a))return void(n=(qn.parse(e,a)+ti(270))%ti(360))}var o=pi(e,t);i.push(o)})),{angle:n,stops:i,type:1}},Ci=function(e,t){var n=ti(180),i=[],r=1,a=0,o=3,s=[];return On(t).forEach((function(t,n){var a=t[0];if(0===n){if(kn(a)&&"linear"===a.value)return void(r=1);if(kn(a)&&"radial"===a.value)return void(r=2)}if(18===a.type)if("from"===a.name){var o=ni.parse(e,a.values[0]);i.push({stop:Hn,color:o})}else if("to"===a.name)o=ni.parse(e,a.values[0]),i.push({stop:jn,color:o});else if("color-stop"===a.name){var s=a.values.filter(Rn);if(2===s.length){o=ni.parse(e,s[1]);var l=s[0];Fn(l)&&i.push({stop:{type:16,number:100*l.number,flags:l.flags},color:o})}}})),1===r?{angle:(n+ti(180))%ti(360),stops:i,type:r}:{size:o,shape:a,stops:i,position:s,type:r}},Bi="closest-side",Ei="farthest-side",Si="closest-corner",Ti="farthest-corner",_i="circle",Ii="ellipse",Li="cover",Fi="contain",ki=function(e,t){var n=0,i=3,r=[],a=[];return On(t).forEach((function(t,o){var s=!0;if(0===o){var l=!1;s=t.reduce((function(e,t){if(l)if(kn(t))switch(t.value){case"center":return a.push(Vn),e;case"top":case"left":return a.push(Hn),e;case"right":case"bottom":return a.push(jn),e}else(Qn(t)||zn(t))&&a.push(t);else if(kn(t))switch(t.value){case _i:return n=0,!1;case Ii:return n=1,!1;case"at":return l=!0,!1;case Bi:return i=0,!1;case Li:case Ei:return i=1,!1;case Fi:case Si:return i=2,!1;case Ti:return i=3,!1}else if(zn(t)||Qn(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),s)}if(s){var A=pi(e,t);r.push(A)}})),{size:i,shape:n,stops:r,position:a,type:2}},Pi=function(e,t){var n=0,i=3,r=[],a=[];return On(t).forEach((function(t,o){var s=!0;if(0===o?s=t.reduce((function(e,t){if(kn(t))switch(t.value){case"center":return a.push(Vn),!1;case"top":case"left":return a.push(Hn),!1;case"right":case"bottom":return a.push(jn),!1}else if(Qn(t)||zn(t))return a.push(t),!1;return e}),s):1===o&&(s=t.reduce((function(e,t){if(kn(t))switch(t.value){case _i:return n=0,!1;case Ii:return n=1,!1;case Fi:case Bi:return i=0,!1;case Ei:return i=1,!1;case Si:return i=2,!1;case Li:case Ti:return i=3,!1}else if(zn(t)||Qn(t))return Array.isArray(i)||(i=[]),i.push(t),!1;return e}),s)),s){var l=pi(e,t);r.push(l)}})),{size:i,shape:n,stops:r,position:a,type:2}},Ui=function(e){return 1===e.type},Di=function(e){return 2===e.type},Ri={name:"image",parse:function(e,t){if(22===t.type){var n={url:t.value,type:0};return e.cache.addImage(t.value),n}if(18===t.type){var i=zi[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return i(e,t.values)}throw new Error("Unsupported image type "+t.type)}};function Oi(e){return!(20===e.type&&"none"===e.value||18===e.type&&!zi[e.name])}var Ni,zi={"linear-gradient":bi,"-moz-linear-gradient":Mi,"-ms-linear-gradient":Mi,"-o-linear-gradient":Mi,"-webkit-linear-gradient":Mi,"radial-gradient":ki,"-moz-radial-gradient":Pi,"-ms-radial-gradient":Pi,"-o-radial-gradient":Pi,"-webkit-radial-gradient":Pi,"-webkit-gradient":Ci},Qi={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var n=t[0];return 20===n.type&&"none"===n.value?[]:t.filter((function(e){return Rn(e)&&Oi(e)})).map((function(t){return Ri.parse(e,t)}))}},Gi={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(kn(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Hi={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return On(t).map((function(e){return e.filter(Qn)})).map(Gn)}},Vi={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return On(t).map((function(e){return e.filter(kn).map((function(e){return e.value})).join(" ")})).map(ji)}},ji=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Ni||(Ni={}));var Wi,Xi={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return On(t).map((function(e){return e.filter(Yi)}))}},Yi=function(e){return kn(e)||Qn(e)},Ki=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Zi=Ki("top"),Ji=Ki("right"),qi=Ki("bottom"),$i=Ki("left"),er=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return Gn(t.filter(Qn))}}},tr=er("top-left"),nr=er("top-right"),ir=er("bottom-right"),rr=er("bottom-left"),ar=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},or=ar("top"),sr=ar("right"),lr=ar("bottom"),Ar=ar("left"),cr=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Ln(t)?t.number:0}}},hr=cr("top"),ur=cr("right"),dr=cr("bottom"),fr=cr("left"),pr={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},mr={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},vr={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(kn).reduce((function(e,t){return e|gr(t.value)}),0)}},gr=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},yr={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},wr={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(Wi||(Wi={}));var xr,br={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Wi.STRICT:Wi.NORMAL}},Mr={name:"line-height",initialValue:"normal",prefix:!1,type:4},Cr=function(e,t){return kn(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:Qn(e)?Xn(e,t):t},Br={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Ri.parse(e,t)}},Er={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Sr={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Tr=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},_r=Tr("top"),Ir=Tr("right"),Lr=Tr("bottom"),Fr=Tr("left"),kr={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(kn).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},Pr={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Ur=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Dr=Ur("top"),Rr=Ur("right"),Or=Ur("bottom"),Nr=Ur("left"),zr={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Qr={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Gr={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Un(t[0],"none")?[]:On(t).map((function(t){for(var n={color:ui.TRANSPARENT,offsetX:Hn,offsetY:Hn,blur:Hn},i=0,r=0;r1?1:0],this.overflowWrap=xa(e,Pr,t.overflowWrap),this.paddingTop=xa(e,Dr,t.paddingTop),this.paddingRight=xa(e,Rr,t.paddingRight),this.paddingBottom=xa(e,Or,t.paddingBottom),this.paddingLeft=xa(e,Nr,t.paddingLeft),this.paintOrder=xa(e,pa,t.paintOrder),this.position=xa(e,Qr,t.position),this.textAlign=xa(e,zr,t.textAlign),this.textDecorationColor=xa(e,ea,null!==(n=t.textDecorationColor)&&void 0!==n?n:t.color),this.textDecorationLine=xa(e,ta,null!==(i=t.textDecorationLine)&&void 0!==i?i:t.textDecoration),this.textShadow=xa(e,Gr,t.textShadow),this.textTransform=xa(e,Hr,t.textTransform),this.transform=xa(e,Vr,t.transform),this.transformOrigin=xa(e,Yr,t.transformOrigin),this.visibility=xa(e,Kr,t.visibility),this.webkitTextStrokeColor=xa(e,ma,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=xa(e,va,t.webkitTextStrokeWidth),this.wordBreak=xa(e,Zr,t.wordBreak),this.zIndex=xa(e,Jr,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return ii(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return sa(this.display,4)||sa(this.display,33554432)||sa(this.display,268435456)||sa(this.display,536870912)||sa(this.display,67108864)||sa(this.display,134217728)},e}(),ya=function(){function e(e,t){this.content=xa(e,la,t.content),this.quotes=xa(e,ua,t.quotes)}return e}(),wa=function(){function e(e,t){this.counterIncrement=xa(e,Aa,t.counterIncrement),this.counterReset=xa(e,ca,t.counterReset)}return e}(),xa=function(e,t,n){var i=new _n,r=null!=n?n.toString():t.initialValue;i.write(r);var a=new In(i.read());switch(t.type){case 2:var o=a.parseComponentValue();return t.parse(e,kn(o)?o.value:t.initialValue);case 0:return t.parse(e,a.parseComponentValue());case 1:return t.parse(e,a.parseComponentValues());case 4:return a.parseComponentValue();case 3:switch(t.format){case"angle":return qn.parse(e,a.parseComponentValue());case"color":return ni.parse(e,a.parseComponentValue());case"image":return Ri.parse(e,a.parseComponentValue());case"length":var s=a.parseComponentValue();return zn(s)?s:Hn;case"length-percentage":var l=a.parseComponentValue();return Qn(l)?l:Hn;case"time":return qr.parse(e,a.parseComponentValue())}}},ba="data-html2canvas-debug",Ma=function(e){switch(e.getAttribute(ba)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},Ca=function(e,t){var n=Ma(e);return 1===n||t===n},Ba=function(){function e(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Ca(t,3),this.styles=new ga(e,window.getComputedStyle(t,null)),ds(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=s(this.context,t),Ca(t,4)&&(this.flags|=16)}return e}(),Ea="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAg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B+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAg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AAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ta="undefined"==typeof Uint8Array?[]:new Uint8Array(256),_a=0;_a>4,c[l++]=(15&i)<<4|r>>2,c[l++]=(3&r)<<6|63&a;return A},La=function(e){for(var t=e.length,n=[],i=0;i>ka,Ra=(1<>ka)+32,Na=65536>>Pa,za=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>ka])<>ka)])<>Pa),t=this.index[t],t+=e>>ka&za,t=((t=this.index[t])<=55296&&r<=56319&&n>10),o%1024+56320)),(r+1===n||i.length>16384)&&(a+=String.fromCharCode.apply(String,i),i.length=0)}return a},ho=Ha(Ea),uo="×",fo="÷",po=function(e){return ho.get(e)},mo=function(e,t,n){var i=n-2,r=t[i],a=t[n-1],o=t[n];if(a===Za&&o===Ja)return uo;if(a===Za||a===Ja||a===qa)return fo;if(o===Za||o===Ja||o===qa)return fo;if(a===to&&-1!==[to,no,ro,ao].indexOf(o))return uo;if(!(a!==ro&&a!==no||o!==no&&o!==io))return uo;if((a===ao||a===io)&&o===io)return uo;if(o===oo||o===$a)return uo;if(o===eo)return uo;if(a===Ka)return uo;if(a===oo&&o===so){for(;r===$a;)r=t[--i];if(r===so)return uo}if(a===lo&&o===lo){for(var s=0;r===lo;)s++,r=t[--i];if(s%2==0)return uo}return fo},vo=function(e){var t=Ao(e),n=t.length,i=0,r=0,a=t.map(po);return{next:function(){if(i>=n)return{done:!0,value:null};for(var e=uo;io.x||r.y>o.y;return o=r,0===t||s}));return e.body.removeChild(t),s},xo=function(){return void 0!==(new Image).crossOrigin},bo=function(){return"string"==typeof(new XMLHttpRequest).responseType},Mo=function(e){var t=new Image,n=e.createElement("canvas"),i=n.getContext("2d");if(!i)return!1;t.src="data:image/svg+xml,";try{i.drawImage(t,0,0),n.toDataURL()}catch(e){return!1}return!0},Co=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},Bo=function(e){var t=e.createElement("canvas"),n=100;t.width=n,t.height=n;var i=t.getContext("2d");if(!i)return Promise.reject(!1);i.fillStyle="rgb(0, 255, 0)",i.fillRect(0,0,n,n);var r=new Image,a=t.toDataURL();r.src=a;var o=Eo(n,n,0,0,r);return i.fillStyle="red",i.fillRect(0,0,n,n),So(o).then((function(t){i.drawImage(t,0,0);var r=i.getImageData(0,0,n,n).data;i.fillStyle="red",i.fillRect(0,0,n,n);var o=e.createElement("div");return o.style.backgroundImage="url("+a+")",o.style.height=n+"px",Co(r)?So(Eo(n,n,0,0,o)):Promise.reject(!1)})).then((function(e){return i.drawImage(e,0,0),Co(i.getImageData(0,0,n,n).data)})).catch((function(){return!1}))},Eo=function(e,t,n,i,r){var a="http://www.w3.org/2000/svg",o=document.createElementNS(a,"svg"),s=document.createElementNS(a,"foreignObject");return o.setAttributeNS(null,"width",e.toString()),o.setAttributeNS(null,"height",t.toString()),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.setAttributeNS(null,"x",n.toString()),s.setAttributeNS(null,"y",i.toString()),s.setAttributeNS(null,"externalResourcesRequired","true"),o.appendChild(s),s.appendChild(r),o},So=function(e){return new Promise((function(t,n){var i=new Image;i.onload=function(){return t(i)},i.onerror=n,i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))}))},To={get SUPPORT_RANGE_BOUNDS(){var e=yo(document);return Object.defineProperty(To,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=To.SUPPORT_RANGE_BOUNDS&&wo(document);return Object.defineProperty(To,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=Mo(document);return Object.defineProperty(To,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?Bo(document):Promise.resolve(!1);return Object.defineProperty(To,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=xo();return Object.defineProperty(To,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e=bo();return Object.defineProperty(To,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(To,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(To,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},_o=function(){function e(e,t){this.text=e,this.bounds=t}return e}(),Io=function(e,t,n,i){var r=Uo(t,n),a=[],s=0;return r.forEach((function(t){if(n.textDecorationLine.length||t.trim().length>0)if(To.SUPPORT_RANGE_BOUNDS){var r=Fo(i,s,t.length).getClientRects();if(r.length>1){var l=ko(t),A=0;l.forEach((function(t){a.push(new _o(t,o.fromDOMRectList(e,Fo(i,A+s,t.length).getClientRects()))),A+=t.length}))}else a.push(new _o(t,o.fromDOMRectList(e,r)))}else{var c=i.splitText(t.length);a.push(new _o(t,Lo(e,i))),i=c}else To.SUPPORT_RANGE_BOUNDS||(i=i.splitText(t.length));s+=t.length})),a},Lo=function(e,t){var n=t.ownerDocument;if(n){var i=n.createElement("html2canvaswrapper");i.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(i,t);var a=s(e,i);return i.firstChild&&r.replaceChild(i.firstChild,i),a}}return o.EMPTY},Fo=function(e,t,n){var i=e.ownerDocument;if(!i)throw new Error("Node has no owner document");var r=i.createRange();return r.setStart(e,t),r.setEnd(e,t+n),r},ko=function(e){if(To.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return go(e)},Po=function(e,t){if(To.SUPPORT_NATIVE_TEXT_SEGMENTATION){var n=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(n.segment(e)).map((function(e){return e.segment}))}return Ro(e,t)},Uo=function(e,t){return 0!==t.letterSpacing?ko(e):Po(e,t)},Do=[32,160,4961,65792,65793,4153,4241],Ro=function(e,t){for(var n,i=Ge(e,{lineBreak:t.lineBreak,wordBreak:"break-word"===t.overflowWrap?"break-word":t.wordBreak}),r=[],a=function(){if(n.value){var e=n.value.slice(),t=A(e),i="";t.forEach((function(e){-1===Do.indexOf(e)?i+=c(e):(i.length&&r.push(i),r.push(c(e)),i="")})),i.length&&r.push(i)}};!(n=i.next()).done;)a();return r},Oo=function(){function e(e,t,n){this.text=No(t.data,n.textTransform),this.textBounds=Io(e,this.text,n,t)}return e}(),No=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(zo,Qo);case 2:return e.toUpperCase();default:return e}},zo=/(^|\s|:|-|\(|\))([a-z])/g,Qo=function(e,t,n){return e.length>0?t+n.toUpperCase():e},Go=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.src=n.currentSrc||n.src,i.intrinsicWidth=n.naturalWidth,i.intrinsicHeight=n.naturalHeight,i.context.cache.addImage(i.src),i}return t(n,e),n}(Ba),Ho=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.canvas=n,i.intrinsicWidth=n.width,i.intrinsicHeight=n.height,i}return t(n,e),n}(Ba),Vo=function(e){function n(t,n){var i=e.call(this,t,n)||this,r=new XMLSerializer,a=s(t,n);return n.setAttribute("width",a.width+"px"),n.setAttribute("height",a.height+"px"),i.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(n)),i.intrinsicWidth=n.width.baseVal.value,i.intrinsicHeight=n.height.baseVal.value,i.context.cache.addImage(i.svg),i}return t(n,e),n}(Ba),jo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.value=n.value,i}return t(n,e),n}(Ba),Wo=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.start=n.start,i.reversed="boolean"==typeof n.reversed&&!0===n.reversed,i}return t(n,e),n}(Ba),Xo=[{type:15,flags:0,unit:"px",number:3}],Yo=[{type:16,flags:0,number:50}],Ko=function(e){return e.width>e.height?new o(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width0)n.textNodes.push(new Oo(e,r,n.styles));else if(us(r))if(_s(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return os(e,t,n,i)}));else{var o=ss(e,r);o.styles.isVisible()&&(As(r,o,i)?o.flags|=4:cs(o.styles)&&(o.flags|=2),-1!==as.indexOf(r.tagName)&&(o.flags|=8),n.elements.push(o),r.slot,r.shadowRoot?os(e,r.shadowRoot,o,i):Ss(r)||ys(r)||Ts(r)||os(e,r,o,i))}},ss=function(e,t){return Ms(t)?new Go(e,t):xs(t)?new Ho(e,t):ys(t)?new Vo(e,t):ps(t)?new jo(e,t):ms(t)?new Wo(e,t):vs(t)?new ts(e,t):Ts(t)?new ns(e,t):Ss(t)?new is(e,t):Cs(t)?new rs(e,t):new Ba(e,t)},ls=function(e,t){var n=ss(e,t);return n.flags|=4,os(e,t,n,n),n},As=function(e,t,n){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||ws(e)&&n.styles.isTransparent()},cs=function(e){return e.isPositioned()||e.isFloating()},hs=function(e){return e.nodeType===Node.TEXT_NODE},us=function(e){return e.nodeType===Node.ELEMENT_NODE},ds=function(e){return us(e)&&void 0!==e.style&&!fs(e)},fs=function(e){return"object"==typeof e.className},ps=function(e){return"LI"===e.tagName},ms=function(e){return"OL"===e.tagName},vs=function(e){return"INPUT"===e.tagName},gs=function(e){return"HTML"===e.tagName},ys=function(e){return"svg"===e.tagName},ws=function(e){return"BODY"===e.tagName},xs=function(e){return"CANVAS"===e.tagName},bs=function(e){return"VIDEO"===e.tagName},Ms=function(e){return"IMG"===e.tagName},Cs=function(e){return"IFRAME"===e.tagName},Bs=function(e){return"STYLE"===e.tagName},Es=function(e){return"SCRIPT"===e.tagName},Ss=function(e){return"TEXTAREA"===e.tagName},Ts=function(e){return"SELECT"===e.tagName},_s=function(e){return"SLOT"===e.tagName},Is=function(e){return e.tagName.indexOf("-")>0},Ls=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,n=e.counterIncrement,i=e.counterReset,r=!0;null!==n&&n.forEach((function(e){var n=t.counters[e.counter];n&&0!==e.increment&&(r=!1,n.length||n.push(1),n[Math.max(0,n.length-1)]+=e.increment)}));var a=[];return r&&i.forEach((function(e){var n=t.counters[e.counter];a.push(e.counter),n||(n=t.counters[e.counter]=[]),n.push(e.reset)})),a},e}(),Fs={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},ks={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Ps={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Us={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Ds=function(e,t,n,i,r,a){return en?Ks(e,r,a.length>0):i.integers.reduce((function(t,n,r){for(;e>=n;)e-=n,t+=i.values[r];return t}),"")+a},Rs=function(e,t,n,i){var r="";do{n||e--,r=i(e)+r,e/=t}while(e*t>=t);return r},Os=function(e,t,n,i,r){var a=n-t+1;return(e<0?"-":"")+(Rs(Math.abs(e),a,i,(function(e){return c(Math.floor(e%a)+t)}))+r)},Ns=function(e,t,n){void 0===n&&(n=". ");var i=t.length;return Rs(Math.abs(e),i,!1,(function(e){return t[Math.floor(e%i)]}))+n},zs=1,Qs=2,Gs=4,Hs=8,Vs=function(e,t,n,i,r,a){if(e<-9999||e>9999)return Ks(e,4,r.length>0);var o=Math.abs(e),s=r;if(0===o)return t[0]+s;for(var l=0;o>0&&l<=4;l++){var A=o%10;0===A&&sa(a,zs)&&""!==s?s=t[A]+s:A>1||1===A&&0===l||1===A&&1===l&&sa(a,Qs)||1===A&&1===l&&sa(a,Gs)&&e>100||1===A&&l>1&&sa(a,Hs)?s=t[A]+(l>0?n[l-1]:"")+s:1===A&&l>0&&(s=n[l-1]+s),o=Math.floor(o/10)}return(e<0?i:"")+s},js="十百千萬",Ws="拾佰仟萬",Xs="マイナス",Ys="마이너스",Ks=function(e,t,n){var i=n?". ":"",r=n?"、":"",a=n?", ":"",o=n?" ":"";switch(t){case 0:return"•"+o;case 1:return"◦"+o;case 2:return"◾"+o;case 5:var s=Os(e,48,57,!0,i);return s.length<4?"0"+s:s;case 4:return Ns(e,"〇一二三四五六七八九",r);case 6:return Ds(e,1,3999,Fs,3,i).toLowerCase();case 7:return Ds(e,1,3999,Fs,3,i);case 8:return Os(e,945,969,!1,i);case 9:return Os(e,97,122,!1,i);case 10:return Os(e,65,90,!1,i);case 11:return Os(e,1632,1641,!0,i);case 12:case 49:return Ds(e,1,9999,ks,3,i);case 35:return Ds(e,1,9999,ks,3,i).toLowerCase();case 13:return Os(e,2534,2543,!0,i);case 14:case 30:return Os(e,6112,6121,!0,i);case 15:return Ns(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return Ns(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return Vs(e,"零一二三四五六七八九",js,"負",r,Qs|Gs|Hs);case 47:return Vs(e,"零壹貳參肆伍陸柒捌玖",Ws,"負",r,zs|Qs|Gs|Hs);case 42:return Vs(e,"零一二三四五六七八九",js,"负",r,Qs|Gs|Hs);case 41:return Vs(e,"零壹贰叁肆伍陆柒捌玖",Ws,"负",r,zs|Qs|Gs|Hs);case 26:return Vs(e,"〇一二三四五六七八九","十百千万",Xs,r,0);case 25:return Vs(e,"零壱弐参四伍六七八九","拾百千万",Xs,r,zs|Qs|Gs);case 31:return Vs(e,"영일이삼사오육칠팔구","십백천만",Ys,a,zs|Qs|Gs);case 33:return Vs(e,"零一二三四五六七八九","十百千萬",Ys,a,0);case 32:return Vs(e,"零壹貳參四五六七八九","拾百千",Ys,a,zs|Qs|Gs);case 18:return Os(e,2406,2415,!0,i);case 20:return Ds(e,1,19999,Us,3,i);case 21:return Os(e,2790,2799,!0,i);case 22:return Os(e,2662,2671,!0,i);case 22:return Ds(e,1,10999,Ps,3,i);case 23:return Ns(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Ns(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Os(e,3302,3311,!0,i);case 28:return Ns(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return Ns(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return Os(e,3792,3801,!0,i);case 37:return Os(e,6160,6169,!0,i);case 38:return Os(e,4160,4169,!0,i);case 39:return Os(e,2918,2927,!0,i);case 40:return Os(e,1776,1785,!0,i);case 43:return Os(e,3046,3055,!0,i);case 44:return Os(e,3174,3183,!0,i);case 45:return Os(e,3664,3673,!0,i);case 46:return Os(e,3872,3881,!0,i);default:return Os(e,48,57,!0,i)}},Zs="data-html2canvas-ignore",Js=function(){function e(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new Ls,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var n=this,a=$s(e,t);if(!a.contentWindow)return Promise.reject("Unable to find iframe window");var o=e.defaultView.pageXOffset,s=e.defaultView.pageYOffset,l=a.contentWindow,A=l.document,c=nl(a).then((function(){return i(n,void 0,void 0,(function(){var e,n;return r(this,(function(i){switch(i.label){case 0:return this.scrolledElements.forEach(sl),l&&(l.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||l.scrollY===t.top&&l.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(l.scrollX-t.left,l.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(n=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:A.fonts&&A.fonts.ready?[4,A.fonts.ready]:[3,2];case 1:i.sent(),i.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,tl(A)]:[3,4];case 3:i.sent(),i.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(A,n)})).then((function(){return a}))]:[2,a]}}))}))}));return A.open(),A.write(al(document.doctype)+""),ol(this.referenceElement.ownerDocument,o,s),A.replaceChild(A.adoptNode(this.documentElement),A.documentElement),A.close(),c},e.prototype.createElementClone=function(e){if(Ca(e,2),xs(e))return this.createCanvasClone(e);if(bs(e))return this.createVideoClone(e);if(Bs(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Ms(t)&&(Ms(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Is(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return rl(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var n=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),i=e.cloneNode(!1);return i.textContent=n,i}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var n=e.ownerDocument.createElement("img");try{return n.src=e.toDataURL(),n}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var i=e.cloneNode(!1);try{i.width=e.width,i.height=e.height;var r=e.getContext("2d"),a=i.getContext("2d");if(a)if(!this.options.allowTaint&&r)a.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var o=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(o){var s=o.getContextAttributes();!1===(null==s?void 0:s.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}a.drawImage(e,0,0)}return i}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return i},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var n=t.getContext("2d");try{return n&&(n.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||n.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var i=e.ownerDocument.createElement("canvas");return i.width=e.offsetWidth,i.height=e.offsetHeight,i},e.prototype.appendChildNode=function(e,t,n){us(t)&&(Es(t)||t.hasAttribute(Zs)||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&us(t)&&Bs(t)||e.appendChild(this.cloneNode(t,n))},e.prototype.cloneChildNodes=function(e,t,n){for(var i=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(us(r)&&_s(r)&&"function"==typeof r.assignedNodes){var a=r.assignedNodes();a.length&&a.forEach((function(e){return i.appendChildNode(t,e,n)}))}else this.appendChildNode(t,r,n)},e.prototype.cloneNode=function(e,t){if(hs(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var n=e.ownerDocument.defaultView;if(n&&us(e)&&(ds(e)||fs(e))){var i=this.createElementClone(e);i.style.transitionProperty="none";var r=n.getComputedStyle(e),a=n.getComputedStyle(e,":before"),o=n.getComputedStyle(e,":after");this.referenceElement===e&&ds(i)&&(this.clonedReferenceElement=i),ws(i)&&dl(i);var s=this.counters.parse(new wa(this.context,r)),l=this.resolvePseudoContent(e,i,a,Ya.BEFORE);Is(e)&&(t=!0),bs(e)||this.cloneChildNodes(e,i,t),l&&i.insertBefore(l,i.firstChild);var A=this.resolvePseudoContent(e,i,o,Ya.AFTER);return A&&i.appendChild(A),this.counters.pop(s),(r&&(this.options.copyStyles||fs(e))&&!Cs(e)||t)&&rl(r,i),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([i,e.scrollLeft,e.scrollTop]),(Ss(e)||Ts(e))&&(Ss(i)||Ts(i))&&(i.value=e.value),i}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,n,i){var r=this;if(n){var a=n.content,o=t.ownerDocument;if(o&&a&&"none"!==a&&"-moz-alt-content"!==a&&"none"!==n.display){this.counters.parse(new wa(this.context,n));var s=new ya(this.context,n),l=o.createElement("html2canvaspseudoelement");rl(n,l),s.content.forEach((function(t){if(0===t.type)l.appendChild(o.createTextNode(t.value));else if(22===t.type){var n=o.createElement("img");n.src=t.value,n.style.opacity="1",l.appendChild(n)}else if(18===t.type){if("attr"===t.name){var i=t.values.filter(kn);i.length&&l.appendChild(o.createTextNode(e.getAttribute(i[0].value)||""))}else if("counter"===t.name){var a=t.values.filter(Rn),A=a[0],c=a[1];if(A&&kn(A)){var h=r.counters.getCounterValue(A.value),u=c&&kn(c)?Sr.parse(r.context,c.value):3;l.appendChild(o.createTextNode(Ks(h,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(Rn),f=(A=d[0],d[1]);if(c=d[2],A&&kn(A)){var p=r.counters.getCounterValues(A.value),m=c&&kn(c)?Sr.parse(r.context,c.value):3,v=f&&0===f.type?f.value:"",g=p.map((function(e){return Ks(e,m,!1)})).join(v);l.appendChild(o.createTextNode(g))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(o.createTextNode(da(s.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(o.createTextNode(da(s.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(o.createTextNode(t.value))}})),l.className=cl+" "+hl;var A=i===Ya.BEFORE?" "+cl:" "+hl;return fs(t)?t.className.baseValue+=A:t.className+=A,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(Ya||(Ya={}));var qs,$s=function(e,t){var n=e.createElement("iframe");return n.className="html2canvas-container",n.style.visibility="hidden",n.style.position="fixed",n.style.left="-10000px",n.style.top="0px",n.style.border="0",n.width=t.width.toString(),n.height=t.height.toString(),n.scrolling="no",n.setAttribute(Zs,"true"),e.body.appendChild(n),n},el=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},tl=function(e){return Promise.all([].slice.call(e.images,0).map(el))},nl=function(e){return new Promise((function(t,n){var i=e.contentWindow;if(!i)return n("No window assigned for iframe");var r=i.document;i.onload=e.onload=function(){i.onload=e.onload=null;var n=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(n),t(e))}),50)}}))},il=["all","d","content"],rl=function(e,t){for(var n=e.length-1;n>=0;n--){var i=e.item(n);-1===il.indexOf(i)&&t.style.setProperty(i,e.getPropertyValue(i))}return t},al=function(e){var t="";return e&&(t+=""),t},ol=function(e,t,n){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||n!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,n)},sl=function(e){var t=e[0],n=e[1],i=e[2];t.scrollLeft=n,t.scrollTop=i},ll=":before",Al=":after",cl="___html2canvas___pseudoelement_before",hl="___html2canvas___pseudoelement_after",ul='{\n content: "" !important;\n display: none !important;\n}',dl=function(e){fl(e,"."+cl+ll+ul+"\n ."+hl+Al+ul)},fl=function(e,t){var n=e.ownerDocument;if(n){var i=n.createElement("style");i.textContent=t,e.appendChild(i)}},pl=function(){function e(){}return e.getOrigin=function(t){var n=e._link;return n?(n.href=t,n.href=n.href,n.protocol+n.hostname+n.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),ml=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:Ml(e)||wl(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a,o=this;return r(this,(function(r){switch(r.label){case 0:return t=pl.isSameOrigin(e),n=!xl(e)&&!0===this._options.useCORS&&To.SUPPORT_CORS_IMAGES&&!t,i=!xl(e)&&!t&&!Ml(e)&&"string"==typeof this._options.proxy&&To.SUPPORT_CORS_XHR&&!n,t||!1!==this._options.allowTaint||xl(e)||Ml(e)||i||n?(a=e,i?[4,this.proxy(a)]:[3,2]):[2];case 1:a=r.sent(),r.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var i=new Image;i.onload=function(){return e(i)},i.onerror=t,(bl(a)||n)&&(i.crossOrigin="anonymous"),i.src=a,!0===i.complete&&setTimeout((function(){return e(i)}),500),o._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+o._options.imageTimeout+"ms) loading image")}),o._options.imageTimeout)}))];case 3:return[2,r.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,n=this._options.proxy;if(!n)throw new Error("No proxy defined");var i=e.substring(0,256);return new Promise((function(r,a){var o=To.SUPPORT_RESPONSE_TYPE?"blob":"text",s=new XMLHttpRequest;s.onload=function(){if(200===s.status)if("text"===o)r(s.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return a(e)}),!1),e.readAsDataURL(s.response)}else a("Failed to proxy resource "+i+" with status code "+s.status)},s.onerror=a;var l=n.indexOf("?")>-1?"&":"?";if(s.open("GET",""+n+l+"url="+encodeURIComponent(e)+"&responseType="+o),"text"!==o&&s instanceof XMLHttpRequest&&(s.responseType=o),t._options.imageTimeout){var A=t._options.imageTimeout;s.timeout=A,s.ontimeout=function(){return a("Timed out ("+A+"ms) proxying "+i)}}s.send()}))},e}(),vl=/^data:image\/svg\+xml/i,gl=/^data:image\/.*;base64,/i,yl=/^data:image\/.*/i,wl=function(e){return To.SUPPORT_SVG_DRAWING||!Cl(e)},xl=function(e){return yl.test(e)},bl=function(e){return gl.test(e)},Ml=function(e){return"blob"===e.substr(0,4)},Cl=function(e){return"svg"===e.substr(-3).toLowerCase()||vl.test(e)},Bl=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,n){return new e(this.x+t,this.y+n)},e}(),El=function(e,t,n){return new Bl(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n)},Sl=function(){function e(e,t,n,i){this.type=1,this.start=e,this.startControl=t,this.endControl=n,this.end=i}return e.prototype.subdivide=function(t,n){var i=El(this.start,this.startControl,t),r=El(this.startControl,this.endControl,t),a=El(this.endControl,this.end,t),o=El(i,r,t),s=El(r,a,t),l=El(o,s,t);return n?new e(this.start,i,o,l):new e(l,s,a,this.end)},e.prototype.add=function(t,n){return new e(this.start.add(t,n),this.startControl.add(t,n),this.endControl.add(t,n),this.end.add(t,n))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Tl=function(e){return 1===e.type},_l=function(){function e(e){var t=e.styles,n=e.bounds,i=Wn(t.borderTopLeftRadius,n.width,n.height),r=i[0],a=i[1],o=Wn(t.borderTopRightRadius,n.width,n.height),s=o[0],l=o[1],A=Wn(t.borderBottomRightRadius,n.width,n.height),c=A[0],h=A[1],u=Wn(t.borderBottomLeftRadius,n.width,n.height),d=u[0],f=u[1],p=[];p.push((r+s)/n.width),p.push((d+c)/n.width),p.push((a+f)/n.height),p.push((l+h)/n.height);var m=Math.max.apply(Math,p);m>1&&(r/=m,a/=m,s/=m,l/=m,c/=m,h/=m,d/=m,f/=m);var v=n.width-s,g=n.height-h,y=n.width-c,w=n.height-f,x=t.borderTopWidth,b=t.borderRightWidth,M=t.borderBottomWidth,C=t.borderLeftWidth,B=Xn(t.paddingTop,e.bounds.width),E=Xn(t.paddingRight,e.bounds.width),S=Xn(t.paddingBottom,e.bounds.width),T=Xn(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||a>0?Il(n.left+C/3,n.top+x/3,r-C/3,a-x/3,qs.TOP_LEFT):new Bl(n.left+C/3,n.top+x/3),this.topRightBorderDoubleOuterBox=r>0||a>0?Il(n.left+v,n.top+x/3,s-b/3,l-x/3,qs.TOP_RIGHT):new Bl(n.left+n.width-b/3,n.top+x/3),this.bottomRightBorderDoubleOuterBox=c>0||h>0?Il(n.left+y,n.top+g,c-b/3,h-M/3,qs.BOTTOM_RIGHT):new Bl(n.left+n.width-b/3,n.top+n.height-M/3),this.bottomLeftBorderDoubleOuterBox=d>0||f>0?Il(n.left+C/3,n.top+w,d-C/3,f-M/3,qs.BOTTOM_LEFT):new Bl(n.left+C/3,n.top+n.height-M/3),this.topLeftBorderDoubleInnerBox=r>0||a>0?Il(n.left+2*C/3,n.top+2*x/3,r-2*C/3,a-2*x/3,qs.TOP_LEFT):new Bl(n.left+2*C/3,n.top+2*x/3),this.topRightBorderDoubleInnerBox=r>0||a>0?Il(n.left+v,n.top+2*x/3,s-2*b/3,l-2*x/3,qs.TOP_RIGHT):new Bl(n.left+n.width-2*b/3,n.top+2*x/3),this.bottomRightBorderDoubleInnerBox=c>0||h>0?Il(n.left+y,n.top+g,c-2*b/3,h-2*M/3,qs.BOTTOM_RIGHT):new Bl(n.left+n.width-2*b/3,n.top+n.height-2*M/3),this.bottomLeftBorderDoubleInnerBox=d>0||f>0?Il(n.left+2*C/3,n.top+w,d-2*C/3,f-2*M/3,qs.BOTTOM_LEFT):new Bl(n.left+2*C/3,n.top+n.height-2*M/3),this.topLeftBorderStroke=r>0||a>0?Il(n.left+C/2,n.top+x/2,r-C/2,a-x/2,qs.TOP_LEFT):new Bl(n.left+C/2,n.top+x/2),this.topRightBorderStroke=r>0||a>0?Il(n.left+v,n.top+x/2,s-b/2,l-x/2,qs.TOP_RIGHT):new Bl(n.left+n.width-b/2,n.top+x/2),this.bottomRightBorderStroke=c>0||h>0?Il(n.left+y,n.top+g,c-b/2,h-M/2,qs.BOTTOM_RIGHT):new Bl(n.left+n.width-b/2,n.top+n.height-M/2),this.bottomLeftBorderStroke=d>0||f>0?Il(n.left+C/2,n.top+w,d-C/2,f-M/2,qs.BOTTOM_LEFT):new Bl(n.left+C/2,n.top+n.height-M/2),this.topLeftBorderBox=r>0||a>0?Il(n.left,n.top,r,a,qs.TOP_LEFT):new Bl(n.left,n.top),this.topRightBorderBox=s>0||l>0?Il(n.left+v,n.top,s,l,qs.TOP_RIGHT):new Bl(n.left+n.width,n.top),this.bottomRightBorderBox=c>0||h>0?Il(n.left+y,n.top+g,c,h,qs.BOTTOM_RIGHT):new Bl(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=d>0||f>0?Il(n.left,n.top+w,d,f,qs.BOTTOM_LEFT):new Bl(n.left,n.top+n.height),this.topLeftPaddingBox=r>0||a>0?Il(n.left+C,n.top+x,Math.max(0,r-C),Math.max(0,a-x),qs.TOP_LEFT):new Bl(n.left+C,n.top+x),this.topRightPaddingBox=s>0||l>0?Il(n.left+Math.min(v,n.width-b),n.top+x,v>n.width+b?0:Math.max(0,s-b),Math.max(0,l-x),qs.TOP_RIGHT):new Bl(n.left+n.width-b,n.top+x),this.bottomRightPaddingBox=c>0||h>0?Il(n.left+Math.min(y,n.width-C),n.top+Math.min(g,n.height-M),Math.max(0,c-b),Math.max(0,h-M),qs.BOTTOM_RIGHT):new Bl(n.left+n.width-b,n.top+n.height-M),this.bottomLeftPaddingBox=d>0||f>0?Il(n.left+C,n.top+Math.min(w,n.height-M),Math.max(0,d-C),Math.max(0,f-M),qs.BOTTOM_LEFT):new Bl(n.left+C,n.top+n.height-M),this.topLeftContentBox=r>0||a>0?Il(n.left+C+T,n.top+x+B,Math.max(0,r-(C+T)),Math.max(0,a-(x+B)),qs.TOP_LEFT):new Bl(n.left+C+T,n.top+x+B),this.topRightContentBox=s>0||l>0?Il(n.left+Math.min(v,n.width+C+T),n.top+x+B,v>n.width+C+T?0:s-C+T,l-(x+B),qs.TOP_RIGHT):new Bl(n.left+n.width-(b+E),n.top+x+B),this.bottomRightContentBox=c>0||h>0?Il(n.left+Math.min(y,n.width-(C+T)),n.top+Math.min(g,n.height+x+B),Math.max(0,c-(b+E)),h-(M+S),qs.BOTTOM_RIGHT):new Bl(n.left+n.width-(b+E),n.top+n.height-(M+S)),this.bottomLeftContentBox=d>0||f>0?Il(n.left+C+T,n.top+w,Math.max(0,d-(C+T)),f-(M+S),qs.BOTTOM_LEFT):new Bl(n.left+C+T,n.top+n.height-(M+S))}return e}();!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(qs||(qs={}));var Il=function(e,t,n,i,r){var a=(Math.sqrt(2)-1)/3*4,o=n*a,s=i*a,l=e+n,A=t+i;switch(r){case qs.TOP_LEFT:return new Sl(new Bl(e,A),new Bl(e,A-s),new Bl(l-o,t),new Bl(l,t));case qs.TOP_RIGHT:return new Sl(new Bl(e,t),new Bl(e+o,t),new Bl(l,A-s),new Bl(l,A));case qs.BOTTOM_RIGHT:return new Sl(new Bl(l,t),new Bl(l,t+s),new Bl(e+o,A),new Bl(e,A));case qs.BOTTOM_LEFT:default:return new Sl(new Bl(l,A),new Bl(l-o,A),new Bl(e,t+s),new Bl(e,t))}},Ll=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Fl=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},kl=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Pl=function(){function e(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n,this.type=0,this.target=6}return e}(),Ul=function(){function e(e,t){this.path=e,this.target=t,this.type=1}return e}(),Dl=function(){function e(e){this.opacity=e,this.type=2,this.target=6}return e}(),Rl=function(e){return 0===e.type},Ol=function(e){return 1===e.type},Nl=function(e){return 2===e.type},zl=function(e,t){return e.length===t.length&&e.some((function(e,n){return e===t[n]}))},Ql=function(e,t,n,i,r){return e.map((function(e,a){switch(a){case 0:return e.add(t,n);case 1:return e.add(t+i,n);case 2:return e.add(t+i,n+r);case 3:return e.add(t,n+r)}return e}))},Gl=function(){function e(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),Hl=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new _l(this.container),this.container.styles.opacity<1&&this.effects.push(new Dl(this.container.styles.opacity)),null!==this.container.styles.transform){var n=this.container.bounds.left+this.container.styles.transformOrigin[0].number,i=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Pl(n,i,r))}if(0!==this.container.styles.overflowX){var a=Ll(this.curves),o=kl(this.curves);zl(a,o)?this.effects.push(new Ul(a,6)):(this.effects.push(new Ul(a,2)),this.effects.push(new Ul(o,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),n=this.parent,i=this.effects.slice(0);n;){var r=n.effects.filter((function(e){return!Ol(e)}));if(t||0!==n.container.styles.position||!n.parent){if(i.unshift.apply(i,r),t=-1===[2,3].indexOf(n.container.styles.position),0!==n.container.styles.overflowX){var a=Ll(n.curves),o=kl(n.curves);zl(a,o)||i.unshift(new Ul(o,6))}}else i.unshift.apply(i,r);n=n.parent}return i.filter((function(t){return sa(t.target,e)}))},e}(),Vl=function(e,t,n,i){e.container.elements.forEach((function(r){var a=sa(r.flags,4),o=sa(r.flags,2),s=new Hl(r,e);sa(r.styles.display,2048)&&i.push(s);var l=sa(r.flags,8)?[]:i;if(a||o){var A=a||r.styles.isPositioned()?n:t,c=new Gl(s);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var h=r.styles.zIndex.order;if(h<0){var u=0;A.negativeZIndex.some((function(e,t){return h>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),A.negativeZIndex.splice(u,0,c)}else if(h>0){var d=0;A.positiveZIndex.some((function(e,t){return h>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),A.positiveZIndex.splice(d,0,c)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else r.styles.isFloating()?A.nonPositionedFloats.push(c):A.nonPositionedInlineLevel.push(c);Vl(s,c,a?c:n,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(s):t.nonInlineLevel.push(s),Vl(s,t,n,l);sa(r.flags,8)&&jl(r,l)}))},jl=function(e,t){for(var n=e instanceof Wo?e.start:1,i=e instanceof Wo&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var i=eA(e),r=kl(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,e.intrinsicWidth,e.intrinsicHeight,i.left,i.top,i.width,i.height),this.ctx.restore()}},n.prototype.renderNodeContent=function(e){return i(this,void 0,void 0,(function(){var t,i,a,s,l,A,c,h,u,d,f,p,m,v,g,y,w,x;return r(this,(function(r){switch(r.label){case 0:this.applyEffects(e.getEffects(4)),t=e.container,i=e.curves,a=t.styles,s=0,l=t.textNodes,r.label=1;case 1:return s0&&C>0&&(g=i.ctx.createPattern(p,"repeat"),i.renderRepeat(w,g,E,S))):Di(n)&&(y=iA(e,t,[null,null,null]),w=y[0],x=y[1],b=y[2],M=y[3],C=y[4],B=0===n.position.length?[Vn]:n.position,E=Xn(B[0],M),S=Xn(B[B.length-1],C),T=xi(n,E,S,M,C),_=T[0],I=T[1],_>0&&I>0&&(L=i.ctx.createRadialGradient(x+E,b+S,0,x+E,b+S,_),mi(n.stops,2*_).forEach((function(e){return L.addColorStop(e.stop,ri(e.color))})),i.path(w),i.ctx.fillStyle=L,_!==I?(F=e.bounds.left+.5*e.bounds.width,k=e.bounds.top+.5*e.bounds.height,U=1/(P=I/_),i.ctx.save(),i.ctx.translate(F,k),i.ctx.transform(1,0,0,P,0,0),i.ctx.translate(-F,-k),i.ctx.fillRect(x,U*(b-k)+k,M,C*U),i.ctx.restore()):i.ctx.fill())),r.label=6;case 6:return t--,[2]}}))},i=this,a=0,o=e.styles.backgroundImage.slice(0).reverse(),l.label=1;case 1:return a0?2!==A.style?[3,5]:[4,this.renderDashedDottedBorder(A.color,A.width,o,e.curves,2)]:[3,11]:[3,13];case 4:return r.sent(),[3,11];case 5:return 3!==A.style?[3,7]:[4,this.renderDashedDottedBorder(A.color,A.width,o,e.curves,3)];case 6:return r.sent(),[3,11];case 7:return 4!==A.style?[3,9]:[4,this.renderDoubleBorder(A.color,A.width,o,e.curves)];case 8:return r.sent(),[3,11];case 9:return[4,this.renderSolidBorder(A.color,o,e.curves)];case 10:r.sent(),r.label=11;case 11:o++,r.label=12;case 12:return s++,[3,3];case 13:return[2]}}))}))},n.prototype.renderDashedDottedBorder=function(e,t,n,a,o){return i(this,void 0,void 0,(function(){var i,s,l,A,c,h,u,d,f,p,m,v,g,y,w,x;return r(this,(function(r){return this.ctx.save(),i=Zl(a,n),s=Xl(a,n),2===o&&(this.path(s),this.ctx.clip()),Tl(s[0])?(l=s[0].start.x,A=s[0].start.y):(l=s[0].x,A=s[0].y),Tl(s[1])?(c=s[1].end.x,h=s[1].end.y):(c=s[1].x,h=s[1].y),u=0===n||2===n?Math.abs(l-c):Math.abs(A-h),this.ctx.beginPath(),3===o?this.formatPath(i):this.formatPath(s.slice(0,2)),d=t<3?3*t:2*t,f=t<3?2*t:t,3===o&&(d=t,f=t),p=!0,u<=2*d?p=!1:u<=2*d+f?(d*=m=u/(2*d+f),f*=m):(v=Math.floor((u+f)/(d+f)),g=(u-v*d)/(v-1),f=(y=(u-(v+1)*d)/v)<=0||Math.abs(f-g)'.concat(e.element,"");var t=document.createElement("div");t.innerHTML=e.element,e.element=t.children[0]}return this._addHotSpot(e)}console.error("缺少关键参数:element")}else console.error("缺少关键参数:position")}},{key:"addLayer",value:function(e){this.layers.indexOf(e)<0&&this.layers.push(e)}},{key:"hideAll",value:function(){this.layers.forEach((function(e){e.hide()}))}},{key:"showAll",value:function(){this.layers.forEach((function(e){e.show()}))}},{key:"onlyShow",value:function(e){this.hideAll(),e.show()}},{key:"toJSON",value:function(){var e=[];return this.layers.forEach((function(t){e.push(t.toJSON())})),e}},{key:"loadLayer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.defaultLayer;viewer.camera.updateProjectionMatrix(),this.addLayer(n),e.forEach((function(e){var i=document.createElement("div");i.innerHTML=e.element,i.className="hot-spot",e.element=i,e.layer=n,t._addHotSpot(e)}))}},{key:"_addHotSpot",value:function(e){var t=this;if(e.element.style.position="absolute",this.container.appendChild(e.element),e.position=Array.isArray(e.position)?(new at).fromArray(e.position):(new at).copy(e.position),void 0!==e.objectId){var n=this.viewer.root.getObjectById(e.objectId);if(!n)return console.error("热点id与模型不匹配"),null;e.worldPos=e.position.clone(),n.worldToLocal(e.position)}var i=new Km(e);return e.layer=e.layer||this.defaultLayer,e.layer.add(i),i.focus=function(n){e.cameraView&&e.cameraView.position&&(i.cameraView.complete=function(){n?n():i.complete&&i.complete()},t.viewer.controls.flyTo(i.cameraView))},i}},{key:"_onUpdate",value:function(){var e=this;this.layers.forEach((function(t){t.visible&&t.spots.forEach((function(t){var n=t.position.clone();void 0!==t.objectId&&(n=e.viewer.root.getObjectById(t.objectId).localToWorld(t.position.clone())),t.updateScreenCoords(e._getProjectHotPos(n)),t.screenCoord?t.hided||(t.element.style.display="block"):t.element.style.display="none"}))}))}},{key:"_getProjectHotPos",value:function(e){var t=this.viewer,n=t.camera.position.clone().sub(e.clone()).normalize(),i=new at;t.camera.getWorldDirection(i).clone();var r=t.renderer.domElement.getBoundingClientRect(),a=t.renderer.domElement.offsetWidth,o=t.renderer.domElement.offsetHeight,s=a/2,l=o/2,A=e.clone();if(A.project(t.camera),i.x=-i.x,i.y=-i.y,i.z=-i.z,n.clone().angleTo(i)>.5*Math.PI)return null;var c=A.x*s+s,h=-A.y*l+l;return a<=Math.round(r.width)&&(c+=r.left),o<=Math.round(r.height)&&(h+=r.top),new tt(c,h)}},{key:"createLayer",value:function(){var e=new Zm;return this.addLayer(e),e}},{key:"deleteLayer",value:function(e){-1!==this.layers.indexOf(e)&&(e.spots.map((function(e){e.element.remove()})),this.layers.splice(this.layers.indexOf(e),1))}},{key:"export",value:function(){return this.toJSON().filter((function(e){return e.length>0}))}},{key:"import",value:function(e,t){var n=this,i=new DOMParser;return e.map((function(e){t=t||n.createLayer(),e.forEach((function(e){e.element=i.parseFromString(e.element,"text/html").body.children[0],e.layer=t,n._addHotSpot(e)}))})),t}},{key:"addSpriteLabel",value:function(e){e.position||console.warn("addSpriteLabel: options.position不能为空!");var t=new $m({position:e.position,html:e.content,userData:e.userData,cameraView:e.cameraView,onclick:e.onclick});return this.spriteRoot.add(t),t}}]),e}(),tv=function(){function e(){s(this,e)}return A(e,[{key:"init",value:function(){this.isActive=!1}},{key:"initParticleItem",value:function(e){}},{key:"update",value:function(e,t){}},{key:"reset",value:function(){}}]),e}(),nv="\nattribute vec4 vertexColor;\nvarying vec4 vColor;\nvarying vec2 vUv;\nvoid main()\n{\n vUv = uv;\n vColor = vertexColor;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n}\n",iv="\n\nuniform sampler2D mainTex;\nvarying vec4 vColor;\nvarying vec2 vUv;\nvoid main()\n{\n vec4 texColor = texture2D(mainTex,vUv.xy);\n vec4 col = texColor * vColor;\n gl_FragColor = col;\n}\n\n",rv="\nattribute vec4 vertexColor;\nuniform vec4 _TintColor;\nvarying vec4 vColor;\nvarying vec2 vUv;\nvoid main()\n{\n vUv = uv;\n vColor = vec4(vertexColor.xyz * _TintColor.xyz,vertexColor.w * _TintColor.w);\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n}\n\n",av="\n\nuniform sampler2D mainTex;\nvarying vec4 vColor;\nvarying vec2 vUv;\nvoid main()\n{\n vec4 texColor = texture2D(mainTex,vUv.xy);\n vec4 col = texColor * vColor * 2.0;\n col.a = clamp(col.a,0.0,1.0);\n gl_FragColor = col;\n}\n\n",ov="\n uniform sampler2D mainTex;\n varying vec4 _TintColor;\n varying vec4 vColor;\n varying vec2 vUv;\n void main()\n {\n vec4 texColor = texture2D(mainTex,vUv.xy);\n vec3 col = texColor.xyz * vColor.xyz * _TintColor.xyz * 2.0;\n float a = (1 - texColor.w) * (_TintColor.w * vColor.w * 2.0);\n gl_FragColor = vec4(col.xyz,a);\n }\n\n",sv="\nuniform sampler2D mainTex;\nvarying vec4 vColor;\nvarying vec2 vUv;\nvoid main()\n{\n vec4 texColor = texture2D(mainTex,vUv.xy);\n vec4 col = texColor * vColor;\n col = lerp(vec4(1,1,1,1),col,col.w);\n gl_FragColor = col;\n}\n \n",lv="\n uniform sampler2D mainTex;\n varying vec4 vColor;\n varying vec2 vUv;\n void main()\n {\n vec4 col;\n vec4 texColor = texture2D(mainTex,vUv.xy);\n col.xyz = texColor.xyz * vColor.xyz * 2;\n col.w = vColor.w * texColor.w;\n col = lerp(vec4(0.5,0.5,0.5,0.5),col,col.a);\n gl_FragColor = col;\n }\n",Av="\n\n uniform sampler2D mainTex;\n varying vec4 vColor;\n varying vec2 vUv;\n void main()\n {\n vec4 texColor = texture2D(mainTex,vUv.xy);\n gl_FragColor = vColor * texColor * vColor.a;\n }\n",cv=function(){function e(){s(this,e)}return A(e,null,[{key:"randomValue",value:function(e,t){var n=Math.random();return Hh.lerp(e,t,n)}},{key:"randomVector3",value:function(e,t){return new at(this.randomValue(e.x,t.x),this.randomValue(e.y,t.y),this.randomValue(e.z,t.z))}},{key:"randomVector4",value:function(e,t){var n=Math.random();return e.lerp(t,n)}},{key:"getShader",value:function(e){return"normal_vertex"===e?nv:"normal_fragment"===e?iv:"normal_legacy_vertex"===e?rv:"normal_legacy_fragment"===e?av:"multily_legacy_fragment"===e?ov:"multipy_fragment"===e?sv:"multiplyDouble_fragment"===e?lv:"premultiplyBlend_fragment"===e?Av:""}},{key:"getShaderBlend",value:function(e){return"SrcAlpha"===e?P:"OneMinusSrcAlpha"===e?U:"One"===e?F:"DstColor"===e?R:"Zero"===e?L:"SrcColor"===e?k:F}}]),e}(),hv=function(){function e(t){s(this,e),null!=t?this.setJsonData(t):(this.times=[],this.values=[],this.currentIndex=0)}return A(e,[{key:"setJsonData",value:function(e){this.times=e.times,this.values=e.values,this.currentIndex=0}},{key:"getValue",value:function(e){var t=this.times.length;if(this.currentIndex=e)return Hh.lerp(this.values[this.currentIndex],this.values[this.currentIndex+1],(e-this.times[this.currentIndex])/(this.times[this.currentIndex+1]-this.times[this.currentIndex]));for(var n=0;n=e)return this.currentIndex=n,Hh.lerp(this.values[n],this.values[n+1],(e-this.times[n])/(this.times[n+1]-this.times[n]))}return 0}}]),e}(),uv=function(){function e(t){s(this,e),null!=t?this.setJsonData(t):(this.m_Mode=e.TYPE.Constant,this.m_ConstantMin=0,this.m_ConstantMax=0,this.m_CurveMin=null,this.m_CurveMax=null)}return A(e,[{key:"setJsonData",value:function(t){this.m_Mode=t.mode,this.m_Mode===e.TYPE.Constant?this.setConstantValue(t.max):this.m_Mode===e.TYPE.TwoConstants?this.setConstantMinMax(t.min,t.max):this.m_Mode===e.TYPE.Curve?this.setCurves(new hv(t.maxCurve)):this.m_Mode===e.TYPE.TwoCurves&&this.setCurvesMinMax(new hv(t.minCurve),new hv(t.maxCurve))}},{key:"setConstantValue",value:function(t){this.m_Mode=e.TYPE.Constant,this.m_ConstantMin=0,this.m_ConstantMax=t,this.m_CurveMin=null,this.m_CurveMax=null}},{key:"setConstantMinMax",value:function(t,n){this.m_Mode=e.TYPE.TwoConstants,this.m_ConstantMin=t,this.m_ConstantMax=n,this.m_CurveMin=null,this.m_CurveMax=null}},{key:"setCurves",value:function(t){this.m_Mode=e.TYPE.Curve,this.m_CurveMax=t,this.m_CurveMin=null}},{key:"setCurvesMinMax",value:function(t,n){this.m_Mode=e.TYPE.TwoCurves,this.m_CurveMin=t,this.m_CurveMax=n}},{key:"getRandomValue",value:function(t){if(this.m_Mode==e.TYPE.Constant)return this.m_ConstantMax;if(this.m_Mode==e.TYPE.TwoConstants)return cv.randomValue(this.m_ConstantMin,this.m_ConstantMax);if(this.m_Mode==e.TYPE.Curve)return this.m_CurveMax.getValue(t);if(this.m_Mode==e.TYPE.TwoCurves){var n=Math.random(),i=this.m_CurveMin.getValue(t),r=this.m_CurveMax.getValue(t);return n>.5?r:i}return 0}}]),e}();uv.TYPE=Object.freeze({Constant:0,Curve:1,TwoCurves:2,TwoConstants:3});var dv=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this)).isActive=!0,null!=e?i.setJsonData(e):(i.rateOverTime=new uv,i.rateOverTime.setConstantValue(5)),i.density=1,i.rateOverTimeResult=i.rateOverTime.getRandomValue(),i.secondParticle=i.rateOverTimeResult*i.density,i.singleTime=1/i.secondParticle,i.playBackTime=0,i.cacheTime=0,i.createParticleCount=0,i}return A(n,[{key:"setJsonData",value:function(e){this.rateOverTime=new uv(e.rateOverTime)}},{key:"setDensity",value:function(e){this.density=e,this.secondParticle=this.rateOverTimeResult*this.density,0==this.secondParticle?this.singleTime=99999999:this.singleTime=1/this.secondParticle}},{key:"update",value:function(e,t){this.playBackTime+=e,this.cacheTime+=e,this.cacheTime>=this.singleTime&&(this.createParticleCount=Math.floor(this.cacheTime/this.singleTime),this.cacheTime=this.cacheTime%this.singleTime)}},{key:"reset",value:function(){b(u(n.prototype),"reset",this).call(this),this.createParticleCount=0}}]),n}(tv),fv=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this)).isActive=!0,null!=e?i.setJsonData(e):(i.shape=n.TYPE.Box,i.angle=25,i.radius=1,i.radiusThickness=1,i.donutRadius=.2,i.position=new at(0,0,0),i.rotation=new Bt(0,0,0),i.scale=new at(1,1,1)),i.startPosition=new at(0,0,0),i.moveDirection=new at(0,0,0),i}return A(n,[{key:"setJsonData",value:function(e){this.shape=e.shapeMode,this.shape===n.TYPE.Cone&&(this.angle=e.cone.angle,this.radius=e.cone.radius,this.radiusThickness=e.cone.radiusThickness),this.position=new at(e.position.x,e.position.y,e.position.z),this.rotation=new Bt(e.rotation.x,e.rotation.y,e.rotation.z),this.scale=new at(e.scale.x,e.scale.y,e.scale.z)}},{key:"update",value:function(e,t){if(b(u(n.prototype),"update",this).call(this,e,t),this.shape==n.TYPE.Cone){var i=Hh.lerp(0,this.angle,1-this.radiusThickness),r=et.degToRad(cv.randomValue(i,this.angle)),a=et.degToRad(cv.randomValue(0,360)),o=Math.sin(r);this.moveDirection=new at(o*Math.cos(a),Math.cos(r),o*Math.sin(a));var s=et.degToRad(cv.randomValue(0,360)),l=cv.randomValue(0,this.radius);this.startPosition=new at(Math.cos(s)*l,0,Math.sin(s)*l),this.startPosition=this.startPosition.multiply(this.scale).add(this.position),this.moveDirection.applyEuler(this.rotation).multiply(this.scale)}else if(this.shape==n.TYPE.Box){var A=this.scale.clone().multiplyScalar(.5);this.startPosition=cv.randomVector3(new at(-A.x,-A.y,-A.z),new at(A.x,A.y,A.z)),this.moveDirection.y=1,this.moveDirection.applyEuler(this.rotation)}}},{key:"reset",value:function(){b(u(n.prototype),"reset",this).call(this),this.startPosition.setScalar(0),this.moveDirection.setScalar(0)}}]),n}(tv);fv.TYPE=Object.freeze({Sphere:0,Hemisphere:2,Cone:4,Box:5,Circle:10});var pv=function(){function e(t){s(this,e),null!=t?this.setJsonData(t):(this.colorLocation=[],this.colors=[],this.alphaLocation=[],this.alphas=[])}return A(e,[{key:"setJsonData",value:function(e){this.colorLocation=e.colorLocation,this.colors=[];for(var t=0;t=e&&0===i)return"number"==typeof n[i]?n[i]:n[i].clone();if(ie){var a=(e-t[i])/(t[i+1]-t[i]);return"number"==typeof n[i]?n[i]+(n[i+1]-n[i])*a:n[i].clone().lerp(n[i+1],a)}}return r("number"==n[n.length-1])?n[n.length-1]:n[n.length-1].clone()}}]),e}(),mv=function(){function e(t){s(this,e),null!=t?this.setJsonData(t):(this.m_mode=e.TYPE.Color,this.minColor=null,this.maxColor=new ut(1,1,1,1),this.minGradient=null,this.maxGradient=null)}return A(e,[{key:"setJsonData",value:function(t){if(this.m_mode=t.m_mode,this.m_mode===e.TYPE.Color)this.setColor(new ut(t.maxColor.r,t.maxColor.g,t.maxColor.b,t.maxColor.a));else if(this.m_mode===e.TYPE.TwoColors){var n=new ut(t.minColor.r,t.minColor.g,t.minColor.b,t.minColor.a),i=new ut(t.maxColor.r,t.maxColor.g,t.maxColor.b,t.maxColor.a);this.setColorMinMax(n,i)}else this.m_mode===e.TYPE.Gradient?this.setGradient(new pv(t.maxGradient)):this.m_mode===e.TYPE.TwoGradients&&this.setMinMaxGradient(new pv(t.minGradient),new pv(t.maxGradient))}},{key:"setColorMinMax",value:function(t,n){this.m_mode=e.TYPE.TwoColors,this.minColor=t,this.maxColor=n}},{key:"setGradient",value:function(t){this.m_mode=e.TYPE.Gradient,this.maxGradient=t}},{key:"setMinMaxGradient",value:function(t,n){this.m_mode=e.TYPE.TwoGradients,this.minGradient=t,this.maxGradient=n}},{key:"setColor",value:function(t){this.m_mode=e.TYPE.Color,this.minColor=null,this.maxColor=t}},{key:"getRandomValue",value:function(){if(this.m_mode==e.TYPE.Color)return this.maxColor;if(this.m_mode==e.TYPE.Gradient)return this.maxGradient.getValue(Math.random());if(this.m_mode==e.TYPE.TwoGradients){var t=Math.random(),n=this.minGradient.getValue(t),i=this.maxGradient.getValue(t);return cv.randomVector4(n,i)}return this.m_mode==e.TYPE.TwoColors?cv.randomVector4(this.minColor,this.maxColor):this.m_mode==e.TYPE.RandomColor?this.maxGradient.getValue(Math.random()):this.maxColor}},{key:"getLerpValue",value:function(t){if(this.m_mode==e.TYPE.Gradient)return this.maxGradient.getValue(t);if(this.m_mode==e.TYPE.TwoGradients){var n=Math.random(),i=this.minGradient.getValue(n),r=this.maxGradient.getValue(n);return n>.5?r:i}return this.maxColor}}]),e}();mv.TYPE=Object.freeze({Color:0,Gradient:1,TwoColors:2,TwoGradients:3,RandomColor:4});var vv=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this)).isActive=!0,i.duration=e.duration,i.isLoop=e.isLoop,i.startDelay=new uv(e.startDelay),i.startLifeTime=new uv(e.startLifeTime),i.startSpeed=new uv(e.startSpeed),i.startSize=new uv(e.startSize),i.startRotation=new uv(e.startRotation),i.startColor=new mv(e.startColor),i.gravityModifier=new uv(e.gravity),i.maxParticles=1e4,i}return A(n,[{key:"initParticleItem",value:function(e){e.startDelay=this.startDelay.getRandomValue(),e.lifeTime=this.startLifeTime.getRandomValue();var t=this.startSpeed.getRandomValue();e.startSpeed=new at(t,t,t),e.startSize=this.startSize.getRandomValue(),e.startRotation=this.startRotation.getRandomValue(),e.startColor=this.startColor.getRandomValue(),e.gravityModifier=this.gravityModifier.getRandomValue(),e.refresh()}},{key:"update",value:function(e,t){b(u(n.prototype),"update",this).call(this,e,t),t.setScaleXYZ(t.startSize,t.startSize,t.startSize),t.color=t.startColor.clone(),t.speed=t.moveDirection.clone().add(t.startSpeed),t.speed.add(new at(0,4.905*-t.gravityModifier*2*t.currentTime,0))}}]),n}(tv),gv=function(){function e(t){s(this,e),this.particleCount=t,this.bufferGeometry=null,this.material=null,this.mesh=null}return A(e,[{key:"init",value:function(){this.bufferGeometry=new si}},{key:"setColor",value:function(e,t){}},{key:"setPosition",value:function(e,t,n,i){}},{key:"setScale",value:function(e,t,n){}},{key:"setRotation",value:function(e,t,n,i){}},{key:"setAlpha",value:function(){}}]),e}();gv.RenderMode=Object.freeze({Billboard:0,StretchedBillboard:1,HorizontalBillboard:2,VerticalBillboard:3});var yv=function(){function e(t){s(this,e),this.particleSystem=t,this.index=0,this.render=null,this.startDelay=0,this.lifeTime=0,this.startSpeed=1,this.startSize=1,this.startColor=new ut(1,1,1,1),this.gravityModifier=0,this.startRotation=0,this.startPosition=new at(0,0,0),this.moveDirection=new at(0,0,0),this.active=!0,this.currentTime=0,this.pos0=new at(0,0,0),this.pos1=new at(0,0,0),this.pos2=new at(0,0,0),this.pos3=new at(0,0,0),this.speed=new at(1,1,1),this.rotationSpeed=new at(0,0,0),this.position=this.startPosition.clone(),this.rotation=new at(0,0,0),this.scale=new at(1,1,1),this.camera=null,this.localMatrix=new bt,this.moveMatrix=new bt,this.scaleMatrix=(new bt).makeScale(1,1,1),this.rotationEuler=new Bt(0,0,0),this.billboardRotationEuler=new Bt(0,0,0),this.startRotationEuler=new Bt(0,0,et.degToRad(this.startRotation)),this.directionEuler=new Bt(0,0,0),this.color=this.startColor.clone(),this.isDirty=!0,this.isColorDirty=!0,this.texStartFrame=0}return A(e,[{key:"setCamera",value:function(e){this.camera=e}},{key:"initRender",value:function(e,t){this.render=e,this.camera=t,this.pos0=new at(-this.render.width,-this.render.height,0),this.pos1=new at(this.render.width,-this.render.height,0),this.pos2=new at(this.render.width,this.render.height,0),this.pos3=new at(-this.render.width,this.render.height,0)}},{key:"refresh",value:function(){this.color=this.startColor.clone(),this.startRotationEuler=new Bt(0,0,et.degToRad(this.startRotation))}},{key:"setStartPosition",value:function(e){this.startPosition=e,this.setRotation(new at(0,0,0)),this.setPosition(this.startPosition.clone())}},{key:"setActive",value:function(e){this.active!=e&&(this.active=e,this.active?this.render.setColor(this.index,this.color):this.render.setColor(this.index,new ut(this.color.x,this.color.y,this.color.z,0)))}},{key:"reset",value:function(){this.currentTime=0,this.scale.set(1,1,1),this.rotation.set(0,0,0),this.rotationEuler.set(0,0,0),this.isDirty=!1,this.isColorDirty=!1,this.position.set(0,0,0),this.texStartFrame=0}},{key:"update",value:function(e){if(this.currentTime+=e,this.currentTime>=this.lifeTime)return this.setActive(!1),void this.reset();this.rotation.addScaledVector(this.rotationSpeed,e),this.setRotationAngleXYZ(this.rotation.x,this.rotation.y,this.rotation.z),this.position.add(this.speed.multiplyScalar(e)),this.setPosition(this.position),this.billboard(),!0===this.isDirty&&this.refreshMatrix(),!0===this.isColorDirty&&this.render.setColor(this.index,this.color)}},{key:"billboard",value:function(){if(null!=this.camera){var e=new at(0,0,0);this.camera.getWorldDirection(e),e.add(this.camera.position),e=this.particleSystem.worldToLocal(e);var t=this.particleSystem.worldToLocal(this.camera.position.clone());this.render.renderMode==gv.RenderMode.StretchedBillboard&&e.setY(t.y);var n=new bt;n.lookAt(t,e,new at(0,1,0));var i=new nt;i.setFromRotationMatrix(n),this.billboardRotationEuler.set(0,0,0),this.billboardRotationEuler.setFromQuaternion(i)}}},{key:"refreshMatrix",value:function(){this.localMatrix=this.scaleMatrix.clone(),this.localMatrix.premultiply(this.moveMatrix);var e=this.pos0.clone().applyEuler(this.startRotationEuler).applyEuler(this.rotationEuler).applyEuler(this.billboardRotationEuler).applyMatrix4(this.localMatrix),t=this.pos1.clone().applyEuler(this.startRotationEuler).applyEuler(this.rotationEuler).applyEuler(this.billboardRotationEuler).applyMatrix4(this.localMatrix),n=this.pos2.clone().applyEuler(this.startRotationEuler).applyEuler(this.rotationEuler).applyEuler(this.billboardRotationEuler).applyMatrix4(this.localMatrix),i=this.pos3.clone().applyEuler(this.startRotationEuler).applyEuler(this.rotationEuler).applyEuler(this.billboardRotationEuler).applyMatrix4(this.localMatrix);this.render.setPosition(4*this.index,e),this.render.setPosition(4*this.index+1,t),this.render.setPosition(4*this.index+2,n),this.render.setPosition(4*this.index+3,i),this.render.refreshPosition()}},{key:"setPosition",value:function(e){this.position.x==e&&this.position.y==e.y&&this.position.z==e.z||(this.position=e,this.moveMatrix.makeTranslation(this.position.x,this.position.y,this.position.z),this.isDirty=!0)}},{key:"setScale",value:function(e){this.setScaleXYZ(e.x,e.y,e.z)}},{key:"setScaleXYZ",value:function(e,t,n){this.scale.x==e&&this.scale.y==t&&this.scale.z==n||(this.scale.set(e,t,n),this.scaleMatrix.makeScale(this.scale.x,this.scale.y,this.scale.z),this.isDirty=!0)}},{key:"setRotationAngleXYZ",value:function(e,t,n){this.setRotationXYZ(et.degToRad(e),et.degToRad(t),et.degToRad(n))}},{key:"setRotation",value:function(e){this.setRotationXYZ(e.x,e.y,e.z)}},{key:"setRotationXYZ",value:function(e,t,n){this.rotationEuler.x==e&&this.rotationEuler.y==t&&this.rotationEuler.z==n||(this.rotation.set(et.radToDeg(e),et.radToDeg(t),et.radToDeg(n)),this.rotationEuler.set(e,t,n),this.isDirty=!0)}},{key:"setColor",value:function(e){this.color.x===e.x&&this.color.y===e.y&&this.color.z===e.z&&this.color.w===e.w||(this.color=e,this.isColorDirty=!0)}},{key:"multiplyColor",value:function(e){this.color.multiply(e),this.isColorDirty=!0}},{key:"setUVs",value:function(e,t){this.render.setUV(this.index,e,t)}}]),e}(),wv=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this,e)).width=.5,r.height=.5,r.mainTexture=null,r.renderMode=n.RenderMode.Billboard,null!=i?(""==i.texName?r.texPath="glow.png":r.texPath=i.texName,r.vertexShaderName=cv.getShader(i.vertexShaderName),r.fragmentShaderName=cv.getShader(i.fragmentShaderName),r.blendSrc=cv.getShaderBlend(i.blendSrc),r.blendDst=cv.getShaderBlend(i.blendDst),r.renderMode=i.renderMode,r.renderMode==gv.RenderMode.StretchedBillboard?r.lengthScale=i.lengthScale:r.lengthScale=1,null!=i.matColor&&(r.matColor=new ut(i.matColor.r,i.matColor.g,i.matColor.b,i.matColor.a))):(r.texPath="glow.png",r.lengthScale=1,r.vertexShaderName=cv.getShader("normal_vertex"),r.fragmentShaderName=cv.getShader("normal_fragment"),r.blendSrc=cv.getShaderBlend("SrcAlpha"),r.blendDst=cv.getShaderBlend("OneMinusSrcAlpha")),r.height*=r.lengthScale,r.init(),r}return A(n,[{key:"init",value:function(){b(u(n.prototype),"init",this).call(this),this.mainTexture=(new tA).load(this.texPath);for(var e=[],t=[],i=[],r=[],a=0;athis.mainModule.maxParticles&&(this.totalParticleCount=this.mainModule.maxParticles),this.render=new wv(this.totalParticleCount,e.render),this.add(this.render.mesh),this.itemPool=[],this.activeItemArray=[],this.removeItemArray=[],this.totalTime=0}},{key:"init",value:function(e){this.camera=e;for(var t=0;t0?this.itemPool.pop():null}},{key:"pushItemToPool",value:function(e){this.itemPool.push(e)}},{key:"setDensity",value:function(e){this.emissionModule.setDensity(e);var t=this.mainModule.duration*this.emissionModule.secondParticle;if(t>this.mainModule.maxParticles&&(t=this.mainModule.maxParticles),t>this.totalParticleCount){for(var n=this.totalParticleCount;n0)for(var n=0;n=0&&this.nodeArray.get(n.parentId).add(i)}this.data=null}}},{key:"setDensity",value:function(e){this.density=e;for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,r)).mesh=e,i.color=r.color||"#17b2ff",i.distortion=r.distortion||3.7,i.speed=r.speed||1,i.size=r.size||1,i.water=new Rv(i.mesh.geometry,{textureWidth:512,textureHeight:512,waterNormals:(new tA).load(Nv,(function(e){e.wrapS=e.wrapT=V})),alpha:1,sunDirection:new Ov(0,1,0),sunColor:16777215,waterColor:i.color,distortionScale:i.distortion,size:i.size}),i.mesh.material0||(i.mesh.material0=i.mesh.material),i.material=i.mesh.material=i.water.material,i}return A(n,[{key:"setSpeed",value:function(e){this.speed=e,this.material.uniforms.baseSpeed.value=e}},{key:"setDistortion",value:function(e){this.distortion=e,this.material.uniforms.noiseScale.value=e}},{key:"setColor",value:function(e){this.material.uniforms.waterColor.value=new Fn(e)}},{key:"setSize",value:function(e){this.material.uniforms.size.value=e}},{key:"clear",value:function(){this.mesh.material=this.mesh.material0,this.paused=!0,AMRT.render()}},{key:"update",value:function(e){this.paused||(this.water.material.uniforms.time.value+=1/60*this.speed)}},{key:"onBeforeRender",value:function(e,t,n,i){this.water.material.uniforms.sunDirection.value=n.position.clone().normalize(),this.water.onBeforeRender(e,t,n)}},{key:"dispose",value:function(){this.material.dispose()}}]),n}(Cm),Qv=function e(t,n){Ei.call(this,t),this.type="Reflector";var i=this,r=void 0!==(n=n||{}).color?new Fn(n.color):new Fn(8355711),a=n.textureWidth||512,o=n.textureHeight||512,s=n.clipBias||0,l=n.shader||e.ReflectorShader,A=void 0!==n.recursion?n.recursion:0,c=new vn,h=new at,u=new at,d=new at,f=new bt,p=new at(0,0,-1),m=new ut,v=new at,g=new at,y=new ut,w=new bt,x=new Ni,b=new dt(a,o,{minFilter:Z,magFilter:Z,format:Ae,stencilBuffer:!1});et.isPowerOfTwo(a)&&et.isPowerOfTwo(o)||(b.texture.generateMipmaps=!1);var M=new Ri({uniforms:Di.clone(l.uniforms),fragmentShader:l.fragmentShader,vertexShader:l.vertexShader});M.uniforms.tDiffuse.value=b.texture,M.uniforms.color.value=r,M.uniforms.textureMatrix.value=w,this.material=M,this.onBeforeRender=function(e,t,n){if("recursion"in n.userData){if(n.userData.recursion===A)return;n.userData.recursion++}if(u.setFromMatrixPosition(i.matrixWorld),d.setFromMatrixPosition(n.matrixWorld),f.extractRotation(i.matrixWorld),h.set(0,0,1),h.applyMatrix4(f),v.subVectors(u,d),!(v.dot(h)>0)){v.reflect(h).negate(),v.add(u),f.extractRotation(n.matrixWorld),p.set(0,0,-1),p.applyMatrix4(f),p.add(d),g.subVectors(u,p),g.reflect(h).negate(),g.add(u),x.position.copy(v),x.up.set(0,1,0),x.up.applyMatrix4(f),x.up.reflect(h),x.lookAt(g),x.far=n.far,x.updateMatrixWorld(),x.projectionMatrix.copy(n.projectionMatrix),x.userData.recursion=0,w.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),w.multiply(x.projectionMatrix),w.multiply(x.matrixWorldInverse),w.multiply(i.matrixWorld),c.setFromNormalAndCoplanarPoint(h,u),c.applyMatrix4(x.matrixWorldInverse),m.set(c.normal.x,c.normal.y,c.normal.z,c.constant);var r=x.projectionMatrix;y.x=(Math.sign(m.x)+r.elements[8])/r.elements[0],y.y=(Math.sign(m.y)+r.elements[9])/r.elements[5],y.z=-1,y.w=(1+r.elements[10])/r.elements[14],m.multiplyScalar(2/m.dot(y)),r.elements[2]=m.x,r.elements[6]=m.y,r.elements[10]=m.z+1-s,r.elements[14]=m.w,i.visible=!1;var a=e.getRenderTarget(),o=e.vr.enabled,l=e.shadowMap.autoUpdate;e.vr.enabled=!1,e.shadowMap.autoUpdate=!1,e.setRenderTarget(b),e.clear(),e.render(t,x),e.vr.enabled=o,e.shadowMap.autoUpdate=l,e.setRenderTarget(a);var M=n.viewport;void 0!==M&&e.state.viewport(M),i.visible=!0}},this.getRenderTarget=function(){return b}};(Qv.prototype=Object.create(Ei.prototype)).constructor=Qv,Qv.ReflectorShader={uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:["uniform mat4 textureMatrix;","varying vec4 vUv;","void main() {","\tvUv = textureMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec4 vUv;","float blendOverlay( float base, float blend ) {","\treturn( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );","}","vec3 blendOverlay( vec3 base, vec3 blend ) {","\treturn vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );","}","void main() {","\tvec4 base = texture2DProj( tDiffuse, vUv );","\tgl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );","}"].join("\n")};var Gv=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this,i)).mesh=e,r.mirror=new Qv(r.mesh.geometry,{clipBias:.003,textureWidth:1024*window.devicePixelRatio,textureHeight:1024*window.devicePixelRatio,color:"#777777",recursion:1}),r.mesh.material0||(r.mesh.material0=r.mesh.material),r.mirror.position.copy(e.position),r.mirror.rotation.copy(e.rotation),r.mirror.scale.copy(e.scale),r.mirror.updateMatrixWorld(!0),r.mesh.material=r.mirror.material,r}return A(n,[{key:"clear",value:function(){this.mesh.material=this.mesh.material0,this.paused=!0,AMRT.render()}},{key:"update",value:function(e){}},{key:"onBeforeRender",value:function(e,t,n,i){this.mirror.onBeforeRender(e,t,n)}},{key:"dispose",value:function(){this.material.dispose()}}]),n}(Cm),Hv=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,n),e=t.call(this);var r=i.size?i.size:5,a=i.color?i.color:"#00fa00",o=i.speed?i.speed:1,l=i.texture?i.texture:"https://laozicloud-sdk.obs.cn-east-2.myhuaweicloud.com/assets/image/radar.png";return e.map=(new tA).load(l),e.map.center.set(.5,.5),e.circle=new Ei(new fl(r,64),new Nn({color:a,map:e.map,transparent:!0})),e.circle.renderOrder=6e3,e.circle.rotation.x=-Math.PI/2,e.circle.onBeforeRender=function(){e.map.rotation-=et.degToRad(2*o)},e.add(e.circle),e}return A(n)}(zt),Vv=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,n),e=t.call(this);var r=i.startRadius?i.startRadius:2,a=i.endRadius?i.endRadius:8,o=i.color?i.color:"#ffab03",l=i.speed?i.speed:1,A=i.texture?i.texture:"https://laozicloud-sdk.obs.cn-east-2.myhuaweicloud.com/assets/image/tours.png",c=(new tA).load(A),h=new $i(2*r,2*r),u=new Nn({map:c,color:o,transparent:!0,side:2});e.tours=new Ei(h,u);var d=a/r;return e.tours.renderOrder=1e3,e.tours.onAfterRender=function(){this.scale.x+=.01*l,this.scale.y=this.scale.x,this.scale.x>.4*d&&(this.material.opacity-=.005),this.scale.x>=d&&(this.scale.x=this.scale.y=1,this.material.opacity=1)},e.tours.rotation.x=-Math.PI/2,e.add(e.tours),e}return A(n)}(zt),jv=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,n),e=t.call(this),i.width||(i.width=100),i.height||(i.height=100),i.radius||(i.radius=10),e.canvas=document.createElement("canvas"),e.canvas.width=i.width,e.canvas.height=i.height,e.context=e.canvas.getContext("2d"),e.radius=i.radius||10,e.context.fillStyle="#00ff00",e.context.fillRect(0,0,i.width,i.height),e.colorStops=i.colorStops||{1:"#f00",.8:"#e2fa00",.6:"#33f900",.3:"#0349df",0:"#fff"},e.data=i.data||[{coord:[-54,0,-70],value:15},{coord:[-17,21,-52],value:13},{coord:[12,21,-52],value:22}],e.draw(e.data),e.material=new Nn({transparent:!0,map:new ts(e.canvas),side:2});var r=new qi(i.width,i.height);return e.map=new Ei(r,e.material),e.map.rotation.x=Math.PI/180*-90,e}return A(n,[{key:"setColorStops",value:function(e){this.colorStops=e}},{key:"setSource",value:function(e){this.draw(e),this.map.material.map.needsUpdate=!0}},{key:"draw",value:function(e){var t=this;this._convertPoints(e,this.radius),this.dataList=e;var n=this.context;n.clearRect(0,0,this.canvas.width,this.canvas.height);var i=this.dataList.reduce((function(e,t){return Math.max(e,t.value)}),0);this.dataList.forEach((function(e){t._drawRadiation(n,{x:e.x,y:e.y,radius:t.radius,weight:Math.max(Math.min((e.value-0)/(i-0),1),0),value:e.value})}));for(var r=this._createPalette(this.colorStops),a=this.canvas,o=a.width,s=a.height,l=n.getImageData(0,0,o,s),A=l.data,c=3;c0?i.x+=t:0==i.x?i.x=t:i.x<0&&(i.x=t+i.x),i.y>0?i.y+=n:0==i.y?i.y=n:i.y<0&&(i.y=n+i.y),e[r]=i}))}},{key:"_drawRadiation",value:function(e,t){var n=t.x,i=t.y,r=t.radius,a=t.weight;r=Math.round(r*a);var o=e.createRadialGradient(n,i,0,n,i,r);o.addColorStop(0,"rgba(25, 0, 0, 1)"),o.addColorStop(1,"rgba(0, 255, 0, 0)"),e.fillStyle=o,e.beginPath(),e.arc(n,i,r,0,2*Math.PI),e.closePath(),e.fill()}},{key:"_getColorByValue",value:function(e){return e>=0&&e<=5?["rgba("+this.colorStops[1]+",1)","rgba("+this.colorStops[0]+",0)"]:e>5&&e<=10?["rgba("+this.colorStops[2]+",1)","rgba("+this.colorStops[1]+",0)"]:e>10&&e<=20?["rgba("+this.colorStops[3]+",1)","rgba("+this.colorStops[2]+",0)"]:e>20?["rgba("+this.colorStops[4]+",1)","rgba("+this.colorStops[3]+",0)"]:void 0}},{key:"_getColorByValue2",value:function(e){return e>=0&&e<=5?["rgb("+this.colorStops[0]+")","rgba("+this.colorStops[1]+")"]:e>5&&e<=10?["rgb("+this.colorStops[1]+")","rgba("+this.colorStops[2]+")"]:e>10&&e<=20?["rgb("+this.colorStops[2]+")","rgba("+this.colorStops[3]+")"]:e>20?["rgb("+this.colorStops[3]+")","rgba("+this.colorStops[4]+")"]:void 0}},{key:"_createPalette",value:function(e){var t=256,n=document.createElement("canvas");n.width=t,n.height=20;var i=n.getContext("2d");i.fillStyle="#0000ff";var r=i.createLinearGradient(0,0,t,0);for(var a in e)r.addColorStop(a,e[a]);i.fillStyle=r,i.fillRect(0,0,t,20);var o=i.getImageData(0,0,t,1).data;return{canvas:n,pickColor:function(e){return o.slice(4*e,4*e+3)}}}}]),n}(zt),Wv=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,n),(e=t.call(this)).matColor=i.color,e.path=i.path,e.uvSpeed=.01,e.speed=i.speed,e.radius=i.radius,e.texture=i.texture||"https://laozicloud-sdk.obs.cn-east-2.myhuaweicloud.com/assets/image/streamer.png",e.tension=i.tension;var r=(new tA).load(e.texture);r.wrapS=r.wrapT=V,r.repeat.set(1,1),r.needsUpdate=!0;var a=new Nn({map:r,side:1,transparent:!0});e.matColor&&(a.color=new Fn(e.matColor));var o=new cA(e.path);null!=e.tension&&(o.curveType="catmullrom",o.tension=e.tension);var l=new ms(o,20*e.path.length,e.radius);e.lineMesh=new Ei(l,a);var A=v(e);return e.lineMesh.onBeforeRender=function(){r&&(r.offset.x-=A.speed)},e.add(e.lineMesh),e}return A(n,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius=e||.1}},{key:"speed",get:function(){return this._speed},set:function(e){this._speed=e?e*this.uvSpeed:this.uvSpeed}},{key:"matColor",get:function(){return this._matColor},set:function(e){e&&(this._matColor=e,this.lineMesh&&(this.lineMesh.material.color=new Fn(this.matColor)))}},{key:"path",get:function(){return this._path},set:function(e){if(e){this._path=[];for(var t=0;t0){void 0===e.cid&&(e.cid=[]);for(var t=0;t0)for(var n=0;n4&&void 0!==arguments[4]&&arguments[4],a=new Kl(this.manager);a.setResponseType("json");var o=this;a.load(e,(function(e){o.data=e;var n=o.parse(r);t(n)}),n,i)},isInBox:function(e,t,n,i,r,a){return!(er||ta)},parse:function(e){for(var t=[],n=this.data,i=0,r=0,a=0,o=0,s=0;s1)for(var v=1;v=Jv.WHEELMAX&&t()}),Jv.WHEELMAX)}),!1),e.addEventListener("mouseup",(function(e){e.preventDefault(),Jv.detect(),t()}),!1),e.addEventListener("touchend",(function(e){e.preventDefault(),t()}),!1)}},qv=function(e){this.camera=e,this.focusLevels=function(e){for(var t=0,n=0,i=0,r=0,a=0,o=0,s=0,l=0,A=1e-6,c=0;cn&&(n=e[c].center.x,o=e[c].radius),e[c].center.zi&&(i=e[c].center.z,s=e[c].radius));var h=new at(t-a,A/=e.length,r-l),u=new at(n+o,A,i+s),d=new at((h.x+u.x)/2,A,(h.z+u.z)/2),f=Math.abs(h.x-u.x),p=Math.abs(h.z-u.z),m=Math.tan(Math.PI/180*.5*this.camera.fov),v=p/2/m,g=f/this.camera.aspect/2/m,y=(new at).copy(d);return y.y+=v>g?v:g,this.camera.position.copy(y),this.camera.lookAt(d),this.camera.updateProjectionMatrix(),d},this.focusSimple=function(){return this.camera.position.copy(new at(0,1e3,0)),this.camera.lookAt(new at),this.camera.updateProjectionMatrix(),new at}},$v=xd("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewoJJ3VzZSBzdHJpY3QnOwoKCWZ1bmN0aW9uIFZlY3RvcjMoeCwgeSwgeikgewoJICB0aGlzLnggPSB4IHx8IDA7CgkgIHRoaXMueSA9IHkgfHwgMDsKCSAgdGhpcy56ID0geiB8fCAwOwoJfQoKCU9iamVjdC5hc3NpZ24oVmVjdG9yMy5wcm90b3R5cGUsIHsKCSAgaXNWZWN0b3IzOiB0cnVlLAoJICBzZXQ6IGZ1bmN0aW9uIHNldCh4LCB5LCB6KSB7CgkgICAgdGhpcy54ID0geDsKCSAgICB0aGlzLnkgPSB5OwoJICAgIHRoaXMueiA9IHo7CgkgICAgcmV0dXJuIHRoaXM7CgkgIH0sCgkgIGNvcHk6IGZ1bmN0aW9uIGNvcHkodikgewoJICAgIHRoaXMueCA9IHYueDsKCSAgICB0aGlzLnkgPSB2Lnk7CgkgICAgdGhpcy56ID0gdi56OwoJICAgIHJldHVybiB0aGlzOwoJICB9LAoJICBkb3Q6IGZ1bmN0aW9uIGRvdCh2KSB7CgkgICAgcmV0dXJuIHRoaXMueCAqIHYueCArIHRoaXMueSAqIHYueSArIHRoaXMueiAqIHYuejsKCSAgfSwKCSAgbGVuZ3RoU3E6IGZ1bmN0aW9uIGxlbmd0aFNxKCkgewoJICAgIHJldHVybiB0aGlzLnggKiB0aGlzLnggKyB0aGlzLnkgKiB0aGlzLnkgKyB0aGlzLnogKiB0aGlzLno7C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woKCSAgICAgICAgICBpZiAoci5lbmQpIDsgZWxzZSB7CgkgICAgICAgICAgICBzZWxmLnBvc3RNZXNzYWdlKHsKCSAgICAgICAgICAgICAgYTogci5pbmRleAoJICAgICAgICAgICAgfSk7CgkgICAgICAgICAgICByLmFib3J0KCk7CgkgICAgICAgICAgICByLmluZGV4ID0gbnVsbDsKCSAgICAgICAgICAgIHIgPSBudWxsOwoJICAgICAgICAgIH0KCSAgICAgICAgfQoJICAgICAgfQoKCSAgICAgIHZhciBsZXZlbCA9IGV2dC5kYXRhLmxldmVsOwoJICAgICAgdmFyIGluZGV4ID0gZXZ0LmRhdGEuaW5kZXg7CgkgICAgICB2YXIgbHIgPSBuZXcgTW9kZWxMb2FkZXIoKS5sb2FkKGV2dC5kYXRhLm11cmwsIGZ1bmN0aW9uIChnZW9EYXRhKSB7CgkgICAgICAgIHNlbGYucG9zdE1lc3NhZ2UoewoJICAgICAgICAgIGE6IGdlb0RhdGEuYSwKCSAgICAgICAgICBiOiBsZXZlbCwKCSAgICAgICAgICBjOiBnZW9EYXRhLmMsCgkgICAgICAgICAgZDogaW5kZXgsCgkgICAgICAgICAgcDogZ2VvRGF0YS5wLAoKCSAgICAgICAgICAvKm46Z2VvRGF0YS5uLCovCgkgICAgICAgICAgdTogZ2VvRGF0YS51LAoJICAgICAgICAgIGk6IGdlb0RhdGEuaQoJICAgICAgICB9LCBbZ2VvRGF0YS5wLmJ1ZmZlciwKCSAgICAgICAgLypnZW9EYXRhLm4uYnVmZmVyLCovCgkgICAgICAgIGdlb0RhdGEudS5idWZmZXIsIGdlb0RhdGEuaS5idWZmZXJdKTsKCSAgICAgICAgbG9hZGluZ1tpbmRleF0gPSB1bmRlZmluZWQ7CgkgICAgICB9LCBmdW5jdGlvbiAobSkge30sIGZ1bmN0aW9uIChtKSB7CgkgICAgICAgIGxvYWRpbmdbaW5kZXhdID0gdW5kZWZpbmVkOwoJICAgICAgICBzZWxmLnBvc3RNZXNzYWdlKHsKCSAgICAgICAgICB4OiBpbmRleAoJICAgICAgICB9KTsKCSAgICAgIH0pOwoJICAgICAgbHIuZW5kID0gZmFsc2U7CgkgICAgICBsci5pbmRleCA9IGluZGV4OwoJICAgICAgbG9hZGluZ1tpbmRleF0gPSBscjsKCSAgICAgIGJyZWFrOwoKCSAgICBjYXNlICJjYW5jZWwiOgoJICAgICAgdmFyIGNpbmRleCA9IGV2dC5kYXRhLmRhdGE7CgoJICAgICAgZm9yICh2YXIgX2kgPSAwLCBjID0gY2luZGV4Lmxlbmd0aDsgX2kgPCBjOyBfaSsrKSB7CgkgICAgICAgIHZhciBzZCA9IGNpbmRleFtfaV07CgoJICAgICAgICBpZiAobG9hZGluZ1tzZF0gJiYgIWxvYWRpbmdbc2RdLmVuZCkgewoJICAgICAgICAgIHNlbGYucG9zdE1lc3NhZ2UoewoJICAgICAgICAgICAgeDogbG9hZGluZ1tzZF0uaW5kZXgKCSAgICAgICAgICB9KTsKCSAgICAgICAgICBsb2FkaW5nW3NkXS5hYm9ydCgpOwoJICAgICAgICAgIGxvYWRpbmdbc2RdID0gdW5kZWZpbmVkOwoJICAgICAgICB9CgkgICAgICB9CgoJICAgICAgYnJlYWs7CgkgIH0KCX07Cgp9KSgpOwoK",null,!1),tg="load",ng="init",ig="detect",rg="cancel";function ag(e){var t=this;this.scene=e,this.loadNum=3,this.loadMaxPT=2,this.currentNum=0,this.pLoadMaxPT=3,this.detectNum=1,this.loadWorkers=[],this.detectWorkers=[],this.todol=[],this.todod=[];for(var n=this,i=function(e){var i=new eg;i.isLoader=!0,i.num=0,i.onmessage=function(e){n.currentNum--,i.num--,n.loadEnd&&e.data&&(void 0!==e.data.d?n.loadEnd(e.data):void 0!==e.data.x&&(n.scene.loading[e.data.x]=void 0))},i.sendMessage=function(e){n.currentNum++,i.num++,i.postMessage(e)},t.loadWorkers.push(i)},r=0;r0)for(var e=0;e0)for(var n=0;n0&&i.applyMatrix4((new bt).fromArray(e.c)),i},parseTextureUrl:function(e){return this.pathUtil.generatePicturePath(e.b,e.a)},parseGeometry:function(e){var t=new si;return t.name=e.a,t.setAttribute("position",new Zn(e.p,3)),t.setAttribute("uv",new Zn(e.u,2)),t.setIndex(new Zn(e.i,1)),t.clearGroups(),t.addGroup(0,e.i.length,0),t}}),lg.prototype=Object.assign(lg.prototype,{constructor:lg,load:function(e){for(var t=0;t0&&this.manager.setTask(a);var s={};s.type=tg,s.data=[];var l=this.pathUtil;this.scene.toload=[];for(var A=0;A0;){for(var m=[],v=0,g=f.length;v0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.isLocal=t,(e.mb||e.cb||e.tb)&&(e.mb?this.GlobalParams.mbase=e.mb:e.cb?this.GlobalParams.mbase=e.cb:e.tb&&(this.GlobalParams.mbase=e.tb),e.cb?this.GlobalParams.cbase=e.cb:e.mb?this.GlobalParams.cbase=e.mb:e.tb&&(this.GlobalParams.cbase=e.tb),e.tb?this.GlobalParams.tbase=e.tb:e.mb?this.GlobalParams.tbase=e.mb:e.cb&&(this.GlobalParams.tbase=e.cb)),this},generateModelPath:function(e,t){return this.GlobalParams.mbase+e+"/"+t+(this.isLocal?".json":".json.gz")},generatePicturePath:function(e,t){return this.GlobalParams.tbase+e+"/maps/"+t+".jpg"},generateConfigPath:function(e){return this.GlobalParams.cbase+e}},new Nc;var cg=new bt,hg=new Wi,ug=function(){function e(t){s(this,e),this.baseUrl=t}return A(e,[{key:"init",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.viewer=e,this.scene=e.scene,this.camera=e.camera,this.renderer=e.renderer,this.sceneGroup=n.root,this.render=e.render,this.initCamera=n.initCamera,this.center={x:0,y:0,z:0},this.pathUtil=(new Ag).config(this.baseUrl,n.isLocal||!1),this.sources={loaded:[],loading:[],nlp:[],levels:[]},this.currCount=0,this.currLoaded=0;var i=new ag(this.sources);this.workerManager=i,n&&(og.pflag=void 0!==n.preloading&&n.preloading,i.loadNum=void 0!==n.concurrency?n.concurrency:i.loadNum,i.loadMaxPT=void 0!==n.capacity?n.capacity:i.loadMaxPT),i.setLoadEnd((function(e){if(t.currLoaded++,t.currLoaded>=t.currCount&&t.loadEnd&&t.loadEnd(),t.initLoad&&(t.initLoad(),t.initLoad=null),t.sources.loaded[e.d]);else{var n=new sg(t.pathUtil).load(e),i=t.sources,r=t.center.y;n.position.y=-r,n.keep=!0,t.sceneGroup.add(n),i.loading[n.index]=void 0,i.loaded[n.index]=n;for(var a=!1,o=i.levels[n.index];o.pid;){if(i.loaded[o.pid]&&!i.loaded[o.pid].keep){for(var s=[],l=0;l0;){for(var A=[],c=0,h=s.length;c0;){for(var g=[],y=0,w=m.length;y=0&&(t=t.slice(0,i)),LoaderUtils.decodeText(new Uint8Array(t))}}]),e}(),pg=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,i=e.length;n=0&&(t=t.slice(0,i)),pg(new Uint8Array(t))}};var vg=1,gg=2,yg=3,wg=4;var xg=function(){function e(t){var n=this;s(this,e),this.sceneManager=t,this.path="",this.loadingTasks={},this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerSourceURL="",this.currentNum=0,this.loadNum=3,this.loadMaxPT=2,this.loadWorkers=[],this.basisLoader=void 0,this.haveNewLoadTaskFlag=!1,this.cachePrioLoadTaskList=[],this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"},this.setDecoderPath(If.getDecoderPath()),this._initDecoder().then((function(){n._initWorkers()}))}return A(e,[{key:"dispose",value:function(){this.sceneManager=null,this.path="",this.loadingTasks={},this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerSourceURL="",this.basisLoader.dispose(),this.basisLoader=null,this.loadWorkers.forEach((function(e){return e.terminate()})),this.loadWorkers=[],this.cachePrioLoadTaskList=[],this.haveNewLoadTaskFlag=!1}},{key:"setPath",value:function(e){this.path=e}},{key:"setDecoderConfig",value:function(e){return this.decoderConfig=e,this}},{key:"_loadLibrary",value:function(e,t){var n=new Kl(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),new Promise((function(t,i){n.load(e,t,void 0,i)}))}},{key:"setDecoderPath",value:function(e){return this.decoderPath=e,this}},{key:"_initDecoder",value:function(){var t=this;if(this.decoderPending)return this.decoderPending;var n="object"!==("undefined"==typeof WebAssembly?"undefined":r(WebAssembly))||"js"===this.decoderConfig.type,i=[];return n?i.push(this._loadLibrary("../amrt_decoder.js","text")):(i.push(this._loadLibrary("../amrt_wasm_wrapper.js","text")),i.push(this._loadLibrary("../../amrt_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(i).then((function(i){var r=i[0];n||(t.decoderConfig.wasmBinary=i[1]);var a=e.MrbsLoaderWorker.toString(),o=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join("\n");t.workerSourceURL=URL.createObjectURL(new Blob([o]))})),this.decoderPending}},{key:"_initWorkers",value:function(){for(var e=this,t=0;t0?t.retData.texs.forEach((function(a){void 0===n.basisLoader&&(n.basisLoader=new Xf,n.basisLoader.setTranscoderPath(function(){var e="js/";if(document.getElementById("AMRT")){var t=document.getElementById("AMRT").src;e=t.slice(0,t.lastIndexOf("/"))+"/"}else for(var n=0;n=i&&n.sceneManager.onCompleteFileLoad(t.retData,e)}),(function(e){console.log("Error: Load basisu texture failed!!! errorCode: "+e)}))})):this.sceneManager.onCompleteFileLoad(t.retData,e)}},{key:"HandleFrameFileLoad",value:function(){var e=this;if(this.haveNewLoadTaskFlag){this.haveNewLoadTaskFlag=!1,this.cachePrioLoadTaskList=[];var t=!1;for(var n in this.loadingTasks){var i=this.loadingTasks[n];void 0!==i&&(i.state!==wg&&(i.priority=this.sceneManager.GetFilePriority(n,i.prioLevel,i.bReplace),i.state===gg?(i.priority,Number.MAX_VALUE):i.state===vg?(this.sceneManager.loadedAllInitChunkComplete||t||0===i.prioLevel&&(t=!0),i.priority===Number.MAX_VALUE&&i.prioLevel>0&&this.sceneManager.CheckIsFixedCamera()?this.sceneManager.CancelLoadingTask(n):this.cachePrioLoadTaskList.push(i)):i.state===yg&&this.sceneManager.CancelLoadingTask(n)))}this.sceneManager.loadedAllInitChunkComplete||t||(this.sceneManager.loadedAllInitChunkComplete=!0),this.cachePrioLoadTaskList.sort((function(e,t){return t.priority-e.priority}))}if([].forEach((function(t){var n={type:"cancel"};n.file=t.file,t.state=yg,e.loadWorkers[t.loaderInx].postMessage(n)})),this.cachePrioLoadTaskList.length>0)for(var r=0;r=n&&t===i}(t)){var c=new o(t);c.skip(4),c.getUint32();var h=0;try{h=c.getUint32()}catch(e){}for(var u=[],d=[],f=[],p=0;p4;)for(var w=c.getUint32(),x=0;x0){var S=c.getArrayBuffer(I);l.Init(new Int8Array(S),S.byteLength),n.decodeType=1;var T=i(r,s,l,n);b.vertexNum=T.numPoints,b.vertexs=T.attributes[0].array}else b.vertexNum=0,b.vertexs=[];else b.vertexNum=c.getUint32(),b.vertexs=c.getFloat32Array(3*b.vertexNum);b.vertexs.buffer&&f.push(b.vertexs.buffer),b.subMeshNum=c.getUint32(),b.subMeshs=[];for(var _=0;_0){S=c.getArrayBuffer(I);l.Init(new Int8Array(S),S.byteLength),n.decodeType=2;T=i(r,s,l,n);b.subMeshs[_].faces=T.attributes[0].array}else b.subMeshs[_].faces=[];else 4==b.subMeshs[_].itemByteNum?b.subMeshs[_].faces=c.getUint32Array(3*b.subMeshs[_].faceNum):2==b.subMeshs[_].itemByteNum?b.subMeshs[_].faces=c.getUint16Array(3*b.subMeshs[_].faceNum):1==b.subMeshs[_].itemByteNum&&(b.subMeshs[_].faces=c.getUint8Array(3*b.subMeshs[_].faceNum));b.subMeshs[_].faces.buffer&&f.push(b.subMeshs[_].faces.buffer)}if(b.bHaveTexture=1&B,b.bTextureFile=2&B,b.bHaveTexture){var I;if(E)if((I=c.getUint32())>0){S=c.getArrayBuffer(I);l.Init(new Int8Array(S),S.byteLength),n.decodeType=1;T=i(r,s,l,n);b.uvNum=T.numPoints,b.uvs=T.attributes[0].array}else b.uvNum=0,b.uvs=[];else b.uvNum=c.getUint32(),b.uvs=c.getFloat32Array(2*b.uvNum);if(b.uvs.buffer&&f.push(b.uvs.buffer),b.bTextureFile){var L=c.getUint8();b.textureFile=c.getString(L)}else{var F=c.getUint8();if(b.textureFile=c.getString(F),1&c.getUint32()){var k=c.getUint32();if(k>0){var P={};P.image=b.textureFile;var U=c.getArrayBuffer(k),D=new Uint8Array(U);D.buffer&&f.push(D.buffer),P.imageArray=D,d.push(P)}}}}y.geometrys.push(b),C+=M,c.setOffset(C)}u.push(y),v+=m,c.setOffset(v)}A.lods=u,A.texs=d,A.share=f}else console.log("mrbs file format error!!!!!!!!");return A}(0,n,s,l,A,c),t(r)}))}catch(t){console.log("decodeMrbsFile failed!!! File: "+e),console.log(t)}}),n,r);return h}(r.data.murl,(function(e){void 0===e?(n[r.data.file]=void 0,self.postMessage({succ:!1,file:r.data.file})):e.lods&&(self.postMessage({succ:!0,file:r.data.file,retData:{lods:e.lods,texs:e.texs}},e.share),n[r.data.file]=void 0)}),(function(e){}),(function(e){n[r.data.file]=void 0,self.postMessage({succ:!1,file:r.data.file})}),l,t);A.end=!1,n[r.data.file]=A;break;case"cancel":n[r.data.file]&&!n[r.data.file].end&&(self.postMessage({succ:!1,file:r.data.file}),n[r.data.file].abort(),n[r.data.file]=void 0)}};var a={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,i=e.length;n=0&&(t=t.slice(0,i)),a.decodeText(new Uint8Array(t))}},s.prototype=Object.assign(s.prototype,{constructor:s,load:function(e,t,i,r){if(void 0===n[e]){n[e]=[],n[e].push({onLoad:t,onProgress:i,onError:r});var a=new XMLHttpRequest;return a.open("GET",e,!0),a.addEventListener("load",(function(t){var i=this.response,r=n[e];if(delete n[e],200===this.status||0===this.status)for(var o=0,s=r.length;o2&&n.root.position.set(Number(a[0]),Number(a[2]),Number(a[1]))}}if(i.coordinate){var o=i.coordinate.split(",");o.length>=2&&(n.coordinate=[Number(o[0]),Number(o[1])])}t&&t()}),null,(function(){t&&t()}))}},{key:"projectBoundingSphere",value:function(e,t,n,i){var r=new at;r.copy(e),r.applyMatrix4(n);var a=t*t,o=r.z*r.z,s=r.lengthSq();return-Math.PI*i*i*a*Math.sqrt(Math.abs((s-a)/(a-o)))/(a-o)}},{key:"computeRangePixels",value:function(e,t){var n=this.camera.fov;return 2*Math.atan(t/e)*180/Math.PI/(Math.max(n,1e-17)/window.innerHeight)}},{key:"GetChildListInNeedForLod",value:function(e){var t=this,n=[];e.isReshowlist=this.InformChildrenLodLoading(e,n),e.reshowlist=n,n.forEach((function(e){e.lastActiveTime=t.curFrameTime})),e.refChildNum=n.length,e.lastShowChildTime=this.curFrameTime,e.fileNode.totalRefChildNum=0,e.fileNode.lods.forEach((function(e){e.refChildNum&&(e.fileNode.totalRefChildNum+=e.refChildNum)}))}},{key:"GetChildListInNeed",value:function(e){var t=this,n=0;e.lods.forEach((function(e){var i=[];e.isReshowlist=t.InformChildrenLodLoading(e,i),e.reshowlist=i,i.forEach((function(e){e.lastActiveTime=t.curFrameTime})),n+=i.length,e.lastShowChildTime=t.curFrameTime})),e.totalRefChildNum=n}},{key:"removeChildListInNeed",value:function(e){e.lods.forEach((function(e){e.isReshowlist=!1,e.reshowlist=void 0,e.lastShowChildTime=void 0})),e.totalRefChildNum=0}},{key:"ShowChildListInNeed",value:function(e){var t=this;(!e.lastShowChildTime||this.curFrameTime-e.lastShowChildTime>=this.updateChildListDeltaTime)&&this.GetChildListInNeedForLod(e);var n=e.isReshowlist;return e.reshowlist&&e.reshowlist.length>0&&e.reshowlist.forEach((function(e){2===e.state&&e.lods.forEach((function(e){t.ShowLod(e)}))})),n}},{key:"traverseMrbsFile",value:function(e){for(var t=this,n=[e],i=[];n.length>0;){var r=n.pop(),a=this.sceneNodeTree[r];if(a)if(a.traverseTwice){a.traverseTwice=!1;for(var o=a.lods.length,s=function(e){var n=a.lods[e],i=0;n.children.forEach((function(e){var n=t.sceneNodeTree[e.file];n&&n.traverseState&&(n.traverseState>i&&(i=n.traverseState),n.traverseState=void 0)})),i!==Bg&&(a.level>=t.minLevelInxForReplaceShow||t.maxLevelAlreadyLoadedForScene-a.level<6&&!t.loadedAllInitChunkComplete)&&(2===a.state?(t.ShowLod(n),t.AddShowedFileNode(a)):(!a.traverseState||i>a.traverseState)&&(a.traverseState=i))},l=0;l=this.maxShowLevel?(a.traverseState=Sg,this.AddShowedFileNode(a)):0===a.lods.length?(this.loadMrbsFile(r,a.level),this.AddShowedFileNode(a)):function(){for(var e=[],o=a.lods.length,s=0,l=0;l=t.minLevelInxForReplaceShow&&i.push(a)),u||-1===a.parentOkLevel)if(-1!==a.parentOkLevel&&a.level-a.parentOkLevel<=2)a.traverseState=Sg;else if(t.ShowChildListInNeed(A))h=!0;else if(-1!==a.parentOkLevel){var d=t.CheckLodIsInFrustumTruly(A);a.traverseState=d?Sg:Eg}else a.traverseState=Eg;else a.traverseState=Sg}else t.ShowLod(A),h=!0;h&&t.AddShowedFileNode(a)}else A.children.forEach((function(t){t.range.x<=s&&s0&&(a.traverseTwice?console.log("Error: sceneTreeFileNode.traverseTwice"):(a.traverseTwice=!0,n.push(r),e.forEach((function(e){n.push(e)})),e=void 0))}()}}i.forEach((function(e){t.LoadReplaceFileNode(e)}))}},{key:"updateFileMaxLoaded",value:function(e,t){e.lods.forEach((function(e){e.maxLoadedLevel=this.minLevelInxForReplaceShow&&e.lastTraverseShowTime!==this.curFrameTime;)t=e,e=e.parentLod?e.parentLod.fileNode:void 0;t&&this.loadMrbsFileByNode(t,t.level,!0)}},{key:"ShowLod",value:function(e){e.subMeshs.forEach((function(e){e.visible=!0})),this.UpdateLod(e)}},{key:"HideLod",value:function(e){e.subMeshs.forEach((function(e){e.visible=!1}))}},{key:"UpdateLod",value:function(e){e.lastActiveTime=this.curFrameTime,this.frameActive.activeLods.push(e),e.fileNode.lastActiveTime=this.curFrameTime}},{key:"updateFrustum",value:function(){Lg.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromMatrix(Lg)}},{key:"update",value:function(){this.updateFrustum(),this.curFrameTime=this.clock.getElapsedTime(),this.frameActive={},this.frameActive.time=this.curFrameTime,this.frameActive.activeLods=[];for(var e=this.rootMrbsFiles.length,t=0;tthis.hideDeltaTime&&(this.HideLod(s),r.splice(o,1),o--,a--)}this.framesActiveList.splice(i,1),n--}this.DestroyTimeoutFileNode()}},{key:"traverseFileNodeForDestroy",value:function(e){for(var t=this,n=[e];n.length>0;){var i=n.pop(),r=this.sceneNodeTree[i];if(void 0===r||void 0===r.lods||r.level>=this.maxShowLevel)return;var a=r.lods.length;if(2===r.state&&this.curFrameTime-r.lastActiveTime>=this.DestroyDeltaTime){for(var o=0;oA.fileNode.level&&A.children.forEach((function(e){n.push(e.file)}))}}}},{key:"DestroyTimeoutFileNode",value:function(){if(this.curFrameTime-this.lastFileNodeDestroyTime>=10){for(var e=this.rootMrbsFiles.length,t=0;t0;){var a=r.pop();a.maxLoadedLevel<=a.fileNode.level?i=!1:a.children.length>0?a.children.forEach((function(e){var a=n.sceneNodeTree[e.file];void 0===a||void 0===a.lods||a.level>=n.maxShowLevel?i=!1:2===a.state?t.push(a):a.lods.forEach((function(e){r.push(e)}))})):i=!1}return i}},{key:"InformChildrenHaveParentLoading",value:function(e,t){var n=this,i=this.sceneNodeTree[e];if(void 0===i||void 0===i.lods||i.level>=this.maxShowLevel)return!1;var r=!0;return 2===i.state?(t.push(i),r=!0):i.lods.forEach((function(e){n.InformChildrenLodLoading(e,t)||(r=!1)})),r}},{key:"CheckLodIsInFrustum",value:function(e){var t={center:e.center,radius:2*e.radius};return this.frustum.containsPoint(e.center)||this.frustum.intersectsSphere(t)}},{key:"CheckLodIsInFrustumTruly",value:function(e){var t={center:e.center,radius:1.5*e.radius};return this.frustum.containsPoint(e.center)||this.frustum.intersectsSphere(t)}},{key:"CancelLoadingTask",value:function(e){var t=this.sceneNodeTree[e];t.state=3,t.checkedChildLoad=!1,this.loaderManager.loadingTasks[e]=void 0}},{key:"GetFilePriority",value:function(e,t,n){var i=this.sceneNodeTree[e];if(!this.bFixedCamera&&(0===i.level||0===t))return 0;var r=Number.MAX_VALUE;if(!n)//!treeFileNode.totalRefChildNum || treeFileNode.totalRefChildNum < parent_file_ref_child_filenode_limit) +{for(var a=!1,o=i.lods.length,s=0;sTg.max.x&&(Tg.max.x=t.max.x),t.max.y>Tg.max.y&&(Tg.max.y=t.max.y),t.max.z>Tg.max.z&&(Tg.max.z=t.max.z)})),n=Tg.getCenter(new at)}this.root.rotateX(-Math.PI/2);var i=Tg;for(var r in this.viewer.isGISViewer?(this.root.position.x-=n.x,this.root.position.y-=n.z,this.root.position.z+=n.y,this.root.position.y=Math.abs(n.z)/2,this.root.updateMatrixWorld(),Tg.applyMatrix4(this.root.matrixWorld),_g=this.root.matrixWorld):(this.root.updateMatrix(),i=Tg.clone().applyMatrix4(this.root.matrix),_g=this.root.matrix),this.isFocus&&this.viewer.fitCamera(this.root,i),setTimeout((function(){t.update()}),1e3),this.viewer.camera.near=1,this.viewer.camera.updateProjectionMatrix(),this.bFixedCamera=!0,this.loaderManager.RefreshLoadFlag(),this.sceneNodeTree){this.sceneNodeTree[r].lods.forEach((function(e){e.center.applyMatrix4(_g)}))}}},{key:"resetGeoCenter",value:function(e){var t=new tn;t.setFromBufferAttribute(e);var n=new at;t.getCenter(n);for(var i=0;ithis.maxLevelAlreadyLoadedForScene&&(this.maxLevelAlreadyLoadedForScene=i.level)}},{key:"setDoubleSide",value:function(e){this.doubeside=e;for(var t=0;t=this.maxShowLevel)){e.state,e.state=1,e.lastActiveTime=this.curFrameTime;var i={};i.chunkIndex=e.chunkIndex,i.level=e.level,i.prioLevel=t,i.level===this.minLevelInxForReplaceShow&&(i.prioLevel=0),i.state=vg,i.file=e.fileName,i.bReplace=!!n,this.loaderManager.AddLoadTask(i)}}},{key:"loadMrbsFile",value:function(e,t){var n=this.sceneNodeTree[e];this.loadMrbsFileByNode(n,t)}},{key:"cancelChildFileLoad",value:function(e){if(!e.checkedChildLoad){e.checkedChildLoad=!0;var t=[];for(e.lods.forEach((function(e){e.children.forEach((function(e){t.push(e.file)}))}));t.length>0;){var n=t.pop(),i=this.sceneNodeTree[n];if(i&&e.level0&&(r.state=yg),i.lods.forEach((function(e){e.children.forEach((function(e){t.push(e.file)}))}))}}}}},{key:"convertArrayBufferToString",value:function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),OA.decodeText(new Uint8Array(e,t,n))}},{key:"isBscbFormatBinary",value:function(e){var t=this.convertArrayBufferToString(e,0,4);return e.byteLength>=4&&"bscb"===t}},{key:"parseTreeFile",value:function(e,t){var n=this;if(this.isBscbFormatBinary(e)){this.rootMrbsFiles=[],this.ChunkRootMrbsFiles=[];var i=new fg(e);i.skip(4),i.getUint32();for(var r=i.getUint32(),a=0;aTg.max.x&&(Tg.max.x=e.center.x+e.radius),e.center.y+e.radius>Tg.max.y&&(Tg.max.y=e.center.y+e.radius),e.center.z+e.radius>Tg.max.z&&(Tg.max.z=e.center.z+e.radius)}}]),e}(),kg=function(){function e(t){s(this,e),void 0===t&&console.error("参数缺少viewer"),this.viewer=t,this.loaders=[],this.largeSceneGroup=this.viewer.modelGroup}return A(e,[{key:"load",value:function(e,t,n,i){var r=!0,a=!1,o=!0,s=0,l=!1;n&&(r=n.focus,a=n.doubeside,null!=n.transparent&&(o=n.transparent),s=n.alphaTest,l=n.isOnline);var A=new Fg(this.viewer,i,this);A.isFocus=r,A.doubeside=a,A.transparent=o,A.alphaTest=s;var c=new zt;return c.path=e,c.isLargeScene=!0,c.loader=A,this.loaders.push(A),c.add(A.root),this.largeSceneGroup.add(c),l?A.load(e+"/conf.mrcb",(function(){t&&t(c)})):A.loadConfig(e+"/confJson.json",(function(){A.load(e+"/conf.mrcb",(function(){c.coordinate=A.coordinate,t&&t(c)}))})),c}},{key:"dispose",value:function(){for(var e=this.loaders.length-1;e>=0;e--){this.loaders[e].dispose()}}}]),e}(),Pg=0,Ug=function(e){h(n,e);var t=y(n);function n(e){var i;s(this,n),(i=t.call(this,e)).enabled=!0,i.viewer=e,i.camera=e.camera,i.viewer.camera.controller=v(i),If.isMobile?i.dblClickHandler=function(e){1===e.touches.length&&(e.timeStamp-Pg<250&&this._dblClickHandler(e.touches[0]),Pg=e.timeStamp)}.bind(v(i)):i.dblClickHandler=i._dblClickHandler.bind(v(i)),e.container.addEventListener("dblclick",i.dblClickHandler),e.container.addEventListener("touchstart",i.dblClickHandler),e.container.position="relative";var r=e.containerRect,a=r.width,o=r.height;return(bg=new Image).src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABcJJREFUaEPVWmtoHFUU/s7djdBqG2i6M7Nb8dkiFqu/pBVfVUGR1AeK/SkqrWl3EgWL+qMFWzB/ov6wm9n04QP9VSoKVaMo+EAtKv6yiiK24gM3M7NNIY02YHbnyJ3d2Uwmuzsz+wjNhYXs3nvPOd+5557XDWGJD1ri8qPjAMw31QsTU+VeEj29RE6vVBCzmGJndqrcm5jSHrb+7aTS2gYgBRZnqR+EfsD99IUIOAlgHIxxZyWPtwuoZQDmy+o1iSTpDmMrEVa1olVmnBGEo+USG9qT1o+t0IgN4MzBzCWzs84gEXQAywNMZwD8CuAkAycJeMY1IWCEgLWofNYBWBbYd44ZRk+PGF01UPgzDpBYAOy89hAY+wFoPia/EHDMcZx31SH7uPf7RE7bnBD4TH4vO7gtPWR+7s1ZOeVGIcS9DNwH4CofLROEJ5Ss+VZUEJEBVIU/6iM8A9Cwok8M12PWDIB/fdHQdjFhFxjp2u+ErVFBRAJQzKd3MPOYx4DBxxzQcFo3v2ukqagA5H4zp14uiHahYpbuIKKdqezEgbCTCAVQNLTnGNjrE/6wqluPhxGOA8CjVcynn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nlV1cyQOiHbbKsW8uo2ZDld5xmuryE3BxhYY/cqg+UFUEO00tvx7XX5NOoLxWovgbYpuvRoFRKsAgooLy2JjN3fDCHrgWgHg9/dVr9Nec9cTJthel906Yso1a3jFATBhaNcL8G4CyQePitV0qr3uEazzwHEW4FyJxeF6vaOoAGwjvRtg6efnnp06/cARABF8Yppm8JGEgyP+Nsx598TkgQh55JOFtuyinWJAdvjcAuS8eeTze58l+8wadKFL9qG7USxYcv9qECWodXNNaCDrJvNO0P4fGKofXnAvUzAAAAAASUVORK5CYII=",bg.style.position="absolute",bg.style.width="30px",bg.style.height="30px",bg.style.top=o/2-15+"px",bg.style.left=a/2-15+"px",bg.style.display="none",(Mg=new Image).src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD8AAAAwCAYAAACmCaIKAAAAAXNSR0IArs4c6QAAAT5JREFUaEPtWsENwjAMvFuHXeAHI/BjBmAFeMEK/GAoxjCKKKgfmrqiVpRcX0i9ND2f7ZrYBAAzOwHYpd8jrw3J20js7DAz2wK4ODZ6kFzRzO4AlgAOYxeTPI7FRuHMbO/YK3E9J/KWiJdIyEHGBe0MdRB5KV9gHLt82QGW26c8p4SnbF/et9sRxi6oYr4X80WVqy4ZJ4A/5TAnrK1michXI6WTiJR3GqwauJSvRkonkVDlzWwNYDHwjk+SVyeHyfBo8unUaPAiGfZOYRslxkP/IL/1tsjn/OM/96X8f+yYf4rc/sfBiWL+bZiwUAzbqJftm/3UtVvk5FNiLCLU7WOp5XcT+byN6kRI+Tp1zbNqW/mu3m6zaaEurbq06tLmU2QFCLWoNZaiIURNYBY3TztXbu0nvHYHj7uztSZHzl/kIiMOWht+IQAAAABJRU5ErkJggg==",Mg.style.position="absolute",Mg.style.width="30px",Mg.style.height="30px",Mg.style.top=o/2-15+"px",Mg.style.left=a/2-15+"px",Mg.style.display="none",e.container.appendChild(bg),e.container.appendChild(Mg),e.container.addEventListener(If.isMobile?"touchstart":"mousedown",(function(e){i.enabled&&(0===e.button||e.touches&&1===e.touches.length)&&(Cg&&clearTimeout(Cg),Cg=setTimeout((function(){bg.style.display="block"}),200))})),e.container.addEventListener(If.isMobile?"touchend":"mouseup",(function(e){i.enabled&&(0===e.button||e.touches)&&(Cg&&(clearTimeout(Cg),Cg=null),bg.style.display="none")})),window.addEventListener("resize",(function(){if(i.enabled){var e=i.viewer.container.getBoundingClientRect(),t=e.width,n=e.height;bg.style.top=n/2+"px",bg.style.left=t/2+"px"}})),i}return A(n,[{key:"update",value:function(){this.enabled&&this._update()}},{key:"_dblClickHandler",value:function(e){var t=this;if(this.enabled){var n=M(this.viewer.picker.rayIntersect(e),1)[0];if(n){var i=n.point,r=this.viewer.picker.vectorToScreen(i),a=(new at).subVectors(this.camera.position,this.target);a=(new at).addScaledVector(a,.8);var o=(new at).addVectors(i,a);this.tween&&this.tween.stop();var s={tx:this.target.x,ty:this.target.y,tz:this.target.z,px:this.camera.position.x,py:this.camera.position.y,pz:this.camera.position.z,cx:r.x-15,cy:r.y-15};this.tween=new ud.Tween(s).to({tx:i.x,ty:i.y,tz:i.z,px:o.x,py:o.y,pz:o.z,cx:this.viewer.containerRect.width/2-15,cy:this.viewer.containerRect.height/2-15},1e3).onUpdate((function(){t.target.set(s.tx,s.ty,s.tz),t.camera.position.set(s.px,s.py,s.pz),Mg.style.top=s.cy+"px",Mg.style.left=s.cx+"px"})).easing(ud.Easing.Cubic.InOut).onComplete((function(){Mg.style.display="none"})).repeat(0).start(),Mg.style.display="block"}}}},{key:"setPosition",value:function(e,t,n){this.object.position.set(e,t,n),this.dispatchEvent("change")}},{key:"setTarget",value:function(e,t,n){this.target.set(e,t,n),this.dispatchEvent("change")}}]),n}(yp),Dg=function(){function e(t,n,i,r){var a=this,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:50,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:50;s(this,e),this.viewer=t,this.camera=new FA(i/-2,i/2,r/2,r/-2,.1,1e3),this.camera.position.set(0,0,1),this.bottom=o,this.left=l;var A=(new tA).load(n,(function(){A.wrapT=A.wrapS=V,A.repeat.multiplyScalar(.994),a.planeWidth=176,a.planeHeight=60;var e=new $i(a.planeWidth,a.planeHeight);a.plane=new Ei(e,new Nn({map:A,transparent:!0})),a.fitCamera(),a.camera.position.y=-r/2+a.bottom+a.planeHeight/2,a.camera.position.x=-i/2+a.left}));this.viewer.renderManager.getRenderer().autoClear=!1,this.viewer.renderManager.addBeforeRenderTask((function(e,t,n){a.onBeforeRender(e,t,n)})),this.viewer.renderManager.addAfterRenderTask((function(e,t,n){a.onAfterRender(e,t,n)}))}return A(e,[{key:"onBeforeRender",value:function(e,t,n){this.viewer.renderManager.getRenderer().clear(),this.plane&&e.domElement.width/e.domElement.height!==this.camera.aspect&&this.onResize(e.domElement.width,e.domElement.height)}},{key:"onAfterRender",value:function(){this.plane&&this.viewer.renderManager.getRenderer().render(this.plane,this.camera)}},{key:"fitCamera",value:function(){var e,t=(new tn).setFromObject(this.plane).getSize(new at),n=this.planeWidth/t.x,i=this.planeHeight/t.y;t.x>=t.y?(e=n)*t.y>this.planeHeight&&(e=i):(e=i)*t.x>this.planeWidth&&(e=n),this.camera.zoom=e,this.camera.updateProjectionMatrix()}},{key:"onResize",value:function(e,t){this.camera.aspect=e/t,this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix(),this.camera.position.y=-t/2+this.bottom+this.planeHeight/2,this.camera.position.x=e/2-this.left-this.planeWidth/2}}]),e}(),Rg=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,e,r))._hotSpotManager=null,i._effectManager=null,i._largeSceneLoader=null,i._largeSceneLoader2=null,i._largeSceneControls=null,i._controls=null,i}return A(n,[{key:"hotSpotManager",get:function(){return this._hotSpotManager||(this._hotSpotManager=new ev(this)),this._hotSpotManager}},{key:"effectManager",get:function(){return this._effectManager||(this._effectManager=new Xv(this)),this._effectManager}},{key:"largeSceneLoader",get:function(){return this._largeSceneLoader||(this._largeSceneLoader=new dg(this)),this._largeSceneLoader}},{key:"largeSceneLoader2",get:function(){return this._largeSceneLoader2||(this._largeSceneLoader2=new kg(this)),this._largeSceneLoader2}},{key:"enableLargeSceneControls",get:function(){return this._enableLargeSceneControls||!1},set:function(e){e!=this._enableLargeSceneControls&&(e?(this._controls=this.controls,this._controls.enabled=!1,this._largeSceneControls||(this._largeSceneControls=new Ug(this),this.renderManager.addAfterRenderTask(this._largeSceneControls.update.bind(this._largeSceneControls))),this._largeSceneControls.enabled=!0,this.controls=this._largeSceneControls):(this.controls=this._controls,this._controls.enabled=!0,this._largeSceneControls.enabled=!1))}},{key:"addWatermark",value:function(e){new Dg(this,e,this.containerRect.width,this.containerRect.height)}}]),n}(Xm);var Og=6378137,Ng=.0066943799901413165,zg=484813681109536e-20,Qg=Math.PI/2,Gg=1e-10,Hg=.017453292519943295,Vg=57.29577951308232,jg=Math.PI/4,Wg=2*Math.PI,Xg=3.14159265359,Yg={greenwich:0,lisbon:-9.131906111111,paris:2.337229166667,bogota:-74.080916666667,madrid:-3.687938888889,rome:12.452333333333,bern:7.439583333333,jakarta:106.807719444444,ferro:-17.666666666667,brussels:4.367975,stockholm:18.058277777778,athens:23.7163375,oslo:10.722916666667},Kg={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}},Zg=/[\s_\-\/\(\)]/g;function Jg(e,t){if(e[t])return e[t];for(var n,i=Object.keys(e),r=t.toLowerCase().replace(Zg,""),a=-1;++a=this.text.length)return;e=this.text[this.place++]}switch(this.state){case 1:return this.neutral(e);case 2:return this.keyword(e);case 4:return this.quoted(e);case 5:return this.afterquote(e);case 3:return this.number(e);case-1:return}},ry.prototype.afterquote=function(e){if('"'===e)return this.word+='"',void(this.state=4);if(ny.test(e))return this.word=this.word.trim(),void this.afterItem(e);throw new Error("havn't handled \""+e+'" in afterquote yet, index '+this.place)},ry.prototype.afterItem=function(e){return","===e?(null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=1)):"]"===e?(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=1,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},ry.prototype.number=function(e){if(!iy.test(e)){if(ny.test(e))return this.word=parseFloat(this.word),void this.afterItem(e);throw new Error("havn't handled \""+e+'" in number yet, index '+this.place)}this.word+=e},ry.prototype.quoted=function(e){'"'!==e?this.word+=e:this.state=5},ry.prototype.keyword=function(e){if(ty.test(e))this.word+=e;else{if("["===e){var t=[];return t.push(this.word),this.level++,null===this.root?this.root=t:this.currentObject.push(t),this.stack.push(this.currentObject),this.currentObject=t,void(this.state=1)}if(!ny.test(e))throw new Error("havn't handled \""+e+'" in keyword yet, index '+this.place);this.afterItem(e)}},ry.prototype.neutral=function(e){if(ey.test(e))return this.word=e,void(this.state=2);if('"'===e)return this.word="",void(this.state=4);if(iy.test(e))return this.word=e,void(this.state=3);if(!ny.test(e))throw new Error("havn't handled \""+e+'" in neutral yet, index '+this.place);this.afterItem(e)},ry.prototype.output=function(){for(;this.place0?90:-90),e.lat_ts=e.lat1)}(r),r}function Ay(e){var t=this;if(2===arguments.length){var n=arguments[1];"string"==typeof n?"+"===n.charAt(0)?Ay[e]=qg(arguments[1]):Ay[e]=ly(arguments[1]):Ay[e]=n}else if(1===arguments.length){if(Array.isArray(e))return e.map((function(e){Array.isArray(e)?Ay.apply(t,e):Ay(e)}));if("string"==typeof e){if(e in Ay)return Ay[e]}else"EPSG"in e?Ay["EPSG:"+e.EPSG]=e:"ESRI"in e?Ay["ESRI:"+e.ESRI]=e:"IAU2000"in e?Ay["IAU2000:"+e.IAU2000]=e:console.log(e);return}}!function(e){e("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),e("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),e("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"),e.WGS84=e["EPSG:4326"],e["EPSG:3785"]=e["EPSG:3857"],e.GOOGLE=e["EPSG:3857"],e["EPSG:900913"]=e["EPSG:3857"],e["EPSG:102113"]=e["EPSG:3857"]}(Ay);var cy=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];var hy=["3857","900913","3785","102113"];function uy(e){if(!function(e){return"string"==typeof e}(e))return e;if(function(e){return e in Ay}(e))return Ay[e];if(function(e){return cy.some((function(t){return e.indexOf(t)>-1}))}(e)){var t=ly(e);if(function(e){var t=Jg(e,"authority");if(t){var n=Jg(t,"epsg");return n&&hy.indexOf(n)>-1}}(t))return Ay["EPSG:3857"];var n=function(e){var t=Jg(e,"extension");if(t)return Jg(t,"proj4")}(t);return n?qg(n):t}return function(e){return"+"===e[0]}(e)?qg(e):void 0}function dy(e,t){var n,i;if(e=e||{},!t)return e;for(i in t)void 0!==(n=t[i])&&(e[i]=n);return e}function fy(e,t,n){var i=e*t;return n/Math.sqrt(1-i*i)}function py(e){return e<0?-1:1}function my(e){return Math.abs(e)<=Xg?e:e-py(e)*Wg}function vy(e,t,n){var i=e*n,r=.5*e;return i=Math.pow((1-i)/(1+i),r),Math.tan(.5*(Qg-t))/i}function gy(e,t){for(var n,i,r=.5*e,a=Qg-2*Math.atan(t),o=0;o<=15;o++)if(n=e*Math.sin(a),a+=i=Qg-2*Math.atan(t*Math.pow((1-n)/(1+n),r))-a,Math.abs(i)<=1e-10)return a;return-9999}function yy(e){return e}var wy=[{init:function(){var e=this.b/this.a;this.es=1-e*e,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=fy(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)},forward:function(e){var t,n,i=e.x,r=e.y;if(r*Vg>90&&r*Vg<-90&&i*Vg>180&&i*Vg<-180)return null;if(Math.abs(Math.abs(r)-Qg)<=Gg)return null;if(this.sphere)t=this.x0+this.a*this.k0*my(i-this.long0),n=this.y0+this.a*this.k0*Math.log(Math.tan(jg+.5*r));else{var a=Math.sin(r),o=vy(this.e,r,a);t=this.x0+this.a*this.k0*my(i-this.long0),n=this.y0-this.a*this.k0*Math.log(o)}return e.x=t,e.y=n,e},inverse:function(e){var t,n,i=e.x-this.x0,r=e.y-this.y0;if(this.sphere)n=Qg-2*Math.atan(Math.exp(-r/(this.a*this.k0)));else{var a=Math.exp(-r/(this.a*this.k0));if(-9999===(n=gy(this.e,a)))return null}return t=my(this.long0+i/(this.a*this.k0)),e.x=t,e.y=n,e},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:yy,inverse:yy,names:["longlat","identity"]}],xy={},by=[];function My(e,t){var n=by.length;return e.names?(by[n]=e,e.names.forEach((function(e){xy[e.toLowerCase()]=n})),this):(console.log(t),!0)}var Cy={start:function(){wy.forEach(My)},add:My,get:function(e){if(!e)return!1;var t=e.toLowerCase();return void 0!==xy[t]&&by[xy[t]]?by[xy[t]]:void 0}},By={MERIT:{a:6378137,rf:298.257,ellipseName:"MERIT 1983"},SGS85:{a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},GRS80:{a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},IAU76:{a:6378140,rf:298.257,ellipseName:"IAU 1976"},airy:{a:6377563.396,b:6356256.91,ellipseName:"Airy 1830"},APL4:{a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},NWL9D:{a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},mod_airy:{a:6377340.189,b:6356034.446,ellipseName:"Modified Airy"},andrae:{a:6377104.43,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},aust_SA:{a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},GRS67:{a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},bessel:{a:6377397.155,rf:299.1528128,ellipseName:"Bessel 1841"},bess_nam:{a:6377483.865,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},clrk66:{a:6378206.4,b:6356583.8,ellipseName:"Clarke 1866"},clrk80:{a:6378249.145,rf:293.4663,ellipseName:"Clarke 1880 mod."},clrk58:{a:6378293.645208759,rf:294.2606763692654,ellipseName:"Clarke 1858"},CPM:{a:6375738.7,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},delmbr:{a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},engelis:{a:6378136.05,rf:298.2566,ellipseName:"Engelis 1985"},evrst30:{a:6377276.345,rf:300.8017,ellipseName:"Everest 1830"},evrst48:{a:6377304.063,rf:300.8017,ellipseName:"Everest 1948"},evrst56:{a:6377301.243,rf:300.8017,ellipseName:"Everest 1956"},evrst69:{a:6377295.664,rf:300.8017,ellipseName:"Everest 1969"},evrstSS:{a:6377298.556,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},fschr60:{a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},fschr60m:{a:6378155,rf:298.3,ellipseName:"Fischer 1960"},fschr68:{a:6378150,rf:298.3,ellipseName:"Fischer 1968"},helmert:{a:6378200,rf:298.3,ellipseName:"Helmert 1906"},hough:{a:6378270,rf:297,ellipseName:"Hough"},intl:{a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},kaula:{a:6378163,rf:298.24,ellipseName:"Kaula 1961"},lerch:{a:6378139,rf:298.257,ellipseName:"Lerch 1979"},mprts:{a:6397300,rf:191,ellipseName:"Maupertius 1738"},new_intl:{a:6378157.5,b:6356772.2,ellipseName:"New International 1967"},plessis:{a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},krass:{a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},SEasia:{a:6378155,b:6356773.3205,ellipseName:"Southeast Asia"},walbeck:{a:6376896,b:6355834.8467,ellipseName:"Walbeck"},WGS60:{a:6378165,rf:298.3,ellipseName:"WGS 60"},WGS66:{a:6378145,rf:298.25,ellipseName:"WGS 66"},WGS7:{a:6378135,rf:298.26,ellipseName:"WGS 72"}},Ey=By.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};By.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var Sy={};Sy.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},Sy.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},Sy.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},Sy.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},Sy.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},Sy.potsdam={towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},Sy.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},Sy.hermannskogel={towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},Sy.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},Sy.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},Sy.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},Sy.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},Sy.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},Sy.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},Sy.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},Sy.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},Sy.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};var Ty={};function _y(e){if(0===e.length)return null;var t="@"===e[0];return t&&(e=e.slice(1)),"null"===e?{name:"null",mandatory:!t,grid:null,isNull:!0}:{name:e,mandatory:!t,grid:Ty[e]||null,isNull:!1}}function Iy(e){return e/3600*Math.PI/180}function Ly(e,t,n){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,n)))}function Fy(e){return e.map((function(e){return[Iy(e.longitudeShift),Iy(e.latitudeShift)]}))}function ky(e,t,n){return{name:Ly(e,t+8,t+16).trim(),parent:Ly(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,n),upperLatitude:e.getFloat64(t+88,n),lowerLongitude:e.getFloat64(t+104,n),upperLongitude:e.getFloat64(t+120,n),latitudeInterval:e.getFloat64(t+136,n),longitudeInterval:e.getFloat64(t+152,n),gridNodeCount:e.getInt32(t+168,n)}}function Py(e,t,n,i){for(var r=t+176,a=[],o=0;o3&&(0===s.datum_params[3]&&0===s.datum_params[4]&&0===s.datum_params[5]&&0===s.datum_params[6]||(s.datum_type=2,s.datum_params[3]*=zg,s.datum_params[4]*=zg,s.datum_params[5]*=zg,s.datum_params[6]=s.datum_params[6]/1e6+1))),o&&(s.datum_type=3,s.grids=o),s.a=n,s.b=i,s.es=r,s.ep2=a,s}(n.datumCode,n.datum_params,a.a,a.b,o.es,o.ep2,s);dy(this,n),dy(this,i),this.a=a.a,this.b=a.b,this.rf=a.rf,this.sphere=a.sphere,this.es=o.es,this.e=o.e,this.ep2=o.ep2,this.datum=l,this.init(),t(null,this)}else t(e)}else t(e)}function Dy(e,t,n){var i,r,a,o,s=e.x,l=e.y,A=e.z?e.z:0;if(l<-Qg&&l>-1.001*Qg)l=-Qg;else if(l>Qg&&l<1.001*Qg)l=Qg;else{if(l<-Qg)return{x:-1/0,y:-1/0,z:e.z};if(l>Qg)return{x:1/0,y:1/0,z:e.z}}return s>Math.PI&&(s-=2*Math.PI),r=Math.sin(l),o=Math.cos(l),a=r*r,{x:((i=n/Math.sqrt(1-t*a))+A)*o*Math.cos(s),y:(i+A)*o*Math.sin(s),z:(i*(1-t)+A)*r}}function Ry(e,t,n,i){var r,a,o,s,l,A,c,h,u,d,f,p,m,v,g,y=1e-12,w=e.x,x=e.y,b=e.z?e.z:0;if(r=Math.sqrt(w*w+x*x),a=Math.sqrt(w*w+x*x+b*b),r/n1e-24&&m<30);return{x:v,y:Math.atan(f/Math.abs(d)),z:g}}function Oy(e){return 1===e||2===e}function Ny(e,t,n){if(function(e,t){return e.datum_type===t.datum_type&&!(e.a!==t.a||Math.abs(e.es-t.es)>5e-11)&&(1===e.datum_type?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]:2!==e.datum_type||e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]&&e.datum_params[3]===t.datum_params[3]&&e.datum_params[4]===t.datum_params[4]&&e.datum_params[5]===t.datum_params[5]&&e.datum_params[6]===t.datum_params[6])}(e,t))return n;if(5===e.datum_type||5===t.datum_type)return n;var i=e.a,r=e.es;if(3===e.datum_type){if(0!==zy(e,!1,n))return;i=Og,r=Ng}var a=t.a,o=t.b,s=t.es;if(3===t.datum_type&&(a=Og,o=6356752.314,s=Ng),r===s&&i===a&&!Oy(e.datum_type)&&!Oy(t.datum_type))return n;if((n=Dy(n,r,i),Oy(e.datum_type)&&(n=function(e,t,n){if(1===t)return{x:e.x+n[0],y:e.y+n[1],z:e.z+n[2]};if(2===t){var i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6];return{x:A*(e.x-l*e.y+s*e.z)+i,y:A*(l*e.x+e.y-o*e.z)+r,z:A*(-s*e.x+o*e.y+e.z)+a}}}(n,e.datum_type,e.datum_params)),Oy(t.datum_type)&&(n=function(e,t,n){if(1===t)return{x:e.x-n[0],y:e.y-n[1],z:e.z-n[2]};if(2===t){var i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6],c=(e.x-i)/A,h=(e.y-r)/A,u=(e.z-a)/A;return{x:c+l*h-s*u,y:-l*c+h+o*u,z:s*c-o*h+u}}}(n,t.datum_type,t.datum_params)),n=Ry(n,s,a,o),3===t.datum_type)&&0!==zy(t,!0,n))return;return n}function zy(e,t,n){if(null===e.grids||0===e.grids.length)return console.log("Grid shift grids not found"),-1;for(var i={x:-n.x,y:n.y},r={x:Number.NaN,y:Number.NaN},a=[],o=0;oi.y||c>i.x||d1e-12&&Math.abs(o.y)>1e-12);if(l<0)return console.log("Inverse grid shift iterator failed to converge."),i;i.x=my(a.x+n.ll[0]),i.y=a.y+n.ll[1]}else isNaN(a.x)||(i.x=e.x+a.x,i.y=e.y+a.y);return i}function Gy(e,t){var n,i={x:e.x/t.del[0],y:e.y/t.del[1]},r=Math.floor(i.x),a=Math.floor(i.y),o=i.x-1*r,s=i.y-1*a,l={x:Number.NaN,y:Number.NaN};if(r<0||r>=t.lim[0])return l;if(a<0||a>=t.lim[1])return l;n=a*t.lim[0]+r;var A=t.cvs[n][0],c=t.cvs[n][1];n++;var h=t.cvs[n][0],u=t.cvs[n][1];n+=t.lim[0];var d=t.cvs[n][0],f=t.cvs[n][1];n--;var p=t.cvs[n][0],m=t.cvs[n][1],v=o*s,g=o*(1-s),y=(1-o)*(1-s),w=(1-o)*s;return l.x=y*A+g*h+w*p+v*d,l.y=y*c+g*u+w*m+v*f,l}function Hy(e,t,n){var i,r,a,o=n.x,s=n.y,l=n.z||0,A={};for(a=0;a<3;a++)if(!t||2!==a||void 0!==n.z)switch(0===a?(i=o,r=-1!=="ew".indexOf(e.axis[a])?"x":"y"):1===a?(i=s,r=-1!=="ns".indexOf(e.axis[a])?"y":"x"):(i=l,r="z"),e.axis[a]){case"e":case"n":A[r]=i;break;case"w":case"s":A[r]=-i;break;case"u":void 0!==n[r]&&(A.z=i);break;case"d":void 0!==n[r]&&(A.z=-i);break;default:return null}return A}function Vy(e){var t={x:e[0],y:e[1]};return e.length>2&&(t.z=e[2]),e.length>3&&(t.m=e[3]),t}function jy(e){if("function"==typeof Number.isFinite){if(Number.isFinite(e))return;throw new TypeError("coordinates must be finite numbers")}if("number"!=typeof e||e!=e||!isFinite(e))throw new TypeError("coordinates must be finite numbers")}function Wy(e,t,n,i){var r;if(Array.isArray(n)&&(n=Vy(n)),function(e){jy(e.x),jy(e.y)}(n),e.datum&&t.datum&&function(e,t){return(1===e.datum.datum_type||2===e.datum.datum_type)&&"WGS84"!==t.datumCode||(1===t.datum.datum_type||2===t.datum.datum_type)&&"WGS84"!==e.datumCode}(e,t)&&(n=Wy(e,r=new Uy("WGS84"),n,i),e=r),i&&"enu"!==e.axis&&(n=Hy(e,!1,n)),"longlat"===e.projName)n={x:n.x*Hg,y:n.y*Hg,z:n.z||0};else if(e.to_meter&&(n={x:n.x*e.to_meter,y:n.y*e.to_meter,z:n.z||0}),!(n=e.inverse(n)))return;if(e.from_greenwich&&(n.x+=e.from_greenwich),n=Ny(e.datum,t.datum,n))return t.from_greenwich&&(n={x:n.x-t.from_greenwich,y:n.y,z:n.z||0}),"longlat"===t.projName?n={x:n.x*Vg,y:n.y*Vg,z:n.z||0}:(n=t.forward(n),t.to_meter&&(n={x:n.x/t.to_meter,y:n.y/t.to_meter,z:n.z||0})),i&&"enu"!==t.axis?Hy(t,!0,n):n}Uy.projections=Cy,Uy.projections.start();var Xy=Uy("WGS84");function Yy(e,t,n,i){var r,a,o;return Array.isArray(n)?(r=Wy(e,t,n,i)||{x:NaN,y:NaN},n.length>2?void 0!==e.name&&"geocent"===e.name||void 0!==t.name&&"geocent"===t.name?"number"==typeof r.z?[r.x,r.y,r.z].concat(n.splice(3)):[r.x,r.y,n[2]].concat(n.splice(3)):[r.x,r.y].concat(n.splice(2)):[r.x,r.y]):(a=Wy(e,t,n,i),2===(o=Object.keys(n)).length||o.forEach((function(i){if(void 0!==e.name&&"geocent"===e.name||void 0!==t.name&&"geocent"===t.name){if("x"===i||"y"===i||"z"===i)return}else if("x"===i||"y"===i)return;a[i]=n[i]})),a)}function Ky(e){return e instanceof Uy?e:e.oProj?e.oProj:Uy(e)}function Zy(e,t,n){e=Ky(e);var i,r=!1;return void 0===t?(t=e,e=Xy,r=!0):(void 0!==t.x||Array.isArray(t))&&(n=t,t=e,e=Xy,r=!0),t=Ky(t),n?Yy(e,t,n):(i={forward:function(n,i){return Yy(e,t,n,i)},inverse:function(n,i){return Yy(t,e,n,i)}},r&&(i.oProj=t),i)}var Jy="AJSAJS",qy="AFAFAF",$y=65,ew=73,tw=79,nw=86,iw=90,rw={forward:aw,inverse:function(e){var t=Aw(uw(e.toUpperCase()));if(t.lat&&t.lon)return[t.lon,t.lat,t.lon,t.lat];return[t.left,t.bottom,t.right,t.top]},toPoint:ow};function aw(e,t){return t=t||5,function(e,t){var n="00000"+e.easting,i="00000"+e.northing;return e.zoneNumber+e.zoneLetter+(r=e.easting,a=e.northing,o=e.zoneNumber,s=hw(o),l=Math.floor(r/1e5),A=Math.floor(a/1e5)%20,function(e,t,n){var i=n-1,r=Jy.charCodeAt(i),a=qy.charCodeAt(i),o=r+e-1,s=a+t,l=!1;return o>iw&&(o=o-iw+$y-1,l=!0),(o===ew||rew||(o>ew||rtw||(o>tw||riw&&(o=o-iw+$y-1),s>nw?(s=s-nw+$y-1,l=!0):l=!1,(s===ew||aew||(s>ew||atw||(s>tw||anw&&(s=s-nw+$y-1),String.fromCharCode(o)+String.fromCharCode(s)}(l,A,s))+n.substr(n.length-5,t)+i.substr(i.length-5,t);var r,a,o,s,l,A}(function(e){var t,n,i,r,a,o,s,l,A=e.lat,c=e.lon,h=6378137,u=.00669438,d=.9996,f=sw(A),p=sw(c);l=Math.floor((c+180)/6)+1,180===c&&(l=60);A>=56&&A<64&&c>=3&&c<12&&(l=32);A>=72&&A<84&&(c>=0&&c<9?l=31:c>=9&&c<21?l=33:c>=21&&c<33?l=35:c>=33&&c<42&&(l=37));s=sw(6*(l-1)-180+3),t=u/(1-u),n=h/Math.sqrt(1-u*Math.sin(f)*Math.sin(f)),i=Math.tan(f)*Math.tan(f),r=t*Math.cos(f)*Math.cos(f),a=Math.cos(f)*(p-s),o=h*((1-u/4-3*u*u/64-5*u*u*u/256)*f-(3*u/8+3*u*u/32+45*u*u*u/1024)*Math.sin(2*f)+(15*u*u/256+45*u*u*u/1024)*Math.sin(4*f)-35*u*u*u/3072*Math.sin(6*f));var m=d*n*(a+(1-i+r)*a*a*a/6+(5-18*i+i*i+72*r-58*t)*a*a*a*a*a/120)+5e5,v=d*(o+n*Math.tan(f)*(a*a/2+(5-i+9*r+4*r*r)*a*a*a*a/24+(61-58*i+i*i+600*r-330*t)*a*a*a*a*a*a/720));A<0&&(v+=1e7);return{northing:Math.round(v),easting:Math.round(m),zoneNumber:l,zoneLetter:cw(A)}}({lat:e[1],lon:e[0]}),t)}function ow(e){var t=Aw(uw(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function sw(e){return e*(Math.PI/180)}function lw(e){return e/Math.PI*180}function Aw(e){var t=e.northing,n=e.easting,i=e.zoneLetter,r=e.zoneNumber;if(r<0||r>60)return null;var a,o,s,l,A,c,h,u,d,f=.9996,p=6378137,m=.00669438,v=(1-Math.sqrt(.99330562))/(1+Math.sqrt(.99330562)),g=n-5e5,y=t;i<"N"&&(y-=1e7),h=6*(r-1)-180+3,a=.006739496752268451,d=(u=y/f/6367449.145945056)+(3*v/2-27*v*v*v/32)*Math.sin(2*u)+(21*v*v/16-55*v*v*v*v/32)*Math.sin(4*u)+151*v*v*v/96*Math.sin(6*u),o=p/Math.sqrt(1-m*Math.sin(d)*Math.sin(d)),s=Math.tan(d)*Math.tan(d),l=a*Math.cos(d)*Math.cos(d),A=.99330562*p/Math.pow(1-m*Math.sin(d)*Math.sin(d),1.5),c=g/(o*f);var w=d-o*Math.tan(d)/A*(c*c/2-(5+3*s+10*l-4*l*l-9*a)*c*c*c*c/24+(61+90*s+298*l+45*s*s-1.6983531815716497-3*l*l)*c*c*c*c*c*c/720);w=lw(w);var x,b=(c-(1+2*s+l)*c*c*c/6+(5-2*l+28*s-3*l*l+8*a+24*s*s)*c*c*c*c*c/120)/Math.cos(d);if(b=h+lw(b),e.accuracy){var M=Aw({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});x={top:M.lat,right:M.lon,bottom:w,left:b}}else x={lat:w,lon:b};return x}function cw(e){var t="Z";return 84>=e&&e>=72?t="X":72>e&&e>=64?t="W":64>e&&e>=56?t="V":56>e&&e>=48?t="U":48>e&&e>=40?t="T":40>e&&e>=32?t="S":32>e&&e>=24?t="R":24>e&&e>=16?t="Q":16>e&&e>=8?t="P":8>e&&e>=0?t="N":0>e&&e>=-8?t="M":-8>e&&e>=-16?t="L":-16>e&&e>=-24?t="K":-24>e&&e>=-32?t="J":-32>e&&e>=-40?t="H":-40>e&&e>=-48?t="G":-48>e&&e>=-56?t="F":-56>e&&e>=-64?t="E":-64>e&&e>=-72?t="D":-72>e&&e>=-80&&(t="C"),t}function hw(e){var t=e%6;return 0===t&&(t=6),t}function uw(e){if(e&&0===e.length)throw"MGRSPoint coverting from nothing";for(var t,n=e.length,i=null,r="",a=0;!/[A-Z]/.test(t=e.charAt(a));){if(a>=2)throw"MGRSPoint bad conversion from: "+e;r+=t,a++}var o=parseInt(r,10);if(0===a||a+3>n)throw"MGRSPoint bad conversion from: "+e;var s=e.charAt(a++);if(s<="A"||"B"===s||"Y"===s||s>="Z"||"I"===s||"O"===s)throw"MGRSPoint zone letter "+s+" not handled: "+e;i=e.substring(a,a+=2);for(var l=hw(o),A=function(e,t){var n=Jy.charCodeAt(t-1),i=1e5,r=!1;for(;n!==e.charCodeAt(0);){if(++n===ew&&n++,n===tw&&n++,n>iw){if(r)throw"Bad character: "+e;n=$y,r=!0}i+=1e5}return i}(i.charAt(0),l),c=function(e,t){if(e>"V")throw"MGRSPoint given invalid Northing "+e;var n=qy.charCodeAt(t-1),i=0,r=!1;for(;n!==e.charCodeAt(0);){if(++n===ew&&n++,n===tw&&n++,n>nw){if(r)throw"Bad character: "+e;n=$y,r=!0}i+=1e5}return i}(i.charAt(1),l);c0&&(u=1e5/Math.pow(10,p),d=e.substring(a,a+p),m=parseFloat(d)*u,f=e.substring(a+p),v=parseFloat(f)*u),{easting:m+A,northing:v+c,zoneLetter:s,zoneNumber:o,accuracy:u}}function dw(e){var t;switch(e){case"C":t=11e5;break;case"D":t=2e6;break;case"E":t=28e5;break;case"F":t=37e5;break;case"G":t=46e5;break;case"H":t=55e5;break;case"J":t=64e5;break;case"K":t=73e5;break;case"L":t=82e5;break;case"M":t=91e5;break;case"N":t=0;break;case"P":t=8e5;break;case"Q":t=17e5;break;case"R":t=26e5;break;case"S":t=35e5;break;case"T":t=44e5;break;case"U":t=53e5;break;case"V":t=62e5;break;case"W":t=7e6;break;case"X":t=79e5;break;default:t=-1}if(t>=0)return t;throw"Invalid zone letter: "+e}function fw(e,t,n){if(!(this instanceof fw))return new fw(e,t,n);if(Array.isArray(e))this.x=e[0],this.y=e[1],this.z=e[2]||0;else if("object"==typeof e)this.x=e.x,this.y=e.y,this.z=e.z||0;else if("string"==typeof e&&void 0===t){var i=e.split(",");this.x=parseFloat(i[0],10),this.y=parseFloat(i[1],10),this.z=parseFloat(i[2],10)||0}else this.x=e,this.y=t,this.z=n||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}fw.fromMGRS=function(e){return new fw(ow(e))},fw.prototype.toMGRS=function(e){return aw([this.x,this.y],e)};var pw=.046875,mw=.01953125,vw=.01068115234375;function gw(e){var t=[];t[0]=1-e*(.25+e*(pw+e*(mw+e*vw))),t[1]=e*(.75-e*(pw+e*(mw+e*vw)));var n=e*e;return t[2]=n*(.46875-e*(.013020833333333334+.007120768229166667*e)),n*=e,t[3]=n*(.3645833333333333-.005696614583333333*e),t[4]=n*e*.3076171875,t}function yw(e,t,n,i){return n*=t,t*=t,i[0]*e-n*(i[1]+t*(i[2]+t*(i[3]+t*i[4])))}function ww(e,t,n){for(var i=1/(1-t),r=e,a=20;a;--a){var o=Math.sin(r),s=1-t*o*o;if(r-=s=(yw(r,o,Math.cos(r),n)-e)*(s*Math.sqrt(s))*i,Math.abs(s)Gg?Math.tan(a):0,f=Math.pow(d,2),p=Math.pow(f,2);t=1-this.es*Math.pow(s,2),A/=Math.sqrt(t);var m=yw(a,s,l,this.en);n=this.a*(this.k0*A*(1+c/6*(1-f+h+c/20*(5-18*f+p+14*h-58*f*h+c/42*(61+179*p-p*f-479*f)))))+this.x0,i=this.a*(this.k0*(m-this.ml0+s*o*A/2*(1+c/12*(5-f+9*h+4*u+c/30*(61+p-58*f+270*h-330*f*h+c/56*(1385+543*p-p*f-3111*f))))))+this.y0}else{var v=l*Math.sin(o);if(Math.abs(Math.abs(v)-1)=1){if(v-1>Gg)return 93;i=0}else i=Math.acos(i);a<0&&(i=-i),i=this.a*this.k0*(i-this.lat0)+this.y0}return e.x=n,e.y=i,e},inverse:function(e){var t,n,i,r,a=(e.x-this.x0)*(1/this.a),o=(e.y-this.y0)*(1/this.a);if(this.es)if(n=ww(t=this.ml0+o/this.k0,this.es,this.en),Math.abs(n)Gg?Math.tan(n):0,c=this.ep2*Math.pow(l,2),h=Math.pow(c,2),u=Math.pow(A,2),d=Math.pow(u,2);t=1-this.es*Math.pow(s,2);var f=a*Math.sqrt(t)/this.k0,p=Math.pow(f,2);i=n-(t*=A)*p/(1-this.es)*.5*(1-p/12*(5+3*u-9*c*u+c-4*h-p/30*(61+90*u-252*c*u+45*d+46*c-p/56*(1385+3633*u+4095*d+1574*d*u)))),r=my(this.long0+f*(1-p/6*(1+2*u+c-p/20*(5+28*u+24*d+8*c*u+6*c-p/42*(61+662*u+1320*d+720*d*u))))/l)}else i=Qg*py(o),r=0;else{var m=Math.exp(a/this.k0),v=.5*(m-1/m),g=this.lat0+o/this.k0,y=Math.cos(g);t=Math.sqrt((1-Math.pow(y,2))/(1+Math.pow(v,2))),i=Math.asin(t),o<0&&(i=-i),r=0===v&&0===y?0:my(Math.atan2(v,y)+this.long0)}return e.x=r,e.y=i,e},names:["Fast_Transverse_Mercator","Fast Transverse Mercator"]};function bw(e){var t=Math.exp(e);return t=(t-1/t)/2}function Mw(e,t){e=Math.abs(e),t=Math.abs(t);var n=Math.max(e,t),i=Math.min(e,t)/(n||1);return n*Math.sqrt(1+Math.pow(i,2))}function Cw(e){var t=Math.abs(e);return t=function(e){var t=1+e,n=t-1;return 0===n?e:e*Math.log(t)/n}(t*(1+t/(Mw(1,t)+1))),e<0?-t:t}function Bw(e,t){for(var n,i=2*Math.cos(2*t),r=e.length-1,a=e[r],o=0;--r>=0;)n=i*a-o+e[r],o=a,a=n;return t+n*Math.sin(2*t)}function Ew(e,t,n){for(var i,r,a=Math.sin(t),o=Math.cos(t),s=bw(n),l=function(e){var t=Math.exp(e);return(t+1/t)/2}(n),A=2*o*l,c=-2*a*s,h=e.length-1,u=e[h],d=0,f=0,p=0;--h>=0;)i=f,r=d,u=A*(f=u)-i-c*(d=p)+e[h],p=c*f-r+A*d;return[(A=a*l)*u-(c=o*s)*p,A*p+c*u]}var Sw={init:function(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(xw.init.apply(this),this.forward=xw.forward,this.inverse=xw.inverse),this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+Math.sqrt(1-this.es)),t=e/(2-e),n=t;this.cgb[0]=t*(2+t*(-2/3+t*(t*(116/45+t*(26/45+t*(-2854/675)))-2))),this.cbg[0]=t*(t*(2/3+t*(4/3+t*(-82/45+t*(32/45+t*(4642/4725)))))-2),n*=t,this.cgb[1]=n*(7/3+t*(t*(-227/45+t*(2704/315+t*(2323/945)))-1.6)),this.cbg[1]=n*(5/3+t*(-16/15+t*(-13/9+t*(904/315+t*(-1522/945))))),n*=t,this.cgb[2]=n*(56/15+t*(-136/35+t*(-1262/105+t*(73814/2835)))),this.cbg[2]=n*(-26/15+t*(34/21+t*(1.6+t*(-12686/2835)))),n*=t,this.cgb[3]=n*(4279/630+t*(-332/35+t*(-399572/14175))),this.cbg[3]=n*(1237/630+t*(t*(-24832/14175)-2.4)),n*=t,this.cgb[4]=n*(4174/315+t*(-144838/6237)),this.cbg[4]=n*(-734/315+t*(109598/31185)),n*=t,this.cgb[5]=n*(601676/22275),this.cbg[5]=n*(444337/155925),n=Math.pow(t,2),this.Qn=this.k0/(1+t)*(1+n*(1/4+n*(1/64+n/256))),this.utg[0]=t*(t*(2/3+t*(-37/96+t*(1/360+t*(81/512+t*(-96199/604800)))))-.5),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+t*(7891/37800)))))),this.utg[1]=n*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+t*(1118711/3870720))))),this.gtu[1]=n*(13/48+t*(t*(557/1440+t*(281/630+t*(-1983433/1935360)))-.6)),n*=t,this.utg[2]=n*(-17/480+t*(37/840+t*(209/4480+t*(-5569/90720)))),this.gtu[2]=n*(61/240+t*(-103/140+t*(15061/26880+t*(167603/181440)))),n*=t,this.utg[3]=n*(-4397/161280+t*(11/504+t*(830251/7257600))),this.gtu[3]=n*(49561/161280+t*(-179/168+t*(6601661/7257600))),n*=t,this.utg[4]=n*(-4583/161280+t*(108847/3991680)),this.gtu[4]=n*(34729/80640+t*(-3418889/1995840)),n*=t,this.utg[5]=n*(-20648693/638668800),this.gtu[5]=.6650675310896665*n;var i=Bw(this.cbg,this.lat0);this.Zb=-this.Qn*(i+function(e,t){for(var n,i=2*Math.cos(t),r=e.length-1,a=e[r],o=0;--r>=0;)n=i*a-o+e[r],o=a,a=n;return Math.sin(t)*n}(this.gtu,2*i))},forward:function(e){var t=my(e.x-this.long0),n=e.y;n=Bw(this.cbg,n);var i=Math.sin(n),r=Math.cos(n),a=Math.sin(t),o=Math.cos(t);n=Math.atan2(i,o*r),t=Math.atan2(a*r,Mw(i,r*o)),t=Cw(Math.tan(t));var s,l,A=Ew(this.gtu,2*n,2*t);return n+=A[0],t+=A[1],Math.abs(t)<=2.623395162778?(s=this.a*(this.Qn*t)+this.x0,l=this.a*(this.Qn*n+this.Zb)+this.y0):(s=1/0,l=1/0),e.x=s,e.y=l,e},inverse:function(e){var t,n,i=(e.x-this.x0)*(1/this.a),r=(e.y-this.y0)*(1/this.a);if(r=(r-this.Zb)/this.Qn,i/=this.Qn,Math.abs(i)<=2.623395162778){var a=Ew(this.utg,2*r,2*i);r+=a[0],i+=a[1],i=Math.atan(bw(i));var o=Math.sin(r),s=Math.cos(r),l=Math.sin(i),A=Math.cos(i);r=Math.atan2(o*A,Mw(l,A*s)),t=my((i=Math.atan2(l,A*s))+this.long0),n=Bw(this.cgb,r)}else t=1/0,n=1/0;return e.x=t,e.y=n,e},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","tmerc"]};var Tw={init:function(){var e=function(e,t){if(void 0===e){if((e=Math.floor(30*(my(t)+Math.PI)/Math.PI)+1)<0)return 0;if(e>60)return 60}return e}(this.zone,this.long0);if(void 0===e)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(e)-183)*Hg,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Sw.init.apply(this),this.forward=Sw.forward,this.inverse=Sw.inverse},names:["Universal Transverse Mercator System","utm"],dependsOn:"etmerc"};function _w(e,t){return Math.pow((1-e)/(1+e),t)}var Iw={init:function(){var e=Math.sin(this.lat0),t=Math.cos(this.lat0);t*=t,this.rc=Math.sqrt(1-this.es)/(1-this.es*e*e),this.C=Math.sqrt(1+this.es*t*t/(1-this.es)),this.phic0=Math.asin(e/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+jg)/(Math.pow(Math.tan(.5*this.lat0+jg),this.C)*_w(this.e*e,this.ratexp))},forward:function(e){var t=e.x,n=e.y;return e.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*n+jg),this.C)*_w(this.e*Math.sin(n),this.ratexp))-Qg,e.x=this.C*t,e},inverse:function(e){for(var t=e.x/this.C,n=e.y,i=Math.pow(Math.tan(.5*n+jg)/this.K,1/this.C),r=20;r>0&&(n=2*Math.atan(i*_w(this.e*Math.sin(e.y),-.5*this.e))-Qg,!(Math.abs(n-e.y)<1e-14));--r)e.y=n;return r?(e.x=t,e.y=n,e):null},names:["gauss"]};var Lw={init:function(){Iw.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},forward:function(e){var t,n,i,r;return e.x=my(e.x-this.long0),Iw.forward.apply(this,[e]),t=Math.sin(e.y),n=Math.cos(e.y),i=Math.cos(e.x),r=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*n*i),e.x=r*n*Math.sin(e.x),e.y=r*(this.cosc0*t-this.sinc0*n*i),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e},inverse:function(e){var t,n,i,r,a;if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,a=Math.sqrt(e.x*e.x+e.y*e.y)){var o=2*Math.atan2(a,this.R2);t=Math.sin(o),n=Math.cos(o),r=Math.asin(n*this.sinc0+e.y*t*this.cosc0/a),i=Math.atan2(e.x*t,a*this.cosc0*n-e.y*this.sinc0*t)}else r=this.phic0,i=0;return e.x=i,e.y=r,Iw.inverse.apply(this,[e]),e.x=my(e.x+this.long0),e},names:["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"]};var Fw={init:function(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Gg&&(this.k0=.5*(1+py(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=Gg&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Gg&&(this.k0=.5*this.cons*fy(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/vy(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=fy(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-Qg,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},forward:function(e){var t,n,i,r,a,o,s=e.x,l=e.y,A=Math.sin(l),c=Math.cos(l),h=my(s-this.long0);return Math.abs(Math.abs(s-this.long0)-Math.PI)<=Gg&&Math.abs(l+this.lat0)<=Gg?(e.x=NaN,e.y=NaN,e):this.sphere?(t=2*this.k0/(1+this.sinlat0*A+this.coslat0*c*Math.cos(h)),e.x=this.a*t*c*Math.sin(h)+this.x0,e.y=this.a*t*(this.coslat0*A-this.sinlat0*c*Math.cos(h))+this.y0,e):(n=2*Math.atan(this.ssfn_(l,A,this.e))-Qg,r=Math.cos(n),i=Math.sin(n),Math.abs(this.coslat0)<=Gg?(a=vy(this.e,l*this.con,this.con*A),o=2*this.a*this.k0*a/this.cons,e.x=this.x0+o*Math.sin(s-this.long0),e.y=this.y0-this.con*o*Math.cos(s-this.long0),e):(Math.abs(this.sinlat0)0?my(this.long0+Math.atan2(e.x,-1*e.y)):my(this.long0+Math.atan2(e.x,e.y)):my(this.long0+Math.atan2(e.x*Math.sin(s),o*this.coslat0*Math.cos(s)-e.y*this.sinlat0*Math.sin(s))),e.x=t,e.y=n,e)}if(Math.abs(this.coslat0)<=Gg){if(o<=Gg)return n=this.lat0,t=this.long0,e.x=t,e.y=n,e;e.x*=this.con,e.y*=this.con,i=o*this.cons/(2*this.a*this.k0),n=this.con*gy(this.e,i),t=this.con*my(this.con*this.long0+Math.atan2(e.x,-1*e.y))}else r=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=Gg?a=this.X0:(a=Math.asin(Math.cos(r)*this.sinX0+e.y*Math.sin(r)*this.cosX0/o),t=my(this.long0+Math.atan2(e.x*Math.sin(r),o*this.cosX0*Math.cos(r)-e.y*this.sinX0*Math.sin(r)))),n=-1*gy(this.e,Math.tan(.5*(Qg+a)));return e.x=t,e.y=n,e},names:["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],ssfn_:function(e,t,n){return t*=n,Math.tan(.5*(Qg+e))*Math.pow((1-t)/(1+t),.5*n)}};var kw={init:function(){var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),n=this.a,i=1/this.rf,r=2*i-Math.pow(i,2),a=this.e=Math.sqrt(r);this.R=this.k0*n*Math.sqrt(1-r)/(1-r*Math.pow(t,2)),this.alpha=Math.sqrt(1+r/(1-r)*Math.pow(Math.cos(e),4)),this.b0=Math.asin(t/this.alpha);var o=Math.log(Math.tan(Math.PI/4+this.b0/2)),s=Math.log(Math.tan(Math.PI/4+e/2)),l=Math.log((1+a*t)/(1-a*t));this.K=o-this.alpha*s+this.alpha*a/2*l},forward:function(e){var t=Math.log(Math.tan(Math.PI/4-e.y/2)),n=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),i=-this.alpha*(t+n)+this.K,r=2*(Math.atan(Math.exp(i))-Math.PI/4),a=this.alpha*(e.x-this.lambda0),o=Math.atan(Math.sin(a)/(Math.sin(this.b0)*Math.tan(r)+Math.cos(this.b0)*Math.cos(a))),s=Math.asin(Math.cos(this.b0)*Math.sin(r)-Math.sin(this.b0)*Math.cos(r)*Math.cos(a));return e.y=this.R/2*Math.log((1+Math.sin(s))/(1-Math.sin(s)))+this.y0,e.x=this.R*o+this.x0,e},inverse:function(e){for(var t=e.x-this.x0,n=e.y-this.y0,i=t/this.R,r=2*(Math.atan(Math.exp(n/this.R))-Math.PI/4),a=Math.asin(Math.cos(this.b0)*Math.sin(r)+Math.sin(this.b0)*Math.cos(r)*Math.cos(i)),o=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-Math.sin(this.b0)*Math.tan(r))),s=this.lambda0+o/this.alpha,l=0,A=a,c=-1e3,h=0;Math.abs(A-c)>1e-7;){if(++h>20)return;l=1/this.alpha*(Math.log(Math.tan(Math.PI/4+a/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(A))/2)),c=A,A=2*Math.atan(Math.exp(l))-Math.PI/2}return e.x=s,e.y=A,e},names:["somerc"]},Pw=1e-7;var Uw={init:function(){var e,t,n,i,r,a,o,s,l,A,c,h,u,d=0,f=0,p=0,m=0,v=0,g=0,y=0;this.no_off=(u="object"==typeof(h=this).PROJECTION?Object.keys(h.PROJECTION)[0]:h.PROJECTION,"no_uoff"in h||"no_off"in h||-1!==["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"].indexOf(u)),this.no_rot="no_rot"in this;var w=!1;"alpha"in this&&(w=!0);var x=!1;if("rectified_grid_angle"in this&&(x=!0),w&&(y=this.alpha),x&&(d=this.rectified_grid_angle*Hg),w||x)f=this.longc;else if(p=this.long1,v=this.lat1,m=this.long2,g=this.lat2,Math.abs(v-g)<=Pw||(e=Math.abs(v))<=Pw||Math.abs(e-Qg)<=Pw||Math.abs(Math.abs(this.lat0)-Qg)<=Pw||Math.abs(Math.abs(g)-Qg)<=Pw)throw new Error;var b=1-this.es;t=Math.sqrt(b),Math.abs(this.lat0)>Gg?(s=Math.sin(this.lat0),n=Math.cos(this.lat0),e=1-this.es*s*s,this.B=n*n,this.B=Math.sqrt(1+this.es*this.B*this.B/b),this.A=this.B*this.k0*t/e,(r=(i=this.B*t/(n*Math.sqrt(e)))*i-1)<=0?r=0:(r=Math.sqrt(r),this.lat0<0&&(r=-r)),this.E=r+=i,this.E*=Math.pow(vy(this.e,this.lat0,s),this.B)):(this.B=1/t,this.A=this.k0,this.E=i=r=1),w||x?(w?(c=Math.asin(Math.sin(y)/i),x||(d=y)):(c=d,y=Math.asin(i*Math.sin(c))),this.lam0=f-Math.asin(.5*(r-1/r)*Math.tan(c))/this.B):(a=Math.pow(vy(this.e,v,Math.sin(v)),this.B),o=Math.pow(vy(this.e,g,Math.sin(g)),this.B),r=this.E/a,l=(o-a)/(o+a),A=((A=this.E*this.E)-o*a)/(A+o*a),(e=p-m)<-Math.pi?m-=Wg:e>Math.pi&&(m+=Wg),this.lam0=my(.5*(p+m)-Math.atan(A*Math.tan(.5*this.B*(p-m))/l)/this.B),c=Math.atan(2*Math.sin(this.B*my(p-this.lam0))/(r-1/r)),d=y=Math.asin(i*Math.sin(c))),this.singam=Math.sin(c),this.cosgam=Math.cos(c),this.sinrot=Math.sin(d),this.cosrot=Math.cos(d),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.A,this.B,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(i*i-1)/Math.cos(y))),this.lat0<0&&(this.u_0=-this.u_0)),r=.5*c,this.v_pole_n=this.ArB*Math.log(Math.tan(jg-r)),this.v_pole_s=this.ArB*Math.log(Math.tan(jg+r))},forward:function(e){var t,n,i,r,a,o,s,l,A={};if(e.x=e.x-this.lam0,Math.abs(Math.abs(e.y)-Qg)>Gg){if(t=.5*((a=this.E/Math.pow(vy(this.e,e.y,Math.sin(e.y)),this.B))-(o=1/a)),n=.5*(a+o),r=Math.sin(this.B*e.x),i=(t*this.singam-r*this.cosgam)/n,Math.abs(Math.abs(i)-1)0?this.v_pole_n:this.v_pole_s,s=this.ArB*e.y;return this.no_rot?(A.x=s,A.y=l):(s-=this.u_0,A.x=l*this.cosrot+s*this.sinrot,A.y=s*this.cosrot-l*this.sinrot),A.x=this.a*A.x+this.x0,A.y=this.a*A.y+this.y0,A},inverse:function(e){var t,n,i,r,a,o,s,l={};if(e.x=(e.x-this.x0)*(1/this.a),e.y=(e.y-this.y0)*(1/this.a),this.no_rot?(n=e.y,t=e.x):(n=e.x*this.cosrot-e.y*this.sinrot,t=e.y*this.cosrot+e.x*this.sinrot+this.u_0),r=.5*((i=Math.exp(-this.BrA*n))-1/i),a=.5*(i+1/i),s=((o=Math.sin(this.BrA*t))*this.cosgam+r*this.singam)/a,Math.abs(Math.abs(s)-1)Gg?this.ns=Math.log(i/s)/Math.log(r/l):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=i/(this.ns*Math.pow(r,this.ns)),this.rh=this.a*this.f0*Math.pow(A,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(e){var t=e.x,n=e.y;Math.abs(2*Math.abs(n)-Math.PI)<=Gg&&(n=py(n)*(Qg-2e-10));var i,r,a=Math.abs(Math.abs(n)-Qg);if(a>Gg)i=vy(this.e,n,Math.sin(n)),r=this.a*this.f0*Math.pow(i,this.ns);else{if((a=n*this.ns)<=0)return null;r=0}var o=this.ns*my(t-this.long0);return e.x=this.k0*(r*Math.sin(o))+this.x0,e.y=this.k0*(this.rh-r*Math.cos(o))+this.y0,e},inverse:function(e){var t,n,i,r,a,o=(e.x-this.x0)/this.k0,s=this.rh-(e.y-this.y0)/this.k0;this.ns>0?(t=Math.sqrt(o*o+s*s),n=1):(t=-Math.sqrt(o*o+s*s),n=-1);var l=0;if(0!==t&&(l=Math.atan2(n*o,n*s)),0!==t||this.ns>0){if(n=1/this.ns,i=Math.pow(t/(this.a*this.f0),n),-9999===(r=gy(this.e,i)))return null}else r=-Qg;return a=my(l/this.ns+this.long0),e.x=a,e.y=r,e},names:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","lcc","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"]};var Rw={init:function(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq},forward:function(e){var t,n,i,r,a,o,s,l=e.x,A=e.y,c=my(l-this.long0);return t=Math.pow((1+this.e*Math.sin(A))/(1-this.e*Math.sin(A)),this.alfa*this.e/2),n=2*(Math.atan(this.k*Math.pow(Math.tan(A/2+this.s45),this.alfa)/t)-this.s45),i=-c*this.alfa,r=Math.asin(Math.cos(this.ad)*Math.sin(n)+Math.sin(this.ad)*Math.cos(n)*Math.cos(i)),a=Math.asin(Math.cos(n)*Math.sin(i)/Math.cos(r)),o=this.n*a,s=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(r/2+this.s45),this.n),e.y=s*Math.cos(o)/1,e.x=s*Math.sin(o)/1,this.czech||(e.y*=-1,e.x*=-1),e},inverse:function(e){var t,n,i,r,a,o,s,l=e.x;e.x=e.y,e.y=l,this.czech||(e.y*=-1,e.x*=-1),a=Math.sqrt(e.x*e.x+e.y*e.y),r=Math.atan2(e.y,e.x)/Math.sin(this.s0),i=2*(Math.atan(Math.pow(this.ro0/a,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),t=Math.asin(Math.cos(this.ad)*Math.sin(i)-Math.sin(this.ad)*Math.cos(i)*Math.cos(r)),n=Math.asin(Math.cos(i)*Math.sin(r)/Math.cos(t)),e.x=this.long0-n/this.alfa,o=t,s=0;var A=0;do{e.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(t/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(o))/(1-this.e*Math.sin(o)),this.e/2))-this.s45),Math.abs(o-e.y)<1e-10&&(s=1),o=e.y,A+=1}while(0===s&&A<15);return A>=15?null:e},names:["Krovak","krovak"]};function Ow(e,t,n,i,r){return e*r-t*Math.sin(2*r)+n*Math.sin(4*r)-i*Math.sin(6*r)}function Nw(e){return 1-.25*e*(1+e/16*(3+1.25*e))}function zw(e){return.375*e*(1+.25*e*(1+.46875*e))}function Qw(e){return.05859375*e*e*(1+.75*e)}function Gw(e){return e*e*e*(35/3072)}function Hw(e,t,n){var i=t*n;return e/Math.sqrt(1-i*i)}function Vw(e){return Math.abs(e)1e-7?(1-e*e)*(t/(1-(n=e*t)*n)-.5/e*Math.log((1-n)/(1+n))):2*t}var Yw=.3333333333333333,Kw=.17222222222222222,Zw=.10257936507936508,Jw=.06388888888888888,qw=.0664021164021164,$w=.016415012942191543;var ex={init:function(){var e,t=Math.abs(this.lat0);if(Math.abs(t-Qg)0)switch(this.qp=Xw(this.e,1),this.mmf=.5/(1-this.es),this.apa=function(e){var t,n=[];return n[0]=e*Yw,t=e*e,n[0]+=t*Kw,n[1]=t*Jw,t*=e,n[0]+=t*Zw,n[1]+=t*qw,n[2]=t*$w,n}(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),e=Math.sin(this.lat0),this.sinb1=Xw(this.e,e)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*e*e)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},forward:function(e){var t,n,i,r,a,o,s,l,A,c,h=e.x,u=e.y;if(h=my(h-this.long0),this.sphere){if(a=Math.sin(u),c=Math.cos(u),i=Math.cos(h),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((n=this.mode===this.EQUIT?1+c*i:1+this.sinph0*a+this.cosph0*c*i)<=Gg)return null;t=(n=Math.sqrt(2/n))*c*Math.sin(h),n*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*c*i}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(i=-i),Math.abs(u+this.lat0)=0?(t=(A=Math.sqrt(o))*r,n=i*(this.mode===this.S_POLE?A:-A)):t=n=0}}return e.x=this.a*t+this.x0,e.y=this.a*n+this.y0,e},inverse:function(e){e.x-=this.x0,e.y-=this.y0;var t,n,i,r,a,o,s,l,A,c,h=e.x/this.a,u=e.y/this.a;if(this.sphere){var d,f=0,p=0;if((n=.5*(d=Math.sqrt(h*h+u*u)))>1)return null;switch(n=2*Math.asin(n),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(p=Math.sin(n),f=Math.cos(n)),this.mode){case this.EQUIT:n=Math.abs(d)<=Gg?0:Math.asin(u*p/d),h*=p,u=f*d;break;case this.OBLIQ:n=Math.abs(d)<=Gg?this.lat0:Math.asin(f*this.sinph0+u*p*this.cosph0/d),h*=p*this.cosph0,u=(f-Math.sin(n)*this.sinph0)*d;break;case this.N_POLE:u=-u,n=Qg-n;break;case this.S_POLE:n-=Qg}t=0!==u||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(h,u):0}else{if(s=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(h/=this.dd,u*=this.dd,(o=Math.sqrt(h*h+u*u))1&&(e=e>1?1:-1),Math.asin(e)}var nx={init:function(){Math.abs(this.lat1+this.lat2)Gg?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)},forward:function(e){var t=e.x,n=e.y;this.sin_phi=Math.sin(n),this.cos_phi=Math.cos(n);var i=Xw(this.e3,this.sin_phi,this.cos_phi),r=this.a*Math.sqrt(this.c-this.ns0*i)/this.ns0,a=this.ns0*my(t-this.long0),o=r*Math.sin(a)+this.x0,s=this.rh-r*Math.cos(a)+this.y0;return e.x=o,e.y=s,e},inverse:function(e){var t,n,i,r,a,o;return e.x-=this.x0,e.y=this.rh-e.y+this.y0,this.ns0>=0?(t=Math.sqrt(e.x*e.x+e.y*e.y),i=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),i=-1),r=0,0!==t&&(r=Math.atan2(i*e.x,i*e.y)),i=t*this.ns0/this.a,this.sphere?o=Math.asin((this.c-i*i)/(2*this.ns0)):(n=(this.c-i*i)/this.ns0,o=this.phi1z(this.e3,n)),a=my(r/this.ns0+this.long0),e.x=a,e.y=o,e},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(e,t){var n,i,r,a,o=tx(.5*t);if(e0||Math.abs(a)<=Gg?(o=this.x0+1*this.a*n*Math.sin(i)/a,s=this.y0+1*this.a*(this.cos_p14*t-this.sin_p14*n*r)/a):(o=this.x0+this.infinity_dist*n*Math.sin(i),s=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*n*r)),e.x=o,e.y=s,e},inverse:function(e){var t,n,i,r,a,o;return e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,(t=Math.sqrt(e.x*e.x+e.y*e.y))?(r=Math.atan2(t,this.rc),n=Math.sin(r),o=tx((i=Math.cos(r))*this.sin_p14+e.y*n*this.cos_p14/t),a=Math.atan2(e.x*n,t*this.cos_p14*i-e.y*this.sin_p14*n),a=my(this.long0+a)):(o=this.phic0,a=0),e.x=a,e.y=o,e},names:["gnom"]};var rx={init:function(){this.sphere||(this.k0=fy(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},forward:function(e){var t,n,i=e.x,r=e.y,a=my(i-this.long0);if(this.sphere)t=this.x0+this.a*a*Math.cos(this.lat_ts),n=this.y0+this.a*Math.sin(r)/Math.cos(this.lat_ts);else{var o=Xw(this.e,Math.sin(r));t=this.x0+this.a*this.k0*a,n=this.y0+this.a*o*.5/this.k0}return e.x=t,e.y=n,e},inverse:function(e){var t,n;return e.x-=this.x0,e.y-=this.y0,this.sphere?(t=my(this.long0+e.x/this.a/Math.cos(this.lat_ts)),n=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(n=function(e,t){var n=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-n)<1e-6)return t<0?-1*Qg:Qg;for(var i,r,a,o,s=Math.asin(.5*t),l=0;l<30;l++)if(r=Math.sin(s),a=Math.cos(s),o=e*r,s+=i=Math.pow(1-o*o,2)/(2*a)*(t/(1-e*e)-r/(1-o*o)+.5/e*Math.log((1-o)/(1+o))),Math.abs(i)<=1e-10)return s;return NaN}(this.e,2*e.y*this.k0/this.a),t=my(this.long0+e.x/(this.a*this.k0))),e.x=t,e.y=n,e},names:["cea"]};var ax={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)},forward:function(e){var t=e.x,n=e.y,i=my(t-this.long0),r=Vw(n-this.lat0);return e.x=this.x0+this.a*i*this.rc,e.y=this.y0+this.a*r,e},inverse:function(e){var t=e.x,n=e.y;return e.x=my(this.long0+(t-this.x0)/(this.a*this.rc)),e.y=Vw(this.lat0+(n-this.y0)/this.a),e},names:["Equirectangular","Equidistant_Cylindrical","eqc"]};var ox={init:function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Nw(this.es),this.e1=zw(this.es),this.e2=Qw(this.es),this.e3=Gw(this.es),this.ml0=this.a*Ow(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(e){var t,n,i,r=e.x,a=e.y,o=my(r-this.long0);if(i=o*Math.sin(a),this.sphere)Math.abs(a)<=Gg?(t=this.a*o,n=-1*this.a*this.lat0):(t=this.a*Math.sin(i)/Math.tan(a),n=this.a*(Vw(a-this.lat0)+(1-Math.cos(i))/Math.tan(a)));else if(Math.abs(a)<=Gg)t=this.a*o,n=-1*this.ml0;else{var s=Hw(this.a,this.e,Math.sin(a))/Math.tan(a);t=s*Math.sin(i),n=this.a*Ow(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+s*(1-Math.cos(i))}return e.x=t+this.x0,e.y=n+this.y0,e},inverse:function(e){var t,n,i,r,a,o,s,l,A;if(i=e.x-this.x0,r=e.y-this.y0,this.sphere)if(Math.abs(r+this.a*this.lat0)<=Gg)t=my(i/this.a+this.long0),n=0;else{var c;for(o=this.lat0+r/this.a,s=i*i/this.a/this.a+o*o,l=o,a=20;a;--a)if(l+=A=-1*(o*(l*(c=Math.tan(l))+1)-l-.5*(l*l+s)*c)/((l-o)/c-1),Math.abs(A)<=Gg){n=l;break}t=my(this.long0+Math.asin(i*Math.tan(l)/this.a)/Math.sin(n))}else if(Math.abs(r+this.ml0)<=Gg)n=0,t=my(this.long0+i/this.a);else{var h,u,d,f,p;for(o=(this.ml0+r)/this.a,s=i*i/this.a/this.a+o*o,l=o,a=20;a;--a)if(p=this.e*Math.sin(l),h=Math.sqrt(1-p*p)*Math.tan(l),u=this.a*Ow(this.e0,this.e1,this.e2,this.e3,l),d=this.e0-2*this.e1*Math.cos(2*l)+4*this.e2*Math.cos(4*l)-6*this.e3*Math.cos(6*l),l-=A=(o*(h*(f=u/this.a)+1)-f-.5*h*(f*f+s))/(this.es*Math.sin(2*l)*(f*f+s-2*o*f)/(4*h)+(o-f)*(h*d-2/Math.sin(2*l))-d),Math.abs(A)<=Gg){n=l;break}h=Math.sqrt(1-this.es*Math.pow(Math.sin(n),2))*Math.tan(n),t=my(this.long0+Math.asin(i*h/this.a)/Math.sin(n))}return e.x=t,e.y=n,e},names:["Polyconic","poly"]};var sx={init:function(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013},forward:function(e){var t,n=e.x,i=e.y-this.lat0,r=n-this.long0,a=i/zg*1e-5,o=r,s=1,l=0;for(t=1;t<=10;t++)s*=a,l+=this.A[t]*s;var A,c=l,h=o,u=1,d=0,f=0,p=0;for(t=1;t<=6;t++)A=d*c+u*h,u=u*c-d*h,d=A,f=f+this.B_re[t]*u-this.B_im[t]*d,p=p+this.B_im[t]*u+this.B_re[t]*d;return e.x=p*this.a+this.x0,e.y=f*this.a+this.y0,e},inverse:function(e){var t,n,i=e.x,r=e.y,a=i-this.x0,o=(r-this.y0)/this.a,s=a/this.a,l=1,A=0,c=0,h=0;for(t=1;t<=6;t++)n=A*o+l*s,l=l*o-A*s,A=n,c=c+this.C_re[t]*l-this.C_im[t]*A,h=h+this.C_im[t]*l+this.C_re[t]*A;for(var u=0;u.999999999999&&(n=.999999999999),t=Math.asin(n);var i=my(this.long0+e.x/(.900316316158*this.a*Math.cos(t)));i<-Math.PI&&(i=-Math.PI),i>Math.PI&&(i=Math.PI),n=(2*t+Math.sin(2*t))/Math.PI,Math.abs(n)>1&&(n=1);var r=Math.asin(n);return e.x=i,e.y=r,e},names:["Mollweide","moll"]};var hx={init:function(){Math.abs(this.lat1+this.lat2)=0?(n=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(n=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var a=0;return 0!==n&&(a=Math.atan2(t*e.x,t*e.y)),this.sphere?(r=my(this.long0+a/this.ns),i=Vw(this.g-n/this.a),e.x=r,e.y=i,e):(i=jw(this.g-n/this.a,this.e0,this.e1,this.e2,this.e3),r=my(this.long0+a/this.ns),e.x=r,e.y=i,e)},names:["Equidistant_Conic","eqdc"]};var ux={init:function(){this.R=this.a},forward:function(e){var t,n,i=e.x,r=e.y,a=my(i-this.long0);Math.abs(r)<=Gg&&(t=this.x0+this.R*a,n=this.y0);var o=tx(2*Math.abs(r/Math.PI));(Math.abs(a)<=Gg||Math.abs(Math.abs(r)-Qg)<=Gg)&&(t=this.x0,n=r>=0?this.y0+Math.PI*this.R*Math.tan(.5*o):this.y0+Math.PI*this.R*-Math.tan(.5*o));var s=.5*Math.abs(Math.PI/a-a/Math.PI),l=s*s,A=Math.sin(o),c=Math.cos(o),h=c/(A+c-1),u=h*h,d=h*(2/A-1),f=d*d,p=Math.PI*this.R*(s*(h-f)+Math.sqrt(l*(h-f)*(h-f)-(f+l)*(u-f)))/(f+l);a<0&&(p=-p),t=this.x0+p;var m=l+h;return p=Math.PI*this.R*(d*m-s*Math.sqrt((f+l)*(l+1)-m*m))/(f+l),n=r>=0?this.y0+p:this.y0-p,e.x=t,e.y=n,e},inverse:function(e){var t,n,i,r,a,o,s,l,A,c,h,u;return e.x-=this.x0,e.y-=this.y0,h=Math.PI*this.R,a=(i=e.x/h)*i+(r=e.y/h)*r,h=3*(r*r/(l=-2*(o=-Math.abs(r)*(1+a))+1+2*r*r+a*a)+(2*(s=o-2*r*r+i*i)*s*s/l/l/l-9*o*s/l/l)/27)/(A=(o-s*s/3/l)/l)/(c=2*Math.sqrt(-A/3)),Math.abs(h)>1&&(h=h>=0?1:-1),u=Math.acos(h)/3,n=e.y>=0?(-c*Math.cos(u+Math.PI/3)-s/3/l)*Math.PI:-(-c*Math.cos(u+Math.PI/3)-s/3/l)*Math.PI,t=Math.abs(i)2*Qg*this.a)return;return n=t/this.a,i=Math.sin(n),r=Math.cos(n),a=this.long0,Math.abs(t)<=Gg?o=this.lat0:(o=tx(r*this.sin_p12+e.y*i*this.cos_p12/t),s=Math.abs(this.lat0)-Qg,a=Math.abs(s)<=Gg?this.lat0>=0?my(this.long0+Math.atan2(e.x,-e.y)):my(this.long0-Math.atan2(-e.x,e.y)):my(this.long0+Math.atan2(e.x*i,t*this.cos_p12*r-e.y*this.sin_p12*i))),e.x=a,e.y=o,e}return l=Nw(this.es),A=zw(this.es),c=Qw(this.es),h=Gw(this.es),Math.abs(this.sin_p12-1)<=Gg?(o=jw(((u=this.a*Ow(l,A,c,h,Qg))-(t=Math.sqrt(e.x*e.x+e.y*e.y)))/this.a,l,A,c,h),a=my(this.long0+Math.atan2(e.x,-1*e.y)),e.x=a,e.y=o,e):Math.abs(this.sin_p12+1)<=Gg?(u=this.a*Ow(l,A,c,h,Qg),o=jw(((t=Math.sqrt(e.x*e.x+e.y*e.y))-u)/this.a,l,A,c,h),a=my(this.long0+Math.atan2(e.x,e.y)),e.x=a,e.y=o,e):(t=Math.sqrt(e.x*e.x+e.y*e.y),p=Math.atan2(e.x,e.y),d=Hw(this.a,this.e,this.sin_p12),m=Math.cos(p),g=-(v=this.e*this.cos_p12*m)*v/(1-this.es),y=3*this.es*(1-g)*this.sin_p12*this.cos_p12*m/(1-this.es),b=1-g*(x=(w=t/d)-g*(1+g)*Math.pow(w,3)/6-y*(1+3*g)*Math.pow(w,4)/24)*x/2-w*x*x*x/6,f=Math.asin(this.sin_p12*Math.cos(x)+this.cos_p12*Math.sin(x)*m),a=my(this.long0+Math.asin(Math.sin(p)*Math.sin(x)/Math.cos(f))),M=Math.sin(f),o=Math.atan2((M-this.es*b*this.sin_p12)*Math.tan(f),M*(1-this.es)),e.x=a,e.y=o,e)},names:["Azimuthal_Equidistant","aeqd"]};var fx={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(e){var t,n,i,r,a,o,s,l=e.x,A=e.y;return i=my(l-this.long0),t=Math.sin(A),n=Math.cos(A),r=Math.cos(i),1,((a=this.sin_p14*t+this.cos_p14*n*r)>0||Math.abs(a)<=Gg)&&(o=1*this.a*n*Math.sin(i),s=this.y0+1*this.a*(this.cos_p14*t-this.sin_p14*n*r)),e.x=o,e.y=s,e},inverse:function(e){var t,n,i,r,a,o,s;return e.x-=this.x0,e.y-=this.y0,n=tx((t=Math.sqrt(e.x*e.x+e.y*e.y))/this.a),i=Math.sin(n),r=Math.cos(n),o=this.long0,Math.abs(t)<=Gg?(s=this.lat0,e.x=o,e.y=s,e):(s=tx(r*this.sin_p14+e.y*i*this.cos_p14/t),a=Math.abs(this.lat0)-Qg,Math.abs(a)<=Gg?(o=this.lat0>=0?my(this.long0+Math.atan2(e.x,-e.y)):my(this.long0-Math.atan2(-e.x,e.y)),e.x=o,e.y=s,e):(o=my(this.long0+Math.atan2(e.x*i,t*this.cos_p14*r-e.y*this.sin_p14*i)),e.x=o,e.y=s,e))},names:["ortho"]},px=1,mx=2,vx=3,gx=4,yx=5,wx=6,xx=1,bx=2,Mx=3,Cx=4;function Bx(e,t,n,i){var r;return ejg&&r<=Qg+jg?(i.value=bx,r-=Qg):r>Qg+jg||r<=-(Qg+jg)?(i.value=Mx,r=r>=0?r-Xg:r+Xg):(i.value=Cx,r+=Qg)),r}function Ex(e,t){var n=e+t;return n<-Xg?n+=Wg:n>+Xg&&(n-=Wg),n}var Sx={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=Qg-jg/2?this.face=yx:this.lat0<=-(Qg-jg/2)?this.face=wx:Math.abs(this.long0)<=jg?this.face=px:Math.abs(this.long0)<=Qg+jg?this.face=this.long0>0?mx:gx:this.face=vx,0!==this.es&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)},forward:function(e){var t,n,i,r,a,o,s={x:0,y:0},l={value:0};if(e.x-=this.long0,t=0!==this.es?Math.atan(this.one_minus_f_squared*Math.tan(e.y)):e.y,n=e.x,this.face===yx)r=Qg-t,n>=jg&&n<=Qg+jg?(l.value=xx,i=n-Qg):n>Qg+jg||n<=-(Qg+jg)?(l.value=bx,i=n>0?n-Xg:n+Xg):n>-(Qg+jg)&&n<=-jg?(l.value=Mx,i=n+Qg):(l.value=Cx,i=n);else if(this.face===wx)r=Qg+t,n>=jg&&n<=Qg+jg?(l.value=xx,i=-n+Qg):n=-jg?(l.value=bx,i=-n):n<-jg&&n>=-(Qg+jg)?(l.value=Mx,i=-n-Qg):(l.value=Cx,i=n>0?-n+Xg:-n-Xg);else{var A,c,h,u,d,f;this.face===mx?n=Ex(n,+Qg):this.face===vx?n=Ex(n,+Xg):this.face===gx&&(n=Ex(n,-Qg)),u=Math.sin(t),d=Math.cos(t),f=Math.sin(n),A=d*Math.cos(n),c=d*f,h=u,this.face===px?i=Bx(r=Math.acos(A),h,c,l):this.face===mx?i=Bx(r=Math.acos(c),h,-A,l):this.face===vx?i=Bx(r=Math.acos(-A),h,-c,l):this.face===gx?i=Bx(r=Math.acos(-c),h,A,l):(r=i=0,l.value=xx)}return o=Math.atan(12/Xg*(i+Math.acos(Math.sin(i)*Math.cos(jg))-Qg)),a=Math.sqrt((1-Math.cos(r))/(Math.cos(o)*Math.cos(o))/(1-Math.cos(Math.atan(1/Math.cos(i))))),l.value===bx?o+=Qg:l.value===Mx?o+=Xg:l.value===Cx&&(o+=1.5*Xg),s.x=a*Math.cos(o),s.y=a*Math.sin(o),s.x=s.x*this.a+this.x0,s.y=s.y*this.a+this.y0,e.x=s.x,e.y=s.y,e},inverse:function(e){var t,n,i,r,a,o,s,l,A,c,h,u,d={lam:0,phi:0},f={value:0};if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,n=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),t=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?f.value=xx:e.y>=0&&e.y>=Math.abs(e.x)?(f.value=bx,t-=Qg):e.x<0&&-e.x>=Math.abs(e.y)?(f.value=Mx,t=t<0?t+Xg:t-Xg):(f.value=Cx,t+=Qg),A=Xg/12*Math.tan(t),a=Math.sin(A)/(Math.cos(A)-1/Math.sqrt(2)),o=Math.atan(a),(s=1-(i=Math.cos(t))*i*(r=Math.tan(n))*r*(1-Math.cos(Math.atan(1/Math.cos(o)))))<-1?s=-1:s>1&&(s=1),this.face===yx)l=Math.acos(s),d.phi=Qg-l,f.value===xx?d.lam=o+Qg:f.value===bx?d.lam=o<0?o+Xg:o-Xg:f.value===Mx?d.lam=o-Qg:d.lam=o;else if(this.face===wx)l=Math.acos(s),d.phi=l-Qg,f.value===xx?d.lam=-o+Qg:f.value===bx?d.lam=-o:f.value===Mx?d.lam=-o-Qg:d.lam=o<0?-o-Xg:-o+Xg;else{var p,m,v;A=(p=s)*p,m=(A+=(v=A>=1?0:Math.sqrt(1-A)*Math.sin(o))*v)>=1?0:Math.sqrt(1-A),f.value===bx?(A=m,m=-v,v=A):f.value===Mx?(m=-m,v=-v):f.value===Cx&&(A=m,m=v,v=-A),this.face===mx?(A=p,p=-m,m=A):this.face===vx?(p=-p,m=-m):this.face===gx&&(A=p,p=m,m=-A),d.phi=Math.acos(-v)-Qg,d.lam=Math.atan2(m,p),this.face===mx?d.lam=Ex(d.lam,-Qg):this.face===vx?d.lam=Ex(d.lam,-Xg):this.face===gx&&(d.lam=Ex(d.lam,+Qg))}return 0!==this.es&&(c=d.phi<0?1:0,h=Math.tan(d.phi),u=this.b/Math.sqrt(h*h+this.one_minus_f_squared),d.phi=Math.atan(Math.sqrt(this.a*this.a-u*u)/(this.one_minus_f*u)),c&&(d.phi=-d.phi)),d.lam+=this.long0,e.x=d.lam,e.y=d.phi,e},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]},Tx=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],_x=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],Ix=.8487,Lx=1.3523,Fx=Vg/5,kx=18,Px=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))};var Ux={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(e){var t=my(e.x-this.long0),n=Math.abs(e.y),i=Math.floor(n*Fx);i<0?i=0:i>=kx&&(i=17);var r={x:Px(Tx[i],n=Vg*(n-.08726646259971647*i))*t,y:Px(_x[i],n)};return e.y<0&&(r.y=-r.y),r.x=r.x*this.a*Ix+this.x0,r.y=r.y*this.a*Lx+this.y0,r},inverse:function(e){var t={x:(e.x-this.x0)/(this.a*Ix),y:Math.abs(e.y-this.y0)/(this.a*Lx)};if(t.y>=1)t.x/=Tx[18][0],t.y=e.y<0?-Qg:Qg;else{var n=Math.floor(t.y*kx);for(n<0?n=0:n>=kx&&(n=17);;)if(_x[n][0]>t.y)--n;else{if(!(_x[n+1][0]<=t.y))break;++n}var i=_x[n],r=5*(t.y-i[0])/(_x[n+1][0]-i[0]);r=function(e,t,n,i){for(var r=t;i;--i){var a=e(r);if(r-=a,Math.abs(a)1e10)throw new Error;if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,0!==this.es){var e=1-this.es,t=1/e;this.radius_p=Math.sqrt(e),this.radius_p2=e,this.radius_p_inv2=t,this.shape="ellipse"}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape="sphere";this.title||(this.title="Geostationary Satellite View")},forward:function(e){var t,n,i,r,a=e.x,o=e.y;if(a-=this.long0,"ellipse"===this.shape){o=Math.atan(this.radius_p2*Math.tan(o));var s=this.radius_p/Mw(this.radius_p*Math.cos(o),Math.sin(o));if(n=s*Math.cos(a)*Math.cos(o),i=s*Math.sin(a)*Math.cos(o),r=s*Math.sin(o),(this.radius_g-n)*n-i*i-r*r*this.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;t=this.radius_g-n,this.flip_axis?(e.x=this.radius_g_1*Math.atan(i/Mw(r,t)),e.y=this.radius_g_1*Math.atan(r/t)):(e.x=this.radius_g_1*Math.atan(i/t),e.y=this.radius_g_1*Math.atan(r/Mw(i,t)))}else"sphere"===this.shape&&(t=Math.cos(o),n=Math.cos(a)*t,i=Math.sin(a)*t,r=Math.sin(o),t=this.radius_g-n,this.flip_axis?(e.x=this.radius_g_1*Math.atan(i/Mw(r,t)),e.y=this.radius_g_1*Math.atan(r/t)):(e.x=this.radius_g_1*Math.atan(i/t),e.y=this.radius_g_1*Math.atan(r/Mw(i,t))));return e.x=e.x*this.a,e.y=e.y*this.a,e},inverse:function(e){var t,n,i,r,a=-1,o=0,s=0;if(e.x=e.x/this.a,e.y=e.y/this.a,"ellipse"===this.shape){this.flip_axis?(s=Math.tan(e.y/this.radius_g_1),o=Math.tan(e.x/this.radius_g_1)*Mw(1,s)):(o=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Mw(1,o));var l=s/this.radius_p;if(t=o*o+l*l+a*a,(i=(n=2*this.radius_g*a)*n-4*t*this.C)<0)return e.x=Number.NaN,e.y=Number.NaN,e;r=(-n-Math.sqrt(i))/(2*t),a=this.radius_g+r*a,o*=r,s*=r,e.x=Math.atan2(o,a),e.y=Math.atan(s*Math.cos(e.x)/a),e.y=Math.atan(this.radius_p_inv2*Math.tan(e.y))}else if("sphere"===this.shape){if(this.flip_axis?(s=Math.tan(e.y/this.radius_g_1),o=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+s*s)):(o=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+o*o)),t=o*o+s*s+a*a,(i=(n=2*this.radius_g*a)*n-4*t*this.C)<0)return e.x=Number.NaN,e.y=Number.NaN,e;r=(-n-Math.sqrt(i))/(2*t),a=this.radius_g+r*a,o*=r,s*=r,e.x=Math.atan2(o,a),e.y=Math.atan(s*Math.cos(e.x)/a)}return e.x=e.x+this.long0,e},names:["Geostationary Satellite View","Geostationary_Satellite","geos"]};function Vx(e){return e.startsWith("TMS")}function jx(e){return e.startsWith("EPSG")}function Wx(e){return jx(e)?e:"EPSG:".concat(e.match(/\d+/)[0])}Zy.defaultDatum="WGS84",Zy.Proj=Uy,Zy.WGS84=new Zy.Proj("WGS84"),Zy.Point=fw,Zy.toPoint=Vy,Zy.defs=Ay,Zy.nadgrid=function(e,t){var n=new DataView(t),i=function(e){var t=e.getInt32(8,!1);if(11===t)return!1;11!==(t=e.getInt32(8,!0))&&console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian");return!0}(n),r=function(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:Ly(e,56,64).trim(),fromSemiMajorAxis:e.getFloat64(120,t),fromSemiMinorAxis:e.getFloat64(136,t),toSemiMajorAxis:e.getFloat64(152,t),toSemiMinorAxis:e.getFloat64(168,t)}}(n,i);r.nSubgrids>1&&console.log("Only single NTv2 subgrids are currently supported, subsequent sub grids are ignored");var a=function(e,t,n){for(var i=176,r=[],a=0;a0&&void 0!==arguments[0]?arguments[0]:qx;s(this,e),this.size=new at,this._radiiSquared=new at,this._invRadiiSquared=new at,this.setSize(t)}return A(e,[{key:"geodeticSurfaceNormal",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at;return e.toVector3(t).multiply(this._invRadiiSquared).normalize()}},{key:"geodeticSurfaceNormalCartographic",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at,n=Hh.degToRad(e.longitude),i=Hh.degToRad(e.latitude),r=Math.cos(i);return t.set(r*Math.cos(n),r*Math.sin(n),Math.sin(i))}},{key:"setSize",value:function(e){this.size.set(e.x,e.y,e.z),this._radiiSquared.multiplyVectors(e,e),this._invRadiiSquared.x=0==e.x?0:1/this._radiiSquared.x,this._invRadiiSquared.y=0==e.y?0:1/this._radiiSquared.y,this._invRadiiSquared.z=0==e.z?0:1/this._radiiSquared.z}},{key:"cartographicToCartesian",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at;$x.copy(e.geodesicNormal),t.multiplyVectors(this._radiiSquared,$x);var n=Math.sqrt($x.dot(t));return t.divideScalar(n),$x.multiplyScalar(e.altitude),t.add($x)}},{key:"cartesianToCartographic",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ob("EPSG:4326",0,0,0),n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z),i=this.size.x,r=this.size.z,a=Math.abs((i*i-r*r)/(i*i)),o=1-Math.sqrt(1-a),s=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.atan2(e.y,e.x),A=Math.atan(e.z/s*(1-o+a*i/n)),c=Math.sin(A),h=Math.cos(A),u=Math.atan((e.z*(1-o)+a*i*c*c*c)/((1-o)*(s-a*i*h*h*h))),d=s*Math.cos(u)+e.z*Math.sin(u)-i*Math.sqrt(1-a*Math.sin(u)*Math.sin(u));return t.setFromValues(Hh.radToDeg(l),Hh.radToDeg(u),d)}},{key:"cartographicToCartesianArray",value:function(e){for(var t=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;s(this,e),this.isCoordinates=!0,Jx.isValid(t),this.crs=t,this.x=0,this.y=0,this.z=0,this._normal=new at,n.length>0?this.setFromArray(n):n.isVector3||n.isCoordinates?this.setFromVector3(n):this.setFromValues(n,i,r),this._normalNeedsUpdate=!0}return A(e,[{key:"setFromValues",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.x=null==e?0:e,this.y=null==t?0:t,this.z=null==n?0:n,this._normalNeedsUpdate=!0,this}},{key:"setFromArray",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.setFromValues(e[t],e[t+1],e[t+2])}},{key:"setFromVector3",value:function(e){return this.setFromValues(e.x,e.y,e.z)}},{key:"clone",value:function(){return new e(this.crs,this)}},{key:"copy",value:function(e){return this.crs=e.crs,this.setFromVector3(e)}},{key:"longitude",get:function(){return this.x}},{key:"latitude",get:function(){return this.y}},{key:"altitude",get:function(){return this.z},set:function(e){this.z=e}},{key:"geodesicNormal",get:function(){return this._normalNeedsUpdate&&(this._normalNeedsUpdate=!1,Jx.is4326(this.crs)?tb.geodeticSurfaceNormalCartographic(this,this._normal):"EPSG:4978"==this.crs?tb.geodeticSurfaceNormal(this,this._normal):this._normal.set(0,0,1)),this._normal}},{key:"toVector3",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new at;return e.copy(this)}},{key:"applyMatrix4",value:function(e){return at.prototype.applyMatrix4.call(this,e)}},{key:"as",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new e(t);return this.crs==t?n.copy(this):(Jx.is4326(this.crs)&&"EPSG:3857"==t&&(this.y=Hh.clamp(this.y,-89.999999,89.999999)),n.setFromArray(ib(this.crs,t).forward([this.x,this.y,this.z]))),n.crs=t,n}}]),e}(),sb=new tt,lb=new tt,Ab=new tt,cb=new tt,hb=new tt,ub=new tt(2,2),db={row:0,col:0,invDiff:0};function fb(e,t){var n=e.zoom-t,i=Math.pow(2,n);return db.invDiff=1/i,db.row=(e.row-e.row%i)*db.invDiff,db.col=(e.col-e.col%i)*db.invDiff,db}for(var pb=new Array(8),mb=pb.length-1;mb>=0;mb--)pb[mb]=new ob("EPSG:4326",0,0,0,0);var vb=new ob("EPSG:4326",0,0),gb=new Map,yb=new Map;function wb(e){var t=Jx.formatToEPSG(e),n=gb.get(t),i=n.dimensions(lb),r=Jx.formatToTms(e);return{epsg:t,globalExtent:n,globalDimension:i,sTs:yb.get(r)||yb.get("default"),isInverted:!r.includes(":NI")}}function xb(e,t){var n=yb.get(Jx.formatToTms(e))||yb.get("default"),i=Math.pow(2,t);return Ab.set(i,i).multiply(n),Ab}var bb=function(){function e(t,n,i,r,a){s(this,e),this.isExtent=!0,this.crs=t,this.zoom=0,Jx.isTms(this.crs)?(this.row=0,this.col=0):(this.west=0,this.east=0,this.south=0,this.north=0),this.set(n,i,r,a)}return A(e,[{key:"clone",value:function(){return Jx.isTms(this.crs)?new e(this.crs,this.zoom,this.row,this.col):new e(this.crs,this.west,this.east,this.south,this.north)}},{key:"tiledCovering",value:function(t){if("EPSG:4326"==this.crs&&t==Jx.tms_3857){var n=[],i=rb.copy(this).as(Jx.formatToEPSG(t),ab),r=wb(Jx.formatToEPSG(t)),a=r.globalExtent,o=r.globalDimension,s=r.sTs;i.clampByExtent(a),i.dimensions(hb);var l=this.zoom+1||Math.floor(Math.log2(Math.round(o.x/(hb.x*s.x)))),A=xb(t,l),c=i.center(vb);cb.x=c.x-a.west,cb.y=a.north-i.north,cb.divide(o).multiply(A).floor();for(var h=Math.ceil((a.north-i.south)/o.x*A.y)-1;h>=cb.y;h--)n.push(new e(t,l,h,cb.x));return n}var u=new e(t,0,0,0),d=wb(this.crs),f=d.globalExtent,p=d.globalDimension,m=d.sTs,v=d.isInverted,g=this.center(vb);this.dimensions(hb);var y=Math.floor(Math.log2(Math.round(p.x/(hb.x*m.x)))),w=xb(t,y);return cb.x=g.x-f.west,cb.y=v?f.north-g.y:g.y-f.south,cb.divide(p).multiply(w).floor(),u.set(y,cb.y,cb.x),[u]}},{key:"as",value:function(t,n){if(Jx.isValid(t),n=n||new e("EPSG:4326",[0,0,0,0]),Jx.isTms(this.crs)){var i=wb(this.crs),r=i.epsg,a=i.globalExtent,o=i.globalDimension,s=xb(this.crs,this.zoom);return hb.set(1,1).divide(s).multiply(o),n.west=a.west+(o.x-hb.x*(s.x-this.col)),n.east=n.west+hb.x,n.south=a.south+hb.y*(s.y-this.row-1),n.north=n.south+hb.y,n.crs=r,n.zoom=this.zoom,t==r?n:n.as(t,n)}if(Jx.isEpsg(t)){if(this.crs!=t){var l=this.center(vb);pb[0].setFromValues(this.west,this.north),pb[1].setFromValues(l.x,this.north),pb[2].setFromValues(this.east,this.north),pb[3].setFromValues(this.east,l.y),pb[4].setFromValues(this.east,this.south),pb[5].setFromValues(l.x,this.south),pb[6].setFromValues(this.west,this.south),pb[7].setFromValues(this.west,l.y),n.set(1/0,-1/0,1/0,-1/0);for(var A=0;A0&&void 0!==arguments[0]?arguments[0]:new ob(this.crs);if(Jx.isTms(this.crs))throw new Error("Invalid operation for WMTS bbox");return this.dimensions(sb),e.crs=this.crs,e.setFromValues(this.west+.5*sb.x,this.south+.5*sb.y),e}},{key:"dimensions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new tt;return e.x=Math.abs(this.east-this.west),e.y=Math.abs(this.north-this.south),e}},{key:"isPointInside",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.crs==e.crs?vb.copy(e):e.as(this.crs,vb),vb.x<=this.east+t&&vb.x>=this.west-t&&vb.y<=this.north+t&&vb.y>=this.south-t}},{key:"isInside",value:function(e,t){return Jx.isTms(this.crs)?this.zoom==e.zoom?this.row==e.row&&this.col==e.col:!(this.zoom1&&void 0!==arguments[1]?arguments[1]:new ut;if(this.crs!=e.crs)throw new Error("unsupported mix");if(Jx.isTms(this.crs))return fb(this,e.zoom),t.set(this.col*db.invDiff-db.col,this.row*db.invDiff-db.row,db.invDiff,db.invDiff);e.dimensions(sb),this.dimensions(lb);var n=(this.west-e.west)/sb.x,i=(e.north-this.north)/sb.y,r=lb.x/sb.x,a=lb.y/sb.y;return t.set(n,i,r,a)}},{key:"tiledExtentParent",value:function(t){return t&&t=t.east||this.east<=t.west||this.south>=t.north||this.north<=t.south)}},{key:"intersect",value:function(t){return this.intersectsExtent(t)?(t.crs!=this.crs&&(t=t.as(this.crs,rb)),new e(this.crs,Math.max(this.west,t.west),Math.min(this.east,t.east),Math.max(this.south,t.south),Math.min(this.north,t.north))):new e(this.crs,0,0,0,0)}},{key:"set",value:function(e,t,n,i){if(null==e)throw new Error("No values to set in the extent");return e.isExtent&&(Jx.isTms(e.crs)?(t=e.row,n=e.col,e=e.zoom):(t=e.east,n=e.south,i=e.north,e=e.west)),Jx.isTms(this.crs)?(this.zoom=e,this.row=t,this.col=n):e.isCoordinates?(this.west=e.x,this.east=t.x,this.south=e.y,this.north=t.y):void 0!==e.west?(this.west=e.west,this.east=e.east,this.south=e.south,this.north=e.north):4==e.length?(this.west=e[0],this.east=e[1],this.south=e[2],this.north=e[3]):void 0!==i&&(this.west=e,this.east=t,this.south=n,this.north=i),this}},{key:"copy",value:function(e){return this.crs=e.crs,this.set(e)}},{key:"union",value:function(e){if(e.crs!=this.crs)throw new Error("unsupported union between 2 diff crs");if(this.west===1/0)this.copy(e);else{var t=e.west;tthis.east&&(this.east=n);var i=e.south;ithis.north&&(this.north=r)}}},{key:"expandByCoordinates",value:function(e){var t=e.crs==this.crs?e:e.as(this.crs,vb);this.expandByValuesCoordinates(t.x,t.y)}},{key:"expandByValuesCoordinates",value:function(e,t){ethis.east&&(this.east=e),tthis.north&&(this.north=t)}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Jx.isTms(this.crs)?"".concat(this.zoom).concat(e).concat(this.row).concat(e).concat(this.col):"".concat(this.east).concat(e).concat(this.north).concat(e).concat(this.west).concat(e).concat(this.south)}},{key:"subdivision",value:function(){return this.subdivisionByScheme()}},{key:"subdivisionByScheme",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ub,n=[],i=this.dimensions(sb).divide(t),r=t.x-1;r>=0;r--)for(var a=t.y-1;a>=0;a--){var o=this.west+r*i.x,s=this.south+a*i.y;n.push(new e(this.crs,o,o+i.x,s,s+i.y))}return n}},{key:"transformedCopy",value:function(e,t,n){if(!Jx.isTms(n.crs)){if(this.crs=n.crs,this.zoom=n.zoom,this.west=(n.west+e.x)*t.x,this.east=(n.east+e.x)*t.x,this.west>this.east){var i=this.west;this.west=this.east,this.east=i}if(this.south=(n.south+e.y)*t.y,this.north=(n.north+e.y)*t.y,this.south>this.north){var r=this.south;this.south=this.north,this.north=r}}}},{key:"clampSouthNorth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.south,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.north;return this.south=Math.max(this.south,e),this.north=Math.min(this.north,t),this}},{key:"clampWestEast",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.west,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.east;return this.west=Math.max(this.west,e),this.east=Math.min(this.east,t),this}},{key:"clampByExtent",value:function(e){return this.clampSouthNorth(e.south,e.north),this.clampWestEast(e.west,e.east)}}],[{key:"fromBox3",value:function(t,n){return new e(t,{west:n.min.x,east:n.max.x,south:n.min.y,north:n.max.y})}}]),e}();rb=new bb("EPSG:4326",[0,0,0,0]),ab=new bb("EPSG:4326",[0,0,0,0]),gb.set("EPSG:4326",new bb("EPSG:4326",-180,180,-90,90));var Mb=gb.get("EPSG:4326").as("EPSG:3857");Mb.clampSouthNorth(Mb.west,Mb.east),gb.set("EPSG:3857",Mb),yb.set("default",new tt(1,1)),yb.set(Jx.tms_3857,yb.get("default")),yb.set(Jx.tms_4326,new tt(2,1));var Cb={v:new at,coord1:new ob("EPSG:4978"),coord2:new ob("EPSG:4978"),offset:new tt};function Bb(e,t,n,i,r,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},s=arguments.length>7?arguments[7]:void 0,l=arguments.length>8?arguments[8]:void 0,A=s||new ob(i);o.worldFromLocal?A.setFromVector3(Cb.v.copy(r).applyMatrix4(o.worldFromLocal)):A.setFromVector3(r);var c=Sb.getTerrainObjectAt(e,A,t,n,l);if(c)return c.coord.z+=a,c.coord.as(i,Cb.coord2).toVector3(r),o.localFromWorld&&r.applyMatrix4(o.localFromWorld),{id:c.texture.id,version:c.texture.version,tile:c.tile}}var Eb,Sb={getElevationValueAt:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,r=Rb(e,n,t,i||e.level0Nodes);if(r)return r.coord.z},getTerrainObjectAt:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;return Rb(e,n,t,i||e.level0Nodes,r)},FAST_READ_Z:0,PRECISE_READ_Z:1,placeObjectOnGround:function(e,t,n){var i,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4?arguments[4]:void 0;if(console.warn("placeObjectOnGround has been deprecated because it needs review and test"),i=a?a.concat(e.level0Nodes):e.level0Nodes,r.modifyGeometry){var o={worldFromLocal:n.matrixWorld,localFromWorld:(new bt).copy(n.matrixWorld).invert()},s=n.geometry;if(s.vertices){r.cache&&(r.cache.length=s.vertices.length);for(var l=!0,A=new ob(t),c=0;c=0?t:void 0}}function _b(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r2&&void 0!==arguments[2]?arguments[2]:new tt;if(e.crs!=t.crs)throw new Error("Unsupported mix: ".concat(e.crs," and ").concat(t.crs));t.dimensions(Db);var i=(e.x-t.west)/Db.x,r=(t.north-e.y)/Db.y;n.set(i,r)}(a,o.extent,Ub.offset),a.z=1==t?function(e,t,n,i,r){var a=i.x/r.x/16,o=Math.floor(n.x/a)*a,s=Math.floor(n.y/a)*a;1==o&&(o-=a),1==s&&(s-=a);var l=o,A=o+a,c=s,h=s+a,u=(n.x-o)/a,d=(n.y-s)/a,f=1==d||u/(1-d)>=1,p=new Tn(new at(l,h),new at(A,c),f?new at(A,h):new at(l,c));p.getBarycoord(new at(n.x,n.y),Pb);var m=e.attachedLayers.filter((function(e){return e.isElevationLayer}))[0],v=Fb(m,t,p.a.x,p.a.y),g=Fb(m,t,p.b.x,p.b.y),y=Fb(m,t,p.c.x,p.c.y);return v*Pb.x+g*Pb.y+y*Pb.z}(e,c,Ub.offset,l.extent.dimensions(),o.extent.dimensions()):kb(e,c,Ub.offset),null!=a.z?{coord:a,texture:c,tile:l}:void 0}}var Ob=1,Nb={frustum:new Wi,matrix:new bt,box3:new tn},zb=new tn(new at(-1,-1,-1),new at(1,1,1));function Qb(e,t,n){if(e.camera3D.isOrthographicCamera)e._preSSE=t;else{var i=Hh.degToRad(n);e._preSSE=t/(2*Math.tan(.5*i))}}var Gb=function(){function e(t,n,i){var r=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(s(this,e),this.crs=t,a.isCamera)console.warn("options.camera parameter is deprecated. Use options.camera.cameraThree to place a custom camera as a parameter. See the documentation of Camera."),this.camera3D=a;else if(a.cameraThree)this.camera3D=a.cameraThree;else if(a.type===Ob)this.camera3D=new FA;else this.camera3D=new Ni(30);if(this.camera3D.aspect=void 0!==this.camera3D.aspect?this.camera3D.aspect:1,this._viewMatrix=new bt,this.width=n,this.height=i,this._viewMatrixNeedsUpdate=!0,this.resize(n,i),this._preSSE=1/0,this.camera3D.isPerspectiveCamera){var o=this.camera3D.fov;Object.defineProperty(this.camera3D,"fov",{get:function(){return o},set:function(e){o=e,Qb(r,r.height,o)}})}}return A(e,[{key:"resize",value:function(e,t){var n=e/t;if(this.camera3D.aspect!==n){if(this.camera3D.isOrthographicCamera){this.camera3D.zoom*=this.width/e;var i=this.camera3D.top*this.camera3D.aspect/n;this.camera3D.bottom=-i,this.camera3D.top=i}else this.camera3D.isPerspectiveCamera&&(this.camera3D.fov=2*et.radToDeg(Math.atan(t/this.height*Math.tan(et.degToRad(this.camera3D.fov)/2))));this.camera3D.aspect=n}this.width=e,this.height=t,Qb(this,this.height,this.camera3D.fov),this.camera3D.updateProjectionMatrix&&(this.camera3D.updateProjectionMatrix(),this._viewMatrixNeedsUpdate=!0)}},{key:"update",value:function(){this.camera3D.updateMatrixWorld(),this._viewMatrixNeedsUpdate=!0}},{key:"position",value:function(e){return new ob(this.crs,this.camera3D.position).as(e||this.crs)}},{key:"setPosition",value:function(e){this.camera3D.position.copy(e.as(this.crs))}},{key:"isBox3Visible",value:function(e,t){return this.box3SizeOnScreen(e,t).intersectsBox(zb)}},{key:"isSphereVisible",value:function(e,t){return this._viewMatrixNeedsUpdate&&(this._viewMatrix.multiplyMatrices(this.camera3D.projectionMatrix,this.camera3D.matrixWorldInverse),this._viewMatrixNeedsUpdate=!1),t?(Nb.matrix.multiplyMatrices(this._viewMatrix,t),Nb.frustum.setFromProjectionMatrix(Nb.matrix)):Nb.frustum.setFromProjectionMatrix(this._viewMatrix),Nb.frustum.intersectsSphere(e)}},{key:"box3SizeOnScreen",value:function(e,t){var n=function(e,t,n){var i=e.camera3D.matrixWorldInverse;n&&(i=Nb.matrix.multiplyMatrices(e.camera3D.matrixWorldInverse,n));Hb[0].set(t.min.x,t.min.y,t.min.z).applyMatrix4(i),Hb[1].set(t.min.x,t.min.y,t.max.z).applyMatrix4(i),Hb[2].set(t.min.x,t.max.y,t.min.z).applyMatrix4(i),Hb[3].set(t.min.x,t.max.y,t.max.z).applyMatrix4(i),Hb[4].set(t.max.x,t.min.y,t.min.z).applyMatrix4(i),Hb[5].set(t.max.x,t.min.y,t.max.z).applyMatrix4(i),Hb[6].set(t.max.x,t.max.y,t.min.z).applyMatrix4(i),Hb[7].set(t.max.x,t.max.y,t.max.z).applyMatrix4(i);for(var r=!1,a=0;a<8;a++)Hb[a].z<=-e.camera3D.near?r=!0:Hb[a].z=-e.camera3D.near;return r?Hb:void 0}(this,e,t);if(!n)return Nb.box3.makeEmpty();for(var i=0;i<8;i++)n[i].applyMatrix4(this.camera3D.projectionMatrix);return Nb.box3.setFromPoints(n)}},{key:"adjustAltitudeToAvoidCollisionWithLayer",value:function(e,t,n){var i=e.camera.position().as("EPSG:4326");if(void 0!==t){var r=Sb.getElevationValueAt(t,i);if(void 0!==r)i.altitude-(r+n)<0&&(i.altitude=r+n,e.camera.camera3D.position.copy(i.as(e.referenceCrs)),e.notifyChange(this.camera3D))}}}]),e}(),Hb=[new at,new at,new at,new at,new at,new at,new at,new at];var Vb="update_start",jb="before_camera_update",Wb="after_camera_update",Xb="before_layer_update",Yb="after_layer_update",Kb="before_render",Zb="after_render",Jb="update_end";function qb(e,t){this.renderingState=0,this.needsRedraw=!1,this.scheduler=e,this.gfxEngine=t,this._updateLoopRestarted=!0}function $b(e,t,n){if(n){var i,r=S(n);try{for(r.s();!(i=r.n()).done;){var a=i.value,o=t.update(e,t,a),s=t.getObjectToUpdateForAttachedLayers(a);if(s)if(s.element){if(__DEBUG__&&!s.element.isObject3D)throw new Error("\n Invalid object for attached layer to update.\n Must be a THREE.Object and have a THREE.Material");var l,A=S(t.attachedLayers);try{for(A.s();!(l=A.n()).done;){var c=l.value;c.ready&&(c.update(e,c,s.element,s.parent),c.cache.flush())}}catch(e){A.e(e)}finally{A.f()}}else if(s.elements)for(var h=0;h0){var l,A=S(o.attachedLayers);try{for(A.s();!(l=A.n()).done;){var c=l.value;c.ready&&c.preUpdate&&c.preUpdate(i,s)}}catch(e){A.e(e)}finally{A.f()}var h=o.preUpdate(i,s);$b(i,o,h),o.postUpdate(i,o,t)}o.cache.flush(),e.execFrameRequesters(Yb,n,this._updateLoopRestarted,o)}}}catch(e){a.e(e)}finally{a.f()}},qb.prototype._step=function(e,t){var n=t-this._lastTimestamp;e._executeFrameRequestersRemovals(),e.execFrameRequesters(Vb,n,this._updateLoopRestarted);var i=this.needsRedraw;this._lastTimestamp=t,this.needsRedraw=!1,this.renderingState=0;var r=new Set(e._changeSources);e._changeSources.clear();var a=this.gfxEngine.getWindowSize();e.execFrameRequesters(jb,n,this._updateLoopRestarted),e.camera.update(a.x,a.y),e.execFrameRequesters(Wb,n,this._updateLoopRestarted);var o=e.camera.camera3D.matrixAutoUpdate;e.camera.camera3D.matrixAutoUpdate=!1,this._update(e,r,n),0==this.scheduler.commandsWaitingExecutionCount()&&this.dispatchEvent({type:"command-queue-empty"}),i&&this._renderView(e,n),this._updateLoopRestarted=0===this.renderingState,__DEBUG__&&(document.title=document.title.substr(0,document.title.length-2)),e.camera.camera3D.matrixAutoUpdate=o,e.execFrameRequesters(Jb,n,this._updateLoopRestarted)},qb.prototype._renderView=function(e,t){e.execFrameRequesters(Kb,t,this._updateLoopRestarted),e.render?e.render():this.gfxEngine.renderView(e),e.execFrameRequesters(Zb,t,this._updateLoopRestarted)},qb.prototype.dispose=function(){this.animationFrame&&cancelAnimationFrame(this.animationFrame)};var tM=!1,nM=8;function iM(e,t,n){var i=e.getContext(),r=i.createShader(t);return i.shaderSource(r,n),i.compileShader(r),r}function rM(){return navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox")}var aM=function(){return tM},oM=function(){return!!document.documentMode},sM=function(){return nM},lM=function(e){var t=e.getContext();nM=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),t.getParameter(t.MAX_TEXTURE_SIZE);var n=t.createProgram(),i=iM(e,t.VERTEX_SHADER,"\nvoid main() {\n gl_Position = vec4( 0.0, 0.0, 0.0, 1.0 );\n}\n"),r="#define SAMPLE ".concat(nM,"\n");r+="\nuniform sampler2D uni[SAMPLE];\nvoid main() {\n gl_FragColor += texture2D(uni[SAMPLE-1], vec2(0));\n}\n";var a=iM(e,t.FRAGMENT_SHADER,r);if(t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),!1===t.getProgramParameter(n,t.LINK_STATUS)){if(!(nM>16))throw new Error("The GPU capabilities could not be determined accurately.\n Impossible to link a shader with the Maximum texture units ".concat(nM));var o=t.getProgramInfoLog(n);console.warn("".concat(o,": using a maximum of 16 texture units instead of the reported value (").concat(nM,")")),rM()&&console.warn("It can come from a Mesa/Firefox bug;\n the shader compiles to an error when using more than 16 sampler uniforms,\n see https://bugzilla.mozilla.org/show_bug.cgi?id=777028"),nM=16}t.deleteProgram(n),t.deleteShader(i),t.deleteShader(a),tM=e.capabilities.logarithmicDepthBuffer},AM="\n#include \n#include \n#include \n#include \n#include \n#include \nattribute vec2 uv_0;\n#if NUM_CRS > 1\nattribute float uv_1;\n#endif\nattribute vec3 normal;\n\nuniform mat4 modelMatrix;\nuniform bool lightingEnabled;\nvarying vec2 vHighPrecisionZW;\n\n#if MODE == MODE_FINAL\n#include \nvarying vec3 vUv;\nvarying vec3 vNormal;\n#endif\nvoid main() {\n vec2 uv = vec2(uv_0.x, 1.0 - uv_0.y);\n\n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n#if MODE == MODE_FINAL\n #include \n #if NUM_CRS > 1\n vUv = vec3(uv_0, (uv_1 > 0.) ? uv_1 : uv_0.y); // set uv_1 = uv_0 if uv_1 is undefined\n #else\n vUv = vec3(uv_0, 0.0);\n #endif\n vNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );\n#endif\n}\n",cM="\n#include \n#include \n#include \n#include \n#include \n#if MODE == MODE_FINAL\n#include \n#include \n#include \n#endif\n#include \n\nuniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vUv; // uv_0.x/uv_1.x, uv_0.y, uv_1.y\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n #include \n\n#if MODE == MODE_ID\n\n #include \n\n#elif MODE == MODE_DEPTH\n\n #include \n\n#else\n\n gl_FragColor = vec4(diffuse, opacity);\n\n uvs[0] = vec3(vUv.xy, 0.);\n\n#if NUM_CRS > 1\n uvs[1] = vec3(vUv.x, fract(vUv.z), floor(vUv.z));\n#endif\n\n vec4 color;\n #pragma unroll_loop\n for ( int i = 0; i < NUM_FS_TEXTURES; i ++ ) {\n color = getLayerColor( i , colorTextures[ i ], colorOffsetScales[ i ], colorLayers[ i ]);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n\n #if defined(DEBUG)\n if (showOutline) {\n #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++) {\n color = getOutlineColor( outlineColors[ i ], uvs[ i ].xy);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, color.rgb, color.a);\n }\n }\n #endif\n\n #include \n #include \n #include \n\n#endif\n}\n",hM=new RegExp("gl_Position.*(?![^]*gl_Position)"),uM=new RegExp("[^\\w]*main[^\\w]*(void)?[^\\w]*{"),dM=function(e){if(!e.vertexShader.includes("USE_LOGDEPTHBUF")&&!e.vertexShader.includes("logdepthbuf_pars_vertex")){e.vertexShader="#include \n#define EPSILON 1e-6\n".concat(e.vertexShader);var t=hM.exec(e.vertexShader),n=t[0].length+t.index;e.vertexShader="".concat(e.vertexShader.slice(0,n),"\n#include \n").concat(e.vertexShader.slice(n)),e.fragmentShader="#include \n").concat(e.fragmentShader.slice(n)),e.defines={USE_LOGDEPTHBUF:1,USE_LOGDEPTHBUF_EXT:1}}},fM=function(e,t){return e.replace(/#pragma unroll_loop\s+for\s*\(\s*int\s+i\s*=\s*([\w\d]+);\s*i\s+<\s+([\w\d]+);\s*i\s*\+\+\s*\)\s*\{\n([^}]*)\}/g,(function(e,n,i,r){var a="";n=n in t?t[n]:parseInt(n,10),i=i in t?t[i]:parseInt(i,10);for(var o=n;on&&console.warn("LayeredMaterial: Not enough texture units (".concat(n," < ").concat(l,"), excess textures have been discarded.")),s.value=l;for(var d=l;d0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(s(this,n),e=t.call(this,i),TM=TM||[1,BM()],e.defines.NUM_VS_TEXTURES=TM[0],e.defines.NUM_FS_TEXTURES=TM[1],e.defines.USE_FOG=1,e.defines.NUM_CRS=r,vM(v(e),"ELEVATION",_M),vM(v(e),"MODE",mM.MODES),gM(v(e),"mode","MODE",mM.MODES.FINAL),__DEBUG__){e.defines.DEBUG=1;var a=[new at(1,0,0)];r>1&&a.push(new at(1,.5,0)),yM(v(e),"showOutline",!0),yM(v(e),"outlineWidth",.008),yM(v(e),"outlineColors",a)}aM()&&(e.defines.USE_LOGDEPTHBUF=1,e.defines.USE_LOGDEPTHBUF_EXT=1),e.vertexShader=AM,IM[r]=IM[r]||fM(cM,e.defines),e.fragmentShader=IM[r],yM(v(e),"diffuse",new Fn(.04,.23,.35)),yM(v(e),"opacity",e.opacity),yM(v(e),"lightingEnabled",!1),yM(v(e),"lightPosition",new at(-.5,0,1)),yM(v(e),"fogDistance",1e9),yM(v(e),"fogColor",new Fn(.76,.85,1)),yM(v(e),"overlayAlpha",0),yM(v(e),"overlayColor",new Fn(1,.3,0)),yM(v(e),"objectId",0),yM(v(e),"minBorderDistance",-.01),e.layers=[],e.elevationLayerIds=[],e.colorLayerIds=[],e.uniforms.elevationLayers=new Rc(new Array(TM[0]).fill(EM)),e.uniforms.elevationTextures=new Rc(new Array(TM[0]).fill(xM)),e.uniforms.elevationOffsetScales=new Rc(new Array(TM[0]).fill(wM)),e.uniforms.elevationTextureCount=new Rc(0),e.uniforms.colorLayers=new Rc(new Array(TM[1]).fill(EM)),e.uniforms.colorTextures=new Rc(new Array(TM[1]).fill(xM)),e.uniforms.colorOffsetScales=new Rc(new Array(TM[1]).fill(wM)),e.uniforms.colorTextureCount=new Rc(0);var o=e.visible;return Object.defineProperty(v(e),"visible",{get:function(){return o},set:function(e){o!=e&&(o=e,this.dispatchEvent({type:e?"shown":"hidden"}))}}),e}return A(n,[{key:"onBeforeCompile",value:function(e,t){t.capabilities.isWebGL2&&(this.defines.WEBGL2=!0,e.glslVersion="300 es")}},{key:"getUniformByType",value:function(e){return{layers:this.uniforms["".concat(e,"Layers")],textures:this.uniforms["".concat(e,"Textures")],offsetScales:this.uniforms["".concat(e,"OffsetScales")],textureCount:this.uniforms["".concat(e,"TextureCount")]}}},{key:"updateLayersUniforms",value:function(){var e=this,t=this.layers.filter((function(t){return e.colorLayerIds.includes(t.id)&&t.visible&&t.opacity>0}));if(t.sort((function(t,n){return e.colorLayerIds.indexOf(t.id)-e.colorLayerIds.indexOf(n.id)})),SM(this.getUniformByType("color"),t,this.defines.NUM_FS_TEXTURES),this.elevationLayerIds.some((function(t){return e.getLayer(t)}))||this.uniforms.elevationTextureCount.value&&!this.elevationLayerIds.length){var n=this.getElevationLayer()?[this.getElevationLayer()]:[];SM(this.getUniformByType("elevation"),n,this.defines.NUM_VS_TEXTURES)}this.layersNeedUpdate=!1}},{key:"dispose",value:function(){this.dispatchEvent({type:"dispose"}),this.layers.forEach((function(e){return e.dispose(!0)})),this.layers.length=0,this.layersNeedUpdate=!0}},{key:"setSequence",value:function(e){this.colorLayerIds=e,this.layersNeedUpdate=!0}},{key:"setSequenceElevation",value:function(e){this.elevationLayerIds[0]=e,this.layersNeedUpdate=!0}},{key:"removeLayer",value:function(e){var t=this.layers.findIndex((function(t){return t.id===e}));if(t>-1){this.layers[t].dispose(),this.layers.splice(t,1);var n=this.colorLayerIds.indexOf(e);n>-1?this.colorLayerIds.splice(n,1):this.elevationLayerIds=[]}}},{key:"addLayer",value:function(e){e.layer.id in this.layers&&console.warn('The "{layer.id}" layer was already present in the material, overwritting.'),this.layers.push(e)}},{key:"getLayer",value:function(e){return this.layers.find((function(t){return t.id===e}))}},{key:"getLayers",value:function(e){return this.layers.filter((function(t){return e.includes(t.id)}))}},{key:"getElevationLayer",value:function(){var e=this;return this.layers.find((function(t){return t.id===e.elevationLayerIds[0]}))}},{key:"setElevationScale",value:function(e){this.elevationLayerIds.length&&(this.getElevationLayer().scale=e)}}]),n}(vl);function FM(e,t,n){var i=e.image,r=i.width,a=i.height,o=i.data;if(!o)return{min:null,max:null};var s=function(e,t,n){var i=t.x,r=t.y,a=t.z,o=[Fb({noDataValue:n},e,i,r),Fb({noDataValue:n},e,i+a,r),Fb({noDataValue:n},e,i+a,r+a),Fb({noDataValue:n},e,i,r+a)].filter((function(e){return null!=e&&e>-10}));if(o.length)return{min:Math.min.apply(Math,C(o)),max:Math.max.apply(Math,C(o))}}(e,t,n)||{max:-1/0,min:1/0},l=s.min,A=s.max,c=Math.floor(t.z*r);if(c>2)for(var h=Math.floor(t.z*a),u=Math.floor(t.x*r),d=Math.floor(t.y*a),f=Math.max(Math.floor(c/32),2),p=d+h,m=d;m-10&&y!=n&&(A=Math.max(A,y),l=Math.min(l,y))}return A===-1/0||l===1/0?{min:null,max:null}:{min:l,max:A}}function kM(e,t,n){var i=e%n/n,r=Math.floor(e/n)/n,a=t.x+i*t.z,o=t.y+r*t.w;return Math.floor(o*n)*n+Math.floor(a*n)}var PM=new ut,UM=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this)).layer=i,r.crs=i.parent.tileMatrixSets.indexOf(Jx.formatToTms(i.crs)),-1==r.crs&&console.error("Unknown crs:",i.crs),r.textures=[],r.offsetScales=[],r.level=-1,r.material=e,r._handlerCBEvent=function(){r.material.layersNeedUpdate=!0},i.addEventListener("visible-property-changed",r._handlerCBEvent),r}return A(n,[{key:"id",get:function(){return this.layer.id}},{key:"opacity",get:function(){return this.layer.opacity}},{key:"visible",get:function(){return this.layer.visible}},{key:"initFromParent",value:function(e,t){if(e&&e.level>this.level){var n,i=0,r=S(t);try{for(r.s();!(n=r.n()).done;){var a,o=n.value,s=S(e.textures);try{for(s.s();!(a=s.n()).done;){var l=a.value;if(o.isInside(l.extent)){this.setTexture(i++,l,o.offsetToParent(l.extent));break}}}catch(e){s.e(e)}finally{s.f()}}}catch(e){r.e(e)}finally{r.f()}__DEBUG__&&i!=t.length&&console.error("non-coherent result ".concat(i," vs ").concat(t.length,"."),t)}}},{key:"dispose",value:function(e){e&&(this.layer.removeEventListener("visible-property-changed",this._handlerCBEvent),this._listeners={});var t,n=S(this.textures);try{for(n.s();!(t=n.n()).done;){var i=t.value;i.isTexture&&i.dispose()}}catch(e){n.e(e)}finally{n.f()}this.level=-1,this.textures=[],this.offsetScales=[],this.material.layersNeedUpdate=!0}},{key:"setTexture",value:function(e,t,n){this.level=t&&0==e?t.extent.zoom:this.level,this.textures[e]=t||null,this.offsetScales[e]=n,this.material.layersNeedUpdate=!0}},{key:"setTextures",value:function(e,t){this.dispose(!1);for(var n=0,i=e.length;ni&&n[r-1]>i&&n[Math.sqrt(r)-1]>i&&n[r-Math.sqrt(r)]>i)||(e.extent.offsetToParent(a.extent,PM),function(e,t,n,i){for(var r=0,a=e.length;r2&&void 0!==arguments[2]?arguments[2]:{};return-1==t?n.zoom?n.zoom.min:0:Math.min(e,Math.ceil((t+e)/2))}function GM(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.level,r=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,s=a.source.zoom?a.source.zoom.max:1/0;if(o.lowestLevelError!=1/0)n=QM(o.lowestLevelError,r,a.source),n=o.lowestLevelError==n?n-1:n,1==e&&(n=NM(n,a.updateStrategy.options));else{switch(e){case 1:n=NM(i,a.updateStrategy.options);break;case 2:n=zM(i,r,a.updateStrategy.options);break;case 3:n=QM(i,r,a.source);break;default:n=OM(t,i,r)}n=Math.min(n,s)}return n}var HM,VM=function(){function e(t){s(this,e),this.layer=t}return A(e,[{key:"clear",value:function(){}},{key:"update",value:function(){}}]),e}(),jM=function(e){h(n,e);var t=y(n);function n(e){var i;return s(this,n),(i=t.call(this,e)).displayed={tiles:new Set},Object.defineProperty(i.displayed,"layers",{get:function(){var e=[];return i.displayed.tiles.forEach((function(t){var n=t.material;e=C(new Set([].concat(C(e),C(n.colorLayerIds.filter((function(e){return n.getLayer(e)}))),C(n.elevationLayerIds))))})),i.layer.attachedLayers.filter((function(t){return e.includes(t.id)}))}}),Object.defineProperty(i.displayed,"extent",{get:function(){var e=new bb(i.layer.extent.crs,1/0,-1/0,1/0,-1/0);return e.min=1/0,e.max=-1/0,i.displayed.tiles.forEach((function(t){e.union(t.extent),e.min=Math.min(t.obb.z.min,e.min),e.max=Math.max(t.obb.z.max,e.max)})),e}}),i}return A(n,[{key:"clear",value:function(){this.displayed.tiles.clear()}},{key:"update",value:function(e){e.material.visible?this.displayed.tiles.add(e):this.displayed.tiles.delete(e)}}]),n}(VM),WM={INFINITE:1/0,TEXTURE:9e5,GEOMETRY:9e5},XM=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:WM.INFINITE;s(this,e),this.lifeTime=t,this.lastTimeFlush=Date.now(),this.data=new Map}return A(e,[{key:"getByArray",value:function(e){return this.get(e[0],e[1],e[2])}},{key:"setByArray",value:function(e,t){return this.set(e,t[0],t[1],t[2])}},{key:"get",value:function(e,t,n){var i=this.data.get(e);if(null!=i){if(null!=i.lastTimeUsed)HM=i;else{var r=i.get(t);if(null==r)return;if(null!=r.lastTimeUsed)HM=r;else{var a=r.get(n);if(null==a)return;HM=a}}return HM.value?(HM.lastTimeUsed=Date.now(),HM.value):void 0}}},{key:"set",value:function(e,t,n,i){if(HM={value:e,lastTimeUsed:Date.now()},null==n)return this.data.set(t,HM),e;this.data.get(t)||this.data.set(t,new Map);var r=this.data.get(t);return null==i?(r.set(n,HM),e):(r.get(n)||r.set(n,new Map),r.get(n).set(i,HM),e)}},{key:"delete",value:function(e,t,n){var i=this.data.get(e);if(void 0!==i)if(null!=i.lastTimeUsed)this.data.get(e),this.data.delete(e);else{var r=i.get(t);if(void 0===r)return;if(null!=r.lastTimeUsed)i.get(t),i.delete(t),0==i.size&&this.data.delete(e);else{if(void 0===r.get(n))return;r.get(n),r.delete(n),0==r.size&&(i.delete(t),0==i.size&&this.data.delete(e))}}}},{key:"clear",value:function(){this.data.clear()}},{key:"flush",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();this.lifeTime==WM.INFINITE||this.lifeTime>t-this.lastTimeFlush||!this.data.size||(this.lastTimeFlush=1/0,this.data.forEach((function(n,i){e.lifeTime1&&void 0!==arguments[1]?arguments[1]:{};return fetch(e,t).then((function(e){return ZM(e),e.arrayBuffer()}))};function qM(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t){var n=new Hi(e,KM,KM,me,ne);return n.internalFormat="R32F",n}return new Hi(e,KM,KM,le,ne)}var $M={text:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(fetch)return fetch(e,t).then((function(e){return ZM(e),e.text()}));console.log("fetch is not defind")},json:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(fetch)return fetch(e,t).then((function(e){return ZM(e),e.json()}));console.log("fetch is not defind")},xml:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(fetch)return fetch(e,t).then((function(e){return ZM(e),e.text()})).then((function(e){return(new window.DOMParser).parseFromString(e,"text/xml")}));console.log("fetch is not defind")},texture:function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};YM.crossOrigin=i.crossOrigin;var r=new Promise((function(e,i){t=e,n=i}));return YM.load(e,t,(function(){}),n),r},arrayBuffer:JM,textureFloat:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return JM(e,t).then((function(e){return qM(new Float32Array(e),t.isWebGL2)}))},multiple:function(e,t){var n,i=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=[];for(var o in t){if(!this[o])throw new Error("".concat(o," is not a valid Fetcher method."));var s,l=S(t[o]);try{var A=function(){var t=s.value;n="".concat(e,".").concat(t),a.push(i[o](n,r).then((function(e){return{type:t,result:e}})))};for(l.s();!(s=l.n()).done;)A()}catch(e){l.e(e)}finally{l.f()}}return Promise.all(a).then((function(e){var t,n={},i=S(e);try{for(i.s();!(t=i.n()).done;){var r=t.value;n[r.type]=r.result}}catch(e){i.e(e)}finally{i.f()}return Promise.resolve(n)}))}},eC=new XM,tC={};function nC(e,t,n,i){n[e]=n[e]||{};var r,a=S(tC[e]);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=rC(t[e][o],i);void 0!==s&&(n[e][o]=s)}}catch(e){a.e(e)}finally{a.f()}}function iC(e){if(!e)return{};if(e.stops||e.expression)return{color:e};if("string"==typeof e){var t=e.match(/(?:((hsl|rgb)a? *\(([\d.%]+(?:deg|g?rad|turn)?)[ ,]*([\d.%]+)[ ,]*([\d.%]+)[ ,/]*([\d.%]*)\))|(#((?:[\d\w]{3}){1,2})([\d\w]{1,2})?))/i);if(!t)return{color:e,opacity:1};if(t[7]){var n=1;return t[9]&&(n=.00392156862745098*parseInt(1==t[9].length?"".concat(t[9]).concat(t[9]):t[9],16)),{color:"#".concat(t[8]),opacity:n}}if(t[0])return{color:"".concat(t[2],"(").concat(t[3],",").concat(t[4],",").concat(t[5],")"),opacity:Number(t[6])||1}}}function rC(e,t){if(null!=e){if(e.expression)return e.expression.evaluate(t);if(e.stops){for(var n=e.stops.length-1;n>=0;n--){var i=e.stops[n];if(t.globals.zoom>=i[0])return i[1]}return e.stops[0][1]}return e}}function aC(e,t){var n=document.createElement("img"),i=document.createElement("canvas");if("string"==typeof e)n.src=e;else if(e&&e[t]){var r=e[t];i.width=r.width,i.height=r.height,i.getContext("2d").drawImage(e.img,r.x,r.y,r.width,r.height,0,0,r.width,r.height),n.src=i.toDataURL("image/png")}return n}var oC={left:[0,-.5],right:[-1,-.5],top:[-.5,0],bottom:[-.5,-1],"top-right":[-1,0],"bottom-left":[0,-1],"bottom-right":[-1,-1],center:[-.5,-.5],"top-left":[0,0]};function sC(e,t,n,i,r){var a;Object.defineProperty(e[t],n,{enumerable:!0,get:function(){return void 0===a?e.parent[t][n]||r:a},set:function(e){a=e}}),e[t][n]=i}var lC=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;s(this,e),this.isStyle=!0,this.order=0,this.parent=i||{zoom:{},fill:{},stroke:{},point:{},text:{}},n.zoom=n.zoom||{},n.fill=n.fill||{},n.stroke=n.stroke||{},n.point=n.point||{},n.text=n.text||{},this.zoom={},sC(this,"zoom","min",n.zoom.min),sC(this,"zoom","max",n.zoom.max),this.fill={},sC(this,"fill","color",n.fill.color),sC(this,"fill","opacity",n.fill.opacity,1),sC(this,"fill","pattern",n.fill.pattern),"string"==typeof this.fill.pattern&&$M.texture(this.fill.pattern).then((function(e){t.fill.pattern=e.image})),this.stroke={},sC(this,"stroke","color",n.stroke.color),sC(this,"stroke","opacity",n.stroke.opacity,1),sC(this,"stroke","width",n.stroke.width,1),sC(this,"stroke","dasharray",n.stroke.dasharray,[]),this.point={},sC(this,"point","color",n.point.color),sC(this,"point","line",n.point.line),sC(this,"point","opacity",n.point.opacity,1),sC(this,"point","radius",n.point.radius,2),sC(this,"point","width",n.point.width,0),this.text={},sC(this,"text","field",n.text.field),sC(this,"text","zOrder",n.text.zOrder,"auto"),sC(this,"text","color",n.text.color,"#000000"),sC(this,"text","anchor",n.text.anchor,"center"),sC(this,"text","offset",n.text.offset,[0,0]),sC(this,"text","padding",n.text.padding,2),sC(this,"text","size",n.text.size,16),sC(this,"text","placement",n.text.placement,"point"),sC(this,"text","rotation",n.text.rotation,"auto"),sC(this,"text","wrap",n.text.wrap,10),sC(this,"text","spacing",n.text.spacing,0),sC(this,"text","transform",n.text.transform,"none"),sC(this,"text","justify",n.text.justify,"center"),sC(this,"text","opacity",n.text.opacity,1),sC(this,"text","font",n.text.font,["Open Sans Regular","Arial Unicode MS Regular","sans-serif"]),sC(this,"text","haloColor",n.text.haloColor,"#000000"),sC(this,"text","haloWidth",n.text.haloWidth,0),sC(this,"text","haloBlur",n.text.haloBlur,0)}return A(e,[{key:"drawingStylefromContext",value:function(e){var t={};if((this.fill.color||this.fill.pattern)&&nC("fill",this,t,e),this.stroke.color&&nC("stroke",this,t,e),this.point.color&&nC("point",this,t,e),Object.keys(t).length)return t}},{key:"symbolStylefromContext",value:function(t){var n=new e;return nC("text",this,n,t),this.icon&&nC("icon",this,n,t),n}},{key:"copy",value:function(e){return Object.assign(this.fill,e.fill),Object.assign(this.stroke,e.stroke),Object.assign(this.point,e.point),Object.assign(this.text,e.text),this}},{key:"clone",value:function(){var t=new e;return t.copy(this)}},{key:"setFromGeojsonProperties",value:function(e,t){return t===pC.POINT?(this.point.color=e.fill,this.point.opacity=e["fill-opacity"],this.point.line=e.stroke,this.point.radius=e.radius,this.text.color=e["label-color"],this.text.opacity=e["label-opacity"],this.text.size=e["label-size"],e.icon&&(this.icon={image:e.icon,size:1})):(this.stroke.color=e.stroke,this.stroke.width=e["stroke-width"],this.stroke.opacity=e["stroke-opacity"],t!==pC.LINE&&(this.fill.color=e.fill,this.fill.opacity=e["fill-opacity"])),this}},{key:"setFromVectorTileLayer",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.layout=e.layout||{},e.paint=e.paint||{},this.order=n,"fill"!==e.type||this.fill.color)if("line"!==e.type||this.stroke.color){if("circle"===e.type||i){var r=iC(void e.paint["circle-color"]),a=r.color,o=r.opacity;this.point.color=a,this.point.opacity=o,this.point.radius=void e.paint["circle-radius"]}else if("symbol"===e.type){this.text.zOrder=void e.layout["symbol-z-order"],"auto"==this.text.zOrder?this.text.zOrder=void e.layout["symbol-sort-key"]||"Y":"viewport-y"==this.text.zOrder?this.text.zOrder="Y":"source"==this.text.zOrder&&(this.text.zOrder=0),this.text.anchor=void e.layout["text-anchor"],this.text.offset=void e.layout["text-offset"],this.text.padding=void e.layout["text-padding"],this.text.size=void e.layout["text-size"],this.text.placement=void e.layout["symbol-placement"],this.text.rotation=void e.layout["text-rotation-alignment"],this.text.field=void e.layout["text-field"],this.text.wrap=void e.layout["text-max-width"],this.text.spacing=void e.layout["text-letter-spacing"],this.text.transform=void e.layout["text-transform"],this.text.justify=void e.layout["text-justify"];var s=iC(void e.paint["text-color"]),l=s.color,A=s.opacity;this.text.color=l,this.text.opacity=void e.paint["text-opacity"]||void 0!==A&&A,this.text.font=void e.layout["text-font"];var c=void e.paint["text-halo-color"];c&&(this.text.haloColor=c.color||c,this.text.haloWidth=void e.paint["text-halo-width"],this.text.haloBlur=void e.paint["text-halo-blur"]);var h=void e.layout["icon-image"];h&&(this.icon={key:h},this.icon.size=void e.layout["icon-size"]||1)}}else{var u=void e.paint["line-color"],d=iC(u),f=d.color,p=d.opacity;this.stroke.dasharray=void e.paint["line-dasharray"],this.stroke.color=f,this.stroke.lineCap=e.layout["line-cap"],this.stroke.width=void e.paint["line-width"],this.stroke.opacity=void e.paint["line-opacity"]||p}else{var m=iC(void(e.paint["fill-color"]||e.paint["fill-pattern"])),v=m.color,g=m.opacity;if(this.fill.color=v,this.fill.opacity=void e.paint["fill-opacity"]||g,e.paint["fill-pattern"]&&t&&(this.fill.pattern=aC(t,e.paint["fill-pattern"])),e.paint["fill-outline-color"]){var y=iC(void e.paint["fill-outline-color"]),w=y.color,x=y.opacity;this.stroke.color=w,this.stroke.opacity=x,this.stroke.width=1,this.stroke.dasharray=[]}}return this}},{key:"applyToHTML",value:function(e,t){var n=this;if(e.style.padding="".concat(this.text.padding,"px"),e.style.maxWidth="".concat(this.text.wrap,"em"),e.style.color=this.text.color,this.text.size>0&&(e.style.fontSize="".concat(this.text.size,"px")),e.style.fontFamily=this.text.font.join(","),e.style.textTransform=this.text.transform,e.style.letterSpacing="".concat(this.text.spacing,"em"),e.style.textAlign=this.text.justify,e.style["white-space"]="pre-line",this.text.haloWidth>0&&(e.style.setProperty("--text_stroke_display","block"),e.style.setProperty("--text_stroke_width","".concat(this.text.haloWidth,"px")),e.style.setProperty("--text_stroke_color",this.text.haloColor),e.setAttribute("data-before",e.textContent)),this.icon){var i=this.icon.image,r=this.icon.size,a=this.icon.key,o=eC.get(i||a,r);o||((o=a&&t?aC(t,a):aC(i)).style.position="absolute",eC.set(o,i||a,r));var s=function t(){var i=o.cloneNode();switch(i.width*=r,i.height*=r,n.text.anchor){case"left":i.style.right="calc(100% - ".concat(.5*i.width,"px)"),i.style.top="calc(50% - ".concat(.5*i.height,"px)");break;case"right":i.style.top="calc(50% - ".concat(.5*i.height,"px)");break;case"top":i.style.right="calc(50% - ".concat(.5*i.width,"px)");break;case"bottom":i.style.top="calc(100% - ".concat(.5*i.height,"px)"),i.style.right="calc(50% - ".concat(.5*i.width,"px)");break;case"bottom-left":i.style.top="calc(100% - ".concat(.5*i.height,"px)"),i.style.right="calc(100% - ".concat(.5*i.width,"px)");break;case"bottom-right":i.style.top="calc(100% - ".concat(.5*i.height,"px)");break;case"top-left":i.style.right="calc(100% - ".concat(.5*i.width,"px)");break;case"top-right":break;default:i.style.top="calc(50% - ".concat(.5*i.height,"px)"),i.style.right="calc(50% - ".concat(.5*i.width,"px)")}i.style["z-index"]=-1,e.appendChild(i),o.removeEventListener("load",t)};o.complete?s():o.addEventListener("load",s)}}},{key:"getTextAnchorPosition",value:function(){return oC[this.text.anchor]}},{key:"getTextFromProperties",value:function(e){return this.text.field.expression?rC(this.text.field,e):this.text.field.replace(/\{(.+?)\}/g,(function(t,n){return e.properties()[n]||""})).trim()}}]),e}(),AC={itowns_stroke_single_before:".itowns-stroke-single:before {\n display: var(--text_stroke_display);\n content: attr(data-before);\n opacity: 1;\n position: absolute;\n -webkit-text-stroke-width: var(--text_stroke_width);\n -webkit-text-stroke-color: var(--text_stroke_color);\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n z-index: -1;\n white-space: inherit;\n overflow-wrap: inherit;\n letter-spacing: inherit;\n text-align: inherit;\n padding: inherit;\n font-family: inherit;\n text-transform: inherit;\n max-width: inherit;\n font-size: inherit;\n}\n"},cC=document.createElement("style");cC.type="text/css",Object.keys(AC).forEach((function(e){cC.innerHTML+="".concat(AC[e],"\n\n")})),document.getElementsByTagName("head")[0].appendChild(cC);var hC=new lC;function uC(e){return new bb(e,1/0,-1/0,1/0,-1/0)}tC.fill=Object.keys(hC.fill),tC.stroke=Object.keys(hC.stroke),tC.point=Object.keys(hC.point),tC.text=Object.keys(hC.text),tC.icon=["image","size","key"];var dC=new ob("EPSG:4326",0,0,0),fC=new at(0,0,1),pC={POINT:0,LINE:1,POLYGON:2},mC=function(){function e(t){s(this,e),this.indices=[],this.properties={},this.size=t.size,t.extent&&(this.extent=uC(t.extent.crs),this._currentExtent=uC(t.extent.crs))}return A(e,[{key:"startSubGeometry",value:function(e,t){var n=this.indices.length-1,i=this.extent?uC(this.extent.crs):void 0,r=n>-1?this.indices[n].offset+this.indices[n].count:t.vertices.length/this.size;this.indices.push({offset:r,count:e,extent:i}),this._currentExtent=i,function(e,t){e.vertices.length+=t*e.size,e.normals&&(e.normals.length=e.vertices.length)}(t,e)}},{key:"closeSubGeometry",value:function(e,t){var n=this.indices.length-1,i=n>-1?this.indices[n].offset+this.indices[n].count:t.vertices.length/this.size-e;this.indices.push({offset:i,count:e,extent:this._currentExtent}),this.extent&&(this.extent.union(this._currentExtent),this._currentExtent=uC(this.extent.crs))}},{key:"getLastSubGeometry",value:function(){var e=this.indices.length-1;return this.indices[e]}},{key:"pushCoordinates",value:function(e,t){e.as(t.crs,dC),t.normals&&dC.geodesicNormal.toArray(t.normals,t._pos),t._pushValues(dC.x,dC.y,dC.z),this._currentExtent&&this._currentExtent.expandByCoordinates(t.useCrsOut?dC:e)}},{key:"pushCoordinatesValues",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:fC;e.normals&&r.toArray(e.normals,e._pos),e._pushValues(t,n,i),this._currentExtent&&this._currentExtent.expandByValuesCoordinates(t,n,i)}},{key:"updateExtent",value:function(){if(this.extent){var e=this.indices[this.indices.length-1];e&&this.extent.union(e.extent)}}}]),e}();function vC(e,t){this.vertices[this._pos++]=e,this.vertices[this._pos++]=t}function gC(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.vertices[this._pos++]=e,this.vertices[this._pos++]=t,this.vertices[this._pos++]=n}var yC=function(){function e(t,n){if(s(this,e),!Object.keys(pC).find((function(e){return pC[e]===t})))throw new Error("Unsupported Feature type: ".concat(t));this.type=t,this.geometries=[],this.vertices=[],this.crs=n.crs,this.size=n.size,this.normals=3==n.size?[]:void 0,n.extent&&(this.extent=uC(n.extent.crs),this.useCrsOut=!n.forceExtentCrs),this._pos=0,this._pushValues=(3===this.size?gC:vC).bind(this),this.style=new lC({},n.style)}return A(e,[{key:"bindNewGeometry",value:function(){var e=new mC(this);return this.geometries.push(e),e}},{key:"updateExtent",value:function(e){this.extent&&this.extent.union(e.extent)}},{key:"geometryCount",get:function(){return this.geometries.length}}]),e}(),wC=function(){function e(t){s(this,e),this.isFeatureCollection=!0,this.crs=Jx.formatToEPSG(t.crs),this.features=[],this.mergeFeatures=void 0===t.mergeFeatures||t.mergeFeatures,this.extent=t.buildExtent?uC(t.forcedExtentCrs||this.crs):void 0,this.translation=new at,this.scale=new at(1,1,1),this.size="3d"==t.structure?3:2,this.filterExtent=t.filterExtent,this.overrideAltitudeInToZero=t.overrideAltitudeInToZero,this.style=t.style}return A(e,[{key:"updateExtent",value:function(e){if(this.extent){var t,n=S(e?[e]:this.features.map((function(e){return e.extent})));try{for(n.s();!(t=n.n()).done;){var i=t.value;this.extent.union(i)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"removeEmptyFeature",value:function(){this.features=this.features.filter((function(e){return e.geometries.length}))}},{key:"pushFeature",value:function(e){this.features.push(e),this.updateExtent(e.extent)}},{key:"requestFeature",value:function(e,t){var n=this.features.find(t);if(n&&this.mergeFeatures)return n;var i=new yC(e,this);return this.features.push(i),i}},{key:"requestFeatureByType",value:function(e){return this.requestFeature(e,(function(t){return t.type===e}))}},{key:"requestFeatureById",value:function(e,t){return this.requestFeature(t,(function(t){return t.id===e}))}},{key:"newFeatureByReference",value:function(e){var t=new yC(e.type,this);return t.extent=e.extent,t.geometries=e.geometries,t.normals=e.normals,t.size=e.size,t.vertices=e.vertices,t._pos=e._pos,this.features.push(t),t}},{key:"transformCoordinates",value:function(e){return e.x=e.x/this.scale.x-this.translation.x,e.y=e.y/this.scale.y-this.translation.y,e.z=e.z/this.scale.z-this.translation.z,e}},{key:"setParentStyle",value:function(e){e&&this.features.forEach((function(t){t.style.parent=e}))}}]),e}(),xC=function(e){if(e.crsOut||e.crsIn){console.warn("Parsing options with crsIn and crsOut are deprecates, use { in, out } structure.");var t={in:{},out:{}};return t.in.crs=e.crsIn,t.in.isInverted=e.isInverted,t.in.styles=e.styles,t.in.layers=e.layers,t.in.filter=e.filter,t.out.crs=e.crsOut,t.out.mergeFeatures=e.mergeFeatures,t.out.withNormal=e.withNormal,t.out.withAltitude=e.withAltitude,e.out.withAltitude&&e.out.withNormal?t.structure="3d":t.structure="2d",t.out.filteringExtent=e.filteringExtent,t.out.style=e.style,t.out.overrideAltitudeInToZero=e.overrideAltitudeInToZero,t.out.filter=e.filter,t}return!e.out||void 0===e.out.withAltitude&&void 0===e.out.withNormal||(console.warn("Parsing options out.withAltitude and out.withNormal are deprecates, use out.structure: 2d or 3d."),e.out.withAltitude&&e.out.withNormal?e.structure="3d":e.structure="2d"),e};function bC(e){if(e.crs){if("epsg"==e.crs.type.toLowerCase())return"EPSG:".concat(e.crs.properties.code);if("name"==e.crs.type.toLowerCase()){var t=e.crs.properties.name.toLowerCase().indexOf("epsg:");if(t>=0){var n=e.crs.properties.name.indexOf(":",t+5);if(n>0)return"EPSG:".concat(e.crs.properties.name.substr(n+1))}}throw new Error("Unsupported CRS type '".concat(e.crs,"'"))}return"EPSG:4326"}var MC=new ob("EPSG:4978",0,0,0),CC=function(e,t,n){return MC.crs=n,MC.setFromArray(t[0]),!e.isPointInside(MC)},BC={populateGeometry:function(e,t,n,i,r){n.startSubGeometry(t.length,r);var a,o=!i.overrideAltitudeInToZero&&3==i.size&&"number"==typeof t[0][2],s=S(t);try{for(s.s();!(a=s.n()).done;){var l=a.value;MC.crs=e,MC.setFromValues(l[0],l[1],o?l[2]:0),n.pushCoordinates(MC,r)}}catch(e){s.e(e)}finally{s.f()}n.updateExtent()},point:function(e,t,n,i,r){this.default(e,t,[n],i,r)},default:function(e,t,n,i,r){if(!i.filterExtent||!CC(i.filterExtent,n,t)){var a=e.bindNewGeometry();a.properties=r,a.properties.style=new lC({},e.style).setFromGeojsonProperties(r,e.type),this.populateGeometry(t,n,a,i,e),e.updateExtent(a)}},polygon:function(e,t,n,i,r){if(!i.filterExtent||!CC(i.filterExtent,n[0],t)){var a=e.bindNewGeometry();a.properties=r,a.properties.style=new lC({},e.style).setFromGeojsonProperties(r,e.type);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{};(t=xC(t)).in=t.in||{};var n=t.out,i=t.in;switch("string"==typeof e&&(e=JSON.parse(e)),i.crs=i.crs||bC(e),n.filteringExtent&&("boolean"==typeof n.filteringExtent?n.filterExtent=e.extent.as(i.crs):n.filteringExtent.isExtent&&(n.filterExtent=n.filteringExtent)),e.type.toLowerCase()){case"featurecollection":return Promise.resolve(TC(i.crs,e.features,n));case"feature":return Promise.resolve(TC(i.crs,[e],n));default:throw new Error("Unsupported GeoJSON type: '".concat(e.type))}}};function IC(e,t){return Array.from(e.getElementsByTagName(t))}function LC(e){return"#"===e[0]?e:`#${e}`}function FC(e){return e?.normalize(),e&&e.textContent||""}function kC(e,t,n){const i=e.getElementsByTagName(t),r=i.length?i[0]:null;return r&&n&&n(r),r}function PC(e,t,n){const i={};if(!e)return i;const r=e.getElementsByTagName(t),a=r.length?r[0]:null;return a&&n?n(a,i):i}function UC(e,t,n){const i=FC(kC(e,t));return i&&n&&n(i)||{}}function DC(e,t,n){const i=parseFloat(FC(kC(e,t)));if(!isNaN(i))return i&&n&&n(i)||{}}function RC(e,t,n){const i=parseFloat(FC(kC(e,t)));if(!isNaN(i))return i&&n&&n(i),i}function OC(e,t){const n={};for(const i of t)UC(e,i,(e=>{n[i]=e}));return n}function NC(e){return 1===e?.nodeType}function zC(e){return PC(e,"line",(e=>{const t=Object.assign({},UC(e,"color",(e=>({stroke:`#${e}`}))),DC(e,"opacity",(e=>({"stroke-opacity":e}))),DC(e,"width",(e=>({"stroke-width":96*e/25.4}))));return t}))}function QC(e){let t=[];if(null===e)return t;for(const n of Array.from(e.childNodes)){if(!NC(n))continue;const e=GC(n.nodeName);if("gpxtpx:TrackPointExtension"===e)t=t.concat(QC(n));else{const i=FC(n);t.push([e,HC(i)])}}return t}function GC(e){return["heart","gpxtpx:hr","hr"].includes(e)?"heart":e}function HC(e){const t=parseFloat(e);return isNaN(t)?e:t}function VC(e){const t=[parseFloat(e.getAttribute("lon")||""),parseFloat(e.getAttribute("lat")||"")];if(isNaN(t[0])||isNaN(t[1]))return null;RC(e,"ele",(e=>{t.push(e)}));const n=kC(e,"time");return{coordinates:t,time:n?FC(n):null,extendedValues:QC(kC(e,"extensions"))}}function jC(e){const t=OC(e,["name","cmt","desc","type","time","keywords"]),n=Array.from(e.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3","*"));for(const i of n)i.parentNode?.parentNode===e&&(t[i.tagName.replace(":","_")]=FC(i));const i=IC(e,"link");return i.length&&(t.links=i.map((e=>Object.assign({href:e.getAttribute("href")},OC(e,["text","type"]))))),t}function WC(e,t){const n=IC(e,t),i=[],r=[],a={};for(let e=0;e1,o=Object.assign({_gpxType:"trk"},jC(e),zC(kC(e,"extensions")),i.length?{coordinateProperties:{times:a?i:i[0]}}:{});for(const e of r){n.push(e.line),o.coordinateProperties||(o.coordinateProperties={});const t=o.coordinateProperties,i=Object.entries(e.extendedValues);for(let e=0;enew Array(e.line.length).fill(null)))),t[n][e]=o):t[n]=o}}return{type:"Feature",properties:o,geometry:a?{type:"MultiLineString",coordinates:n}:{type:"LineString",coordinates:n[0]}}}function KC(e){const t=Object.assign(jC(e),OC(e,["sym"])),n=VC(e);return n?{type:"Feature",properties:t,geometry:{type:"Point",coordinates:n.coordinates}}:null}function*ZC(e){for(const t of IC(e,"trk")){const e=YC(t);e&&(yield e)}for(const t of IC(e,"rte")){const e=XC(t);e&&(yield e)}for(const t of IC(e,"wpt")){const e=KC(t);e&&(yield e)}}function JC(e,t){const n={},i="stroke"==t||"fill"===t?t:t+"-color";return"#"===e[0]&&(e=e.substring(1)),6===e.length||3===e.length?n[i]="#"+e:8===e.length&&(n[t+"-opacity"]=parseInt(e.substring(0,2),16)/255,n[i]="#"+e.substring(6,8)+e.substring(4,6)+e.substring(2,4)),n}function qC(e,t,n){const i={};return RC(e,t,(e=>{i[n]=e})),i}function $C(e,t){return PC(e,"color",(e=>JC(FC(e),t)))}function eB(e){return Object.assign({},function(e){return PC(e,"PolyStyle",((e,t)=>Object.assign(t,PC(e,"color",(e=>JC(FC(e),"fill"))),UC(e,"fill",(e=>{if("0"===e)return{"fill-opacity":0}})),UC(e,"outline",(e=>{if("0"===e)return{"stroke-opacity":0}})))))}(e),function(e){return PC(e,"LineStyle",(e=>Object.assign($C(e,"stroke"),qC(e,"width","stroke-width"))))}(e),function(e){return PC(e,"LabelStyle",(e=>Object.assign($C(e,"label"),qC(e,"scale","label-scale"))))}(e),function(e){return PC(e,"IconStyle",(e=>Object.assign($C(e,"icon"),qC(e,"scale","icon-scale"),qC(e,"heading","icon-heading"),PC(e,"hotSpot",(e=>{const t=parseFloat(e.getAttribute("x")||""),n=parseFloat(e.getAttribute("y")||""),i=e.getAttribute("xunits")||"",r=e.getAttribute("yunits")||"";return isNaN(t)||isNaN(n)?{}:{"icon-offset":[t,n],"icon-offset-units":[i,r]}})),PC(e,"Icon",((e,t)=>(UC(e,"href",(e=>{t.icon=e})),t))))))}(e))}const tB=/\s*/g,nB=/^\s*|\s*$/g,iB=/\s+/;function rB(e){return e.replace(tB,"").split(",").map(parseFloat).filter((e=>!isNaN(e))).slice(0,3)}function aB(e){return e.replace(nB,"").split(iB).map(rB).filter((e=>e.length>=2))}function oB(e){let t=IC(e,"coord");var n,i,r;0===t.length&&(n=e,i="coord",r="*",t=Array.from(n.getElementsByTagNameNS(r,i)));const a=t.map((e=>FC(e).split(" ").map(parseFloat)));return 0===a.length?null:{geometry:a.length>2?{type:"LineString",coordinates:a}:{type:"Point",coordinates:a[0]},times:IC(e,"when").map((e=>FC(e)))}}function sB(e){if(0===e.length)return e;const t=e[0],n=e[e.length-1];let i=!0;for(let e=0;e=2&&t.push({type:"Point",coordinates:e});break}case"LineString":{const e=aB(AB(r));e.length>=2&&t.push({type:"LineString",coordinates:e});break}case"Polygon":{const e=[];for(const t of IC(r,"LinearRing")){const n=sB(aB(AB(t)));n.length>=4&&e.push(n)}e.length&&t.push({type:"Polygon",coordinates:e});break}case"Track":case"gx:Track":{const e=oB(r);if(!e)break;const{times:i,geometry:a}=e;t.push(a),i.length&&n.push(i);break}}return{geometries:t,coordTimes:n}}function hB(e){return PC(e,"ExtendedData",((e,t)=>{for(const n of IC(e,"Data"))t[n.getAttribute("name")||""]=FC(kC(n,"value"));for(const n of IC(e,"SimpleData"))t[n.getAttribute("name")||""]=FC(n);return t}))}function uB(e){return 0===e.length?null:1===e.length?e[0]:{type:"GeometryCollection",geometries:e}}function dB(e){return PC(e,"TimeSpan",(e=>({timespan:{begin:FC(kC(e,"begin")),end:FC(kC(e,"end"))}})))}function fB(e){return PC(e,"TimeStamp",(e=>({timestamp:FC(kC(e,"when"))})))}function pB(e,t){return UC(e,"styleUrl",(e=>(e=LC(e),t[e]?Object.assign({styleUrl:e},t[e]):{styleUrl:e})))}function mB(e){const t=kC(e,"description");for(const e of Array.from(t?.childNodes||[]))if(4===e.nodeType)return{description:{"@type":"html",value:FC(e)}};return{}}function vB(e,t){const{coordTimes:n,geometries:i}=cB(e),r={type:"Feature",geometry:uB(i),properties:Object.assign(OC(e,["name","address","visibility","open","phoneNumber","description"]),mB(e),pB(e,t),eB(e),hB(e),dB(e),fB(e),n.length?{coordinateProperties:{times:1===n.length?n[0]:n}}:{})};void 0!==r.properties?.visibility&&(r.properties.visibility="0"!==r.properties.visibility);const a=e.getAttribute("id");return null!==a&&""!==a&&(r.id=a),r}function gB(e){let t=e.getAttribute("id");const n=e.parentNode;return!t&&NC(n)&&"CascadingStyle"===n.localName&&(t=n.getAttribute("kml:id")||n.getAttribute("id")),LC(t||"")}function*yB(e){const t=function(e){const t={};for(const n of IC(e,"Style"))t[gB(n)]=eB(n);for(const n of IC(e,"StyleMap")){const e=LC(n.getAttribute("id")||"");UC(n,"styleUrl",(n=>{n=LC(n),t[n]&&(t[e]=t[n])}))}return t}(e);for(const n of IC(e,"Placemark")){const e=vB(n,t);e&&(yield e)}}var wB={parse:function(e,t){return t=xC(t),_C.parse((n=e,{type:"FeatureCollection",features:Array.from(yB(n))}),t);var n}},xB={parse:function(e,t){return t=xC(t),_C.parse((n=e,{type:"FeatureCollection",features:Array.from(ZC(n))}),t);var n}},bB=function(e,t,n,i,r){var a,o,s=8*r-i-1,l=(1<>1,c=-7,h=n?r-1:0,u=n?-1:1,d=e[t+h];for(h+=u,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+h],h+=u,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=i;c>0;o=256*o+e[t+h],h+=u,c-=8);if(0===a)a=1-A;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),a-=A}return(d?-1:1)*o*Math.pow(2,a-i)},MB=function(e,t,n,i,r,a){var o,s,l,A=8*a-r-1,c=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:a-1,f=i?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?u/l:u*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(s=0,o=c):o+h>=1?(s=(t*l-1)*Math.pow(2,r),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,r),o=0));r>=8;e[n+d]=255&s,d+=f,s/=256,r-=8);for(o=o<0;e[n+d]=255&o,d+=f,o/=256,A-=8);e[n+d-f]|=128*p},CB=BB;function BB(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}BB.Varint=0,BB.Fixed64=1,BB.Bytes=2,BB.Fixed32=5;var EB=4294967296,SB=1/EB,TB="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _B(e){return e.type===BB.Bytes?e.readVarint()+e.pos:e.pos+1}function IB(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function LB(e,t,n){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(i);for(var r=n.pos-1;r>=e;r--)n.buf[r+i]=n.buf[r]}function FB(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function HB(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}BB.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos>3,a=this.pos;this.type=7&i,e(r,t,this),this.pos===a&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=QB(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=HB(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=QB(this.buf,this.pos)+QB(this.buf,this.pos+4)*EB;return this.pos+=8,e},readSFixed64:function(){var e=QB(this.buf,this.pos)+HB(this.buf,this.pos+4)*EB;return this.pos+=8,e},readFloat:function(){var e=bB(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=bB(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,i=this.buf;return t=127&(n=i[this.pos++]),n<128?t:(t|=(127&(n=i[this.pos++]))<<7,n<128?t:(t|=(127&(n=i[this.pos++]))<<14,n<128?t:(t|=(127&(n=i[this.pos++]))<<21,n<128?t:function(e,t,n){var i,r,a=n.buf;if(r=a[n.pos++],i=(112&r)>>4,r<128)return IB(e,i,t);if(r=a[n.pos++],i|=(127&r)<<3,r<128)return IB(e,i,t);if(r=a[n.pos++],i|=(127&r)<<10,r<128)return IB(e,i,t);if(r=a[n.pos++],i|=(127&r)<<17,r<128)return IB(e,i,t);if(r=a[n.pos++],i|=(127&r)<<24,r<128)return IB(e,i,t);if(r=a[n.pos++],i|=(1&r)<<31,r<128)return IB(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=i[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&TB?function(e,t,n){return TB.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){var i="",r=t;for(;r239?4:l>223?3:l>191?2:1;if(r+c>n)break;1===c?l<128&&(A=l):2===c?128==(192&(a=e[r+1]))&&(A=(31&l)<<6|63&a)<=127&&(A=null):3===c?(a=e[r+1],o=e[r+2],128==(192&a)&&128==(192&o)&&((A=(15&l)<<12|(63&a)<<6|63&o)<=2047||A>=55296&&A<=57343)&&(A=null)):4===c&&(a=e[r+1],o=e[r+2],s=e[r+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&((A=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||A>=1114112)&&(A=null)),null===A?(A=65533,c=1):A>65535&&(A-=65536,i+=String.fromCharCode(A>>>10&1023|55296),A=56320|1023&A),i+=String.fromCharCode(A),r+=c}return i}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==BB.Bytes)return e.push(this.readVarint(t));var n=_B(this);for(e=e||[];this.pos127;);else if(t===BB.Bytes)this.pos=this.readVarint()+this.pos;else if(t===BB.Fixed32)this.pos+=4;else{if(t!==BB.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,i;e>=0?(n=e%4294967296|0,i=e/4294967296|0):(i=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,i=i+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos]=127&e}(n,0,t),function(e,t){var n=(7&e)<<4;if(t.buf[t.pos++]|=n|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(i,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var i,r,a=0;a55295&&i<57344){if(!r){i>56319||a+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):r=i;continue}if(i<56320){e[n++]=239,e[n++]=191,e[n++]=189,r=i;continue}i=r-55296<<10|i-56320|65536,r=null}else r&&(e[n++]=239,e[n++]=191,e[n++]=189,r=null);i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=63&i|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&LB(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),MB(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),MB(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&LB(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,BB.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,FB,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,kB,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,DB,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,PB,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,UB,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,RB,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,OB,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,NB,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,zB,t)},writeBytesField:function(e,t){this.writeTag(e,BB.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,BB.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,BB.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,BB.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,BB.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,BB.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,BB.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,BB.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,BB.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,BB.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var VB=jB;function jB(e,t){this.x=e,this.y=t}jB.prototype={clone:function(){return new jB(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[0]*this.x+e[1]*this.y,n=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=n,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),i=t*this.x-n*this.y,r=n*this.x+t*this.y;return this.x=i,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),i=Math.sin(e),r=t.x+n*(this.x-t.x)-i*(this.y-t.y),a=t.y+i*(this.x-t.x)+n*(this.y-t.y);return this.x=r,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},jB.convert=function(e){return e instanceof jB?e:Array.isArray(e)?new jB(e[0],e[1]):e};var WB=XB;function XB(e,t,n,i,r){this.properties={},this.extent=n,this.type=0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=r,e.readFields(YB,this,t)}function YB(e,t,n){1==e?t.id=n.readVarint():2==e?function(e,t){var n=e.readVarint()+e.pos;for(;e.pos>3}if(r--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(t&&s.push(t),t=[]),t.push(new VB(a,o));else{if(7!==i)throw new Error("unknown command "+i);t&&t.push(t[0].clone())}}return t&&s.push(t),s},XB.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,i=0,r=0,a=0,o=1/0,s=-1/0,l=1/0,A=-1/0;e.pos>3}if(i--,1===n||2===n)(r+=e.readSVarint())s&&(s=r),(a+=e.readSVarint())A&&(A=a);else if(7!==n)throw new Error("unknown command "+n)}return[o,l,s,A]},XB.prototype.toGeoJSON=function(e,t,n){var i,r,a=this.extent*Math.pow(2,n),o=this.extent*e,s=this.extent*t,l=this.loadGeometry(),A=XB.types[this.type];function c(e){for(var t=0;t>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}return t}(n))}function $B(e,t,n){if(3===e){var i=new ZB(n,n.readVarint()+n.pos);i.length&&(t[i.name]=i)}}JB.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new WB(this._pbf,t,this.extent,this._keys,this._values)};var eE=function(e,t){this.layers=e.readFields($B,{},t)},tE=gb.get("EPSG:3857").dimensions(),nE=new at(tE.x,tE.y,1),iE=new tt,rE=new tt;function aE(e,t){t.out=t.out||{};var n=new eE(new CB(e)),i=Object.keys(n.layers);if(!(i.length<1)){var r=e.extent.col,a=e.extent.zoom,o=t.in.isInverted?e.extent.row:(1<=e.zoom.min&&a2&&void 0!==arguments[2]&&arguments[2],i=t.bindNewGeometry();n=n&&t.type===pC.POLYGON,i.properties=e.properties;var r=e._pbf;r.pos=e._geometry;for(var a=r.readVarint()+r.pos,o=1,s=0,l=0,A=0,c=0,h=0;r.pos>3}if(s--,1===o||2===o)l+=r.readSVarint(),A+=r.readSVarint(),1===o&&(c&&(n&&h>0&&i.indices.length>0&&(t.updateExtent(i),(i=t.bindNewGeometry()).properties=e.properties),i.closeSubGeometry(c,t),i.getLastSubGeometry().ccw=h<0),c=0,h=0),c++,i.pushCoordinatesValues(t,l,A),1==c?(rE.set(l,A),iE.set(l,A)):n&&c>1&&(h+=(iE.x-l)*(iE.y+A),iE.set(l,A));else{if(7!==o)throw new Error("unknown command ".concat(o));c&&(c++,i.pushCoordinatesValues(t,rE.x,rE.y),n&&(h+=(iE.x-rE.x)*(iE.y+rE.y)))}}c&&(n&&h>0&&i.indices.length>0&&(t.updateExtent(i),(i=t.bindNewGeometry()).properties=e.properties),i.closeSubGeometry(c,t),i.getLastSubGeometry().ccw=h<0),t.updateExtent(i)}(o,A))};for(c.s();!(r=c.n()).done;)h()}catch(e){c.e(e)}finally{c.f()}},o=i.length-1;o>=0;o--)r(o)})),s.removeEmptyFeature(),s.features.sort((function(e,t){return e.order-t.order})),s.updateExtent(),s.extent=e.extent,Promise.resolve(s)}}var oE={parse:function(e,t){return t=xC(t),Promise.resolve(aE(e,t))}},sE=new Map([["image/x-bil;bits=32",$M.textureFloat],["geojson",$M.json],["application/json",$M.json],["application/kml",$M.xml],["application/gpx",$M.xml],["application/x-protobuf;type=mapbox-vector",$M.arrayBuffer]]),lE=new Map([["geojson",_C.parse],["application/json",_C.parse],["application/kml",wB.parse],["application/gpx",xB.parse],["application/x-protobuf;type=mapbox-vector",oE.parse]]),AE={getByArray:function(){},setByArray:function(e){return e},clear:function(){}};var cE=0,hE=function(e){h(n,e);var t=y(n);function n(e){var i;if(s(this,n),(i=t.call(this,e)).isSource=!0,!e.url)throw new Error("New Source: url is required");return i.uid=cE++,i.url=e.url,i.format=e.format,i.fetcher=e.fetcher||sE.get(e.format)||$M.texture,i.parser=e.parser||lE.get(e.format)||function(e){return e},i.isVectorSource=null!=(e.parser||lE.get(e.format)),i.networkOptions=e.networkOptions||{crossOrigin:"anonymous"},i.attribution=e.attribution,i.whenReady=Promise.resolve(),i._featuresCaches={},e.extent&&!e.extent.isExtent?i.extent=new bb(i.crs,e.extent):i.extent=e.extent,i}return A(n,[{key:"handlingError",value:function(e){throw new Error(e)}},{key:"urlFromExtent",value:function(e){throw new Error("In extended Source, you have to implement the method urlFromExtent!")}},{key:"requestToKey",value:function(e){return[e.zoom,e.row,e.col]}},{key:"loadData",value:function(e,t){var n=this,i=this._featuresCaches[t.crs],r=this.requestToKey(e),a=i.getByArray(r);return a||(a=i.setByArray(function(e,t){var n=e.urlFromExtent(t);return e.fetcher(n,e.networkOptions).then((function(e){return e.extent=t,e}),(function(t){return e.handlingError(t)}))}(this,e).then((function(e){return n.parser(e,{out:t,in:n})}),(function(e){return n.handlingError(e)})),r),this.onParsedFile&&a.then((function(e){return n.onParsedFile(e),console.warn("Source.onParsedFile was deprecated"),e}))),a}},{key:"onLayerAdded",value:function(e){this._featuresCaches[e.out.crs]||(this._featuresCaches[e.out.crs]=this.isVectorSource?new XM:AE)}},{key:"onLayerRemoved",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this._featuresCaches[e.unusedCrs];t&&(t.clear(),delete this._featuresCaches[e.unusedCrs])}},{key:"extentInsideLimit",value:function(e){throw new Error("In extented Source, you have to implement the method extentInsideLimit!")}}]),n}(A((function e(t){s(this,e),t.projection&&(console.warn("Source projection parameter is deprecated, use crs instead."),t.crs=t.crs||t.projection),this.crs=t.crs}))),uE=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,n),r.projection&&(console.warn("Layer projection parameter is deprecated, use crs instead."),r.crs=r.crs||r.projection),void 0===r.source||!0===r.source)throw new Error("Layer ".concat(e," needs Source"));return(i=t.call(this)).isLayer=!0,Object.assign(v(i),r),Object.defineProperty(v(i),"id",{value:e,writable:!1}),i.options=r.options||{},i.updateStrategy||(i.updateStrategy={type:0,options:{}}),i.defineLayerProperty("frozen",!1),r.zoom?(i.zoom={max:r.zoom.max,min:r.zoom.min||0},null==i.zoom.max&&(i.zoom.max=1/0)):i.zoom={max:1/0,min:0},i.info=new VM(v(i)),i.source=i.source||new hE({url:"none"}),i.ready=!1,i._promises=[],i.whenReady=new Promise((function(e,t){i._resolve=e,i._reject=t})).then((function(){return i.ready=!0,i.source.onLayerAdded({out:v(i)}),v(i)})),i._promises.push(i.source.whenReady),i.cache=new XM(r.cacheLifeTime),i.mergeFeatures=void 0===i.mergeFeatures||r.mergeFeatures,i.filter=i.filter||i.source.filter,i}return A(n,[{key:"addInitializationStep",value:function(){var e;return this._promises.push(new Promise((function(t){e=t}))),e}},{key:"defineLayerProperty",value:function(e,t,n){var i=this,r=Object.getOwnPropertyDescriptor(this,e);if(!r||!r.set){var a=null==this[e]?t:this[e];Object.defineProperty(this,e,{get:function(){return a},set:function(t){if(a!==t){var r={type:"".concat(e,"-property-changed"),previous:{},new:{}};r.previous[e]=a,r.new[e]=t,a=t,n&&n(i,e),i.dispatchEvent(r)}}})}}},{key:"convert",value:function(e){return e}},{key:"getData",value:function(e,t){var n=this,i=this.source.requestToKey(this.source.isVectorSource?t:e),r=this.cache.getByArray(i);return r||(r=this.source.loadData(e,this).then((function(e){return n.convert(e,t)}),(function(e){throw e})),this.cache.setByArray(r,i)),r}},{key:"isValidData",value:function(e){}},{key:"delete",value:function(){console.warn("Function delete doesn't exist for this layer")}}]),n}(Je),dE=function(e){var t=Array.from(e);return t.sort((function(e,t){return e.sequence-t.sequence})),t.map((function(e){return e.id}))},fE=function(){try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},pE=function(){try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},mE=function(e){var t={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},n='Your $0 does not seem to support $1',i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",n=(n=t[e]?n.replace("$0","graphics card"):n.replace("$0","browser")).replace("$1",{1:"WebGL",2:"WebGL 2"}[e]),i.innerHTML=n,i};function vE(e,t){return!(e.left>t.right||e.rightt.bottom||e.bottom0&&void 0!==arguments[0]?arguments[0]:12,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;s(this,e),this.x=t,this.y=n,this.grid=[],this.hidden=[],this.visible=[],this.resize(),this.reset(),this.width=i,this.height=r}return A(e,[{key:"reset",value:function(){for(var e=0;e0&&this.grid[a][o].some((function(t){return vE(t.boundaries,e.boundaries)})))return this.hidden.push(e),!1;for(var s=t;s<=n;s++)for(var l=i;l<=r;l++)this.grid[s][l].push(e);return!0}}]),e}(),yE=new bt,wE=new at,xE=function(){function e(){s(this,e),this.domElement=document.createElement("div"),this.domElement.style.overflow="hidden",this.domElement.style.position="absolute",this.domElement.style.height="100%",this.domElement.style.width="100%",this.domElement.style.zIndex=1,this.garbage=document.createElement("div"),this.garbage.style.display="none",this.domElement.appendChild(this.garbage),this.halfWidth=0,this.halfHeight=0,this.grid=new gE,this.infoTileLayer=void 0}return A(e,[{key:"setSize",value:function(e,t){this.domElement.style.width="".concat(e),this.domElement.style.height="".concat(t),this.halfWidth=e/2,this.halfHeight=t/2,this.grid.width=e,this.grid.height=t,this.grid.x=Math.ceil(e/20),this.grid.y=Math.ceil(t/20),this.grid.resize()}},{key:"registerLayer",value:function(e){this.domElement.appendChild(e.domElement)}},{key:"render",value:function(e,t){var n=this;this.infoTileLayer&&this.infoTileLayer.layer.attachedLayers.find((function(e){return e.isLabelLayer&&e.visible}))&&(this.grid.reset(),yE.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.culling(e,this.infoTileLayer.displayed.extent),this.grid.visible.sort((function(e,t){var n=t.order-e.order;return 0==n?!e.visible&&t.visible?1:-1:n})),this.grid.visible.forEach((function(e){n.grid.insert(e)&&(e.visible=!0,e.updateCSSPosition())})),this.grid.hidden.forEach((function(e){e.visible=!1})))}},{key:"culling",value:function(e,t){var n=this;if(e.isLabel)!t.isPointInside(e.coordinates)||function(e){var t=e.parent;return t.material&&!t.material.visible&&t.children.find((function(e){return e.isTileMesh&&e.children.find((function(e){return e.isLabel}))}))}(e)||e.parent.level<4&&e.parent.layer.horizonCulling&&e.parent.layer.horizonCulling(e.horizonCullingPoint)?this.grid.hidden.push(e):(wE.setFromMatrixPosition(e.matrixWorld),wE.applyMatrix4(yE),e.updateProjectedPosition(wE.x*this.halfWidth+this.halfWidth,-wE.y*this.halfHeight+this.halfHeight),this.grid.visible.some((function(t){return t.projectedPosition.x==e.projectedPosition.x&&t.projectedPosition.y==e.projectedPosition.y&&t.baseContent==e.baseContent}))?(e.parent.remove(e),this.grid.hidden.push(e)):this.grid.visible.push(e));else{if(!e.visible)return void this.hideNodeDOM(e);if(e.extent&&!e.extent.intersectsExtent(t))return void this.hideNodeDOM(e);this.showNodeDOM(e),e.children.forEach((function(e){return n.culling(e,t)}))}}},{key:"removeLabelDOM",value:function(e){this.garbage.appendChild(e.content),this.garbage.innerHTML=""}},{key:"hideNodeDOM",value:function(e){var t=this;if(e.domElements){var n=Object.values(e.domElements);n.length>0?n.forEach((function(e){1==e.visible&&(e.dom.style.display="none",e.visible=!1)})):e.children.filter((function(e){return e.isTileMesh})).forEach((function(e){return t.hideNodeDOM(e)}))}}},{key:"showNodeDOM",value:function(e){e.domElements&&Object.values(e.domElements).forEach((function(e){0==e.visible&&(e.dom.style.display="block",e.visible=!0)}))}}]),e}(),bE=new ut,ME=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,e);var i=!oM();void 0===n.antialias&&(n.antialias=!0),void 0===n.alpha&&(n.alpha=!0),void 0===n.logarithmicDepthBuffer&&(n.logarithmicDepthBuffer=this.gLDebug||i),void 0===n.isWebGL2&&(n.isWebGL2=!0);var r=t.domElement?t:void 0,a=r?r.domElement:t;this.width=a.clientWidth,this.height=a.clientHeight,this.positionBuffer=null,this._nextThreejsLayer=1,this.fullSizeRenderTarget=new dt(this.width,this.height),this.fullSizeRenderTarget.texture.minFilter=Z,this.fullSizeRenderTarget.texture.magFilter=X,this.fullSizeRenderTarget.depthBuffer=!0,this.fullSizeRenderTarget.depthTexture=new ns,this.fullSizeRenderTarget.depthTexture.type=ee,this.renderView=function(e){this.renderer.clear(),this.renderer.render(e.scene,e.camera.camera3D),this.label2dRenderer.render(e.scene,e.camera.camera3D)}.bind(this),this.onWindowResize=function(e,t){this.width=e,this.height=t,this.fullSizeRenderTarget.setSize(this.width,this.height),this.renderer.setSize(this.width,this.height),this.label2dRenderer.setSize(this.width,this.height)}.bind(this);try{this.label2dRenderer=new xE,this.label2dRenderer.setSize(this.width,this.height),a.appendChild(this.label2dRenderer.domElement),this.renderer=r||new(n.isWebGL2,$a)({canvas:document.createElement("canvas"),antialias:n.antialias,alpha:n.alpha,logarithmicDepthBuffer:n.logarithmicDepthBuffer}),this.renderer.domElement.style.position="relative",this.renderer.domElement.style.zIndex=0,this.renderer.domElement.style.top=0}catch(e){var o=n.isWebGL2?"2":"1";console.error("Failed to create WebGLRenderer webGL ".concat(o,".")),this.renderer=null}if(!this.renderer)throw fE()?pE()||a.appendChild(mE(2)):a.appendChild(mE(1)),new Error("WebGL unsupported");!r&&n.logarithmicDepthBuffer&&(this.renderer.capabilities.isWebGL2||this.renderer.extensions.get("EXT_frag_depth")||(this.renderer.dispose(),this.renderer=new(n.isWebGL2,$a)({canvas:document.createElement("canvas"),antialias:n.antialias,alpha:n.alpha,logarithmicDepthBuffer:!1}))),-1===this.renderer.domElement.tabIndex&&(this.renderer.domElement.tabIndex=-1),lM(this.renderer),this.renderer.setClearColor(197896),this.renderer.sortObjects=!0,this.renderer.debug.checkShaderErrors=__DEBUG__,r||(this.renderer.setPixelRatio(a.devicePixelRatio),this.renderer.setSize(a.clientWidth,a.clientHeight),a.appendChild(this.renderer.domElement))}return A(e,[{key:"getWindowSize",value:function(){return new tt(this.width,this.height)}},{key:"getRenderer",value:function(){return this.renderer}},{key:"renderViewToBuffer",value:function(e,t){return t||(t={x:0,y:0,width:this.width,height:this.height}),t.buffer=t.buffer||new Uint8Array(4*t.width*t.height),this.renderViewToRenderTarget(e,this.fullSizeRenderTarget,t),this.renderer.readRenderTargetPixels(this.fullSizeRenderTarget,t.x,this.height-(t.y+t.height),t.width,t.height,t.buffer),t.buffer}},{key:"renderViewToRenderTarget",value:function(e,t,n){t||(t=this.fullSizeRenderTarget);var i=this.renderer.getRenderTarget();return n&&(this.fullSizeRenderTarget.scissor.set(n.x,t.height-(n.y+n.height),n.width,n.height),this.fullSizeRenderTarget.scissorTest=!0),this.renderer.setRenderTarget(t),this.renderer.clear(!0,!0,!1),this.renderer.render(e.scene,e.camera.camera3D),this.renderer.setRenderTarget(i),this.fullSizeRenderTarget.scissorTest=!1,t}},{key:"bufferToImage",value:function(e,t,n){var i=document.createElement("canvas"),r=i.getContext("2d");i.width=t,i.height=n;var a=r.getImageData(0,0,t,n);a.data.set(e),r.putImageData(a,0,0);var o=new Image;return o.src=i.toDataURL(),o}},{key:"getUniqueThreejsLayer",value:function(){return this._nextThreejsLayer>31&&(console.warn("Too much three.js layers. Starting from now all of them will use layerMask = 31"),this._nextThreejsLayer=31),this._nextThreejsLayer++}},{key:"depthBufferRGBAValueToOrthoZ",value:function(e,t){if(bE.fromArray(e).divideScalar(255),aM()&&"PerspectiveCamera"==t.type){var n=CM(bE),i=2/(Math.log(t.far+1)/Math.LN2);return Math.pow(2,2*n/i)}var r=CM(bE);return r=2*r-1}},{key:"onRender",value:function(){}}]),e}();function CE(e,t,n,i,r,a,o){if(t==pC.LINE&&function(e,t,n,i,r,a){for(var o=e.x,s=e.y,l=i+a,A=i;l=-n&&y<=g+n&&Math.abs(v*o-m*s+u*h-d*c)/g<=n)return!0}return!1}(e,n,i,r,a,o))return!0;if(t==pC.POLYGON&&function(e,t,n,i,r){for(var a=e.x,o=e.y,s=!1,l=n,A=n+i-r;lo!=d>o&&a<(u-c)*(o-h)/(d-h)+c&&(s=!s)}return s}(e,n,r,a,o))return!0;if(t==pC.POINT){var s=function(e,t,n,i,r,a){for(var o,s=e.x,l=e.y,A=n*n,c=i;c2&&void 0!==arguments[2]?arguments[2]:.1,i=[];if(SE.copy(e),t.extent){if(SE.as(Jx.formatToEPSG(t.extent.crs),SE),t.extent.as(SE.crs,EE),!EE.isPointInside(SE,n))return i;(t.isFeatureCollection&&1!=t.scale.x&&1!=t.scale.y||0!=t.translation.x&&0!=t.translation.y)&&(SE.x=(SE.x+t.translation.x)*t.scale.x,SE.y=(SE.y+t.translation.y)*t.scale.y,1!=t.scale.x&&1!=t.scale.y&&(n*=Math.sqrt(Math.pow(t.scale.x,2)+Math.pow(t.scale.y,2))))}if(t.isFeatureCollection){var r,a=S(t.features);try{for(a.s();!(r=a.n()).done;){var o=r.value;o.extent&&!o.extent.isPointInside(SE,n)||BE(SE,o,n,i)}}catch(e){a.e(e)}finally{a.f()}}else t.geometries&&BE(SE,t,n,i);return i},_E=new bb("EPSG:4326",[0,0,0,0]),IE=0;function LE(e){var t=/\$\{u:([\w-_.|]+)\}/.exec(e);if(!t)return e;var n=t[1].split("|");return e.replace(t[0],n[IE++%n.length])}var FE=function(e,t){return LE(t.url.replace(/(\$\{z\}|%TILEMATRIX)/,e.zoom).replace(/(\$\{y\}|%ROW)/,e.row).replace(/(\$\{x\}|%COL)/,e.col))},kE=function(e,t){var n="EPSG:4326"==t.crs?9:2;e.as(t.crs,_E);var i=_E.west.toFixed(n),r=_E.south.toFixed(n),a=_E.east.toFixed(n),o=_E.north.toFixed(n),s=t.axisOrder||"wsen";return s=s.replace("w","".concat(i,",")).replace("s","".concat(r,",")).replace("e","".concat(a,",")).replace("n","".concat(o,",")).slice(0,-1),LE(t.url.replace("%bbox",s))},PE=function(e){return LE(e)},UE={executeCommand:function(e){var t=e.layer,n=e.extentsSource,i=e.extentsDestination||n;return Promise.all(n.map((function(e,n){return t.getData(e,i[n])})))}},DE=function(){function e(t){s(this,e),this.command=t,this.isCancelledCommandException=!0}return A(e,[{key:"toString",value:function(){return"Cancelled command ".concat(this.command.requester.id,"/").concat(this.command.layer.id)}}]),e}(),RE={executeCommand:function(e){var t=[],n=e.layer,i=e.requester,r=e.extentsSource;if(i&&!i.material)return Promise.reject(new DE(e));for(var a=0,o=r.length;a=2.0 are supported."));else{var c=new H(A,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(var u=0;u=0&&void 0===l[v]&&console.warn('THREE.GLTFLoader: Unknown extension "'+v+'".')}}c.setExtensions(s),c.setPlugins(l),c.parse(i,r)}}});var n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};function i(e){this.parser=e,this.name=n.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function a(){this.name=n.KHR_MATERIALS_UNLIT}function o(e){this.parser=e,this.name=n.KHR_MATERIALS_CLEARCOAT}function s(e){this.parser=e,this.name=n.KHR_MATERIALS_TRANSMISSION}function l(e){this.parser=e,this.name=n.KHR_TEXTURE_BASISU}function A(e){this.parser=e,this.name=n.EXT_TEXTURE_WEBP,this.isSupported=null}function c(e){this.name=n.EXT_MESHOPT_COMPRESSION,this.parser=e}i.prototype._markDefs=function(){for(var e=this.parser,t=this.parser.json.nodes||[],n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a,o)},A.prototype.loadTexture=function(e){var t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;var a=r.extensions[t],o=i.images[a.source],s=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(s=l)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))},A.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported},c.prototype.loadBufferView=function(e){var t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){var i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,a.ready]).then((function(e){var t=i.byteOffset||0,n=i.byteLength||0,r=i.count,o=i.byteStride,s=new ArrayBuffer(r*o),l=new Uint8Array(e[0],t,n);return a.decodeGltfBuffer(new Uint8Array(s),r,o,l,i.mode,i.filter),s}))}return null};var h="glTF",u=1313821514,d=5130562;function f(e){this.name=n.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,12);if(this.header={magic:OA.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==h)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var i=this.header.length-12,r=new DataView(e,12),a=0;a",t).replace("#include ",n).replace("#include ",i).replace("#include ",r).replace("#include ",a)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}function g(){return{name:n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return v},extendParams:function(e,t,n){var i=t.extensions[this.name];e.color=new Fn(1,1,1),e.opacity=1;var r=[];if(Array.isArray(i.diffuseFactor)){var a=i.diffuseFactor;e.color.fromArray(a),e.opacity=a[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(e,"map",i.diffuseTexture)),e.emissive=new Fn(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Fn(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var o=i.specularGlossinessTexture;r.push(n.assignTexture(e,"glossinessMap",o)),r.push(n.assignTexture(e,"specularMap",o))}return Promise.all(r)},createMaterial:function(e){var t=new v(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}}function y(){this.name=n.KHR_MESH_QUANTIZATION}function w(e,t,n,i){Il.call(this,e,t,n,i)}p.prototype.decodePrimitive=function(e,t){var n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var A in a){var c=F[A]||A.toLowerCase();o[c]=a[A]}for(A in e.attributes){c=F[A]||A.toLowerCase();if(void 0!==a[A]){var h=n.accessors[e.attributes[A]],u=T[h.componentType];l[c]=u,s[c]=!0===h.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(var n in e.attributes){var i=e.attributes[n],r=s[n];void 0!==r&&(i.normalized=r)}t(e)}),o,l)}))}))},m.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},v.prototype=Object.create(gl.prototype),v.prototype.constructor=v,v.prototype.copy=function(e){return gl.prototype.copy.call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this},w.prototype=Object.create(Il.prototype),w.prototype.constructor=w,w.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i,a=0;a!==i;a++)t[a]=n[r+a];return t},w.prototype.beforeStart_=w.prototype.copySampleValue_,w.prototype.afterEnd_=w.prototype.copySampleValue_,w.prototype.interpolate_=function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,A=i-t,c=(n-t)/A,h=c*c,u=h*c,d=e*l,f=d-l,p=-2*u+3*h,m=u-h,v=1-p,g=m-h+c,y=0;y!==o;y++){var w=a[f+y+o],x=a[f+y+s]*A,b=a[d+y+o],M=a[d+y]*A;r[y]=v*w+g*x+p*b+m*M}return r};var x=0,b=1,M=2,C=3,B=4,E=5,S=6,T={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},_={9728:X,9729:Z,9984:Y,9985:J,9986:K,9987:q},I={33071:j,33648:W,10497:V},L={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},F={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex",_BATCHID:"_BATCHID"},k={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},P={CUBICSPLINE:void 0,LINEAR:ke,STEP:Fe},U="OPAQUE",D="MASK",R="BLEND";function O(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function N(e,t,n){for(var i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function z(e,t){void 0!==t.extras&&("object"===r(t.extras)?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Q(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var n=0,i=t.weights.length;n=2&&r.setY(C,x[b*o+1]),o>=3&&r.setZ(C,x[b*o+2]),o>=4&&r.setW(C,x[b*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return r}))},H.prototype.loadTexture=function(e){var t=this.json,n=this.options,i=t.textures[e],r=t.images[i.source],a=this.textureLoader;if(r.uri){var o=n.manager.getHandler(r.uri);null!==o&&(a=o)}return this.loadTextureImage(e,r,a)},H.prototype.loadTextureImage=function(e,t,n){var i=this,r=this.json,a=this.options,o=r.textures[e],s=self.URL||self.webkitURL,l=t.uri,A=!1,c=!0;if("image/jpeg"===t.mimeType&&(c=!1),void 0!==t.bufferView)l=i.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){var n=new DataView(e,25,1).getUint8(0,!1);c=6===n||4===n||3===n}A=!0;var i=new Blob([e],{type:t.mimeType});return l=s.createObjectURL(i)}));else if(void 0===t.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return Promise.resolve(l).then((function(e){return new Promise((function(t,i){var r=t;!0===n.isImageBitmapLoader&&(r=function(e){t(new ts(e))}),n.load(O(e,a.path),r,void 0,i)}))})).then((function(t){!0===A&&s.revokeObjectURL(l),t.flipY=!1,o.name&&(t.name=o.name),c||(t.format=Ae);var n=(r.samplers||{})[o.sampler]||{};return t.magFilter=_[n.magFilter]||Z,t.minFilter=_[n.minFilter]||q,t.wrapS=I[n.wrapS]||V,t.wrapT=I[n.wrapT]||V,i.associations.set(t,{type:"textures",index:e}),t}))},H.prototype.assignTexture=function(e,t,i){var r=this;return this.getDependency("texture",i.index).then((function(a){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===t&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+t+" not yet supported."),r.extensions[n.KHR_TEXTURE_TRANSFORM]){var o=void 0!==i.extensions?i.extensions[n.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var s=r.associations.get(a);a=r.extensions[n.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,s)}}e[t]=a}))},H.prototype.assignFinalMaterial=function(e){var t=e.geometry,n=e.material,i=void 0!==t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal,o=!0===e.isSkinnedMesh,s=Object.keys(t.morphAttributes).length>0,l=s&&void 0!==t.morphAttributes.normal;if(e.isPoints){var A="PointsMaterial:"+n.uuid,c=this.cache.get(A);c||(c=new Xo,On.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(A,c)),n=c}else if(e.isLine){A="LineBasicMaterial:"+n.uuid;var h=this.cache.get(A);h||(h=new Do,On.prototype.copy.call(h,n),h.color.copy(n.color),this.cache.add(A,h)),n=h}if(i||r||a||o||s){A="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(A+="specular-glossiness:"),o&&(A+="skinning:"),i&&(A+="vertex-tangents:"),r&&(A+="vertex-colors:"),a&&(A+="flat-shading:"),s&&(A+="morph-targets:"),l&&(A+="morph-normals:");var u=this.cache.get(A);u||(u=n.clone(),o&&(u.skinning=!0),r&&(u.vertexColors=!0),a&&(u.flatShading=!0),s&&(u.morphTargets=!0),l&&(u.morphNormals=!0),i&&(u.vertexTangents=!0,u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(A,u),this.associations.set(u,this.associations.get(n))),n=u}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n},H.prototype.getMaterialType=function(){return gl},H.prototype.loadMaterial=function(e){var t,i=this,r=this.json,a=this.extensions,o=r.materials[e],s={},l=o.extensions||{},A=[];if(l[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var c=a[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=c.getMaterialType(),A.push(c.extendParams(s,o,i))}else if(l[n.KHR_MATERIALS_UNLIT]){var h=a[n.KHR_MATERIALS_UNLIT];t=h.getMaterialType(),A.push(h.extendParams(s,o,i))}else{var u=o.pbrMetallicRoughness||{};if(s.color=new Fn(1,1,1),s.opacity=1,Array.isArray(u.baseColorFactor)){var d=u.baseColorFactor;s.color.fromArray(d),s.opacity=d[3]}void 0!==u.baseColorTexture&&A.push(i.assignTexture(s,"map",u.baseColorTexture)),s.metalness=void 0!==u.metallicFactor?u.metallicFactor:1,s.roughness=void 0!==u.roughnessFactor?u.roughnessFactor:1,void 0!==u.metallicRoughnessTexture&&(A.push(i.assignTexture(s,"metalnessMap",u.metallicRoughnessTexture)),A.push(i.assignTexture(s,"roughnessMap",u.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),A.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===o.doubleSided&&(s.side=2);var f=o.alphaMode||U;return f===R?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,f===D&&(s.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==Nn&&(A.push(i.assignTexture(s,"normalMap",o.normalTexture)),s.normalScale=new tt(1,-1),void 0!==o.normalTexture.scale&&s.normalScale.set(o.normalTexture.scale,-o.normalTexture.scale)),void 0!==o.occlusionTexture&&t!==Nn&&(A.push(i.assignTexture(s,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(s.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==Nn&&(s.emissive=(new Fn).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&t!==Nn&&A.push(i.assignTexture(s,"emissiveMap",o.emissiveTexture)),Promise.all(A).then((function(){var r;return r=t===v?a[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new t(s),o.name&&(r.name=o.name),r.map&&(r.map.encoding=Ne),r.emissiveMap&&(r.emissiveMap.encoding=Ne),z(r,o),i.associations.set(r,{type:"materials",index:e}),o.extensions&&N(a,r,o),r}))},H.prototype.createUniqueName=function(e){for(var t=kc.sanitizeNodeName(e||""),n=t,i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n},H.prototype.loadGeometries=function(e){var t=this,i=this.extensions,r=this.primitiveCache;function a(e){return i[n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return $(n,e,t)}))}for(var o,s,l=[],A=0,c=e.length;A0&&Q(h,a),h.name=n.createUniqueName(a.name||"mesh_"+e),z(h,a),d.extensions&&N(r,h,d),n.assignFinalMaterial(h),l.push(h)}if(1===l.length)return l[0];var p=new ja;for(A=0,c=l.length;A1?new ja:1===t.length?t[0]:new zt)!==t[0])for(var s=0,l=t.length;st._taskLoad?-1:1}));return(i=n.workerPool[n.workerPool.length-1])._taskCosts[e]=t,i._taskLoad+=t,i}))},_releaseTask:function(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]},debug:function(){console.log("Task load: ",this.workerPool.map((function(e){return e._taskLoad})))},dispose:function(){for(var e=0;e=0&&(l[i.KHR_MATERIALS_COMMON]=new r(A)),new B(A,l,{crossOrigin:this.crossOrigin,manager:this.manager,path:t||this.resourcePath||""}).parse((function(e,t,i,r){n({scene:e,scenes:t,cameras:i,animations:r})}))}}),e.Shaders={update:function(){console.warn("threeExamples.LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.")}},n.prototype.update=function(e,t){var n=this.boundUniforms;for(var i in n){var r=n[i];switch(r.semantic){case"MODELVIEW":r.uniform.value.multiplyMatrices(t.matrixWorldInverse,r.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var a=r.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,r.sourceNode.matrixWorld),a.getNormalMatrix(this._m4);break;case"PROJECTION":r.uniform.value.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=r.uniform.value,s=0;s>10),56320+(1023&i)))}return t}(a)}};var KE=new XE("utf-8"),ZE="tileset",JE="batchtable",qE="boundingVolume",$E=function(){function e(t,n,i,r){s(this,e),this.type=JE,this.batchLength=i;var a=t;n>0&&(console.warn("Binary batch table content not supported yet."),a=t.slice(0,t.byteLength));var o=KE.decode(new Uint8Array(a)),l=JSON.parse(o);l.extensions&&(this.extensions=r.parseExtensions(l.extensions,this.type),delete l.extensions),this.content=l}return A(e,[{key:"getInfoById",value:function(e){if(e<0&&e0){var u=l,d=e.slice(u,s.FTJSONLength+u),f=KE.decode(new Uint8Array(d));(c=JSON.parse(f)).RTC_CENTER?h.fromArray(c.RTC_CENTER):h.set(0,0,0)}if(s.FTBinaryLength>0&&console.warn("3D Tiles feature table binary not supported yet."),s.BTJSONLength>0){var p=l+s.FTJSONLength+s.FTBinaryLength,m=e.slice(p,s.BTJSONLength+p);A.push(new $E(m,s.BTBinaryLength,c.BATCH_LENGTH,t.registeredExtensions))}else A.push(Promise.resolve({}));var v=l+s.FTJSONLength+s.FTBinaryLength+s.BTJSONLength+s.BTBinaryLength,g=e.slice(v),y=new DataView(g,0,20);return A.push(new Promise((function(e){var a=function(i){var a,o=S(i.scenes);try{for(o.s();!(a=o.n()).done;){a.value.traverse(rS)}}catch(e){o.e(e)}finally{o.f()}void 0===n||"Y"===n?i.scene.applyMatrix4(eS):"X"===n&&i.scene.applyMatrix4(tS),i.scene.position.copy(h);var s=new Uint8Array(g,20,y.getUint32(12,!0)),l=KE.decode(new Uint8Array(s)),A=JSON.parse(l);A.extensions&&A.extensions.CESIUM_RTC&&(i.scene.position.fromArray(A.extensions.CESIUM_RTC.center),i.scene.updateMatrixWorld(!0));i.scene.traverse((function(e){if(e.isB3dm=!0,e.frustumCulled=!1,e.material){if(t.overrideMaterials){if(Array.isArray(e.material)){var n,i=S(e.material);try{for(i.s();!(n=i.n()).done;){n.value.dispose()}}catch(e){i.e(e)}finally{i.f()}}else e.material.dispose();"object"===r(t.overrideMaterials)&&t.overrideMaterials.isMaterial?e.material=t.overrideMaterials:e.material.depthWrite=!0}else aM()&&e.material.isRawShaderMaterial&&!t.doNotPatchMaterial&&(dM(e.material),console.warn("b3dm shader has been patched to add log depth buffer support"));e.material.transparent=t.opacity<1,e.material.opacity=t.opacity}})),e(i)};1===y.getUint32(4,!0)?iS.parse(g,i,a):nS.parse(g,i,a)}))),Promise.all(A).then((function(e){return{gltf:e[1],batchTable:e[0]}}))}throw new Error("Invalid b3dm file.")},oS=function(e,t){if(!e)throw new Error("No array buffer provided.");var n=new DataView(e),i=0,r={},a={},o={};if(r.magic=KE.decode(new Uint8Array(e,i,4)),i+=4,r.magic){r.version=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,r.byteLength=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,r.FTJSONLength=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,r.FTBinaryLength=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,r.BTJSONLength=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT,r.BTBinaryLength=n.getUint32(i,!0),i+=Uint32Array.BYTES_PER_ELEMENT;var s={};if(r.FTJSONLength>0){var l=i,A=e.slice(l,r.FTJSONLength+l),c=KE.decode(new Uint8Array(A));s=JSON.parse(c)}if(r.FTBinaryLength>0&&(o=function(e,t,n){var i,r=new si,a=KE.decode(new Uint8Array(e,t,n)),o=JSON.parse(a);o.POINTS_LENGTH&&(i=o.POINTS_LENGTH);if(o.POSITION){var s=o.POSITION.byteOffset+a.length+t,l=new Float32Array(e,s,3*i);r.setAttribute("position",new zn(l,3))}if(o.RGB){var A=o.RGB.byteOffset+a.length+t,c=new Uint8Array(e,A,3*i);r.setAttribute("color",new zn(c,3,!0))}if(o.POSITION_QUANTIZED)throw new Error("For pnts loader, POSITION_QUANTIZED: not yet managed");if(o.RGBA)throw new Error("For pnts loader, RGBA: not yet managed");if(o.RGB565)throw new Error("For pnts loader, RGB565: not yet managed");if(o.NORMAL)throw new Error("For pnts loader, NORMAL: not yet managed");if(o.NORMAL_OCT16P)throw new Error("For pnts loader, NORMAL_OCT16P: not yet managed");if(o.BATCH_ID)throw new Error("For pnts loader, BATCH_ID: not yet managed");var h=o.RTC_CENTER?(new at).fromArray(o.RTC_CENTER):void 0;return{geometry:r,offset:h}}(e,i,r.FTJSONLength)),r.BTJSONLength>0){var h=i+r.FTJSONLength+r.FTBinaryLength,u=e.slice(h,r.BTJSONLength+h);a=new $E(u,r.BTBinaryLength,s.BATCH_LENGTH,t)}var d={point:o,batchTable:a};return Promise.resolve(d)}throw new Error("Invalid pnts file.")};function sS(e,t,n){var i=OA.extractUrlBase(n),r={gltfUpAxis:t.tileset.asset.gltfUpAxis,urlBase:i,overrideMaterials:t.overrideMaterials,doNotPatchMaterial:t.doNotPatchMaterial,opacity:t.opacity,registeredExtensions:t.registeredExtensions};return aS(e,r).then((function(e){return{batchTable:e.batchTable,object3d:e.gltf.scene}}))}function lS(e,t){return oS(e,t.registeredExtensions).then((function(e){var n=t.material?t.material.clone():new Xo({size:.05,vertexColors:!0}),i=new qo(e.point.geometry,n);return e.point.offset&&i.position.copy(e.point.offset),{object3d:i}}))}var AS={executeCommand:function(e){var t=e.layer,n=e.metadata,i=new zt;!function(e,t,n,i){e.frustumCulled=!1,e.layer=t,n.transform&&e.applyMatrix4(n.transform),e.geometricError=n.geometricError,e.tileId=n.tileId,n.refine?e.additiveRefinement="ADD"===n.refine.toUpperCase():e.additiveRefinement=!!i&&i.additiveRefinement,e.viewerRequestVolume=n.viewerRequestVolume,e.boundingVolume=n.boundingVolume,e.boundingVolume.region&&e.add(e.boundingVolume.region),e.updateMatrixWorld()}(i,t,n,e.requester);var r=n.content&&(n.content.url||n.content.uri),a=function(e){e.layers.set(t.threejsLayer),e.userData.metadata=n,e.layer=t,e.material&&(e.material.transparent=t.opacity<1,e.material.opacity=t.opacity,e.material.wireframe=t.wireframe)};if(r){var o=r.startsWith("http")?r:n.baseURL+r,s={b3dm:sS,pnts:lS};return $M.arrayBuffer(o,t.source.networkOptions).then((function(e){if(void 0!==e){var r,l=KE.decode(new Uint8Array(e,0,4));if("{"===l[0]){e=JSON.parse(KE.decode(new Uint8Array(e)));var A=o.slice(0,o.lastIndexOf("/")+1);t.tileset.extendTileset(e,n.tileId,A,t.registeredExtensions)}else if("b3dm"==l)r=s.b3dm;else{if("pnts"!=l)return Promise.reject("Unsupported magic code ".concat(l));r=s.pnts}if(r)return r(e,t,o).then((function(e){return i.content=e.object3d,e.batchTable&&(i.batchTable=e.batchTable),i.add(e.object3d),i.traverse(a),i}))}return i.traverse(a),i}))}return i.traverse(a),Promise.resolve(i)}},cS=1;var hS={executeCommand:function(e){var t=e.layer,n=e.requester;return n.load().then((function(i){var r=new qo(i,t.material);return function(e){var t=e.geometry.attributes.position.count,n=new Uint8Array(4*t),i=cS++;if(t>65535||i>65535)return console.warn("Currently picking is limited to Points with less than 65535 elements and less than 65535 Points instances"),e;for(var r=0;r>24,n[4*r+1]=(16711680&a)>>16,n[4*r+2]=(65280&a)>>8,n[4*r+3]=(255&a)>>0}e.baseId=i,e.geometry.setAttribute("unique_id",new zn(n,4,!0))}(r),r.frustumCulled=!1,r.matrixAutoUpdate=!1,t.isEntwinePointTileLayer||(r.position.copy(n.bbox.min),r.scale.copy(t.scale)),r.updateMatrix(),r.tightbbox=i.boundingBox.applyMatrix4(r.matrix),r.layers.set(t.threejsLayer),r.layer=t,r.extent=bb.fromBox3(e.view.referenceCrs,n.bbox),r.userData.node=n,r}))}};function uS(e,t){var n=t.priority-e.priority;return 0===n?t.timestamp-e.timestamp:n}function dS(){return{queue:function(e){var t=e.layer,n=this.storages.get(t.id);n||(n={q:new PriorityQueue({comparator:uS}),priority:1,accumulator:0},this.storages.set(t.id,n)),n.priority=t.priority||1,n.q.queue(e),this.counters.pending++},storages:new Map,counters:{executing:0,executed:0,failed:0,cancelled:0,pending:0},execute:function(e,t){var n=this;return this.counters.pending--,this.counters.executing++,t.executeCommand(e).then((function(t){n.counters.executing--,e.resolve(t),n.counters.executed++}),(function(t){n.counters.executing--,e.reject(t),n.counters.failed++,__DEBUG__&&n.counters.failed<3&&console.error(t)}))}}}function fS(){this.defaultQueue=dS(),this.hostQueues=new Map,this.providers={},this.maxCommandsPerHost=6,this.initDefaultProviders()}function pS(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=e.camera.camera3D.layers.mask;return e.camera.camera3D.layers.mask=1<>>1],t)>=0?r=a+1:i=a;return r},t.exports=function(){function e(e){var t;this.options=e,this.comparator=this.options.comparator,this.data=(null!=(t=this.options.initialValues)?t.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return e.prototype.queue=function(e){var t;t=i(this.data,e,this.comparator),this.data.splice(t,0,e)},e.prototype.dequeue=function(){return this.data.pop()},e.prototype.peek=function(){return this.data[this.data.length-1]},e.prototype.clear=function(){this.data.length=0},e}()},{}],4:[function(e,t,n){t.exports=function(){function e(e){var t,n,i,r,a,o,s,l;for(this.comparator=(null!=e?e.comparator:void 0)||function(e,t){return e-t},this.pageSize=(null!=e?e.pageSize:void 0)||512,this.length=0,s=0;1<a;0<=a?++n:--n)t.push(null);if(this._memory=[],this._mask=this.pageSize-1,e.initialValues)for(i=0,r=(o=e.initialValues).length;i0&&(this._write(1,t),this._bubbleDown(1,t)),e},e.prototype.peek=function(){return this._read(1)},e.prototype.clear=function(){this.length=0,this._memory.length=0},e.prototype._write=function(e,t){var n;for(n=e>>this._shift;n>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[n][e&this._mask]=t},e.prototype._read=function(e){return this._memory[e>>this._shift][e&this._mask]},e.prototype._bubbleUp=function(e,t){var n,i,r,a;for(n=this.comparator;e>1&&(i=e&this._mask,e3?r=e&~this._mask|i>>1:i<2?(r=e-this.pageSize>>this._shift,r+=r&~(this._mask>>1),r|=this.pageSize>>1):r=e-2,!(n(a=this._read(r),t)<0));)this._write(r,t),this._write(e,a),e=r},e.prototype._bubbleDown=function(e,t){var n,i,r,a,o;for(o=this.comparator;ethis._mask&&!(e&this._mask-1)?n=i=e+2:e&this.pageSize>>1?(n=(e&~this._mask)>>1,i=(n=(n|=e&this._mask>>1)+1<0)for(e=t=1,n=this.data.length;1<=n?tn;e=1<=n?++t:--t)this._bubbleUp(e)},e.prototype.queue=function(e){this.data.push(e),this._bubbleUp(this.data.length-1)},e.prototype.dequeue=function(){var e,t;return t=this.data[0],e=this.data.pop(),this.data.length>0&&(this.data[0]=e,this._bubbleDown(0)),t},e.prototype.peek=function(){return this.data[0]},e.prototype.clear=function(){this.length=0,this.data.length=0},e.prototype._bubbleUp=function(e){for(var t,n;e>0&&(t=e-1>>>1,this.comparator(this.data[e],this.data[t])<0);)n=this.data[t],this.data[t]=this.data[e],this.data[e]=n,e=t},e.prototype._bubbleDown=function(e){var t,n,i,r,a;for(t=this.data.length-1;r=(n=1+(e<<1))+1,i=e,n<=t&&this.comparator(this.data[n],this.data[i])<0&&(i=n),r<=t&&this.comparator(this.data[r],this.data[i])<0&&(i=r),i!==e;)a=this.data[i],this.data[i]=this.data[e],this.data[e]=a,e=i},e}()},{}]},{},[1])(1)})),fS.prototype.constructor=fS,fS.prototype.initDefaultProviders=function(){this.addProtocolProvider("tile",RE),this.addProtocolProvider("3d-tiles",AS),this.addProtocolProvider("pointcloud",hS)},fS.prototype.runCommand=function(e,t,n){var i=this,r=this.getProtocolProvider(e.layer.protocol);if(!r)throw new Error("No known provider for layer ".concat(e.layer.id));t.execute(e,r,n).then((function(){if(e.view.notifyChange(e.requester,e.redraw),t.counters.executing0&&(r+=o.priority,o.accumulator+=o.priority,(!t||o.accumulator>n)&&(t=o,n=o.accumulator))}}catch(e){a.e(e)}finally{a.f()}if(t)return t.accumulator-=r,t.q}(e.storages);t&&t.length>0;){var n=t.dequeue();if(!n.earlyDropFunction||!n.earlyDropFunction(n))return n;e.counters.pending--,e.counters.cancelled++,n.reject(new DE(n))}};var mS=new ut;function vS(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=e.mainLoop.gfxEngine.getWindowSize();n=n||new tt(Math.floor(r.x/2),Math.floor(r.y/2));var a=t.level0Nodes.map((function(e){return mM.push(e,mM.MODES.ID)})),o=pS(e,t.object3d,t.threejsLayer),s=e.mainLoop.gfxEngine.renderViewToBuffer({camera:e.camera,scene:t.object3d},{x:n.x-i,y:n.y-i,width:1+2*i,height:1+2*i});o(),a.forEach((function(e){return e()}));var l=[];return gS(i,(function(e,t){var n=4*(2*t*i+e),r=s.slice(n,n+4||void 0);mS.fromArray(r).divideScalar(255);var a=CM(mS,Math.pow(256,3)),o=Math.round(a);l.includes(o)||l.push(o)})),l}function gS(e,t){for(var n,i=0;i<=e;i++){for(var r=i*i,a=-i;a<=i;a++)for(var o=a*a,s=-i;s<=i;s++){var l=o+s*s;if(!(l>r)&&(!(l<=n)&&!1===t(a,s)))return}n=r}}function yS(e){return e.layer?e.layer:e.parent?yS(e.parent):void 0}var wS,xS=new Nc,bS=function(e,t,n,i){var r,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=vS(e,i,t,n),s=function(e){o.includes(e.id)&&e.isTileMesh&&a.push({object:e,layer:i})},l=S(i.level0Nodes);try{for(l.s();!(r=l.n()).done;){var A=r.value;A.traverse(s)}}catch(e){l.e(e)}finally{l.f()}return a},MS=function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],a=arguments.length>5?arguments[5]:void 0;if(void 0!==a?xS.layers.set(a):xS.layers.enableAll(),n<0){var o=e.viewToNormalizedCoords(t);xS.setFromCamera(o,e.camera.camera3D);var s,l=xS.intersectObject(i,!0),A=S(l);try{for(A.s();!(s=A.n()).done;){var c=s.value;c.layer=yS(c.object),r.push(c)}}catch(e){A.e(e)}finally{A.f()}return r}var h={x:t.x-n,y:t.y-n,width:1+2*n,height:1+2*n},u=e.mainLoop.gfxEngine.renderViewToBuffer({scene:i,camera:e.camera},h),d=new Fn;e.mainLoop.gfxEngine.renderer.getClearColor(d);var f=Math.round(255*d.r),p=Math.round(255*d.g),m=Math.round(255*d.b),v=e.viewToNormalizedCoords(t),g=v.clone();return gS(n,(function(t,a){var o=4*((a+n)*(2*n+1)+(t+n)),s=u[o],l=u[o+1],A=u[o+2];if(!(Math.abs(f-s)<=1&&Math.abs(p-l)<=1&&Math.abs(m-A)<=1)){g.setX(v.x+t/e.camera.width).setY(v.y+a/e.camera.height),xS.setFromCamera(g,e.camera.camera3D);var c,h=S(xS.intersectObject(i,!0));try{for(h.s();!(c=h.n()).done;){var d=c.value;d.layer=yS(d.object),r.push(d)}}catch(e){h.e(e)}finally{h.f()}return 0==r.length}})),r},CS=0,BS=1,ES=2,SS=3,TS=4,_S=[1,3,7,60],IS=function(){function e(){s(this,e),this.state=CS,this.lastErrorTimestamp=0,this.errorCount=0,this.failureParams={lowestLevelError:1/0}}return A(e,[{key:"canTryUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();switch(this.state){case CS:return!0;case SS:case BS:case TS:return!1;default:var t=1e3*this.secondsUntilNextTry();return t<=e-this.lastErrorTimestamp}}},{key:"secondsUntilNextTry",value:function(){if(this.state!==ES)return 0;var e=Math.max(0,Math.min(this.errorCount,_S.length)-1);return _S[e]}},{key:"newTry",value:function(){this.state=BS}},{key:"success",value:function(){this.lastErrorTimestamp=0,this.state=CS}},{key:"noMoreUpdatePossible",value:function(){this.state=TS}},{key:"noData",value:function(e){this.state=CS,this.failureParams.lowestLevelError=Math.min(e.targetLevel,this.failureParams.lowestLevelError)}},{key:"failure",value:function(e,t,n){n&&null!=n.targetLevel&&(this.failureParams.lowestLevelError=Math.min(n.targetLevel,this.failureParams.lowestLevelError)),this.lastErrorTimestamp=e,this.state=t?SS:ES,this.errorCount++}},{key:"inError",value:function(){return this.state==SS||this.state==ES}}]),e}(),LS={cleanup:function(e){if(e.layer=null,"function"==typeof e.dispose)e.dispose();else if(e.geometry&&e.geometry.dispose(),e.material)if(Array.isArray(e.material)){var t,n=S(e.material);try{for(n.s();!(t=n.n()).done;){t.value.dispose()}}catch(e){n.e(e)}finally{n.f()}}else e.material.dispose()},removeChildren:function(e,t){var n=t.children.filter((function(t){return(t.layer&&t.layer.id)===e.id}));return t.remove.apply(t,C(n)),n},removeChildrenAndCleanup:function(e,t){var n=t.children.filter((function(t){return(t.layer&&t.layer.id)===e.id}));return t.remove.apply(t,C(n)),t.layer===e&&this.cleanup(t),n},removeChildrenAndCleanupRecursively:function(e,t){var n,i=t.children.filter((function(t){return(t.layer&&t.layer.id)===e.id})),r=S(i);try{for(r.s();!(n=r.n()).done;){var a=n.value;this.removeChildrenAndCleanupRecursively(e,a)}}catch(e){r.e(e)}finally{r.f()}return t.remove.apply(t,C(i)),t.layer&&t.layer.id===e.id&&this.cleanup(t),i}},FS=new ob("EPSG:4326"),kS="";kS=void 0!==document.documentElement.style.transform?"transform":void 0!==document.documentElement.style.webkitTransform?"webkitTransform":void 0!==document.documentElement.style.mozTransform?"mozTransform":void 0!==document.documentElement.style.oTransform?"oTransform":"transform";var PS=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(s(this,n),null==r)throw new Error("coordinates are mandatory to add a Label");var l=(e=t.call(this)).visible;return Object.defineProperty(v(e),"visible",{set:function(e){e!=l&&(l=e,this.content.style.display=e?"block":"none")},get:function(){return l}}),e.isLabel=!0,e.coordinates=r,e.projectedPosition={x:0,y:0},e.boundaries={left:0,right:0,top:0,bottom:0},e.content=document.createElement("div"),e.content.classList.add("itowns-label"),e.content.style.userSelect="none",e.content.style.position="absolute","string"==typeof i?e.content.textContent=i:e.content.appendChild(i),e.baseContent=i,a.isStyle?(e.anchor=a.getTextAnchorPosition(),a.text.haloWidth>0&&e.content.classList.add("itowns-stroke-single"),a.applyToHTML(e.content,o)):e.anchor=[0,0],e.zoom={min:a.zoom&&null!=a.zoom.min?a.zoom.min:2,max:a.zoom&&null!=a.zoom.max?a.zoom.max:24},e.order=a.order||0,e.padding=2,e}return A(n,[{key:"updateProjectedPosition",value:function(e,t){var n=Math.round(e),i=Math.round(t);n==this.projectedPosition.x&&i==this.projectedPosition.y||(this.projectedPosition.x=n,this.projectedPosition.y=i,this.boundaries.left=e+this.offset.left-this.padding,this.boundaries.right=e+this.offset.right+this.padding,this.boundaries.top=t+this.offset.top-this.padding,this.boundaries.bottom=t+this.offset.bottom+this.padding)}},{key:"updateCSSPosition",value:function(){this.content.style[kS]="translate(".concat(this.boundaries.left+this.padding,"px, ").concat(this.boundaries.top+this.padding,"px)")}},{key:"initDimensions",value:function(){if(!this.offset){wS=this.content.getBoundingClientRect();var e=Math.round(wS.width),t=Math.round(wS.height);this.offset={left:e*this.anchor[0],top:t*this.anchor[1]},this.offset.right=this.offset.left+e,this.offset.bottom=this.offset.top+t}}},{key:"update3dPosition",value:function(e){this.coordinates.as(e,FS),FS.toVector3(this.position),this.parent.worldToLocal(this.position),this.updateMatrixWorld()}},{key:"updateElevationFromLayer",value:function(e){var t=Sb.getElevationValueAt(e,this.coordinates,Sb.FAST_READ_Z);if(t&&t!=this.coordinates.z)return this.coordinates.z=t,this.updateHorizonCullingPoint(),!0}},{key:"updateHorizonCullingPoint",value:function(){this.horizonCullingPoint&&this.getWorldPosition(this.horizonCullingPoint)}}]),n}(zt),US=new ob("EPSG:4326",0,0,0),DS=new bb("EPSG:4326",0,0,0,0),RS=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,e,r)).isLabelLayer=!0,i.domElement=document.createElement("div"),i.domElement.id="itowns-label-".concat(i.id),i.defineLayerProperty("visible",!0,(function(){i.domElement.style.display=i.visible?"block":"none"})),i.buildExtent=!0,i}return A(n,[{key:"convert",value:function(e,t){var n=this,i=[],r=this.style&&this.style.text&&this.style.text.field;t.as(e.crs,DS),US.crs=e.crs;var a={zoom:t.zoom};return e.features.forEach((function(t){if(t.type===pC.POINT){var o=t.style&&t.style.text.field;t.geometries.forEach((function(s){if(US.setFromArray(t.vertices,s.size*s.indices[0].offset),e.transformCoordinates(US),2==t.size&&(US.z=0),DS.isPointInside(US)){var l,A=s.properties.style&&s.properties.style.text.field,c={globals:a,properties:function(){return s.properties}};if(A||o||r)A?l=s.properties.style.getTextFromProperties(c):o?l=t.style.getTextFromProperties(c):r&&(l=n.style.getTextFromProperties(c));else if(!(s.properties.style&&s.properties.style.icon||t.style&&t.style.icon||n.style&&n.style.icon))return;var h=(s.properties.style||t.style||n.style).symbolStylefromContext(c),u=new PS(l,US.clone(),h,n.source.sprites);u.layerId=n.id,2==t.size&&(u.needsAltitude=!0),i.push(u)}}))}})),i}},{key:"preUpdate",value:function(){}},{key:"update",value:function(e,t,n,i){var r=this;if(i||!n.children.length){if(!this.frozen&&n.visible&&this.visible){var a=n.getExtentsByProjection(this.source.crs)||[n.extent],o=a[0].zoom;if(!(ot.zoom.max)){void 0===n.layerUpdateState[this.id]&&(n.layerUpdateState[this.id]=new IS);var s=n.material.getElevationLayer();if(s&&n.layerUpdateState[s.id].canTryUpdate()&&n.children.forEach((function(t){t.isLabel&&t.needsAltitude&&t.updateElevationFromLayer(r.parent)&&t.update3dPosition(e.view.referenceCrs)})),n.layerUpdateState[this.id].canTryUpdate()){if(this.source.extentInsideLimit(n.extent,o)){n.layerUpdateState[this.id].newTry();var l={layer:this,extentsSource:a,view:e.view,threejsLayer:this.threejsLayer,requester:n};return e.scheduler.execute(l).then((function(t){if(t){var i=e.view.mainLoop.gfxEngine.label2dRenderer,a=[];if(t.forEach((function(t){n.parent?t.forEach((function(t){t.needsAltitude&&t.updateElevationFromLayer(r.parent),n.children.find((function(e){return e.isLabel&&e.baseContent==t.baseContent}))||(n.add(t),t.update3dPosition(e.view.referenceCrs),n.level<4&&(t.horizonCullingPoint=new at,t.updateHorizonCullingPoint()),a.push(t.content))})):t.forEach((function(e){LS.removeChildrenAndCleanupRecursively(r,e),i.removeLabelDOM(e)}))})),a.length>0){var o,s=n.domElements[r.id];s||(s={dom:document.createElement("div"),visible:!0},n.domElements[r.id]=s),(o=s.dom).append.apply(o,a);var l=n.findClosestDomElement(r.id);(l&&l.dom||r.domElement).appendChild(s.dom),s.visible=!0,t.forEach((function(e){return e.forEach((function(e){return e.initDimensions()}))})),t.forEach((function(e){return e.forEach((function(e){e.visible=!1}))})),n.children.sort((function(e){return e.isLabel?-e.order:1})),n.addEventListener("removed",(function(){t.forEach((function(e){return e.forEach((function(e){return n.remove(e)}))})),r.removeNodeDomElement(n)}))}n.layerUpdateState[r.id].noMoreUpdatePossible()}}))}n.layerUpdateState[this.id].noMoreUpdatePossible()}}}}else LS.removeChildrenAndCleanupRecursively(this,n)}},{key:"removeLabelsFromNodeRecursive",value:function(e){var t=this;e.children.forEach((function(n){n.isLabel&&n.layerId===t.id?e.remove(n):n.isTileMesh&&t.removeLabelsFromNodeRecursive(n)})),this.removeNodeDomElement(e)}},{key:"removeNodeDomElement",value:function(e){if(e.domElements[this.id]){var t=e.domElements[this.id].dom;t.parentElement.removeChild(t),delete e.domElements[this.id]}}},{key:"delete",value:function(){var e=this;this.domElement.parentElement.removeChild(this.domElement),this.parent.level0Nodes.forEach((function(t){return e.removeLabelsFromNodeRecursive(t)}))}}]),n}(uE),OS="layers-initialized",NS="layer-removed",zS="layer-added",QS="initialized",GS="camera-moved",HS=function(e,t){e.object3d&&(e.object3d.visible=e.visible),e.threejsLayer&&(e.visible?t.camera.camera3D.layers.enable(e.threejsLayer):t.camera.camera3D.layers.disable(e.threejsLayer))};var VS,jS=new tt,WS=new bt,XS=new tt,YS=new dn,KS=new at,ZS=new at,JS=new ob("EPSG:4326"),qS=[],$S=function(e){h(n,e);var t=y(n);function n(e,i){var r,a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(s(this,n),!i)throw new Error("Invalid viewerDiv parameter (must non be null/undefined)");(r=t.call(this)).domElement=i,r.referenceCrs=e,JS.crs=e,a=o.renderer&&o.renderer.domElement?new ME(o.renderer):new ME(i,o.renderer),r.engine=a,r.mainLoop=o.mainLoop||new qb(new fS,a),r.scene=o.scene3D||new Qt,o.scene3D||(r.scene.autoUpdate=!1),r.camera=new Gb(r.referenceCrs,r.mainLoop.gfxEngine.getWindowSize().x,r.mainLoop.gfxEngine.getWindowSize().y,o.camera),r._frameRequesters={},r._layers=[],window.addEventListener("resize",(function(){return r.resize()}),!1),r._changeSources=new Set,__DEBUG__&&(r.isDebugMode=!0),r._delayedFrameRequesterRemoval=[],r._allLayersAreReadyCallback=function(){r.getLayers().every((function(e){return e.ready}))&&0==r.mainLoop.scheduler.commandsWaitingExecutionCount()&&0==r.mainLoop.renderingState&&(r.dispatchEvent({type:OS}),r.removeFrameRequester(Jb,r._allLayersAreReadyCallback))},r.camera.resize(r.domElement.clientWidth,r.domElement.clientHeight);var l=function e(){r.removeEventListener(OS,e),r.dispatchEvent({type:QS})};return r.addEventListener(OS,l),r._fullSizeDepthBuffer=new Uint8Array(4*r.camera.width*r.camera.height),r._pixelDepthBuffer=new Uint8Array(4),r.domElement.tabIndex=-1,r.domElement.focus(),qS.push(v(r)),r}return A(n,[{key:"dispose",value:function(){var e=qS.indexOf(this);if(-1!=e){this.controls&&this.controls.dispose&&this.controls.dispose(),this.removeAllFrameRequesters(),this.removeAllEvents();var t,n=S(this.getLayers((function(e){return!e.isTiledGeometryLayer&&!e.isAtmosphere})));try{for(n.s();!(t=n.n()).done;){var i=t.value;this.removeLayer(i.id)}}catch(e){n.e(e)}finally{n.f()}var r,a=S(this.getLayers((function(e){return e.isAtmosphere})));try{for(a.s();!(r=a.n()).done;){var o=r.value;this.removeLayer(o.id)}}catch(e){a.e(e)}finally{a.f()}var s,l=S(this.getLayers((function(e){return e.isTiledGeometryLayer})));try{for(l.s();!(s=l.n()).done;){var A=s.value;this.removeLayer(A.id)}}catch(e){l.e(e)}finally{l.f()}qS.splice(e,1),this.mainLoop.dispose()}else console.warn("View already disposed")}},{key:"addLayer",value:function(e,t){var n=this;if(!e||!e.isLayer)return Promise.reject(new Error("Add Layer type object"));if(this.getLayerById(e.id))return e._reject(new Error("Invalid id '".concat(e.id,"': id already used")));if(e=function(e,t,n){var i=t.source;if(n&&!t.extent&&(t.extent=n.extent,i&&!i.extent&&(i.extent=n.extent)),t.isGeometryLayer?(n&&(t.threejsLayer=e.mainLoop.gfxEngine.getUniqueThreejsLayer()),t.defineLayerProperty("visible",!0,(function(){return HS(t,e)})),HS(t,e),t.crs=e.referenceCrs):t.crs||(n&&n.tileMatrixSets&&n.tileMatrixSets.includes(Jx.formatToTms(i.crs))?t.crs=i.crs:t.crs=n&&n.extent.crs),t.isLabelLayer)e.mainLoop.gfxEngine.label2dRenderer.registerLayer(t);else if(t.labelEnabled||t.addLabelLayer){t.labelEnabled&&console.info("layer.labelEnabled is deprecated use addLabelLayer, instead of"),t.buildExtent=!0;var r=new RS("".concat(t.id,"-label"),{source:i,style:t.style,zoom:t.zoom,crs:i.crs,visible:t.visible});t.addEventListener("visible-property-changed",(function(){r.visible=t.visible})),e.addEventListener(NS,(function n(i){i.layerId===t.id&&e.removeLayer(r.id),e.removeEventListener(NS,n)})),t.whenReady=t.whenReady.then((function(){return e.addLayer(r),t}))}return t}(this,e,t),t)if(e.isColorLayer){var i=this.getLayers((function(e){return e.isColorLayer}));if(e.sequence=i.length,!(t.countColorLayersTextures.apply(t,C(i).concat([e]))<=BM()))return e._reject(new Error("Cant add color layer ".concat(e.id,": the maximum layer is reached")));t.attach(e)}else e.isElevationLayer&&"image/x-bil;bits=32"==e.source.format?(e.source.networkOptions.isWebGL2=this.mainLoop.gfxEngine.renderer.capabilities.isWebGL2,t.attach(e)):t.attach(e);else{if("function"!=typeof e.update)return e._reject(new Error("Cant add GeometryLayer: missing a update function"));if("function"!=typeof e.preUpdate)return e._reject(new Error("Cant add GeometryLayer: missing a preUpdate function"));this._layers.push(e)}return e.object3d&&!e.object3d.parent&&e.object3d!==this.scene&&this.scene.add(e.object3d),Promise.all(e._promises).then((function(){e._resolve(),n.notifyChange(t||e,!1),n._frameRequesters[Jb]&&n._frameRequesters[Jb].includes(n._allLayersAreReadyCallback)||n.addFrameRequester(Jb,n._allLayersAreReadyCallback),n.dispatchEvent({type:zS,layerId:e.id})}),e._reject),e.whenReady}},{key:"removeLayer",value:function(e){var t=this.getLayerById(e);if(t){var n=t.parent;if(t.delete(),n&&!n.detach(t))throw new Error("Error to detach ".concat(e," from ").concat(n.id));if(null==n&&this._layers.splice(this._layers.findIndex((function(t){return t.id==e})),1),t.isColorLayer){var i,r=S(this.getLayers((function(e){return e.isColorLayer})));try{for(r.s();!(i=r.n()).done;){var a=i.value;a.sequence>t.sequence&&a.sequence--}}catch(e){r.e(e)}finally{r.f()}}var o,s=0,l=S(qS);try{for(l.s();!(o=l.n()).done;){s+=o.value.getLayers((function(e){return e.source.uid==t.source.uid&&e.crs==t.crs})).length}}catch(e){l.e(e)}finally{l.f()}return t.source.onLayerRemoved({unusedCrs:0==s?t.crs:void 0}),this.notifyChange(this.camera),this.dispatchEvent({type:NS,layerId:e}),!0}throw new Error("".concat(e," doesn't exist"))}},{key:"notifyChange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&(this._changeSources.add(e),(e.isTileMesh||e.isCamera)&&(this._fullSizeDepthBuffer.needsUpdate=!0)),this.mainLoop.scheduleViewUpdate(this,t)}},{key:"getLayers",value:function(e){var t,n=[],i=S(this._layers);try{for(i.s();!(t=i.n()).done;){var r=t.value;if(e&&!e(r)||n.push(r),r.attachedLayers){var a,o=S(r.attachedLayers);try{for(o.s();!(a=o.n()).done;){var s=a.value;e&&!e(s,r)||n.push(s)}}catch(e){o.e(e)}finally{o.f()}}}}catch(e){i.e(e)}finally{i.f()}return n}},{key:"getLayerById",value:function(e){return this.getLayers((function(t){return t.id===e}))[0]}},{key:"addFrameRequester",value:function(e,t){if("function"!=typeof t)throw new Error("frameRequester must be a function");this._frameRequesters[e]?this._frameRequesters[e].push(t):this._frameRequesters[e]=[t]}},{key:"removeFrameRequester",value:function(e,t){this._frameRequesters[e].includes(t)?this._delayedFrameRequesterRemoval.push({when:e,frameRequester:t}):console.error("Invalid call to removeFrameRequester: frameRequester isn't registered")}},{key:"removeAllFrameRequesters",value:function(){for(var e in this._frameRequesters)if(Object.prototype.hasOwnProperty.call(this._frameRequesters,e)){var t,n=S(this._frameRequesters[e]);try{for(n.s();!(t=n.n()).done;){var i=t.value;this.removeFrameRequester(e,i)}}catch(e){n.e(e)}finally{n.f()}}this._executeFrameRequestersRemovals()}},{key:"removeAllEvents",value:function(){if(void 0!==this._listeners){for(var e in this._listeners)Object.prototype.hasOwnProperty.call(this._listeners,e)&&delete this._listeners[e];this._listeners=void 0}}},{key:"_executeFrameRequestersRemovals",value:function(){var e,t=S(this._delayedFrameRequesterRemoval);try{for(t.s();!(e=t.n()).done;){var n=e.value,i=this._frameRequesters[n.when].indexOf(n.frameRequester);i>=0?this._frameRequesters[n.when].splice(i,1):console.warn("FrameReq has already been removed")}}catch(e){t.e(e)}finally{t.f()}this._delayedFrameRequesterRemoval.length=0}},{key:"execFrameRequesters",value:function(e,t,n){if(this._frameRequesters[e]){this._delayedFrameRequesterRemoval.length>0&&this._executeFrameRequestersRemovals();for(var i=arguments.length,r=new Array(i>3?i-3:0),a=3;a1&&void 0!==arguments[1]?arguments[1]:jS,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=this.domElement.getBoundingClientRect();if(void 0!==e.touches&&e.touches.length)return t.set(e.touches[n].clientX-i.x,e.touches[n].clientY-i.y);var r=e.target.getBoundingClientRect();return t.set(r.x+e.offsetX-i.x,r.y+e.offsetY-i.y)}},{key:"eventToNormalizedCoords",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.viewToNormalizedCoords(this.eventToViewCoords(e,jS,t))}},{key:"viewToNormalizedCoords",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jS;return t.x=e.x/this.camera.width*2-1,t.y=e.y/this.camera.height*-2+1,t}},{key:"normalizedToViewCoords",value:function(e){return jS.x=.5*(e.x+1)*this.camera.width,jS.y=-.5*(e.y-1)*this.camera.height,jS}},{key:"pickObjectsAt",value:function(e){for(var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length,r=new Array(i>2?i-2:0),a=2;a0&&void 0!==arguments[0]?arguments[0]:.28;return this.getScaleFromDistance(e,this.getDistanceFromCamera())}},{key:"getScaleFromDistance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.28,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;e/=1e3;var n=Hh.degToRad(this.camera.camera3D.fov),i=this.camera.height/(2*t*Math.tan(.5*n));return e*i}},{key:"getDistanceFromCamera",value:function(e){return this.getPickingPositionFromDepth(e,ZS),this.camera.camera3D.position.distanceTo(ZS)}},{key:"getPixelsToMeters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;return this.camera.camera3D.isOrthographicCamera?e*(VS=(this.camera.camera3D.right-this.camera.camera3D.left)/this.camera.camera3D.zoom)/this.camera.width:this.getPixelsToMetersFromDistance(e,this.getDistanceFromCamera(t))}},{key:"getPixelsToMetersFromDistance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e*t/this.camera._preSSE}},{key:"getMetersToPixels",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;return this.camera.camera3D.isOrthographicCamera?(VS=(this.camera.camera3D.right-this.camera.camera3D.left)/this.camera.camera3D.zoom,e*this.camera.width/VS):this.getMetersToPixelsFromDistance(e,this.getDistanceFromCamera(t))}},{key:"getMetersToPixelsFromDistance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.camera._preSSE*e/t}},{key:"pickFeaturesAt",value:function(e){for(var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,i=arguments.length,r=new Array(i>2?i-2:0),a=2;a0&&A.forEach((function(e){return s[e.layer.id].push(e)})),0==o.length)return s;this.getPickingPositionFromDepth(l,ZS);var c,h=this.camera.camera3D.position.distanceTo(ZS);JS.setFromVector3(ZS);var u={M:this.getPixelsToMetersFromDistance(n,h),D:.001*n};this.isPlanarView?u.D=u.M:this.getPixelsToDegrees&&(u.D=this.getMetersToDegrees(u.M));var d,f=bS(this,l,n,this.tileLayer),p=S(f);try{for(p.s();!(d=p.n()).done;){var m=d.value;if(m.object.material){var v,g=S(m.object.material.getLayers(o));try{for(g.s();!(v=g.n()).done;){var y,w=v.value,x=S(w.textures);try{for(x.s();!(y=x.n()).done;){var b=y.value;b.features&&(c=Jx.isMetricUnit(b.features.crs)?u.M:u.D,s[w.id]=s[w.id].concat(TE(JS,b.features,c)))}}catch(e){x.e(e)}finally{x.f()}}}catch(e){g.e(e)}finally{g.f()}}}}catch(e){p.e(e)}finally{p.f()}return s}},{key:"readDepthBuffer",value:function(e,t,n,i,r){var a=this.mainLoop.gfxEngine,o=this.tileLayer.wireframe,s=this.tileLayer.opacity,l=this.tileLayer.visible;o&&(this.tileLayer.wireframe=!1),s<1&&(this.tileLayer.opacity=1),l||(this.tileLayer.visible=!0);var A=this.tileLayer.level0Nodes.map((function(e){return mM.push(e,mM.MODES.DEPTH)}));return r=a.renderViewToBuffer({camera:this.camera,scene:this.tileLayer.object3d},{x:e,y:t,width:n,height:i,buffer:r}),A.forEach((function(e){return e()})),this.tileLayer.wireframe!==o&&(this.tileLayer.wireframe=o),this.tileLayer.opacity!==s&&(this.tileLayer.opacity=s),this.tileLayer.visible!==l&&(this.tileLayer.visible=l),r}},{key:"getPickingPositionFromDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at;if(this.tileLayer&&0!=this.tileLayer.level0Nodes.length&&this.tileLayer.level0Nodes[0]){var n=this.mainLoop,i=0==n.scheduler.commandsWaitingExecutionCount()&&0==n.renderingState,r=n.gfxEngine,a=r.getWindowSize(),o=this.camera.camera3D;(e=e||a.clone().multiplyScalar(.5)).x=Math.floor(e.x),e.y=Math.floor(e.y);var s,l=o.layers.mask;if(o.layers.mask=1<1e7))return t}else t=void 0}},{key:"pickCoordinates",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ob(this.tileLayer.extent.crs);return e instanceof Event?this.eventToViewCoords(e):e&&void 0!==e.x&&void 0!==e.y?jS.copy(e):jS.set(this.mainLoop.gfxEngine.width/2,this.mainLoop.gfxEngine.height/2),this.getPickingPositionFromDepth(jS,ZS),JS.crs=this.referenceCrs,JS.setFromVector3(ZS),JS.as(t.crs,t),t}},{key:"resize",value:function(e,t){null==e&&(e=this.domElement.clientWidth),null==t&&(t=this.domElement.clientHeight),this._fullSizeDepthBuffer=new Uint8Array(4*e*t),this.mainLoop.gfxEngine.onWindowResize(e,t),this.camera.resize(e,t),this.notifyChange(this.camera.camera3D)}}]),n}(Je),eT=1e3/60,tT=0,nT=1,iT=2,rT=function(e){e.id&&(clearInterval(e.id),e.id=void 0),e.waitTimer&&(clearInterval(e.waitTimer),e.waitTimer=void 0),e.keyframe=0},aT=function(e){rT(e),e.isEnded()&&e.dispatchEvent({type:"animation-ended"}),e.dispatchEvent({type:"animation-stopped"}),e.duration=0},oT=function(e){h(n,e);var t=y(n);function n(){var e;return s(this,n),(e=t.call(this)).id=null,e.keyframe=0,e.duration=0,e.state=tT,e.waitTimer=null,e}return A(n,[{key:"isPlaying",value:function(){return this.state===nT}},{key:"isStopped",value:function(){return this.state===tT}},{key:"isEnded",value:function(){return this.state===iT}},{key:"play",value:function(e){this.duration=e,this.dispatchEvent({type:"animation-started"}),this.state=nT,rT(this),this.id=setInterval(this.frame.bind(this),eT)}},{key:"playLater",value:function(e,t){var n=Math.floor(eT*t);window.clearInterval(this.waitTimer);var i=this;this.waitTimer=window.setTimeout((function(){i.play(e)}),n)}},{key:"stop",value:function(){this.state=tT,aT(this)}},{key:"frame",value:function(){this.keyframeMath.pow(2,32))throw new Error("Tile segments count is too big");var o=r*r*2+(e.disableSkirt?0:4*r*2);t.position=new Float32Array(3*a),t.normal=new Float32Array(3*a);var s=e.builder.uvCount;s>1&&(t.uvs[1]=new Float32Array(a)),n[0]=function(){},e.buildIndexAndUv_0&&(a1&&function(){var r=i.computeUvs[1](e);n[1]=function(e){t.uvs[1][e]=r}}();for(var v=0;v<=l;v++){var g=v/l,y=3*c;i.uProjecte(g,e);var w=i.vertexPosition(e,e.projected),x=i.vertexNormal(e);w.sub(e.center),e.quatNormalToZ&&(w.applyQuaternion(e.quatNormalToZ),x.applyQuaternion(e.quatNormalToZ)),w.toArray(t.position,y),x.toArray(t.normal,y);var b,M=S(n);try{for(M.s();!(b=M.n()).done;){(0,b.value)(c,g,m)}}catch(e){M.e(e)}finally{M.f()}e.disableSkirt||0!==f&&f!==A&&(v===l?u.push(c):0===v&&d.push(c)),p.push(c),c++}h.push(p),0===f?u=u.concat(p):f===A&&(u=u.concat(p.slice().reverse()))}function C(e,n,i,r){return t.index[r+0]=e,t.index[r+1]=n,t.index[r+2]=i,r+3}e.disableSkirt||(u=u.concat(d.reverse()));var B=0;if(e.buildIndexAndUv_0)for(var E=0;E1&&(t.uvs[1][c]=t.uvs[1][O]);var Q=(R+1)%u.length;B=U(B,O,c,0===Q?k:c+1,u[Q]),c++}}return t}function lT(e){e.buildIndexAndUv_0=!0,e.center=e.builder.center(e.extent).clone();var t=sT(e);t.index=new zn(t.index,1),t.uvs[0]=new zn(t.uvs[0],2),t.position=new zn(t.position,3),t.normal=new zn(t.normal,3);for(var n=1;n1&&void 0!==arguments[1]?arguments[1]:lT(e);s(this,n),(i=t.call(this)).center=e.center,i.extent=e.extent,i.setIndex(r.index),i.setAttribute("position",r.position),i.setAttribute("normal",r.normal);for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:{};s(this,e),this.tmp={coords:[new ob("EPSG:4326",0,0),new ob("EPSG:4326",0,0)],position:new at,dimension:new tt},this.crs=t.crs,this.uvCount=t.uvCount,this.computeUvs=[function(){},function(e){var t=vT(e.projected.latitude)*e.nbRow;return(isFinite(t)?t:0)-e.deltaUV1}]}return A(e,[{key:"prepare",value:function(e){e.nbRow=Math.pow(2,e.level+1);var t=vT(e.extent.south);isFinite(t)||(t=0);var n=t%(1/e.nbRow);e.deltaUV1=(t-n)*e.nbRow,e.quatNormalToZ=mT.setFromAxisAngle(dT,-(.5*Math.PI-Hh.degToRad(e.extent.center().latitude))),e.projected={longitude:0,latitude:0},e.extent.dimensions(this.tmp.dimension)}},{key:"center",value:function(e){return e.center(this.tmp.coords[0]).as(this.crs,this.tmp.coords[1]).toVector3()}},{key:"vertexPosition",value:function(e){return this.tmp.coords[0].setFromValues(e.projected.longitude,e.projected.latitude),this.tmp.coords[0].as(this.crs,this.tmp.coords[1]).toVector3(this.tmp.position),this.tmp.position}},{key:"vertexNormal",value:function(){return this.tmp.coords[1].geodesicNormal}},{key:"uProjecte",value:function(e,t){t.projected.longitude=t.extent.west+e*this.tmp.dimension.x}},{key:"vProjecte",value:function(e,t){t.projected.latitude=t.extent.south+e*this.tmp.dimension.y}},{key:"computeSharableExtent",value:function(e){var t=Math.abs(e.west-e.east)/2,n=new bb(e.crs,-t,t,e.south,e.north),i=Hh.degToRad(e.west-n.west),r=Hh.degToRad(90-e.center(this.tmp.coords[0]).latitude);return fT.setFromAxisAngle(uT,i),pT.setFromAxisAngle(dT,r),fT.multiply(pT),{sharableExtent:n,quaternion:fT.clone(),position:this.center(e)}}}]),e}(),xT=new wT({crs:"EPSG:4978",uvCount:1}),bT=new at,MT=new tt,CT=new at,BT=new ob("EPSG:4326",0,0,0),ET=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new at(1/0,1/0,1/0),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at(-1/0,-1/0,-1/0);return s(this,n),zt.DefaultUp.set(0,0,1),(e=t.call(this)).box3D=new tn(i.clone(),r.clone()),e.natBox=e.box3D.clone(),e.z={min:0,max:0,scale:1},g(e,v(e))}return A(n,[{key:"clone",value:function(){return(new n).copy(this)}},{key:"copy",value:function(e){return b(u(n.prototype),"copy",this).call(this,e),this.box3D.copy(e.box3D),this.natBox.copy(e.natBox),this.z.min=e.z.min,this.z.max=e.z.max,this.z.scale=e.z.scale,this}},{key:"update",value:function(){this.updateMatrixWorld(!0)}},{key:"updateZ",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.z.scale;this.z={min:e,max:t,scale:n,delta:Math.abs(t-e)*n},this.box3D.min.z=this.natBox.min.z+e*n,this.box3D.max.z=this.natBox.max.z+t*n}},{key:"updateScaleZ",value:function(e){e>0&&this.updateZ(this.z.min,this.z.max,e)}},{key:"isSphereAboveXYBox",value:function(e){var t=this.worldToLocal(e.center),n=Math.max(this.box3D.min.x,Math.min(t.x,this.box3D.max.x)),i=Math.max(this.box3D.min.y,Math.min(t.y,this.box3D.max.y));return Math.sqrt((n-t.x)*(n-t.x)+(i-t.y)*(i-t.y))1&&void 0!==arguments[1]?arguments[1]:e.min||0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.max||0;if("EPSG:4326"==e.crs){var r=xT.computeSharableExtent(e),a=r.sharableExtent,o=r.quaternion,s=r.position,l=Math.max(Math.floor(a.dimensions(MT).x/90+1),2),A={extent:a,level:0,segment:l,disableSkirt:!0,builder:xT},c=new AT(A);gT||(gT=new n),gT.box3D.copy(c.boundingBox),gT.natBox.copy(c.boundingBox),this.copy(gT),this.updateZ(t,i),this.position.copy(s),this.quaternion.copy(o),this.updateMatrixWorld(!0)}else{if(Jx.isTms(e.crs)||!Jx.isMetricUnit(e.crs))throw new Error("Unsupported extent crs");e.center(BT).toVector3(this.position),e.dimensions(MT),bT.set(MT.x,MT.y,Math.abs(i-t)),this.box3D.setFromCenterAndSize(CT,bT),this.updateMatrixWorld(!0)}return this}}]),n}(zt),ST=new at,TT=new ob("EPSG:4326",0,0,0),_T=new eb,IT=[],LT=new at;function FT(e){return e-360*Math.floor((e+180)/360)}function kT(e){return e.getLayers((function(e){return e.isTiledGeometryLayer}))[0]}var PT=function(e){h(n,e);var t=y(n);function n(){var e;return s(this,n),e=t.call(this),zt.DefaultUp.set(0,0,1),e.seaLevel=new zt,e.target=new zt,e.target.rotation.order="ZXY",e.camera=new Oi,e.add(e.seaLevel),e.seaLevel.add(e.target),e.target.add(e.camera),e.coord=new ob("EPSG:4978",0,0),e.targetWorldPosition=new at,e.removeAll=function(){},e._onChangeCallback=null,e}return A(n,[{key:"applyTransformToCamera",value:function(e,t){var n=this;this.proxy?(t.quaternion._onChange(this._onChangeCallback),this.camera.matrixWorld.decompose(this.proxy.position,t.quaternion,t.scale),t.quaternion._onChange((function(){return n.removeProxy(e,t)}))):this.camera.matrixWorld.decompose(t.position,t.quaternion,t.scale)}},{key:"setProxy",value:function(e,t){var n=this;!this.proxy&&e&&t&&(this.proxy={position:new at},Object.keys(t.position).forEach((function(i){return function(e,t,n,i){n.proxy.position[i]=t.position[i],Object.defineProperty(t.position,i,{get:function(){return n.proxy.position[i]},set:function(r){n.removeProxy(e,t),t.position[i]=r}})}(e,t,n,i)})),this._onChangeCallback=t.quaternion._onChangeCallback,t.quaternion._onChange((function(){return n.removeProxy(e,t)})))}},{key:"removeProxy",value:function(e,t){var n=this;this.stop(e),this.proxy&&e&&t&&(Object.keys(t.position).forEach((function(e){return Object.defineProperty(t.position,e,{value:n.proxy.position[e],writable:!0})})),t.quaternion._onChange(this._onChangeCallback),this.proxy=null)}},{key:"setTargetFromCoordinate",value:function(e,t){t.as(kT(e).extent.crs,this.coord);var n=Math.max(0,this.coord.z);this.coord.z=n,this.coord.as(e.referenceCrs).toVector3(ST),"EPSG:4978"==e.referenceCrs?(this.lookAt(ST),this.seaLevel.position.set(0,0,ST.length()-n)):(this.position.set(ST.x,ST.y,0),this.seaLevel.position.set(0,0,0)),this.target.position.set(0,0,n)}},{key:"setFromPositions",value:function(e,t){this.setTargetFromCoordinate(e,new ob(e.referenceCrs,ST)),this.target.rotation.set(0,0,0),this.updateMatrixWorld(!0),this.camera.position.copy(t),this.target.worldToLocal(this.camera.position);var n=this.camera.position.length();this.target.rotation.x=Math.asin(this.camera.position.z/n);var i=Hh.clamp(this.camera.position.y/(Math.cos(this.target.rotation.x)*n),-1,1);this.target.rotation.z=Math.sign(-this.camera.position.x)*Math.acos(i),this.camera.position.set(0,n,0)}},{key:"applyParams",value:function(e,t){t.coord&&this.setTargetFromCoordinate(e,t.coord),null!=t.tilt&&(this.target.rotation.x=Hh.degToRad(t.tilt)),null!=t.heading&&(this.target.rotation.z=Hh.degToRad(FT(t.heading+180))),t.range&&this.camera.position.set(0,t.range,0),this.camera.rotation.set(.5*-Math.PI,0,Math.PI),this.updateMatrixWorld(!0),this.targetWorldPosition.setFromMatrixPosition(this.seaLevel.matrixWorld)}},{key:"getParams",value:function(){return{coord:this.coord.clone(),tilt:this.tilt,heading:this.heading,range:this.range,targetWorldPosition:this.targetWorldPosition}}},{key:"setfromCamera",value:function(e,t,n){t.updateMatrixWorld(!0),null==n&&(n=e.getPickingPositionFromDepth()||function(e,t){var n=new at(0,0,.5);if(n.unproject(t),n.sub(t.position).normalize(),"EPSG:4978"==e.referenceCrs)return _T.intersection({direction:n,origin:t.position});var i=t.position.z/n.z;return n.multiplyScalar(i).add(t.position)}(e,t));var i=n&&!isNaN(n.x)?t.position.distanceTo(n):100;t.localToWorld(ST.set(0,0,-i)),this.setFromPositions(e,t.position)}},{key:"copyObject3D",value:function(e){return this.copy(e,!1),this.seaLevel.copy(e.seaLevel,!1),this.target.copy(e.target,!1),this.camera.copy(e.camera),this}},{key:"animateCameraToLookAtTarget",value:function(e,t,i){var r=this;i.easing=i.easing||ud.Easing.Quartic.InOut,this.setfromCamera(e,t);var a=new ud.Group;this.start=(this.start||new n).copyObject3D(this),this.end=(this.end||new n).copyObject3D(this);var o,s,l=i.time||2500,A={t:0},c=[],h={promise:new Promise((function(e,t){o=e,s=t})),resolve:o,reject:s};return this.addPlaceTargetOnGround(e,t,i.coord,A),this.end.applyParams(e,i),c.push(new ud.Tween(A,a).to({t:1},l).easing(i.easing).onUpdate((function(t){"EPSG:4978"==e.referenceCrs&&r.quaternion.slerpQuaternions(r.start.quaternion,r.end.quaternion,t.t),r.camera.quaternion.slerpQuaternions(r.start.camera.quaternion,r.end.camera.quaternion,t.t),r.target.rotation.set(0,0,0),r.target.rotateZ(Hh.lerp(r.start.target.rotation.z,r.end.target.rotation.z,t.t)),r.target.rotateX(Hh.lerp(r.start.target.rotation.x,r.end.target.rotation.x,t.t))})).onComplete(i.onComplete)),"EPSG:4978"!=e.referenceCrs&&c.push(new ud.Tween(this.position,a).to(this.end.position,l).easing(i.easing).onComplete(i.onComplete)),c.push(new ud.Tween(this.seaLevel.position,a).to(this.end.seaLevel.position,l).easing(i.easing)),c.push(new ud.Tween(this.camera.position,a).to(this.end.camera.position,l).easing(i.easing)),this.animationFrameRequester=function(){a.update(),r.updateMatrixWorld(!0),r.applyTransformToCamera(e,t),r.targetWorldPosition.setFromMatrixPosition(r.seaLevel.matrixWorld),i.callback&&i.callback(r),TT.crs=e.referenceCrs,TT.setFromVector3(r.targetWorldPosition).as(kT(e).extent.crs,r.coord),e.notifyChange(t)},this.removeAll=function(t){this.removeAll=function(){},a.removeAll(),this.animationFrameRequester&&e.removeFrameRequester(Kb,this.animationFrameRequester),h.resolve(void 0!==t),this.animationFrameRequester=null},c[c.length-1].onComplete(this.removeAll),c.forEach((function(e){return e.start()})),e.addFrameRequester(Kb,this.animationFrameRequester),e.notifyChange(t),h}},{key:"stop",value:function(e){this.removePlaceTargetOnGround(e),this.removeAll()}},{key:"addPlaceTargetOnGround",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{t:1};if(this.removePlaceTargetOnGround(e),e&&t){var a=this.target.position.z;this.placeTargetOnGround=function(){var o=Math.max(0,Sb.getElevationValueAt(kT(e),n||i.coord,Sb.PRECISE_READ_Z)||0);i.target.position.z=a*(1-r.t)+o*r.t,i.target.updateMatrixWorld(!0),i.applyTransformToCamera(e,t)},this.placeTargetOnGround(),e.addFrameRequester(Kb,this.placeTargetOnGround)}}},{key:"removePlaceTargetOnGround",value:function(e){e&&this.placeTargetOnGround&&(e.removeFrameRequester(Kb,this.placeTargetOnGround),this.placeTargetOnGround=null)}},{key:"tilt",get:function(){return Hh.radToDeg(this.target.rotation.x)}},{key:"heading",get:function(){return FT(Hh.radToDeg(this.target.rotation.z)+180)}},{key:"range",get:function(){return this.camera.position.y}}]),n}(zt);function UT(e){return IT[e.uuid]=IT[e.uuid]||new PT(e),IT[e.uuid]}var DT,RT,OT,NT={defaultStopPlaceOnGroundAtEnd:!1,Easing:ud.Easing,stop:function(e,t){UT(t).stop(e)},getTransformCameraLookingAtTarget:function(e,t,n){var i=UT(t);return i.setfromCamera(e,t,n),i.getParams()},transformCameraToLookAtTarget:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.isExtent&&(n=this.getCameraTransformOptionsFromExtent(e,t,n)),n.proxy=void 0===n.proxy||n.proxy;var i=UT(t);return i.stop(e),i.setfromCamera(e,t),n.proxy&&i.setProxy(e,t),i.applyParams(e,n),i.addPlaceTargetOnGround(e,t,n.coord),i.applyTransformToCamera(e,t),e.notifyChange(t),Promise.resolve(i.getParams())},getCameraTransformOptionsFromExtent:function(e,t,n){var i,r={coord:new ob(n.crs,0,0,0),heading:0,tilt:e.isPlanarView?90:89.9};if(e.isGlobeView?(n=n.as("EPSG:4326"),yT||(yT=new ET),yT.setFromExtent(n),yT.box3D.getSize(LT),i={x:LT.y,y:LT.x}):i=(n=n.as(e.referenceCrs)).dimensions(),n.center(r.coord),t.isOrthographicCamera)i.x/i.y>t.aspect?t.zoom=(t.right-t.left)/i.x:t.zoom=(t.top-t.bottom)/i.y,t.updateProjectionMatrix(),r.range=1e3;else if(t.isPerspectiveCamera){var a=et.degToRad(t.fov);if(i.x/i.y>t.aspect){var o=.5*e.domElement.clientHeight/Math.tan(.5*a),s=2*Math.atan(.5*e.domElement.clientWidth/o);r.range=i.x/(2*Math.tan(.5*s))}else r.range=i.y/(2*Math.tan(.5*a))}return r},animateCameraToLookAtTarget:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.proxy=void 0===i.proxy||i.proxy;var r=UT(t);return r.stop(e),i.proxy&&r.setProxy(e,t),r.animateCameraToLookAtTarget(e,t,i).promise.then((function(t){var i=r.getParams();return(void 0===i.stopPlaceOnGroundAtEnd?n.defaultStopPlaceOnGroundAtEnd:i.stopPlaceOnGroundAtEnd)&&r.stop(e),i.finished=t,i}))},sequenceAnimationsToLookAtTarget:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[{}],r=function(e){return e.reduce((function(e,t){return e.then((function(e){return!e.length||e[e.length-1].finished?t().then(Array.prototype.concat.bind(e)):Promise.resolve([{finished:!1}])}))}),Promise.resolve([]))},a=i.map((function(i){return function(){return n.animateCameraToLookAtTarget(e,t,i)}}));return r(a)},getDiffParams:function(e,t){var n;if(e&&t)return Math.abs(e.range-t.range)/e.range>.001&&((n=n||{}).range={previous:e.range,new:t.range}),Math.abs(e.tilt-t.tilt)>.1&&((n=n||{}).tilt={previous:e.tilt,new:t.tilt}),Math.abs(e.heading-t.heading)>.1&&((n=n||{}).heading={previous:e.heading,new:t.heading}),(Math.abs(e.coord.x-t.coord.x)>1e-6||Math.abs(e.coord.y-t.coord.y)>1e-6)&&((n=n||{}).coord={previous:e.coord,new:t.coord}),n}},zT=37,QT=38,GT=39,HT=40,VT=16,jT=17,WT=function(){function e(){s(this,e),this.NONE={},this.ORBIT={mouseButton:_.LEFT,keyboard:jT,enable:!0,finger:2},this.DOLLY={mouseButton:_.MIDDLE,enable:!0},this.PAN={mouseButton:_.RIGHT,up:QT,bottom:HT,left:zT,right:GT,enable:!0,finger:3},this.MOVE_GLOBE={mouseButton:_.LEFT,enable:!0,finger:1},this.PANORAMIC={mouseButton:_.LEFT,keyboard:VT,enable:!0}}return A(e,[{key:"inputToState",value:function(e,t){for(var n=0,i=Object.keys(this);n1&&void 0!==arguments[1]&&arguments[1];return(e=Object.assign({},e)).coord&&Array.isArray(e.coord)&&(e.coord=new ob("EPSG:4326").setFromArray(e.coord).as("EPSG:4978",DT)),Math.abs(e.heading-this.getHeading())<.5&&(e.heading=this.getHeading()),this.lookAtCoordinate(e,t)}},{key:"flyTo",value:function(e){return this.setView(e,!0)}},{key:"fit",value:function(e){if(e){var t=(new tn).setFromObject(e).getSize(new at);return this.flyTo({coord:new ob("EPSG:4978").setFromVector3(e.getWorldPosition(new at)).as("EPSG:4326"),range:Math.max(t.x,t.z),tilt:90})}}},{key:"lookAtCoordinate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.isAnimationEnabled();if(!t.isExtent&&(t.zoom?t.range=this.view.tileLayer.computeDistanceCameraFromTileZoom(t.zoom,this.view.camera):t.scale&&(t.range=this.view.getScaleFromDistance(t.pitch,t.scale),(t.rangethis.maxDistance)&&(console.warn("This scale ".concat(t.scale," can not be reached")),t.range=Hh.clamp(t.range,this.minDistance,this.maxDistance))),void 0!==t.tilt)){var i=90-Hh.radToDeg(this.maxPolarAngle),r=90-Hh.radToDeg(this.minPolarAngle);(t.tiltr)&&(t.tilt=Hh.clamp(t.tilt,i,r),console.warn("Tilt was clamped to ",t.tilt," the interval is between ".concat(i," and ").concat(r," degree")))}return n?(t.callback=function(e){},this.dispatchEvent({type:"animation-started"}),NT.animateCameraToLookAtTarget(this.view,this.camera,t).then((function(t){return e.dispatchEvent({type:"animation-ended"}),t}))):NT.transformCameraToLookAtTarget(this.view,this.camera,t).then((function(e){return e}))}}]),n}(Je),YT=1e-6,KT=new tt,ZT=new tt,JT=new tt,qT=new Gc(1,.01,0),$T=new Gc(1,0,0),e_=1,t_=new tt,n_=new tt,i_=new tt,r_=new at,a_=new tt,o_=new tt,s_=new tt,l_=new nt,A_=new ob("EPSG:4978"),c_=new ob("EPSG:4978",0,0,0),h_=new ob("EPSG:4326",0,0,0);function u_(e,t){c_.setFromVector3(e).as("EPSG:4326",h_),t.position.copy(e),t.lookAt(h_.geodesicNormal.add(e)),t.rotateX(.5*Math.PI),t.updateMatrixWorld(!0)}var d_,f_,p_=0,m_=!0,v_=.25,g_=new nt(0,0,0,1),y_=new at,w_=new at,x_=new nt,b_=new an,M_=new at,C_=new at,B_={},E_="orientation-changed",S_="range-changed",T_="camera-target-changed",__=new nt,I_=new nt,L_=new at(1,0,0),F_=1/0,k_=new at,P_=new at,U_=new Nc,D_=new at,R_=new at,O_=new an,N_=function(e){h(n,e);var t=y(n);function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),(r=t.call(this,e)).player=new oT,r.states=new WT,r.state=r.states.NONE,r.enabled=!0,a.zoomSpeed&&(console.warn("Controls zoomSpeed parameter is deprecated. Use zoomInFactor and zoomOutFactor instead."),a.zoomFactor=a.zoomFactor||a.zoomSpeed),r.zoomFactor=a.zoomFactor||1.25,r.minDistance=a.minDistance||50,r.maxDistance=a.maxDistance||8*qx.x,r.minZoom=0,r.maxZoom=1/0,r.rotateSpeed=a.rotateSpeed||.25,r.keyPanSpeed=7,r.minPolarAngle=Hh.degToRad(.5),r.maxPolarAngle=Hh.degToRad(86),r.minAzimuthAngle=-1/0,r.maxAzimuthAngle=1/0,r.handleCollision=void 0===a.handleCollision||a.handleCollision,r.minDistanceCollision=60,r.enableKeys=!0,r.enableDamping=!0,r.dampingMoveFactor=null!=a.dampingMoveFactor?a.dampingMoveFactor:v_,r.enablePan=!0,r.startEvent={type:"start"},r.endEvent={type:"end"},r.updateHelper=function(){},r._onEndingMove=null,r._onMouseMove=r.onMouseMove.bind(v(r)),r._onMouseUp=r.onMouseUp.bind(v(r)),r._onMouseDown=r.onMouseDown.bind(v(r)),r._onMouseWheel=r.onMouseWheel.bind(v(r)),r._onContextMenuListener=r.onContextMenuListener.bind(v(r)),r._ondblclick=r.ondblclick.bind(v(r)),r._onTouchStart=r.onTouchStart.bind(v(r)),r._update=r.update.bind(v(r)),r._onTouchMove=r.onTouchMove.bind(v(r)),r._onKeyDown=r.onKeyDown.bind(v(r)),r._onKeyUp=r.onKeyUp.bind(v(r)),r._onBlurListener=r.onBlurListener.bind(v(r)),r.view.domElement.addEventListener("contextmenu",r._onContextMenuListener,!1),r.view.domElement.addEventListener("mousedown",r._onMouseDown,!1),r.view.domElement.addEventListener("mousewheel",r._onMouseWheel,!1),r.view.domElement.addEventListener("dblclick",r._ondblclick,!1),r.view.domElement.addEventListener("DOMMouseScroll",r._onMouseWheel,!1),r.view.domElement.addEventListener("touchstart",r._onTouchStart,!1),r.view.domElement.addEventListener("touchend",r._onMouseUp,!1),r.view.domElement.addEventListener("touchmove",r._onTouchMove,!1),r.player.addEventListener("animation-frame",r._update),window.addEventListener("keydown",r._onKeyDown,!1),window.addEventListener("keyup",r._onKeyUp,!1),window.addEventListener("blur",r._onBlurListener),OT||((OT=new zt).matrixWorldInverse=new bt),e.scene.add(OT),i.isExtent?i.center().as("EPSG:4978",c_):(i.coord.as("EPSG:4978",c_),i.tilt=i.tilt||89.5,i.heading=i.heading||0),u_(c_,OT),r.lookAtCoordinate(i,!1),A_.crs=r.view.referenceCrs,r}return A(n,[{key:"dollyInScale",get:function(){return this.zoomFactor}},{key:"dollyOutScale",get:function(){return 1/this.zoomFactor}},{key:"isPaused",get:function(){return this.state==this.states.NONE}},{key:"onEndingMove",value:function(e){this._onEndingMove&&(this.player.removeEventListener("animation-stopped",this._onEndingMove),this._onEndingMove=null),this.state=this.states.NONE,this.handlingEvent(e)}},{key:"rotateLeft",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;$T.theta-=e}},{key:"rotateUp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;$T.phi-=e}},{key:"panLeft",value:function(e){var t=this.camera.matrix.elements;r_.fromArray(t),r_.multiplyScalar(-e),y_.add(r_)}},{key:"panUp",value:function(e){var t=this.camera.matrix.elements;r_.fromArray(t,4),r_.multiplyScalar(e),y_.add(r_)}},{key:"mouseToPan",value:function(e,t){var n=this.view.mainLoop.gfxEngine;if(this.state=this.states.PAN,this.camera.isPerspectiveCamera){var i=this.camera.position.distanceTo(this.getCameraTargetPosition());i*=2*Math.tan(Hh.degToRad(.5*this.camera.fov)),this.panLeft(e*i/n.width*this.camera.aspect),this.panUp(t*i/n.height)}else this.camera.isOrthographicCamera&&(this.panLeft(e*(this.camera.right-this.camera.left)/n.width),this.panUp(t*(this.camera.top-this.camera.bottom)/n.height))}},{key:"dolly",value:function(e){0!==e&&(RT=e>0?this.dollyInScale:this.dollyOutScale,this.camera.isPerspectiveCamera?e_/=RT:this.camera.isOrthographicCamera&&(this.camera.zoom=Hh.clamp(this.camera.zoom*RT,this.minZoom,this.maxZoom),this.camera.updateProjectionMatrix(),this.view.notifyChange(this.camera)))}},{key:"getMinDistanceCameraBoundingSphereObbsUp",value:function(e){if(e.level>10&&1==e.children.length&&e.geometry){var t=e.obb;O_.center.copy(this.camera.position),O_.radius=this.minDistanceCollision,t.isSphereAboveXYBox(O_)&&(F_=Math.min(O_.center.z-t.box3D.max.z,F_))}}},{key:"update",value:function(){if(F_=1/0,this.handleCollision&&this.view.tileLayer){var e,t=S(this.view.tileLayer.level0Nodes);try{for(t.s();!(e=t.n()).done;){e.value.traverse(this.getMinDistanceCameraBoundingSphereObbsUp.bind(this))}}catch(e){t.e(e)}finally{t.f()}}switch(this.state){case this.states.MOVE_GLOBE:if(F_<0)OT.translateY(-F_),this.camera.position.setLength(this.camera.position.length()-F_);else if(F_o&&$T.phi>0){var s=a-o,l=1-(s-(F_-o))/s;$T.phi*=l*l}else if(F_-o&&$T.phi>-.01){var A=2*o,c=-Math.asin(.25*(o-F_)/qT.radius);c=Hh.clamp(c,-.01,0);var h=1-(o-F_)/A;$T.phi=Hh.lerp($T.phi,c,h),F_-=Math.sin($T.phi)*qT.radius}qT.theta+=$T.theta,qT.phi+=$T.phi,qT.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,qT.theta)),qT.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,qT.phi)),qT.radius=this.camera.position.length()*e_,qT.makeSafe(),qT.radius=Math.max(this.minDistance,Math.min(this.maxDistance,qT.radius)),this.camera.position.setFromSpherical(qT),F_<0&&(this.camera.position.y-=F_,qT.setFromVector3(this.camera.position),$T.phi=0),OT.localToWorld(this.camera.position)}this.camera.up.copy(OT.position).normalize(),this.camera.lookAt(OT.position),this.enableDamping?($T.theta*=.75,$T.phi*=.75,l_.slerp(g_,.2*this.dampingMoveFactor)):($T.theta=0,$T.phi=0,l_.set(0,0,0,1)),e_=1,y_.set(0,0,0),(w_.distanceToSquared(this.camera.position)>YT||8*(1-x_.dot(this.camera.quaternion))>YT)&&(this.view.notifyChange(this.camera),w_.copy(this.camera.position),x_.copy(this.camera.quaternion)),this.enableDamping&&this.state===this.states.ORBIT&&this.player.isStopped()&&($T.theta>YT||$T.phi>YT)&&this.player.playLater(60,2),this.view.dispatchEvent({type:GS,coord:A_.setFromVector3(OT.position),range:qT.radius,heading:-Hh.radToDeg(qT.theta),tilt:90-Hh.radToDeg(qT.phi)})}},{key:"onMouseMove",value:function(e){if(this.player.isPlaying()&&this.player.stop(),!1!==this.enabled){e.preventDefault();var t=this.view.eventToViewCoords(e);switch(this.state){case this.states.ORBIT:case this.states.PANORAMIC:ZT.copy(t),JT.subVectors(ZT,KT);var n=this.view.mainLoop.gfxEngine;this.rotateLeft(2*Math.PI*JT.x/n.width*this.rotateSpeed),this.rotateUp(2*Math.PI*JT.y/n.height*this.rotateSpeed),KT.copy(ZT);break;case this.states.DOLLY:o_.copy(t),s_.subVectors(o_,a_),this.dolly(-s_.y),a_.copy(o_);break;case this.states.PAN:this.enablePan&&(n_.copy(t),i_.subVectors(n_,t_),this.mouseToPan(i_.x,i_.y),t_.copy(n_));break;case this.states.MOVE_GLOBE:var i=this.view.viewToNormalizedCoords(t);U_.setFromCamera(i,this.camera),U_.ray.intersectSphere(b_,C_)?(P_.copy(C_).normalize(),l_.setFromUnitVectors(P_,k_),p_=Date.now()):this.onMouseUp()}this.state!==this.states.NONE&&this.update()}}},{key:"updateTarget",value:function(){this.view.getPickingPositionFromDepth(null,R_);var e=isNaN(R_.x)?100:this.camera.position.distanceTo(R_);D_.set(0,0,-e),this.camera.localToWorld(D_),u_(D_,OT),OT.matrixWorldInverse.copy(OT.matrixWorld).invert(),D_.copy(this.camera.position),D_.applyMatrix4(OT.matrixWorldInverse),qT.setFromVector3(D_)}},{key:"handlingEvent",value:function(e){e=e||NT.getTransformCameraLookingAtTarget(this.view,this.camera);var t=NT.getDiffParams(f_,e);if(t&&(t.range&&this.dispatchEvent({type:S_,previous:t.range.previous,new:t.range.new}),t.coord&&this.dispatchEvent({type:T_,previous:t.coord.previous,new:t.coord.new}),t.tilt||t.heading)){var n={type:E_};t.tilt&&(n.previous={tilt:t.tilt.previous},n.new={tilt:t.tilt.new}),t.heading&&(n.previous=n.previous||{},n.new=n.new||{},n.new.heading=t.heading.new,n.previous.heading=t.heading.previous),this.dispatchEvent(n)}}},{key:"onMouseDown",value:function(e){if(NT.stop(this.view,this.camera),this.player.stop(),this.onEndingMove(),!1!==this.enabled){this.updateTarget(),f_=NT.getTransformCameraLookingAtTarget(this.view,this.camera,R_),this.state=this.states.inputToState(e.button,d_);var t=this.view.eventToViewCoords(e);switch(this.state){case this.states.ORBIT:case this.states.PANORAMIC:KT.copy(t);break;case this.states.MOVE_GLOBE:this.view.getPickingPositionFromDepth(t,M_)?(b_.radius=M_.length(),k_.copy(M_).normalize(),this.updateHelper(M_,B_.picking)):this.state=this.states.NONE;break;case this.states.DOLLY:a_.copy(t);break;case this.states.PAN:t_.copy(t)}this.state!=this.states.NONE&&(this.view.domElement.addEventListener("mousemove",this._onMouseMove,!1),this.view.domElement.addEventListener("mouseup",this._onMouseUp,!1),this.view.domElement.addEventListener("mouseleave",this._onMouseUp,!1),this.dispatchEvent(this.startEvent))}}},{key:"ondblclick",value:function(e){if(!1!==this.enabled&&!d_){this.player.stop();var t=this.view.getPickingPositionFromDepth(this.view.eventToViewCoords(e)),n=this.getRange(t);return t&&n>this.minDistance?this.lookAtCoordinate({coord:new ob("EPSG:4978",t),range:.6*n,time:1500}):void 0}}},{key:"onMouseUp",value:function(){var e=this;!1!==this.enabled&&(this.view.domElement.removeEventListener("mousemove",this._onMouseMove,!1),this.view.domElement.removeEventListener("mouseup",this._onMouseUp,!1),this.view.domElement.removeEventListener("mouseleave",this._onMouseUp,!1),this.dispatchEvent(this.endEvent),this.player.stop(),this.enableDamping?this.state===this.states.ORBIT&&($T.theta>YT||$T.phi>YT)?(this.player.play(60),this._onEndingMove=function(){return e.onEndingMove()},this.player.addEventListener("animation-stopped",this._onEndingMove)):this.state===this.states.MOVE_GLOBE&&Date.now()-p_<50?(this.player.play(120),this._onEndingMove=function(){return e.onEndingMove()},this.player.addEventListener("animation-stopped",this._onEndingMove)):this.onEndingMove():this.onEndingMove())}},{key:"onMouseWheel",value:function(e){if(this.player.stop(),this.enabled&&this.states.DOLLY.enable){NT.stop(this.view,this.camera),e.preventDefault(),this.updateTarget();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),this.dolly(t);var n=this.getRange(R_);this.update();var i=this.getRange(R_);Math.abs(i-n)/n>.001&&this.dispatchEvent({type:S_,previous:n,new:i}),this.dispatchEvent(this.startEvent),this.dispatchEvent(this.endEvent)}}},{key:"onKeyUp",value:function(){!1!==this.enabled&&!1!==this.enableKeys&&(d_=void 0)}},{key:"onKeyDown",value:function(e){if(this.player.stop(),!1!==this.enabled&&!1!==this.enableKeys)switch(d_=e.keyCode,e.keyCode){case this.states.PAN.up:this.mouseToPan(0,this.keyPanSpeed),this.state=this.states.PAN,this.update();break;case this.states.PAN.bottom:this.mouseToPan(0,-this.keyPanSpeed),this.state=this.states.PAN,this.update();break;case this.states.PAN.left:this.mouseToPan(this.keyPanSpeed,0),this.state=this.states.PAN,this.update();break;case this.states.PAN.right:this.mouseToPan(-this.keyPanSpeed,0),this.state=this.states.PAN,this.update()}}},{key:"onTouchStart",value:function(e){if(this.player.stop(),!1!==this.enabled&&(this.state=this.states.touchToState(e.touches.length),this.updateTarget(),this.state!==this.states.NONE)){switch(this.state){case this.states.MOVE_GLOBE:var t=this.view.eventToViewCoords(e);this.view.getPickingPositionFromDepth(t,M_)?(b_.radius=M_.length(),k_.copy(M_).normalize(),this.updateHelper(M_,B_.picking)):this.state=this.states.NONE;break;case this.states.ORBIT:case this.states.DOLLY:var n=e.touches[0].pageX,i=e.touches[0].pageY,r=n-e.touches[1].pageX,a=i-e.touches[1].pageY,o=Math.sqrt(r*r+a*a);a_.set(0,o),KT.set(n,i);break;case this.states.PAN:t_.set(e.touches[0].pageX,e.touches[0].pageY)}this.dispatchEvent(this.startEvent)}}},{key:"onTouchMove",value:function(e){if(this.player.isPlaying()&&this.player.stop(),!1!==this.enabled){switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case this.states.MOVE_GLOBE.finger:var t=this.view.eventToViewCoords(e),n=this.view.viewToNormalizedCoords(t);U_.setFromCamera(n,this.camera),U_.ray.intersectSphere(b_,C_)?(P_.copy(C_).normalize(),l_.setFromUnitVectors(P_,k_),p_=Date.now()):this.onMouseUp.bind(this)();break;case this.states.ORBIT.finger:case this.states.DOLLY.finger:var i=this.view.mainLoop.gfxEngine;ZT.set(e.touches[0].pageX,e.touches[0].pageY),JT.subVectors(ZT,KT),this.rotateLeft(2*Math.PI*JT.x/i.width*this.rotateSpeed),this.rotateUp(2*Math.PI*JT.y/i.height*this.rotateSpeed),KT.copy(ZT);var r=e.touches[0].pageX-e.touches[1].pageX,a=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(r*r+a*a);o_.set(0,o),s_.subVectors(o_,a_),this.dolly(s_.y),a_.copy(o_);break;case this.states.PAN.finger:n_.set(e.touches[0].pageX,e.touches[0].pageY),i_.subVectors(n_,t_),this.mouseToPan(i_.x,i_.y),t_.copy(n_);break;default:this.state=this.states.NONE}this.state!==this.states.NONE&&this.update()}}},{key:"onContextMenuListener",value:function(e){e.preventDefault()}},{key:"onBlurListener",value:function(){this.onKeyUp(),this.onMouseUp()}},{key:"dispose",value:function(){this.view.domElement.removeEventListener("contextmenu",this._onContextMenuListener,!1),this.view.domElement.removeEventListener("mousedown",this._onMouseDown,!1),this.view.domElement.removeEventListener("mousemove",this._onMouseMove,!1),this.view.domElement.removeEventListener("mousewheel",this._onMouseWheel,!1),this.view.domElement.removeEventListener("DOMMouseScroll",this._onMouseWheel,!1),this.view.domElement.removeEventListener("mouseup",this._onMouseUp,!1),this.view.domElement.removeEventListener("mouseleave",this._onMouseUp,!1),this.view.domElement.removeEventListener("dblclick",this._ondblclick,!1),this.view.domElement.removeEventListener("touchstart",this._onTouchStart,!1),this.view.domElement.removeEventListener("touchend",this._onMouseUp,!1),this.view.domElement.removeEventListener("touchmove",this._onTouchMove,!1),this.player.removeEventListener("animation-frame",this._onKeyUp),window.removeEventListener("keydown",this._onKeyDown,!1),window.removeEventListener("keyup",this._onKeyUp,!1),window.removeEventListener("blur",this._onBlurListener),this.dispatchEvent({type:"dispose"})}},{key:"pan",value:function(e){return this.mouseToPan(e.x,e.y),this.update(),Promise.resolve()}},{key:"getCameraOrientation",value:function(){return this.view.getPickingPositionFromDepth(null,R_),[this.getTilt(R_),this.getHeading(R_)]}},{key:"getCameraCoordinate",value:function(){return new ob("EPSG:4978",this.camera.position).as("EPSG:4326")}},{key:"getLookAtCoordinate",value:function(){return NT.getTransformCameraLookingAtTarget(this.view,this.camera).coord}},{key:"setAnimationEnabled",value:function(e){m_=e}},{key:"isAnimationEnabled",value:function(){return m_}},{key:"getZoom",value:function(){return this.view.tileLayer.computeTileZoomFromDistanceCamera(this.getRange(),this.view.camera)}},{key:"setZoom",value:function(e,t){return this.lookAtCoordinate({zoom:e},t)}},{key:"zoomIn",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lookAtCoordinate({zoom:Math.min(this.getZoom()+1,18),time:500},e)}},{key:"zoomOut",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lookAtCoordinate({zoom:this.getZoom()-1,time:500},e)}},{key:"getScale",value:function(e){return console.warn("Deprecated, use View#getScale instead."),this.view.getScale(e)}},{key:"pixelsToMeters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.28;console.warn("Deprecated use View#getPixelsToMeters instead.");var n=this.getScale(t),i=e*t;return i/n/1e3}},{key:"pixelsToDegrees",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.28;console.warn("Deprecated, use View#getPixelsToMeters and GlobeControls#getMetersToDegrees instead.");var n=this.pixelsToMeters(e,t);return Hh.radToDeg(2*Math.asin(n/(2*qx.x)))}},{key:"metersToPixels",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.28;console.warn("Deprecated, use View#getMetersToPixels instead.");var n=this.getScale(t);return e*n/(t/=1e3)}},{key:"setScale",value:function(e,t,n){return this.lookAtCoordinate({scale:e,pitch:t},n)}},{key:"lookAtCoordinate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.isAnimationEnabled();if(!t.isExtent&&(t.zoom?t.range=this.view.tileLayer.computeDistanceCameraFromTileZoom(t.zoom,this.view.camera):t.scale&&(t.range=this.view.getScaleFromDistance(t.pitch,t.scale),(t.rangethis.maxDistance)&&(console.warn("This scale ".concat(t.scale," can not be reached")),t.range=Hh.clamp(t.range,this.minDistance,this.maxDistance))),void 0!==t.tilt)){var i=90-Hh.radToDeg(this.maxPolarAngle),r=90-Hh.radToDeg(this.minPolarAngle);(t.tiltr)&&(t.tilt=Hh.clamp(t.tilt,i,r),console.warn("Tilt was clamped to ",t.tilt," the interval is between ".concat(i," and ").concat(r," degree")))}return f_=NT.getTransformCameraLookingAtTarget(this.view,this.camera),n?(t.callback=function(e){return OT.position.copy(e.targetWorldPosition)},this.dispatchEvent({type:"animation-started"}),NT.animateCameraToLookAtTarget(this.view,this.camera,t).then((function(t){return e.dispatchEvent({type:"animation-ended"}),e.handlingEvent(t),t}))):NT.transformCameraToLookAtTarget(this.view,this.camera,t).then((function(t){return OT.position.copy(t.targetWorldPosition),e.handlingEvent(t),t}))}},{key:"getCameraTargetPosition",value:function(){return OT.position}}]),n}(XT);function z_(e){if(e.dispose)e.dispose();else if(e.geometry&&e.geometry.dispose(),e.material)if(Array.isArray(e.material)){var t,n=S(e.material);try{for(n.s();!(t=n.n()).done;){t.value.dispose()}}catch(e){n.e(e)}finally{n.f()}}else e.material.dispose()}function Q_(e,t){var n,i=S(e.children);try{for(i.s();!(n=i.n()).done;){Q_(n.value,t)}}catch(e){i.e(e)}finally{i.f()}t(e)}var G_=function(e){h(n,e);var t=y(n);function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(s(this,n),a.cacheLifeTime=null==a.cacheLifeTime?WM.GEOMETRY:a.cacheLifeTime,(r=t.call(this,e,a)).isGeometryLayer=!0,!i||!i.isObject3D)throw new Error("Missing/Invalid object3d parameter (must be a\n three.js Object3D instance)");return"Group"===i.type&&""===i.name&&(i.name=e),Object.defineProperty(v(r),"object3d",{value:i,writable:!1,configurable:!0}),r.defineLayerProperty("opacity",1,(function(){(r.parent?r.parent.object3d:r.object3d).traverse((function(e){e.layer==v(r)?r.changeOpacity(e):e.content&&e.content.layer==v(r)&&e.content.traverse(r.changeOpacity)}))})),r.defineLayerProperty("wireframe",!1,(function(){(r.parent?r.parent.object3d:r.object3d).traverse((function(e){e.layer==v(r)&&e.material?e.material.wireframe=r.wireframe:e.content&&e.content.layer==v(r)&&e.content.traverse((function(e){e.material&&e.layer==v(r)&&(e.material.wireframe=r.wireframe)}))}))})),r.attachedLayers=[],r.visible=null==a.visible||a.visible,Object.defineProperty(r.zoom,"max",{value:1/0,writable:!1}),r.filteringExtent=!r.source.isFileSource,r.structure="3d",r}return A(n,[{key:"getObjectToUpdateForAttachedLayers",value:function(e){if(e.parent&&e.material)return{element:e,parent:e.parent}}},{key:"postUpdate",value:function(){}},{key:"culling",value:function(){return!0}},{key:"attach",value:function(e){if(!e.update)throw new Error("Missing 'update' function -> can't attach layer\n ".concat(e.id));this.attachedLayers.push(e),e.parent=this}},{key:"detach",value:function(e){var t=this.attachedLayers.length;return this.attachedLayers=this.attachedLayers.filter((function(t){return t.id!=e.id})),e.parent=void 0,this.attachedLayers.length2&&void 0!==arguments[2]?arguments[2]:this.options.defaultPickingRadius,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=this.parent?this.parent.object3d:this.object3d;return MS(e,t,n,r,i,this.threejsLayer)}},{key:"changeOpacity",value:function(e){e.material&&(null!=e.material.opacity&&(e.material.transparent=this.opacity<1,e.material.opacity=this.opacity),e.material.uniforms&&null!=e.material.uniforms.opacity&&(e.material.transparent=this.opacity<1,e.material.uniforms.opacity.value=this.opacity))}}]),n}(uE),H_=function(e){h(n,e);var t=y(n);function n(e,i,r,a){var o,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(s(this,n),o=t.call(this,e,i),!a)throw new Error("extent is mandatory to build a TileMesh");o.layer=r,o.extent=a,o.extent.zoom=l,o.level=l,o.material.objectId=o.id,o.obb=o.geometry.OBB.clone(),o.boundingSphere=new an,o.obb.box3D.getBoundingSphere(o.boundingSphere),o._tms=new Map;var A,c=S(r.tileMatrixSets);try{for(c.s();!(A=c.n()).done;){var h=A.value;o._tms.set(h,o.extent.tiledCovering(h))}}catch(e){c.e(e)}finally{c.f()}return o.frustumCulled=!1,o.matrixAutoUpdate=!1,o.rotationAutoUpdate=!1,o.layerUpdateState={},o.isTileMesh=!0,o.domElements={},o}return A(n,[{key:"setBBoxZ",value:function(e,t,n){null==e&&null==t||Math.floor(e)===Math.floor(this.obb.z.min)&&Math.floor(t)===Math.floor(this.obb.z.max)||(this.obb.updateZ(e,t,n),this.horizonCullingPointElevationScaled&&this.horizonCullingPointElevationScaled.setLength(this.obb.z.delta+this.horizonCullingPoint.length()),this.obb.box3D.getBoundingSphere(this.boundingSphere))}},{key:"getExtentsByProjection",value:function(e){return this._tms.get(Jx.formatToTms(e))}},{key:"findCommonAncestor",value:function(e){if(e)return e.level==this.level?e.id==this.id?e:0!=e.level?this.parent.findCommonAncestor(e.parent):void 0:e.level1&&(c.uvs[1]=new zn(c.uvs[1],1));var u=new AT(t,c);return u.OBB=new ET(u.boundingBox.min,u.boundingBox.max),u._count=0,u.dispose=function(){u._count--,u._count<=0&&(u.index=null,delete u.attributes.uv_0,si.prototype.dispose.call(u),j_.delete(o,t.level,s))},A(u),Promise.resolve({geometry:u,quaternion:r,position:a})}return l.then((function(e){return{geometry:e,quaternion:r,position:a}}))}(i,o).then((function(e){e.geometry._count++;var o=n.tileMatrixSets.length,s=new LM(n.materialOptions,o),l=new H_(e.geometry,s,n,t,a);if(r&&r.isTileMesh){var A=i.computeSharableExtent(r.extent);e.position.sub(A.position).applyQuaternion(A.quaternion.invert()),e.quaternion.premultiply(A.quaternion)}return l.position.copy(e.position),l.quaternion.copy(e.quaternion),l.visible=!1,l.updateMatrix(),l.add(l.obb),function(e,t){if(e.material.transparent=t.opacity<1,e.material.opacity=t.opacity,t.diffuse&&(e.material.diffuse=t.diffuse),__DEBUG__&&(e.material.showOutline=t.showOutline||!1,e.material.wireframe=t.wireframe||!1),t.isGlobeLayer){e.horizonCullingPoint=e.extent.center().as("EPSG:4978").toVector3(),e.extent.dimensions(W_).multiplyScalar(Hh.DEG2RAD);var n=W_.length(),i=Math.abs(1/Math.cos(.5*n));e.horizonCullingPoint.setLength(i*e.horizonCullingPoint.length()),e.horizonCullingPointElevationScaled=e.horizonCullingPoint.clone()}}(l,n),r&&l.setBBoxZ(r.obb.z.min,r.obb.z.max),l}))};function Y_(e,t,n,i,r){if(e.isCancelledCommandException)t.layerUpdateState[n.id].success();else if(e instanceof SyntaxError)t.layerUpdateState[n.id].failure(0,!0);else{__DEBUG__&&(n.isColorLayer?console.warn("Error in process color on layer",n.id,", node",t,e):n.isElevationLayer?console.warn("Error in process elevation on layer",n.id,", node",t,e):console.warn("Error in process feature on layer",n.id,", node",t,e));var a=t.layerUpdateState[n.id].errorCount>4;t.layerUpdateState[n.id].failure(Date.now(),a,{targetLevel:i}),a||window.setTimeout((function(){r.notifyChange(t,!1)}),1e3*t.layerUpdateState[n.id].secondsUntilNextTry())}}var K_=Math.pow(131072,.5);function Z_(e){return e.visible?100:10}function J_(e){return!e.requester.parent||!e.requester.material||(!!(e.layer.isElevationLayer&&e.requester.material.getElevationLayer()&&e.targetLevel<=e.requester.material.getElevationLayer().level)||!e.requester.material.visible)}function q_(e,t,n,i,r){return{view:e,layer:t,extentsSource:n,extentsDestination:i,requester:r,priority:Z_(r.material),earlyDropFunction:J_}}function $_(e){return function(t){t.material&&t.material.removeLayer&&(t.material.removeLayer(e),t.material.elevationLayerIds[0]==e&&t.setBBoxZ(0,0)),t.layerUpdateState&&t.layerUpdateState[e]&&delete t.layerUpdateState[e]}}var eI,tI=new at,nI=new at,iI=function(e){h(n,e);var t=y(n);function n(e,i,r,a,o){var l;if(s(this,n),o.cacheLifeTime=WM.INFINITE,o.source=!1,(l=t.call(this,e,i,o)).isTiledGeometryLayer=!0,l.protocol="tile",l.sseSubdivisionThreshold=l.sseSubdivisionThreshold||1,l.schemeTile=r,l.builder=a,l.info=new jM(v(l)),!l.schemeTile)throw new Error("Cannot init tiled layer without schemeTile for layer ".concat(l.id));if(!l.builder)throw new Error("Cannot init tiled layer without builder for layer ".concat(l.id));l.level0Nodes=[];var A,c=[],h=S(l.schemeTile);try{for(h.s();!(A=h.n()).done;){var u=A.value;c.push(l.convert(void 0,u))}}catch(e){h.e(e)}finally{h.f()}return l._promises.push(Promise.all(c).then((function(e){var t;l.level0Nodes=e,(t=l.object3d).add.apply(t,C(e)),l.object3d.updateMatrixWorld()}))),l}return A(n,[{key:"pickObjectsAt",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.defaultPickingRadius,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return bS(e,t,n,this,i)}},{key:"preUpdate",value:function(e,t){var n=this;if(t.has(void 0)||0==t.size)return this.level0Nodes;__DEBUG__&&(this._latestUpdateStartingLevel=0),e.colorLayers=e.view.getLayers((function(e,t){return t&&t.id==n.id&&e.isColorLayer})),e.elevationLayers=e.view.getLayers((function(e,t){return t&&t.id==n.id&&e.isElevationLayer})),e.maxElevationLevel=-1;var i,r,a=S(e.elevationLayers);try{for(a.s();!(i=a.n()).done;){var o=i.value;e.maxElevationLevel=Math.max(o.source.zoom.max,e.maxElevationLevel)}}catch(e){a.e(e)}finally{a.f()}-1==e.maxElevationLevel&&(e.maxElevationLevel=1/0),this.colorLayersOrder=dE(e.colorLayers);var s,l=S(t.values());try{for(l.s();!(s=l.n()).done;){var A=s.value;if(A.isCamera)return this.level0Nodes;if(A.layer===this){if(r){if(!(r=A.findCommonAncestor(r)))return this.level0Nodes}else r=A;null==r.material&&(r=void 0)}}}catch(e){l.e(e)}finally{l.f()}return r?(__DEBUG__&&(this._latestUpdateStartingLevel=r.level),[r]):this.level0Nodes}},{key:"update",value:function(e,t,i){var r=this;if(!i.parent)return LS.removeChildrenAndCleanup(this,i);if(i.parent.pendingSubdivision)return i.visible=!1,i.material.visible=!1,void this.info.update(i);if(i.visible=!this.culling(i,e.camera),i.visible){var a=!1;return i.material.visible=!0,this.info.update(i),(i.pendingSubdivision||n.hasEnoughTexturesToSubdivide(e,i)&&this.subdivision(e,this,i))&&(this.subdivideNode(e,i),i.material.visible=i.pendingSubdivision,this.info.update(i),a=!0),i.material.visible&&!a?LS.removeChildren(this,i):a?i.children.filter((function(e){return e.layer==r})):void 0}return i.material.visible=!1,this.info.update(i),LS.removeChildren(this,i)}},{key:"convert",value:function(e,t){return X_(e,t,this)}},{key:"countColorLayersTextures",value:function(){return arguments.length}},{key:"culling",value:function(e,t){return!t.isBox3Visible(e.obb.box3D,e.obb.matrixWorld)}},{key:"subdivideNode",value:function(e,t){var n=this;if(!t.pendingSubdivision&&!t.children.some((function(e){return e.layer==n}))){var i=t.extent.subdivision();t.pendingSubdivision=!0;var r={view:e.view,requester:t,layer:this,priority:1e4,extentsSource:i,redraw:!1};return e.scheduler.execute(r).then((function(n){var i,r=S(n);try{for(r.s();!(i=r.n()).done;){var a=i.value;t.add(a),a.updateMatrixWorld(!0)}}catch(e){r.e(e)}finally{r.f()}t.pendingSubdivision=!1,e.view.notifyChange(t,!1)}),(function(e){if(t.pendingSubdivision=!1,!e.isCancelledCommandException)throw new Error(e)}))}}},{key:"subdivision",value:function(e,t,n){if(n.levelo.zoom.max||sc.zoom.max||h2&&void 0!==arguments[2]?arguments[2]:{};s(this,n);var o=yb.get(Jx.tms_4326),l=gb.get("EPSG:4326").subdivisionByScheme(o);a.tileMatrixSets=[Jx.tms_4326,Jx.tms_3857];var A=a.tileMatrixSets.length,c=new wT({crs:"EPSG:4978",uvCount:A});(r=t.call(this,e,i||new ja,l,c,a)).isGlobeLayer=!0,r.options.defaultPickingRadius=5,r.minSubdivisionLevel=null==r.minSubdivisionLevel?2:r.minSubdivisionLevel,r.maxSubdivisionLevel=null==r.maxSubdivisionLevel?19:r.maxSubdivisionLevel,r.maxDeltaElevation=r.maxDeltaElevation||4,r.extent=r.schemeTile[0].clone();for(var h=1;h0:oI degrees, and the cosine of that","// earth shadow hack","const float cutoffAngle = pi/1.95;","const float steepness = 1.5;","vec3 totalRayleigh(vec3 lambda)","{","return (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn));","}","// A simplied version of the total Reayleigh scattering to works on browsers that use ANGLE","vec3 simplifiedRayleigh()","{","return 0.0005 / vec3(94, 40, 18);","}","float rayleighPhase(float cosTheta)","{ ","return (3.0 / (16.0*pi)) * (1.0 + pow(cosTheta, 2.0));","// return (1.0 / (3.0*pi)) * (1.0 + pow(cosTheta, 2.0));","// return (3.0 / 4.0) * (1.0 + pow(cosTheta, 2.0));","}","vec3 totalMie(vec3 lambda, vec3 K, float T)","{","float c = (0.2 * T ) * 10E-18;","return 0.434 * c * pi * pow((2.0 * pi) / lambda, vec3(v - 2.0)) * K;","}","float hgPhase(float cosTheta, float g)","{","return (1.0 / (4.0*pi)) * ((1.0 - pow(g, 2.0)) / pow(1.0 - 2.0*g*cosTheta + pow(g, 2.0), 1.5));","}","float sunIntensity(float zenithAngleCos)","{","return EE * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness)));","}","// float logLuminance(vec3 c)","// {","// return log(c.r * 0.2126 + c.g * 0.7152 + c.b * 0.0722);","// }","// Filmic ToneMapping http://filmicgames.com/archives/75","float A = 0.15;","float B = 0.50;","float C = 0.10;","float D = 0.20;","float E = 0.02;","float F = 0.30;","float W = 1000.0;","vec3 Uncharted2Tonemap(vec3 x)","{","return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;","}","void main() ","{","vec3 up2 = normalize(cameraPosition.xyz);","float sunfade = 1.0-clamp(1.0-exp((v3LightPosition.y/450000.0)),0.0,1.0);","float reileighCoefficient = reileigh - (1.0* (1.0-sunfade));","vec3 sunDirection = normalize(v3LightPosition);","float sunE = sunIntensity(dot(sunDirection, up2));","// extinction (absorbtion + out scattering) ","// rayleigh coefficients","vec3 betaR = simplifiedRayleigh() * reileighCoefficient;","// mie coefficients","vec3 betaM = totalMie(lambda, K, turbidity) * mieCoefficient;","// optical length","// cutoff angle at 90 to avoid singularity in next formula.","float zenithAngle = acos(max(0.0, dot(up2, normalize(vWorldPosition - cameraPosition))));","float sR = rayleighZenithLength / (cos(zenithAngle) + 0.15 * pow(93.885 - ((zenithAngle * 180.0) / pi), -1.253));","float sM = mieZenithLength / (cos(zenithAngle) + 0.15 * pow(93.885 - ((zenithAngle * 180.0) / pi), -1.253));","// combined extinction factor","vec3 Fex = exp(-(betaR * sR + betaM * sM));","// in scattering","float cosTheta = dot(normalize(vWorldPosition - cameraPosition), sunDirection);","float rPhase = rayleighPhase(cosTheta*0.5+0.5);","vec3 betaRTheta = betaR * rPhase;","float mPhase = hgPhase(cosTheta, mieDirectionalG);","vec3 betaMTheta = betaM * mPhase;","vec3 Lin = pow(sunE * ((betaRTheta + betaMTheta) / (betaR + betaM)) * (1.0 - Fex),vec3(1.5));","Lin *= mix(vec3(1.0),pow(sunE * ((betaRTheta + betaMTheta) / (betaR + betaM)) * Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up2, sunDirection),5.0),0.0,1.0));","//nightsky","vec3 direction = normalize(vWorldPosition - cameraPosition);","float theta = acos(direction.y); // elevation --\x3e y-axis, [-pi/2, pi/2]","float phi = atan(direction.z, direction.x); // azimuth --\x3e x-axis [-pi/2, pi/2]","vec2 uv = vec2(phi, theta) / vec2(2.0*pi, pi) + vec2(0.5, 0.0);","// vec3 L0 = texture2D(skySampler, uv).rgb+0.1 * Fex;","vec3 L0 = vec3(0.1) * Fex;","// composition + solar disc","//if (cosTheta > sunAngularDiameterCos)","float sundisk = smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);","// if (normalize(vWorldPosition - cameraPosition).y>0.0)","L0 += (sunE * 19000.0 * Fex)*sundisk;","vec3 whiteScale = 1.0/Uncharted2Tonemap(vec3(W));","vec3 texColor = (Lin+L0); ","texColor *= 0.04 ;","texColor += vec3(0.0,0.001,0.0025)*0.3;","float g_fMaxLuminance = 1.0;","float fLumScaled = 0.1 / luminance; ","float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (g_fMaxLuminance * g_fMaxLuminance)))) / (1.0 + fLumScaled); ","float ExposureBias = fLumCompressed;","vec3 curr = Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);","vec3 color = curr*whiteScale;","vec3 retColor = pow(color,vec3(1.0/(1.2+(1.2*sunfade))));","gl_FragColor.rgb = retColor;","gl_FragColor.a = 1. - ( (length(cameraPosition) - 6400000.) / 1000.);","}"].join("\n")},hI=function(e){h(n,e);var t=y(n);function n(){s(this,n);var e=Di.clone(cI.uniforms),i=new Ri({fragmentShader:cI.fragmentShader,vertexShader:cI.vertexShader,uniforms:e,side:1,transparent:!0,depthWrite:!1}),r=new el(4e4,32,15);return t.call(this,r,i)}return A(n)}(Ei),uI="\n#include \n\nuniform int atmoIN;\nvarying float intensity;\n\nvec4 glowColor = vec4(0.45, 0.74, 1. ,1.0);\n\nvoid main() {\n #include \n gl_FragColor = glowColor * intensity;\n}\n",dI="\n#include \n#include \n\nuniform int atmoIN;\nvarying float intensity;\n\nvoid main()\n{\n vec3 normalES = normalize( normalMatrix * normal );\n vec3 normalCAMES = normalize( normalMatrix * cameraPosition );\n\n if(atmoIN == 0) {\n intensity = pow(0.666 - dot(normalES, normalCAMES), 4. );\n } else {\n intensity = pow( 1. - dot(normalES, normalCAMES), 0.8 );\n }\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n #include \n}\n",fI=new at(1,0,0),pI=new at,mI=new ob("EPSG:4326"),vI=new ob("EPSG:4326"),gI=new Fn(9688568),yI=new Fn,wI=new Fn(197896),xI=6e5,bI=160*qx.x,MI=function(e){h(n,e);var t=y(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"atmosphere",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,n),r.source=!1,(e=t.call(this,i,new zt,r)).isAtmosphere=!0;var a=new Ri({uniforms:{atmoIN:{type:"i",value:0},screenSize:{type:"v2",value:new tt(window.innerWidth,window.innerHeight)}},vertexShader:dI,fragmentShader:uI,side:1,blending:2,transparent:!0,wireframe:!1}),o=new $s(1,64,64),l=new Ei(o,a);l.scale.copy(qx).multiplyScalar(1.14),e.basicAtmosphere=new zt,e.realisticAtmosphere=new zt,e.realisticAtmosphere.visible=!1,e.object3d.add(e.basicAtmosphere),e.object3d.add(e.realisticAtmosphere),e.basicAtmosphere.add(l);var A=new Ri({uniforms:{atmoIN:{type:"i",value:1},screenSize:{type:"v2",value:new tt(window.innerWidth,window.innerHeight)}},vertexShader:dI,fragmentShader:uI,side:0,blending:2,transparent:!0,depthWrite:!1}),c=new Ei(o,A);return c.scale.copy(qx).multiplyScalar(1.002),e.basicAtmosphere.add(c),e.realisticLightingPosition={x:-.5,y:0,z:1},e.fog={enable:!0,distance:bI},e.realisticAtmosphereInitParams=r.Kr?r:{Kr:.0025,Km:.0015,ESun:20,g:-.95,innerRadius:64e5,outerRadius:67e5,wavelength:[.65,.57,.475],scaleDepth:.25},e.object3d.updateMatrixWorld(),e}return A(n,[{key:"update",value:function(e,t,n){n.material.fogDistance=this.fog.distance,n.material.lightingEnabled=this.realisticAtmosphere.visible,n.material.lightPosition=this.realisticLightingPosition}},{key:"preUpdate",value:function(e,t){var n=e.view.camera.camera3D.position;if(this.fog.enable){pI.setFromMatrixPosition(e.view.tileLayer.object3d.matrixWorld);var i=pI.distanceTo(n);this.fog.distance=bI*Math.pow(.25*(i-.99*qx.x)/qx.x,1.5)}else this.fog.distance=1e11;var r=e.view.mainLoop.gfxEngine.renderer;mI.crs=e.view.referenceCrs,mI.setFromVector3(n).as("EPSG:4326",vI);var a=vI.altitude;if(a1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};s(this,n),zt.DefaultUp.set(0,0,1),(i=t.call(this,"EPSG:4978",e,a)).isGlobeView=!0,i.camera.camera3D.near=Math.max(15,2352e-9*qx.x),i.camera.camera3D.far=10*qx.x;var o=new lI("globe",a.object3d,a);i.mainLoop.gfxEngine.label2dRenderer.infoTileLayer=o.info;var l=new PA;return l.position.set(-.5,0,1),l.updateMatrixWorld(!0),o.object3d.add(l),i.addLayer(o),i.tileLayer=o,Array.isArray(r.coord)&&(r.coord=new ob("EPSG:4326").setFromArray(r.coord)),r.isExtent||(r.coord=r.coord||new ob("EPSG:4326",0,0),r.tilt=r.tilt||89.5,r.heading=r.heading||0,r.range=r.range||2*qx.x),a.noControls?NT.transformCameraToLookAtTarget(v(i),i.camera.camera3D,r):(i.controls=new N_(v(i),r),i.controls.handleCollision=void 0===a.handleCollision||a.handleCollision),i.addLayer(new MI("atmosphere",a.atmosphere)),i.camera.resize(e.clientWidth,e.clientHeight),i}return A(n,[{key:"addLayer",value:function(e){if(!e||!e.isLayer)return Promise.reject(new Error("Add Layer type object"));if(e.isColorLayer){if(!this.tileLayer.tileMatrixSets.includes(Jx.formatToTms(e.source.crs)))return e._reject("Only ".concat(this.tileLayer.tileMatrixSets," tileMatrixSet are currently supported for color layers"))}else if(e.isElevationLayer&&Jx.formatToTms(e.source.crs)!==this.tileLayer.tileMatrixSets[0])return e._reject("Only ".concat(this.tileLayer.tileMatrixSets[0]," tileMatrixSet is currently supported for elevation layers"));return b(u(n.prototype),"addLayer",this).call(this,e,this.tileLayer)}},{key:"getPixelsToDegrees",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;return this.getMetersToDegrees(this.getPixelsToMeters(e,t))}},{key:"getPixelsToDegreesFromDistance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.getMetersToDegrees(this.getPixelsToMetersFromDistance(e,t))}},{key:"getMetersToDegrees",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return Hh.radToDeg(2*Math.asin(e/(2*qx.x)))}}]),n}($S),BI=32,EI=84,SI=89,TI=_.LEFT,_I=_.MIDDLE,II=_.RIGHT,LI=new at,FI=new nt,kI=0,PI=new at,UI=-1,DI=0,RI=1,OI=2,NI=3,zI=4,QI={default:"auto",drag:"move",pan:"cell",travel:"wait",rotate:"move",ortho_zoom:"wait"},GI=new at,HI=new tt,VI=new tt,jI=new tt(0,0),WI=new at,XI=new at,YI=new at,KI=new at(0,0,0),ZI=0,JI=new at,qI=new nt,$I=new tt,eL=new at,tL=new at,nL=new nt,iL=new nt,rL=0,aL=0,oL=!1,sL=!1,lL=0,AL=0,cL=new Nc,hL=new vn(new at(0,0,-1)),uL={enableRotation:!0,rotateSpeed:2,minPanSpeed:.05,maxPanSpeed:15,zoomTravelTime:.2,zoomFactor:2,maxResolution:0,minResolution:1/0,maxAltitude:5e7,groundLevel:200,autoTravelTimeMin:1.5,autoTravelTimeMax:4,autoTravelTimeDist:5e4,smartTravelHeightMin:75,smartTravelHeightMax:500,instantTravel:!1,minZenithAngle:0,maxZenithAngle:82.5,focusOnMouseOver:!0,focusOnMouseClick:!0,handleCollision:!0,minDistanceCollision:30,enableSmartTravel:!0,enablePan:!0},dL="moved",fL=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,e)).camera.isOrthographicCamera?(kI=i.camera.zoom,i.enableRotation=!1,i.enablePan=!1,i.maxAltitude=1/0,i.zoomTravelTime="number"==typeof r.zoomTravelTime?r.zoomTravelTime:uL.zoomTravelTime):(i.enableRotation=void 0===r.enableRotation?uL.enableRotation:r.enableRotation,i.rotateSpeed=r.rotateSpeed||uL.rotateSpeed,i.enablePan=void 0===r.enablePan?uL.enablePan:r.enablePan,i.minPanSpeed=r.minPanSpeed||uL.minPanSpeed,i.maxPanSpeed=r.maxPanSpeed||uL.maxPanSpeed,i.maxAltitude=r.maxAltitude||uL.maxAltitude,i.zoomTravelTime=r.zoomTravelTime||uL.zoomTravelTime),r.zoomInFactor&&(console.warn("Controls zoomInFactor parameter is deprecated. Use zoomFactor instead."),r.zoomFactor=r.zoomFactor||r.zoomInFactor),r.zoomOutFactor&&(console.warn("Controls zoomOutFactor parameter is deprecated. Use zoomFactor instead."),r.zoomFactor=r.zoomFactor||r.zoomInFactor||1/r.zoomOutFactor),0===r.zoomFactor&&(console.warn("Controls zoomFactor parameter can not be equal to 0. Its value will be set to default."),r.zoomFactor=uL.zoomFactor),i.zoomInFactor=r.zoomFactor||uL.zoomFactor,i.zoomOutFactor=1/(r.zoomFactor||uL.zoomFactor),i.maxResolution=r.maxResolution||uL.maxResolution,i.minResolution=r.minResolution||uL.minResolution,i.groundLevel=r.groundLevel||uL.groundLevel,i.autoTravelTimeMin=r.autoTravelTimeMin||uL.autoTravelTimeMin,i.autoTravelTimeMax=r.autoTravelTimeMax||uL.autoTravelTimeMax,i.autoTravelTimeDist=r.autoTravelTimeDist||uL.autoTravelTimeDist,r.smartZoomHeightMin&&(console.warn("Controls smartZoomHeightMin parameter is deprecated. Use smartTravelHeightMin instead."),r.smartTravelHeightMin=r.smartTravelHeightMin||r.smartZoomHeightMin),r.smartZoomHeightMax&&(console.warn("Controls smartZoomHeightMax parameter is deprecated. Use smartTravelHeightMax instead."),r.smartTravelHeightMax=r.smartTravelHeightMax||r.smartZoomHeightMax),i.smartTravelHeightMin=r.smartTravelHeightMin||uL.smartTravelHeightMin,i.smartTravelHeightMax=r.smartTravelHeightMax||uL.smartTravelHeightMax,i.instantTravel=r.instantTravel||uL.instantTravel,i.minZenithAngle=(r.minZenithAngle||uL.minZenithAngle)*Math.PI/180,i.maxZenithAngle=(r.maxZenithAngle||uL.maxZenithAngle)*Math.PI/180,i.focusOnMouseOver=r.focusOnMouseOver||uL.focusOnMouseOver,i.focusOnMouseClick=r.focusOnMouseClick||uL.focusOnMouseClick,i.handleCollision=void 0===r.handleCollision?uL.handleCollision:r.handleCollision,i.minDistanceCollision=uL.minDistanceCollision,i.enableSmartTravel=void 0===r.enableSmartTravel?uL.enableSmartTravel:r.enableSmartTravel,LI.copy(i.camera.position),FI.copy(i.camera.quaternion),i.state=UI,i.cursor=QI,i.view.controls&&(console.warn("Deprecated use of PlanarControls. See examples to correct PlanarControls implementation."),i.view.controls.dispose()),i.view.controls=v(i),i._handlerOnKeyDown=i.onKeyDown.bind(v(i)),i._handlerOnMouseDown=i.onMouseDown.bind(v(i)),i._handlerOnMouseUp=i.onMouseUp.bind(v(i)),i._handlerOnMouseMove=i.onMouseMove.bind(v(i)),i._handlerOnMouseWheel=i.onMouseWheel.bind(v(i)),i._handlerFocusOnMouseClick=i.onMouseClick.bind(v(i)),i._handlerFocusOnMouseOver=i.onMouseOver.bind(v(i)),i._handlerContextMenu=i.onContextMenu.bind(v(i)),i._handlerUpdate=i.update.bind(v(i)),i.view.addFrameRequester(Wb,i._handlerUpdate),i.addInputListeners(),i}return A(n,[{key:"dispose",value:function(){this.removeInputListeners(),this.view.removeFrameRequester(Wb,this._handlerUpdate)}},{key:"update",value:function(e,t){t&&(e=16);var n=this.state!==UI;switch(this.state){case NI:this.handleTravel(e),this.dispatchEvent({type:"range-changed"}),this.view.notifyChange(this.camera);break;case zI:this.handleZoomOrtho(e),this.dispatchEvent({type:"range-changed"}),this.view.notifyChange(this.camera);break;case DI:this.handleDragMovement(),this.view.notifyChange(this.camera);break;case OI:this.handleRotation(),this.view.dispatchEvent({type:GS,heading:this.getHeading(),tilt:this.getTilt()}),this.view.notifyChange(this.camera);break;case RI:this.handlePanMovement(),this.view.notifyChange(this.camera)}this.handleCollision&&this.view.camera.adjustAltitudeToAvoidCollisionWithLayer(this.view,this.view.tileLayer,this.minDistanceCollision),n&&this.view.dispatchEvent({type:dL}),jI.set(0,0)}},{key:"initiateDrag",value:function(){this.state=DI,WI.copy(this.getWorldPointAtScreenXY(HI)),YI.set(0,0,0)}},{key:"handleDragMovement",value:function(){this.getWorldPointFromMathPlaneAtScreenXY(HI,WI.z,XI),YI.subVectors(WI,XI),this.camera.position.add(YI),YI.set(0,0,0)}},{key:"initiatePan",value:function(){this.state=RI}},{key:"handlePanMovement",value:function(){JI.set(-jI.x,jI.y,0),this.camera.localToWorld(JI),this.camera.position.copy(JI)}},{key:"initiateRotation",value:function(){this.state=OI,KI.copy(this.getWorldPointAtScreenXY(new tt(.5*this.view.mainLoop.gfxEngine.width,.5*this.view.mainLoop.gfxEngine.height)));var e=this.camera.position.distanceTo(KI);ZI=Math.acos((this.camera.position.z-KI.z)/e)}},{key:"handleRotation",value:function(){var e=-this.rotateSpeed*jI.x/this.view.mainLoop.gfxEngine.width,t=-this.rotateSpeed*jI.y/this.view.mainLoop.gfxEngine.height,n=this.camera.position.clone().sub(KI);0===e&&0===t||(ZI+t>=this.minZenithAngle&&ZI+t<=this.maxZenithAngle&&0!==t&&(ZI+=t,JI.set(0,0,1),qI.setFromUnitVectors(this.camera.up,JI),n.applyQuaternion(qI),JI.setFromMatrixColumn(this.camera.matrix,0),qI.setFromAxisAngle(JI,t),n.applyQuaternion(qI),JI.set(0,0,1),qI.setFromUnitVectors(this.camera.up,JI).invert(),n.applyQuaternion(qI)),0!==e&&(JI.set(0,0,1),qI.setFromAxisAngle(JI,e),n.applyQuaternion(qI))),this.camera.position.copy(n),this.camera.lookAt(GI),this.camera.position.add(KI),this.camera.updateMatrixWorld()}},{key:"initiateZoom",value:function(e){var t;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),PI.copy(this.getWorldPointAtScreenXY(HI));var n=new at;if(t>0||t<0&&this.maxAltitude>this.camera.position.z){var i=t>0?this.zoomInFactor:this.zoomOutFactor,r=this.view.getPixelsToMeters()/i;if(this.maxResolution>r||r>this.minResolution)return;this.camera.isOrthographicCamera?(this.state=zI,this.view.notifyChange(this.camera),lL=this.camera.zoom,AL=lL*i,PI.z=this.camera.position.z,rL=0,aL=this.zoomTravelTime,this.updateMouseCursorType()):(n.lerpVectors(this.camera.position,PI,1-1/i),this.initiateTravel(n,this.zoomTravelTime,null,!1))}}},{key:"handleZoomOrtho",value:function(e){rL=Math.min(rL+e/1e3/aL,1);var t=lL+rL*(AL-lL);this.camera.zoom!==t&&(this.camera.zoom=t,this.camera.updateProjectionMatrix(),this.view.viewToNormalizedCoords(HI,JI),JI.z=0,JI.unproject(this.camera),this.camera.position.x+=PI.x-JI.x,this.camera.position.y+=PI.y-JI.y,this.camera.updateMatrixWorld(!0)),this.testAnimationEnd()}},{key:"initiateSmartTravel",value:function(){var e=this.getWorldPointAtScreenXY(HI),t=new at;t.copy(e).sub(this.camera.position),t.z=0,t.normalize();var n=this.camera.position.distanceTo(e),i=Hh.lerp(this.smartTravelHeightMin,this.smartTravelHeightMax,Math.min(n/5e3,1)),r=new at;r.copy(e),this.enableRotation&&r.add(t.multiplyScalar(2*-i)),r.z=e.z+i,this.camera.isOrthographicCamera&&(lL=this.camera.zoom,AL=lL*(1+Math.min(n/5e3,1)),r.z=this.camera.position.z),this.initiateTravel(r,"auto",e,!0)}},{key:"initiateTravel",value:function(e,t,n,i){if(this.state=NI,this.view.notifyChange(this.camera),rL=0,this.updateMouseCursorType(),oL=this.enableRotation&&n&&(n.isQuaternion||n.isVector3),sL=i,tL.copy(this.camera.position),nL.copy(this.camera.quaternion),oL&&(n.isQuaternion?iL.copy(n):n.isVector3&&(e===n?(this.camera.lookAt(n),iL.copy(this.camera.quaternion),this.camera.quaternion.copy(nL)):(this.camera.position.copy(e),this.camera.lookAt(n),iL.copy(this.camera.quaternion),this.camera.quaternion.copy(nL),this.camera.position.copy(tL)))),eL.copy(e),this.instantTravel)aL=0;else if("auto"===t){var r=Math.min(1,e.distanceTo(this.camera.position)/this.autoTravelTimeDist);if(aL=Hh.lerp(this.autoTravelTimeMin,this.autoTravelTimeMax,r),oL){var a=.5-.5*iL.normalize().dot(this.camera.quaternion.normalize());aL*=1+2*a,aL=Math.min(aL,this.autoTravelTimeMax)}}else aL=t}},{key:"handleTravel",value:function(e){rL=Math.min(rL+e/1e3/aL,1);var t=sL?this.smooth(rL):rL;this.camera.position.lerpVectors(tL,eL,t);var n=lL+t*(AL-lL);this.camera.isOrthographicCamera&&this.camera.zoom!==n&&(this.camera.zoom=n,this.camera.updateProjectionMatrix()),!0===oL&&this.camera.quaternion.slerpQuaternions(nL,iL,t),this.testAnimationEnd()}},{key:"testAnimationEnd",value:function(){1===rL&&(this.state=UI,this.updateMouseCursorType())}},{key:"goToTopView",value:function(){var e=new at,t=new nt;e.copy(this.getWorldPointAtScreenXY(new tt(.5*this.view.mainLoop.gfxEngine.width,.5*this.view.mainLoop.gfxEngine.height))),e.z+=Math.min(this.maxAltitude,this.camera.position.distanceTo(e)),t.setFromAxisAngle(new at(1,0,0),0),this.initiateTravel(e,"auto",t,!0)}},{key:"goToStartView",value:function(){this.camera.isOrthographicCamera&&(lL=this.camera.zoom,AL=kI),this.initiateTravel(LI,"auto",FI,!0)}},{key:"getWorldPointFromMathPlaneAtScreenXY",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new at;return $I.copy(this.view.viewToNormalizedCoords(e)),cL.setFromCamera($I,this.camera),hL.constant=t,cL.ray.intersectPlane(hL,n),n}},{key:"getWorldPointAtScreenXY",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new at;return this.view.getPickingPositionFromDepth(e,t)||this.getWorldPointFromMathPlaneAtScreenXY(e,this.groundLevel,t),t}},{key:"addInputListeners",value:function(){this.view.domElement.addEventListener("keydown",this._handlerOnKeyDown,!1),this.view.domElement.addEventListener("mousedown",this._handlerOnMouseDown,!1),this.view.domElement.addEventListener("mouseup",this._handlerOnMouseUp,!1),this.view.domElement.addEventListener("mouseleave",this._handlerOnMouseUp,!1),this.view.domElement.addEventListener("mousemove",this._handlerOnMouseMove,!1),this.view.domElement.addEventListener("mousewheel",this._handlerOnMouseWheel,!1),this.focusOnMouseOver&&this.view.domElement.addEventListener("mouseover",this._handlerFocusOnMouseOver,!1),this.focusOnMouseClick&&this.view.domElement.addEventListener("click",this._handlerFocusOnMouseClick,!1),this.view.domElement.addEventListener("contextmenu",this._handlerContextMenu,!1),this.view.domElement.addEventListener("MozMousePixelScroll",this._handlerOnMouseWheel,!1)}},{key:"removeInputListeners",value:function(){this.view.domElement.removeEventListener("keydown",this._handlerOnKeyDown,!0),this.view.domElement.removeEventListener("mousedown",this._handlerOnMouseDown,!1),this.view.domElement.removeEventListener("mouseup",this._handlerOnMouseUp,!1),this.view.domElement.removeEventListener("mouseleave",this._handlerOnMouseUp,!1),this.view.domElement.removeEventListener("mousemove",this._handlerOnMouseMove,!1),this.view.domElement.removeEventListener("mousewheel",this._handlerOnMouseWheel,!1),this.view.domElement.removeEventListener("mouseover",this._handlerFocusOnMouseOver,!1),this.view.domElement.removeEventListener("click",this._handlerFocusOnMouseClick,!1),this.view.domElement.removeEventListener("contextmenu",this._handlerContextMenu,!1),this.view.domElement.removeEventListener("MozMousePixelScroll",this._handlerOnMouseWheel,!1)}},{key:"updateMouseCursorType",value:function(){switch(this.state){case UI:this.view.domElement.style.cursor=this.cursor.default;break;case DI:this.view.domElement.style.cursor=this.cursor.drag;break;case RI:this.view.domElement.style.cursor=this.cursor.pan;break;case NI:this.view.domElement.style.cursor=this.cursor.travel;break;case zI:this.view.domElement.style.cursor=this.cursor.ortho_zoom;break;case OI:this.view.domElement.style.cursor=this.cursor.rotate}}},{key:"updateMousePositionAndDelta",value:function(e){this.view.eventToViewCoords(e,HI),jI.copy(HI).sub(VI),VI.copy(HI)}},{key:"setCursor",value:function(e,t){this.cursor[e]=t,this.updateMouseCursorType()}},{key:"onMouseDown",value:function(e){if(e.preventDefault(),UI===this.state){if(eI=e.button,this.updateMousePositionAndDelta(e),TI===e.button)if(e.ctrlKey){if(!this.enableRotation)return;this.initiateRotation()}else this.initiateDrag();else if(_I===e.button){if(!this.enableSmartTravel)return;this.initiateSmartTravel()}else if(II===e.button){if(!this.enablePan)return;this.initiatePan()}this.updateMouseCursorType()}}},{key:"onMouseUp",value:function(e){e.preventDefault(),NI!==this.state&&zI!==this.state&&eI===e.button&&(this.state=UI),this.updateMouseCursorType()}},{key:"onMouseMove",value:function(e){e.preventDefault(),this.updateMousePositionAndDelta(e),UI!==this.state&&this.view.notifyChange()}},{key:"onKeyDown",value:function(e){if(UI===this.state)switch(e.keyCode){case EI:this.camera.isOrthographicCamera||this.goToTopView();break;case SI:this.goToStartView();break;case BI:this.enableSmartTravel&&this.initiateSmartTravel(e)}}},{key:"onMouseWheel",value:function(e){e.preventDefault(),e.stopPropagation(),UI===this.state&&this.initiateZoom(e)}},{key:"onMouseOver",value:function(){this.view.domElement.focus()}},{key:"onMouseClick",value:function(){this.view.domElement.focus()}},{key:"onContextMenu",value:function(e){e.preventDefault()}},{key:"smooth",value:function(e){return Math.pow(Math.pow(e,2)*(3-2*e),1.2)}},{key:"zoomIn",value:function(){this._getScreenCenter(),this.initiateZoom({wheelDelta:1})}},{key:"zoomOut",value:function(){this._getScreenCenter(),this.initiateZoom({wheelDelta:-1})}},{key:"_getScreenCenter",value:function(){var e=this.view.domElement.getBoundingClientRect();HI.set(e.x+e.width/2-e.x,e.y+e.height/2-e.y)}}]),n}(XT),pL=new nt,mL=new at,vL=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s(this,e),t.projection&&(console.warn("PlanarTileBuilder projection parameter is deprecated, use crs instead."),t.crs=t.crs||t.projection),!t.crs)throw new Error("options.crs is mandatory for PlanarTileBuilder");this.crs=t.crs,this.tmp={coords:new ob("EPSG:4326",0,0),position:new at,normal:new at(0,0,1)},this.uvCount=t.uvCount||1}return A(e,[{key:"prepare",value:function(e){e.nbRow=Math.pow(2,e.zoom+1),e.projected=new at}},{key:"center",value:function(e){return e.center(this.tmp.coords),mL.set(this.tmp.coords.x,this.tmp.coords.y,0),mL}},{key:"vertexPosition",value:function(e){return this.tmp.position.set(e.projected.x,e.projected.y,0),this.tmp.position}},{key:"vertexNormal",value:function(){return this.tmp.normal}},{key:"uProjecte",value:function(e,t){t.projected.x=t.extent.west+e*(t.extent.east-t.extent.west)}},{key:"vProjecte",value:function(e,t){t.projected.y=t.extent.south+e*(t.extent.north-t.extent.south)}},{key:"computeSharableExtent",value:function(e){return{sharableExtent:new bb(e.crs,0,Math.abs(e.west-e.east),0,Math.abs(e.north-e.south)),quaternion:pL,position:this.center(e).clone()}}}]),e}(),gL=function(e){h(n,e);var t=y(n);function n(e,i,r){var a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};s(this,n);var l=Jx.formatToTms(i.crs),A=[l];return gb.get(i.crs)||gb.set(i.crs,i),o.tileMatrixSets=A,(a=t.call(this,e,r||new ja,[i],new vL({crs:i.crs}),o)).isPlanarLayer=!0,a.extent=i,a.minSubdivisionLevel=null==a.minSubdivisionLevel?0:a.minSubdivisionLevel,a.maxSubdivisionLevel=null==a.maxSubdivisionLevel?5:a.maxSubdivisionLevel,a.maxDeltaElevation=a.maxDeltaElevation||4,a}return A(n)}(iI),yL=function(e){h(n,e);var t=y(n);function n(e,i){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};s(this,n),zt.DefaultUp.set(0,0,1),(r=t.call(this,i.crs,e,a)).isPlanarView=!0;var o=i.dimensions(),l=Math.max(o.x,o.y),A=r.camera.camera3D;A.near=.1,A.far=A.isOrthographicCamera?2e3:2*l,A.updateProjectionMatrix();var c=new gL("planar",i,a.object3d,a);r.mainLoop.gfxEngine.label2dRenderer.infoTileLayer=c.info,r.addLayer(c);var h=a.placement||{};return Array.isArray(h.coord)&&(h.coord=new ob("EPSG:4326").setFromArray(h.coord)),h.isExtent||(h.coord=h.coord||i.center(),h.tilt=h.tilt||90,h.heading=h.heading||0,h.range=h.range||l),NT.transformCameraToLookAtTarget(v(r),A,h),a.noControls||(r.controls=new fL(v(r),a.controls)),r.tileLayer=c,r}return A(n,[{key:"addLayer",value:function(e){return b(u(n.prototype),"addLayer",this).call(this,e,this.tileLayer)}}]),n}($S),wL=new ob("EPSG:4326",0,0,0),xL=new bt;function bL(e,t){e.geometry&&e.geometry.applyMatrix4(t),e.children.forEach((function(e){return bL(e,t)}))}function ML(e,t){if(e){e.layer=t,e.material&&(e.material.transparent=t.opacity<1,e.material.opacity=t.opacity,e.material.wireframe=t.wireframe,t.size&&(e.material.size=t.size),t.linewidth&&(e.material.linewidth=t.linewidth)),e.layers.set(t.threejsLayer);var n,i=S(e.children);try{for(i.s();!(n=i.n()).done;){ML(n.value,t)}}catch(e){i.e(e)}finally{i.f()}return e}}var CL={update:function(e,t,n){if(n.parent||!n.children.length){if(n.visible){if(void 0===n.layerUpdateState[t.id])n.layerUpdateState[t.id]=new IS;else if(!n.layerUpdateState[t.id].canTryUpdate())return;var i=n.children.filter((function(e){return e.layer==t}));if(i.length>0)return i;var r=n.getExtentsByProjection(t.source.crs)||[n.extent],a=r[0].zoom;if(a==t.zoom.min&&this.source.extentInsideLimit(n.extent,a)&&(!t.source.isFileSource||n.extent.isPointInside(t.source.extent.center(wL)))){n.layerUpdateState[t.id].newTry();var o={layer:t,extentsSource:r,view:e.view,threejsLayer:t.threejsLayer,requester:n};return e.scheduler.execute(o).then((function(e){if(e=e[0]){var i=!e.layer;if(ML(e,t),t.onMeshCreated&&t.onMeshCreated(e),n.layerUpdateState[t.id].success(),!n.parent)return void LS.removeChildrenAndCleanupRecursively(t,e);i&&(xL.copy(n.matrixWorld).invert().elements[14]-=e.minAltitude,bL(e,xL)),e.minAltitude&&(e.position.z=e.minAltitude),e.layer=t,n.add(e),n.updateMatrixWorld()}else n.layerUpdateState[t.id].failure(1,!0)}),(function(i){return Y_(i,n,t,n.level,e.view)}))}n.layerUpdateState[t.id].noMoreUpdatePossible()}}else LS.removeChildrenAndCleanupRecursively(t,n)}};new at,new Fn(1,1,1),new Fn(.5,.5,.5),new Fn(.5,.5,.5),new Fn(.63,.32,.18),new Fn(0,1,0),new Fn(0,.8,0),new Fn(0,.6,0),new Fn(1,.66,0),new Fn(1,0,1),new Fn(1,0,0),new Fn(0,0,1),new Fn(.8,.8,1),new Fn(.4,.4,.7),new Fn(1,1,0),new Fn(.3,.6,.6);var BL={38:{method:"translateZ",sign:-1},40:{method:"translateZ",sign:1},37:{method:"translateX",sign:-1},39:{method:"translateX",sign:1},33:{method:"rotateZ",sign:1,noSpeed:!0},34:{method:"rotateZ",sign:-1,noSpeed:!0},wheelup:{method:"translateZ",sign:1,oneshot:!0},wheeldown:{method:"translateZ",sign:-1,oneshot:!0}};function EL(e){e.preventDefault(),this._isMouseDown=!0;var t=this.view.eventToViewCoords(e);this._onMouseDownMouseX=t.x,this._onMouseDownMouseY=t.y}function SL(e){e.preventDefault(),this._isMouseDown=!0,this._onMouseDownMouseX=e.touches[0].pageX,this._onMouseDownMouseY=e.touches[0].pageY}function TL(e){if(!0===this._isMouseDown){var t=this.view.eventToViewCoords(e),n=Hh.degToRad(this._camera3D.fov)/this.view.mainLoop.gfxEngine.height;this._camera3D.rotateY((t.x-this._onMouseDownMouseX)*n),this._camera3D.rotateX((t.y-this._onMouseDownMouseY)*n),this._onMouseDownMouseX=t.x,this._onMouseDownMouseY=t.y,this.view.notifyChange(this._camera3D,!1)}}function _L(){this._isMouseDown=!1}function IL(e){var t=BL[e.keyCode];t&&(this.moves.delete(t),e.preventDefault())}function LL(e){var t=BL[e.keyCode];t&&(this.moves.add(t),this.view.notifyChange(this._camera3D,!1),e.preventDefault())}function FL(e){var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t<0?this.moves.add(BL.wheelup):this.moves.add(BL.wheeldown),this.view.notifyChange(this._camera3D,!1)}var kL=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,n),(i=t.call(this)).view=e,i.options=r,i._camera3D=e.camera.camera3D,i.moves=new Set,i.moveSpeed=10,i._onMouseDownMouseX=0,i._onMouseDownMouseY=0,i._isMouseDown=!1,e.domElement.addEventListener("mousedown",EL.bind(v(i)),!1),e.domElement.addEventListener("touchstart",SL.bind(v(i)),!1);var a=TL.bind(v(i));return e.domElement.addEventListener("mousemove",a,!1),e.domElement.addEventListener("touchmove",a,!1),e.domElement.addEventListener("mouseup",_L.bind(v(i)),!1),e.domElement.addEventListener("touchend",_L.bind(v(i)),!1),e.domElement.addEventListener("mousewheel",FL.bind(v(i)),!1),e.domElement.addEventListener("DOMMouseScroll",FL.bind(v(i)),!1),window.addEventListener("keyup",IL.bind(v(i)),!0),window.addEventListener("keydown",LL.bind(v(i)),!0),i.view.addFrameRequester(Wb,i.update.bind(v(i))),r.focusOnMouseOver&&e.domElement.addEventListener("mouseover",(function(){return e.domElement.focus()})),r.focusOnClick&&e.domElement.addEventListener("click",(function(){return e.domElement.focus()})),i}return A(n,[{key:"isUserInteracting",value:function(){return 0!==this.moves.size||this._isMouseDown}},{key:"update",value:function(e,t){t&&(e=16);var n,i=S(this.moves);try{for(i.s();!(n=i.n()).done;){var r=n.value;this._camera3D[r.method](r.sign*(r.noSpeed?1:this.moveSpeed)*e/1e3)}}catch(e){i.e(e)}finally{i.f()}if(this.moves.size>0||this._isMouseDown){this.view.notifyChange(this._camera3D);var a,o=S(this.moves);try{for(o.s();!(a=o.n()).done;){var s=a.value;s.oneshot&&this.moves.delete(s)}}catch(e){o.e(e)}finally{o.f()}}}}]),n}(Je);function PL(e,t,n){var i=.5*Hh.degToRad(n-e.fov);return Hh.clamp(t,-i,i)}var UL=new at(0,1,0);function DL(e,t,n){t.quaternion.setFromUnitVectors(UL,t.up),t.rotateY(n.rotateY),t.rotateX(n.rotateX),e.notifyChange(e.camera.camera3D)}var RL={38:{method:"translateZ",sign:-1},40:{method:"translateZ",sign:1},37:{method:"translateX",sign:-1},39:{method:"translateX",sign:1},33:{method:"translateY",sign:1},34:{method:"translateY",sign:-1}};function OL(e){this.camera.position.z+=e}var NL=new at,zL=new nt,QL=new Bt(0,0,0,"YXZ");function GL(e){NL.copy(this.camera.position),NL.normalize(),this.camera.position.add(NL.multiplyScalar(e))}var HL=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,n),(i=t.call(this)).isFirstPersonControls=!0,i.camera=e.camera.camera3D,i.view=e,i.moves=new Set,r.panoramaRatio){var a=200*r.panoramaRatio/(2*Math.PI);r.verticalFOV=2==r.panoramaRatio?180:Hh.radToDeg(2*Math.atan(200/(2*a)))}return r.verticalFOV=r.verticalFOV||180,r.moveSpeed=void 0===r.moveSpeed?10:r.moveSpeed,i.options=r,i._isMouseDown=!1,i._onMouseDownMouseX=0,i._onMouseDownMouseY=0,i._state={rotateX:0,rotateY:0,snapshot:function(){return{rotateX:this.rotateX,rotateY:this.rotateY}}},i.reset(),i.eventListeners=r.disableEventListeners,r.disableEventListeners||(i._onMouseDown=i.onMouseDown.bind(v(i)),i._onMouseMove=i.onMouseMove.bind(v(i)),i._onMouseUp=i.onMouseUp.bind(v(i)),i._onMouseWheel=i.onMouseWheel.bind(v(i)),i._onKeyUp=i.onKeyUp.bind(v(i)),i._onKeyDown=i.onKeyDown.bind(v(i)),e.domElement.addEventListener("mousedown",i._onMouseDown,!1),e.domElement.addEventListener("touchstart",i._onMouseDown,!1),e.domElement.addEventListener("mousemove",i._onMouseMove,!1),e.domElement.addEventListener("touchmove",i._onMouseMove,!1),e.domElement.addEventListener("mouseup",i._onMouseUp,!1),e.domElement.addEventListener("touchend",i._onMouseUp,!1),e.domElement.addEventListener("mousewheel",i._onMouseWheel,!1),e.domElement.addEventListener("DOMMouseScroll",i._onMouseWheel,!1),document.addEventListener("keydown",i._onKeyDown,!1),document.addEventListener("keyup",i._onKeyUp,!1)),i.view.addFrameRequester(Wb,i.update.bind(v(i))),i._onFocus=function(){return e.domElement.focus()},i.focusOnMouseOver=r.focusOnMouseOver,r.focusOnMouseOver&&e.domElement.addEventListener("mouseover",i._onFocus),i.focusOnClick=r.focusOnClick,r.focusOnClick&&e.domElement.addEventListener("click",i._onFocus),"EPSG:4978"==e.referenceCrs?i.moveCameraVertical=GL:i.moveCameraVertical=OL,i}return A(n,[{key:"isUserInteracting",value:function(){return 0!==this.moves.size&&!this._isMouseDown}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];zL.setFromUnitVectors(UL,this.camera.up),zL.invert(),zL.multiply(this.camera.quaternion),QL.setFromQuaternion(zL),e||(this._state.rotateX=QL.x),this._state.rotateY=QL.y}},{key:"update",value:function(e,t,n){if(0!=this.enabled){t&&(e=16);var i,r=this.camera.position.y,a=S(this.moves);try{for(a.s();!(i=a.n()).done;){var o=i.value;"translateY"===o.method?this.moveCameraVertical(o.sign*this.options.moveSpeed*e/1e3):this.camera[o.method](o.sign*this.options.moveSpeed*e/1e3)}}catch(e){a.e(e)}finally{a.f()}!0!==this._isMouseDown&&!0!==n||DL(this.view,this.camera,this._state),this.moves.size&&this.view.notifyChange(this.view.camera.camera3D),this.camera.position.y=r}}},{key:"onMouseDown",value:function(e){if(0!=this.enabled){this._isMouseDown=!0;var t=this.view.eventToViewCoords(e);this._onMouseDownMouseX=t.x,this._onMouseDownMouseY=t.y,this._stateOnMouseDown=this._state.snapshot()}}},{key:"onMouseUp",value:function(){0!=this.enabled&&(this._isMouseDown=!1)}},{key:"onMouseMove",value:function(e){if(0!=this.enabled&&!0===this._isMouseDown){var t=Hh.degToRad(this.camera.fov)/this.view.mainLoop.gfxEngine.height,n=this.view.eventToViewCoords(e);this._state.rotateY=(n.x-this._onMouseDownMouseX)*t+this._stateOnMouseDown.rotateY,this._state.rotateX=PL(this.camera,(n.y-this._onMouseDownMouseY)*t+this._stateOnMouseDown.rotateX,this.options.verticalFOV),DL(this.view,this.camera,this._state)}}},{key:"onMouseWheel",value:function(e){if(0!=this.enabled){var t=0;void 0!==e.wheelDelta?t=-e.wheelDelta:void 0!==e.detail&&(t=e.detail),this.camera.fov=Hh.clamp(this.camera.fov+Math.sign(t),10,Math.min(100,this.options.verticalFOV)),this.camera.updateProjectionMatrix(),this._state.rotateX=PL(this.camera,this._state.rotateX,this.options.verticalFOV),DL(this.view,this.camera,this._state)}}},{key:"onKeyUp",value:function(e){if(0!=this.enabled){var t=RL[e.keyCode];t&&(this.moves.delete(t),this.view.notifyChange(void 0,!1),e.preventDefault())}}},{key:"onKeyDown",value:function(e){if(0!=this.enabled){var t=RL[e.keyCode];t&&(this.moves.add(t),this.view.notifyChange(void 0,!1),e.preventDefault())}}},{key:"dispose",value:function(){this.eventListeners||(this.view.domElement.removeEventListener("mousedown",this._onMouseDown,!1),this.view.domElement.removeEventListener("touchstart",this._onMouseDown,!1),this.view.domElement.removeEventListener("mousemove",this._onMouseMove,!1),this.view.domElement.removeEventListener("touchmove",this._onMouseMove,!1),this.view.domElement.removeEventListener("mouseup",this._onMouseUp,!1),this.view.domElement.removeEventListener("touchend",this._onMouseUp,!1),this.view.domElement.removeEventListener("mousewheel",this._onMouseWheel,!1),this.view.domElement.removeEventListener("DOMMouseScroll",this._onMouseWheel,!1),document.removeEventListener("keydown",this._onKeyDown,!1),document.removeEventListener("keyup",this._onKeyUp,!1)),this.focusOnMouseOver&&this.view.domElement.removeEventListener("mouseover",this._onFocus),this.focusOnClick&&this.view.domElement.removeEventListener("click",this._onFocus),this.dispatchEvent({type:"dispose"})}}]),n}(Je);new Nn({color:16777215,depthTest:!1,transparent:!0,opacity:.5}),new at,new at,new nt;var VL=Jm((function(e){function t(e,t,a){a=a||2;var o,s,l,h,u,f,p,m=t&&t.length,v=m?t[0]*a:e.length,g=n(e,0,v,a,!0),y=[];if(!g||g.next===g.prev)return y;if(m&&(g=function(e,t,r,a){var o,s,l,h=[];for(o=0,s=t.length;o80*a){o=l=e[0],s=h=e[1];for(var w=a;wl&&(l=u),f>h&&(h=f);p=0!==(p=Math.max(l-o,h-s))?1/p:0}return r(g,y,a,o,s,p),y}function n(e,t,n,i,r){var a,o;if(r===E(e,t,n,i)>0)for(a=t;a=t;a-=i)o=M(a,e[a],e[a+1],o);return o&&v(o,o.next)&&(C(o),o=o.next),o}function i(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!v(i,i.next)&&0!==m(i.prev,i,i.next))i=i.next;else{if(C(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function r(e,t,n,A,c,h,d){if(e){!d&&h&&function(e,t,n,i){var r=e;do{null===r.z&&(r.z=u(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,n,i,r,a,o,s,l,A=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,A*=2}while(o>1)}(r)}(e,A,c,h);for(var f,p,m=e;e.prev!==e.next;)if(f=e.prev,p=e.next,h?o(e,A,c,h):a(e))t.push(f.i/n),t.push(e.i/n),t.push(p.i/n),C(e),e=p.next,m=p.next;else if((e=p)===m){d?1===d?r(e=s(i(e),t,n),t,n,A,c,h,2):2===d&&l(e,t,n,A,c,h):r(i(e),t,n,A,c,h,1);break}}}function a(e){var t=e.prev,n=e,i=e.next;if(m(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(f(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&m(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function o(e,t,n,i){var r=e.prev,a=e,o=e.next;if(m(r,a,o)>=0)return!1;for(var s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,c=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,h=u(s,l,t,n,i),d=u(A,c,t,n,i),p=e.prevZ,v=e.nextZ;p&&p.z>=h&&v&&v.z<=d;){if(p!==e.prev&&p!==e.next&&f(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,v!==e.prev&&v!==e.next&&f(r.x,r.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&f(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;v&&v.z<=d;){if(v!==e.prev&&v!==e.next&&f(r.x,r.y,a.x,a.y,o.x,o.y,v.x,v.y)&&m(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function s(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!v(a,o)&&g(a,r,r.next,o)&&x(a,o)&&x(o,a)&&(t.push(a.i/n),t.push(r.i/n),t.push(o.i/n),C(r),C(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,a,o,s){var l=e;do{for(var A=l.next.next;A!==l.prev;){if(l.i!==A.i&&p(l,A)){var c=b(l,A);return l=i(l,l.next),c=i(c,c.next),r(l,t,n,a,o,s),void r(c,t,n,a,o,s)}A=A.next}l=l.next}while(l!==e)}function A(e,t){return e.x-t.x}function c(e,t){if(t=function(e,t){var n,i=t,r=e.x,a=e.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=c&&r!==i.x&&f(an.x||i.x===n.x&&h(n,i)))&&(n=i,d=l)),i=i.next}while(i!==A);return n}(e,t),t){var n=b(t,e);i(t,t.next),i(n,n.next)}}function h(e,t){return m(e.prev,e,t.prev)<0&&m(t.next,e,e.next)<0}function u(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function d(e){var t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function p(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&g(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(x(e,t)&&x(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||v(e,t)&&m(e.prev,e,e.next)>0&&m(t.prev,t,t.next)>0)}function m(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function v(e,t){return e.x===t.x&&e.y===t.y}function g(e,t,n,i){var r=w(m(e,t,n)),a=w(m(e,t,i)),o=w(m(n,i,e)),s=w(m(n,i,t));return r!==a&&o!==s||(!(0!==r||!y(e,n,t))||(!(0!==a||!y(e,i,t))||(!(0!==o||!y(n,e,i))||!(0!==s||!y(n,t,i)))))}function y(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function w(e){return e>0?1:e<0?-1:0}function x(e,t){return m(e.prev,e,e.next)<0?m(e,t,e.next)>=0&&m(e,e.prev,t)>=0:m(e,t,e.prev)<0||m(e,e.next,t)<0}function b(e,t){var n=new B(e.i,e.x,e.y),i=new B(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function M(e,t,n,i){var r=new B(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function C(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function B(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function E(e,t,n,i){for(var r=0,a=t,o=n-i;a0&&(i+=e[r-1].length,n.holes.push(i))}return n}}));function jL(e,t,n){for(var i=t[e],r=arguments.length,a=new Array(r>3?r-3:0),o=3;o3&&void 0!==arguments[3]?arguments[3]:0,r=(i*=3)+3*t,a=i;a3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:e.length/3,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:a;a*=3;var l,A=(s*=3)+(o*=3);l=isNaN(i)?Array.isArray(i)?function(e){return i[(e-s)/3]}:function(t){return i({},KL.setFromArray(e,t))}:function(){return i};for(var c=s,h=a;c1){var h,u=2*(o-e.geometries.length),d=new Uint16Array(u),f=0,p=S(e.geometries);try{for(p.s();!(h=p.n()).done;){var m=h.value,v=jL("color",t,WL,m.properties),g=m.indices[0].offset;if(g>65535){console.warn("Feature to Line: integer overflow, too many points in lines");break}var y=m.indices[0].count,w=g+y;XL(a,y,v,g);for(var x=g;x65535)return console.warn("Feature to Polygon: integer overflow, too many points in polygons"),"break";var h=jL("color",t,WL,e.properties),u=e.indices.slice(-1)[0],d=u.offset+u.count,f=d-c,p=jL("altitude",t,0,e.properties);0!==p&&ZL(n,i,r,p,0,c,f),XL(a,f,h,c);var m=r.slice(3*c,3*d),v=e.indices.map((function(e){return e.offset-c})).slice(1),g=VL(m,v,3),y=o.length;o.length+=g.length;for(var w=0;w0&&void 0!==arguments[0]?arguments[0]:{};return function(t){if(t)return iF(t.features,e)}};Hh.DEG2RAD,new bt,new at,new at,(new at).set(0,0,1),new ob("EPSG:4326",0,0,0),new Bt,new nt;var aF={color_layers_pars_fragment:"\nstruct Layer {\n int textureOffset;\n int crs;\n float effect;\n float opacity;\n};\n\nuniform sampler2D colorTextures[NUM_FS_TEXTURES];\nuniform vec4 colorOffsetScales[NUM_FS_TEXTURES];\nuniform Layer colorLayers[NUM_FS_TEXTURES];\nuniform int colorTextureCount;\n\nvec3 uvs[NUM_CRS];\n\nfloat getBorderDistance(vec2 uv) {\n vec2 p2 = min(uv, 1. -uv);\n return min(p2.x, p2.y);\n}\n\nfloat tolerance = 0.99;\n\nvec4 applyWhiteToInvisibleEffect(vec4 color, float intensity) {\n float a = dot(color.rgb, vec3(0.333333333));\n if (a >= tolerance) {\n color.a *= 1.0 - pow(abs(a), intensity);\n }\n return color;\n}\n\nvec4 applyLightColorToInvisibleEffect(vec4 color, float intensity) {\n float a = max(0.05,1. - length(color.xyz - 1.));\n color.a *= 1.0 - pow(abs(a), intensity);\n color.rgb *= color.rgb * color.rgb;\n return color;\n}\n\n#if defined(DEBUG)\nuniform bool showOutline;\nuniform vec3 outlineColors[NUM_CRS];\nuniform float outlineWidth;\n\nvec4 getOutlineColor(vec3 outlineColor, vec2 uv) {\n float alpha = 1. - clamp(getBorderDistance(uv) / outlineWidth, 0., 1.);\n return vec4(outlineColor, alpha);\n}\n#endif\n\nuniform float minBorderDistance;\nvec4 getLayerColor(int textureOffset, sampler2D tex, vec4 offsetScale, Layer layer) {\n if ( textureOffset >= colorTextureCount ) return vec4(0);\n\n vec3 uv;\n // #pragma unroll_loop\n for ( int i = 0; i < NUM_CRS; i ++ ) {\n if ( i == layer.crs ) uv = uvs[ i ];\n }\n\n float borderDistance = getBorderDistance(uv.xy);\n if (textureOffset != layer.textureOffset + int(uv.z) || borderDistance < minBorderDistance ) return vec4(0);\n vec4 color = texture2D(tex, pitUV(uv.xy, offsetScale));\n if(color.a > 0.0) {\n if(layer.effect > 2.0) {\n color.rgb /= color.a;\n color = applyLightColorToInvisibleEffect(color, layer.effect);\n } else if(layer.effect > 0.0) {\n color.rgb /= color.a;\n color = applyWhiteToInvisibleEffect(color, layer.effect);\n }\n }\n\n color.a *= layer.opacity;\n return color;\n}\n",elevation_pars_vertex:"\n#if NUM_VS_TEXTURES > 0\n struct Layer {\n float scale;\n float bias;\n int mode;\n float zmin;\n float zmax;\n };\n\n uniform Layer elevationLayers[NUM_VS_TEXTURES];\n uniform sampler2D elevationTextures[NUM_VS_TEXTURES];\n uniform vec4 elevationOffsetScales[NUM_VS_TEXTURES];\n uniform int elevationTextureCount;\n\n highp float decode32(highp vec4 rgba) {\n highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;\n highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;\n highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);\n highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));\n return Result;\n }\n\n float getElevationMode(vec2 uv, sampler2D tex, int mode) {\n if (mode == ELEVATION_RGBA)\n return decode32(texture2D( tex, uv ).abgr * 255.0);\n if (mode == ELEVATION_DATA || mode == ELEVATION_COLOR)\n #if defined(WEBGL2)\n return texture2D( tex, uv ).r;\n #else\n return texture2D( tex, uv ).w;\n #endif\n return 0.;\n }\n\n float getElevation(vec2 uv, sampler2D tex, vec4 offsetScale, Layer layer) {\n uv = uv * offsetScale.zw + offsetScale.xy;\n float d = getElevationMode(uv, tex, layer.mode);\n if (d < layer.zmin || d > layer.zmax) d = 0.;\n return d * layer.scale + layer.bias;\n }\n#endif\n",elevation_vertex:"\n#if NUM_VS_TEXTURES > 0\n if(elevationTextureCount > 0) {\n float elevation = getElevation(uv, elevationTextures[0], elevationOffsetScales[0], elevationLayers[0]);\n transformed += elevation * normal;\n }\n#endif\n",fog_fragment:"\n#if defined(USE_FOG)\n float fogFactor = 1. - min( exp(-fogDepth / fogDistance), 1.);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif\n",fog_pars_fragment:"\n#if defined(USE_FOG)\nuniform vec3 fogColor;\nuniform float fogDistance;\nvarying float fogDepth;\n#endif\n",lighting_fragment:"\nif (lightingEnabled) {\n float light = min(2. * dot(vNormal, lightPosition), 1.);\n gl_FragColor.rgb *= light;\n}\n",lighting_pars_fragment:"\nuniform bool lightingEnabled;\nuniform vec3 lightPosition;\nvarying vec3 vNormal;\n",mode_depth_fragment:"\n#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\ngl_FragColor = packDepthToRGBA(gl_FragDepthEXT);\n#else\nfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\ngl_FragColor = packDepthToRGBA(fragCoordZ);\n#endif\n",mode_id_fragment:"\ngl_FragColor = packDepthToRGBA(float(objectId) / 16777216.0);\n",mode_pars_fragment:"\n#if MODE == MODE_ID || MODE == MODE_DEPTH\n#include \n#endif\n\n#if MODE == MODE_ID\nuniform int objectId;\n#endif\n",overlay_fragment:"\ngl_FragColor.rgb = mix(gl_FragColor.rgb, overlayColor, overlayAlpha);\n",overlay_pars_fragment:"\nuniform vec3 overlayColor;\nuniform float overlayAlpha;\n",pitUV:"\nvec2 pitUV(vec2 uv, vec4 pit)\n{\n return uv * pit.zw + vec2(pit.x, 1.0 - pit.w - pit.y);\n}\n",precision_qualifier:"\nprecision highp float;\nprecision highp int;\n",projective_texturing_vertex:"\nfor(int i = 0; i < ORIENTED_IMAGES_COUNT; ++i)\n projectiveTextureCoords[i] = projectiveTextureMatrix[i] * mvPosition;\n",projective_texturing_pars_vertex:"\nuniform mat4 projectiveTextureMatrix[ORIENTED_IMAGES_COUNT];\nvarying vec4 projectiveTextureCoords[ORIENTED_IMAGES_COUNT];\n",projective_texturing_pars_fragment:"\nuniform sampler2D projectiveTexture[ORIENTED_IMAGES_COUNT];\nuniform sampler2D mask[ORIENTED_IMAGES_COUNT];\nvarying vec4 projectiveTextureCoords[ORIENTED_IMAGES_COUNT];\nuniform float projectiveTextureAlphaBorder;\nuniform float opacity;\nuniform bool boostLight;\n\nstruct Distortion {\n vec2 size;\n#if USE_DISTORTION\n vec2 pps;\n vec4 polynom;\n vec3 l1l2;\n#endif\n};\n\nuniform Distortion projectiveTextureDistortion[ORIENTED_IMAGES_COUNT];\n\nfloat getAlphaBorder(vec2 p)\n{\n vec2 d = clamp(projectiveTextureAlphaBorder * min(p, 1. - p), 0., 1.);\n return min(d.x, d.y);\n}\n\n#if USE_DISTORTION\nvoid distort(inout vec2 p, vec4 polynom, vec2 pps)\n{\n vec2 v = p - pps;\n float v2 = dot(v, v);\n if (v2 > polynom.w) {\n p = vec2(-1.);\n }\n else {\n p += (v2 * (polynom.x + v2 * (polynom.y + v2 * polynom.z) ) ) * v;\n }\n}\n\nvoid distort(inout vec2 p, vec4 polynom, vec3 l1l2, vec2 pps)\n{\n if ((l1l2.x == 0.) && (l1l2.y == 0.)) {\n distort(p, polynom, pps);\n } else {\n vec2 AB = (p - pps) / l1l2.z;\n float R = length(AB);\n float lambda = atan(R) / R;\n vec2 ab = lambda * AB;\n float rho2 = dot(ab, ab);\n float r357 = 1. + rho2* (polynom.x + rho2* (polynom.y + rho2 * polynom.z));\n p = pps + l1l2.z * (r357 * ab + vec2(dot(l1l2.xy, ab), l1l2.y * ab.x));\n }\n}\n#endif\n\nvec4 mixBaseColor(vec4 aColor, vec4 baseColor) {\n #ifdef USE_BASE_MATERIAL\n baseColor.rgb = aColor.a == 1.0 ? aColor.rgb : mix(baseColor, aColor, aColor.a).rgb;\n baseColor.a = min(1.0, aColor.a + baseColor.a);\n #else\n baseColor.rgb += aColor.rgb * aColor.a;\n baseColor.a += aColor.a;\n #endif\n return baseColor;\n}\n\nvec4 projectiveTextureColor(vec4 coords, Distortion distortion, sampler2D tex, sampler2D mask, vec4 baseColor) {\n vec3 p = coords.xyz / coords.w;\n if(p.z * p.z < 1.) {\n#if USE_DISTORTION\n p.xy *= distortion.size;\n distort(p.xy, distortion.polynom, distortion.l1l2, distortion.pps);\n p.xy /= distortion.size;\n#endif\n\n float d = getAlphaBorder(p.xy) * texture2D(mask, p.xy).r;\n\n if(d > 0.) {\n\n#if DEBUG_ALPHA_BORDER\n vec3 r = texture2D(tex, p.xy).rgb;\n return mixBaseColor(vec4( r.r * d, r.g, r.b, 1.0), baseColor);\n#else\n vec4 color = texture2D(tex, p.xy);\n color.a *= d;\n if (boostLight) {\n return mixBaseColor(vec4(sqrt(color.rgb), color.a), baseColor);\n } else {\n return mixBaseColor(color, baseColor);\n }\n#endif\n\n }\n }\n return mixBaseColor(vec4(0.), baseColor);\n}\n",project_pars_vertex:"\nattribute vec3 position;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\n",WebGL2_pars_vertex:"\n#if defined(WEBGL2)\n#define attribute in\n#define varying out\n#define texture2D texture\n#endif\n",WebGL2_pars_fragment:"\n#if defined(WEBGL2)\n#define varying in\nout highp vec4 pc_fragColor;\n#define gl_FragColor pc_fragColor\n#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad\n#endif\n",install:function(e,t,n){return n?(Object.keys(t).forEach((function(i){"install"!=i&&(e[n+i]=t[i])})),e):Object.assign(e,this)}};aF.install(Xi,aF,"itowns/");var oF=new bb("EPSG:4326",[0,0,0,0]);function sF(e,t,n,i,r,a,o,s){e.beginPath();var l,A=S(n);try{for(A.s();!(l=A.n()).done;){var c=l.value;if(c.extent&&c.extent.intersectsExtent(a)){var h=c.offset*r,u=h+c.count*r;e.moveTo(t[h],t[h+1]);for(var d=h+r;d3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4?arguments[4]:void 0;e.beginPath();var a=null==i.point.opacity?1:i.point.opacity;a!==e.globalAlpha&&(e.globalAlpha=a),e.arc(t,n,(i.point.radius||3)*r,0,2*Math.PI,!1),i.point.color&&(e.fillStyle=i.point.color,e.fill()),i.point.line&&(e.lineWidth=(i.point.width||1)*r,e.strokeStyle=i.point.line,e.stroke())}document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix();var AF=new ob("EPSG:4326",0,0,0);function cF(e,t,n,i,r){var a,o=n.dimensions().x/e.canvas.width,s={zoom:n.zoom},l=S(t.geometries);try{var A=function(){var l=a.value;if(l.extent.intersectsExtent(n)){var A={globals:s,properties:function(){return l.properties}},c=(l.properties.style||i).drawingStylefromContext(A);if(c)if(t.type===pC.POINT){var h,u=(Math.round(c.point.radius*r)||3*r)*o,d=S(l.indices);try{for(d.s();!(h=d.n()).done;)for(var f=h.value,p=f.offset*t.size,m=p+f.count*t.size,v=p;v2&&void 0!==arguments[2]?arguments[2]:[{offset:0,count:1}],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,s=arguments.length>7?arguments[7]:void 0;if(0!==t.length)if(i.length){var l,A=S(i);try{for(A.s();!(l=A.n()).done;){sF(e,t,n,l.value,r,a,o,s)}}catch(e){A.e(e)}finally{A.f()}}else sF(e,t,n,i,r,a,o,s)}(e,t.vertices,l.indices,c,t.size,n,r,t.type==pC.POLYGON)}};for(l.s();!(a=l.n()).done;)A()}catch(e){l.e(e)}finally{l.f()}}var hF=new tt,uF=new tt,dF=new tt,fF=new bb("EPSG:4326",0,0,0,0),pF=function(e,t,n,i,r){var a;if(e){t.dimensions(uF);var o=document.createElement("canvas");AF.crs=t.crs,o.width=n,o.height=n;var s=o.getContext("2d");r&&(s.fillStyle=r.getStyle(),s.fillRect(0,0,n,n)),s.globalCompositeOperation=i.globalCompositeOperation||"source-over",s.imageSmoothingEnabled=!1,s.lineJoin="round";var l=e.crs==t.crs?t:t.as(e.crs,oF),A=e.translation,c=e.scale;fF.transformedCopy(A,c,l),dF.set(s.canvas.width,s.canvas.width).divide(uF),hF.set(t.west,t.south).add(A).multiply(dF).negate(),s.setTransform(dF.x/c.x,0,0,dF.y/c.y,hF.x,hF.y);var h,u=c.x/dF.x,d=S(e.features);try{for(d.s();!(h=d.n()).done;){var f=h.value;cF(s,f,fF,f.style||i,u)}}catch(e){d.e(e)}finally{d.f()}(a=new ts(o)).flipY=!1}else if(r){var p=new Uint8Array(3);p[0]=255*r.r,p[1]=255*r.g,p[2]=255*r.b,a=new Hi(p,1,1,Ae)}else a=new ht;return a},mF=new bb("EPSG:4326",[0,0,0,0]),vF=function(e){return e.generateMipmaps=!1,e.magFilter=Z,e.minFilter=Z,e};var gF=function(e,t,n){var i;if(e.isFeatureCollection){var r=n.source.backgroundLayer,a=r&&r.paint?new Fn(r.paint["background-color"]):void 0;t.as(Jx.formatToEPSG(n.crs),mF),(i=pF(e,mF,256,n.style,a)).features=e,i.extent=t}else{if(!e.isTexture)throw new Error("Data type is not supported to convert into texture");i=e}return n.isColorLayer?function(e,t){return e.anisotropy=16,e.premultiplyAlpha=t,vF(e)}(i,n.transparent):n.isElevationLayer?(i.flipY&&(i.flipY=!1),vF(i)):void 0},yF=function(e){h(n,e);var t=y(n);function n(e,i){return s(this,n),i.cacheLifeTime=null==i.cacheLifeTime?WM.TEXTURE:i.cacheLifeTime,t.call(this,e,i)}return A(n,[{key:"convert",value:function(e,t){return gF(e,t,this)}},{key:"delete",value:function(){var e,t=S(this.parent.level0Nodes);try{for(t.s();!(e=t.n()).done;){e.value.traverse($_(this.id))}}catch(e){t.e(e)}finally{t.f()}}}]),n}(uE),wF=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),(i=t.call(this,e,r)).isColorLayer=!0,i.style=new lC(r.style),i.defineLayerProperty("visible",!0),i.defineLayerProperty("opacity",1),i.defineLayerProperty("sequence",0),i.transparent=r.transparent||i.opacity<1,i.noTextureParentOutsideLimit=!!r.source&&r.source.isFileSource,i.fx=r.fx||0,i.buildExtent=!0,i.structure="2d",i}return A(n,[{key:"setupRasterNode",value:function(e){var t=new DM(e.material,this);return e.material.addLayer(t),e.material.setSequence(this.parent.colorLayersOrder),t}},{key:"update",value:function(e,t,n,i){return function(e,t,n,i){var r=n.material;if(i&&r){var a=n.getExtentsByProjection(t.crs),o=a[0].zoom;if(!(o>t.zoom.max||o=t.source.zoom.min)return void e.view.notifyChange(n,!1)}if(r.visible&&t.visible&&n.layerUpdateState[t.id].canTryUpdate())if(s.level>=a[0].zoom)n.layerUpdateState[t.id].noMoreUpdatePossible();else if(!t.frozen){var A=n.layerUpdateState[t.id].failureParams,c=a[0].zoom||n.level,h=GM(t.updateStrategy.type,n,c,s.level,t,A);if(!(!t.source.isVectorSource&&h<=s.level||h>c)){if(!t.source.extentInsideLimit(n.extent,h))return n.layerUpdateState[t.id].noData({targetLevel:h}),void e.view.notifyChange(n,!1);var u=a.map((function(e){return e.tiledExtentParent(h)}));n.layerUpdateState[t.id].newTry();var d=q_(e.view,t,u,a,n);return e.scheduler.execute(d).then((function(e){var i=a.map((function(t,n){return t.offsetToParent(e[n].extent,s.offsetScales[n])}));s.setTextures(e,i),n.layerUpdateState[t.id].success()}),(function(i){return Y_(i,n,t,h,e.view)}))}A.lowestLevelError!=1/0&&n.layerUpdateState[t.id].noMoreUpdatePossible()}}}}(e,this,n,i)}}]),n}(yF),xF=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,n),(i=t.call(this,e,r)).isElevationLayer=!0;var a=1;return i.useColorTextureElevation&&(a=i.colorTextureElevationMaxZ-i.colorTextureElevationMinZ),i.defineLayerProperty("scale",i.scale||1,(function(e){e.parent.object3d.traverse((function(t){t.layer==e.parent&&t.material&&(t.material.setElevationScale(e.scale*a),t.obb.updateScaleZ(e.scale))}))})),i}return A(n,[{key:"setupRasterNode",value:function(e){var t=this,n=new RM(e.material,this);e.material.addLayer(n),e.material.setSequenceElevation(this.id);var i=function(){return e.setBBoxZ(n.min,n.max,t.scale)};return i(),n.addEventListener("updatedElevation",i),n}},{key:"update",value:function(e,t,n,i){return function(e,t,n,i){var r=n.material;if(i&&r){var a=n.getExtentsByProjection(t.crs),o=a[0].zoom;if(!(o>t.zoom.max||o=t.source.zoom.min)return void e.view.notifyChange(n,!1)}if(!t.frozen&&r.visible&&n.layerUpdateState[t.id].canTryUpdate()){var A=n.layerUpdateState[t.id].failureParams,c=GM(t.updateStrategy.type,n,a[0].zoom,s.level,t,A);if(!(c<=s.level||c>a[0].zoom)){if(!t.source.extentInsideLimit(n.extent,c))return n.layerUpdateState[t.id].noData({targetLevel:c}),void e.view.notifyChange(n,!1);var h=a.map((function(e){return e.tiledExtentParent(c)}));n.layerUpdateState[t.id].newTry();var u=q_(e.view,t,h,a,n);return e.scheduler.execute(u).then((function(e){if(c<=s.level)n.layerUpdateState[t.id].noMoreUpdatePossible();else{var i=a.map((function(t,n){return t.offsetToParent(e[n].extent,s.offsetScales[n])}));s.setTextures(e,i),n.layerUpdateState[t.id].success()}}),(function(i){return Y_(i,n,t,c,e.view)}))}n.layerUpdateState[t.id].noMoreUpdatePossible()}}}}(e,this,n,i)}}]),n}(yF);new at;var bF=new Ei,MF=new tn;bF.geometry.boundingBox=MF,new at;var CF=new Ei,BF=new tn;function EF(e,t,n,i,r,a){var o={view:e,requester:r,layer:n,priority:r?1/(r.distance+1):100,metadata:i,redraw:a};return t.execute(o)}function SF(e){return e.children.filter((function(t){return t.layer==e.layer&&t.tileId}))}function TF(e,t,n,i){n.additiveRefinement?function(e,t,n,i){var r,a=S(t.tileset.tiles[n.tileId].children);try{var o=function(){var a=r.value;if(a.promise||a.loaded)return"continue";var o=n.matrixWorld;if(a.transform&&(o=FF.multiplyMatrices(n.matrixWorld,a.transform)),!(!i||!i(t,e.camera,a,o)))return"continue";a.promise=EF(e.view,e.scheduler,t,a,n,!0).then((function(i){n.add(i),i.updateMatrixWorld();var r=LF(t.extent.crs,i.boundingVolume,i.matrixWorld);i.traverse((function(e){e.extent=r})),t.onTileContentLoaded(i),e.view.notifyChange(a),a.loaded=!0,delete a.promise}))};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}}(e,t,n,i):function(e,t,n){if(!n.pendingSubdivision&&0==SF(n).length){var i=function(){var i=t.tileset.tiles[n.tileId].children;if(null==i||0===i.length)return{v:void 0};n.pendingSubdivision=!0;for(var r=[],a=function(a){r.push(EF(e.view,e.scheduler,t,i[a],n,!1).then((function(r){i[a].loaded=!0,n.add(r),r.updateMatrixWorld(),n.additiveRefinement&&e.view.notifyChange(n),t.tileset.tiles[r.tileId].loaded=!0,t.onTileContentLoaded(r)})))},o=0;o2&&void 0!==arguments[2]?arguments[2]:0,i=t.additiveRefinement||n>0,r=0;rthis.cleanupDelay){this.root.cleanableSince=void 0;for(var t=0;tthis.cleanupDelay))break;PF(this,n)}this._cleanableTiles.splice(0,t)}return[this.root]}var RF=new tn,OF=new an;function NF(e,t){e.content&&(e.content.visible=t)}function zF(e,t){t.cleanableSince||(t.cleanableSince=Date.now(),e._cleanableTiles.push(t))}function QF(e,t,n){if(void 0===t.tileset.tiles[n.tileId].children)return!1;if(t.tileset.tiles[n.tileId].isTileset)return!0;var i=function(e,t){if(t.distance=0,t.boundingVolume.region)RF.copy(t.boundingVolume.region.box3D),RF.applyMatrix4(t.boundingVolume.region.matrixWorld),t.distance=RF.distanceToPoint(e.camera3D.position);else if(t.boundingVolume.box)RF.copy(t.boundingVolume.box),RF.applyMatrix4(t.matrixWorld),t.distance=RF.distanceToPoint(e.camera3D.position);else{if(!t.boundingVolume.sphere)return 1/0;OF.copy(t.boundingVolume.sphere),OF.applyMatrix4(t.matrixWorld),t.distance=Math.max(0,OF.distanceToPoint(e.camera3D.position))}return 0===t.distance?1/0:e._preSSE*(t.geometricError/t.distance)}(e.camera,n);return i>t.sseThreshold}var GF=new bt,HF=new at,VF=new at,jF=new bb("EPSG:4326",0,0,0,0),WF=new at,XF=new at,YF=function(){function e(t,n,i){if(s(this,e),this.type=qE,t.region)this.initBoundingRegion(t.region,n);else if(t.box)this.initBoundingBox(t.box);else{if(!t.sphere)throw new Error("3D Tiles nodes must have a bounding volume");this.initBoundingSphere(t.sphere)}t.extensions&&(this.extensions=i.parseExtensions(t.extensions,this.type))}return A(e,[{key:"initBoundingRegion",value:function(e,t){jF.set(Hh.radToDeg(e[0]),Hh.radToDeg(e[2]),Hh.radToDeg(e[1]),Hh.radToDeg(e[3]));var n=new ET;n.setFromExtent(jF),n.updateZ(e[4],e[5]),n.matrix.premultiply(t),n.matrix.decompose(n.position,n.quaternion,n.scale),this.region=n}},{key:"initBoundingBox",value:function(e){HF.set(e[0],e[1],e[2]),VF.set(e[3],e[7],e[11]).multiplyScalar(2),this.box=new tn,this.box.setFromCenterAndSize(HF,VF)}},{key:"initBoundingSphere",value:function(e){WF.set(e[0],e[1],e[2]),this.sphere=new an(WF,e[3])}},{key:"boundingVolumeCulling",value:function(e,t){return!(!this.region||e.isBox3Visible(this.region.box3D,GF.multiplyMatrices(t,this.region.matrix)))||(!(!this.box||e.isBox3Visible(this.box,t))||this.sphere&&!e.isSphereVisible(this.sphere,t))}},{key:"viewerRequestVolumeCulling",value:function(e,t){return this.region?(console.warn("Region viewerRequestVolume not yet supported"),!0):this.box?(console.warn("Bounding box viewerRequestVolume not yet supported"),!0):!(!this.sphere||(XF.copy(this.sphere.center),XF.applyMatrix4(t),e.camera3D.position.distanceTo(XF)<=this.sphere.radius))}}]),e}(),KF=new bt,ZF=function(){function e(t,n,i){s(this,e),this.type=ZE,this.asset=t.asset,this.properties=t.properties,this.geometricError=t.geometricError,this.extensionsUsed=t.extensionsUsed,this.extensionsRequired=t.extensionsRequired,this.tiles=[],this.parseTiles(t.root,n,void 0,i),t.extensions&&(this.extensions=i.parseExtensions(t.extensions,this.type))}return A(e,[{key:"parseTiles",value:function(e,t,n,i){if(e.transform=e.transform?(new bt).fromArray(e.transform):void 0,e._worldFromLocalTransform=e.transform,n&&n._worldFromLocalTransform&&(e.transform?e._worldFromLocalTransform=(new bt).multiplyMatrices(n._worldFromLocalTransform,e.transform):e._worldFromLocalTransform=n._worldFromLocalTransform),(e.viewerRequestVolume&&e.viewerRequestVolume.region||e.boundingVolume&&e.boundingVolume.region)&&(e._worldFromLocalTransform?KF.copy(e._worldFromLocalTransform).invert():KF.identity()),e.viewerRequestVolume=e.viewerRequestVolume?new YF(e.viewerRequestVolume,KF,i):void 0,e.boundingVolume=e.boundingVolume?new YF(e.boundingVolume,KF,i):void 0,this.tiles.push(e),e.tileId=this.tiles.length-1,e.baseURL=t,e.children){var r,a=S(e.children);try{for(a.s();!(r=a.n()).done;){var o=r.value;this.parseTiles(o,t,e,i)}}catch(e){a.e(e)}finally{a.f()}}}},{key:"extendTileset",value:function(e,t,n,i){this.parseTiles(e.root,n,this.tiles[t],i),this.tiles[t].children=[e.root],this.tiles[t].isTileset=!0}}]),e}(),JF=function(){function e(){s(this,e)}return A(e,[{key:"registerExtension",value:function(e,t){this[e]=t}},{key:"getExtension",value:function(e,t){if(this[e]&&this[e][t])return this[e][t];console.error("".concat("No extension manager registered for extension "," ").concat(e," and for class ").concat(t))}},{key:"isExtensionRegistered",value:function(e){return this[e]}},{key:"parseExtensions",value:function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=new(this.getExtension(i,t))(e[i]));return n}}]),e}(),qF=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kF,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:QF;return function(n,i,r){if(!r.parent.pendingSubdivision||r.parent.additiveRefinement){var a=!e||!e(i,n.camera,r,r.matrixWorld);if(r.visible=a,a){var o;if(r.cleanableSince&&(i._cleanableTiles.splice(i._cleanableTiles.indexOf(r),1),r.cleanableSince=void 0),r.pendingSubdivision||t(n,i,r))TF(n,i,r,e),NF(r,r.pendingSubdivision||r.additiveRefinement),o=SF(r);else{NF(r,!0);var s,l=S(SF(r));try{for(l.s();!(s=l.n()).done;){var A=s.value;A.visible=!1,zF(i,A)}}catch(e){l.e(e)}finally{l.f()}}return o}zF(i,r)}else r.visible=!1}}(),$F=function(e){h(n,e);var t=y(n);function n(e,i,r){var a;s(this,n),(a=t.call(this,e,new ja,{source:i.source})).isC3DTilesLayer=!0,a.sseThreshold=i.sseThreshold||16,a.cleanupDelay=i.cleanupDelay||1e3,a.onTileContentLoaded=i.onTileContentLoaded||function(){},a.protocol="3d-tiles",a.overrideMaterials=void 0===i.overrideMaterials||i.overrideMaterials,a.name=i.name,a.registeredExtensions=i.registeredExtensions||new JF,a._cleanableTiles=[];var o=a.addInitializationStep();return a.source.whenReady.then((function(e){if(a.tileset=new ZF(e,a.source.baseUrl,a.registeredExtensions),a.tileset.extensionsUsed){var t,n=S(a.tileset.extensionsUsed);try{for(n.s();!(t=n.n()).done;){var i=t.value;a.registeredExtensions.isExtensionRegistered(i)||(a.tileset.extensionsRequired&&a.tileset.extensionsRequired.includes(i)?console.error('3D Tiles tileset required extension "'.concat(i,'" must be registered to the 3D Tiles layer of iTowns to be parsed and used.')):console.warn('3D Tiles tileset used extension "'.concat(i,'" must be registered to the 3D Tiles layer of iTowns to be parsed and used.')))}}catch(e){n.e(e)}finally{n.f()}}(function(e,t,n,i){return EF(e,t,n,i,void 0,!0).then((function(t){n.object3d.add(t),t.updateMatrixWorld(),n.tileset.tiles[t.tileId].loaded=!0,n.root=t,n.extent=LF(n.crs||e.referenceCrs,t.boundingVolume,t.matrixWorld),n.onTileContentLoaded(t)}))})(r,r.mainLoop.scheduler,v(a),e.root).then(o)})),a}return A(n,[{key:"preUpdate",value:function(){return DF.bind(this)()}},{key:"update",value:function(e,t,n){return qF(e,t,n)}},{key:"getObjectToUpdateForAttachedLayers",value:function(e){if(e.content){var t=[];e.content.traverse((function(n){n.isObject3D&&n.material&&n.layer==e.layer&&t.push(n)}));var n=e.parent;return n&&n.content?{elements:t,parent:n.content}:{elements:t}}}},{key:"findBatchTable",value:function(e){return e.batchTable?e.batchTable:e.parent?this.findBatchTable(e.parent):void 0}},{key:"getInfoFromIntersectObject",value:function(e){for(var t={},n=-1,i={},r=0;r=this.zoom.min;r--){var a=this.tileMatrixSetLimits[r],o=ik.set(r,a.minTileRow,a.minTileCol).as(i),s=o.west,l=o.north,A=ik.set(r,a.maxTileRow,a.maxTileCol).as(i),c=A.east,h=A.south;this.extentSetlimits[i][r]=new bb(i,s,c,h,l)}}}},{key:"extentInsideLimit",value:function(e,t){return t>=this.zoom.min&&t<=this.zoom.max&&(null==this.extentSetlimits[e.crs]||this.extentSetlimits[e.crs][t].intersectsExtent(e))}}]),n}(hE),ak=function(e){h(n,e);var t=y(n);function n(e){var i;if(s(this,n),e.projection&&(console.warn("WFSSource projection parameter is deprecated, use crs instead."),e.crs=e.crs||e.projection),!e.typeName)throw new Error("source.typeName is required in wfs source.");if(!e.crs)throw new Error("source.crs is required in wfs source");for(var r in e.format=e.format||"application/json",(i=t.call(this,e)).isWFSSource=!0,i.typeName=e.typeName,i.version=e.version||"2.0.2",i.url="".concat(e.url,"SERVICE=WFS&REQUEST=GetFeature&typeName=").concat(i.typeName,"&VERSION=").concat(i.version,"&SRSNAME=").concat(i.crs,"&BBOX=%bbox,").concat(i.crs),void 0!==e.tk&&(i.url+="&tk="+e.tk),e.format&&(i.url=i.url+"&outputFormat="+e.format),e.name&&(i.url=i.url+"&name="+e.name),i.zoom={min:0,max:1/0},i.vendorSpecific=e.vendorSpecific,i.vendorSpecific)Object.prototype.hasOwnProperty.call(i.vendorSpecific,r)&&(i.url="".concat(i.url,"&").concat(r,"=").concat(i.vendorSpecific[r]));return i}return A(n,[{key:"handlingError",value:function(e){var t=this;return e.response&&400==e.response.status?e.response.text().then((function(n){var i="".concat(t.url,"SERVICE=WFS&REQUEST=GetCapabilities&VERSION=").concat(t.version),r=(new DOMParser).parseFromString(n,"application/xml").querySelector("Exception"),a=r.getAttribute("exceptionCode"),o=r.querySelector("ExceptionText").textContent;console.error("Source ".concat(t.typeName,': bad request when fetching data. Server says: "').concat(a,": ").concat(o,'". \nReviewing ').concat(i," may help."),e)})):b(u(n.prototype),"handlingError",this).call(this,e)}},{key:"requestToKey",value:function(e){return Jx.isTms(e.crs)?b(u(n.prototype),"requestToKey",this).call(this,e):[e.zoom,e.south,e.west]}},{key:"urlFromExtent",value:function(e){return kE(e,this)}},{key:"extentInsideLimit",value:function(e){return this.extent.intersectsExtent(e)}}]),n}(hE),ok=function(e){h(n,e);var t=y(n);function n(e){var i;if(s(this,n),!e.name)throw new Error("New WMTSSource: name is required");return(i=t.call(this,e)).isWMTSSource=!0,i.url="".concat(i.url)+(i.url.includes("?")?"&":"?")+"LAYER=".concat(e.name)+"&FORMAT=".concat(i.format)+"&SERVICE=WMTS"+"&VERSION=".concat(e.version||"1.0.0")+"&REQUEST=GetTile"+"&STYLE=".concat(e.style||"normal")+"&TILEMATRIXSET=".concat(e.tileMatrixSet)+"&TILEMATRIX=%TILEMATRIX&TILEROW=%ROW&TILECOL=%COL",void 0!==e.tk&&(i.url+="&tk="+e.tk),i}return A(n)}(rk),sk={POSITION_CARTESIAN:{numElements:3,arrayType:Float32Array,attributeName:"position"},COLOR_PACKED:{numElements:4,arrayType:Uint8Array,attributeName:"color",normalized:!0},INTENSITY:{numElements:1,numByte:2,arrayType:Uint16Array,attributeName:"intensity",normalized:!0},CLASSIFICATION:{numElements:1,arrayType:Uint8Array,attributeName:"classification",normalized:!0},NORMAL_SPHEREMAPPED:{numElements:2,arrayType:Uint8Array,attributeName:"sphereMappedNormal"},NORMAL_OCT16:{numElements:2,arrayType:Uint8Array,attributeName:"oct16Normal"},NORMAL:{numElements:3,arrayType:Float32Array,attributeName:"normal"}},lk=function(){var e=ck[Ak],t=sk[e];t.potreeName=e,t.numByte=t.numByte||t.arrayType.BYTES_PER_ELEMENT,t.byteSize=t.numElements*t.numByte,t.normalized=t.normalized||!1;var n="getUint".concat(8*t.numByte);t.getValue=1===t.numByte?function(e,t){return e[n](t)}:function(e,t){return e[n](t,!0)}},Ak=0,ck=Object.keys(sk);Ak>18]+o[63&e>>12]+o[63&e>>6]+o[63&e]}function a(e,t,n){for(var i,a=[],o=t;o>16,A[c++]=255&t>>8,A[c++]=255&t;return 2===o&&(t=s[e.charCodeAt(n)]<<2|s[e.charCodeAt(n+1)]>>4,A[c++]=255&t),1===o&&(t=s[e.charCodeAt(n)]<<10|s[e.charCodeAt(n+1)]<<4|s[e.charCodeAt(n+2)]>>2,A[c++]=255&t>>8,A[c++]=255&t),A},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,r=[],s=16383,l=0,A=n-i;lA?A:l+s));return 1===i?(t=e[n-1],r.push(o[t>>2]+o[63&t<<4]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],r.push(o[t>>10]+o[63&t>>4]+o[63&t<<2]+"=")),r.join("")};for(var o=[],s=[],l="undefined"==typeof Uint8Array?Array:Uint8Array,A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,h=A.length;ct||e.byteLengthe)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e,n,i){return A(e),0>=e||void 0===n?t(e):"string"==typeof i?t(e).fill(n,i):t(e).fill(n)}function h(e){return A(e),t(0>e?0:0|p(e))}function u(e,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|m(e,n),a=t(r),o=a.write(e,n);return o!==r&&(a=a.slice(0,o)),a}function d(e){for(var n=0>e.length?0:0|p(e.length),i=t(n),r=0;r=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|e}function m(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+r(e));var n=e.length,a=2>>1;case"base64":return Q(e).length;default:if(o)return a?-1:z(e).length;t=(""+t).toLowerCase(),o=!0}}function v(e,t,n){var i=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return F(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return L(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function g(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function y(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647n&&(n=-2147483648),V(n=+n)&&(n=a?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(0>n){if(!a)return-1;n=0}if("string"==typeof t&&(t=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:w(e,t,n,r,a);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):w(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function w(e,t,n,i,r){function a(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var o,s=1,l=e.length,A=t.length;if(void 0!==i&&("ucs2"===(i=(i+"").toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(2>e.length||2>t.length)return-1;s=2,l/=2,A/=2,n/=2}if(r){var c=-1;for(o=n;ol&&(n=l-A),o=n;0<=o;o--){for(var h=!0,u=0;ur&&(i=r):i=r;var a=t.length;i>a/2&&(i=a/2);for(var o,s=0;s(t-=2));++o)i=(n=e.charCodeAt(o))>>8,r=n%256,a.push(r),a.push(i);return a}(t,e.length-n),e,n,i)}function S(e,t,n){return 0===t&&n===e.length?j.fromByteArray(e):j.fromByteArray(e.slice(t,n))}function T(e,t,n){n=l(e.length,n);for(var i=[],r=t;rc&&(h=c):2===u?128==(192&(a=e[r+1]))&&(127<(A=(31&c)<<6|63&a)&&(h=A)):3===u?(a=e[r+1],o=e[r+2],128==(192&a)&&128==(192&o)&&(2047<(A=(15&c)<<12|(63&a)<<6|63&o)&&(55296>A||57343A&&(h=A)));null===h?(h=65533,u=1):65535>>10),h=56320|1023&h),i.push(h),r+=u}return _(i)}function _(e){var t=e.length;if(t<=4096)return s.apply(String,e);for(var n="",i=0;it)&&(t=0),(!n||0>n||n>i)&&(n=i);for(var r="",a=t;ae)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,n,r,a,o){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||te.length)throw new RangeError("Index out of range")}function D(e,t,n,i){if(n+i>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function R(e,t,n,i,r){return t=+t,n>>>=0,r||D(e,0,n,4),W.write(e,t,n,i,23,4),n+4}function O(e,t,n,i,r){return t=+t,n>>>=0,r||D(e,0,n,8),W.write(e,t,n,i,52,8),n+8}function N(e){return 16>e?"0"+e.toString(16):e.toString(16)}function z(e,t){t=t||1/0;for(var n,i=e.length,r=null,a=[],o=0;on){if(!r){if(56319n){-1<(t-=3)&&a.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&-1<(t-=3)&&a.push(239,191,189);if(r=null,128>n){if(0>(t-=1))break;a.push(n)}else if(2048>n){if(0>(t-=2))break;a.push(192|n>>6,128|63&n)}else if(65536>n){if(0>(t-=3))break;a.push(224|n>>12,128|63&n>>6,128|63&n)}else{if(!(1114112>n))throw new Error("Invalid code point");if(0>(t-=4))break;a.push(240|n>>18,128|63&n>>12,128|63&n>>6,128|63&n)}}return a}function Q(e){return j.toByteArray(function(e){if(2>(e=(e=e.split("=")[0]).trim().replace(X,"")).length)return"";for(;0!=e.length%4;)e+="=";return e}(e))}function G(e,t,n,i){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function V(e){return e!=e}var j=e("base64-js"),W=e("ieee754");n.Buffer=i,n.SlowBuffer=function(e){return+e!=e&&(e=0),i.alloc(+e)},n.INSPECT_MAX_BYTES=50,n.kMaxLength=2147483647,i.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){return i.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){return i.isBuffer(this)?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(e,t,n){return o(e,t,n)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(e,t,n){return c(e,t,n)},i.allocUnsafe=function(e){return h(e)},i.allocUnsafeSlow=function(e){return h(e)},i.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==i.prototype},i.compare=function(e,t){if(H(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,o=l(n,r);at&&(e+=" ... "),""},i.prototype.compare=function(e,t,n,a,o){if(H(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+r(e));if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===o&&(o=this.length),0>t||n>e.length||0>a||o>this.length)throw new RangeError("out of range index");if(a>=o&&t>=n)return 0;if(a>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(a>>>=0),A=(n>>>=0)-(t>>>=0),c=l(s,A),h=this.slice(a,o),u=e.slice(t,n),d=0;d>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),0n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var a=!1;;)switch(i){case"hex":return x(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return M(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return B(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},i.prototype.slice=function(e,t){var n=this.length;0>(e=~~e)?0>(e+=n)&&(e=0):e>n&&(e=n),0>(t=void 0===t?n:~~t)?0>(t+=n)&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||P(e,t,this.length);for(var i=this[e],r=1,a=0;++a>>=0,t>>>=0,n||P(e,t,this.length);for(var i=this[e+--t],r=1;0>>=0,t||P(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var i=this[e],r=1,o=0;++o=(r*=128)&&(i-=a(2,8*t)),i},i.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var i=t,r=1,o=this[e+--i];0=(r*=128)&&(o-=a(2,8*t)),o},i.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),W.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),W.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),W.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),W.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,n,i){(e=+e,t>>>=0,n>>>=0,i)||U(this,e,t,n,a(2,8*n)-1,0);var r=1,o=0;for(this[t]=255&e;++o>>=0,n>>>=0,i)||U(this,e,t,n,a(2,8*n)-1,0);var r=n-1,o=1;for(this[t+r]=255&e;0<=--r&&(o*=256);)this[t+r]=255&e/o;return t+n},i.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=a(2,8*n-1);U(this,e,t,n,r-1,-r)}var o=0,s=1,l=0;for(this[t]=255&e;++oe&&0===l&&0!==this[t+o-1]&&(l=1),this[t+o]=255&(e/s>>0)-l;return t+n},i.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t>>>=0,!i){var r=a(2,8*n-1);U(this,e,t,n,r-1,-r)}var o=n-1,s=1,l=0;for(this[t+o]=255&e;0<=--o&&(s*=256);)0>e&&0===l&&0!==this[t+o+1]&&(l=1),this[t+o]=255&(e/s>>0)-l;return t+n},i.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return O(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return O(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(!i.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-ta||"latin1"===r)&&(e=a)}}else"number"==typeof e&&(e&=255);if(0>t||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o */ +o.read=function(e,t,n,i,r){var o,s,l=8*r-i-1,A=(1<>1,h=-7,u=n?r-1:0,d=n?-1:1,f=e[t+u];for(u+=d,o=f&(1<<-h)-1,f>>=-h,h+=l;0>=-h,h+=i;0>1,v=23===l?a(2,-24)-a(2,-77):0,g=s?0:A-1,y=s?1:-1,w=0>r||0===r&&0>1/r?1:0;for(r=n(r),isNaN(r)||r===1/0?(h=isNaN(r)?1:0,c=p):(c=e(t(r)/d),1>r*(u=a(2,-c))&&(c--,u*=2),2<=(r+=1<=c+m?v/u:v*a(2,1-m))*u&&(c++,u/=2),c+m>=p?(h=0,c=p):1<=c+m?(h=(r*u-1)*a(2,l),c+=m):(h=r*a(2,m-1)*a(2,l),c=0));8<=l;i[o+g]=255&h,g+=y,h/=256,l-=8);for(c=c< + (c) 2009-2016 Stuart Knightley + Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. + JSZip uses the library pako released under the MIT license : + https://github.com/nodeca/pako/blob/master/LICENSE + */ +!function(e){"object"==r(a)&&void 0!==i?i.exports=e():("undefined"==typeof window?void 0===o?"undefined"==typeof self?this:self:o:window).JSZip=e()}((function(){return function e(n,i,r){function a(s,l){if(!i[s]){if(!n[s]){var A="function"==typeof t&&t;if(!l&&A)return A(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=i[s]={exports:{}};n[s][0].call(h.exports,(function(e){return a(n[s][1][e]||e)}),h,h.exports,e,n,i,r)}return i[s].exports}for(var o="function"==typeof t&&t,s=0;s>2,o=(3&t)<<4|n>>4,s=1>6:64,l=2>4,n=(15&a)<<4|(o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(l++)))>>2,i=(3&o)<<6|(s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(l++))),c[A++]=t,64!==o&&(c[A++]=n),64!==s&&(c[A++]=i);return c}},{"./support":30,"./utils":32}],2:[function(e,t){function n(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}var i=e("./external"),r=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");n.prototype={getContentWorker:function(){var e=new r(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new r(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},n.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=n},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var i=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t){var n=e("./utils"),i=function(){for(var e,t=[],n=0;256>n;n++){e=n;for(var i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"===n.getTypeOf(e)?function(e,t,n){e^=-1;for(var r=0;r<0+n;r++)e=e>>>8^i[255&(e^t.charCodeAt(r))];return-1^e}(0|t,e,e.length):function(e,t,n){e^=-1;for(var r=0;r<0+n;r++)e=e>>>8^i[255&(e^t[r])];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t){var n;n="undefined"==typeof Promise?e("lie"):Promise,t.exports={Promise:n}},{lie:37}],7:[function(e,t,n){function i(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,a=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),l=r?"uint8array":"array";n.magic="\b\0",o.inherits(i,s),i.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(l,e.data),!1)},i.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},i.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},i.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new i("Deflate",e)},n.uncompressWorker=function(){return new i("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t){function n(e,t){var n,i="";for(n=0;n>>=8;return i}function i(e,t,i,r,o,s){var h,u,d=e.file,f=e.compression,p=s!==l.utf8encode,m=a.transformTo("string",s(d.name)),v=a.transformTo("string",l.utf8encode(d.name)),g=d.comment,y=a.transformTo("string",s(g)),w=a.transformTo("string",l.utf8encode(g)),x=v.length!==d.name.length,b=w.length!==g.length,M="",C="",B="",E=d.dir,S=d.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!i||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var _=0;t&&(_|=8),!p&&(x||b)&&(_|=2048);var I,L=0,F=0;E&&(L|=16),"UNIX"===o?(F=798,L|=((I=d.unixPermissions)||(I=E?16893:33204),(65535&I)<<16)):(F=20,L|=63&(d.dosPermissions||0)),h=S.getUTCHours(),h<<=6,h|=S.getUTCMinutes(),h<<=5,h|=S.getUTCSeconds()/2,u=S.getUTCFullYear()-1980,u<<=4,u|=S.getUTCMonth()+1,u<<=5,u|=S.getUTCDate(),x&&(M+="up"+n((C=n(1,1)+n(A(m),4)+v).length,2)+C),b&&(M+="uc"+n((B=n(1,1)+n(A(y),4)+w).length,2)+B);var k="";return k+="\n\0",k+=n(_,2),k+=f.magic,k+=n(h,2),k+=n(u,2),k+=n(T.crc32,4),k+=n(T.compressedSize,4),k+=n(T.uncompressedSize,4),k+=n(m.length,2),k+=n(M.length,2),{fileRecord:c.LOCAL_FILE_HEADER+k+m+M,dirRecord:c.CENTRAL_FILE_HEADER+n(F,2)+k+n(y.length,2)+"\0\0\0\0"+n(L,4)+n(r,4)+m+M+y}}function r(e,t,n,i){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}var a=e("../utils"),o=e("../stream/GenericWorker"),l=e("../utf8"),A=e("../crc32"),c=e("../signature");a.inherits(r,o),r.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))},r.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},r.prototype.closedSource=function(e){this.accumulate=!1;var t,r=this.streamFiles&&!e.file.dir,a=i(e,r,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(a.dirRecord),r)this.push({data:(t=e,c.DATA_DESCRIPTOR+n(t.crc32,4)+n(t.compressedSize,4)+n(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:a.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},r.prototype.flush=function(){for(var e=this.bytesWritten,t=0;te)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,n=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return i.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(127&e>>25),(15&e>>21)-1,31&e>>16,31&e>>11,63&e>>5,(31&e)<<1))}},t.exports=n},{"../utils":32}],19:[function(e,t){function n(e){i.call(this,e)}var i=e("./Uint8ArrayReader");e("../utils").inherits(n,i),n.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t){function n(e){i.call(this,e)}var i=e("./DataReader");e("../utils").inherits(n,i),n.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},n.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},n.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},n.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./DataReader":18}],21:[function(e,t){function n(e){i.call(this,e)}var i=e("./ArrayReader");e("../utils").inherits(n,i),n.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(e,t){var n=e("../utils"),i=e("../support"),r=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),s=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new s(n.transformTo("uint8array",e)):new r(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t){function n(e){i.call(this,"ConvertWorker to "+e),this.destType=e}var i=e("./GenericWorker"),r=e("../utils");r.inherits(n,i),n.prototype.processChunk=function(e){this.push({data:r.transformTo(this.destType,e.data),meta:e.meta})},t.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(e,t){function n(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}var i=e("./GenericWorker"),r=e("../crc32");e("../utils").inherits(n,i),n.prototype.processChunk=function(e){this.streamInfo.crc32=r(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t){function n(e){r.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}var i=e("../utils"),r=e("./GenericWorker");i.inherits(n,r),n.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}r.prototype.processChunk.call(this,e)},t.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(e,t){function n(e){r.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}var i=e("../utils"),r=e("./GenericWorker");i.inherits(n,r),n.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=l(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(e,t){function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=n},{}],29:[function(e,t){function n(e,t,n){var o=t;"blob"===t||"arraybuffer"===t?o="uint8array":"base64"===t&&(o="string");try{this._internalType=o,this._outputType=t,this._mimeType=n,i.checkSupport(o),this._worker=e.pipe(new r(o)),e.lock()}catch(n){this._worker=new a("error"),this._worker.error(n)}}var i=e("../utils"),r=e("./ConvertWorker"),a=e("./GenericWorker"),o=e("../base64"),s=e("../support"),l=e("../external"),c=null;if(s.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(n){}n.prototype={accumulate:function(e){return t=this,n=e,new l.Promise((function(e,r){var a=[],s=t._internalType,l=t._outputType,c=t._mimeType;t.on("data",(function(e,t){a.push(e),n&&n(t)})).on("error",(function(e){a=[],r(e)})).on("end",(function(){try{var t=function(e,t,n){return"blob"===e?i.newBlob(i.transformTo("arraybuffer",t),n):"base64"===e?o.encode(t):i.transformTo(e,t)}(l,function(e,t){var n,i=0,r=null,a=0;for(n=0;nc;c++)A[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;A[254]=A[254]=1,n.utf8encode=function(e){return o.nodebuffer?s.newBufferFrom(e,"utf-8"):function(e){var t,n,i,r,a,s=e.length,l=0;for(r=0;rn?1:2048>n?2:65536>n?3:4;for(t=o.uint8array?new Uint8Array(l):Array(l),r=a=0;an?t[a++]=n:(2048>n?t[a++]=192|n>>>6:(65536>n?t[a++]=224|n>>>12:(t[a++]=240|n>>>18,t[a++]=128|63&n>>>12),t[a++]=128|63&n>>>6),t[a++]=128|63&n);return t}(e)},n.utf8decode=function(e){return o.nodebuffer?a.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,r,o=e.length,s=Array(2*o);for(t=n=0;t(i=e[t++]))s[n++]=i;else if(4<(r=A[i]))s[n++]=65533,t+=r-1;else{for(i&=2===r?31:3===r?15:7;1i?s[n++]=i:(i-=65536,s[n++]=55296|1023&i>>10,s[n++]=56320|1023&i)}return s.length!==n&&(s.subarray?s=s.subarray(0,n):s.length=n),a.applyFromCharCode(s)}(e=a.transformTo(o.uint8array?"uint8array":"array",e))},a.inherits(i,l),i.prototype.processChunk=function(e){var t=a.transformTo(o.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var i=t;(t=new Uint8Array(i.length+this.leftOver.length)).set(this.leftOver,0),t.set(i,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var r=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return 0>n||0===n?t:n+A[e[n]]>t?n:t}(t),s=t;r!==t.length&&(o.uint8array?(s=t.subarray(0,r),this.leftOver=t.subarray(r,t.length)):(s=t.slice(0,r),this.leftOver=t.slice(r,t.length))),this.push({data:n.utf8decode(s),meta:e.meta})},i.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=i,a.inherits(r,l),r.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=r},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){function r(e){return e}function a(e,t){for(var n=0;n(t=e.charCodeAt(n))?"0":"")+t.toString(16).toUpperCase();return i},i.delay=function(e,t,n){d((function(){e.apply(n||null,t||[])}))},i.inherits=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},i.extend=function(){var e,t,n={};for(e=0;ee)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,0>(e=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR)))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),0>this.relativeOffsetEndOfZip64CentralDir))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var r=t-i;if(0r)throw new Error("Corrupted zip: missing "+n(r)+" bytes.")},prepareReader:function(e){this.reader=r(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=i},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(e,t){function n(e,t){this.options=e,this.loadOptions=t}var i=e("./reader/readerFor"),r=e("./utils"),a=e("./compressedObject"),o=e("./crc32"),s=e("./utf8"),l=e("./compressions"),A=e("./support");n.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in l)if(l.hasOwnProperty(t)&&l[t].magic===e)return l[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=65535&this.externalFileAttributes>>16),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=i(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,i,r=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4t.windowBits&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new A,this.strm.avail_out=0;var n=a.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(l[n]);if(t.header&&a.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(r="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=a.deflateSetDictionary(this.strm,r)))throw new Error(l[n]);this._dict_set=!0}}function r(e,t){var n=new i(t);if(n.push(e,!0),n.err)throw n.msg||l[n.err];return n.result}var a=e("./zlib/deflate"),o=e("./utils/common"),s=e("./utils/strings"),l=e("./zlib/messages"),A=e("./zlib/zstream"),c=Object.prototype.toString;i.prototype.push=function(e,t){var n,i,r=this.strm,l=this.options.chunkSize;if(this.ended)return!1;i=t===~~t?t:!0===t?4:0,r.input="string"==typeof e?s.string2buf(e):"[object ArrayBuffer]"===c.call(e)?new Uint8Array(e):e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new o.Buf8(l),r.next_out=0,r.avail_out=l),1!==(n=a.deflate(r,i))&&0!==n)return this.onEnd(n),!(this.ended=!0);0!==r.avail_out&&(0!==r.avail_in||4!==i&&2!==i)||("string"===this.options.to?this.onData(s.buf2binstring(o.shrinkBuf(r.output,r.next_out))):this.onData(o.shrinkBuf(r.output,r.next_out)))}while((0t.windowBits&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&16>t.windowBits)||e&&e.windowBits||(t.windowBits+=32),15t.windowBits&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=a.inflateInit2(this.strm,t.windowBits);if(n!==l.Z_OK)throw new Error(A[n]);this.header=new h,a.inflateGetHeader(this.strm,this.header)}function r(e,t){var n=new i(t);if(n.push(e,!0),n.err)throw n.msg||A[n.err];return n.result}var a=e("./zlib/inflate"),o=e("./utils/common"),s=e("./utils/strings"),l=e("./zlib/constants"),A=e("./zlib/messages"),c=e("./zlib/zstream"),h=e("./zlib/gzheader"),u=Object.prototype.toString;i.prototype.push=function(e,t){var n,i,r,A,c,h,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,m=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?l.Z_FINISH:l.Z_NO_FLUSH,d.input="string"==typeof e?s.binstring2buf(e):"[object ArrayBuffer]"===u.call(e)?new Uint8Array(e):e,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new o.Buf8(f),d.next_out=0,d.avail_out=f),(n=a.inflate(d,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&p&&(h="string"==typeof p?s.string2buf(p):"[object ArrayBuffer]"===u.call(p)?new Uint8Array(p):p,n=a.inflateSetDictionary(this.strm,h)),n===l.Z_BUF_ERROR&&!0===m&&(n=l.Z_OK,m=!1),n!==l.Z_STREAM_END&&n!==l.Z_OK)return this.onEnd(n),!(this.ended=!0);d.next_out&&(0!==d.avail_out&&n!==l.Z_STREAM_END&&(0!==d.avail_in||i!==l.Z_FINISH&&i!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(r=s.utf8border(d.output,d.next_out),A=d.next_out-r,c=s.buf2string(d.output,r),d.next_out=A,d.avail_out=f-A,A&&o.arraySet(d.output,d.output,r,A,0),this.onData(c)):this.onData(o.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(m=!0)}while((0t&&(e.subarray&&o||!e.subarray&&a))return s.apply(null,r.shrinkBuf(e,t));for(var n="",i=0;iA;A++)l[A]=252<=A?6:248<=A?5:240<=A?4:224<=A?3:192<=A?2:1;l[254]=l[254]=1,n.string2buf=function(e){var t,n,i,a,o,s=e.length,l=0;for(a=0;an?1:2048>n?2:65536>n?3:4;for(t=new r.Buf8(l),a=o=0;on?t[o++]=n:(2048>n?t[o++]=192|n>>>6:(65536>n?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|63&n>>>12),t[o++]=128|63&n>>>6),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return i(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n(a=e[n++]))A[r++]=a;else if(4<(o=l[a]))A[r++]=65533,n+=o-1;else{for(a&=2===o?31:3===o?15:7;1a?A[r++]=a:(a-=65536,A[r++]=55296|1023&a>>10,A[r++]=56320|1023&a)}return i(A,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return 0>n||0===n?t:n+l[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t){t.exports=function(e,t,n,i){for(var r=0|65535&e,a=0|65535&e>>>16,o=0;0!==n;){for(n-=o=2e3n;n++){e=n;for(var i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,i,r){e^=-1;for(var a=r;a>>8^n[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){function i(e,t){return e.msg=C[t],t}function r(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(w.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function s(e,t){x._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,o(e.strm)}function l(e,t){e.pending_buf[e.pending++]=t}function A(e,t){e.pending_buf[e.pending++]=255&t>>>8,e.pending_buf[e.pending++]=255&t}function c(e,t){var n,i,r=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,A=e.window,c=e.w_mask,h=e.prev,u=e.strstart+258,d=A[a+o-1],f=A[a+o];e.prev_length>=e.good_match&&(r>>=2),s>e.lookahead&&(s=e.lookahead);do{if(A[(n=t)+o]===f&&A[n+o-1]===d&&A[n]===A[a]&&A[++n]===A[a+1]){a+=2,n++;do{}while(A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&A[++a]===A[++n]&&al&&0!=--r);return o<=e.lookahead?o:e.lookahead}function h(e){var t,n,i,r,a,o,s,l,A,c,h=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=h+(h-262)){for(w.arraySet(e.window,e.window,h,h,0),e.match_start-=h,e.strstart-=h,e.block_start-=h,t=n=e.hash_size;i=e.head[--t],e.head[t]=h<=i?i-h:0,--n;);for(t=n=h;i=e.prev[--t],e.prev[t]=h<=i?i-h:0,--n;);r+=h}if(0===e.strm.avail_in)break;if(o=e.strm,s=e.window,l=e.strstart+e.lookahead,c=void 0,(A=r)<(c=o.avail_in)&&(c=A),n=0===c?0:(o.avail_in-=c,w.arraySet(s,o.input,o.next_in,c,l),1===o.state.wrap?o.adler=b(o.adler,s,c,l):2===o.state.wrap&&(o.adler=M(o.adler,s,c,l)),o.next_in+=c,o.total_in+=c,c),e.lookahead+=n,3<=e.lookahead+e.insert)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<e.lookahead+e.insert)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function u(e,t){for(var n,i;;){if(e.lookahead<262){if(h(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,3<=e.lookahead&&(e.ins_h=(e.ins_h<=e.match_length&&(1===e.strategy||3===e.match_length&&4096t.wrap&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,x._tr_init(t),0):i(e,-2)}function v(e){var t,n=m(e);return 0===n&&((t=e.state).window_size=2*t.w_size,a(t.head),t.max_lazy_match=y[t.level].max_lazy,t.good_match=y[t.level].good_length,t.nice_match=y[t.level].nice_length,t.max_chain_length=y[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function g(e,t,n,r,a,o){if(!e)return-2;var s=1;if(-1===t&&(t=6),0>r?(s=0,r=-r):15a||9r||15t||9o||4e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(1>=e.lookahead){if(h(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,s(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(s(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(s(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(s(e,!1),e.strm.avail_out),1)})),new f(4,4,8,4,u),new f(4,5,16,8,u),new f(4,6,32,32,u),new f(4,4,16,16,d),new f(8,16,32,32,d),new f(8,16,128,128,d),new f(8,32,128,256,d),new f(32,128,258,1024,d),new f(32,258,258,4096,d)],n.deflateInit=function(e,t){return g(e,t,8,15,8,0)},n.deflateInit2=g,n.deflateReset=v,n.deflateResetKeep=m,n.deflateSetHeader=function(e,t){return e&&e.state&&2===e.state.wrap?(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,c,u,d;if(!e||!e.state||5t)return e?i(e,-2):-2;if(c=e.state,!e.output||!e.input&&0!==e.avail_in||666===c.status&&4!==t)return i(e,0===e.avail_out?-5:-2);if(c.strm=e,n=c.last_flush,c.last_flush=t,42===c.status)if(2===c.wrap)e.adler=0,l(c,31),l(c,139),l(c,8),c.gzhead?(l(c,(c.gzhead.text?1:0)+(c.gzhead.hcrc?2:0)+(c.gzhead.extra?4:0)+(c.gzhead.name?8:0)+(c.gzhead.comment?16:0)),l(c,255&c.gzhead.time),l(c,255&c.gzhead.time>>8),l(c,255&c.gzhead.time>>16),l(c,255&c.gzhead.time>>24),l(c,9===c.level?2:2<=c.strategy||2>c.level?4:0),l(c,255&c.gzhead.os),c.gzhead.extra&&c.gzhead.extra.length&&(l(c,255&c.gzhead.extra.length),l(c,255&c.gzhead.extra.length>>8)),c.gzhead.hcrc&&(e.adler=M(e.adler,c.pending_buf,c.pending,0)),c.gzindex=0,c.status=69):(l(c,0),l(c,0),l(c,0),l(c,0),l(c,0),l(c,9===c.level?2:2<=c.strategy||2>c.level?4:0),l(c,3),c.status=113);else{var f=8+(c.w_bits-8<<4)<<8;f|=(2<=c.strategy||2>c.level?0:6>c.level?1:6===c.level?2:3)<<6,0!==c.strstart&&(f|=32),f+=31-f%31,c.status=113,A(c,f),0!==c.strstart&&(A(c,e.adler>>>16),A(c,65535&e.adler)),e.adler=1}if(69===c.status)if(c.gzhead.extra){for(u=c.pending;c.gzindex<(65535&c.gzhead.extra.length)&&(c.pending!==c.pending_buf_size||(c.gzhead.hcrc&&c.pending>u&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),o(e),u=c.pending,c.pending!==c.pending_buf_size));)l(c,255&c.gzhead.extra[c.gzindex]),c.gzindex++;c.gzhead.hcrc&&c.pending>u&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),c.gzindex===c.gzhead.extra.length&&(c.gzindex=0,c.status=73)}else c.status=73;if(73===c.status)if(c.gzhead.name){u=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>u&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),o(e),u=c.pending,c.pending===c.pending_buf_size)){d=1;break}d=c.gzindexu&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),0===d&&(c.gzindex=0,c.status=91)}else c.status=91;if(91===c.status)if(c.gzhead.comment){u=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>u&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),o(e),u=c.pending,c.pending===c.pending_buf_size)){d=1;break}d=c.gzindexu&&(e.adler=M(e.adler,c.pending_buf,c.pending-u,u)),0===d&&(c.status=103)}else c.status=103;if(103===c.status&&(c.gzhead.hcrc?(c.pending+2>c.pending_buf_size&&o(e),c.pending+2<=c.pending_buf_size&&(l(c,255&e.adler),l(c,255&e.adler>>8),e.adler=0,c.status=113)):c.status=113),0!==c.pending){if(o(e),0===e.avail_out)return c.last_flush=-1,0}else if(0===e.avail_in&&r(t)<=r(n)&&4!==t)return i(e,-5);if(666===c.status&&0!==e.avail_in)return i(e,-5);if(0!==e.avail_in||0!==c.lookahead||0!==t&&666!==c.status){var p=2===c.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(h(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=x._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(s(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(s(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?1:2}(c,t):3===c.strategy?function(e,t){for(var n,i,r,a,o=e.window;;){if(258>=e.lookahead){if(h(e),258>=e.lookahead&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,3<=e.lookahead&&0e.lookahead&&(e.match_length=e.lookahead)}if(3<=e.match_length?(n=x._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=x._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(s(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(s(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(s(e,!1),0===e.strm.avail_out)?1:2}(c,t):y[c.level].func(c,t);if(3!==p&&4!==p||(c.status=666),1===p||3===p)return 0===e.avail_out&&(c.last_flush=-1),0;if(2===p&&(1===t?x._tr_align(c):5!=t&&(x._tr_stored_block(c,0,0,!1),3==t&&(a(c.head),0===c.lookahead&&(c.strstart=0,c.block_start=0,c.insert=0))),o(e),0===e.avail_out))return c.last_flush=-1,0}return 4===t?0>=c.wrap?1:(2===c.wrap?(l(c,255&e.adler),l(c,255&e.adler>>8),l(c,255&e.adler>>16),l(c,255&e.adler>>24),l(c,255&e.total_in),l(c,255&e.total_in>>8),l(c,255&e.total_in>>16),l(c,255&e.total_in>>24)):(A(c,e.adler>>>16),A(c,65535&e.adler)),o(e),0=n.w_size&&(0===o&&(a(n.head),n.strstart=0,n.block_start=0,n.insert=0),c=new w.Buf8(n.w_size),w.arraySet(c,t,u-n.w_size,n.w_size,0),t=c,u=n.w_size),s=e.avail_in,l=e.next_in,A=e.input,e.avail_in=u,e.next_in=0,e.input=t,h(n);n.lookahead>=3;){for(i=n.strstart,r=n.lookahead-2;n.ins_h=(n.ins_h<f&&(d+=B[i++]<>>=w=y>>>24,f-=w,0==(w=255&y>>>16))E[a++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=p[(65535&y)+(d&(1<>>=w,f-=w),15>f&&(d+=B[i++]<>>=w=y>>>24,f-=w,!(16&(w=255&y>>>16))){if(0==(64&w)){y=m[(65535&y)+(d&(1<>>=w,f-=w,(w=a-o)>3,d&=(1<<(f-=x<<3))-1,e.next_in=i,e.next_out=a,e.avail_in=i>>24)+(65280&e>>>8)+((65280&e)<<8)+((255&e)<<24)}function r(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new f.Buf16(320),this.work=new f.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new f.Buf32(852),t.distcode=t.distdyn=new f.Buf32(592),t.sane=1,t.back=-1,0):-2}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):-2}function l(e,t){var n,i;return e&&e.state?(i=e.state,0>t?(n=0,t=-t):(n=1+(t>>4),48>t&&(t&=15)),t&&(8>t||15t;)e.lens[t++]=8;for(;256>t;)e.lens[t++]=9;for(;280>t;)e.lens[t++]=7;for(;288>t;)e.lens[t++]=8;for(g(1,e.lens,0,288,u,0,e.work,{bits:9}),t=0;32>t;)e.lens[t++]=5;g(2,e.lens,0,32,d,0,e.work,{bits:5}),y=!1}e.lencode=u,e.lenbits=9,e.distcode=d,e.distbits=5}function h(e,t,n,i){var r,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(f.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i<(r=a.wsize-a.wnext)&&(r=i),f.arraySet(a.window,t,n-i,r,a.wnext),(i-=r)?(f.arraySet(a.window,t,n-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whavey;){if(0===A)break e;A--,d+=r[o++]<>>8,n.check=m(n.check,D,2,0),y=d=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&d)){e.msg="unknown compression method",n.mode=30;break}if(y-=4,L=8+(15&(d>>>=4)),0===n.wbits)n.wbits=L;else if(L>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<y;){if(0===A)break e;A--,d+=r[o++]<>8),512&n.flags&&(D[0]=255&d,D[1]=255&d>>>8,n.check=m(n.check,D,2,0)),y=d=0,n.mode=3;case 3:for(;32>y;){if(0===A)break e;A--,d+=r[o++]<>>8,D[2]=255&d>>>16,D[3]=255&d>>>24,n.check=m(n.check,D,4,0)),y=d=0,n.mode=4;case 4:for(;16>y;){if(0===A)break e;A--,d+=r[o++]<>8),512&n.flags&&(D[0]=255&d,D[1]=255&d>>>8,n.check=m(n.check,D,2,0)),y=d=0,n.mode=5;case 5:if(1024&n.flags){for(;16>y;){if(0===A)break e;A--,d+=r[o++]<>>8,n.check=m(n.check,D,2,0)),y=d=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(A<(b=n.length)&&(b=A),b&&(n.head&&(L=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),f.arraySet(n.head.extra,r,o,b,L)),512&n.flags&&(n.check=m(n.check,r,b,o)),A-=b,o+=b,n.length-=b),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===A)break e;for(b=0;L=r[o+b++],n.head&&L&&65536>n.length&&(n.head.name+=s(L)),L&&bn.length&&(n.head.comment+=s(L)),L&&by;){if(0===A)break e;A--,d+=r[o++]<>9,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;32>y;){if(0===A)break e;A--,d+=r[o++]<>>=7&y,y-=7&y,n.mode=27;break}for(;3>y;){if(0===A)break e;A--,d+=r[o++]<>>=1)){case 0:n.mode=14;break;case 1:if(c(n),n.mode=20,6!==t)break;d>>>=2,y-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}d>>>=2,y-=2;break;case 14:for(d>>>=7&y,y-=7&y;32>y;){if(0===A)break e;A--,d+=r[o++]<>>16)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&d,y=d=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(b=n.length){if(Ay;){if(0===A)break e;A--,d+=r[o++]<>>=5,y-=5,n.ndist=1+(31&d),d>>>=5,y-=5,n.ncode=4+(15&d),d>>>=4,y-=4,286y;){if(0===A)break e;A--,d+=r[o++]<>>=3,y-=3}for(;19>n.have;)n.lens[R[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,k={bits:n.lenbits},F=g(0,n.lens,0,19,n.lencode,0,n.work,k),n.lenbits=k.bits,F){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16,S=65535&U,!((B=U>>>24)<=y);){if(0===A)break e;A--,d+=r[o++]<S)d>>>=B,y-=B,n.lens[n.have++]=S;else{if(16===S){for(P=B+2;y>>=B,y-=B,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}L=n.lens[n.have-1],b=3+(3&d),d>>>=2,y-=2}else if(17===S){for(P=B+3;y>>=B)),d>>>=3,y-=3}else{for(P=B+7;y>>=B)),d>>>=7,y-=7}if(n.have+b>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;b--;)n.lens[n.have++]=L}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,k={bits:n.lenbits},F=g(1,n.lens,0,n.nlen,n.lencode,0,n.work,k),n.lenbits=k.bits,F){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,k={bits:n.distbits},F=g(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,k),n.distbits=k.bits,F){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=A&&258<=u){e.next_out=l,e.avail_out=u,e.next_in=o,e.avail_in=A,n.hold=d,n.bits=y,v(e,x),l=e.next_out,a=e.output,u=e.avail_out,o=e.next_in,r=e.input,A=e.avail_in,d=n.hold,y=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;E=255&(U=n.lencode[d&(1<>>16,S=65535&U,!((B=U>>>24)<=y);){if(0===A)break e;A--,d+=r[o++]<>T)])>>>16,S=65535&U,!(T+(B=U>>>24)<=y);){if(0===A)break e;A--,d+=r[o++]<>>=T,y-=T,n.back+=T}if(d>>>=B,y-=B,n.back+=B,n.length=S,0===E){n.mode=26;break}if(32&E){n.back=-1,n.mode=12;break}if(64&E){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&E,n.mode=22;case 22:if(n.extra){for(P=n.extra;y>>=n.extra,y-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;E=255&(U=n.distcode[d&(1<>>16,S=65535&U,!((B=U>>>24)<=y);){if(0===A)break e;A--,d+=r[o++]<>T)])>>>16,S=65535&U,!(T+(B=U>>>24)<=y);){if(0===A)break e;A--,d+=r[o++]<>>=T,y-=T,n.back+=T}if(d>>>=B,y-=B,n.back+=B,64&E){e.msg="invalid distance code",n.mode=30;break}n.offset=S,n.extra=15&E,n.mode=24;case 24:if(n.extra){for(P=n.extra;y>>=n.extra,y-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===u)break e;if(b=x-u,n.offset>b){if((b=n.offset-b)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}M=b>n.wnext?(b-=n.wnext,n.wsize-b):n.wnext-b,b>n.length&&(b=n.length),C=n.window}else C=a,M=l-n.offset,b=n.length;for(uy;){if(0===A)break e;A--,d|=r[o++]<y;){if(0===A)break e;A--,d+=r[o++]<n.mode&&(27>n.mode||4!==t))&&h(e,e.output,e.next_out,x-e.avail_out)?(n.mode=31,-4):(w-=e.avail_in,x-=e.avail_out,e.total_in+=w,e.total_out+=x,n.total+=x,n.wrap&&x&&(e.adler=n.check=n.flags?m(n.check,a,x,e.next_out-x):p(n.check,a,x,e.next_out-x)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==w&&0===x||4===t)&&0===F&&(F=-5),F)},n.inflateEnd=function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state?0==(2&(n=e.state).wrap)?-2:((n.head=t).done=!1,0):-2},n.inflateSetDictionary=function(e,t){var n,i=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&p(1,t,i,0)!==n.check?-3:h(e,t,i,i)?(n.mode=31,-4):(n.havedict=1,0):-2},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t){var n=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],r=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,s,l,A,c,h,u){var d,f,p,m,v,g,y,w,x,b=u.bits,M=0,C=0,B=0,E=0,S=0,T=0,_=0,I=0,L=0,F=0,k=null,P=0,U=new n.Buf16(16),D=new n.Buf16(16),R=null,O=0;for(M=0;15>=M;M++)U[M]=0;for(C=0;C=M;M++)if(I<<=1,0>(I-=U[M]))return-1;if(0M;M++)D[M+1]=D[M]+U[M];for(C=0;Cg?(w=R[O+h[C]],k[P+h[C]]):(w=96,0),d=1<>_)+(f-=d)]=y<<24|w<<16|x|0,0!==f;);for(d=1<>=1;if(0===d?F=0:(F&=d-1,F+=d),C++,0==--U[M]){if(M===E)break;M=t[s+h[C]]}if(S=(I-=U[T+_]));)T++,I<<=1;if(L+=1<e?T[e]:T[256+(e>>>7)]}function s(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=255&t>>>8}function l(e,t,n){e.bi_valid>16-n?(e.bi_buf|=65535&t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=65535&t<>>=1,n<<=1,0<--t;);return n>>>1}function h(e,t,n){var i,r,a=Array(16),o=0;for(i=1;i<=15;i++)a[i]=o=o+n[i-1]<<1;for(r=0;r<=t;r++){var s=e[2*r+1];0!==s&&(e[2*r]=c(a[s]++,s))}}function u(e){var t;for(t=0;286>t;t++)e.dyn_ltree[2*t]=0;for(t=0;30>t;t++)e.dyn_dtree[2*t]=0;for(t=0;19>t;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function d(e){8e.heap_len;)a[2*(r=e.heap[++e.heap_len]=2>A?++A:0)]=1,e.depth[r]=0,e.opt_len--,s&&(e.static_len-=o[2*r+1]);for(t.max_code=A,n=e.heap_len>>1;1<=n;n--)p(e,a,n);for(r=l;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],p(e,a,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,a[2*r]=a[2*n]+a[2*i],e.depth[r]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,a[2*n+1]=a[2*i+1]=r,e.heap[1]=r++,p(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,i,r,a,o,s,l=t.dyn_tree,A=t.max_code,c=t.stat_desc.static_tree,h=t.stat_desc.has_stree,u=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,f=t.stat_desc.max_length,p=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;573>n;n++)f<(a=l[2*l[2*(i=e.heap[n])+1]+1]+1)&&(a=f,p++),l[2*i+1]=a,A=s?e.bl_tree[34]++:e.bl_tree[36]++:(r!==a&&e.bl_tree[2*r]++,e.bl_tree[32]++),a=r,A=(s=0)===o?(l=138,3):r===o?(l=6,3):(l=7,4))}function y(e,t,n){var i,r,a=-1,o=t[1],s=0,c=7,h=4;for(0===o&&(c=138,h=3),i=0;i<=n;i++)if(r=o,o=t[2*(i+1)+1],!(++s=s?(A(e,17,e.bl_tree),l(e,s-3,3)):(A(e,18,e.bl_tree),l(e,s-11,7)):(r!==a&&(A(e,r,e.bl_tree),s--),A(e,16,e.bl_tree),l(e,s-3,2));a=r,h=(s=0)===o?(c=138,3):r===o?(c=6,3):(c=7,4)}}function w(e,t,n,i){var r,a,o;l(e,0+(i?1:0),3),a=t,o=n,d(r=e),s(r,o),s(r,~o),x.arraySet(r.pending_buf,r.window,a,o,r.pending),r.pending+=o}var x=e("../utils/common"),b=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E=Array(576);i(E);var S=Array(60);i(S);var T=Array(512);i(T);var _=Array(256);i(_);var I=Array(29);i(I);var L,F,k,P=Array(30);i(P);var U=!1;n._tr_init=function(e){U||(function(){var e,t,n,i,a,o=Array(16);for(i=n=0;28>i;i++)for(I[i]=n,e=0;e<1<i;i++)for(P[i]=a,e=0;e<1<>=7;30>i;i++)for(P[i]=a<<7,e=0;e<1<=e;)E[2*e+1]=8,e++,o[8]++;for(;255>=e;)E[2*e+1]=9,e++,o[9]++;for(;279>=e;)E[2*e+1]=7,e++,o[7]++;for(;287>=e;)E[2*e+1]=8,e++,o[8]++;for(h(E,287,o),e=0;30>e;e++)S[2*e+1]=5,S[2*e]=c(e,5);L=new r(E,b,257,286,15),F=new r(S,M,0,30,15),k=new r([],C,0,19,7)}(),U=!0),e.l_desc=new a(e.dyn_ltree,L),e.d_desc=new a(e.dyn_dtree,F),e.bl_desc=new a(e.bl_tree,k),e.bi_buf=0,e.bi_valid=0,u(e)},n._tr_stored_block=w,n._tr_flush_block=function(e,t,n,i){var r,a,o=0;0=t;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;256>t;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),v(e,e.l_desc),v(e,e.d_desc),o=function(e){var t;for(g(e,e.dyn_ltree,e.l_desc.max_code),g(e,e.dyn_dtree,e.d_desc.max_code),v(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*B[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=r&&(r=a)):r=a=n+5,n+4<=r&&-1!==t?w(e,t,n,i):4===e.strategy||a===r?(l(e,2+(i?1:0),3),m(e,E,S)):(l(e,4+(i?1:0),3),function(e,t,n,i){var r;for(l(e,t-257,5),l(e,n-1,5),l(e,i-4,4),r=0;r>>8,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(_[n]+256+1)]++,e.dyn_dtree[2*o(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){var t;l(e,2,3),A(e,256,E),16===(t=e).bi_valid?(s(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t){t.exports="function"==typeof c?c:function(){var e=[].slice.apply(arguments);e.splice(1,0,0),setTimeout.apply(null,e)}},{}]},{},[10])(10)}))}).call(this,void 0===o?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:o)},{}]},{},[1])(1)}))}).call(this,void 0===o?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:o)},{}]},{},[1])(1)}))}).call(this,void 0===o?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:o)},{}]},{},[1])(1)}))}).call(this,void 0===o?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:o)},{}]},{},[1])(1)}))}).call(this,void 0===o?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:o)},{}]},{},[1])(1)}))}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,t("buffer").Buffer,t("timers").setImmediate)},{buffer:8,timers:22}],12:[function(e,t){function n(){}function i(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,e!==n&&l(this,e)}function a(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function o(e,t,n){c((function(){var i;try{i=t(n)}catch(t){return h.reject(e,t)}i===e?h.reject(e,new TypeError("Cannot resolve promise with itself")):h.resolve(e,i)}))}function s(e){var t=e&&e.then;if(e&&("object"==r(e)||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function l(e,t){function n(t){r||(r=!0,h.reject(e,t))}function i(t){r||(r=!0,h.resolve(e,t))}var r=!1,a=A((function(){t(i,n)}));"error"===a.status&&n(a.value)}function A(e,t){var n={};try{n.value=e(t),n.status="success"}catch(t){n.status="error",n.value=t}return n}var c=e("immediate"),h={},u=["REJECTED"],d=["FULFILLED"],f=["PENDING"];t.exports=i,i.prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))},i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){if("function"!=typeof e&&this.state===d||"function"!=typeof t&&this.state===u)return this;var i=new this.constructor(n);this.state!==f?o(i,this.state===d?e:t,this.outcome):this.queue.push(new a(i,e,t));return i},a.prototype.callFulfilled=function(e){h.resolve(this.promise,e)},a.prototype.otherCallFulfilled=function(e){o(this.promise,this.onFulfilled,e)},a.prototype.callRejected=function(e){h.reject(this.promise,e)},a.prototype.otherCallRejected=function(e){o(this.promise,this.onRejected,e)},h.resolve=function(e,t){var n=A(s,t);if("error"===n.status)return h.reject(e,n.value);var i=n.value;if(i)l(e,i);else{e.state=d,e.outcome=t;for(var r=-1,a=e.queue.length;++r=this._max)&&(this._max=1/0),this._lengthCalculator=e.length||n,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=n),this._allowStale=e.stale||!1,this._maxAge=e.maxAge||null,this._dispose=e.dispose,void this.reset()):new a(e)}function o(e,t,n){i(t);var r=e._cache[t];return r&&(s(e,r)?(c(e,r),!e._allowStale&&(r=void 0)):n&&function(e,t){A(e,t),t.lu=e._mru++,e._lruList[t.lu]=t}(e,r),r&&(r=r.value)),r}function s(e,t){if(!t||!t.maxAge&&!e._maxAge)return!1;var n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e._maxAge&&n>e._maxAge}function l(e){for(;e._lrue._max;)c(e,e._lruList[e._lru])}function A(e,t){for(delete e._lruList[t.lu];e._lru=e)||(e=1/0),this._max=e,this._length>this._max&&l(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(a.prototype,"lengthCalculator",{set:function(e){if("function"!=typeof e)for(var t in this._lengthCalculator=n,this._length=this._itemCount,this._cache)this._cache[t].length=1;else for(var t in this._lengthCalculator=e,this._length=0,this._cache)this._cache[t].length=this._lengthCalculator(this._cache[t].value),this._length+=this._cache[t].length;this._length>this._max&&l(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(a.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(a.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),a.prototype.forEach=function(e,t){t=t||this;for(var n=0,i=this._itemCount,r=this._mru-1;0<=r&&nthis._max?(c(this,this._cache[t]),!1):(this._dispose&&this._dispose(t,this._cache[t].value),this._cache[t].now=a,this._cache[t].maxAge=r,this._cache[t].value=n,this._length+=o-this._cache[t].length,this._cache[t].length=o,this.get(t),this._length>this._max&&l(this),!0);var s=new h(t,n,this._mru++,o,a,r);return s.length>this._max?(this._dispose&&this._dispose(t,n),!1):(this._length+=s.length,this._lruList[s.lu]=this._cache[t]=s,this._itemCount++,this._length>this._max&&l(this),!0)},a.prototype.has=function(t){return i(t),!!e(this._cache,t)&&!s(this,this._cache[t])},a.prototype.get=function(e){return i(e),o(this,e,!0)},a.prototype.peek=function(e){return i(e),o(this,e,!1)},a.prototype.pop=function(){var e=this._lruList[this._lru];return c(this,e),e||null},a.prototype.del=function(e){i(e),c(this,this._cache[e])},a.prototype.load=function(e){this.reset();for(var t,n=Date.now(),r=e.length-1;0<=r;r--){i((t=e[r]).k);var a=t.e||0;if(0===a)this.set(t.k,t.v);else{var o=a-n;0-1.001*ce)s=-ce;else if(s>ce&&s<1.001*ce)s=ce;else{if(s<-ce)return{x:-1/0,y:-1/0,z:e.z};if(s>ce)return{x:1/0,y:1/0,z:e.z}}return o>u&&(o-=2*u),r=m(s),a=v(s),{x:((i=n/g(1-t*(r*r)))+l)*a*v(o),y:(i+l)*a*m(o),z:(i*(1-t)+l)*r}}function O(e,t,i,r){var a,o,s,l,A,h,u,f,p,m,v,y,w,x,b,M=1e-12,C=e.x,B=e.y,E=e.z?e.z:0;if(a=g(C*C+B*B),o=g(C*C+B*B+E*E),a/iM*M&&w<30);return{x:x,y:d(v/n(m)),z:b}}function N(e){return 1===e||2===e}function z(e,t,i){if(null===e.grids||0===e.grids.length)return console.log("Grid shift grids not found"),-1;for(var r,a={x:-i.x,y:i.y},o={x:A,y:A},s=[],l=0;la.y||u>a.x||p1e-12&&n(s.y)>1e-12);if(0>c)return console.log("Inverse grid shift iterator failed to converge."),r;r.x=ke(o.x+i.ll[0]),r.y=o.y+i.ll[1]}else isNaN(o.x)||(r.x=e.x+o.x,r.y=e.y+o.y);return r}function G(t,n){var i,r={x:t.x/n.del[0],y:t.y/n.del[1]},a=e(r.x),o=e(r.y),s=r.x-1*a,l=r.y-1*o,c={x:A,y:A};if(0>a||a>=n.lim[0])return c;if(0>o||o>=n.lim[1])return c;i=o*n.lim[0]+a;var h=n.cvs[i][0],u=n.cvs[i][1];i++;var d=n.cvs[i][0],f=n.cvs[i][1];i+=n.lim[0];var p=n.cvs[i][0],m=n.cvs[i][1];i--;var v=n.cvs[i][0],g=n.cvs[i][1],y=s*l,w=s*(1-l),x=(1-s)*(1-l),b=(1-s)*l;return c.x=x*h+w*d+b*v+y*p,c.y=x*u+w*f+b*g+y*m,c}function H(e){var t=Number.isFinite;if("function"==typeof t){if(t(e))return;throw new TypeError("coordinates must be finite numbers")}if("number"!=typeof e||e!=e||!isFinite(e))throw new TypeError("coordinates must be finite numbers")}function V(e,t,n){var i;if(Array.isArray(n)&&(n=je(n)),We(n),e.datum&&t.datum&&function(e,t){return(1===e.datum.datum_type||2===e.datum.datum_type)&&"WGS84"!==t.datumCode||(1===t.datum.datum_type||2===t.datum.datum_type)&&"WGS84"!==e.datumCode}(e,t)&&(n=V(e,i=new U("WGS84"),n),e=i),"enu"!==e.axis&&(n=Ve(e,!1,n)),"longlat"===e.projName)n={x:n.x*pe,y:n.y*pe,z:n.z||0};else if(e.to_meter&&(n={x:n.x*e.to_meter,y:n.y*e.to_meter,z:n.z||0}),!(n=e.inverse(n)))return;return e.from_greenwich&&(n.x+=e.from_greenwich),(n=He(e.datum,t.datum,n))?(t.from_greenwich&&(n={x:n.x-t.from_greenwich,y:n.y,z:n.z||0}),"longlat"===t.projName?n={x:n.x*me,y:n.y*me,z:n.z||0}:(n=t.forward(n),t.to_meter&&(n={x:n.x/t.to_meter,y:n.y/t.to_meter,z:n.z||0})),"enu"===t.axis?n:Ve(t,!0,n)):void 0}function j(e,t,n){var i,r,a;return Array.isArray(n)?(i=V(e,t,n)||{x:NaN,y:NaN},2l&&3<=A&&12>A&&(s=32),72<=l&&84>l&&(0<=A&&9>A?s=31:9<=A&&21>A?s=33:21<=A&&33>A?s=35:33<=A&&42>A&&(s=37)),n=u/(1-u),i=c/g(1-u*m(f)*m(f)),r=p(f)*p(f),a=n*v(f)*v(f),o=c*((1-u/4-3*u*u/64-5*u*u*u/256)*f-(3*u/8+3*u*u/32+45*u*u*u/1024)*m(2*f)+(15*u*u/256+45*u*u*u/1024)*m(4*f)-35*u*u*u/3072*m(6*f));var y=d*i*(65+65*(1-r+a)*65*65/6+65*(5-18*r+r*r+72*a-58*n)*65*65*65*65/120)+5e5,w=d*(o+i*p(f)*(2112.5+65*(5-r+9*a+4*a*a)*65*65*65/24+65*(61-58*r+r*r+600*a-330*n)*65*65*65*65*65/720));return 0>l&&(w+=1e7),{northing:h(w),easting:h(y),zoneNumber:s,zoneLetter:$(l)}}({lat:t[1],lon:t[0]}),n)}function K(e){var t=q(ne(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function Z(e){return e*(u/180)}function J(e){return e/u*180}function q(e){var t=e.northing,n=e.easting,i=e.zoneLetter,r=e.zoneNumber;if(0>r||60i&&(M-=1e7),u=6*(r-1)-180+3,o=x/(1-x),f=(d=M/y/6367449.145945056)+(3*b/2-27*b*b*b/32)*m(2*d)+(21*b*b/16-55*b*b*b*b/32)*m(4*d)+151*b*b*b/96*m(6*d),s=w/g(1-x*m(f)*m(f)),l=p(f)*p(f),A=o*v(f)*v(f),c=w*(1-x)/a(1-x*m(f)*m(f),1.5),h=(n-5e5)/(s*y);var C=f-s*p(f)/c*(h*h/2-(5+3*l+10*A-4*A*A-9*o)*h*h*h*h/24+(61+90*l+298*A+45*l*l-252*o-3*A*A)*h*h*h*h*h*h/720);C=J(C);var B,E=(h-(1+2*l+A)*h*h*h/6+(5-2*A+28*l-3*A*A+8*o+24*l*l)*h*h*h*h*h/120)/v(f);if(E=u+J(E),e.accuracy){var S=q({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});B={top:S.lat,right:S.lon,bottom:C,left:E}}else B={lat:C,lon:E};return B}function $(e){var t="Z";return 84>=e&&72<=e?t="X":72>e&&64<=e?t="W":64>e&&56<=e?t="V":56>e&&48<=e?t="U":48>e&&40<=e?t="T":40>e&&32<=e?t="S":32>e&&24<=e?t="R":24>e&&16<=e?t="Q":16>e&&8<=e?t="P":8>e&&0<=e?t="N":0>e&&-8<=e?t="M":-8>e&&-16<=e?t="L":-16>e&&-24<=e?t="K":-24>e&&-32<=e?t="J":-32>e&&-40<=e?t="H":-40>e&&-48<=e?t="G":-48>e&&-56<=e?t="F":-56>e&&-64<=e?t="E":-64>e&&-72<=e?t="D":-72>e&&-80<=e&&(t="C"),t}function ee(t,n,i){var r=te(i);return function(e,t,n){var i=n-1,r="AJSAJS".charCodeAt(i),a="AFAFAF".charCodeAt(i),o=r+e-1,l=a+t,A=!1;return 90r&&73r)&&A)&&o++,(79===o||79>r&&79r)&&A)&&73==++o&&o++,90a&&73a)&&A)&&l++,(79===l||79>a&&79a)&&A)&&73==++l&&l++,86n)throw"MGRSPoint bad conversion from: "+e;var l=e.charAt(o++);if("A">=l||"B"===l||"Y"===l||"Z"<=l||"I"===l||"O"===l)throw"MGRSPoint zone letter "+l+" not handled: "+e;i=e.substring(o,o+=2);for(var A=te(s),c=function(e,t){for(var n="AJSAJS".charCodeAt(t-1),i=1e5,r=!1;n!==e.charCodeAt(0);){if(73===++n&&n++,79===n&&n++,90ve&&a<=ce+ve?(r.value=tn.AREA_1,a-=ce):a>ce+ve||a<=-(ce+ve)?(r.value=tn.AREA_2,a=0<=a?a-ye:a+ye):(r.value=tn.AREA_3,a+=ce)),a}function oe(e,t){var n=e+t;return n<-ye?n+=ge:n>+ye&&(n-=ge),n}var se=6378137,le=.0066943799901413165,Ae=484813681109536e-20,ce=u/2,he=.16666666666666666,ue=.04722222222222222,de=.022156084656084655,fe=1e-10,pe=.017453292519943295,me=57.29577951308232,ve=u/4,ge=2*u,ye=3.14159265359,we={greenwich:0,lisbon:-9.131906111111,paris:2.337229166667,bogota:-74.080916666667,madrid:-3.687938888889,rome:12.452333333333,bern:7.439583333333,jakarta:106.807719444444,ferro:-17.666666666667,brussels:4.367975,stockholm:18.058277777778,athens:23.7163375,oslo:10.722916666667},xe={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}},be=/[\s_\-\/\(\)]/g,Me=function(e){var t,n,i,r={},a=e.split("+").map((function(e){return e.trim()})).filter((function(e){return e})).reduce((function(e,t){var n=t.split("=");return n.push(!0),e[n[0].toLowerCase()]=n[1],e}),{}),o={proj:"projName",datum:"datumCode",rf:function(e){r.rf=parseFloat(e)},lat_0:function(e){r.lat0=e*pe},lat_1:function(e){r.lat1=e*pe},lat_2:function(e){r.lat2=e*pe},lat_ts:function(e){r.lat_ts=e*pe},lon_0:function(e){r.long0=e*pe},lon_1:function(e){r.long1=e*pe},lon_2:function(e){r.long2=e*pe},alpha:function(e){r.alpha=parseFloat(e)*pe},gamma:function(e){r.rectified_grid_angle=parseFloat(e)},lonc:function(e){r.longc=e*pe},x_0:function(e){r.x0=parseFloat(e)},y_0:function(e){r.y0=parseFloat(e)},k_0:function(e){r.k0=parseFloat(e)},k:function(e){r.k0=parseFloat(e)},a:function(e){r.a=parseFloat(e)},b:function(e){r.b=parseFloat(e)},r_a:function(){r.R_A=!0},zone:function(e){r.zone=parseInt(e,10)},south:function(){r.utmSouth=!0},towgs84:function(e){r.datum_params=e.split(",").map((function(e){return parseFloat(e)}))},to_meter:function(e){r.to_meter=parseFloat(e)},units:function(e){r.units=e;var t=y(xe,e);t&&(r.to_meter=t.to_meter)},from_greenwich:function(e){r.from_greenwich=e*pe},pm:function(e){var t=y(we,e);r.from_greenwich=(t||parseFloat(e))*pe},nadgrids:function(e){"@null"===e?r.datumCode="none":r.nadgrids=e},axis:function(e){3===e.length&&-1!=="ewnsud".indexOf(e.substr(0,1))&&-1!=="ewnsud".indexOf(e.substr(1,1))&&-1!=="ewnsud".indexOf(e.substr(2,1))&&(r.axis=e)},approx:function(){r.approx=!0}};for(t in a)n=a[t],t in o?"function"==typeof(i=o[t])?i(n):r[i]=n:r[t]=n;return"string"==typeof r.datumCode&&"WGS84"!==r.datumCode&&(r.datumCode=r.datumCode.toLowerCase()),r},Ce=/[,\]]/,Be=/[\d\.E\-\+]/;w.prototype.readCharicter=function(){var e=this.text[this.place++];if(4!==this.state)for(;/\s/.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case 1:return this.neutral(e);case 2:return this.keyword(e);case 4:return this.quoted(e);case 5:return this.afterquote(e);case 3:return this.number(e)}},w.prototype.afterquote=function(e){if('"'===e)return this.word+='"',void(this.state=4);if(Ce.test(e))return this.word=this.word.trim(),void this.afterItem(e);throw new Error("havn't handled \""+e+'" in afterquote yet, index '+this.place)},w.prototype.afterItem=function(e){return","===e?(null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=1)):"]"===e?(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=1,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},w.prototype.number=function(e){if(!Be.test(e)){if(Ce.test(e))return this.word=parseFloat(this.word),void this.afterItem(e);throw new Error("havn't handled \""+e+'" in number yet, index '+this.place)}this.word+=e},w.prototype.quoted=function(e){return'"'===e?void(this.state=5):void(this.word+=e)},w.prototype.keyword=function(e){if(/[A-Za-z84]/.test(e))this.word+=e;else{if("["===e){var t=[];return t.push(this.word),this.level++,null===this.root?this.root=t:this.currentObject.push(t),this.stack.push(this.currentObject),this.currentObject=t,void(this.state=1)}if(!Ce.test(e))throw new Error("havn't handled \""+e+'" in keyword yet, index '+this.place);this.afterItem(e)}},w.prototype.neutral=function(e){if(/[A-Za-z]/.test(e))return this.word=e,void(this.state=2);if('"'===e)return this.word="",void(this.state=4);if(Be.test(e))return this.word=e,void(this.state=3);if(!Ce.test(e))throw new Error("havn't handled \""+e+'" in neutral yet, index '+this.place);this.afterItem(e)},w.prototype.output=function(){for(;this.placee?-1:1},ke=function(e){return n(e)<=ye?e:e-Fe(e)*ge},Pe=function(e,t,n){var i=e*n;return i=a((1-i)/(1+i),.5*e),p(.5*(ce-t))/i},Ue=function(e,t){for(var i,r,o=ce-2*d(t),s=0;15>=s;s++)if(i=e*m(o),o+=r=ce-2*d(t*a((1-i)/(1+i),.5*e))-o,1e-10>=n(r))return o;return-9999},De=[{init:function(){var e=this.b/this.a;this.es=1-e*e,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=g(this.es),this.lat_ts?this.sphere?this.k0=v(this.lat_ts):this.k0=Le(this.e,m(this.lat_ts),v(this.lat_ts)):!this.k0&&(this.k?this.k0=this.k:this.k0=1)},forward:function(e){var i,r,a=e.x,o=e.y;if(90o*me&&180a*me)return null;if(n(n(o)-ce)<=fe)return null;if(this.sphere)i=this.x0+this.a*this.k0*ke(a-this.long0),r=this.y0+this.a*this.k0*t(p(ve+.5*o));else{var s=m(o),l=Pe(this.e,o,s);i=this.x0+this.a*this.k0*ke(a-this.long0),r=this.y0-this.a*this.k0*t(l)}return e.x=i,e.y=r,e},inverse:function(e){var t,n,i=e.x-this.x0,r=e.y-this.y0;if(this.sphere)n=ce-2*d(f(-r/(this.a*this.k0)));else{var a=f(-r/(this.a*this.k0));if(-9999===(n=Ue(this.e,a)))return null}return t=ke(this.long0+i/(this.a*this.k0)),e.x=t,e.y=n,e},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:E,inverse:E,names:["longlat","identity"]}],Re={},Oe=[],Ne={MERIT:{a:6378137,rf:298.257,ellipseName:"MERIT 1983"},SGS85:{a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},GRS80:{a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},IAU76:{a:6378140,rf:298.257,ellipseName:"IAU 1976"},airy:{a:6377563.396,b:6356256.91,ellipseName:"Airy 1830"},APL4:{a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},NWL9D:{a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},mod_airy:{a:6377340.189,b:6356034.446,ellipseName:"Modified Airy"},andrae:{a:6377104.43,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},aust_SA:{a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},GRS67:{a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},bessel:{a:6377397.155,rf:299.1528128,ellipseName:"Bessel 1841"},bess_nam:{a:6377483.865,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},clrk66:{a:6378206.4,b:6356583.8,ellipseName:"Clarke 1866"},clrk80:{a:6378249.145,rf:293.4663,ellipseName:"Clarke 1880 mod."},clrk58:{a:6378293.645208759,rf:294.2606763692654,ellipseName:"Clarke 1858"},CPM:{a:6375738.7,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},delmbr:{a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},engelis:{a:6378136.05,rf:298.2566,ellipseName:"Engelis 1985"},evrst30:{a:6377276.345,rf:300.8017,ellipseName:"Everest 1830"},evrst48:{a:6377304.063,rf:300.8017,ellipseName:"Everest 1948"},evrst56:{a:6377301.243,rf:300.8017,ellipseName:"Everest 1956"},evrst69:{a:6377295.664,rf:300.8017,ellipseName:"Everest 1969"},evrstSS:{a:6377298.556,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},fschr60:{a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},fschr60m:{a:6378155,rf:298.3,ellipseName:"Fischer 1960"},fschr68:{a:6378150,rf:298.3,ellipseName:"Fischer 1968"},helmert:{a:6378200,rf:298.3,ellipseName:"Helmert 1906"},hough:{a:6378270,rf:297,ellipseName:"Hough"},intl:{a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},kaula:{a:6378163,rf:298.24,ellipseName:"Kaula 1961"},lerch:{a:6378139,rf:298.257,ellipseName:"Lerch 1979"},mprts:{a:6397300,rf:191,ellipseName:"Maupertius 1738"},new_intl:{a:6378157.5,b:6356772.2,ellipseName:"New International 1967"},plessis:{a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},krass:{a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},SEasia:{a:6378155,b:6356773.3205,ellipseName:"Southeast Asia"},walbeck:{a:6376896,b:6355834.8467,ellipseName:"Walbeck"},WGS60:{a:6378165,rf:298.3,ellipseName:"WGS 60"},WGS66:{a:6378145,rf:298.25,ellipseName:"WGS 66"},WGS7:{a:6378135,rf:298.26,ellipseName:"WGS 72"}},ze=Ne.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};Ne.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var Qe={wgs84:{towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},ch1903:{towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},ggrs87:{towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},nad83:{towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},nad27:{nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},potsdam:{towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},carthage:{towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},hermannskogel:{towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},osni52:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},ire65:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},rassadiran:{towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},nzgd49:{towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},osgb36:{towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},s_jtsk:{towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},beduaram:{towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},gunung_segara:{towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},rnb72:{towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"}},Ge={};U.projections={start:function(){De.forEach(S)},add:S,get:function(e){if(!e)return!1;var t=e.toLowerCase();return void 0!==Re[t]&&Oe[Re[t]]?Oe[Re[t]]:void 0}},U.projections.start();var He=function(e,t,n){if(D(e,t))return n;if(5===e.datum_type||5===t.datum_type)return n;var i=e.a,r=e.es;if(3===e.datum_type){if(0!==z(e,!1,n))return;i=se,r=le}var a=t.a,o=t.b,s=t.es;if(3===t.datum_type&&(a=se,o=6356752.314,s=le),r===s&&i===a&&!N(e.datum_type)&&!N(t.datum_type))return n;if((n=R(n,r,i),N(e.datum_type)&&(n=function(e,t,n){if(1===t)return{x:e.x+n[0],y:e.y+n[1],z:e.z+n[2]};if(2===t){var i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6];return{x:A*(e.x-l*e.y+s*e.z)+i,y:A*(l*e.x+e.y-o*e.z)+r,z:A*(-s*e.x+o*e.y+e.z)+a}}}(n,e.datum_type,e.datum_params)),N(t.datum_type)&&(n=function(e,t,n){if(1===t)return{x:e.x-n[0],y:e.y-n[1],z:e.z-n[2]};if(2===t){var i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],A=n[6],c=(e.x-i)/A,h=(e.y-r)/A,u=(e.z-a)/A;return{x:c+l*h-s*u,y:-l*c+h+o*u,z:s*c-o*h+u}}}(n,t.datum_type,t.datum_params)),n=O(n,s,a,o),3===t.datum_type)&&0!==z(t,!0,n))return;return n},Ve=function(e,t,n){var i,r,a,o=n.x,s=n.y,l=n.z||0,A={};for(a=0;3>a;a++)if(!t||2!==a||void 0!==n.z)switch(0===a?(i=o,r=-1==="ew".indexOf(e.axis[a])?"y":"x"):1===a?(i=s,r=-1==="ns".indexOf(e.axis[a])?"x":"y"):(i=l,r="z"),e.axis[a]){case"e":case"n":A[r]=i;break;case"w":case"s":A[r]=-i;break;case"u":void 0!==n[r]&&(A.z=i);break;case"d":void 0!==n[r]&&(A.z=-i);break;default:return null}return A},je=function(e){var t={x:e[0],y:e[1]};return 2fe?p(A):0,b=a(x,2),M=a(b,2);i=1-this.es*a(h,2),d/=g(i);var C=qe(A,h,u,this.en);r=this.a*(this.k0*d*(1+f/6*(1-b+y+f/20*(5-18*b+M+14*y-58*b*y+f/42*(61+179*M-M*b-479*b)))))+this.x0,s=this.a*(this.k0*(C-this.ml0+h*c*d/2*(1+f/12*(5-b+9*y+4*w+f/30*(61+M-58*b+270*y-330*b*y+f/56*(1385+543*M-M*b-3111*b))))))+this.y0}else{var B=u*m(c);if(n(n(B)-1)fe)return 93;s=0}else s=o(s);0>A&&(s=-s),s=this.a*this.k0*(s-this.lat0)+this.y0}return e.x=r,e.y=s,e},inverse:function(e){var t,r,o,s,l=(e.x-this.x0)*(1/this.a),A=(e.y-this.y0)*(1/this.a);if(this.es)if(t=this.ml0+A/this.k0,r=$e(t,this.es,this.en),n(r)fe?p(r):0,y=this.ep2*a(u,2),w=a(y,2),x=a(d,2),b=a(x,2);t=1-this.es*a(h,2);var M=l*g(t)/this.k0,C=a(M,2);o=r-(t*=d)*C/(1-this.es)*.5*(1-C/12*(5+3*x-9*y*x+y-4*w-C/30*(61+90*x-252*y*x+45*b+46*y-C/56*(1385+3633*x+4095*b+1574*b*x)))),s=ke(this.long0+M*(1-C/6*(1+2*x+y-C/20*(5+28*x+24*b+8*y*x+6*y-C/42*(61+662*x+1320*b+720*b*x))))/u)}else o=ce*Fe(A),s=0;else{var B=f(l/this.k0),E=.5*(B-1/B),S=this.lat0+A/this.k0,T=v(S);t=g((1-a(T,2))/(1+a(E,2))),o=i(t),0>A&&(o=-o),s=0===E&&0===T?0:ke(c(E,T)+this.long0)}return e.x=s,e.y=o,e},names:["Fast_Transverse_Mercator","Fast Transverse Mercator"]},tt=function(e){var t=f(e);return t=(t-1/t)/2},nt=function(e,t){var i=(0,Math.max)(e=n(e),t=n(t)),r=l(e,t)/(i||1);return i*g(1+a(r,2))},it=function(e){var i=n(e);return i=function(e){var n=1+e,i=n-1;return 0===i?e:e*t(n)/i}(i*(1+i/(nt(1,i)+1))),0>e?-i:i},rt=function(e,t){for(var n,i=2*v(2*t),r=e.length-1,a=e[r],o=0;0<=--r;)n=i*a-o+e[r],o=a,a=n;return t+n*m(2*t)},at=function(e){var t=f(e);return t=(t+1/t)/2},ot=function(e,t,n){for(var i,r,a=m(t),o=v(t),s=tt(n),l=at(n),A=2*o*l,c=-2*a*s,h=e.length-1,u=e[h],d=0,f=0,p=0;0<=--h;)i=f,r=d,u=A*(f=u)-i-c*(d=p)+e[h],p=c*f-r+A*d;return[(A=a*l)*u-(c=o*s)*p,A*p+c*u]},st={init:function(){if(!this.approx&&(isNaN(this.es)||0>=this.es))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(et.init.apply(this),this.forward=et.forward,this.inverse=et.inverse),this.x0=void 0===this.x0?0:this.x0,this.y0=void 0===this.y0?0:this.y0,this.long0=void 0===this.long0?0:this.long0,this.lat0=void 0===this.lat0?0:this.lat0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+g(1-this.es)),t=e/(2-e),n=t;this.cgb[0]=t*(2+t*(-2/3+t*(t*(116/45+t*(26/45+t*(-2854/675)))-2))),this.cbg[0]=t*(t*(2/3+t*(4/3+t*(-82/45+t*(32/45+t*(4642/4725)))))-2),n*=t,this.cgb[1]=n*(7/3+t*(t*(-227/45+t*(2704/315+t*(2323/945)))-1.6)),this.cbg[1]=n*(5/3+t*(-16/15+t*(-13/9+t*(904/315+t*(-1522/945))))),n*=t,this.cgb[2]=n*(56/15+t*(-136/35+t*(-1262/105+t*(73814/2835)))),this.cbg[2]=n*(-26/15+t*(34/21+t*(1.6+t*(-12686/2835)))),n*=t,this.cgb[3]=n*(4279/630+t*(-332/35+t*(-399572/14175))),this.cbg[3]=n*(1237/630+t*(t*(-24832/14175)-2.4)),n*=t,this.cgb[4]=n*(4174/315+t*(-144838/6237)),this.cbg[4]=n*(-734/315+t*(109598/31185)),n*=t,this.cgb[5]=n*(601676/22275),this.cbg[5]=n*(444337/155925),n=a(t,2),this.Qn=this.k0/(1+t)*(1+n*(1/4+n*(1/64+n/256))),this.utg[0]=t*(t*(2/3+t*(-37/96+t*(1/360+t*(81/512+t*(-96199/604800)))))-.5),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+t*(7891/37800)))))),this.utg[1]=n*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+t*(1118711/3870720))))),this.gtu[1]=n*(13/48+t*(t*(557/1440+t*(281/630+t*(-1983433/1935360)))-.6)),n*=t,this.utg[2]=n*(-17/480+t*(37/840+t*(209/4480+t*(-5569/90720)))),this.gtu[2]=n*(61/240+t*(-103/140+t*(15061/26880+t*(167603/181440)))),n*=t,this.utg[3]=n*(-4397/161280+t*(11/504+t*(830251/7257600))),this.gtu[3]=n*(49561/161280+t*(-179/168+t*(6601661/7257600))),n*=t,this.utg[4]=n*(-4583/161280+t*(108847/3991680)),this.gtu[4]=n*(34729/80640+t*(-3418889/1995840)),n*=t,this.utg[5]=n*(-20648693/638668800),this.gtu[5]=.6650675310896665*n;var i=rt(this.cbg,this.lat0);this.Zb=-this.Qn*(i+function(e,t){for(var n,i=2*v(t),r=e.length-1,a=e[r],o=0;0<=--r;)n=i*a-o+e[r],o=a,a=n;return m(t)*n}(this.gtu,2*i))},forward:function(e){var t=ke(e.x-this.long0),i=e.y;i=rt(this.cbg,i);var r=m(i),a=v(i),o=m(t),s=v(t);i=c(r,s*a),t=c(o*a,nt(r,a*s)),t=it(p(t));var l,A,h=ot(this.gtu,2*i,2*t);return i+=h[0],t+=h[1],2.623395162778>=n(t)?(l=this.a*(this.Qn*t)+this.x0,A=this.a*(this.Qn*i+this.Zb)+this.y0):(l=1/0,A=1/0),e.x=l,e.y=A,e},inverse:function(e){var t,i,r=(e.x-this.x0)*(1/this.a),a=(e.y-this.y0)*(1/this.a);if(a=(a-this.Zb)/this.Qn,r/=this.Qn,2.623395162778>=n(r)){var o=ot(this.utg,2*a,2*r);a+=o[0],r+=o[1],r=d(tt(r));var s=m(a),l=v(a),A=m(r),h=v(r);a=c(s*h,nt(A,h*l)),r=c(A,h*l),t=ke(r+this.long0),i=rt(this.cgb,a)}else t=1/0,i=1/0;return e.x=t,e.y=i,e},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","tmerc"]},lt={init:function(){var t=function(t,n){if(void 0===t){if(0>(t=e(30*(ke(n)+u)/u)+1))return 0;if(60fe?(u=m(this.lat0),s=v(this.lat0),e=1-this.es*u*u,this.B=s*s,this.B=g(1+this.es*this.B*this.B/L),this.A=this.B*this.k0*o/e,0>=(A=(l=this.B*o/(s*g(e)))*l-1)?A=0:(A=g(A),0>this.lat0&&(A=-A)),this.E=A+=l,this.E*=a(Pe(this.e,this.lat0,u),this.B)):(this.B=1/o,this.A=this.k0,this.E=l=A=1),_||I?(_?(w=i(m(T)/l),!I&&(b=T)):T=i(l*m(w=b)),this.lam0=M-i(.5*(A-1/A)*p(w))/this.B):(c=a(Pe(this.e,E,m(E)),this.B),h=a(Pe(this.e,S,m(S)),this.B),A=this.E/c,f=(h-c)/(h+c),y=((y=this.E*this.E)-h*c)/(y+h*c),(e=C-B)<-x?B-=ge:e>x&&(B+=ge),this.lam0=ke(.5*(C+B)-d(y*p(.5*this.B*(C-B))/f)/this.B),w=d(2*m(this.B*ke(C-this.lam0))/(A-1/A)),b=T=i(l*m(w))),this.singam=m(w),this.cosgam=v(w),this.sinrot=m(b),this.cosrot=v(b),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.no_off?this.u_0=0:(this.u_0=n(this.ArB*d(g(l*l-1)/v(T))),0>this.lat0&&(this.u_0=-this.u_0)),A=.5*w,this.v_pole_n=this.ArB*t(p(ve-A)),this.v_pole_s=this.ArB*t(p(ve+A))},forward:function(e){var i,r,o,s,l,A,h,u={};if(e.x-=this.lam0,n(n(e.y)-ce)>fe){if(i=.5*((s=this.E/a(Pe(this.e,e.y,m(e.y)),this.B))-(l=1/s)),r=.5*(s+l),m(this.B*e.x),o=(i*this.singam-86*this.cosgam)/r,n(n(o)-1)A?-ce:ce;else{if(h.y=this.E/g((1+A)/(1-A)),h.y=Ue(this.e,a(h.y,1/this.B)),h.y===1/0)throw new Error;h.x=-this.rB*c(o*this.cosgam-l*this.singam,v(this.BrA*t))}return h.x+=this.lam0,h},names:["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","Oblique_Mercator","omerc"]},mt={init:function(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(n(this.lat1+this.lat2)fe?t(o/c)/t(s/h):i,isNaN(this.ns)&&(this.ns=i),this.f0=o/(this.ns*a(s,this.ns)),this.rh=this.a*this.f0*a(u,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(e){var t=e.x,i=e.y;n(2*n(i)-u)<=fe&&(i=Fe(i)*(ce-2*fe));var r,o,s=n(n(i)-ce);if(s>fe)r=Pe(this.e,i,m(i)),o=this.a*this.f0*a(r,this.ns);else{if(0>=(s=i*this.ns))return null;o=0}var l=this.ns*ke(t-this.long0);return e.x=this.k0*(o*m(l))+this.x0,e.y=this.k0*(this.rh-o*v(l))+this.y0,e},inverse:function(e){var t,n,i,r,o,s=(e.x-this.x0)/this.k0,l=this.rh-(e.y-this.y0)/this.k0;0n(A-e.y)&&(h=1),A=e.y,f+=1}while(0===h&&15>f);return 15<=f?null:e},names:["Krovak","krovak"]},gt=function(e,t,n,i,r){return e*r-t*m(2*r)+n*m(4*r)-i*m(6*r)},yt=function(e){return 1-.25*e*(1+e/16*(3+1.25*e))},wt=function(e){return.375*e*(1+.25*e*(1+.46875*e))},xt=function(e){return.05859375*e*e*(1+.75*e)},bt=function(e){return e*e*e*(35/3072)},Mt=function(e,t,n){var i=t*n;return e/g(1-i*i)},Ct=function(e){return n(e)l;l++)if(o+=s=(e-(t*o-i*m(2*o)+r*m(4*o)-a*m(6*o)))/(t-2*i*v(2*o)+4*r*v(4*o)-6*a*v(6*o)),1e-10>=n(s))return o;return NaN},Et={init:function(){this.sphere||(this.e0=yt(this.es),this.e1=wt(this.es),this.e2=xt(this.es),this.e3=bt(this.es),this.ml0=this.a*gt(this.e0,this.e1,this.e2,this.e3,this.lat0))},forward:function(e){var t,n,r=e.x,a=e.y;if(r=ke(r-this.long0),this.sphere)t=this.a*i(v(a)*m(r)),n=this.a*(c(p(a),v(r))-this.lat0);else{var o=m(a),s=v(a),l=Mt(this.a,this.e,o),A=p(a)*p(a),h=r*v(a),u=h*h,d=this.es*s*s/(1-this.es);t=l*h*(1-u*A*(1/6-(8-A+8*d)*u/120)),n=this.a*gt(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+l*o/s*u*(.5+(5-A+6*d)*u/24)}return e.x=t+this.x0,e.y=n+this.y0,e},inverse:function(e){e.x-=this.x0,e.y-=this.y0;var t,r,o=e.x/this.a,s=e.y/this.a;if(this.sphere){var l=s+this.lat0;t=i(m(l)*v(o)),r=c(p(o),v(l))}else{var A=this.ml0/this.a+s,h=Bt(A,this.e0,this.e1,this.e2,this.e3);if(n(n(h)-ce)<=fe)return e.x=this.long0,e.y=ce,0>s&&(e.y*=-1),e;var u=Mt(this.a,this.e,m(h)),d=u*u*u/this.a/this.a*(1-this.es),f=a(p(h),2),g=o*this.a/u,y=g*g;t=h-u*p(h)/d*g*g*(.5-(1+3*f)*g*g/24),r=g*(1-y*(f/3+(1+3*f)*f*y/15))/v(h)}return e.x=ke(r+this.long0),e.y=Ct(t),e},names:["Cassini","Cassini_Soldner","cass"]},St=function(e,n){var i;return 1e-7this.lat0?this.S_POLE:this.N_POLE:n(t)fe?(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*g(this.c-this.ns0*this.qs0)/this.ns0)},forward:function(e){var t=e.x,n=e.y;this.sin_phi=m(n),this.cos_phi=v(n);var i=St(this.e3,this.sin_phi,this.cos_phi),r=this.a*g(this.c-this.ns0*i)/this.ns0,a=this.ns0*ke(t-this.long0),o=r*m(a)+this.x0,s=this.rh-r*v(a)+this.y0;return e.x=o,e.y=s,e},inverse:function(e){var t,n,r,a,o,s;return e.x-=this.x0,e.y=this.rh-e.y+this.y0,0<=this.ns0?(t=g(e.x*e.x+e.y*e.y),r=1):(t=-g(e.x*e.x+e.y*e.y),r=-1),a=0,0!==t&&(a=c(r*e.x,r*e.y)),r=t*this.ns0/this.a,this.sphere?s=i((this.c-r*r)/(2*this.ns0)):(n=(this.c-r*r)/this.ns0,s=this.phi1z(this.e3,n)),o=ke(a/this.ns0+this.long0),e.x=o,e.y=s,e},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(e,i){var r,a,o,s,l=Ut(.5*i);if(e=A;A++)if(l+=s=.5*(o=1-(a=e*(r=m(l)))*a)*o/v(l)*(i/(1-e*e)-r/o+.5/e*t((1-a)/(1+a))),1e-7>=n(s))return l;return null}},Rt={init:function(){this.sin_p14=m(this.lat0),this.cos_p14=v(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1},forward:function(e){var t,i,r,a,o,s,l,A=e.x,c=e.y;return r=ke(A-this.long0),t=m(c),i=v(c),a=v(r),1,0<(o=this.sin_p14*t+this.cos_p14*i*a)||n(o)<=fe?(s=this.x0+1*this.a*i*m(r)/o,l=this.y0+1*this.a*(this.cos_p14*t-this.sin_p14*i*a)/o):(s=this.x0+this.infinity_dist*i*m(r),l=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*i*a)),e.x=s,e.y=l,e},inverse:function(e){var t,n,i,r,a,o;return e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,(t=g(e.x*e.x+e.y*e.y))?(r=c(t,this.rc),n=m(r),i=v(r),o=Ut(i*this.sin_p14+e.y*n*this.cos_p14/t),a=c(e.x*n,t*this.cos_p14*i-e.y*this.sin_p14*n),a=ke(this.long0+a)):(o=this.phic0,a=0),e.x=a,e.y=o,e},names:["gnom"]},Ot={init:function(){this.sphere||(this.k0=Le(this.e,m(this.lat_ts),v(this.lat_ts)))},forward:function(e){var t,n,i=e.x,r=e.y,a=ke(i-this.long0);if(this.sphere)t=this.x0+this.a*a*v(this.lat_ts),n=this.y0+this.a*m(r)/v(this.lat_ts);else{var o=St(this.e,m(r));t=this.x0+this.a*this.k0*a,n=this.y0+this.a*o*.5/this.k0}return e.x=t,e.y=n,e},inverse:function(e){var r,o;return e.x-=this.x0,e.y-=this.y0,this.sphere?(r=ke(this.long0+e.x/this.a/v(this.lat_ts)),o=i(e.y/this.a*v(this.lat_ts))):(o=function(e,r){var o=1-(1-e*e)/(2*e)*t((1-e)/(1+e));if(1e-6>n(n(r)-o))return 0>r?-1*ce:ce;for(var s,l,A,c,h=i(.5*r),u=0;30>u;u++)if(l=m(h),A=v(h),h+=s=a(1-(c=e*l)*c,2)/(2*A)*(r/(1-e*e)-l/(1-c*c)+.5/e*t((1-c)/(1+c))),1e-10>=n(s))return h;return NaN}(this.e,2*e.y*this.k0/this.a),r=ke(this.long0+e.x/(this.a*this.k0))),e.x=r,e.y=o,e},names:["cea"]},Nt={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=v(this.lat_ts)},forward:function(e){var t=e.x,n=e.y,i=ke(t-this.long0),r=Ct(n-this.lat0);return e.x=this.x0+this.a*i*this.rc,e.y=this.y0+this.a*r,e},inverse:function(e){var t=e.x,n=e.y;return e.x=ke(this.long0+(t-this.x0)/(this.a*this.rc)),e.y=Ct(this.lat0+(n-this.y0)/this.a),e},names:["Equirectangular","Equidistant_Cylindrical","eqc"]},zt={init:function(){this.temp=this.b/this.a,this.es=1-a(this.temp,2),this.e=g(this.es),this.e0=yt(this.es),this.e1=wt(this.es),this.e2=xt(this.es),this.e3=bt(this.es),this.ml0=this.a*gt(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(e){var t,i,r,a=e.x,o=e.y,s=ke(a-this.long0);if(r=s*m(o),this.sphere)n(o)<=fe?(t=this.a*s,i=-1*this.a*this.lat0):(t=this.a*m(r)/p(o),i=this.a*(Ct(o-this.lat0)+(1-v(r))/p(o)));else if(n(o)<=fe)t=this.a*s,i=-1*this.ml0;else{var l=Mt(this.a,this.e,m(o))/p(o);t=l*m(r),i=this.a*gt(this.e0,this.e1,this.e2,this.e3,o)-this.ml0+l*(1-v(r))}return e.x=t+this.x0,e.y=i+this.y0,e},inverse:function(e){var t,r,o,s,l,A,c,h,u;if(o=e.x-this.x0,s=e.y-this.y0,this.sphere)if(n(s+this.a*this.lat0)<=fe)t=ke(o/this.a+this.long0),r=0;else{var d;for(A=this.lat0+s/this.a,c=o*o/this.a/this.a+A*A,h=A,l=20;l;--l)if(h+=u=-1*(A*(h*(d=p(h))+1)-h-.5*(h*h+c)*d)/((h-A)/d-1),n(u)<=fe){r=h;break}t=ke(this.long0+i(o*p(h)/this.a)/m(r))}else if(n(s+this.ml0)<=fe)r=0,t=ke(this.long0+o/this.a);else{var f,y,w,x,b;for(A=(this.ml0+s)/this.a,c=o*o/this.a/this.a+A*A,h=A,l=20;l;--l)if(b=this.e*m(h),f=g(1-b*b)*p(h),y=this.a*gt(this.e0,this.e1,this.e2,this.e3,h),w=this.e0-2*this.e1*v(2*h)+4*this.e2*v(4*h)-6*this.e3*v(6*h),h-=u=(A*(f*(x=y/this.a)+1)-x-.5*f*(x*x+c))/(this.es*m(2*h)*(x*x+c-2*A*x)/(4*f)+(A-x)*(f*w-2/m(2*h))-w),n(u)<=fe){r=h;break}f=g(1-this.es*a(m(r),2))*p(r),t=ke(this.long0+i(o*f/this.a)/m(r))}return e.x=t,e.y=r,e},names:["Polyconic","poly"]},Qt={init:function(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013},forward:function(e){var t,n=e.x,i=e.y-this.lat0,r=n-this.long0,a=1,o=0;for(t=1;10>=t;t++)a*=i/Ae*1e-5,o+=this.A[t]*a;var s,l=o,A=r,c=1,h=0,u=0,d=0;for(t=1;6>=t;t++)s=h*l+c*A,c=c*l-h*A,h=s,u=u+this.B_re[t]*c-this.B_im[t]*h,d=d+this.B_im[t]*c+this.B_re[t]*h;return e.x=d*this.a+this.x0,e.y=u*this.a+this.y0,e},inverse:function(e){var t,n,i=e.x,r=e.y,a=i-this.x0,o=(r-this.y0)/this.a,s=a/this.a,l=1,A=0,c=0,h=0;for(t=1;6>=t;t++)n=A*o+l*s,l=l*o-A*s,A=n,c=c+this.C_re[t]*l-this.C_im[t]*A,h=h+this.C_im[t]*l+this.C_re[t]*A;for(var u=0;u=t;t++)d=p*c+f*h,f=f*c-p*h,p=d,m+=(t-1)*(this.B_re[t]*f-this.B_im[t]*p),v+=(t-1)*(this.B_im[t]*f+this.B_re[t]*p);f=1,p=0;var g=this.B_re[1],y=this.B_im[1];for(t=2;6>=t;t++)d=p*c+f*h,f=f*c-p*h,p=d,g+=t*(this.B_re[t]*f-this.B_im[t]*p),y+=t*(this.B_im[t]*f+this.B_re[t]*p);var w=g*g+y*y;c=(m*g+v*y)/w,h=(v*g-m*y)/w}var x=c,b=h,M=1,C=0;for(t=1;9>=t;t++)M*=x,C+=this.D[t]*M;var B=this.lat0+C*Ae*1e5,E=this.long0+b;return e.x=E,e.y=B,e},names:["New_Zealand_Map_Grid","nzmg"]},Gt={init:function(){},forward:function(e){var n=e.x,i=e.y,r=ke(n-this.long0),a=this.x0+this.a*r,o=this.y0+this.a*t(p(u/4+i/2.5))*1.25;return e.x=a,e.y=o,e},inverse:function(e){e.x-=this.x0,e.y-=this.y0;var t=ke(this.long0+e.x/this.a),n=2.5*(d(f(.8*e.y/this.a))-u/4);return e.x=t,e.y=n,e},names:["Miller_Cylindrical","mill"]},Ht={init:function(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=g((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=Je(this.es)},forward:function(e){var t,r,a=e.x,o=e.y;if(a=ke(a-this.long0),this.sphere){if(this.m)for(var s,l=this.n*m(o),A=20;A&&(o-=s=(this.m*o+m(o)-l)/(this.m+v(o)),!(n(s)u&&(a=u),r=(2*t+m(2*t))/u,1o&&(w=-w),t=this.x0+w;var x=A+d;return w=u*this.R*(f*x-l*g((y+A)*(A+1)-x*x))/(y+A),i=0<=a?this.y0+w:this.y0-w,e.x=t,e.y=i,e},inverse:function(e){var t,i,r,a,s,l,A,c,h,d,f,p,m;return e.x-=this.x0,e.y-=this.y0,f=u*this.R,s=(r=e.x/f)*r+(a=e.y/f)*a,m=a*a/(c=-2*(l=-n(a)*(1+s))+1+2*a*a+s*s)+(2*(A=l-2*a*a+r*r)*A*A/c/c/c-9*l*A/c/c)/27,d=2*g(-(h=(l-A*A/3/c)/c)/3),12*ce*this.a?void 0:(r=t/this.a,o=m(r),s=v(r),l=this.long0,n(t)<=fe?A=this.lat0:(A=Ut(s*this.sin_p12+e.y*o*this.cos_p12/t),h=n(this.lat0)-ce,l=n(h)<=fe?0<=this.lat0?ke(this.long0+c(e.x,-e.y)):ke(this.long0-c(-e.x,e.y)):ke(this.long0+c(e.x*o,t*this.cos_p12*s-e.y*this.sin_p12*o))),e.x=l,e.y=A,e):(u=yt(this.es),d=wt(this.es),f=xt(this.es),y=bt(this.es),n(this.sin_p12-1)<=fe?(w=this.a*gt(u,d,f,y,ce),t=g(e.x*e.x+e.y*e.y),A=Bt((w-t)/this.a,u,d,f,y),l=ke(this.long0+c(e.x,-1*e.y)),e.x=l,e.y=A,e):n(this.sin_p12+1)<=fe?(w=this.a*gt(u,d,f,y,ce),t=g(e.x*e.x+e.y*e.y),A=Bt((t-w)/this.a,u,d,f,y),l=ke(this.long0+c(e.x,e.y)),e.x=l,e.y=A,e):(t=g(e.x*e.x+e.y*e.y),M=c(e.x,e.y),x=Mt(this.a,this.e,this.sin_p12),C=v(M),E=-(B=this.e*this.cos_p12*C)*B/(1-this.es),S=3*this.es*(1-E)*this.sin_p12*this.cos_p12*C/(1-this.es),I=1-E*(_=(T=t/x)-E*(1+E)*a(T,3)/6-S*(1+3*E)*a(T,4)/24)*_/2-T*_*_*_/6,b=i(this.sin_p12*v(_)+this.cos_p12*m(_)*C),l=ke(this.long0+i(m(M)*m(_)/v(b))),L=m(b),A=c((L-this.es*I*this.sin_p12)*p(b),L*(1-this.es)),e.x=l,e.y=A,e))},names:["Azimuthal_Equidistant","aeqd"]},Yt={init:function(){this.sin_p14=m(this.lat0),this.cos_p14=v(this.lat0)},forward:function(e){var t,i,r,a,o,s,l,A=e.x,c=e.y;return r=ke(A-this.long0),t=m(c),i=v(c),a=v(r),1,(0<(o=this.sin_p14*t+this.cos_p14*i*a)||n(o)<=fe)&&(s=1*this.a*i*m(r),l=this.y0+1*this.a*(this.cos_p14*t-this.sin_p14*i*a)),e.x=s,e.y=l,e},inverse:function(e){var t,i,r,a,o,s,l;return e.x-=this.x0,e.y-=this.y0,t=g(e.x*e.x+e.y*e.y),i=Ut(t/this.a),r=m(i),a=v(i),s=this.long0,n(t)<=fe?(l=this.lat0,e.x=s,e.y=l,e):(l=Ut(a*this.sin_p14+e.y*r*this.cos_p14/t),o=n(this.lat0)-ce,n(o)<=fe?(s=0<=this.lat0?ke(this.long0+c(e.x,-e.y)):ke(this.long0-c(-e.x,e.y)),e.x=s,e.y=l,e):(s=ke(this.long0+c(e.x*r,t*this.cos_p14*a-e.y*this.sin_p14*r)),e.x=s,e.y=l,e))},names:["ortho"]},Kt=1,Zt=2,Jt=3,qt=4,$t=5,en=6,tn={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4},nn={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.face=this.lat0>=ce-ve/2?$t:this.lat0<=-(ce-ve/2)?en:n(this.long0)<=ve?Kt:n(this.long0)<=ce+ve?0=ve&&n<=ce+ve?(A.value=tn.AREA_0,i=n-ce):n>ce+ve||n<=-(ce+ve)?(A.value=tn.AREA_1,i=0-(ce+ve)&&n<=-ve?(A.value=tn.AREA_2,i=n+ce):(A.value=tn.AREA_3,i=n);else if(this.face===en)r=ce+t,n>=ve&&n<=ce+ve?(A.value=tn.AREA_0,i=-n+ce):n=-ve?(A.value=tn.AREA_1,i=-n):n<-ve&&n>=-(ce+ve)?(A.value=tn.AREA_2,i=-n-ce):(A.value=tn.AREA_3,i=0=n(e.y)?b.value=tn.AREA_0:0<=e.y&&e.y>=n(e.x)?(b.value=tn.AREA_1,t-=ce):0>e.x&&-e.x>=n(e.y)?(b.value=tn.AREA_2,t=0>t?t+ye:t-ye):(b.value=tn.AREA_3,t+=ce),u=ye/12*p(t),s=m(u)/(v(u)-1/g(2)),l=d(s),-1>(A=1-(r=v(t))*r*(a=p(i))*a*(1-v(d(1/v(l)))))?A=-1:1l?l+ye:l-ye:b.value===tn.AREA_2?l-ce:l;else if(this.face===en)h=o(A),x.phi=h-ce,x.lam=b.value===tn.AREA_0?-l+ce:b.value===tn.AREA_1?-l:b.value===tn.AREA_2?-l-ce:0>l?-l-ye:-l+ye;else{var M,C,B;u=(M=A)*M,C=1<=(u+=(B=1<=u?0:g(1-u)*m(l))*B)?0:g(1-u),b.value===tn.AREA_1?(u=C,C=-B,B=u):b.value===tn.AREA_2?(C=-C,B=-B):b.value===tn.AREA_3&&(u=C,C=B,B=-u),this.face===Zt?(u=M,M=-C,C=u):this.face===Jt?(M=-M,C=-C):this.face===qt&&(u=M,M=C,C=-u),x.phi=o(-B)-ce,x.lam=c(C,M),this.face===Zt?x.lam=oe(x.lam,-ce):this.face===Jt?x.lam=oe(x.lam,-ye):this.face===qt&&(x.lam=oe(x.lam,+ce))}0!==this.es&&(f=0>x.phi?1:0,y=p(x.phi),w=this.b/g(y*y+this.one_minus_f_squared),x.phi=d(g(this.a*this.a-w*w)/(this.one_minus_f*w)),f&&(x.phi=-x.phi));return x.lam+=this.long0,e.x=x.lam,e.y=x.phi,e},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]},rn=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],an=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],on=.8487,sn=1.3523,ln=me/5,An=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},cn={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(t){var i=ke(t.x-this.long0),r=n(t.y),a=e(r*ln);0>a?a=0:18<=a&&(a=17);var o={x:An(rn[a],r=me*(r-1/ln*a))*i,y:An(an[a],r)};return 0>t.y&&(o.y=-o.y),o.x=o.x*this.a*on+this.x0,o.y=o.y*this.a*sn+this.y0,o},inverse:function(t){var i={x:(t.x-this.x0)/(this.a*on),y:n(t.y-this.y0)/(this.a*sn)};if(1<=i.y)i.x/=rn[18][0],i.y=0>t.y?-ce:ce;else{var r=e(18*i.y);for(0>r?r=0:18<=r&&(r=17);;)if(an[r][0]>i.y)--r;else{if(!(an[r+1][0]<=i.y))break;++r}var a=an[r],o=5*(i.y-a[0])/(an[r+1][0]-a[0]);o=function(e,t,i,r){for(var a,o=t;r&&(o-=a=e(o),!(n(a)t.y&&(i.y=-i.y)}return i.x=ke(i.x+this.long0),i},names:["Robinson","robin"]},hn={init:function(){this.name="geocent"},forward:function(e){return R(e,this.es,this.a)},inverse:function(e){return O(e,this.es,this.a,this.b)},names:["Geocentric","geocentric","geocent","Geocent"]},un=0,dn=1,fn=2,pn=3,mn={h:{def:1e5,num:!0},azi:{def:0,num:!0,degrees:!0},tilt:{def:0,num:!0,degrees:!0},long0:{def:0,num:!0},lat0:{def:0,num:!0}},vn={init:function(){if(Object.keys(mn).forEach(function(e){if(void 0===this[e])this[e]=mn[e].def;else{if(mn[e].num&&isNaN(this[e]))throw new Error("Invalid parameter value, must be numeric "+e+" = "+this[e]);mn[e].num&&(this[e]=parseFloat(this[e]))}mn[e].degrees&&(this[e]*=pe)}.bind(this)),n(n(this.lat0)-ce)this.lat0?dn:un:n(this.lat0)=this.pn1||1e10 */var a=e("buffer"),o=a.Buffer;o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=a:(i(a,n),n.Buffer=r),r.prototype=Object.create(o.prototype),i(o,r),r.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},r.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=o(e);return void 0===t?i.fill(0):"string"==typeof n?i.fill(t,n):i.fill(t),i},r.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},r.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return a.SlowBuffer(e)}},{buffer:8}],19:[function(e,t,n){function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(u.isEncoding===d||!d(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=o,this.end=s,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=A,t=3;break;default:return this.write=c,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(t)}function r(e){return 127>=e?0:6==e>>5?2:14==e>>4?3:30==e>>3?4:2==e>>6?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(1=i)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function s(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0==n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1==n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function A(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function c(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}var u=e("safe-buffer").Buffer,d=u.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};n.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=(t=e[i])?n+=s(t):n+=s(55296+((t-=65536)>>10),56320+(1023&t));return n}function A(e){return 0<=e&&127>=e}function c(e){this.tokens=[].slice.call(e),this.tokens.reverse()}function h(e,t){if(e)throw TypeError("Decoder error");return t||65533}function u(e){throw TypeError("The code point "+e+" could not be encoded.")}function d(e){return e=(e+"").trim().toLowerCase(),Object.prototype.hasOwnProperty.call(H,e)?H[e]:null}function f(e,t){return t&&t[e]||null}function p(e,t){var n=t.indexOf(e);return-1===n?null:n}function m(e){if(!("encoding-indexes"in i))throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");return i["encoding-indexes"][e]}function v(e,t){if(!(this instanceof v))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0===e?"utf-8":e+"",t=o(t),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var n=d(e);if(null===n||"replacement"===n.name)throw RangeError("Unknown encoding: "+e);if(!X[n.name])throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");var i=this;return i._encoding=n,!!t.fatal&&(i._error_mode="fatal"),!!t.ignoreBOM&&(i._ignoreBOM=!0),Object.defineProperty||(this.encoding=i._encoding.name.toLowerCase(),this.fatal="fatal"===i._error_mode,this.ignoreBOM=i._ignoreBOM),i}function g(e,t){if(!(this instanceof g))throw TypeError("Called as a function. Did you forget 'new'?");t=o(t),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=t.fatal?"fatal":"replacement";var n=this;if(t.NONSTANDARD_allowLegacyEncoding){var r=d(e=void 0===e?"utf-8":e+"");if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!W[r.name])throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");n._encoding=r}else n._encoding=d("utf-8"),void 0!==e&&"console"in i&&console.warn("TextEncoder constructor called with encoding label, which is ignored.");return Object.defineProperty||(this.encoding=n._encoding.name.toLowerCase()),n}function y(e){var t=e.fatal,n=0,i=0,r=0,o=128,s=191;this.handler=function(e,l){if(-1===l&&0!==r)return r=0,h(t);if(-1===l)return-1;if(0===r){if(a(l,0,127))return l;if(a(l,194,223))r=1,n=31&l;else if(a(l,224,239))224===l&&(o=160),237===l&&(s=159),r=2,n=15&l;else{if(!a(l,240,244))return h(t);240===l&&(o=144),244===l&&(s=143),r=3,n=7&l}return null}if(!a(l,o,s))return n=r=i=0,o=128,s=191,e.prepend(l),h(t);if(o=128,s=191,n=n<<6|63&l,(i+=1)!==r)return null;var A=n;return n=r=i=0,A}}function w(e){e.fatal,this.handler=function(e,t){if(-1===t)return-1;if(Q(t))return t;var n,i;a(t,128,2047)?(n=1,i=192):a(t,2048,65535)?(n=2,i=224):a(t,65536,1114111)&&(n=3,i=240);for(var r=[(t>>6*n)+i];0>6*(n-1);r.push(128|63&o),n-=1}return r}}function x(e,t){var n=t.fatal;this.handler=function(t,i){if(-1===i)return-1;if(A(i))return i;var r=e[i-128];return null===r?h(n):r}}function b(e,t){t.fatal,this.handler=function(t,n){if(-1===n)return-1;if(Q(n))return n;var i=p(n,e);return null===i&&u(n),i+128}}function M(e){var t=e.fatal,n=0,i=0,r=0;this.handler=function(e,o){if(-1===o&&0===n&&0===i&&0===r)return-1;var s;if(-1===o&&(0!==n||0!==i||0!==r)&&(n=0,i=0,r=0,h(t)),0!==r){s=null,a(o,48,57)&&(s=function(e){if(39419e||1237575o?64:65;return(a(o,64,126)||a(o,128,254))&&(u=190*(c-129)+(o-d)),null===(s=null===u?null:f(u,m("gb18030")))&&A(o)&&e.prepend(o),null===s?h(t):s}return A(o)?o:128===o?8364:a(o,129,254)?(n=o,null):h(t)}}function C(e,t){e.fatal,this.handler=function(e,n){if(-1===n)return-1;if(Q(n))return n;if(58853===n)return u(n);if(t&&8364===n)return 128;var i=p(n,m("gb18030"));if(null!==i){var r=i%190;return[z(i/190)+129,r+(63>r?64:65)]}if(t)return u(n);i=function(e){if(59335===e)return 7457;var t,n=0,i=0,r=m("gb18030-ranges");for(t=0;ti?64:98;switch((a(i,64,126)||a(i,161,254))&&(o=157*(r-129)+(i-s)),o){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var l=null===o?null:f(o,m("big5"));return null===l&&A(i)&&e.prepend(i),null===l?h(t):l}return A(i)?i:a(i,129,254)?(n=i,null):h(t)}}function E(e){e.fatal,this.handler=function(e,t){if(-1===t)return-1;if(Q(t))return t;var n=function(e){j=j||m("big5").map((function(e,t){return t<5024?null:e}));var t=j;return 9552===e||9566===e||9569===e||9578===e||21313===e||21317===e?t.lastIndexOf(e):p(e,t)}(t);if(null===n)return u(t);var i=z(n/157)+129;if(161>i)return u(t);var r=n%157;return[i,r+(63>r?64:98)]}}function S(e){var t=e.fatal,n=!1,i=0;this.handler=function(e,r){if(-1===r&&0!==i)return i=0,h(t);if(-1===r&&0===i)return-1;if(142===i&&a(r,161,223))return i=0,65216+r;if(143===i&&a(r,161,254))return n=!0,i=r,null;if(0!==i){var o=i;i=0;var s=null;return a(o,161,254)&&a(r,161,254)&&(s=f(94*(o-161)+(r-161),m(n?"jis0212":"jis0208"))),n=!1,a(r,161,254)||e.prepend(r),null===s?h(t):s}return A(r)?r:142===r||143===r||a(r,161,254)?(i=r,null):h(t)}}function T(e){e.fatal,this.handler=function(e,t){if(-1===t)return-1;if(Q(t))return t;if(165===t)return 92;if(8254===t)return 126;if(a(t,65377,65439))return[142,t-65377+161];8722===t&&(t=65293);var n=p(t,m("jis0208"));return null===n?u(t):[z(n/94)+161,n%94+161]}}function _(e){var t=e.fatal,n=0,i=1,r=2,o=3,s=4,l=5,A=6,c=n,u=n,d=0,p=!1;this.handler=function(e,v){switch(c){default:case n:return 27===v?(c=l,null):a(v,0,127)&&14!==v&&15!==v&&27!==v?(p=!1,v):-1===v?-1:(p=!1,h(t));case i:return 27===v?(c=l,null):92===v?(p=!1,165):126===v?(p=!1,8254):a(v,0,127)&&14!==v&&15!==v&&27!==v&&92!==v&&126!==v?(p=!1,v):-1===v?-1:(p=!1,h(t));case r:return 27===v?(c=l,null):a(v,33,95)?(p=!1,65344+v):-1===v?-1:(p=!1,h(t));case o:return 27===v?(c=l,null):a(v,33,126)?(p=!1,d=v,c=s,null):-1===v?-1:(p=!1,h(t));case s:if(27===v)return c=l,h(t);if(a(v,33,126)){c=o;var g=f(94*(d-33)+v-33,m("jis0208"));return null===g?h(t):g}return-1===v?(c=o,e.prepend(v),h(t)):(c=o,h(t));case l:return 36===v||40===v?(d=v,c=A,null):(e.prepend(v),p=!1,c=u,h(t));case A:var y=d;d=0;var w=null;if(40===y&&66===v&&(w=n),40===y&&74===v&&(w=i),40===y&&73===v&&(w=r),36===y&&(64===v||66===v)&&(w=o),null!==w){c=c=w;var x=p;return p=!0,x?h(t):null}return e.prepend([y,v]),p=!1,c=u,h(t)}}}function I(e){e.fatal;var t=0,n=1,i=2,r=t;this.handler=function(e,a){if(-1===a&&r!==t)return e.prepend(a),r=t,[27,40,66];if(-1===a&&r===t)return-1;if(!(r!==t&&r!==n||14!==a&&15!==a&&27!==a))return u(65533);if(r===t&&Q(a))return a;if(r===n&&(Q(a)&&92!==a&&126!==a||165==a||8254==a)){if(Q(a))return a;if(165===a)return 92;if(8254===a)return 126}if(Q(a)&&r!==t)return e.prepend(a),r=t,[27,40,66];if((165===a||8254===a)&&r!==n)return e.prepend(a),r=n,[27,40,74];8722===a&&(a=65293);var o=p(a,m("jis0208"));return null===o?u(a):r!==i?(e.prepend(a),r=i,[27,36,66]):[z(o/94)+33,o%94+33]}}function L(e){var t=e.fatal,n=0;this.handler=function(e,i){if(-1===i&&0!==n)return n=0,h(t);if(-1===i&&0===n)return-1;if(0!==n){var r=n,o=null;n=0;var s=127>i?64:65,l=160>r?129:193;if((a(i,64,126)||a(i,128,252))&&(o=188*(r-l)+i-s),a(o,8836,10715))return 48508+o;var c=null===o?null:f(o,m("jis0208"));return null===c&&A(i)&&e.prepend(i),null===c?h(t):c}return A(i)||128===i?i:a(i,161,223)?65216+i:a(i,129,159)||a(i,224,252)?(n=i,null):h(t)}}function F(e){e.fatal,this.handler=function(e,t){if(-1===t)return-1;if(Q(t)||128===t)return t;if(165===t)return 92;if(8254===t)return 126;if(a(t,65377,65439))return t-65377+161;8722===t&&(t=65293);var n=function(e){return V=V||m("jis0208").map((function(e,t){return a(t,8272,8835)?null:e})),V.indexOf(e)}(t);if(null===n)return u(t);var i=z(n/188),r=n%188;return[i+(31>i?129:193),r+(63>r?64:65)]}}function k(e){var t=e.fatal,n=0;this.handler=function(e,i){if(-1===i&&0!==n)return n=0,h(t);if(-1===i&&0===n)return-1;if(0!==n){var r=n,o=null;n=0,a(i,65,254)&&(o=190*(r-129)+(i-65));var s=null===o?null:f(o,m("euc-kr"));return null===o&&A(i)&&e.prepend(i),null===s?h(t):s}return A(i)?i:a(i,129,254)?(n=i,null):h(t)}}function P(e){e.fatal,this.handler=function(e,t){if(-1===t)return-1;if(Q(t))return t;var n=p(t,m("euc-kr"));return null===n?u(t):[z(n/190)+129,n%190+65]}}function U(e,t){var n=e>>8,i=255&e;return t?[n,i]:[i,n]}function D(e,t){var n=t.fatal,i=null,r=null;this.handler=function(t,o){if(-1===o&&(null!==i||null!==r))return h(n);if(-1===o&&null===i&&null===r)return-1;if(null===i)return i=o,null;var s;if(s=e?(i<<8)+o:(o<<8)+i,i=null,null!==r){var l=r;return r=null,a(s,56320,57343)?65536+1024*(l-55296)+(s-56320):(t.prepend(U(s,e)),h(n))}return a(s,55296,56319)?(r=s,null):a(s,56320,57343)?h(n):s}}function R(e,t){t.fatal,this.handler=function(t,n){if(-1===n)return-1;if(a(n,0,65535))return U(n,e);var i=U(55296+(n-65536>>10),e),r=U(56320+(1023&n-65536),e);return i.concat(r)}}function O(e){e.fatal,this.handler=function(e,t){return-1===t?-1:A(t)?t:63360+t-128}}function N(e){e.fatal,this.handler=function(e,t){return-1===t?-1:Q(t)?t:a(t,63360,63487)?t-63360+128:u(t)}}void 0!==n&&n.exports&&!i["encoding-indexes"]&&t("./encoding-indexes.js");var z=e,Q=A;c.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():-1},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.pop());else this.tokens.push(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.shift());else this.tokens.unshift(e)}};var G=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],H={};G.forEach((function(e){e.encodings.forEach((function(e){e.labels.forEach((function(t){H[t]=e}))}))}));var V,j,W={},X={};Object.defineProperty&&(Object.defineProperty(v.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(v.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(v.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),v.prototype.decode=function(e,t){var n;n="object"==r(e)&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==r(e)&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=o(t),this._do_not_flush||(this._decoder=X[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=!!t.stream;for(var i,a,s=new c(n),A=[];-1!==(a=s.read())&&-1!==(i=this._decoder.handler(s,a));)null!==i&&(Array.isArray(i)?A.push.apply(A,i):A.push(i));if(!this._do_not_flush){do{if(-1===(i=this._decoder.handler(s,s.read())))break;null!==i&&(Array.isArray(i)?A.push.apply(A,i):A.push(i))}while(!s.endOfStream());this._decoder=null}return function(e){return!function(e,t){return-1!==e.indexOf(t)}(["UTF-8","UTF-16LE","UTF-16BE"],this._encoding.name)||this._ignoreBOM||this._BOMseen||(0a||57343=a)r.push(65533);else if(55296<=a&&56319>=a)if(i===n-1)r.push(65533);else{var o=t.charCodeAt(i+1);56320<=o&&57343>=o?(r.push(65536+((1023&a)<<10)+(1023&o)),i+=1):r.push(65533)}i+=1}return r}(e)),a=[];-1!==(i=r.read())&&-1!==(n=this._encoder.handler(r,i));)Array.isArray(n)?a.push.apply(a,n):a.push(n);if(!this._do_not_flush){for(;-1!==(n=this._encoder.handler(r,r.read()));)Array.isArray(n)?a.push.apply(a,n):a.push(n);this._encoder=null}return new Uint8Array(a)},W["UTF-8"]=function(e){return new w(e)},X["UTF-8"]=function(e){return new y(e)},"encoding-indexes"in i&&G.forEach((function(e){"Legacy single-byte encodings"!==e.heading||e.encodings.forEach((function(e){var t=e.name,n=m(t.toLowerCase());X[t]=function(e){return new x(n,e)},W[t]=function(e){return new b(n,e)}}))})),X.GBK=function(e){return new M(e)},W.GBK=function(e){return new C(e,!0)},W.gb18030=function(e){return new C(e)},X.gb18030=function(e){return new M(e)},W.Big5=function(e){return new E(e)},X.Big5=function(e){return new B(e)},W["EUC-JP"]=function(e){return new T(e)},X["EUC-JP"]=function(e){return new S(e)},W["ISO-2022-JP"]=function(e){return new I(e)},X["ISO-2022-JP"]=function(e){return new _(e)},W.Shift_JIS=function(e){return new F(e)},X.Shift_JIS=function(e){return new L(e)},W["EUC-KR"]=function(e){return new P(e)},X["EUC-KR"]=function(e){return new k(e)},W["UTF-16BE"]=function(e){return new R(!0,e)},X["UTF-16BE"]=function(e){return new D(!0,e)},W["UTF-16LE"]=function(e){return new R(!1,e)},X["UTF-16LE"]=function(e){return new D(!1,e)},W["x-user-defined"]=function(e){return new N(e)},X["x-user-defined"]=function(e){return new O(e)},i.TextEncoder||(i.TextEncoder=g),i.TextDecoder||(i.TextDecoder=v),void 0!==n&&n.exports&&(n.exports={TextEncoder:i.TextEncoder,TextDecoder:i.TextDecoder,EncodingIndexes:i["encoding-indexes"]})}(this||{})},{"./encoding-indexes.js":7}],22:[function(e,t,n){(function(t,i){(function(){function r(e,t){this._id=e,this._clearFn=t}var a=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,l={},A=0;n.setTimeout=function(){return new r(o.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new r(o.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n.setImmediate="function"==typeof t?t:function(e){var t=A++,i=!(2>arguments.length)&&s.call(arguments,1);return l[t]=!0,a((function(){l[t]&&(i?e.apply(null,i):e.call(null),n.clearImmediate(t))})),t},n.clearImmediate="function"==typeof i?i:function(e){delete l[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":16,timers:22}],23:[function(e,t){(function(n){(function(){function r(e){if(!e)throw new Error("forgot to pass buffer");return v.isBuffer(e)?e:a(e)?v.from(e):a(e.buffer)?1===e.BYTES_PER_ELEMENT?v.from(e):v.from(e.buffer):void 0}function a(e){return e instanceof n.ArrayBuffer||"[object ArrayBuffer]"===Object.prototype.toString.call(e)}function s(e,t){return"string"==typeof e&&y.has(e)?p.resolve(y.get(e)):s.getShapefile(e,t).then((function(t){return"string"==typeof e&&y.set(e,t),t}))}function l(e,t){return A.apply(this,arguments)}function A(){return A=o(i().mark((function e(t,n){var r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u(t);case 2:return r=e.sent,e.abrupt("return",s.parseZip(r,n));case 4:case"end":return e.stop()}}),e)}))),A.apply(this,arguments)}var c=e("proj4");c.default&&(c=c.default);var h=e("./unzip"),u=e("./binaryajax"),d=e("./parseShp"),f=e("parsedbf"),p=e("lie"),m=e("lru-cache"),v=e("buffer").Buffer,g=n.URL,y=new m({max:20});s.combine=function(e){var t=M(e,2),n=t[0],i=t[1],r={type:"FeatureCollection",features:[]},a=0,o=n.length;for(i||(i=[]);a1&&void 0!==arguments[1]?arguments[1]:{};return n=xC(n),e.zip?t=wk.parseZip(e.zip):e.shp&&e.shx&&e.dbf&&(t=Promise.all([wk.parseShp(e.shp,e.prj),wk.parseDbf(e.dbf)]).then(wk.combine)),n.in=n.in||{},n.in.crs=e.prj?Zy(e.prj).oProj.datumName:void 0,Promise.resolve(t).then((function(e){return _C.parse(e,n)}))},bk=function(){function e(t){s(this,e),this.classes=t.classes,this.inverseHierarchy={},this.instancesIdxs=[];var n={},i=0,r=t.parentCounts;void 0===r&&(r=new Array(t.instancesLength)).fill(1);for(var a=0;a\n
90 km\n
\n
\n
\n \n
\n
\n \n
\n\n
\n \n
\n\n
\n \n \n
\n
\n',t.container.appendChild(this.element),this.compass=t.container.querySelector("#compass"),this.widgetsScale=t.container.querySelector("#widgets-scale"),this.btn3d=t.container.querySelector("#button-3d"),this.element.querySelector("#zoom-in-button").onclick=function(){n.view.controls.zoomIn()},this.element.querySelector("#zoom-out-button").onclick=function(){n.view.controls.zoomOut()},this.btn3d.onclick=function(){n.view.controls.setTilt("3D"===n.btn3d.innerText?40:90,!0),n.btn3d.innerText="3D"===n.btn3d.innerText?"2D":"3D"},this.element.querySelector("#home-button").onclick=function(){t.controls.flyTo(t.defaultView)},this.view.controls.addEventListener("range-changed",(function(e){var t=Math.round(n.view.getPixelsToMeters(200)),i=Math.pow(10,t.toString().length-1);t=Math.round(t/i)*i;var r=n.view.getMetersToPixels(t),a="m";t>=1e3&&(t/=1e3,a="km"),n.widgetsScale.innerHTML="".concat(t," ").concat(a),n.widgetsScale.style.width="".concat(r,"px")})),this.view.addEventListener(AMRT.Event.CAMERA_MOVED,(function(e){n.compass.style.transform="rotate(".concat(-e.heading,"deg)"),n.btn3d.innerText=e.tilt<89?"2D":"3D"}))}return A(e,[{key:"visible",get:function(){return this._visible},set:function(e){this._visible=e,this.element.style.display=e?"block":"none"}}]),e}(),Ek={coord:[108.5525,34.3227],range:10204904,tilt:90,heading:.001},Sk="globe",Tk="planar",_k=function(e){h(n,e);var t=y(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,n),zt.DefaultUp.set(0,0,1),window.__DEBUG__=!1,r.logarithmicDepthBuffer=!0,(i=t.call(this,e,r)).name="GISViewer",i.options=r,i.isGISViewer=!0,i}return A(n,[{key:"initialize",value:function(e){b(u(n.prototype),"initialize",this).call(this,e),this.camera.frustumCulled=!0,this.scene.background=null,this.renderer.setClearAlpha(1),this.defaultView=Ek,this.controlsMap={},this.viewType=e.viewType||Sk,this.viewType===Sk?(this.mapView=new CI(this.container,this.defaultView,{camera:this.camera,renderer:this.renderer,scene3D:this.scene}),this.controlsMap[pp.GLOBE]=this.mapView.controls,this.viewMode=pp.GLOBE):this.viewType===Tk&&(e.extent=e.extent||new bb("EPSG:3857",-20037508.342789244,20037508.342789244,-20037508.342789255,20037508.342789244),this.mapView=new yL(this.container,e.extent,{disableSkirt:!1,maxSubdivisionLevel:19,placement:e.view,camera:this.camera,renderer:this.renderer,scene3D:this.scene}),this.viewMode=pp.PLANAR,this.controlsMap[pp.PLANAR]=this.mapView.controls),this.globe=this.mapView,this.mapView.render=this.renderManager.render,this.controls=this.mapView.controls,this.camera.near=.1,this.camera.updateProjectionMatrix(),If.bindAll(["onUpdate","_onGlobeComplete"],this),this.onGlebeComplete=!1,this.controls.enabled=!1,this.mapView.addEventListener(QS,this._onGlobeComplete),setTimeout(this._onGlobeComplete,2e3),this.mapCenter=this.coordinatesToVector3(e.view?e.view.coord:Ek.coord),this.addEventListener("update",this.onUpdate),Ck.token=e.mapToken||Ck.token,this._elevationLayers=[],this.initLayer(e),this.navigationBar=new Bk(this),e.navigation||(this.navigationBar.visible=!1)}},{key:"_onGlobeComplete",value:function(){var e=this;this.onGlebeComplete||(this.options.showTerrain&&(this._elevationLayers.push(this.loadElevationLayer(Ck.WORLD_DTM)),this._elevationLayers.push(this.loadElevationLayer(Ck.MNT_HIGHRES))),this.mapView.isGlobeView&&this.options.view?(this.defaultView=this.options.view,this.defaultView.onComplete=function(){e.defaultView.onComplete=null,e.controls.enabled=!0,e.dispatchEvent(ld.MAP_INIT)},this.controls.flyTo(this.defaultView)):(this.controls.enabled=!0,this.dispatchEvent(ld.MAP_INIT)),this.onGlebeComplete=!0)}},{key:"initLayer",value:function(e){var t=this;(e.mapSource||[Ck.TianDiTu.imagery]).forEach((function(e){t.loadColorLayer(e)}))}},{key:"addModel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{noFit:!0};return b(u(n.prototype),"addModel",this).call(this,e,t)}},{key:"loadModel",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.onLoad;return i.noSky=!0,i.focus=!1,i.background=!1,i.addModel=!1,i.onLoad=function(e){var n=new ja;if(n.name="modelBox",n.isModelBox=!0,t.modelGroup.add(n),!i.coord&&e.coordinate&&2===e.coordinate.split(",").length){var a=e.coordinate.split(",");i.coord=[Number(a[1]),Number(a[0])]}i.coord&&(i.coord.isVector3?n.position.copy(i.coord):Array.isArray(i.coord)?3===i.coord.length?n.position.fromArray(i.coord):2===i.coord.length&&n.position.copy(t.coordinatesToVector3(i.coord)):i.coord.isCoordinates&&n.position.copy(t.coordinatesToVector3(i.coord)));var o=n.position.clone().normalize().add(n.position);e.isModel&&(e.position.y+=e.getSize().y/2),n.lookAt(o),n.rotateX(Math.PI/2),n.add(e),r&&r(e)},b(u(n.prototype),"loadModel",this).call(this,e,i)}},{key:"loadColorLayer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;e.tk=Ck.token,e.zoom=e.zoom||{min:1,max:18},e.crs=e.crs||"EPSG:3857";var n=e.id;"WMTS"===e.type?e=new ok(e):"TMS"===e.type&&(e=new rk(e));var i=new wF(n,{source:e});return this.mapView.addLayer(i).then((function(){t&&t()})),i}},{key:"loadWFSLayer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.protocol="wfs",e.crs=e.crs||"EPSG:4326",e.typeName=e.name;var t=new ak(e),n=new G_(e.id||(new ja).id,new ja,{name:e.name,update:CL.update,convert:rF({color:new Fn(e.color||"#00ff00"),opacity:e.opacity,altitude:5}),source:t,zoom:{min:3},transparent:!0,opacity:.5});return this.mapView.addLayer(n),n}},{key:"loadSHPLayer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.mapView;return $M.multiple(e.url,{arrayBuffer:["shp","dbf","shx"],text:["prj"]}).then((function(e){return xk(e,{out:{crs:"EPSG:3857",buildExtent:!0}})})).then((function(n){var i=new nk({features:n}),r=new lC(e.style),a=new wF(e.id||(new ja).id,{source:i,style:r,addLabelLayer:!0});return t.addLayer(a)}))}},{key:"loadGeoJSONLayer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.format=e.format||"application/json",e.crs=e.crs||"EPSG:4326";var t=new nk(e),n=new wF(e.id||(new ja).id,{transparent:!0,source:t,style:new lC(e.style)});return this.mapView.addLayer(n),n}},{key:"removeLayerById",value:function(e){this.mapView.removeLayer(e)}},{key:"getLayerById",value:function(e){return this.mapView.getLayerById(e)}},{key:"getLayers",value:function(){return this.mapView.getLayers().splice(2)}},{key:"load3DTilesLayer",value:function(e,t){var n=new JF;n.registerExtension("3DTILES_batch_table_hierarchy",c({},JE,bk));var i=e.id||(new zt).id,r=new $F(i,{name:e.name||i,source:new hk(e),registeredExtensions:n},this.mapView);return $S.prototype.addLayer.call(this.mapView,r).then((function(){t&&t()})),r}},{key:"coordinatesToVector3",value:function(e){return Array.isArray(e)&&(e=new ob("EPSG:4326",e[0],e[1])),e.as(this.mapView.referenceCrs).toVector3()}},{key:"vector3ToCoordinates",value:function(e){var t=new ob("EPSG:4978").setFromVector3(e).as("EPSG:4326");return[t.longitude,t.latitude]}},{key:"pickPosition",value:function(e){return this.mapView.getPickingPositionFromDepth(this.mapView.eventToViewCoords(e))}},{key:"pickCoordinates",value:function(e,t){return this.mapView.pickCoordinates(e,t)}},{key:"computeDistance",value:function(e,t){return e.isVector3&&(e=this.vector3ToCoordinates(e)),t.isVector3&&(t=this.vector3ToCoordinates(t)),e.isCoordinates&&(e=[e.x,e.y]),t.isCoordinates&&(t=[t.x,t.y]),If.computeDistance(e,t)}},{key:"getObjectCoord",value:function(e){return this.vector3ToCoordinates(e.getWorldPosition(new at))}},{key:"setObjectCoord",value:function(e,t){e&&(e.isModel&&(e=e.parent),e.position.copy(this.coordinatesToVector3(t)))}},{key:"setViewMode",value:function(e){if(this.viewMode!==e){switch(this.viewMode=e,this.controls.enabled=!1,e){case pp.GLOBE:this.controls=this.mapView.controls=this.controlsMap[pp.GLOBE];break;case pp.ROAM_FREE:this.controls=this.mapView.controls=this.controlsMap[pp.ROAM_FREE]||new HL(this.mapView);break;case pp.FLY:this.controls=this.mapView.controls=this.controlsMap[pp.FLY]||new kL(this.mapView);case pp.DRIVE:case pp.ROAM_AUTO:}this.controls.enabled=!0}}},{key:"fitCamera",value:function(){}},{key:"_initControls",value:function(){this.camera.defaultPos=this.camera.position.clone()}},{key:"_proxyEvent",value:function(){var e=this;this.renderManager.addEventListener(ld.UPDATE,(function(){e.dispatchEvent(ld.UPDATE)})),this.modelManager.addEventListener(ld.MODEL_UPDATE,(function(){e.dispatchEvent(ld.MODEL_UPDATE)}))}},{key:"loadElevationLayer",value:function(e){e.source=new ok(e.source);var t=new xF(e.id,e);return this.mapView.addLayer(t),t}},{key:"showElevationLayer",value:function(){this._elevationLayers.forEach((function(e){e.visible=!0}))}},{key:"hideElevationLayer",value:function(){this._elevationLayers.forEach((function(e){e.visible=!1}))}},{key:"getCoordsByAddress",value:function(e,t){var n=this;lu.getCoordsByAddress(e,(function(e){if(e.bound){var i=e.bound.split(","),r=n.computeDistance([Number(i[0]),Number(i[1])],[Number(i[0]),Number(i[3])]),a=n.computeDistance([Number(i[0]),Number(i[1])],[Number(i[2]),Number(i[1])]);e.range=Math.max(r,a)}t(e.coord,e.range)}))}},{key:"positioning",value:function(e,t){var n=this;Ek.onComplete=function(){n.controls.flyTo({coord:e,tilt:90,heading:.001,range:t}),Ek.onComplete=void 0},this.controls.flyTo(Ek)}},{key:"onUpdate",value:function(){}},{key:"dispose",value:function(){this.mapView.dispose(),b(u(n.prototype),"dispose",this).call(this)}}]),n}(Rg),Ik=function(){function e(){s(this,e)}return A(e,null,[{key:"createLine",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#ffffff",n=new Li;return e.forEach((function(e){n.vertices.push((new at).copy(e))})),new Go(n,new Do({color:t}))}},{key:"createSprite",value:function(e,t){var n=new go(new ro({map:(new tA).load(e,(function(e){}))}));return n.scale.set(t,t,t),n}},{key:"createPointLight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#ffffff",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=new LA(e,t,n);return i}},{key:"createSpotLight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#ffffff",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Math.PI/3,r=new _A(e,t,n,i);return r}},{key:"createBoundingBox",value:function(e,t){return new Lh(e,t)}},{key:"createFontMesh",value:function(e,t,n){(n=n||{}).font=e;var i=new Js(t,n);return i.computeBoundingBox(),new Ei(i,new Vh([new wl({color:n.color,shading:1}),new wl({color:n.color,shading:2})]))}},{key:"createLightHelper",value:function(e){var t;return e.isDirectionalLight?t=new Bh(e,1):e.isSpotLight?t=new nh(e):e.isPointLight&&(t=new lh(e)),t}},{key:"createPlane",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#ffffff",i=new $i(e,t),r=new Ei(i,new Nn({color:n}));return r.rotation.x=-Math.PI/2,r}}]),e}(),Lk=function(e,t){hu.call(this),void 0===du&&console.error("TexturePass relies on CopyShader");var n=du;this.map=e,this.opacity=void 0!==t?t:1,this.uniforms=Di.clone(n.uniforms),this.material=new Ri({uniforms:this.uniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,depthTest:!1,depthWrite:!1}),this.needsSwap=!1,this.fsQuad=new hu.FullScreenQuad(null)};Lk.prototype=Object.assign(Object.create(hu.prototype),{constructor:Lk,render:function(e,t,n){var i=e.autoClear;e.autoClear=!1,this.fsQuad.material=this.material,this.uniforms.opacity.value=this.opacity,this.uniforms.tDiffuse.value=this.map,this.material.transparent=this.opacity<1,e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(),this.fsQuad.render(e),e.autoClear=i}});var Fk={uniforms:{tDiffuse:{value:null},pixelSize:{value:null},kernel:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float pixelSize;\n uniform float kernel[25];\n varying vec2 vUv;\n void main(){\n vec4 texel = \n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-2, 2)))) * kernel[0] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-1, 2)))) * kernel[1] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 0, 2)))) * kernel[2] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 1, 2)))) * kernel[3] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 2, 2)))) * kernel[4] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-2, 1)))) * kernel[5] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-1, 1)))) * kernel[6] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 0, 1)))) * kernel[7] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 1, 1)))) * kernel[8] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 2, 1)))) * kernel[9] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-2, 0)))) * kernel[10] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-1, 0)))) * kernel[11] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 0, 0)))) * kernel[12] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 1, 0)))) * kernel[13] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 2, 0)))) * kernel[14] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-2,-1)))) * kernel[15] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-1,-1)))) * kernel[16] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 0,-1)))) * kernel[17] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 1,-1)))) * kernel[18] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 2,-1)))) * kernel[19] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-2,-2)))) * kernel[20] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2(-1,-2)))) * kernel[21] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 0,-2)))) * kernel[22] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 1,-2)))) * kernel[23] +\n texture2D(tDiffuse, fract(1.0 + (vUv + pixelSize * vec2( 2,-2)))) * kernel[24] ;\n\n gl_FragColor = texel / 256.0;\n }\n "},kk=new Kf;function Pk(e){if(uk||((uk=new $a({antialias:!0,alpha:!0})).setPixelRatio(window.devicePixelRatio),uk.setClearAlpha(0)),uk.setSize(e,e),dk)pk&&dk.remove(pk),mk&&dk.remove(mk),fk.left=e/-2,fk.right=e/2,fk.top=e/2,fk.bottom=e/-2,fk.updateProjectionMatrix();else{(dk=new Qt).background=null,dk.add(new UA(16777215,.7));var t=new PA(16777215,.7);t.position.set(-1,1,-1).normalize(),dk.add(t),fk=new FA(e/-2,e/2,e/2,e/-2,1,1e3)}fk.position.set(0,0,-e-1),fk.lookAt(0,0,0)}var Uk,Dk,Rk,Ok,Nk,zk,Qk,Gk,Hk=function(){function e(){s(this,e)}return A(e,null,[{key:"generateMaterialIcon",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:128;if(Pk(t),pk)pk.material=e;else{var n=new el(1,32,32);pd(n),pk=new Ei(n,e)}return dk.add(pk),pk.scale.set(t/2,t/2,t/2),uk.render(dk,fk),uk.domElement.style.background="transparent",uk.domElement.toDataURL("image/png")}},{key:"generateHDRIcon",value:function(e,t,n){Pk(t=t||128),kk.renderer=uk,kk.load(e,(function(e){var i=new Nn({map:e,side:2});if(mk)mk.material=i;else{var r=new $i(1,1);mk=new Ei(r,i)}dk.add(mk),mk.position.set(0,0,0),mk.scale.set(t,t,t),mk.rotateY(Math.PI),uk.render(dk,fk),n&&n(uk.domElement.toDataURL("image/jpeg"))}))}},{key:"generateTextureIcon",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:128;Pk(t);var n=new Nn({map:e,side:2});if(mk)mk.material=n;else{var i=new $i(1,1);mk=new Ei(i,n)}return dk.add(mk),mk.position.set(0,0,0),mk.scale.set(t,t,t),uk.render(dk,fk),uk.domElement.toDataURL("image/jpeg")}},{key:"generateBlurMap",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,i=arguments.length>3?arguments[3]:void 0;Pk(t),vk||(vk=new vu(uk),gk=new Lk,(yk=new fu(Fk)).uniforms.pixelSize.value=2/t,yk.uniforms.kernel.value=[1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1]),vk.setSize(t,t),vk.passes.length=0,vk.addPass(gk);for(var r=0;r10||e<1||(Jk=5*e,eP())}},{key:"getStrength",value:function(){return 10*qk}},{key:"setStrength",value:function(e){isNaN(e)||e>10||e<1||(qk=e/10,eP())}},{key:"getHeight",value:function(){return Zk/Yk}},{key:"setHeight",value:function(e){isNaN(e)||e>100||e<0||(Zk=Yk*e,eP())}},{key:"importShadow",value:function(t,n,i){i&&i.visible&&(e.createShadow(t,n),Zk=Yk*i.height||0,qk=i.strength/10||.3,Jk=5*i.blur||30,Kk=!0,eP())}}]),e}();function eP(){var e;if(Gk){Uk||((Uk=new $a({antialias:!0,alpha:!0})).setClearAlpha(0),Uk.setPixelRatio(window.devicePixelRatio),Uk.setSize(512,512),Uk.domElement.style.width="512px",Uk.domElement.style.height="512px",(Dk=new Qt).overrideMaterial=new Nn({color:0}),Rk=new FA(-1,1,1,-1,0,1e3)),Dk.remove(Dk.children[0]),Dk.add(Gk),Gk.updateMatrixWorld(),Vk.setFromObject(Gk);var t=Vk.max,n=Vk.min;Vk.getCenter(Wk);var i=t.x-n.x,r=t.z-n.z;(e=zk.geometry).scale.apply(e,[1.2*i/jk[0],1,1.2*r/jk[2]]),jk=[1.2*i,1,1.2*r],zk.position.set(Wk.x,n.y-Zk,Wk.z),Rk.left=-1.2*i/2,Rk.right=1.2*i/2,Rk.top=1.2*r/2,Rk.bottom=-1.2*r/2,Rk.far=t.y-n.y,Rk.updateProjectionMatrix(),Rk.position.set(Wk.x,t.y+.1,Wk.z),Rk.lookAt(Wk.x,n.y,Wk.z),Rk.updateMatrixWorld(),Uk.render(Dk,Rk),Qk.modelGroup.add(Gk),zk.material.map&&zk.material.map.dispose(),Hk.generateBlurMap(Uk.domElement.toDataURL("image/png"),512,Jk,(function(e){zk.material.opacity=qk,zk.material.map=(new tA).load(e),zk.material.needsUpdate=!0}))}}var tP,nP=new at,iP=new at,rP=new at,aP=function(e){h(n,e);var t=y(n);function n(e,i,r){var a;s(this,n),(a=t.call(this)).name="DirectionalLightIcon",a.light=i,a.camera=e,a.light.updateMatrixWorld(),a.color=r||"#1296db",a.matrix=i.matrixWorld,a.matrixAutoUpdate=!1,a.lightIcon=new go(new ro({map:(new tA).load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACUVJREFUeF7tW32MFGcZ/z0zd3yYKrezUFotpnA7e1RsJYG0pWhC+LDRVk0aISJVS5TCznJYiAWrMaCJEqspWphZKGrbCKI9Y+JHbRqwNVFKacBUKpbb2YOL0AZ6t7OHJS1wu/OYdz9gP2Z3Znb2OI33/rXZeT5/87zv+zzP+w5hl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8DA0cJfJQYh3JS7s/iP9mWFzBhHoPmOB15VW599oPV7fH/GgDyIDhdgApiYeWm3fK7hMEi4HFzfFjm5Tng1aF49NWSreFEaiEDz4J5Qkt8J7pIwD3pWORKei0KMdj0oaB3lpoGIJRIfY4YW8XxVGE1pZ1pLRIrOdyhn5otUfZ7rTgas7ntG0Px6VcArjwbpH4mPJKJRX7ZDNhNAaAYyZUA/axK4cXLWXzwwjpVnBNeGa0+HFV08+MgPF/tLBGvTMf83zj3DUAoYcaIYTihnR03IVyvSxtKnJgPW5oPSbqLmG8FMKNKxkkmeg22/RIk+2AmNlPcIaoZjXIOBscyWnSnn0jwBUC9tlR+CvhtUO460h6yO7oEb0Ya6sXqucNeDa+beea3GX/Zp2cAQrr5dSIx5x3HcUhYVl4qe3WmGTq3Yzg/hyaeAHDZ2pp2XnRxBABud/mcQHIDAcBmS1O/4wawNwCMVG/1bZCi4KadVwxTdG++XJTzU0tTRfbna7iAcNbS1BvdBLoC0OBOTtPO57s24IrrLBJo7qAWOepmcPXzRiDkbMw5v1b9WyOZrgAI5pBuvlXVM2zaeSGv1XeFnUGgfkseirotrp4AEI1TJmmzSHoY2EMStgZZ8FoNQB5Uw1zKwKZiLTEEwpNWTN3gFlGeACgJmbTL7Dy/Wq05CHFTUhO2I/jBhJiybe/kjg5umvm2F7t8AeBFoBeakYgAL3qdaMYAaBa5IHxjETCCa4DfFzM2Bfwi1gr6wrZKT5bLCvLJTBCbRiUCpuinbshR7lCpmSI+xGr2k5kgzgveUQGgmLgE/mQmqPOC/z91kP5273HRKgAAAABJRU5ErkJggg=="),sizeAttenuation:!1,depthTest:!1})),a.add(a.lightIcon),a.lightIcon.scale.multiplyScalar(2e-4),a.targetLines=[];for(var o=new Nn({depthTest:!0,color:a.color}),l=0;l<4;l++){var A=new ki(.001,.001,.25);A.translate(0,0,.125);var c=new Ei(A,o);c.renderOrder=5001,a.targetLines.push(c),a.add(c)}return a.targetLines[0].geometry.translate(0,.0075,0),a.targetLines[1].geometry.translate(0,-.0075,0),a.targetLines[2].geometry.translate(.0075,0,0),a.targetLines[3].geometry.translate(-.0075,0,0),a.size=1,a.update(),a}return A(n,[{key:"dispose",value:function(){this.lightIcon.geometry.dispose(),this.lightIcon.material.dispose(),this.targetLines.forEach((function(e){e.geometry.dispose(),e.material.dispose()}))}},{key:"update",value:function(){var e=this;nP.setFromMatrixPosition(this.light.matrixWorld),nP.normalize(),iP.setFromMatrixPosition(this.light.target.matrixWorld),iP.normalize(),rP.subVectors(iP,nP),rP.normalize(),this.lightIcon.lookAt(iP);var t=nP.distanceTo(this.camera.position)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n=this.size/75;this.lightIcon.scale.set(n,n,n),this.targetLines.forEach((function(n){n.lookAt(iP),n.scale.set(1,1,1).multiplyScalar(t*e.size/4)}))}}]),n}(zt),oP=function(){function e(){s(this,e)}return A(e,null,[{key:"screenShot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.hideAxes(e),i=this.hideGrid(e),r=(tP=e.renderManager.defaultRenderer).getPixelRatio()||1,a=t.width||300*r,o=t.height||300*r,s=tP.getSize(),l=tP.domElement.width,A=tP.domElement.height;tP.domElement.width=a,tP.domElement.height=o,tP.setSize(a,o);var c=e.camera.clone();c.aspect=a/o,c.updateProjectionMatrix(),e.renderManager.render(!0),tP.render(e.scene,c);var h=tP.domElement.toDataURL("image/png");return tP.domElement.width=l,tP.domElement.height=A,tP.setSize(s.x,s.y),n&&e.sceneManager.showAxesHelper(),i&&e.sceneManager.showGridHelp(),h}},{key:"encircleScreenShot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.hideAxes(e),i=this.hideGrid(e),r=(tP=e.renderManager.defaultRenderer).getPixelRatio()||1,a=t.count||16,o=t.width||300*r,s=t.height||300*r,l=tP.getSize(),A=tP.domElement.width,c=tP.domElement.height,h=e.camera.aspect;tP.domElement.width=o,tP.domElement.height=s,tP.setSize(o,s);var u=t.callback,d=o/s,f=e.camera,p=e.camera.clone();e.camera=p,f.aspect=d,f.updateProjectionMatrix(),p.aspect=d,p.updateProjectionMatrix(),e.controls.update();var m=new yp({camera:f,renderer:tP,renderManager:e.renderManager}),v=[];m.setPosition(e.camera.position.x,e.camera.position.y,e.camera.position.z),m.setTarget(e.controls.target.x,e.controls.target.y,e.controls.target.z);for(var g=0;g1&&void 0!==arguments[1]?arguments[1]:{};s(this,e),this.init(t,n)}return A(e,[{key:"init",value:function(t,n){this.model=t,this.path=n.path,this.directions=n.directions,this.target=n.target,this.rotate=n.rotate,this.tension=n.tension?n.tension:.2,this.time=n.time?n.time:3e3,this.loopType=n.loopType==e.LOOPTYPE_PINGPONG?e.LOOPTYPE_PINGPONG:e.LOOPTYPE_NORMAL,this.loop=n.loop||1/0,this.loopTypeState=0,this.tween=null,this.onUpdate=n.onUpdate,this.onRepeat=n.onRepeat,this.onComplete=n.onComplete}},{key:"path",get:function(){return this._path},set:function(e){if(this._path=[],e)for(var t=0;tMath.PI/2&&(s=-s);var l=new at(t.x,0,t.z).normalize(),A=t.clone(),c=l.angleTo(A);A.y>0&&(c=-c);var h=new nt;h.setFromAxisAngle(new at(1,0,0),c);var u=new nt;return u.setFromAxisAngle(new at(0,1,0),s),n.multiply(u),n.multiply(h),n}},{key:"isValidData",value:function(){return this.model?!this.path||this.path.length<2?(console.error("路径数据错误!"),!1):"number"!=typeof this.tension||this.tension<0||this.tension>1?(console.error("平滑系数取值为0-1之间!"),!1):"number"!=typeof this.time||this.time<=0?(console.error("时间应为正数!"),!1):0!==this.loopType&&1!==this.loopType?(console.error("循环类型只能取0或1!"),!1):!("number"!=typeof this.loop||this.loop<1)||(console.error("循环次数应大于0!"),!1):(console.error("未设置动画模型!"),!1)}}]),e}(),lP=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"catmullrom",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;s(this,e);var a=new cA(t);a.curveType=n,a.tension=i,this.curve=a,this.path=t,this.accuracy=r||10*t.length,this.curveType=n,this.tension=i,this.points=a.getPoints(this.accuracy),this.compute()}return A(e,[{key:"compute",value:function(){var e=this.points.length;this.allLen=0,this.lenArr=[0];for(var t=0;t1)return t?t.set(this.lastPoint.x,this.lastPoint.y,this.lastPoint.z):t=this.lastPoint.clone(),t;for(var n=this.allLen*e,i=0;in){var o=this.points[i],s=n-r,l=this.points[i+1].clone().sub(o).normalize(),A=o.clone().addScaledVector(l,s);return t?t.set(A.x,A.y,A.z):t=this.points[i].clone(),t}}var c=this.points[this.points.length-1];return t?t.set(c.x,c.y,c.z):t=c.clone(),t}},{key:"getLines",value:function(){for(var e=this.points,t=[],n=[],i=0;ir.x/r.z?o=(s=r.z)*n:s=(o=r.x)/n;var c=-(o*=1.1)/2,h=o/2,u=(s*=1.1)/2,d=-s/2,f=2*r.y;this.miniCamera.left=c,this.miniCamera.right=h,this.miniCamera.top=u,this.miniCamera.bottom=d,this.miniCamera.near=.1,this.miniCamera.far=f,this.miniCamera.updateProjectionMatrix(),this.miniCamera.position.copy(l),this.miniCamera.lookAt(A),n>1?(this.insetHeight=this.miniMinSize,this.insetWidth=this.insetHeight*n):(this.insetWidth=this.miniMinSize,this.insetHeight=this.insetWidth/n),this.renderer1||(this.renderer1=new $a({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));var p=this.renderer1;p.setClearAlpha(0),p.setPixelRatio(window.devicePixelRatio),p.setSize(e,t),p.setViewport(0,0,e,t),p.setClearColor(2236962,0),p.render(this.viewer.scene,this.miniCamera);var m=(new tA).load(p.domElement.toDataURL());p.clearDepth(),p.setScissorTest(!0),p.setScissor(this.leftMargin,t-this.insetHeight-this.topMargin,this.insetWidth,this.insetHeight),p.setViewport(this.leftMargin,t-this.insetHeight-this.topMargin,this.insetWidth,this.insetHeight),p.setClearColor(2236962,0),p.render(this.miniScene,this.miniCamera),p.setScissorTest(!1),this.miniPlane.geometry.dispose(),this.miniPlane.geometry=new qi(o,s),this.miniPlane.geometry.verticesNeedUpdate=!0,this.miniPlane.material.map=m,this.miniPlane.material.needsUpdate=!0,this.needUpdateMap=!1,this.setNodesVisible(!0)}}},{key:"show",value:function(){this.visible=!0}},{key:"hide",value:function(){this.visible=!1}},{key:"setNodes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this._hideNodes=[],t&&t.length>0&&this.viewer.modelGroup.traverse((function(n){"Object3D"!==n.type&&"Mesh"!==n.type||t.forEach((function(t){t==n.name&&e._hideNodes.push(n)}))}))}},{key:"setNodesVisible",value:function(e){this.model.visible=e,this._hideNodes.forEach((function(t){t&&(t.visible=e)}))}},{key:"onAfterRender",value:function(e,t,n,i,r){if(this.visible){var a=this.viewer.container.clientWidth,o=this.viewer.container.clientHeight,s=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.setScissorTest(!0),this.renderer.setScissor(this.leftMargin,o-this.insetHeight-this.topMargin,this.insetWidth,this.insetHeight),this.renderer.setViewport(this.leftMargin,o-this.insetHeight-this.topMargin,this.insetWidth,this.insetHeight),this.renderer.setClearColor(2236962,1),this.renderer.render(this.miniScene,this.miniCamera),this.renderer.setScissorTest(!1),this.updateMan(),this.renderer.autoClear=s,this.renderer.setViewport(0,0,a,o)}}},{key:"updateMan",value:function(){var e=new at(0,0,1),t=this.model.getWorldDirection(new at),n=this.getLookAtRotate(e,t);this.miniMan.material.rotation=n;var i=this.model.getWorldPosition(new at);this.miniMan.position.set(i.x,1,i.z)}},{key:"getLookAtRotate",value:function(e,t){var n=new at(t.x,0,t.z);if(0===e.x&&0===e.y&&0===e.z||0===n.x&&0===n.y&&0===n.z||e.x===n.x&&e.y===n.y&&e.z===n.z)return 0;var i=e.angleTo(n);return n.x<0?-i:i}},{key:"getLookAtRotateQue4",value:function(e,t){var n=new nt,i=new nt;if(i.setFromAxisAngle(new at(1,0,0),-Math.PI/2),n.multiply(i),0===e.x&&0===e.y&&0===e.z||0===t.x&&0===t.y&&0===t.z||e.x===t.x&&e.y===t.y&&e.z===t.z)return n;var r=e.clone(),a=new at(0,1,0).clone().cross(r).normalize(),o=new at(e.x,0,e.z).normalize(),s=new at(t.x,0,t.z).normalize(),l=o.angleTo(s);a.angleTo(s)>Math.PI/2&&(l=-l);var A=new nt;return A.setFromAxisAngle(new at(0,0,1),l),n.multiply(A),n}},{key:"hideNodeNames",set:function(e){this.setNodes(e)}},{key:"needUpdateMap",get:function(){return this._needUpdateMap},set:function(e){this._needUpdateMap=!!e,this.updateMap()}},{key:"texture",get:function(){return this._texture||(this._texture=(new tA).load("https://laozicloud-sdk.obs.myhuaweicloud.com/assets/image/miniMan2.png"),this._texture.wrapS=this._texture.wrapT=V,this._texture.repeat.set(1,1),this._texture.needsUpdate=!0),this._texture},set:function(e){e&&(this._texture=(new tA).load(e),this._texture.wrapS=this._texture.wrapT=V,this._texture.repeat.set(1,1),this._texture.needsUpdate=!0,this.miniMan.material.map=this._texture,this.miniMan.material.needsUpdate=!0)}},{key:"miniMinSize",get:function(){return this._miniMinSize},set:function(e){e&&(this._miniMinSize=e)}},{key:"manSize",get:function(){return this._manSize},set:function(e){e&&(this._manSize=e,this.miniMan.scale.set(e,e,e))}}]),n}(zt),cP=function(e){h(n,e);var t=y(n);function n(e,i){var r;return s(this,n),(r=t.call(this)).viewer=e,r.viewer.modelGroup.add(v(r)),r.renderer=e.renderer,r.model=i||r.createModel(),r.modelScale=.1,r.viewMinSize=200,r.rightMargin=10,r.bottomMargin=10,r._freeCamera=new Ni(r.viewer.camera.fov,r.viewer.camera.aspect,r.viewer.camera.near,r.viewer.camera.far),r.needUpdateMap=!0,r}return A(n,[{key:"updateMap",value:function(){if(this._needUpdateMap){var e=this.viewer.container.clientWidth,t=this.viewer.container.clientHeight,n=e/t;n>1?(this.insetHeight=this.viewMinSize,this.insetWidth=this.insetHeight*n):(this.insetWidth=this.viewMinSize,this.insetHeight=this.insetWidth/n),this.renderer1||(this.renderer1=new $a({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));var i=this.renderer1;i.setClearAlpha(0),i.setPixelRatio(window.devicePixelRatio),i.setSize(e,t),i.setViewport(0,0,e,t),i.setClearColor(2236962,0),i.render(this.viewer.scene,this._freeCamera),i.clearDepth(),i.setScissorTest(!0),i.setScissor(e-this.rightMargin-this.insetWidth,this.bottomMargin,this.insetWidth,this.insetHeight),i.setViewport(e-this.rightMargin-this.insetWidth,this.bottomMargin,this.insetWidth,this.insetHeight),i.setClearColor(2236962,0),i.render(this.viewer.scene,this._freeCamera),i.setScissorTest(!1),this.needUpdateMap=!1}}},{key:"createModel",value:function(){var e=new kf(this.viewer),t=new Ei(new Fi(2,2,4),new Gf({}));e.add(t);var n=new Ei(new Fi(1,1,3),new Gf({}));return n.position.z=2,e.add(n),this.add(e),e}},{key:"updateCameraQua",value:function(){this.model.recalculationBound();var e=this.model.boundingSphere,t=(new nt).copy(this.model.quaternion),n=(new nt).setFromAxisAngle(new at(0,1,0),Math.PI),i=(new nt).multiply(t).multiply(n);this._freeCamera.quaternion.copy(i);var r=this.model.getWorldDirection(new at),a=e.center.clone().addScaledVector(r,e.radius);this._freeCamera.position.copy(a)}},{key:"show",value:function(){this.visible=!0}},{key:"hide",value:function(){this.visible=!1}},{key:"onAfterRender",value:function(e,t,n,i,r){if(this.visible){this.updateCameraQua();var a=this.viewer.container.clientWidth,o=this.viewer.container.clientHeight,s=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.setScissorTest(!0),this.renderer.setScissor(a-this.rightMargin-this.insetWidth,this.bottomMargin,this.insetWidth,this.insetHeight),this.renderer.setViewport(a-this.rightMargin-this.insetWidth,this.bottomMargin,this.insetWidth,this.insetHeight),this.renderer.setClearColor(2236962,1),this.renderer.render(this.viewer.scene,this._freeCamera),this.renderer.setScissorTest(!1),this.renderer.autoClear=s,this.renderer.setViewport(0,0,a,o)}}},{key:"modelScale",get:function(){return this.model.scale.x},set:function(e){e&&this.model.scale.set(e,e,e)}},{key:"needUpdateMap",get:function(){return this._needUpdateMap},set:function(e){this._needUpdateMap=!!e,this.updateMap()}},{key:"viewMinSize",get:function(){return this._viewMinSize},set:function(e){e&&(this._viewMinSize=e)}}]),n}(zt);function hP(e,t){var n,i;this.viewer=e,this.camera=e.camera,this.rotateSpeed=.002,this.moveSpeed=5,this.Ammo=t,this.physicsWorld,this.rigidBodies=[],this.count=0,this.movingRegion=new tn(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0)),this.init=function(e){var t=this;this.Ammo().then((function(i){n=i,t.initPhysicsWorld(),e&&e(i)}))},this.initPhysicsWorld=function(){var e=new n.btDefaultCollisionConfiguration,t=new n.btCollisionDispatcher(e),i=new n.btDbvtBroadphase,r=new n.btSequentialImpulseConstraintSolver,a=new n.btDiscreteDynamicsWorld(t,i,r,e);a.setGravity(new n.btVector3(0,-9.82,0)),this.physicsWorld=a},this.bindModels=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Array.isArray(t)||(t=[t]),t.forEach((function(t){t.traverse((function(t){t.isMesh&&e.createRigidBody(t,n)}))}))},this.createRigidBody=function(e,t){var i,a,o=e.getWorldScale(new at),s=e.getWorldPosition(new at),l=e.getWorldQuaternion(new nt);if(e.isMesh){var A=this.getMeshData(e);i=A.faces,0==(a=A.vertices).length&&console.error("no vertices to define mesh shape with"),o||(o={x:1,y:1,z:1});var c=new n.btTriangleMesh;if(r.count++,!(r.count>200)){console.log(r.count);for(var h=0,u=i.length;h0&&(this.rigidBodies.push(e),x.setActivationState(4)),this.physicsWorld.addRigidBody(x),x}}else console.error("cannot make mesh shape for non-Mesh object")},this.getMeshData=function(e){var t=null!==e.geometry.index?e.geometry.index:void 0,n=e.geometry.attributes,i=e.scale;if(void 0!==n.position){for(var r=n.position,a=[],o=[],s=0;s0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=e.getMotionState();if(a){var o=new n.btTransform;a.getWorldTransform(o);var s=o.getOrigin(),l=o.getRotation(),A=new n.btTransform;A.setIdentity(),A.setOrigin(new n.btVector3(s.x()+t,s.y()+i,s.z()+r)),A.setRotation(new n.btQuaternion(l.x(),l.y(),l.z(),l.w())),e.setCenterOfMassTransform(A)}},e._getRotation=function(){return e._getPosAndRot()[1]},e._setLinearVelocity=function(t,i,r){e.setLinearVelocity(new n.btVector3(t,i,r))}}(u),this.physicsWorld.addRigidBody(u),this.person.userData.physicsBody=u,this.person.userData.collided=!1,this.rigidBodies.push(this.person),i=function(e,t,n){var i=new AMRT.BoxGeometry(e,t,n,1,1,1),a=new AMRT.Mesh(i,new Gf);return r.viewer.scene.add(a),a}(s.x,s.y,s.z)},this.setView=function(){var e,t,i,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(void 0!==a.position&&(e=Array.isArray(a.position)?(new AMRT.Vector3).fromArray(a.position):(new AMRT.Vector3).copy(a.position),r.person.position.copy(e)),void 0!==a.rotation&&(Array.isArray(a.rotation)?r.person.rotation.fromArray(a.rotation):r.person.rotation.setFromVector3(a.rotation)),r.person.userData.physicsBody){var o=r.person.userData.physicsBody,s=o.getMotionState();if(s){var l=new n.btTransform;s.getWorldTransform(l),e||(e=l.getOrigin(),e=new AMRT.Vector3(e.x(),e.y(),e.z())),t=r.person.getWorldQuaternion(new nt);var A=new n.btTransform;A.setIdentity(),A.setOrigin(new n.btVector3(e.x,e.y,e.z)),A.setRotation(new n.btQuaternion(t.x,t.y,t.z,t.w)),o.setCenterOfMassTransform(A)}}void 0!==a.cameraDirection?(i=Array.isArray(a.cameraDirection)?(new at).fromArray(a.cameraDirection):(new at).copy(a.cameraDirection)).normalize().negate():((i=this.person.getWorldDirection(new at)).y-=.4,i.normalize().negate()),a.distance&&(N=a.distance),a.minDistance&&(z=a.minDistance),a.maxDistance&&(Q=a.maxDistance),L(i)},this.getView=function(){return{position:this.person.position.toArray(),rotation:this.person.rotation.toArray(),cameraDirection:this.camera.getWorldDirection(new at),distance:N,minDistance:z,maxDistance:Q}};var r=this,a={type:"change"},o=new Bt(0,0,0,"YXZ"),s=Math.PI/2,l=new at,A=!1,c=!1,h=!1,u=!1,d=!1,f=!1,p=performance.now(),m=new at,v=new at;new Nc;var g,y=function(){if(!0===r.enabled){var e=performance.now(),t=(e-p)/1e3;m.x-=10*m.x*t,m.z-=10*m.z*t,m.y-=10*m.y*t,v.z=Number(A)-Number(c),v.x=Number(u)-Number(h),v.y=Number(f)-Number(d),v.normalize(),A||c||h||u?((A||c)&&(m.z-=v.z*r.moveSpeed*t,r.moveForward(-m.z*t)),(h||u)&&(m.x-=v.x*r.moveSpeed*t,r.moveRight(-m.x*t)),w("run")):(r.moveForward(0),w("stop")),p=e,r.physicsWorld.stepSimulation(t,10)}}.bind(this);function w(e){if(r.person)if(e){if(e!=g)switch(e){case"run":r.person.animation.play(P);break;case"up":r.person.animation.play(D);break;case"down":r.person.animation.play(R);break;case"jump":r.person.animation.play(U);break;default:r.person.animation.stop()}}else this.person.animation.stop();g=e}function x(e,t,a){var o;a=a||e,r.person.recalculationBound();var s=r.person.position.clone();if(Math.abs(t)>0){s.addScaledVector(e,t),o=s.clone().sub(r.person.position).normalize(),t=t<0?-1:1;var l=s.clone().addScaledVector(a,t*N*1e4);if(r.person.lookAt(l),r.person.userData.physicsBody)r.person.userData.physicsBody.setLinearVelocity(new n.btVector3(o.x*r.moveSpeed,o.y*r.moveSpeed,o.z*r.moveSpeed))}if(r.person.userData.physicsBody){var A=r.person.userData.physicsBody.getMotionState();if(A){var c=new n.btTransform;A.getWorldTransform(c);var h=c.getOrigin(),u=r.person.getWorldQuaternion(new nt);r.person.position.set(h.x(),h.y(),h.z()),i.position.set(h.x(),h.y(),h.z()),i.quaternion.copy(u)}L()}}function b(e){switch(e.keyCode){case 38:case 87:A=!0;break;case 37:case 65:h=!0;break;case 40:case 83:c=!0;break;case 39:case 68:u=!0;break;case 82:d=!0;break;case 70:f=!0;break;case 32:r.jump()}}function M(e){switch(e.keyCode){case 38:case 87:A=!1;break;case 37:case 65:h=!1;break;case 40:case 83:c=!1;break;case 39:case 68:u=!1;break;case 82:d=!1;break;case 70:f=!1}}function C(e){0===e.button&&document.addEventListener(ld.MOVE,E,!1)}function B(){document.removeEventListener(ld.MOVE,E,!1)}function E(e){if(!1!==r.enabled){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;G.set(t,n,0),0!=r.rotationAngle&&G.applyAxisAngle(new AMRT.Vector3(0,0,1),r.rotationAngle*Hh.DEG2RAD),o.setFromQuaternion(r.camera.quaternion),o.y+=G.x*r.rotateSpeed,o.x-=G.y*r.rotateSpeed,o.x=Math.max(-s,Math.min(s,o.x)),r.camera.quaternion.setFromEuler(o);var i=r.camera.getWorldDirection(new at),l=r.person.getWorldPosition(new at).clone().addScaledVector(i,-N);r.dispatchEvent(a),r.camera.position.copy(l)}}function S(e){!1!==r.enabled&&(e.deltaY<0?(--N0&&(++N>Q&&(N=Q),L()))}function T(e){r.preX=e.targetTouches[0].clientX,r.preY=e.targetTouches[0].clientY,document.addEventListener("touchmove",I,!1)}function _(){document.removeEventListener("touchmove",I,!1)}function I(e){if(!1!==r.enabled){var t=e.targetTouches[0].clientX-r.preX||0,n=e.targetTouches[0].clientY-r.preY||0;G.set(t,n,0),0!=r.rotationAngle&&G.applyAxisAngle(new AMRT.Vector3(0,0,1),r.rotationAngle*Hh.DEG2RAD),o.setFromQuaternion(r.camera.quaternion),o.y-=G.x*r.rotateSpeed,o.x-=G.y*r.rotateSpeed,o.x=Math.max(-s,Math.min(s,o.x)),r.camera.quaternion.setFromEuler(o);var i=r.camera.getWorldDirection(new at),l=r.person.getWorldPosition(new at).clone().addScaledVector(i,-N);r.dispatchEvent(a),r.camera.position.copy(l),r.preX=e.targetTouches[0].clientX,r.preY=e.targetTouches[0].clientY}}function L(e){e||(e=r.camera.getWorldDirection(new at).negate());var t=r.person.getWorldPosition(new at),n=t.clone().addScaledVector(e,N);r.camera.position.copy(n),r.camera.lookAt(t)}this.moveForward=function(e){l.setFromMatrixColumn(r.camera.matrix,2),l.y=0,l.normalize().negate(),x(l,e)},this.moveRight=function(e){l.setFromMatrixColumn(r.camera.matrix,0),l.y=0,l.normalize().negate(),x(l,-e)},new at,this.connect=function(){document.addEventListener(ld.START,C,!1),document.addEventListener(ld.END,B,!1),document.addEventListener("keydown",b,!1),document.addEventListener("keyup",M,!1),document.addEventListener("touchstart",T,!1),document.addEventListener("touchend",_,!1),document.addEventListener("wheel",S,!1)},this.disconnect=function(){document.removeEventListener(ld.START,C,!1),document.removeEventListener(ld.END,B,!1),document.removeEventListener("keydown",b,!1),document.removeEventListener("keyup",M,!1),document.removeEventListener("touchstart",T,!1),document.removeEventListener("touchend",_,!1),document.removeEventListener("wheel",S,!1)},this.rotationAngle=0;var F,k=!1;new at;var P,U,D,R,O,N,z,Q,G=new at;Object.defineProperties(this,{person:{get:function(){return O},set:function(e){(O=e).boundingBox.getSize(new at).y;var t=O.boundingSphere;N=5*t.radius,z=1*t.radius,Q=20*t.radius,O.name="threePersonControls",r.createPerson()}},distance:{get:function(){return N},set:function(e){N=e}},maxDistance:{get:function(){return Q},set:function(e){Q=e}},minDistance:{get:function(){return z},set:function(e){z=e}},enabled:{get:function(){return k},set:function(e){e=k=Boolean(e),r.viewer.controls.enabled=!e,e?(r.connect(),F=r.viewer.camera.near,r.viewer.camera.near=.1,r.viewer.camera.updateProjectionMatrix(),r.viewer.addEventListener("update",y)):(r.disconnect(),r.viewer.camera.near=F,r.viewer.camera.updateProjectionMatrix(),r.viewer.removeEventListener("update",y))}},runAnimationName:{set:function(e){P=e}},upAnimationName:{set:function(e){D=e}},downAnimationName:{set:function(e){R=e}},jumpAnimationName:{set:function(e){U=e}}})}return hP.prototype=Object.create(Je.prototype),hP.prototype.constructor=hP,e.ACESFilmicToneMapping=5,e.AMRTBasicMaterial=El,e.AMRTShadowMaterial=Sl,e.AddEquation=I,e.AddOperation=2,e.AdditiveBlending=2,e.AlphaFormat=le,e.AlwaysDepth=1,e.AlwaysStencilFunc=519,e.AmbientLight=UA,e.AmbientLightProbe=rc,e.AmmoHelper=hP,e.Anchor=Ym,e.AnimationClip=Gl,e.AnimationLoader=Zl,e.AnimationMixer=Dc,e.AnimationObjectGroup=Pc,e.AnimationUtils=_l,e.ArcCurve=rA,e.ArrayCamera=Wa,e.ArrowHelper=Rh,e.Audio=fc,e.AudioAnalyser=wc,e.AudioContext=$A,e.AudioListener=dc,e.AudioLoader=ec,e.AxesHelper=Oh,e.AxisHelper=function(e){return console.warn("AxisHelper has been renamed to AxesHelper."),new Oh(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicEditorTool=Nm,e.BasicModelTool=Pm,e.BasicShadowMap=0,e.BinaryTextureLoader=function(e){return console.warn("BinaryTextureLoader has been renamed to DataTextureLoader."),new ql(e)},e.Bone=_o,e.BooleanKeyframeTrack=Ul,e.BoundingBoxHelper=function(e,t){return console.warn("BoundingBoxHelper has been deprecated. Creating a BoxHelper instead."),new Lh(e,t)},e.Box2=jc,e.Box3=tn,e.Box3Helper=Fh,e.BoxBufferGeometry=ki,e.BoxGeometry=Fi,e.BoxHelper=Lh,e.BufferAttribute=zn,e.BufferGeometry=si,e.BufferGeometryLoader=QA,e.ByteType=1010,e.Cache=Xl,e.Camera=Oi,e.CameraHelper=Th,e.CameraViewMode=pp,e.CanvasRenderer=function(){console.error("CanvasRenderer has been removed")},e.CanvasTexture=ts,e.CatmullRomCurve3=cA,e.CineonToneMapping=4,e.CircleBufferGeometry=fl,e.CircleGeometry=dl,e.ClampToEdgeWrapping=j,e.Clipping=ip,e.Clock=lc,e.ClosedSplineCurve3=jh,e.Color=Fn,e.ColorKeyframeTrack=Dl,e.CompressedTexture=es,e.CompressedTextureLoader=Jl,e.ConeBufferGeometry=ul,e.ConeGeometry=hl,e.CubeCamera=Qi,e.CubeGeometry=Fi,e.CubeReflectionMapping=N,e.CubeRefractionMapping=z,e.CubeTexture=hr,e.CubeTextureLoader=eA,e.CubeUVReflectionMapping=G,e.CubeUVRefractionMapping=H,e.CubicBezierCurve=fA,e.CubicBezierCurve3=pA,e.CubicInterpolant=Ll,e.CullFaceBack=1,e.CullFaceFront=2,e.CullFaceFrontBack=3,e.CullFaceNone=0,e.Curve=nA,e.CurvePath=bA,e.CustomBlending=5,e.CylinderBufferGeometry=cl,e.CylinderGeometry=Al,e.Cylindrical=Hc,e.DataTexture=Hi,e.DataTexture2DArray=ur,e.DataTexture3D=dr,e.DataTextureLoader=ql,e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=34056,e.DefaultLoadingManager=jl,e.DepthFormat=fe,e.DepthStencilFormat=pe,e.DepthTexture=ns,e.DirectionalLight=PA,e.DirectionalLightHelper=Bh,e.DirectionalLightIcon=aP,e.DirectionalLightShadow=kA,e.DiscreteInterpolant=kl,e.DodecahedronBufferGeometry=ps,e.DodecahedronGeometry=fs,e.DoubleSide=2,e.DstAlphaFactor=D,e.DstColorFactor=R,e.DynamicBufferAttribute=function(e,t){return console.warn("DynamicBufferAttribute has been removed. Use new BufferAttribute().setDynamic( true ) instead."),new zn(e,t).setDynamic(!0)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=Ye,e.DynamicReadUsage=35049,e.EdgesGeometry=ll,e.EdgesHelper=function(e,t){return console.warn("EdgesHelper has been removed. Use EdgesGeometry instead."),new jo(new ll(e.geometry),new Do({color:void 0!==t?t:16777215}))},e.EllipseCurve=iA,e.EntityFactory=Ik,e.EqualDepth=4,e.EqualStencilFunc=514,e.EquirectangularReflectionMapping=303,e.EquirectangularRefractionMapping=Q,e.Euler=Bt,e.Event=ld,e.EventDispatcher=Je,e.Exploding=Ld,e.ExtrudeBufferGeometry=Ys,e.ExtrudeBufferGeometry2=Jh,e.ExtrudeGeometry=Xs,e.ExtrudeGeometry2=Zh,e.Face3=Dn,e.Face4=function(e,t,n,i,r,a,o){return console.warn("Face4 has been removed. A Face3 will be created instead."),new Dn(e,t,n,r,a,o)},e.FaceColors=1,e.FaceNormalsHelper=xh,e.FileLoader=Kl,e.FlatShading=1,e.Float32Attribute=function(e,t){return console.warn("Float32Attribute has been removed. Use new Float32BufferAttribute() instead."),new Yn(e,t)},e.Float32BufferAttribute=Yn,e.Float64Attribute=function(e,t){return console.warn("Float64Attribute has been removed. Use new Float64BufferAttribute() instead."),new Kn(e,t)},e.Float64BufferAttribute=Kn,e.FloatType=ne,e.FlyLineTool=Om,e.Fog=to,e.FogExp2=eo,e.Font=ZA,e.FontLoader=qA,e.FreeCamera=cP,e.FrontFaceDirectionCCW=1,e.FrontFaceDirectionCW=0,e.FrontSide=0,e.Frustum=Wi,e.GISViewer=_k,e.GammaEncoding=ze,e.Geometry=Li,e.GeometryUtils=Yh,e.GreaterDepth=6,e.GreaterEqualDepth=5,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=ph,e.Group=ja,e.HalfFloatType=ie,e.HemisphereLight=EA,e.HemisphereLightHelper=dh,e.HemisphereLightProbe=ic,e.IconHelper=Hk,e.IcosahedronBufferGeometry=ds,e.IcosahedronGeometry=us,e.ImageBitmapLoader=YA,e.ImageLoader=$l,e.ImageUtils=At,e.ImmediateRenderObject=Kc,e.IncrementStencilOp=7682,e.IncrementWrapStencilOp=34055,e.InstancedBufferAttribute=zA,e.InstancedBufferGeometry=NA,e.InstancedInterleavedBuffer=Oc,e.InstancedMesh=Uo,e.Int16Attribute=function(e,t){return console.warn("Int16Attribute has been removed. Use new Int16BufferAttribute() instead."),new Vn(e,t)},e.Int16BufferAttribute=Vn,e.Int32Attribute=function(e,t){return console.warn("Int32Attribute has been removed. Use new Int32BufferAttribute() instead."),new Wn(e,t)},e.Int32BufferAttribute=Wn,e.Int8Attribute=function(e,t){return console.warn("Int8Attribute has been removed. Use new Int8BufferAttribute() instead."),new Qn(e,t)},e.Int8BufferAttribute=Qn,e.IntType=1013,e.InterleavedBuffer=no,e.InterleavedBufferAttribute=io,e.Interpolant=Il,e.InterpolateDiscrete=Fe,e.InterpolateLinear=ke,e.InterpolateSmooth=Pe,e.InvertStencilOp=5386,e.JSONLoader=function(){console.error("JSONLoader has been removed.")},e.KeepStencilOp=We,e.KeyframeTrack=Pl,e.LOD=bo,e.LargeSceneLoader=dg,e.LargeSceneLoader2=kg,e.LatheBufferGeometry=rl,e.LatheGeometry=il,e.Layers=Et,e.LensFlare=function(){console.error("LensFlare has been moved to /examples/js/objects/Lensflare.js")},e.LessDepth=2,e.LessEqualDepth=3,e.LessEqualStencilFunc=515,e.LessStencilFunc=513,e.Light=BA,e.LightProbe=nc,e.LightProbeHelper=fh,e.LightShadow=SA,e.Line=Go,e.Line3=Yc,e.LineBasicMaterial=Do,e.LineCurve=mA,e.LineCurve3=vA,e.LineDashedMaterial=Bl,e.LineLoop=Wo,e.LinePieces=1,e.LineSegments=jo,e.LineStrip=0,e.LinearEncoding=Oe,e.LinearFilter=Z,e.LinearInterpolant=Fl,e.LinearMipMapLinearFilter=1008,e.LinearMipMapNearestFilter=1007,e.LinearMipmapLinearFilter=q,e.LinearMipmapNearestFilter=J,e.LinearToneMapping=1,e.Loader=Wl,e.LoaderUtils=OA,e.LoadingManager=Vl,e.LogLuvEncoding=3003,e.LoopOnce=Ie,e.LoopPingPong=2202,e.LoopRepeat=Le,e.LuminanceAlphaFormat=ue,e.LuminanceFormat=he,e.MOUSE=_,e.MapSource=Ck,e.Material=On,e.MaterialLoader=RA,e.Math=et,e.MathUtils=Hh,e.Matrix3=lt,e.Matrix4=bt,e.MaxEquation=104,e.Measure3D=Lm,e.Measure3DTool=Dm,e.Mesh=Ei,e.MeshBasicMaterial=Nn,e.MeshDepthMaterial=Ra,e.MeshDistanceMaterial=Oa,e.MeshLambertMaterial=Ml,e.MeshMatcapMaterial=Cl,e.MeshNormalMaterial=bl,e.MeshPhongMaterial=wl,e.MeshPhysicalMaterial=yl,e.MeshStandardMaterial=gl,e.MeshToonMaterial=xl,e.MinEquation=103,e.MinimapTool=AP,e.MirroredRepeatWrapping=W,e.MixOperation=1,e.MultiMaterial=Vh,e.MultiplyBlending=4,e.MultiplyOperation=0,e.NearestFilter=X,e.NearestMipMapLinearFilter=1005,e.NearestMipMapNearestFilter=1004,e.NearestMipmapLinearFilter=K,e.NearestMipmapNearestFilter=Y,e.NeverDepth=0,e.NeverStencilFunc=512,e.NoBlending=0,e.NoColors=0,e.NoToneMapping=0,e.NormalBlending=1,e.NotEqualDepth=7,e.NotEqualStencilFunc=517,e.NumberKeyframeTrack=Rl,e.Object3D=zt,e.ObjectLoader=HA,e.ObjectSpaceNormalMap=1,e.OctahedronBufferGeometry=hs,e.OctahedronGeometry=cs,e.OneFactor=F,e.OneMinusDstAlphaFactor=207,e.OneMinusDstColorFactor=209,e.OneMinusSrcAlphaFactor=U,e.OneMinusSrcColorFactor=203,e.OrthographicCamera=FA,e.PCFShadowMap=1,e.PCFSoftShadowMap=2,e.ParametricBufferGeometry=as,e.ParametricGeometry=rs,e.Particle=function(e){return console.warn("Particle has been renamed to Sprite."),new go(e)},e.ParticleBasicMaterial=function(e){return console.warn("ParticleBasicMaterial has been renamed to PointsMaterial."),new Xo(e)},e.ParticleSystem=function(e,t){return console.warn("ParticleSystem has been renamed to Points."),new qo(e,t)},e.ParticleSystemMaterial=function(e){return console.warn("ParticleSystemMaterial has been renamed to PointsMaterial."),new Xo(e)},e.Path=MA,e.PathEditor=Tm,e.PathEditorTool=Um,e.PathTween=sP,e.PerspectiveCamera=Ni,e.Plane=vn,e.PlaneBufferGeometry=$i,e.PlaneGeometry=qi,e.PlaneHelper=kh,e.PointCloud=function(e,t){return console.warn("PointCloud has been renamed to Points."),new qo(e,t)},e.PointCloudMaterial=function(e){return console.warn("PointCloudMaterial has been renamed to PointsMaterial."),new Xo(e)},e.PointLight=LA,e.PointLightHelper=lh,e.Points=qo,e.PointsMaterial=Xo,e.PolarGridHelper=mh,e.PolyhedronBufferGeometry=ss,e.PolyhedronGeometry=os,e.PositionalAudio=yc,e.PositionalAudioHelper=vh,e.PropertyBinding=kc,e.PropertyMixer=xc,e.QuadraticBezierCurve=gA,e.QuadraticBezierCurve3=yA,e.Quaternion=nt,e.QuaternionKeyframeTrack=Nl,e.QuaternionLinearInterpolant=Ol,e.REVISION=T,e.RGBADepthPacking=je,e.RGBAFormat=ce,e.RGBA_ASTC_10x10_Format=37819,e.RGBA_ASTC_10x5_Format=37816,e.RGBA_ASTC_10x6_Format=37817,e.RGBA_ASTC_10x8_Format=37818,e.RGBA_ASTC_12x10_Format=37820,e.RGBA_ASTC_12x12_Format=37821,e.RGBA_ASTC_4x4_Format=Ee,e.RGBA_ASTC_5x4_Format=37809,e.RGBA_ASTC_5x5_Format=37810,e.RGBA_ASTC_6x5_Format=37811,e.RGBA_ASTC_6x6_Format=37812,e.RGBA_ASTC_8x5_Format=37813,e.RGBA_ASTC_8x6_Format=37814,e.RGBA_ASTC_8x8_Format=37815,e.RGBA_BPTC_Format=Se,e.RGBA_ETC2_EAC_Format=_e,e.RGBA_PVRTC_2BPPV1_Format=Ce,e.RGBA_PVRTC_4BPPV1_Format=Me,e.RGBA_S3TC_DXT1_Format=ge,e.RGBA_S3TC_DXT3_Format=ye,e.RGBA_S3TC_DXT5_Format=we,e.RGBDEncoding=Ve,e.RGBEEncoding=Qe,e.RGBEFormat=de,e.RGBELoader=Nh,e.RGBFormat=Ae,e.RGBM16Encoding=He,e.RGBM7Encoding=Ge,e.RGB_ETC1_Format=Be,e.RGB_ETC2_Format=Te,e.RGB_PVRTC_2BPPV1_Format=be,e.RGB_PVRTC_4BPPV1_Format=xe,e.RGB_S3TC_DXT1_Format=ve,e.RawShaderMaterial=vl,e.Ray=dn,e.Raycaster=Nc,e.RectAreaLight=DA,e.RectAreaLightHelper=Ah,e.RedFormat=me,e.ReinhardToneMapping=2,e.RenderOrder2=Ze,e.RenderOrder3=3e3,e.RenderOrder5=Ke,e.RepeatWrapping=V,e.ReplaceStencilOp=7681,e.ReverseSubtractEquation=102,e.RingBufferGeometry=nl,e.RingGeometry=tl,e.Scene=Qt,e.SceneUtils=Kh,e.ScreenHelper=oP,e.SelectionTool=Rm,e.ShaderChunk=Xi,e.ShaderLib=Ki,e.ShaderMaterial=Ri,e.ShadowHelper=$k,e.ShadowMaterial=ml,e.Shape=CA,e.ShapeBufferGeometry=ol,e.ShapeGeometry=al,e.ShapePath=KA,e.ShapeUtils=Vs,e.ShortType=1011,e.Skeleton=To,e.SkeletonHelper=sh,e.SkinnedMesh=Bo,e.SmoothShading=2,e.Sphere=an,e.SphereBufferGeometry=el,e.SphereGeometry=$s,e.Spherical=Gc,e.SphericalHarmonics3=tc,e.SphericalReflectionMapping=305,e.Spline=Xh,e.SplineCurve=wA,e.SplineCurve3=Wh,e.SpotLight=_A,e.SpotLightHelper=nh,e.SpotLightShadow=TA,e.Sprite=go,e.SpriteMaterial=ro,e.SrcAlphaFactor=P,e.SrcAlphaSaturateFactor=210,e.SrcColorFactor=k,e.StaticCopyUsage=35046,e.StaticDrawUsage=Xe,e.StaticReadUsage=35045,e.StereoCamera=sc,e.StreamCopyUsage=35042,e.StreamDrawUsage=35040,e.StreamReadUsage=35041,e.StringKeyframeTrack=zl,e.SubtractEquation=101,e.SubtractiveBlending=3,e.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e.TWEEN=ud,e.TangentSpaceNormalMap=0,e.TetrahedronBufferGeometry=As,e.TetrahedronGeometry=ls,e.TextBufferGeometry=qs,e.TextGeometry=Js,e.Texture=ht,e.TextureLoader=tA,e.TorusBufferGeometry=xs,e.TorusGeometry=ws,e.TorusKnotBufferGeometry=ys,e.TorusKnotGeometry=gs,e.TransFormMode=Mm,e.TransformControls=bm,e.Triangle=Tn,e.TriangleFanDrawMode=2,e.TriangleStripDrawMode=1,e.TrianglesDrawMode=0,e.TubeBufferGeometry=vs,e.TubeGeometry=ms,e.UVMapping=O,e.Uint16Attribute=function(e,t){return console.warn("Uint16Attribute has been removed. Use new Uint16BufferAttribute() instead."),new jn(e,t)},e.Uint16BufferAttribute=jn,e.Uint32Attribute=function(e,t){return console.warn("Uint32Attribute has been removed. Use new Uint32BufferAttribute() instead."),new Xn(e,t)},e.Uint32BufferAttribute=Xn,e.Uint8Attribute=function(e,t){return console.warn("Uint8Attribute has been removed. Use new Uint8BufferAttribute() instead."),new Gn(e,t)},e.Uint8BufferAttribute=Gn,e.Uint8ClampedAttribute=function(e,t){return console.warn("Uint8ClampedAttribute has been removed. Use new Uint8ClampedBufferAttribute() instead."),new Hn(e,t)},e.Uint8ClampedBufferAttribute=Hn,e.Uncharted2ToneMapping=3,e.Uniform=Rc,e.UniformsLib=Yi,e.UniformsUtils=Di,e.UnsignedByteType=$,e.UnsignedInt248Type=se,e.UnsignedIntType=te,e.UnsignedShort4444Type=re,e.UnsignedShort5551Type=ae,e.UnsignedShort565Type=oe,e.UnsignedShortType=ee,e.VSMShadowMap=3,e.Vector2=tt,e.Vector3=at,e.Vector4=ut,e.VectorKeyframeTrack=Ql,e.Vertex=function(e,t,n){return console.warn("Vertex has been removed. Use Vector3 instead."),new at(e,t,n)},e.VertexColors=2,e.VertexNormalsHelper=eh,e.VideoTexture=li,e.Viewer=Rg,e.WebGLMultisampleRenderTarget=ft,e.WebGLRenderTarget=dt,e.WebGLRenderTargetCube=Gi,e.WebGLRenderer=$a,e.WebGLUtils=Ga,e.WireframeGeometry=is,e.WireframeHelper=function(e,t){return console.warn("WireframeHelper has been removed. Use WireframeGeometry instead."),new jo(new is(e.geometry),new Do({color:void 0!==t?t:16777215}))},e.WorkerBufferAttribute=Zn,e.WrapAroundEnding=Re,e.XHRLoader=function(e){return console.warn("XHRLoader has been renamed to FileLoader."),new Kl(e)},e.ZeroCurvatureEnding=Ue,e.ZeroFactor=L,e.ZeroSlopeEnding=De,e.ZeroStencilOp=0,e._Math=et,e.sRGBEncoding=Ne,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/public/amrt_decoder.js b/public/amrt_decoder.js new file mode 100644 index 0000000..6bf4b75 --- /dev/null +++ b/public/amrt_decoder.js @@ -0,0 +1,50 @@ +var DracoDecoderModule = (function() { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(DracoDecoderModule) { + DracoDecoderModule = DracoDecoderModule || {}; + +var Module=typeof DracoDecoderModule!=="undefined"?DracoDecoderModule:{};var isRuntimeInitialized=false;var isModuleParsed=false;Module["onRuntimeInitialized"]=function(){isRuntimeInitialized=true;if(isModuleParsed){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};Module["onModuleParsed"]=function(){isModuleParsed=true;if(isRuntimeInitialized){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};function isVersionSupported(versionString){if(typeof versionString!=="string")return false;const version=versionString.split(".");if(version.length<2||version.length>3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;if(end>_emscripten_get_heap_size()){abort()}HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}function convertJsFunctionToWasm(func,sig){return func}function addFunctionWasm(func,sig){var table=wasmTable;var ret=table.length;try{table.grow(1)}catch(err){if(!err instanceof RangeError){throw err}throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{table.set(ret,func)}catch(err){if(!err instanceof TypeError){throw err}assert(typeof sig!=="undefined","Missing signature argument to addFunction");var wrapped=convertJsFunctionToWasm(func,sig);table.set(ret,wrapped)}return ret}function removeFunctionWasm(index){}var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];var WebAssembly={Memory:function(opts){return{buffer:new ArrayBuffer(opts["initial"]*65536),grow:function(amount){var ret=__growWasmMemory(amount);return ret}}},Table:function(opts){var ret=new Array(opts["initial"]);ret.grow=function(by){if(ret.length>=381+0){abort("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.")}ret.push(null)};ret.set=function(i,func){ret[i]=func};ret.get=function(i){return ret[i]};return ret},Module:function(binary){return{}},Instance:function(module,info){var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=0;q[c>>2]=0;q[c+4>>2]=0;d=dm(b);if(d>>>0<4294967280){a:{b:{if(d>>>0>=11){f=d+16&-16;e=Mm(f);q[c+8>>2]=f|-2147483648;q[c>>2]=e;q[c+4>>2]=d;break b}o[c+11|0]=d;e=c;if(!d){break a}}Cn(e,b,d)}o[d+e|0]=0;a=ga(a,c);if(o[c+11|0]<=-1){An(q[c>>2])}T=c+16|0;return(a|0)!=0}Pm();F()}function ga(a,b){var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=q[a+4>>2];if(a){h=r[b+11|0];i=h<<24>>24<0;h=i?q[b+4>>2]:h;l=i?q[b>>2]:b;while(1){b=a+16|0;g=r[a+27|0];i=g<<24>>24<0;j=i?q[a+20>>2]:g;m=j>>>0>>0;a:{b:{c:{d:{e:{f:{g=m?j:h;if(g){k=i?q[b>>2]:b;n=cm(l,k,g);if(n){break f}}if(h>>>0>>0){break a}if(!g){break d}k=i?q[b>>2]:b;break e}if((n|0)<=-1){break a}}b=cm(k,l,g);if(b){break c}}if(m){break b}return 1}if((b|0)<=-1){break b}return 1}a=a+4|0}a=q[a>>2];if(a){continue}break}}return 0}function ha(a,b){var p=0,r=0,s=0,t=0;p=T-16|0;T=p;q[p+12>>2]=0;q[p+8>>2]=0;q[p>>2]=0;q[p+4>>2]=0;r=dm(b);if(r>>>0<4294967280){a:{b:{if(r>>>0>=11){t=r+16&-16;s=Mm(t);q[p+8>>2]=t|-2147483648;q[p>>2]=s;q[p+4>>2]=r;break b}o[p+11|0]=r;s=p;if(!r){break a}}Cn(s,b,r)}o[r+s|0]=0;Vk(a,p,p+12|0);a=q[p+12>>2];if(o[p+11|0]<=-1){An(q[p>>2])}T=p+16|0;return a}Pm();F()}function ia(a,b,u){var v=0,w=0,x=0,y=0;v=T-32|0;T=v;q[v+24>>2]=0;q[v+16>>2]=0;q[v+20>>2]=0;w=dm(b);if(w>>>0<4294967280){a:{b:{if(w>>>0>=11){y=w+16&-16;x=Mm(y);q[v+24>>2]=y|-2147483648;q[v+16>>2]=x;q[v+20>>2]=w;break b}o[v+27|0]=w;x=v+16|0;if(!w){break a}}Cn(x,b,w)}o[w+x|0]=0;q[v+8>>2]=0;q[v>>2]=0;q[v+4>>2]=0;Wk(a,v+16|0,v);a=q[u>>2];if(a){q[u+4>>2]=a;An(a);q[u+8>>2]=0;q[u>>2]=0;q[u+4>>2]=0}q[u>>2]=q[v>>2];q[u+4>>2]=q[v+4>>2];q[u+8>>2]=q[v+8>>2];if(o[v+27|0]<=-1){An(q[v+16>>2])}T=v+32|0;return}Pm();F()}function ja(a,b){var u=0,z=0,A=0,B=0,C=0;u=T-32|0;T=u;q[u+24>>2]=0;q[u+28>>2]=0;q[u+16>>2]=0;q[u+8>>2]=0;q[u+12>>2]=0;z=dm(b);if(z>>>0<4294967280){a:{b:{if(z>>>0>=11){B=z+16&-16;A=Mm(B);q[u+16>>2]=B|-2147483648;q[u+8>>2]=A;q[u+12>>2]=z;break b}o[u+19|0]=z;A=u+8|0;if(!z){break a}}Cn(A,b,z)}o[z+A|0]=0;Xk(a,u+8|0,u+24|0);C=v[u+24>>3];if(o[u+19|0]<=-1){An(q[u+8>>2])}T=u+32|0;return C}Pm();F()}function ka(a,b,D){var E=0,G=0,H=0,I=0;E=T-16|0;T=E;q[E+8>>2]=0;q[E>>2]=0;q[E+4>>2]=0;G=dm(D);if(G>>>0<4294967280){a:{b:{if(G>>>0>=11){I=G+16&-16;H=Mm(I);q[E+8>>2]=I|-2147483648;q[E>>2]=H;q[E+4>>2]=G;break b}o[E+11|0]=G;H=E;if(!G){break a}}Cn(H,D,G)}o[G+H|0]=0;a=a+16|0;D=0;c:{if(!Yk(b,E,a)){break c}D=q[a>>2];if(o[a+11|0]<=-1){break c}D=a}if(o[E+11|0]<=-1){An(q[E>>2])}T=E+16|0;return D}Pm();F()}function la(a,b,D){var F=0,J=0,K=0,L=0;a:{if(q[a+12>>2]==(b|0)){break a}F=q[a>>2];K=a+4|0;J=q[K>>2];if((F|0)!=(J|0)){while(1){L=J+ -12|0;if(o[J+ -1|0]<=-1){An(q[L>>2])}J=L;if((J|0)!=(F|0)){continue}break}}q[a+12>>2]=b;q[K>>2]=F;J=q[b>>2];K=b+4|0;if((J|0)==(K|0)){break a}L=a+8|0;while(1){b=J+16|0;b:{if(q[L>>2]!=(F|0)){Rm(F,b);b=a+4|0;q[b>>2]=q[b>>2]+12;break b}ma(a,b)}F=q[J+4>>2];c:{if(!F){b=q[J+8>>2];if(q[b>>2]==(J|0)){break c}J=J+8|0;while(1){F=q[J>>2];J=F+8|0;b=q[F+8>>2];if((F|0)!=q[b>>2]){continue}break}break c}while(1){b=F;F=q[F>>2];if(F){continue}break}}if((b|0)==(K|0)){break a}F=q[a+4>>2];J=b;continue}}F=0;d:{if((D|0)<0){break d}b=q[a+4>>2];a=q[a>>2];if((b-a|0)/12>>>0<=D>>>0){break d}F=a+w(D,12)|0;if(o[F+11|0]>-1){break d}F=q[F>>2]}return F}function ma(a,b){var D=0,M=0,N=0,O=0,P=0;a:{b:{c:{N=q[a>>2];P=(q[a+4>>2]-N|0)/12|0;D=P+1|0;if(D>>>0<357913942){N=(q[a+8>>2]-N|0)/12|0;O=N<<1;D=N>>>0<178956970?O>>>0>>0?D:O:357913941;M=0;d:{if(!D){break d}if(D>>>0>=357913942){break c}M=Mm(w(D,12))}N=M+w(D,12)|0;b=Rm(M+w(P,12)|0,b);P=b+12|0;D=q[a+4>>2];M=q[a>>2];if((D|0)==(M|0)){break b}while(1){D=D+ -12|0;O=q[D+4>>2];b=b+ -12|0;q[b>>2]=q[D>>2];q[b+4>>2]=O;O=D+8|0;q[b+8>>2]=q[O>>2];q[D>>2]=0;q[D+4>>2]=0;q[O>>2]=0;if((D|0)!=(M|0)){continue}break}M=q[a+4>>2];D=q[a>>2];break a}bn();F()}ab(1040);F()}D=M}q[a>>2]=b;q[a+8>>2]=N;q[a+4>>2]=P;if((D|0)!=(M|0)){while(1){a=M+ -12|0;if(o[M+ -1|0]<=-1){An(q[a>>2])}M=a;if((a|0)!=(D|0)){continue}break}}if(D){An(D)}}function na(a){var b=0;ck(a);b=a+16|0;q[b>>2]=0;q[b+4>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;q[a+12>>2]=b;q[a+32>>2]=0;q[a+36>>2]=0;return a}function oa(a){var Q=0;Q=T-32|0;T=Q;hh(Q+8|0,a);a=q[Q+24>>2];if(o[Q+23|0]<=-1){An(q[Q+12>>2])}T=Q+32|0;return a}function pa(a,R,S){var U=0;U=T-16|0;T=U;ih(U,a,R,S);q[a+24>>2]=q[U>>2];Tm(a+28|0,U|4);a=a+24|0;if(o[U+15|0]<=-1){An(q[U+4>>2])}T=U+16|0;return a}function qa(a,R,S){var V=0;V=T-16|0;T=V;jh(V,a,R,S);q[a+24>>2]=q[V>>2];Tm(a+28|0,V|4);a=a+24|0;if(o[V+15|0]<=-1){An(q[V+4>>2])}T=V+16|0;return a}function ra(a,R){var S=0,W=0,X=0,Y=0;S=T-32|0;T=S;q[S+24>>2]=0;q[S+16>>2]=0;q[S+20>>2]=0;W=dm(R);if(W>>>0<4294967280){a:{b:{if(W>>>0>=11){Y=W+16&-16;X=Mm(Y);q[S+24>>2]=Y|-2147483648;q[S+16>>2]=X;q[S+20>>2]=W;break b}o[S+27|0]=W;X=S+16|0;if(!W){break a}}Cn(X,R,W)}o[W+X|0]=0;q[S+8>>2]=67108864;q[S>>2]=0;q[S+4>>2]=0;o[S+4|0]=0;q[S>>2]=1701667182;W=q[a+4>>2];R=-1;c:{if(!W){break c}W=Pk(W,S,S+16|0);R=-1;if(!W){break c}R=el(a,q[W+24>>2])}if(o[S+11|0]<=-1){An(q[S>>2])}if(o[S+27|0]<=-1){An(q[S+16>>2])}T=S+32|0;return R}Pm();F()}function sa(a,R,Z){var _=0,$=0,aa=0,ba=0;_=T-32|0;T=_;q[_+24>>2]=0;q[_+16>>2]=0;q[_+20>>2]=0;a:{ba=dm(R);if(ba>>>0<4294967280){b:{c:{if(ba>>>0>=11){$=ba+16&-16;aa=Mm($);q[_+24>>2]=$|-2147483648;q[_+16>>2]=aa;q[_+20>>2]=ba;break c}o[_+27|0]=ba;aa=_+16|0;if(!ba){break b}}Cn(aa,R,ba)}o[aa+ba|0]=0;q[_+8>>2]=0;q[_>>2]=0;q[_+4>>2]=0;$=dm(Z);if($>>>0>=4294967280){break a}d:{e:{if($>>>0>=11){R=$+16&-16;aa=Mm(R);q[_+8>>2]=R|-2147483648;q[_>>2]=aa;q[_+4>>2]=$;break e}o[_+11|0]=$;aa=_;if(!$){break d}}Cn(aa,Z,$)}o[$+aa|0]=0;Z=q[a+4>>2];R=-1;f:{if(!Z){break f}Z=Pk(Z,_+16|0,_);R=-1;if(!Z){break f}R=el(a,q[Z+24>>2])}a=R;if(o[_+11|0]<=-1){An(q[_>>2])}if(o[_+27|0]<=-1){An(q[_+16>>2])}T=_+32|0;return a}Pm();F()}Pm();F()}function ta(a,o,R){var Z=0,ca=0,da=0;Z=T-16|0;T=Z;ca=q[a+96>>2];q[Z+8>>2]=0;q[Z>>2]=0;q[Z+4>>2]=0;a=Mm(12);q[Z>>2]=a;q[Z+4>>2]=a;da=a+12|0;q[Z+8>>2]=da;ca=Cn(a,ca+w(o,12)|0,12)+12|0;q[Z+4>>2]=ca;o=q[R>>2];if(o){q[R+4>>2]=o;An(o);q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0}q[R>>2]=a;q[R+8>>2]=da;q[R+4>>2]=ca;T=Z+16|0;return 1}function ua(a,o){var R=0,ea=0;R=T-96|0;T=R;Dn(R+16|0,0,76);q[R+92>>2]=-1;q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0;a:{if(va(R+16|0,a,R)){a=q[o>>2];if(a){q[o+4>>2]=a;An(a);q[o+8>>2]=0;q[o>>2]=0;q[o+4>>2]=0}q[o>>2]=q[R>>2];q[o+4>>2]=q[R+4>>2];q[o+8>>2]=q[R+8>>2];q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0;ea=q[R+84>>2];break a}a=q[R>>2];if(!a){break a}q[R+4>>2]=a;An(a)}a=q[R+72>>2];if(a){An(a)}a=q[R+48>>2];if(a){q[R+52>>2]=a;An(a)}a=q[R+36>>2];if(a){q[R+40>>2]=a;An(a)}a=q[R+24>>2];if(a){q[R+28>>2]=a;An(a)}a=q[R+20>>2];q[R+20>>2]=0;if(a){wa(R+16|4,a)}T=R+96|0;return ea}function va(a,o,fa){var ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0;ja=T-16|0;T=ja;a:{if(!xa(a,o)){break a}ia=1;ha=q[o+96>>2];oa=o+100|0;ga=q[oa>>2];if((ha|0)==(ga|0)){break a}pa=a+12|0;qa=a+24|0;ra=a+36|0;na=fa+8|0;la=fa+4|0;while(1){if(!(q[q[a+56>>2]+(ma>>>3&536870908)>>2]>>>(ma&31)&1)){ia=w(ma,3);Jk(a,0,ia);sa=q[pa>>2];ka=q[a+8>>2];Jk(a,1,ia+1|0);ha=q[qa>>2];ga=q[a+20>>2];Jk(a,2,ia+2|0);ia=ha-ga>>2;ha=sa-ka|0;ga=ha>>2;ka=ia>>>0>ga>>>0;ka=q[ra>>2]-q[a+32>>2]>>2>>>0>(ka?ia:ga)>>>0?2:ka?1:ha?0:-1;b:{if(q[a+68>>2]<1){break b}ga=q[a+76>>2];q[ja+12>>2]=ga;ha=q[la>>2];c:{if(ha>>>0>2]){q[ha>>2]=ga;q[la>>2]=ha+4;break c}ya(fa,ja+12|0)}ga=ja;ia=q[((ka<<2)+a|0)+44>>2];ha=-1;d:{if((ia|0)<0){break d}ha=(ia>>>0)/3|0;ha=q[(q[q[a>>2]+96>>2]+w(ha,12)|0)+(ia-w(ha,3)<<2)>>2]}q[ga+8>>2]=ha;ga=q[la>>2];e:{if(ga>>>0>2]){q[ga>>2]=ha;q[la>>2]=ga+4;break e}ya(fa,ja+8|0)}ga=q[a+72>>2]+2|0;q[a+72>>2]=ga;if(!(ga&1)){break b}q[ja+4>>2]=ha;ga=q[la>>2];f:{if(ga>>>0>2]){q[ga>>2]=ha;q[la>>2]=ga+4;break f}ya(fa,ja+4|0)}q[a+72>>2]=q[a+72>>2]+1}za(a,ka,fa);ha=q[o+96>>2];ga=q[oa>>2]}ia=1;ma=ma+1|0;if(ma>>>0<(ga-ha|0)/12>>>0){continue}break}}T=ja+16|0;return ia}function wa(a,o){if(o){a=q[o+76>>2];if(a){q[o+80>>2]=a;An(a)}a=q[o- -64>>2];if(a){q[o+68>>2]=a;An(a)}a=q[o+48>>2];if(a){q[o+52>>2]=a;An(a)}a=q[o+24>>2];if(a){q[o+28>>2]=a;An(a)}a=q[o+12>>2];if(a){q[o+16>>2]=a;An(a)}a=q[o>>2];if(a){q[o+4>>2]=a;An(a)}An(o)}}function xa(a,fa){var ta=0,ua=0,va=0;ta=T-16|0;T=ta;q[a+68>>2]=0;q[a+72>>2]=0;q[a>>2]=fa;Ik(ta+8|0,fa);ua=q[ta+8>>2];q[ta+8>>2]=0;va=q[a+4>>2];q[a+4>>2]=ua;a:{if(!va){q[ta+8>>2]=0;break a}ua=a+4|0;wa(ua,va);va=q[ta+8>>2];q[ta+8>>2]=0;if(va){wa(ta+8|0,va)}ua=q[ua>>2]}if(ua){ua=q[fa+100>>2];fa=q[fa+96>>2];o[ta+7|0]=0;bb(a+56|0,(ua-fa|0)/12|0,ta+7|0);a=1}else{a=0}T=ta+16|0;return a}function ya(a,o){var T=0,fa=0,wa=0,xa=0,ya=0,za=0;a:{wa=q[a>>2];ya=q[a+4>>2]-wa|0;T=ya>>2;fa=T+1|0;if(fa>>>0<1073741824){za=T<<2;T=q[a+8>>2]-wa|0;xa=T>>1;fa=T>>2>>>0<536870911?xa>>>0>>0?fa:xa:1073741823;T=0;b:{if(!fa){break b}if(fa>>>0>=1073741824){break a}T=Mm(fa<<2)}xa=za+T|0;q[xa>>2]=q[o>>2];o=T+(fa<<2)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da+12>>2]=Ba;Ca=q[Ea>>2];if(Ca>>>0>2]){q[Ca>>2]=Ba;q[Ea>>2]=Ca+4;break b}ya(Aa,Da+12|0);break b}Ba=(o|0)<0?-1:q[(q[q[a>>2]+96>>2]+w(Fa,12)|0)+((o>>>0)%3<<2)>>2];q[a+76>>2]=Ba;q[Da+12>>2]=Ba;Ca=q[Ea>>2];g:{if(Ca>>>0>2]){q[Ca>>2]=Ba;q[Ea>>2]=Ca+4;break g}ya(Aa,Da+12|0)}if(Ha&1){Ba=-1;if((o|0)==-1){break a}if(o-w(Fa,3)){o=o+ -1|0;break b}o=o+2|0;break b}Ba=-1;if((o|0)==-1){break a}Ba=o+1|0;o=(Ba>>>0)%3|0?Ba:o+ -2|0}Ba=-1;if((o|0)==-1){break a}Ba=q[q[q[a+4>>2]+12>>2]+(o<<2)>>2]}Ha=Ha+1|0;if((Ha|0)<(Ia|0)){continue}break}}T=Da+16|0}function Aa(a,o,Aa){var Ja=0,Ka=0,La=0;a:{if(t[a+80>>2]>65535){break a}Ka=q[a+96>>2];a=q[a+100>>2]-Ka|0;La=(a|0)/12|0;if((w(La,6)|0)!=(o|0)){break a}if(!a){return 1}a=0;while(1){o=w(a,6)+Aa|0;Ja=w(a,12)+Ka|0;p[o>>1]=q[Ja>>2];p[o+2>>1]=q[Ja+4>>2];p[o+4>>1]=q[Ja+8>>2];Ja=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ja}function Ba(a,o,Aa){var Ma=0,Na=0,Oa=0;Na=q[a+96>>2];a=q[a+100>>2]-Na|0;Oa=(a|0)/12|0;if((a|0)==(o|0)){if(!o){return 1}a=0;while(1){Ma=w(a,12);o=Ma+Aa|0;Ma=Ma+Na|0;q[o>>2]=q[Ma>>2];q[o+4>>2]=q[Ma+4>>2];q[o+8>>2]=q[Ma+8>>2];Ma=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ma}function Ca(a,Aa,Pa){var Qa=0,Ra=0,Sa=0,Ta=0;Qa=T-32|0;T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va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(r[Aa|0]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa/x(255)):Xa;Aa=Aa+1|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 1:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(p[Aa>>1]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa/x(32767)):Xa;Aa=Aa+2|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 2:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(s[Aa>>1]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa/x(65535)):Xa;Aa=Aa+2|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 3:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(q[Aa>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(4.656612873077393e-10)):Xa;Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 4:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(t[Aa>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(2.3283064365386963e-10)):Xa;Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 5:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(+t[Aa>>2]+4294967296*+q[Aa+4>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(1.0842021724855044e-19)):Xa;Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 6:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(+t[Aa>>2]+4294967296*+t[Aa+4>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(5.421010862427522e-20)):Xa;Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 7:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){q[(Wa<<2)+Ua>>2]=q[Aa>>2];Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 8:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){u[(Wa<<2)+Ua>>2]=v[Aa>>3];Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 9:break c}}Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){u[(Wa<<2)+Ua>>2]=r[Aa|0]?x(1):x(0);Aa=Aa+1|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}Dn((Va<<2)+Ua|0,0,Pa-Va<<2)}return Za}Dn((Va<<2)+Ua|0,0,Pa-Va<<2);return 1}function Ea(a,Aa,Pa){var Ua=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0;Ua=T-16|0;T=Ua;bb=q[a+80>>2];cb=o[Aa+24|0];a=q[259];q[Ua+8>>2]=q[258];q[Ua+12>>2]=a;a=q[257];q[Ua>>2]=q[256];q[Ua+4>>2]=a;a=w(bb,cb);$a=q[Pa>>2];_a=q[Pa+4>>2]-$a>>2;a:{if(a>>>0>_a>>>0){Fa(Pa,a-_a|0);break a}if(a>>>0>=_a>>>0){break a}q[Pa+4>>2]=$a+(a<<2)}b:{if(!bb){a=1;break b}$a=0;db=Aa+68|0;eb=(cb|0)<1;while(1){a=ab;_a=Aa;if(!r[_a+84|0]){a=q[q[db>>2]+(ab<<2)>>2]}if(!Da(_a,a,o[Aa+24|0],Ua)){a=0;break b}if(!eb){_a=q[Pa>>2];a=0;while(1){q[_a+($a<<2)>>2]=q[(a<<2)+Ua>>2];$a=$a+1|0;a=a+1|0;if((cb|0)!=(a|0)){continue}break}}a=1;ab=ab+1|0;if((bb|0)!=(ab|0)){continue}break}}T=Ua+16|0;return a}function Fa(a,o){var Aa=0,Pa=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0;Pa=q[a+8>>2];fb=a+4|0;Aa=q[fb>>2];if(Pa-Aa>>2>>>0>=o>>>0){a=o<<2;kb=fb,lb=Dn(Aa,0,a)+a|0,q[kb>>2]=lb;return}a:{fb=q[a>>2];hb=Aa-fb|0;Aa=hb>>2;gb=Aa+o|0;if(gb>>>0<1073741824){jb=Aa<<2;Pa=Pa-fb|0;Aa=Pa>>1;Pa=Pa>>2>>>0<536870911?Aa>>>0>>0?gb:Aa:1073741823;Aa=0;b:{if(!Pa){break b}if(Pa>>>0>=1073741824){break a}ib=Mm(Pa<<2);Aa=ib}Dn(jb+Aa|0,0,o<<2);o=Aa+(gb<<2)|0;gb=Aa+(Pa<<2)|0;if((hb|0)>=1){Cn(ib,fb,hb)}q[a>>2]=Aa;q[a+8>>2]=gb;q[a+4>>2]=o;if(fb){An(fb)}return}bn();F()}ab(1040);F()}function Ga(a,mb,nb){var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0;pb=T-16|0;T=pb;sb=q[a+80>>2];rb=o[mb+24|0];qb=w(sb,rb);a:{a=q[mb+28>>2];b:{if(!(!r[mb+84|0]|((a|0)!=2?(a|0)!=1:0))){rb=q[mb+48>>2];mb=q[q[mb>>2]>>2];q[pb+8>>2]=0;q[pb>>2]=0;q[pb+4>>2]=0;a=0;if(qb){if((qb|0)<=-1){break a}a=Mm(qb);q[pb>>2]=a;ob=a+qb|0;q[pb+8>>2]=ob;Cn(a,mb+rb|0,qb);q[pb+4>>2]=ob}mb=q[nb>>2];if(mb){q[nb+4>>2]=mb;An(mb);q[nb+8>>2]=0;q[nb>>2]=0;q[nb+4>>2]=0}q[nb>>2]=a;q[nb+8>>2]=ob;q[nb+4>>2]=ob;ob=1;break b}q[pb+8>>2]=0;q[pb>>2]=0;q[pb+4>>2]=0;if(rb){if((rb|0)<=-1){break a}ob=Mm(rb);q[pb>>2]=ob;q[pb+4>>2]=ob;q[pb+8>>2]=ob+rb;a=rb;while(1){o[ob|0]=0;ob=q[pb+4>>2]+1|0;q[pb+4>>2]=ob;a=a+ -1|0;if(a){continue}break}}ob=q[nb>>2];a=q[nb+4>>2]-ob|0;c:{if(qb>>>0>a>>>0){Ha(nb,qb-a|0);break c}if(qb>>>0>=a>>>0){break c}q[nb+4>>2]=ob+qb}d:{if(!sb){ob=1;break d}a=0;tb=mb+68|0;ub=(rb|0)<1;qb=0;while(1){ob=qb;vb=mb;if(!r[mb+84|0]){ob=q[q[tb>>2]+(qb<<2)>>2]}if(!Ia(vb,ob,o[mb+24|0],q[pb>>2])){ob=0;break d}ob=0;if(!ub){while(1){o[q[nb>>2]+a|0]=r[q[pb>>2]+ob|0];a=a+1|0;ob=ob+1|0;if((rb|0)!=(ob|0)){continue}break}}ob=1;qb=qb+1|0;if((sb|0)!=(qb|0)){continue}break}}a=q[pb>>2];if(!a){break b}q[pb+4>>2]=a;An(a)}T=pb+16|0;return ob}bn();F()}function Ha(a,mb){var nb=0,wb=0,xb=0,yb=0,zb=0,Ab=0;a:{wb=q[a+8>>2];xb=a+4|0;nb=q[xb>>2];b:{if(wb-nb>>>0>=mb>>>0){while(1){o[nb|0]=0;nb=q[xb>>2]+1|0;q[xb>>2]=nb;mb=mb+ -1|0;if(mb){continue}break b}}yb=q[a>>2];zb=nb-yb|0;nb=zb+mb|0;if((nb|0)<=-1){break a}xb=0;wb=wb-yb|0;Ab=wb<<1;wb=wb>>>0<1073741823?Ab>>>0>>0?nb:Ab:2147483647;if(wb){xb=Mm(wb)}nb=xb+zb|0;Dn(nb,0,mb);wb=wb+xb|0;while(1){nb=nb+1|0;mb=mb+ -1|0;if(mb){continue}break}if((zb|0)>=1){Cn(xb,yb,zb)}q[a>>2]=xb;q[a+8>>2]=wb;q[a+4>>2]=nb;if(!yb){break b}An(yb)}return}bn();F()}function Ia(a,mb,Bb,Cb){var Db=0,Eb=0,Fb=0,Gb=0,Hb=x(0),Ib=0;a:{b:{if(!Cb){break b}Db=q[a+28>>2]+ -1|0;if(Db>>>0>10){break b}c:{d:{e:{switch(Db-1|0){default:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+1|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 0:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+1|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 1:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+2|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 2:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+2|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 3:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+4|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 4:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+4|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 5:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 6:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 7:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24<1){break c}Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){Db=Cb+Eb|0;Hb=u[mb>>2];f:{if(x(y(Hb))(Bb|0)?Bb:Db)<<24>>24){continue}break}break c;case 8:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24<1){break d}Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){Db=Cb+Eb|0;Ib=v[mb>>3];g:{if(y(Ib)<2147483648){Gb=~~Ib;break g}Gb=-2147483648}o[Db|0]=Gb;mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}break d;case 9:break e}}Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o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!Mb){Cb=1;break d}a=0;Nb=mb+68|0;Ob=(Lb|0)<1;Kb=0;while(1){Cb=Kb;Pb=mb;if(!r[mb+84|0]){Cb=q[q[Nb>>2]+(Kb<<2)>>2]}if(!Ka(Pb,Cb,o[mb+24|0],q[Jb>>2])){Cb=0;break d}Cb=0;if(!Ob){while(1){o[q[Bb>>2]+a|0]=r[q[Jb>>2]+Cb|0];a=a+1|0;Cb=Cb+1|0;if((Lb|0)!=(Cb|0)){continue}break}}Cb=1;Kb=Kb+1|0;if((Mb|0)!=(Kb|0)){continue}break}}a=q[Jb>>2];if(!a){break b}q[Jb+4>>2]=a;An(a)}T=Jb+16|0;return Cb}bn();F()}function Ka(a,mb,Bb,Qb){var Rb=0,Sb=0,Tb=0,Ub=0,Vb=x(0),Wb=0;a:{b:{if(!Qb){break b}Rb=q[a+28>>2]+ -1|0;if(Rb>>>0>10){break b}c:{d:{e:{switch(Rb-1|0){default:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+1|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 0:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+1|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 1:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+2|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 2:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+2|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 3:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 4:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 5:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+8|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 6:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+8|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 7:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24<1){break c}Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){Rb=Qb+Sb|0;Vb=u[mb>>2];f:{if(Vb=x(0)){Ub=~~Vb>>>0;break f}Ub=0}o[Rb|0]=Ub;mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}break c;case 8:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24<1){break d}Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){Rb=Qb+Sb|0;Wb=v[mb>>3];g:{if(Wb<4294967296&Wb>=0){Ub=~~Wb>>>0;break g}Ub=0}o[Rb|0]=Ub;mb=mb+8|0;Sb=Sb+1|0;Rb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zb=Xb+Yb|0;q[Qb+8>>2]=Zb;Dn(Yb,0,Xb);q[Qb+4>>2]=Zb}Yb=q[Bb>>2];Xb=q[Bb+4>>2]-Yb>>1;c:{if(a>>>0>Xb>>>0){Ma(Bb,a-Xb|0);break c}if(a>>>0>=Xb>>>0){break c}q[Bb+4>>2]=Yb+(a<<1)}d:{if(!ac){a=1;break d}Yb=0;Zb=mb+68|0;bc=(_b|0)<1;while(1){a=$b;Xb=mb;if(!r[mb+84|0]){a=q[q[Zb>>2]+($b<<2)>>2]}if(!Na(Xb,a,o[mb+24|0],q[Qb>>2])){a=0;break d}if(!bc){Xb=q[Bb>>2];a=0;cc=q[Qb>>2];while(1){p[Xb+(Yb<<1)>>1]=s[cc+(a<<1)>>1];Yb=Yb+1|0;a=a+1|0;if((_b|0)!=(a|0)){continue}break}}a=1;$b=$b+1|0;if((ac|0)!=($b|0)){continue}break}}mb=q[Qb>>2];if(!mb){break b}q[Qb+4>>2]=mb;An(mb)}T=Qb+16|0;return a}bn();F()}function Ma(a,o){var mb=0,Bb=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;Bb=q[a+8>>2];dc=a+4|0;mb=q[dc>>2];if(Bb-mb>>1>>>0>=o>>>0){a=o<<1;ic=dc,jc=Dn(mb,0,a)+a|0,q[ic>>2]=jc;return}a:{dc=q[a>>2];fc=mb-dc|0;mb=fc>>1;ec=mb+o|0;if((ec|0)>-1){hc=mb<<1;Bb=Bb-dc|0;Bb=Bb>>1>>>0<1073741823?Bb>>>0>>0?ec:Bb:2147483647;mb=0;b:{if(!Bb){break b}if((Bb|0)<=-1){break a}gc=Mm(Bb<<1);mb=gc}Dn(hc+mb|0,0,o<<1);o=mb+(ec<<1)|0;ec=mb+(Bb<<1)|0;if((fc|0)>=1){Cn(gc,dc,fc)}q[a>>2]=mb;q[a+8>>2]=ec;q[a+4>>2]=o;if(dc){An(dc)}return}bn();F()}ab(1040);F()}function Na(a,kc,lc,mc){var nc=0,oc=0,pc=0,qc=0,rc=x(0),sc=0;a:{b:{if(!mc){break b}nc=q[a+28>>2]+ -1|0;if(nc>>>0>10){break b}c:{d:{e:{switch(nc-1|0){default:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=o[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 0:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=r[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 1:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=s[kc>>1];kc=kc+2|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 2:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=s[kc>>1];kc=kc+2|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 3:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 4:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 5:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 6:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 7:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24<1){break c}nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){nc=(oc<<1)+mc|0;rc=u[kc>>2];f:{if(x(y(rc))>1]=qc;kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}break c;case 8:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24<1){break d}nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){nc=(oc<<1)+mc|0;sc=v[kc>>3];g:{if(y(sc)<2147483648){qc=~~sc;break g}qc=-2147483648}p[nc>>1]=qc;kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}break d;case 9:break e}}pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=r[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}Dn((nc<<1)+mc|0,0,lc-nc<<1);break b}if((nc|0)>=(lc|0)){break b}break a}if((nc|0)>=(lc|0)){break b}break a}return pc}Dn((nc<<1)+mc|0,0,lc-nc<<1);return 1}function Oa(a,kc,lc){var mc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0;mc=T-16|0;T=mc;yc=q[a+80>>2];wc=o[kc+24|0];a=w(yc,wc);a:{tc=q[kc+28>>2];b:{if(!(!r[kc+84|0]|((tc|0)!=4?(tc|0)!=3:0))){xc=q[kc+48>>2];tc=q[q[kc>>2]>>2];q[mc+8>>2]=0;q[mc>>2]=0;q[mc+4>>2]=0;kc=0;a=a<<1;if(a){if((a|0)<=-1){break a}uc=Mm(a);q[mc>>2]=uc;vc=(a>>1<<1)+uc|0;q[mc+8>>2]=vc;kc=Cn(uc,tc+xc|0,a)+a|0;q[mc+4>>2]=kc}a=q[lc>>2];if(a){q[lc+4>>2]=a;An(a);q[lc+8>>2]=0;q[lc>>2]=0;q[lc+4>>2]=0}q[lc>>2]=uc;q[lc+8>>2]=vc;q[lc+4>>2]=kc;a=1;break b}q[mc+8>>2]=0;q[mc>>2]=0;q[mc+4>>2]=0;if(wc){if((wc|0)<=-1){break a}tc=wc<<1;uc=Mm(tc);q[mc>>2]=uc;vc=tc+uc|0;q[mc+8>>2]=vc;Dn(uc,0,tc);q[mc+4>>2]=vc}uc=q[lc>>2];tc=q[lc+4>>2]-uc>>1;c:{if(a>>>0>tc>>>0){Ma(lc,a-tc|0);break c}if(a>>>0>=tc>>>0){break c}q[lc+4>>2]=uc+(a<<1)}d:{if(!yc){a=1;break d}uc=0;vc=kc+68|0;zc=(wc|0)<1;while(1){a=xc;tc=kc;if(!r[kc+84|0]){a=q[q[vc>>2]+(xc<<2)>>2]}if(!Pa(tc,a,o[kc+24|0],q[mc>>2])){a=0;break d}if(!zc){tc=q[lc>>2];a=0;Ac=q[mc>>2];while(1){p[tc+(uc<<1)>>1]=s[Ac+(a<<1)>>1];uc=uc+1|0;a=a+1|0;if((wc|0)!=(a|0)){continue}break}}a=1;xc=xc+1|0;if((yc|0)!=(xc|0)){continue}break}}kc=q[mc>>2];if(!kc){break b}q[mc+4>>2]=kc;An(kc)}T=mc+16|0;return a}bn();F()}function Pa(a,kc,lc,Bc){var Cc=0,Dc=0,Ec=0,Fc=0,Gc=x(0),Hc=0;a:{b:{if(!Bc){break b}Cc=q[a+28>>2]+ -1|0;if(Cc>>>0>10){break b}c:{d:{e:{switch(Cc-1|0){default:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=o[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 0:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=r[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 1:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=s[kc>>1];kc=kc+2|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 2:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=s[kc>>1];kc=kc+2|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 3:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 4:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 5:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 6:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 7:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24<1){break c}Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){Cc=(Dc<<1)+Bc|0;Gc=u[kc>>2];f:{if(Gc=x(0)){Fc=~~Gc>>>0;break f}Fc=0}p[Cc>>1]=Fc;kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}break c;case 8:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24<1){break d}Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){Cc=(Dc<<1)+Bc|0;Hc=v[kc>>3];g:{if(Hc<4294967296&Hc>=0){Fc=~~Hc>>>0;break g}Fc=0}p[Cc>>1]=Fc;kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}break d;case 9:break e}}Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=r[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}Dn((Cc<<1)+Bc|0,0,lc-Cc<<1);break b}if((Cc|0)>=(lc|0)){break b}break a}if((Cc|0)>=(lc|0)){break b}break a}return Ec}Dn((Cc<<1)+Bc|0,0,lc-Cc<<1);return 1}function Qa(a,kc,lc){var Bc=0,Ic=0,Jc=0,Kc=0,L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c|0)!=(a|0)){continue}break}}a=1;Mc=Mc+1|0;if((Nc|0)!=(Mc|0)){continue}break}}kc=q[Bc>>2];if(!kc){break b}q[Bc+4>>2]=kc;An(kc)}T=Bc+16|0;return a}bn();F()}function Ra(a,kc,lc,Qc){var Rc=0,Sc=0,Tc=0,Uc=0,Vc=x(0),Wc=0;a:{b:{if(!Qc){break b}Rc=q[a+28>>2]+ -1|0;if(Rc>>>0>10){break b}c:{d:{e:{switch(Rc-1|0){default:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=o[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 0:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=r[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 1:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=p[kc>>1];kc=kc+2|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 2:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=s[kc>>1];kc=kc+2|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 3:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 4:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 5:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 6:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 7:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24<1){break c}Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){Rc=(Sc<<2)+Qc|0;Vc=u[kc>>2];f:{if(x(y(Vc))>2]=Uc;kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}break c;case 8:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24<1){break d}Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){Rc=(Sc<<2)+Qc|0;Wc=v[kc>>3];g:{if(y(Wc)<2147483648){Uc=~~Wc;break g}Uc=-2147483648}q[Rc>>2]=Uc;kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}break d;case 9:break e}}Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=r[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}Dn((Rc<<2)+Qc|0,0,lc-Rc<<2);break b}if((Rc|0)>=(lc|0)){break b}break a}if((Rc|0)>=(lc|0)){break b}break a}return Tc}Dn((Rc<<2)+Qc|0,0,lc-Rc<<2);return 1}function Sa(a,kc,lc){var Qc=0,Xc=0,Yc=0,Zc=0,_c=0,$c=0,ad=0,bd=0,cd=0;Qc=T-16|0;T=Qc;ad=q[a+80>>2];Zc=o[kc+24|0];Yc=w(ad,Zc);a:{a=q[kc+28>>2];b:{if(!(!r[kc+84|0]|((a|0)!=6?(a|0)!=5:0))){$c=q[kc+48>>2];Zc=q[q[kc>>2]>>2];q[Qc+8>>2]=0;q[Qc>>2]=0;q[Qc+4>>2]=0;a=0;kc=Yc<<2;c:{if(!kc){break c}a=kc>>2;if(a>>>0>=1073741824){break a}Xc=Mm(kc);q[Qc>>2]=Xc;q[Qc+4>>2]=Xc;_c=(a<<2)+Xc|0;q[Qc+8>>2]=_c;if((kc|0)<1){a=Xc;break c}a=Cn(Xc,Zc+$c|0,kc)+kc|0;q[Qc+4>>2]=a}kc=q[lc>>2];if(kc){q[lc+4>>2]=kc;An(kc);q[lc+8>>2]=0;q[lc>>2]=0;q[lc+4>>2]=0}q[lc>>2]=Xc;q[lc+8>>2]=_c;q[lc+4>>2]=a;a=1;break b}q[Qc+8>>2]=0;q[Qc>>2]=0;q[Qc+4>>2]=0;if(Zc){if((Zc|0)<=-1){break a}a=Zc<<2;Xc=Mm(a);q[Qc>>2]=Xc;_c=a+Xc|0;q[Qc+8>>2]=_c;Dn(Xc,0,a);q[Qc+4>>2]=_c}Xc=q[lc>>2];a=q[lc+4>>2]-Xc>>2;d:{if(Yc>>>0>a>>>0){Fa(lc,Yc-a|0);break d}if(Yc>>>0>=a>>>0){break d}q[lc+4>>2]=Xc+(Yc<<2)}e:{if(!ad){a=1;break e}Xc=0;_c=kc+68|0;bd=(Zc|0)<1;while(1){a=$c;Yc=kc;if(!r[kc+84|0]){a=q[q[_c>>2]+($c<<2)>>2]}if(!Ta(Yc,a,o[kc+24|0],q[Qc>>2])){a=0;break e}if(!bd){Yc=q[lc>>2];a=0;cd=q[Qc>>2];while(1){q[Yc+(Xc<<2)>>2]=q[cd+(a<<2)>>2];Xc=Xc+1|0;a=a+1|0;if((Zc|0)!=(a|0)){continue}break}}a=1;$c=$c+1|0;if((ad|0)!=($c|0)){continue}break}}kc=q[Qc>>2];if(!kc){break b}q[Qc+4>>2]=kc;An(kc)}T=Qc+16|0;return a}bn();F()}function Ta(a,kc,lc,dd){var ed=0,fd=0,gd=0,hd=0,id=x(0),jd=0;a:{b:{if(!dd){break b}ed=q[a+28>>2]+ -1|0;if(ed>>>0>10){break b}c:{d:{e:{switch(ed-1|0){default:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=o[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 0:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=r[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 1:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=p[kc>>1];kc=kc+2|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 2:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=s[kc>>1];kc=kc+2|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 3:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 4:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 5:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 6:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 7:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24<1){break c}ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){ed=(fd<<2)+dd|0;id=u[kc>>2];f:{if(id=x(0)){hd=~~id>>>0;break f}hd=0}q[ed>>2]=hd;kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}break c;case 8:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24<1){break d}ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){ed=(fd<<2)+dd|0;jd=v[kc>>3];g:{if(jd<4294967296&jd>=0){hd=~~jd>>>0;break g}hd=0}q[ed>>2]=hd;kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}break d;case 9:break e}}gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=r[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}Dn((ed<<2)+dd|0,0,lc-ed<<2);break b}if((ed|0)>=(lc|0)){break b}break a}if((ed|0)>=(lc|0)){break b}break a}return gd}Dn((ed<<2)+dd|0,0,lc-ed<<2);return 1}function Ua(a,kc,lc,dd,kd){var ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0;md=T-16|0;T=md;lc=lc+ -1|0;a:{if(lc>>>0>8){break a}b:{switch(lc-1|0){default:ld=Va(a,kc,dd,kd);break a;case 1:ld=Wa(a,kc,dd,kd);break a;case 3:ld=Xa(a,kc,dd,kd);break a;case 0:ld=Ya(a,kc,dd,kd);break a;case 2:ld=Za(a,kc,dd,kd);break a;case 4:ld=_a(a,kc,dd,kd);break a;case 5:case 6:break a;case 7:break b}}nd=q[a+80>>2];od=o[kc+24|0];pd=od<<2;if((w(nd,pd)|0)!=(dd|0)){break a}a=0;lc=q[259];q[md+8>>2]=q[258];q[md+12>>2]=lc;lc=q[257];q[md>>2]=q[256];q[md+4>>2]=lc;if(!nd){ld=1;break a}qd=kc+68|0;rd=(od|0)<1;lc=0;while(1){dd=lc;ld=kc;if(!r[kc+84|0]){dd=q[q[qd>>2]+(lc<<2)>>2]}if(!Da(ld,dd,o[kc+24|0],md)){ld=0;break a}if(!rd){Cn((a<<2)+kd|0,md,pd);a=a+od|0}ld=1;lc=lc+1|0;if((nd|0)!=(lc|0)){continue}break}}T=md+16|0;return ld}function Va(a,kc,lc,dd){var kd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0;sd=T-16|0;T=sd;a:{vd=q[a+80>>2];td=o[kc+24|0];b:{if((w(vd,td)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=1)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);kd=1;break b}q[sd+8>>2]=0;q[sd>>2]=0;q[sd+4>>2]=0;if(td){if((td|0)<=-1){break a}kd=Mm(td);q[sd>>2]=kd;q[sd+4>>2]=kd;q[sd+8>>2]=kd+td;lc=td;while(1){o[kd|0]=0;kd=q[sd+4>>2]+1|0;q[sd+4>>2]=kd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!vd){kd=1;break c}lc=0;wd=kc+68|0;xd=(td|0)<1;while(1){a=ud;kd=kc;if(!r[kd+84|0]){a=q[q[wd>>2]+(ud<<2)>>2]}if(!Ia(kd,a,o[kc+24|0],q[sd>>2])){kd=0;break c}if(!xd){kd=0;a=q[sd>>2];while(1){o[lc+dd|0]=r[a+kd|0];lc=lc+1|0;kd=kd+1|0;if((td|0)!=(kd|0)){continue}break}}kd=1;ud=ud+1|0;if((vd|0)!=(ud|0)){continue}break}}a=q[sd>>2];if(!a){break b}q[sd+4>>2]=a;An(a)}T=sd+16|0;return kd}bn();F()}function Wa(a,kc,lc,dd){var yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;yd=T-16|0;T=yd;a:{Cd=q[a+80>>2];Ad=o[kc+24|0];a=Ad<<1;b:{if((w(Cd,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=3)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);zd=1;break b}lc=0;q[yd+8>>2]=0;q[yd>>2]=0;q[yd+4>>2]=0;if(Ad){if((Ad|0)<=-1){break a}lc=Mm(a);q[yd>>2]=lc;q[yd+8>>2]=(Ad<<1)+lc;Fd=yd,Gd=Dn(lc,0,a)+a|0,q[Fd+4>>2]=Gd}c:{if(!Cd){zd=1;break c}lc=0;Dd=kc+68|0;Ed=(Ad|0)<1;while(1){a=Bd;zd=kc;if(!r[kc+84|0]){a=q[q[Dd>>2]+(Bd<<2)>>2]}d:{if(!Na(zd,a,o[kc+24|0],q[yd>>2])){zd=0;break d}if(!Ed){zd=0;a=q[yd>>2];while(1){p[(lc<<1)+dd>>1]=s[a+(zd<<1)>>1];lc=lc+1|0;zd=zd+1|0;if((Ad|0)!=(zd|0)){continue}break}}zd=1;Bd=Bd+1|0;if((Cd|0)!=(Bd|0)){continue}}break}lc=q[yd>>2]}if(!lc){break b}q[yd+4>>2]=lc;An(lc)}T=yd+16|0;return zd}bn();F()}function Xa(a,kc,lc,dd){var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0,Od=0,Pd=0;Hd=T-16|0;T=Hd;a:{Ld=q[a+80>>2];Jd=o[kc+24|0];a=Jd<<2;b:{if((w(Ld,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=5)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Id=1;break b}lc=0;q[Hd+8>>2]=0;q[Hd>>2]=0;q[Hd+4>>2]=0;if(Jd){if((Jd|0)<=-1){break a}lc=Mm(a);q[Hd>>2]=lc;q[Hd+8>>2]=(Jd<<2)+lc;Od=Hd,Pd=Dn(lc,0,a)+a|0,q[Od+4>>2]=Pd}c:{if(!Ld){Id=1;break c}lc=0;Md=kc+68|0;Nd=(Jd|0)<1;while(1){a=Kd;Id=kc;if(!r[kc+84|0]){a=q[q[Md>>2]+(Kd<<2)>>2]}d:{if(!Ra(Id,a,o[kc+24|0],q[Hd>>2])){Id=0;break d}if(!Nd){Id=0;a=q[Hd>>2];while(1){q[(lc<<2)+dd>>2]=q[a+(Id<<2)>>2];lc=lc+1|0;Id=Id+1|0;if((Jd|0)!=(Id|0)){continue}break}}Id=1;Kd=Kd+1|0;if((Ld|0)!=(Kd|0)){continue}}break}lc=q[Hd>>2]}if(!lc){break b}q[Hd+4>>2]=lc;An(lc)}T=Hd+16|0;return Id}bn();F()}function Ya(a,kc,lc,dd){var Qd=0,Rd=0,Sd=0,Td=0,Ud=0,Vd=0,Wd=0;Rd=T-16|0;T=Rd;a:{Ud=q[a+80>>2];Sd=o[kc+24|0];b:{if((w(Ud,Sd)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=2)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Qd=1;break b}q[Rd+8>>2]=0;q[Rd>>2]=0;q[Rd+4>>2]=0;if(Sd){if((Sd|0)<=-1){break a}Qd=Mm(Sd);q[Rd>>2]=Qd;q[Rd+4>>2]=Qd;q[Rd+8>>2]=Qd+Sd;lc=Sd;while(1){o[Qd|0]=0;Qd=q[Rd+4>>2]+1|0;q[Rd+4>>2]=Qd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!Ud){Qd=1;break c}lc=0;Vd=kc+68|0;Wd=(Sd|0)<1;while(1){a=Td;Qd=kc;if(!r[Qd+84|0]){a=q[q[Vd>>2]+(Td<<2)>>2]}if(!Ka(Qd,a,o[kc+24|0],q[Rd>>2])){Qd=0;break c}if(!Wd){Qd=0;a=q[Rd>>2];while(1){o[lc+dd|0]=r[a+Qd|0];lc=lc+1|0;Qd=Qd+1|0;if((Sd|0)!=(Qd|0)){continue}break}}Qd=1;Td=Td+1|0;if((Ud|0)!=(Td|0)){continue}break}}a=q[Rd>>2];if(!a){break b}q[Rd+4>>2]=a;An(a)}T=Rd+16|0;return Qd}bn();F()}function Za(a,kc,lc,dd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Xd=T-16|0;T=Xd;a:{$d=q[a+80>>2];Zd=o[kc+24|0];a=Zd<<1;b:{if((w($d,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=4)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Yd=1;break b}lc=0;q[Xd+8>>2]=0;q[Xd>>2]=0;q[Xd+4>>2]=0;if(Zd){if((Zd|0)<=-1){break a}lc=Mm(a);q[Xd>>2]=lc;q[Xd+8>>2]=(Zd<<1)+lc;ce=Xd,de=Dn(lc,0,a)+a|0,q[ce+4>>2]=de}c:{if(!$d){Yd=1;break c}lc=0;ae=kc+68|0;be=(Zd|0)<1;while(1){a=_d;Yd=kc;if(!r[kc+84|0]){a=q[q[ae>>2]+(_d<<2)>>2]}d:{if(!Pa(Yd,a,o[kc+24|0],q[Xd>>2])){Yd=0;break d}if(!be){Yd=0;a=q[Xd>>2];while(1){p[(lc<<1)+dd>>1]=s[a+(Yd<<1)>>1];lc=lc+1|0;Yd=Yd+1|0;if((Zd|0)!=(Yd|0)){continue}break}}Yd=1;_d=_d+1|0;if(($d|0)!=(_d|0)){continue}}break}lc=q[Xd>>2]}if(!lc){break b}q[Xd+4>>2]=lc;An(lc)}T=Xd+16|0;return Yd}bn();F()}function _a(a,kc,lc,dd){var ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0;ee=T-16|0;T=ee;a:{ie=q[a+80>>2];ge=o[kc+24|0];a=ge<<2;b:{if((w(ie,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=6)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);fe=1;break b}lc=0;q[ee+8>>2]=0;q[ee>>2]=0;q[ee+4>>2]=0;if(ge){if((ge|0)<=-1){break a}lc=Mm(a);q[ee>>2]=lc;q[ee+8>>2]=(ge<<2)+lc;le=ee,me=Dn(lc,0,a)+a|0,q[le+4>>2]=me}c:{if(!ie){fe=1;break c}lc=0;je=kc+68|0;ke=(ge|0)<1;while(1){a=he;fe=kc;if(!r[kc+84|0]){a=q[q[je>>2]+(he<<2)>>2]}d:{if(!Ta(fe,a,o[kc+24|0],q[ee>>2])){fe=0;break d}if(!ke){fe=0;a=q[ee>>2];while(1){q[(lc<<2)+dd>>2]=q[a+(fe<<2)>>2];lc=lc+1|0;fe=fe+1|0;if((ge|0)!=(fe|0)){continue}break}}fe=1;he=he+1|0;if((ie|0)!=(he|0)){continue}}break}lc=q[ee>>2]}if(!lc){break b}q[ee+4>>2]=lc;An(lc)}T=ee+16|0;return fe}bn();F()}function $a(a,o){var kc=0,lc=0;kc=q[a+4>>2];if(!kc){return 0}o=q[q[q[a+8>>2]+(o<<2)>>2]+60>>2];if((o|0)<0){return 0}a=q[kc+24>>2];kc=q[kc+28>>2];if((a|0)==(kc|0)){return 0}a:{while(1){lc=q[a>>2];if((o|0)==q[lc+24>>2]){break a}a=a+4|0;if((kc|0)!=(a|0)){continue}break}return 0}return lc}function ab(a){var o=0;o=I(8)|0;q[o>>2]=15856;q[o>>2]=15900;Nm(o+4|0,a);q[o>>2]=15948;J(o|0,15980,1);F()}function bb(a,dd,ne){var oe=0,pe=0,qe=0,re=0,se=0;pe=T-16|0;T=pe;q[a+4>>2]=0;a:{b:{if(!dd){break b}qe=q[a+8>>2];oe=qe<<5;c:{if(oe>>>0>=dd>>>0){q[a+4>>2]=dd;break c}q[pe+8>>2]=0;q[pe>>2]=0;q[pe+4>>2]=0;if((dd|0)<=-1){break a}se=pe;if(oe>>>0<=1073741822){re=dd+31&-32;oe=qe<<6;re=oe>>>0>>0?re:oe}else{re=2147483647}cb(se,re);re=q[a>>2];q[a>>2]=q[pe>>2];q[pe>>2]=re;qe=q[a+4>>2];q[a+4>>2]=dd;q[pe+4>>2]=qe;oe=a+8|0;qe=q[oe>>2];q[oe>>2]=q[pe+8>>2];q[pe+8>>2]=qe;if(!re){break c}An(re)}oe=dd>>>5;qe=oe<<2;a=q[a>>2];if(r[ne|0]){a=Dn(a,255,qe);dd=dd&31;if(!dd){break b}a=a+(oe<<2)|0;q[a>>2]=q[a>>2]|-1>>>32-dd;break b}a=Dn(a,0,qe);dd=dd&31;if(!dd){break b}a=a+(oe<<2)|0;q[a>>2]=q[a>>2]&(-1>>>32-dd^-1)}T=pe+16|0;return}bn();F()}function cb(a,dd){var ne=0,te=0;ne=T-32|0;T=ne;a:{b:{if(q[a+8>>2]<<5>>>0>=dd>>>0){break b}q[ne+24>>2]=0;q[ne+16>>2]=0;q[ne+20>>2]=0;if((dd|0)<=-1){break a}dd=(dd+ -1>>>5)+1|0;te=Mm(dd<<2);q[ne+24>>2]=dd;q[ne+20>>2]=0;q[ne+16>>2]=te;dd=q[a>>2];q[ne+12>>2]=0;q[ne+8>>2]=dd;te=q[a+4>>2];q[ne+4>>2]=te&31;q[ne>>2]=dd+(te>>>3&536870908);db(ne+16|0,ne+8|0,ne);dd=q[a>>2];q[a>>2]=q[ne+16>>2];q[ne+16>>2]=dd;te=q[a+4>>2];q[a+4>>2]=q[ne+20>>2];q[ne+20>>2]=te;a=a+8|0;te=q[a>>2];q[a>>2]=q[ne+24>>2];q[ne+24>>2]=te;if(!dd){break b}An(dd)}T=ne+32|0;return}bn();F()}function db(a,dd,ue){var ve=0,we=0,xe=0,ye=0,ze=0,Ae=0;xe=T-32|0;T=xe;ze=q[ue+4>>2];ve=q[dd+4>>2];Ae=q[ue>>2];ye=q[dd>>2];dd=(ze-ve|0)+(Ae-ye<<3)|0;ue=q[a+4>>2];we=dd+ue|0;q[a+4>>2]=we;a:{if(!(!ue|(we+ -1^ue+ -1)>>>0>31)){a=q[a>>2];break a}a=q[a>>2];if(we>>>0<=32){q[a>>2]=0;break a}q[(we+ -1>>>3&536870908)+a>>2]=0}a=(ue>>>3&536870908)+a|0;ue=ue&31;b:{if((ue|0)==(ve|0)){c:{if((dd|0)<1){break c}d:{if(!ve){ue=0;break d}we=32-ve|0;ue=(dd|0)<(we|0)?dd:we;we=-1<>>we-ue;q[a>>2]=q[a>>2]&(we^-1)|we&q[ye>>2];dd=dd-ue|0;ve=ue+ve|0;ue=ve&31;a=(ve>>>3&536870908)+a|0;ye=ye+4|0}ve=(dd|0)/32|0;we=ve<<2;a=En(a,ye,we)+we|0;ve=dd-(ve<<5)|0;if((ve|0)<1){ve=ue;break c}dd=-1>>>32-ve;q[a>>2]=q[a>>2]&(dd^-1)|dd&q[we+ye>>2]}q[xe+4>>2]=ve;q[xe>>2]=a;break b}q[xe+28>>2]=ve;q[xe+24>>2]=ye;q[xe+20>>2]=ze;q[xe+16>>2]=Ae;q[xe+12>>2]=ue;q[xe+8>>2]=a;eb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be>>2];q[a+4>>2]=ue;q[a>>2]=dd}function fb(a){a=a|0;return q[a>>2]}function gb(a){a=a|0;return!q[a>>2]|0}function hb(a){a=a|0;var dd=0;dd=a+4|0;if(o[a+15|0]<=-1){dd=q[dd>>2]}return dd|0}function ib(a){a=a|0;if(a){if(o[a+15|0]<=-1){An(q[a+4>>2])}An(a)}}function jb(){var a=0;a=Mm(12);q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;return a|0}function kb(ue,Be){ue=ue|0;Be=Be|0;return s[q[ue>>2]+(Be<<1)>>1]}function lb(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]>>1}function mb(ue){ue=ue|0;var Be=0;if(ue){Be=q[ue>>2];if(Be){q[ue+4>>2]=Be;An(Be)}An(ue)}}function nb(){return al(Mm(84))|0}function ob(ue){ue=ue|0;return q[ue+12>>2]-q[ue+8>>2]>>2}function pb(ue){ue=ue|0;return q[ue+80>>2]}function qb(ue){ue=ue|0;if(ue){n[q[q[ue>>2]+4>>2]](ue)}}function rb(ue,Ke){ue=ue|0;Ke=Ke|0;return r[q[ue>>2]+Ke|0]}function sb(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]|0}function tb(ue,Ke){ue=ue|0;Ke=Ke|0;return q[q[ue>>2]+(Ke<<2)>>2]}function ub(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]>>2}function vb(){var ue=0;ue=Mm(8);q[ue+4>>2]=-1;q[ue>>2]=1116;return ue|0}function wb(Ke,Le){Ke=Ke|0;Le=Le|0;return n[q[q[Ke>>2]+12>>2]](Ke,Le)|0}function xb(Ke){Ke=Ke|0;return q[Ke+4>>2]}function yb(){return rd(Mm(96))|0}function zb(Ke){Ke=Ke|0;return q[Ke+88>>2]}function Ab(Ke){Ke=Ke|0;return q[Ke+56>>2]}function Bb(Ke){Ke=Ke|0;return q[Ke+28>>2]}function Cb(q){q=q|0;return o[q+24|0]}function Db(q){q=q|0;return r[q+32|0]}function Eb(Ke){Ke=Ke|0;return q[Ke+40>>2]}function Fb(Ke){Ke=Ke|0;return q[Ke+48>>2]}function Gb(Ke){Ke=Ke|0;return q[Ke+60>>2]}function Hb(Ke){Ke=Ke|0;var Le=0,Me=0;if(Ke){Le=Ke+88|0;Me=q[Le>>2];q[Le>>2]=0;if(Me){Le=q[Me+8>>2];if(Le){q[Me+12>>2]=Le;An(Le)}An(Me)}Me=q[Ke+68>>2];if(Me){q[Ke+72>>2]=Me;An(Me)}Le=Ke- -64|0;Me=q[Le>>2];q[Le>>2]=0;if(Me){Le=q[Me>>2];if(Le){q[Me+4>>2]=Le;An(Le)}An(Me)}An(Ke)}}function Ib(){var Ke=0;Ke=Mm(40);q[Ke>>2]=-1;Uj(Ke+8|0);return Ke|0}function Jb(Ne){Ne=Ne|0;var Oe=0;if(Ne){Oe=q[Ne+8>>2];if(Oe){q[Ne+12>>2]=Oe;An(Oe)}An(Ne)}}function Kb(){var Ne=0;Ne=Mm(24);q[Ne+4>>2]=-1;q[Ne>>2]=1232;q[Ne+8>>2]=0;q[Ne+12>>2]=0;q[Ne+16>>2]=0;q[Ne+20>>2]=0;return Ne|0}function Lb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return x(u[q[Pe+8>>2]+(Qe<<2)>>2])}function Mb(q){q=q|0;return x(u[q+20>>2])}function Nb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return o[q[Pe>>2]+Qe|0]}function Ob(){var Pe=0;Pe=Mm(28);q[Pe>>2]=0;q[Pe+4>>2]=0;q[Pe+24>>2]=0;q[Pe+16>>2]=0;q[Pe+20>>2]=0;q[Pe+8>>2]=0;q[Pe+12>>2]=0;return Pe|0}function Pb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return fa(Qe,Re)|0}function Qb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return ha(Qe,Re)|0}function Rb(q,Qe,Re,Se){q=q|0;Qe=Qe|0;Re=Re|0;Se=Se|0;ia(Qe,Re,Se)}function Sb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return+ja(Qe,Re)}function Tb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return ka(q,Qe,Re)|0}function Ub(Qe,Re){Qe=Qe|0;Re=Re|0;return q[Re+8>>2]}function Vb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return la(q,Qe,Re)|0}function Wb(Qe){Qe=Qe|0;var Re=0,Se=0,Te=0,Ue=0,Ve=0;if(Qe){if(o[Qe+27|0]<=-1){An(q[Qe+16>>2])}Se=q[Qe>>2];if(Se){Re=Se;Ve=Qe+4|0;Te=q[Ve>>2];Ue=Re;a:{if((Te|0)==(Re|0)){break a}while(1){Re=Te+ -12|0;if(o[Te+ -1|0]<=-1){An(q[Re>>2])}Te=Re;if((Re|0)!=(Se|0)){continue}break}Ue=q[Qe>>2]}Re=Ue;q[Ve>>2]=Se;An(Re)}An(Qe)}}function Xb(Qe,We){Qe=Qe|0;We=We|0;return p[q[Qe>>2]+(We<<1)>>1]}function Yb(Qe,We){Qe=Qe|0;We=We|0;return x(u[q[Qe>>2]+(We<<2)>>2])}function Zb(){return nd(Mm(64))|0}function _b(q){q=q|0;if(q){An(q)}}function $b(){return Yj(Mm(40))|0}function ac(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;q[Qe+16>>2]=0;q[Qe+20>>2]=0;q[Qe>>2]=We;q[Qe+8>>2]=Xe;q[Qe+12>>2]=0}function bc(){return na(Mm(40))|0}function cc(q,Qe){q=q|0;Qe=Qe|0;return oa(Qe)|0}function dc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return pa(q,Qe,We)|0}function ec(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return qa(q,Qe,We)|0}function fc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return bl(Qe,We)|0}function gc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return ra(Qe,We)|0}function hc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return sa(Qe,We,Xe)|0}function ic(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;return q[q[We+8>>2]+(Xe<<2)>>2]}function jc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return dl(Qe,We)|0}function kc(Qe,We){Qe=Qe|0;We=We|0;return q[We+4>>2]}function lc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return $a(Qe,We)|0}function mc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ta(Qe,We,Xe)|0}function nc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return ua(Qe,We)|0}function oc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Aa(Qe,We,Xe)|0}function pc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ba(Qe,We,Xe)|0}function qc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ca(Qe,We,Xe)|0}function rc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ea(Qe,We,Xe)|0}function sc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Qa(Qe,We,Xe)|0}function tc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ga(Qe,We,Xe)|0}function uc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ja(Qe,We,Xe)|0}function vc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return La(Qe,We,Xe)|0}function wc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Oa(Qe,We,Xe)|0}function xc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Sa(Qe,We,Xe)|0}function yc(q,Qe,We,Xe,Ye,Ze){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;Ye=Ye|0;Ze=Ze|0;return Ua(Qe,We,Xe,Ye,Ze)|0}function zc(q,Qe){q=q|0;Qe=Qe|0;kh(q,Qe)}function Ac(Qe){Qe=Qe|0;if(Qe){if(o[Qe+39|0]<=-1){An(q[Qe+28>>2])}Bc(Qe+12|0,q[Qe+16>>2]);Cc(Qe,q[Qe+4>>2]);An(Qe)}}function Bc(Qe,We){if(We){Bc(Qe,q[We>>2]);Bc(Qe,q[We+4>>2]);Cc(We+20|0,q[We+24>>2]);An(We)}}function Cc(Qe,We){if(We){Cc(Qe,q[We>>2]);Cc(Qe,q[We+4>>2]);if(o[We+39|0]<=-1){An(q[We+28>>2])}if(o[We+27|0]<=-1){An(q[We+16>>2])}An(We)}}function Dc(){return vk(Mm(108))|0}function Ec(Qe){Qe=Qe|0;return(q[Qe+100>>2]-q[Qe+96>>2]|0)/12|0}function Fc(){var Qe=0,We=0,Xe=0;We=Mm(24);Xe=We+4|0;Qe=Xe;q[Qe>>2]=0;q[Qe+4>>2]=0;Qe=We+16|0;q[Qe>>2]=0;q[Qe+4>>2]=0;q[We>>2]=Xe;q[We+12>>2]=Qe;return We|0}function Gc(Ye){Ye=Ye|0;if(Ye){Hc(Ye+12|0,q[Ye+16>>2]);Ic(Ye,q[Ye+4>>2]);An(Ye)}}function Hc(Ye,Ze){var _e=0;if(Ze){Hc(Ye,q[Ze>>2]);Hc(Ye,q[Ze+4>>2]);_e=Ze+28|0;Ye=q[_e>>2];q[_e>>2]=0;if(Ye){Hc(Ye+12|0,q[Ye+16>>2]);Ic(Ye,q[Ye+4>>2]);An(Ye)}if(o[Ze+27|0]<=-1){An(q[Ze+16>>2])}An(Ze)}}function Ic(Ye,Ze){if(Ze){Ic(Ye,q[Ze>>2]);Ic(Ye,q[Ze+4>>2]);Ye=q[Ze+28>>2];if(Ye){q[Ze+32>>2]=Ye;An(Ye)}if(o[Ze+27|0]<=-1){An(q[Ze+16>>2])}An(Ze)}}function Jc(){return 0}function Kc(){return-1}function Lc(){return-2}function Mc(){return-3}function Nc(){return-4}function Oc(){return-5}function Pc(){return 1}function Qc(){return 2}function Rc(){return 3}function Sc(){return 4}function Tc(){return 5}function Uc(){return 6}function Vc(){return 7}function Wc(){return 8}function Xc(){return 9}function Yc(){return 10}function Zc(){return 11}function _c(){return 12}function $c(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var $e=0;Ze=q[Ze+88>>2];if(!(!Ze|q[Ze>>2]!=2)){$e=Ye;Ye=q[Ze+8>>2];q[$e+4>>2]=r[Ye|0]|r[Ye+1|0]<<8|(r[Ye+2|0]<<16|r[Ye+3|0]<<24);$e=1}return $e|0}function ad(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var af=0,bf=0;q[Ze>>2]=2;af=q[Ze+8>>2];bf=q[Ze+12>>2]-af|0;if(bf>>>0<=4294967291){Ze=Ze+8|0;Xj(Ze,bf+4|0);af=q[Ze>>2]}Ze=af+bf|0;Ye=r[Ye+4|0]|r[Ye+5|0]<<8|(r[Ye+6|0]<<16|r[Ye+7|0]<<24);o[Ze|0]=Ye;o[Ze+1|0]=Ye>>>8;o[Ze+2|0]=Ye>>>16;o[Ze+3|0]=Ye>>>24}function bd(q){q=q|0;return q|0}function cd(q){q=q|0;An(q)}function dd(q){q=q|0;return 2}function ed(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var cf=0,df=0,ef=0,ff=0,gf=0,hf=0;ef=q[Ze+88>>2];if(!(!ef|q[ef>>2]!=1)){ff=ef+8|0;ef=q[ff>>2];cf=ef;q[Ye+4>>2]=r[cf|0]|r[cf+1|0]<<8|(r[cf+2|0]<<16|r[cf+3|0]<<24);gf=Ye+8|0;hf=q[Ye+8>>2];df=q[Ye+12>>2]-hf>>2;cf=o[Ze+24|0];a:{if(df>>>0>>0){Fa(gf,cf-df|0);ef=q[ff>>2];cf=r[Ze+24|0];break a}if(df>>>0<=cf>>>0){break a}q[Ye+12>>2]=hf+(cf<<2)}ff=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+1|0]=Ye>>>8;o[Ze+2|0]=Ye>>>16;o[Ze+3|0]=Ye>>>24}function gd(Ye,Ze,pf,qf,rf){q[Ye+4>>2]=Ze;hd(Ye+8|0,pf,(qf<<2)+pf|0);u[Ye+20>>2]=rf}function hd(Ye,Ze,pf){var qf=0,rf=0,sf=0,tf=0,uf=0,vf=0,wf=0;a:{tf=pf-Ze|0;sf=tf>>2;qf=q[Ye+8>>2];rf=q[Ye>>2];b:{if(sf>>>0<=qf-rf>>2>>>0){qf=q[Ye+4>>2]-rf|0;tf=qf>>2;qf=sf>>>0>tf>>>0?Ze+qf|0:pf;uf=qf-Ze|0;if(uf){En(rf,Ze,uf)}if(sf>>>0>tf>>>0){Ze=pf-qf|0;if((Ze|0)<1){break b}Ye=Ye+4|0;Cn(q[Ye>>2],qf,Ze);q[Ye>>2]=Ze+q[Ye>>2];return}q[Ye+4>>2]=rf+(uf>>2<<2);return}if(rf){q[Ye+4>>2]=rf;An(rf);q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;qf=0}if(sf>>>0>=1073741824){break a}pf=qf>>1;pf=qf>>2>>>0<536870911?pf>>>0>>0?sf:pf:1073741823;if(pf>>>0>=1073741824){break a}rf=pf<<2;pf=Mm(rf);q[Ye>>2]=pf;sf=Ye+4|0;q[sf>>2]=pf;q[Ye+8>>2]=pf+rf;if((tf|0)<1){break b}vf=sf,wf=Cn(pf,Ze,tf)+tf|0,q[vf>>2]=wf}return}bn();F()}function id(Ye){Ye=Ye|0;var Ze=0;q[Ye>>2]=1232;Ze=q[Ye+8>>2];if(Ze){q[Ye+12>>2]=Ze;An(Ze)}return Ye|0}function jd(Ye){Ye=Ye|0;var pf=0;q[Ye>>2]=1232;pf=q[Ye+8>>2];if(pf){q[Ye+12>>2]=pf;An(pf)}An(Ye)}function kd(q){q=q|0;return 1}function ld(Ye,xf){var yf=0;yf=Mm(40);q[yf>>2]=-1;Uj(yf+8|0);n[q[q[Ye>>2]+16>>2]](Ye,yf);Ye=q[xf+88>>2];q[xf+88>>2]=yf;if(Ye){xf=q[Ye+8>>2];if(xf){q[Ye+12>>2]=xf;An(xf)}An(Ye)}return 1}function md(Ye,xf,zf){var Af=0,Bf=0,Cf=0,Df=0,Ef=0,Ff=0;Cf=q[Ye+8>>2];Af=q[Ye+4>>2];if(Cf-Af>>2>>>0>=xf>>>0){while(1){q[Af>>2]=q[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}q[Ye+4>>2]=Af;return}a:{Df=q[Ye>>2];Ef=Af-Df|0;Ff=Ef>>2;Af=Ff+xf|0;if(Af>>>0<1073741824){Cf=Cf-Df|0;Bf=Cf>>1;Af=Cf>>2>>>0<536870911?Bf>>>0>>0?Af:Bf:1073741823;Bf=0;b:{if(!Af){break b}if(Af>>>0>=1073741824){break a}Bf=Mm(Af<<2)}Cf=Bf+(Af<<2)|0;Af=Bf+(Ff<<2)|0;while(1){q[Af>>2]=q[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}if((Ef|0)>=1){Cn(Bf,Df,Ef)}q[Ye>>2]=Bf;q[Ye+8>>2]=Cf;q[Ye+4>>2]=Af;if(Df){An(Df)}return}bn();F()}ab(1308);F()}function nd(Ye){q[Ye+8>>2]=0;q[Ye+12>>2]=0;q[Ye>>2]=0;q[Ye+40>>2]=0;q[Ye+44>>2]=0;q[Ye+28>>2]=9;o[Ye+24|0]=1;q[Ye+56>>2]=-1;q[Ye+60>>2]=0;q[Ye+16>>2]=0;q[Ye+20>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;return Ye}function od(Ye,xf,zf,Gf,Hf,If,Jf){q[Ye>>2]=0;q[Ye+56>>2]=xf;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+40>>2]=If;q[Ye+44>>2]=Jf;o[Ye+32|0]=Hf;q[Ye+28>>2]=Gf;o[Ye+24|0]=zf}function pd(Ye,xf){var zf=0,Gf=0,Hf=0;Gf=q[Ye>>2];a:{if(!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(eg>>>0>=Tf>>>0){break c}q[Ye+8>>2]=$f+(eg<<2)}lg=Ye+16|0;mg=q[Ye+32>>2];ng=Ye+20|0;while(1){gg=q[xf+8>>2];dg=q[xf+16>>2];bg=q[xf+12>>2];$f=bg;Tf=q[xf+20>>2];if(($f|0)<(Tf|0)?1:($f|0)<=(Tf|0)?gg>>>0>dg>>>0?0:1:0){ag=0;break a}ig=q[xf>>2];og=r[ig+dg|0];$f=Tf;fg=dg+1|0;if(fg>>>0<1){$f=$f+1|0}ag=xf;q[xf+16>>2]=fg;q[xf+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>fg>>>0?0:1:0){ag=0;break a}fg=r[fg+ig|0];$f=Tf;hg=dg+2|0;if(hg>>>0<2){$f=$f+1|0}q[xf+16>>2]=hg;q[ag+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>hg>>>0?0:1:0){ag=0;break a}hg=r[hg+ig|0];$f=Tf;jg=dg+3|0;if(jg>>>0<3){$f=$f+1|0}q[xf+16>>2]=jg;q[ag+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>jg>>>0?0:1:0){ag=0;break a}bg=r[jg+ig|0];$f=Tf;Tf=dg+4|0;if(Tf>>>0<4){$f=$f+1|0}q[xf+16>>2]=Tf;q[ag+20>>2]=$f;if(og>>>0>4){ag=0;break a}if((fg+ -1&255)>>>0>10){ag=0;break a}dg=nd(cg+24|0);Tf=w(bk(fg),hg);od(dg,og,hg<<24>>24,fg,(bg|0)!=0,Tf,Tf>>31);d:{Tf=s[q[Ye+28>>2]+36>>1];e:{if((Tf<<24|Tf<<8&16711680)>>>16>>>0<=258){ag=q[xf+12>>2];$f=q[xf+20>>2];bg=q[xf+16>>2];Tf=bg+2|0;if(Tf>>>0<2){$f=$f+1|0}gg=Tf;Tf=$f;if((ag|0)<(Tf|0)?1:(ag|0)<=(Tf|0)?t[xf+8>>2]>=gg>>>0?0:1:0){break d}$f=bg+q[xf>>2]|0;$f=r[$f|0]|r[$f+1|0]<<8;q[xf+16>>2]=gg;q[xf+20>>2]=Tf;q[cg+20>>2]=$f;break e}zd(1,cg+20|0,xf);$f=q[cg+20>>2]}q[cg+84>>2]=$f;Tf=Mm(96);sd(Tf,dg);q[cg+16>>2]=Tf;Tf=fl(mg,cg+16|0);ag=q[cg+16>>2];q[cg+16>>2]=0;if(ag){Hb(ag)}bg=Tf<<2;q[q[bg+q[mg+8>>2]>>2]+60>>2]=$f;q[q[Ye+4>>2]+(kg<<2)>>2]=Tf;$f=q[Ye+16>>2];ag=q[ng>>2]-$f>>2;f:{if((Tf|0)<(ag|0)){break f}q[cg+12>>2]=-1;Tf=Tf+1|0;if(Tf>>>0>ag>>>0){Ad(lg,Tf-ag|0,cg+12|0);$f=q[lg>>2];break f}if(Tf>>>0>=ag>>>0){break f}q[ng>>2]=(Tf<<2)+$f}q[$f+bg>>2]=kg;ag=1;kg=kg+1|0;if((kg|0)!=(eg|0)){continue}break a}break}ag=0}T=cg+96|0;return ag|0}function zd(Ye,xf,pg){var qg=0,rg=0,sg=0,tg=0;a:{if(Ye>>>0>5){break a}sg=q[pg+16>>2];qg=q[pg+12>>2];rg=q[pg+20>>2];if((qg|0)<(rg|0)?1:(qg|0)<=(rg|0)?t[pg+8>>2]>sg>>>0?0:1:0){break a}qg=r[sg+q[pg>>2]|0];sg=sg+1|0;if(sg>>>0<1){rg=rg+1|0}q[pg+16>>2]=sg;q[pg+20>>2]=rg;rg=xf;if(qg&128){if(!zd(Ye+1|0,xf,pg)){break a}Ye=q[xf>>2]<<7;q[xf>>2]=Ye;qg=Ye|qg&127}q[rg>>2]=qg;tg=1}return tg}function Ad(Ye,xf,pg){var ug=0,vg=0,wg=0,xg=0,yg=0,zg=0;wg=q[Ye+8>>2];ug=q[Ye+4>>2];if(wg-ug>>2>>>0>=xf>>>0){while(1){q[ug>>2]=q[pg>>2];ug=ug+4|0;xf=xf+ -1|0;if(xf){continue}break}q[Ye+4>>2]=ug;return}a:{xg=q[Ye>>2];yg=ug-xg|0;zg=yg>>2;ug=zg+xf|0;if(ug>>>0<1073741824){wg=wg-xg|0;vg=wg>>1;ug=wg>>2>>>0<536870911?vg>>>0>>0?ug:vg:1073741823;vg=0;b:{if(!ug){break b}if(ug>>>0>=1073741824){break a}vg=Mm(ug<<2)}wg=vg+(ug<<2)|0;ug=vg+(zg<<2)|0;while(1){q[ug>>2]=q[pg>>2];ug=ug+4|0;xf=xf+ -1|0;if(xf){continue}break}if((yg|0)>=1){Cn(vg,xg,yg)}q[Ye>>2]=vg;q[Ye+8>>2]=wg;q[Ye+4>>2]=ug;if(xg){An(xg)}return}bn();F()}ab(1520);F()}function Bd(Ye){Ye=Ye|0;var xf=0;q[Ye>>2]=1384;xf=q[Ye+16>>2];if(xf){q[Ye+20>>2]=xf;An(xf)}xf=q[Ye+4>>2];if(xf){q[Ye+8>>2]=xf;An(xf)}return Ye|0}function Cd(q){q=q|0;F()}function Dd(Ye,pg){Ye=Ye|0;pg=pg|0;var Ag=0;a:{if(!n[q[q[Ye>>2]+36>>2]](Ye,pg)){break a}if(!n[q[q[Ye>>2]+40>>2]](Ye,pg)){break a}Ag=n[q[q[Ye>>2]+44>>2]](Ye)|0}return Ag|0}function Ed(Ye,pg){Ye=Ye|0;pg=pg|0;return q[q[Ye+4>>2]+(pg<<2)>>2]}function Fd(Ye){Ye=Ye|0;return q[Ye+8>>2]-q[Ye+4>>2]>>2}function Gd(q,Ye){q=q|0;Ye=Ye|0;return 0}function Hd(q,Ye){q=q|0;Ye=Ye|0;return 1}function Id(Ye){wd(Ye);q[Ye+36>>2]=0;q[Ye+40>>2]=0;q[Ye>>2]=1596;q[Ye+44>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+56>>2]=0;q[Ye+60>>2]=0;q[Ye+64>>2]=0;q[Ye+68>>2]=0}function Jd(Ye,pg){Ye=Ye|0;pg=pg|0;var Bg=0,Cg=0,Dg=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=q[pg+16>>2]+4|0;if(eh>>>0<4){dh=dh+1|0}q[pg+16>>2]=eh;q[pg+20>>2]=dh;if(!ch){gh=1;break a}q[Ye+8>>2]=0;if(!$g(Ye+16|0,pg)){break a}if(!$g(Ye+36|0,pg)){break a}if(!$g(Ye+56|0,pg)){break a}if(!$g(Ye+76|0,pg)){break a}return Zd(Ye,q[Ye+4>>2],ah)}return gh}function Nd(Ye){var pg=0,$g=0,ah=0,hh=0,ih=0;ah=q[Ye+132>>2];if(ah){ih=Ye+136|0;pg=q[ih>>2];$g=ah;a:{if((ah|0)==(pg|0)){break a}while(1){$g=pg+ -12|0;hh=q[$g>>2];if(hh){q[pg+ -8>>2]=hh;An(hh)}pg=$g;if((pg|0)!=(ah|0)){continue}break}$g=q[Ye+132>>2]}q[ih>>2]=ah;An($g)}ah=q[Ye+120>>2];if(ah){ih=Ye+124|0;pg=q[ih>>2];$g=ah;b:{if((ah|0)==(pg|0)){break b}while(1){$g=pg+ -12|0;hh=q[$g>>2];if(hh){q[pg+ -8>>2]=hh;An(hh)}pg=$g;if((pg|0)!=(ah|0)){continue}break}$g=q[Ye+120>>2]}q[ih>>2]=ah;An($g)}pg=q[Ye+108>>2];if(pg){q[Ye+112>>2]=pg;An(pg)}pg=q[Ye+96>>2];if(pg){q[Ye+100>>2]=pg;An(pg)}_g(Ye+76|0);_g(Ye+56|0);_g(Ye+36|0);_g(Ye+16|0)}function Od(Ye,jh){var kh=0,lh=0,mh=0,nh=0;mh=T-16|0;T=mh;q[Ye+12>>2]=jh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;Zg(Ye+16|0);Zg(Ye+36|0);Zg(Ye+56|0);Zg(Ye+76|0);q[Ye+104>>2]=0;q[Ye+96>>2]=0;q[Ye+100>>2]=0;a:{b:{c:{if(jh){if(jh>>>0>=1073741824){break c}kh=jh<<2;lh=Mm(kh);q[Ye+96>>2]=lh;q[Ye+100>>2]=lh;q[Ye+104>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[Ye+100>>2]=lh}q[Ye+108>>2]=0;q[Ye+112>>2]=0;q[Ye+116>>2]=0;if(jh){if(jh>>>0>=1073741824){break b}kh=jh<<2;lh=Mm(kh);q[Ye+108>>2]=lh;q[Ye+112>>2]=lh;q[Ye+116>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[Ye+112>>2]=lh}q[mh+8>>2]=0;q[mh>>2]=0;q[mh+4>>2]=0;if(jh){if(jh>>>0>=1073741824){break a}kh=jh<<2;lh=Mm(kh);q[mh>>2]=lh;q[mh+4>>2]=lh;q[mh+8>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[mh+4>>2]=lh}nh=jh<<5|1;_d(Ye+120|0,nh,mh);kh=q[mh>>2];if(kh){q[mh+4>>2]=kh;An(kh)}q[mh+8>>2]=0;q[mh>>2]=0;q[mh+4>>2]=0;if(jh){if(jh>>>0>=1073741824){break a}kh=jh<<2;lh=Mm(kh);q[mh>>2]=lh;q[mh+4>>2]=lh;q[mh+8>>2]=lh+kh;Dn(lh,0,kh);while(1){lh=lh+4|0;jh=jh+ -1|0;if(jh){continue}break}q[mh+4>>2]=lh}_d(Ye+132|0,nh,mh);jh=q[mh>>2];if(jh){q[mh+4>>2]=jh;An(jh)}T=mh+16|0;return Ye}bn();F()}bn();F()}bn();F()}function Pd(Ye,jh,oh){var ph=0,qh=0,rh=0,sh=0,th=0,uh=0;qh=q[jh+12>>2];a:{rh=q[jh+20>>2];sh=q[jh+16>>2];ph=sh+4|0;if(ph>>>0<4){rh=rh+1|0}if((qh|0)<(rh|0)?1:(qh|0)<=(rh|0)?t[jh+8>>2]>=ph>>>0?0:1:0){break a}ph=sh+q[jh>>2]|0;ph=r[ph|0]|r[ph+1|0]<<8|(r[ph+2|0]<<16|r[ph+3|0]<<24);q[Ye>>2]=ph;qh=q[jh+20>>2];sh=qh;th=q[jh+16>>2];rh=th+4|0;if(rh>>>0<4){qh=qh+1|0}q[jh+16>>2]=rh;q[jh+20>>2]=qh;if(ph>>>0>32){break a}qh=q[jh+12>>2];ph=th+8|0;if(ph>>>0<8){sh=sh+1|0}if((qh|0)<(sh|0)?1:(qh|0)<=(sh|0)?t[jh+8>>2]>=ph>>>0?0:1:0){break a}ph=rh+q[jh>>2]|0;qh=r[ph|0]|r[ph+1|0]<<8|(r[ph+2|0]<<16|r[ph+3|0]<<24);q[Ye+4>>2]=qh;rh=q[jh+20>>2];sh=q[jh+16>>2]+4|0;if(sh>>>0<4){rh=rh+1|0}q[jh+16>>2]=sh;q[jh+20>>2]=rh;if(!qh){uh=1;break a}q[Ye+8>>2]=0;if(!$g(Ye+16|0,jh)){break a}if(!$g(Ye+36|0,jh)){break a}if(!$g(Ye+56|0,jh)){break a}if(!$g(Ye+76|0,jh)){break a}return $d(Ye,q[Ye+4>>2],oh)}return uh}function Qd(Ye,jh,oh){var vh=0,wh=0,xh=0,yh=0,zh=0,Ah=0;wh=q[jh+12>>2];a:{xh=q[jh+20>>2];yh=q[jh+16>>2];vh=yh+4|0;if(vh>>>0<4){xh=xh+1|0}if((wh|0)<(xh|0)?1:(wh|0)<=(xh|0)?t[jh+8>>2]>=vh>>>0?0:1:0){break a}vh=yh+q[jh>>2]|0;vh=r[vh|0]|r[vh+1|0]<<8|(r[vh+2|0]<<16|r[vh+3|0]<<24);q[Ye>>2]=vh;wh=q[jh+20>>2];yh=wh;zh=q[jh+16>>2];xh=zh+4|0;if(xh>>>0<4){wh=wh+1|0}q[jh+16>>2]=xh;q[jh+20>>2]=wh;if(vh>>>0>32){break a}wh=q[jh+12>>2];vh=zh+8|0;if(vh>>>0<8){yh=yh+1|0}if((wh|0)<(yh|0)?1:(wh|0)<=(yh|0)?t[jh+8>>2]>=vh>>>0?0:1:0){break a}vh=xh+q[jh>>2]|0;wh=r[vh|0]|r[vh+1|0]<<8|(r[vh+2|0]<<16|r[vh+3|0]<<24);q[Ye+4>>2]=wh;xh=q[jh+20>>2];yh=q[jh+16>>2]+4|0;if(yh>>>0<4){xh=xh+1|0}q[jh+16>>2]=yh;q[jh+20>>2]=xh;if(!wh){Ah=1;break a}q[Ye+8>>2]=0;if(!bh(Ye+16|0,jh)){break a}if(!$g(Ye+32|0,jh)){break a}if(!$g(Ye+52|0,jh)){break a}if(!$g(Ye+72|0,jh)){break a}return ae(Ye,q[Ye+4>>2],oh)}return Ah}function Rd(Ye){var jh=0,oh=0,Bh=0,Ch=0,Dh=0;Bh=q[Ye+128>>2];if(Bh){Dh=Ye+132|0;jh=q[Dh>>2];oh=Bh;a:{if((Bh|0)==(jh|0)){break a}while(1){oh=jh+ -12|0;Ch=q[oh>>2];if(Ch){q[jh+ -8>>2]=Ch;An(Ch)}jh=oh;if((jh|0)!=(Bh|0)){continue}break}oh=q[Ye+128>>2]}q[Dh>>2]=Bh;An(oh)}Bh=q[Ye+116>>2];if(Bh){Dh=Ye+120|0;jh=q[Dh>>2];oh=Bh;b:{if((Bh|0)==(jh|0)){break b}while(1){oh=jh+ -12|0;Ch=q[oh>>2];if(Ch){q[jh+ -8>>2]=Ch;An(Ch)}jh=oh;if((jh|0)!=(Bh|0)){continue}break}oh=q[Ye+116>>2]}q[Dh>>2]=Bh;An(oh)}jh=q[Ye+104>>2];if(jh){q[Ye+108>>2]=jh;An(jh)}jh=q[Ye+92>>2];if(jh){q[Ye+96>>2]=jh;An(jh)}_g(Ye+72|0);_g(Ye+52|0);_g(Ye+32|0)}function Sd(Ye,Eh){var Fh=0,Gh=0,Hh=0,Ih=0;Hh=T-16|0;T=Hh;q[Ye+12>>2]=Eh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;ah(Ye+16|0);Zg(Ye+32|0);Zg(Ye+52|0);Zg(Ye+72|0);q[Ye+100>>2]=0;q[Ye+92>>2]=0;q[Ye+96>>2]=0;a:{b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>2];Jh=Wh;b:{if((Wh|0)==(Eh|0)){break b}while(1){Jh=Eh+ -12|0;Xh=q[Jh>>2];if(Xh){q[Eh+ -8>>2]=Xh;An(Xh)}Eh=Jh;if((Eh|0)!=(Wh|0)){continue}break}Jh=q[Ye+628>>2]}q[Yh>>2]=Wh;An(Jh)}Eh=q[Ye+616>>2];if(Eh){q[Ye+620>>2]=Eh;An(Eh)}Eh=q[Ye+604>>2];if(Eh){q[Ye+608>>2]=Eh;An(Eh)}_g(Ye+584|0);_g(Ye+564|0);_g(Ye+544|0)}function Wd(Ye,Zh){var _h=0,$h=0,ai=0,bi=0;ai=T-16|0;T=ai;q[Ye+12>>2]=Zh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;de(Ye+16|0);ah(Ye+528|0);Zg(Ye+544|0);Zg(Ye+564|0);Zg(Ye+584|0);q[Ye+612>>2]=0;q[Ye+604>>2]=0;q[Ye+608>>2]=0;a:{b:{c:{if(Zh){if(Zh>>>0>=1073741824){break c}_h=Zh<<2;$h=Mm(_h);q[Ye+604>>2]=$h;q[Ye+608>>2]=$h;q[Ye+612>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[Ye+608>>2]=$h}q[Ye+616>>2]=0;q[Ye+620>>2]=0;q[Ye+624>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break b}_h=Zh<<2;$h=Mm(_h);q[Ye+616>>2]=$h;q[Ye+620>>2]=$h;q[Ye+624>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[Ye+620>>2]=$h}q[ai+8>>2]=0;q[ai>>2]=0;q[ai+4>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break a}_h=Zh<<2;$h=Mm(_h);q[ai>>2]=$h;q[ai+4>>2]=$h;q[ai+8>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[ai+4>>2]=$h}bi=Zh<<5|1;_d(Ye+628|0,bi,ai);_h=q[ai>>2];if(_h){q[ai+4>>2]=_h;An(_h)}q[ai+8>>2]=0;q[ai>>2]=0;q[ai+4>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break a}_h=Zh<<2;$h=Mm(_h);q[ai>>2]=$h;q[ai+4>>2]=$h;q[ai+8>>2]=$h+_h;Dn($h,0,_h);while(1){$h=$h+4|0;Zh=Zh+ -1|0;if(Zh){continue}break}q[ai+4>>2]=$h}_d(Ye+640|0,bi,ai);Zh=q[ai>>2];if(Zh){q[ai+4>>2]=Zh;An(Zh)}T=ai+16|0;return Ye}bn();F()}bn();F()}bn();F()}function Xd(Ye,Zh,ci){var di=0,ei=0,fi=0,gi=0,hi=0,ii=0;ei=q[Zh+12>>2];a:{fi=q[Zh+20>>2];gi=q[Zh+16>>2];di=gi+4|0;if(di>>>0<4){fi=fi+1|0}if((ei|0)<(fi|0)?1:(ei|0)<=(fi|0)?t[Zh+8>>2]>=di>>>0?0:1:0){break a}di=gi+q[Zh>>2]|0;di=r[di|0]|r[di+1|0]<<8|(r[di+2|0]<<16|r[di+3|0]<<24);q[Ye>>2]=di;ei=q[Zh+20>>2];gi=ei;hi=q[Zh+16>>2];fi=hi+4|0;if(fi>>>0<4){ei=ei+1|0}q[Zh+16>>2]=fi;q[Zh+20>>2]=ei;if(di>>>0>32){break a}ei=q[Zh+12>>2];di=hi+8|0;if(di>>>0<8){gi=gi+1|0}if((ei|0)<(gi|0)?1:(ei|0)<=(gi|0)?t[Zh+8>>2]>=di>>>0?0:1:0){break a}di=fi+q[Zh>>2]|0;ei=r[di|0]|r[di+1|0]<<8|(r[di+2|0]<<16|r[di+3|0]<<24);q[Ye+4>>2]=ei;fi=q[Zh+20>>2];gi=q[Zh+16>>2]+4|0;if(gi>>>0<4){fi=fi+1|0}q[Zh+16>>2]=gi;q[Zh+20>>2]=fi;if(!ei){ii=1;break a}q[Ye+8>>2]=0;di=0;while(1){if(!bh(((di<<4)+Ye|0)+16|0,Zh)){break a}di=di+1|0;if((di|0)!=32){continue}break}if(!bh(Ye+528|0,Zh)){break a}if(!$g(Ye+544|0,Zh)){break a}if(!$g(Ye+564|0,Zh)){break a}if(!$g(Ye+584|0,Zh)){break a}return ee(Ye,q[Ye+4>>2],ci)}return ii}function Yd(Ye,Zh,ci){var ji=0,ki=0,li=0,mi=0,ni=0,oi=0;ki=q[Zh+12>>2];a:{li=q[Zh+20>>2];mi=q[Zh+16>>2];ji=mi+4|0;if(ji>>>0<4){li=li+1|0}if((ki|0)<(li|0)?1:(ki|0)<=(li|0)?t[Zh+8>>2]>=ji>>>0?0:1:0){break a}ji=mi+q[Zh>>2]|0;ji=r[ji|0]|r[ji+1|0]<<8|(r[ji+2|0]<<16|r[ji+3|0]<<24);q[Ye>>2]=ji;ki=q[Zh+20>>2];mi=ki;ni=q[Zh+16>>2];li=ni+4|0;if(li>>>0<4){ki=ki+1|0}q[Zh+16>>2]=li;q[Zh+20>>2]=ki;if(ji>>>0>32){break a}ki=q[Zh+12>>2];ji=ni+8|0;if(ji>>>0<8){mi=mi+1|0}if((ki|0)<(mi|0)?1:(ki|0)<=(mi|0)?t[Zh+8>>2]>=ji>>>0?0:1:0){break a}ji=li+q[Zh>>2]|0;ki=r[ji|0]|r[ji+1|0]<<8|(r[ji+2|0]<<16|r[ji+3|0]<<24);q[Ye+4>>2]=ki;li=q[Zh+20>>2];mi=q[Zh+16>>2]+4|0;if(mi>>>0<4){li=li+1|0}q[Zh+16>>2]=mi;q[Zh+20>>2]=li;if(!ki){oi=1;break a}q[Ye+8>>2]=0;ji=0;while(1){if(!bh(((ji<<4)+Ye|0)+16|0,Zh)){break a}ji=ji+1|0;if((ji|0)!=32){continue}break}if(!bh(Ye+528|0,Zh)){break a}if(!$g(Ye+544|0,Zh)){break a}if(!$g(Ye+564|0,Zh)){break a}if(!$g(Ye+584|0,Zh)){break a}return fe(Ye,q[Ye+4>>2],ci)}return oi}function Zd(Ye,Zh,ci){var pi=0,qi=0,ri=0,si=0,ti=0,ui=0,vi=0,wi=0,xi=0,yi=0,zi=0,Ai=0,Bi=0,Ci=0,Di=0,Ei=0,Fi=0,Gi=0,Hi=0,Ii=0,Ji=0,Ki=0,Li=0,Mi=0,Ni=0,Oi=0;si=T-32|0;T=si;qi=q[Ye+12>>2];q[si+16>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;a:{if(qi){if(qi>>>0>=1073741824){break a}pi=qi<<2;ri=Mm(pi);q[si+8>>2]=ri;q[si+12>>2]=ri;q[si+16>>2]=pi+ri;ui=Dn(ri,0,pi);pi=qi;while(1){ui=ui+4|0;pi=pi+ -1|0;if(pi){continue}break}q[si+12>>2]=ui}ti=q[Ye+120>>2];pi=q[ti>>2];if(pi){q[ti+4>>2]=pi;An(pi);q[ti+8>>2]=0;q[ti>>2]=0;q[ti+4>>2]=0;qi=q[Ye+12>>2];ui=q[si+12>>2];ri=q[si+8>>2]}q[ti>>2]=ri;q[ti+4>>2]=ui;q[ti+8>>2]=q[si+16>>2];ui=0;q[si+16>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;pi=0;b:{if(qi){if(qi>>>0>=1073741824){break b}ri=qi<<2;pi=Mm(ri);q[si+8>>2]=pi;q[si+12>>2]=pi;q[si+16>>2]=pi+ri;ui=Dn(pi,0,ri);while(1){ui=ui+4|0;qi=qi+ -1|0;if(qi){continue}break}q[si+12>>2]=ui}ti=q[Ye+132>>2];ri=q[ti>>2];if(ri){q[ti+4>>2]=ri;An(ri);q[ti+8>>2]=0;q[ti>>2]=0;q[ti+4>>2]=0;ui=q[si+12>>2];pi=q[si+8>>2]}q[ti>>2]=pi;q[ti+4>>2]=ui;q[ti+8>>2]=q[si+16>>2];qi=si+24|0;q[qi>>2]=0;q[qi+4>>2]=0;ri=si+16|0;q[ri>>2]=0;q[ri+4>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;re(si+8|0);ti=q[si+12>>2];pi=0;c:{if((ti|0)==q[ri>>2]){break c}ri=q[qi>>2]+q[si+28>>2]|0;pi=(ri>>>0)/341|0;pi=q[ti+(pi<<2)>>2]+w(ri-w(pi,341)|0,12)|0}q[pi+4>>2]=0;q[pi+8>>2]=0;q[pi>>2]=Zh;pi=1;ri=q[si+28>>2];qi=ri+1|0;q[si+28>>2]=qi;d:{if(qi>>>0>>0){break d}Li=Ye+132|0;Ki=Ye+120|0;Gi=ci+20|0;Mi=Ye+108|0;Ni=Ye+96|0;Hi=Ye+48|0;Ii=Ye+28|0;Oi=Ye+80|0;while(1){pi=q[si+12>>2];vi=q[si+24>>2];wi=qi+ -1|0;ti=vi+wi|0;ri=(ti>>>0)/341|0;ri=q[pi+(ri<<2)>>2]+w(ti-w(ri,341)|0,12)|0;Ai=q[ri+8>>2];ti=q[ri+4>>2];zi=q[ri>>2];q[si+28>>2]=wi;ri=q[si+16>>2];pi=ri-pi|0;if(((pi?w(pi>>2,341)+ -1|0:0)-(qi+vi|0)|0)+1>>>0>=682){An(q[ri+ -4>>2]);q[si+16>>2]=q[si+16>>2]+ -4}pi=0;if(zi>>>0>Zh>>>0){break d}ri=q[Ki>>2];Bi=w(Ai,12);Ei=Bi+q[Li>>2]|0;ui=ml(Ye,Ei,ti);if(ui>>>0>=t[Ye+12>>2]){break d}Fi=ri+Bi|0;e:{f:{Ci=ui<<2;ti=q[Ye>>2]-q[Ci+q[Ei>>2]>>2]|0;if(!ti){if(!zi){break f}xi=0;while(1){ti=0;qi=q[ci+16>>2];g:{if((qi|0)==q[Gi>>2]){break g}while(1){qi=w(ti,20)+qi|0;ri=q[Fi>>2]+(q[qi+4>>2]<<2)|0;yi=q[qi>>2];ui=q[qi+12>>2];h:{if(ui>>>0>3){break h}pi=q[ci+12>>2];vi=qi+16|0;if(!q[vi>>2]){ri=pi;break h}wi=qi+12|0;qi=0;while(1){pi=Cn(pi,(qi<<2)+ri|0,ui);ui=q[wi>>2];pi=pi+ui|0;qi=qi+1|0;if(qi>>>0>2]){continue}break}ri=q[ci+12>>2]}qi=q[ci+28>>2];qi=r[yi+84|0]?qi:q[q[yi+68>>2]+(qi<<2)>>2];if(qi>>>0>=t[yi+80>>2]){break g}pi=q[yi+40>>2];Cn(q[q[yi>>2]>>2]+w(pi,qi)|0,ri,pi);ti=ti+1|0;qi=q[ci+16>>2];if(ti>>>0<(q[Gi>>2]-qi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;xi=xi+1|0;if((zi|0)!=(xi|0)){continue}break}break f}i:{j:{k:{l:{if(zi>>>0<=2){ri=q[Mi>>2];q[ri>>2]=ui;pi=1;qi=q[Ye+12>>2];if(qi>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}pi=q[Ki>>2];xi=Ai+1|0;yi=w(xi,12);ri=pi+yi|0;if((ri|0)!=(Fi|0)){hd(ri,q[Fi>>2],q[Fi+4>>2]);pi=q[Ki>>2]}pi=Ci+q[pi+yi>>2]|0;q[pi>>2]=q[pi>>2]+(1<>2];ti=32-wi|0;m:{if((vi|0)<=(ti|0)){ti=q[Ii>>2];if((ti|0)==q[Ye+20>>2]){pi=0;break m}pi=q[ti>>2];ri=vi+wi|0;q[Ye+32>>2]=ri;pi=pi<>>32-vi;if((ri|0)!=32){break m}q[Ye+32>>2]=0;q[Ii>>2]=ti+4;break m}qi=q[Ii>>2];pi=qi+4|0;if((pi|0)==q[Ye+20>>2]){pi=0;break m}ri=q[qi>>2];q[Ii>>2]=pi;pi=vi-ti|0;q[Ye+32>>2]=pi;pi=q[qi+4>>2]>>>32-pi|ri<>>32-vi}ri=(zi>>>1)-pi|0;pi=zi-ri|0;n:{if((pi|0)==(ri|0)){pi=ri;break n}vi=q[Ye+88>>2];if((vi|0)==q[Oi>>2]){break k}wi=q[vi>>2];qi=q[Ye+92>>2];ti=qi+1|0;q[Ye+92>>2]=ti;qi=wi&-2147483648>>>qi;o:{if((ti|0)==32){q[Ye+92>>2]=0;q[Ye+88>>2]=vi+4;if(qi){break o}break k}if(!qi){break k}}}ti=pi;pi=ri;break j}while(1){ui=(qi+ -1|0)==(ui|0)?0:ui+1|0;q[ri+(pi<<2)>>2]=ui;pi=pi+1|0;qi=q[Ye+12>>2];if(pi>>>0>>0){continue}break}break i}ti=ri}vi=q[Li>>2];wi=vi+Bi|0;qi=q[wi>>2];ri=qi+Ci|0;q[ri>>2]=q[ri>>2]+1;hd(vi+yi|0,qi,q[wi+4>>2]);if(pi){ri=q[si+28>>2]+q[si+24>>2]|0;vi=q[si+16>>2];qi=q[si+12>>2];wi=vi-qi|0;if((ri|0)==((wi?w(wi>>2,341)+ -1|0:0)|0)){re(si+8|0);qi=q[si+12>>2];vi=q[si+16>>2];ri=q[si+24>>2]+q[si+28>>2]|0}if((qi|0)==(vi|0)){ri=0}else{Ei=qi;qi=(ri>>>0)/341|0;ri=q[Ei+(qi<<2)>>2]+w(ri-w(qi,341)|0,12)|0}q[ri+8>>2]=Ai;q[ri+4>>2]=ui;q[ri>>2]=pi;q[si+28>>2]=q[si+28>>2]+1}if(!ti){break f}pi=q[si+28>>2]+q[si+24>>2]|0;ri=q[si+16>>2];qi=q[si+12>>2];wi=ri-qi|0;if((pi|0)==((wi?w(wi>>2,341)+ -1|0:0)|0)){re(si+8|0);ri=q[si+16>>2];qi=q[si+12>>2];pi=q[si+24>>2]+q[si+28>>2]|0}if((qi|0)==(ri|0)){pi=0}else{ri=(pi>>>0)/341|0;pi=q[(ri<<2)+qi>>2]+w(pi-w(ri,341)|0,12)|0}q[pi+8>>2]=xi;q[pi+4>>2]=ui;q[pi>>2]=ti;qi=q[si+28>>2]+1|0;q[si+28>>2]=qi;break e}if(!zi){break f}Ai=0;while(1){if(qi){ui=q[Ni>>2];xi=q[Mi>>2];vi=q[Fi>>2];wi=q[Ei>>2];qi=0;while(1){Bi=xi+(qi<<2)|0;q[ui+(q[Bi>>2]<<2)>>2]=0;pi=q[Bi>>2]<<2;Di=q[Ye>>2]-q[pi+wi>>2]|0;p:{if(!Di){break p}Ji=pi+ui|0;Ci=q[Ye+52>>2];ti=32-Ci|0;if((Di|0)<=(ti|0)){ri=q[Hi>>2];if((ri|0)==q[Ye+40>>2]){q[Ji>>2]=0;break p}q[Ji>>2]=q[ri>>2]<>>32-Di;pi=Di+q[Ye+52>>2]|0;q[Ye+52>>2]=pi;if((pi|0)!=32){break p}q[Ye+52>>2]=0;q[Hi>>2]=ri+4;break p}yi=q[Hi>>2];pi=yi+4|0;if((pi|0)==q[Ye+40>>2]){q[Ji>>2]=0;break p}ri=q[yi>>2];q[Hi>>2]=pi;pi=Di-ti|0;q[Ye+52>>2]=pi;q[Ji>>2]=q[yi+4>>2]>>>32-pi|ri<>>32-Di}ri=q[Bi>>2]<<2;pi=ri+ui|0;q[pi>>2]=q[pi>>2]|q[ri+vi>>2];qi=qi+1|0;if(qi>>>0>2]){continue}break}}ti=0;qi=q[ci+16>>2];q:{if((qi|0)==q[Gi>>2]){break q}while(1){qi=w(ti,20)+qi|0;ri=q[Ni>>2]+(q[qi+4>>2]<<2)|0;xi=q[qi>>2];ui=q[qi+12>>2];r:{if(ui>>>0>3){break r}pi=q[ci+12>>2];vi=qi+16|0;if(!q[vi>>2]){ri=pi;break r}wi=qi+12|0;qi=0;while(1){pi=Cn(pi,(qi<<2)+ri|0,ui);ui=q[wi>>2];pi=pi+ui|0;qi=qi+1|0;if(qi>>>0>2]){continue}break}ri=q[ci+12>>2]}qi=q[ci+28>>2];qi=r[xi+84|0]?qi:q[q[xi+68>>2]+(qi<<2)>>2];if(qi>>>0>=t[xi+80>>2]){break q}pi=q[xi+40>>2];Cn(q[q[xi>>2]>>2]+w(pi,qi)|0,ri,pi);ti=ti+1|0;qi=q[ci+16>>2];if(ti>>>0<(q[Gi>>2]-qi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Ai=Ai+1|0;if((Ai|0)==(zi|0)){break f}qi=q[Ye+12>>2];continue}}qi=q[si+28>>2]}if(qi){continue}break}pi=1}se(si+8|0);qi=q[si+12>>2];Ye=q[si+16>>2];s:{if((qi|0)==(Ye|0)){break s}while(1){An(q[qi>>2]);qi=qi+4|0;if((Ye|0)!=(qi|0)){continue}break}Zh=q[si+16>>2];Ye=q[si+12>>2];if((Zh|0)==(Ye|0)){break s}q[si+16>>2]=Zh+(((Zh-Ye|0)+ -4>>>2^-1)<<2)}Ye=q[si+8>>2];if(Ye){An(Ye)}T=si+32|0;return pi}bn();F()}bn();F()}function _d(Ye,Zh,ci){var Pi=0,Qi=0,Ri=0,Si=0,Ti=0,Ui=0,Vi=0,Wi=0;q[Ye>>2]=0;q[Ye+4>>2]=0;q[Ye+8>>2]=0;a:{b:{if(Zh){if(Zh>>>0>=357913942){break b}Qi=w(Zh,12);Pi=Mm(Qi);q[Ye>>2]=Pi;Ri=Ye+4|0;q[Ri>>2]=Pi;q[Ye+8>>2]=Pi+Qi;while(1){q[Pi>>2]=0;q[Pi+4>>2]=0;Qi=Pi+8|0;q[Qi>>2]=0;Si=ci+4|0;Ye=q[Si>>2]-q[ci>>2]|0;c:{if(!Ye){break c}Ti=Ye>>2;if(Ti>>>0>=1073741824){break a}Ye=Mm(Ye);q[Pi>>2]=Ye;Ui=Pi+4|0;q[Ui>>2]=Ye;q[Qi>>2]=Ye+(Ti<<2);Qi=q[ci>>2];Pi=q[Si>>2]-Qi|0;if((Pi|0)<1){break c}Vi=Ui,Wi=Cn(Ye,Qi,Pi)+Pi|0,q[Vi>>2]=Wi}Pi=q[Ri>>2]+12|0;q[Ri>>2]=Pi;Zh=Zh+ -1|0;if(Zh){continue}break}}return}bn();F()}bn();F()}function $d(Ye,Zh,ci){var Xi=0,Yi=0,Zi=0,_i=0,$i=0,aj=0,bj=0,cj=0,dj=0,ej=0,fj=0,gj=0,hj=0,ij=0,jj=0,kj=0,lj=0,mj=0,nj=0,oj=0,pj=0,qj=0,rj=0,sj=0,tj=0,uj=0;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|0;if(Yi>>>0>2]){continue}break}Zi=q[ci+12>>2]}Yi=q[ci+28>>2];Yi=r[bj+84|0]?Yi:q[q[bj+68>>2]+(Yi<<2)>>2];if(Yi>>>0>=t[bj+80>>2]){break g}Xi=q[bj+40>>2];Cn(q[q[bj>>2]>>2]+w(Xi,Yi)|0,Zi,Xi);ej=ej+1|0;Yi=q[ci+16>>2];if(ej>>>0<(q[jj>>2]-Yi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;cj=cj+1|0;if((aj|0)!=(cj|0)){continue}break}break f}i:{j:{k:{l:{if(aj>>>0<=2){Zi=q[pj>>2];q[Zi>>2]=$i;Xi=1;Yi=q[Ye+12>>2];if(Yi>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}Zi=Xi;Xi=Yi+12|0;hd(Zi+Xi|0,q[fj>>2],q[fj+4>>2]);Xi=bj+q[Xi+q[nj>>2]>>2]|0;q[Xi>>2]=q[Xi>>2]+(1<>2];cj=32-Zi|0;m:{if((Xi|0)<=(cj|0)){fj=q[lj>>2];if((fj|0)==q[Ye+20>>2]){Zi=0;break m}cj=q[fj>>2];dj=Xi+Zi|0;q[Ye+32>>2]=dj;Zi=cj<>>32-Xi;if((dj|0)!=32){break m}q[Ye+32>>2]=0;q[lj>>2]=fj+4;break m}fj=q[lj>>2];dj=fj+4|0;if((dj|0)==q[Ye+20>>2]){Zi=0;break m}gj=q[fj>>2];q[lj>>2]=dj;cj=Xi-cj|0;q[Ye+32>>2]=cj;Zi=q[fj+4>>2]>>>32-cj|gj<>>32-Xi}fj=ej+1|0;Xi=(aj>>>1)-Zi|0;Zi=aj-Xi|0;n:{if((Zi|0)==(Xi|0)){Zi=Xi;break n}aj=q[Ye+88>>2];if((aj|0)==q[sj>>2]){break k}cj=q[aj>>2];dj=q[Ye+92>>2];gj=dj+1|0;q[Ye+92>>2]=gj;cj=cj&-2147483648>>>dj;o:{if((g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=ej+1|0;Yi=q[ci+16>>2];if(ej>>>0<(q[jj>>2]-Yi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;cj=cj+1|0;if((cj|0)==(aj|0)){break f}Yi=q[Ye+12>>2];continue}}Yi=q[_i+28>>2]}if(Yi){continue}break}Zi=1}se(_i+8|0);Yi=q[_i+12>>2];Ye=q[_i+16>>2];s:{if((Yi|0)==(Ye|0)){break s}while(1){An(q[Yi>>2]);Yi=Yi+4|0;if((Ye|0)!=(Yi|0)){continue}break}Ye=q[_i+16>>2];Zh=q[_i+12>>2];if((Ye|0)==(Zh|0)){break s}q[_i+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[_i+8>>2];if(Ye){An(Ye)}T=_i+32|0;return Zi}bn();F()}bn();F()}function ae(Ye,Zh,ci){var vj=0,wj=0,xj=0,yj=0,zj=0,Aj=0,Bj=0,Cj=0,Dj=0,Ej=0,Fj=0,Gj=0,Hj=0,Ij=0,Jj=0,Kj=0,Lj=0,Mj=0,Nj=0,Oj=0,Pj=0,Qj=0,Rj=0,Sj=0,Tj=0,Uj=0,Vj=0;yj=T-32|0;T=yj;vj=q[Ye+12>>2];q[yj+16>>2]=0;q[yj+8>>2]=0;q[yj+12>>2]=0;a:{if(vj){if(vj>>>0>=1073741824){break a}wj=vj<<2;xj=Mm(wj);q[yj+8>>2]=xj;q[yj+12>>2]=xj;q[yj+16>>2]=wj+xj;Aj=Dn(xj,0,wj);wj=vj;while(1){Aj=Aj+4|0;wj=wj+ -1|0;if(wj){continue}break}q[yj+12>>2]=Aj}zj=q[Ye+116>>2];wj=q[zj>>2];if(wj){q[zj+4>>2]=wj;An(wj);q[zj+8>>2]=0;q[zj>>2]=0;q[zj+4>>2]=0;vj=q[Ye+12>>2];Aj=q[yj+12>>2];xj=q[yj+8>>2]}q[zj>>2]=xj;q[zj+4>>2]=Aj;q[zj+8>>2]=q[yj+16>>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+Bj|0)|0)+1>>>0>=682){An(q[xj+ -4>>2]);q[yj+16>>2]=q[yj+16>>2]+ -4}wj=0;if(Fj>>>0>Zh>>>0){break d}xj=q[Oj>>2];Hj=w(Gj,12);Pj=Hj+q[Qj>>2]|0;Aj=ml(Ye,Pj,zj);if(Aj>>>0>=t[Ye+12>>2]){break d}Kj=xj+Hj|0;e:{Ij=Aj<<2;zj=q[Ye>>2]-q[Ij+q[Pj>>2]>>2]|0;if(!zj){if(!Fj){break e}Dj=0;while(1){zj=0;vj=q[ci+16>>2];f:{if((vj|0)==q[Lj>>2]){break f}while(1){vj=w(zj,20)+vj|0;xj=q[Kj>>2]+(q[vj+4>>2]<<2)|0;Ej=q[vj>>2];Aj=q[vj+12>>2];g:{if(Aj>>>0>3){break g}wj=q[ci+12>>2];Bj=vj+16|0;if(!q[Bj>>2]){xj=wj;break g}Cj=vj+12|0;vj=0;while(1){wj=Cn(wj,(vj<<2)+xj|0,Aj);Aj=q[Cj>>2];wj=wj+Aj|0;vj=vj+1|0;if(vj>>>0>2]){continue}break}xj=q[ci+12>>2]}vj=q[ci+28>>2];vj=r[Ej+84|0]?vj:q[q[Ej+68>>2]+(vj<<2)>>2];if(vj>>>0>=t[Ej+80>>2]){break f}wj=q[Ej+40>>2];Cn(q[q[Ej>>2]>>2]+w(wj,vj)|0,xj,wj);zj=zj+1|0;vj=q[ci+16>>2];if(zj>>>0<(q[Lj>>2]-vj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Dj=Dj+1|0;if((Fj|0)!=(Dj|0)){continue}break}break e}h:{i:{j:{k:{if(Fj>>>0<=2){xj=q[Rj>>2];q[xj>>2]=Aj;wj=1;vj=q[Ye+12>>2];if(vj>>>0>1){break k}break h}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}wj=q[Oj>>2];Dj=Gj+1|0;Ej=w(Dj,12);xj=wj+Ej|0;if((xj|0)!=(Kj|0)){hd(xj,q[Kj>>2],q[Kj+4>>2]);wj=q[Oj>>2]}wj=Ij+q[wj+Ej>>2]|0;q[wj>>2]=q[wj>>2]+(1<>2]=0;eh(Uj,z(Fj)^31,yj+4|0);xj=(Fj>>>1)-q[yj+4>>2]|0;wj=Fj-xj|0;l:{if((wj|0)==(xj|0)){wj=xj;break l}Bj=q[Ye+84>>2];if((Bj|0)==q[Vj>>2]){break j}Cj=q[Bj>>2];vj=q[Ye+88>>2];zj=vj+1|0;q[Ye+88>>2]=zj;vj=Cj&-2147483648>>>vj;m:{if((zj|0)==32){q[Ye+88>>2]=0;q[Ye+84>>2]=Bj+4;if(vj){break m}break j}if(!vj){break j}}}zj=wj;wj=xj;break i}while(1){Aj=(vj+ -1|0)==(Aj|0)?0:Aj+1|0;q[xj+(wj<<2)>>2]=Aj;wj=wj+1|0;vj=q[Ye+12>>2];if(wj>>>0>>0){continue}break}break h}zj=xj}Bj=q[Qj>>2];Cj=Bj+Hj|0;vj=q[Cj>>2];xj=vj+Ij|0;q[xj>>2]=q[xj>>2]+1;hd(Bj+Ej|0,vj,q[Cj+4>>2]);if(wj){xj=q[yj+28>>2]+q[yj+24>>2]|0;Bj=q[yj+16>>2];vj=q[yj+12>>2];Cj=Bj-vj|0;if((xj|0)==((Cj?w(Cj>>2,341)+ -1|0:0)|0)){re(yj+8|0);vj=q[yj+12>>2];Bj=q[yj+16>>2];xj=q[yj+24>>2]+q[yj+28>>2]|0}if((vj|0)==(Bj|0)){xj=0}else{Bj=vj;vj=(xj>>>0)/341|0;xj=q[Bj+(vj<<2)>>2]+w(xj-w(vj,341)|0,12)|0}q[xj+8>>2]=Gj;q[xj+4>>2]=Aj;q[xj>>2]=wj;q[yj+28>>2]=q[yj+28>>2]+1}if(!zj){break e}wj=q[yj+28>>2]+q[yj+24>>2]|0;xj=q[yj+16>>2];vj=q[yj+12>>2];Cj=xj-vj|0;if((wj|0)==((Cj?w(Cj>>2,341)+ -1|0:0)|0)){re(yj+8|0);xj=q[yj+16>>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1){wj=Cn(wj,(vj<<2)+xj|0,Aj);Aj=q[Cj>>2];wj=wj+Aj|0;vj=vj+1|0;if(vj>>>0>2]){continue}break}xj=q[ci+12>>2]}vj=q[ci+28>>2];vj=r[Dj+84|0]?vj:q[q[Dj+68>>2]+(vj<<2)>>2];if(vj>>>0>=t[Dj+80>>2]){break o}wj=q[Dj+40>>2];Cn(q[q[Dj>>2]>>2]+w(wj,vj)|0,xj,wj);zj=zj+1|0;vj=q[ci+16>>2];if(zj>>>0<(q[Lj>>2]-vj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Gj=Gj+1|0;if((Gj|0)==(Fj|0)){break e}vj=q[Ye+12>>2];continue}}vj=q[yj+28>>2];if(vj){continue}break}wj=1}se(yj+8|0);vj=q[yj+12>>2];Ye=q[yj+16>>2];q:{if((vj|0)==(Ye|0)){break q}while(1){An(q[vj>>2]);vj=vj+4|0;if((Ye|0)!=(vj|0)){continue}break}Zh=q[yj+16>>2];Ye=q[yj+12>>2];if((Zh|0)==(Ye|0)){break q}q[yj+16>>2]=Zh+(((Zh-Ye|0)+ -4>>>2^-1)<<2)}Ye=q[yj+8>>2];if(Ye){An(Ye)}T=yj+32|0;return wj}bn();F()}bn();F()}function be(Ye,Zh,ci){var Wj=0,Xj=0,Yj=0,Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0,fk=0,gk=0,hk=0,ik=0,jk=0,kk=0,lk=0,mk=0,nk=0,ok=0,pk=0,qk=0,rk=0,sk=0,tk=0,uk=0;Zj=T-32|0;T=Zj;Xj=q[Ye+12>>2];q[Zj+16>>2]=0;q[Zj+8>>2]=0;q[Zj+12>>2]=0;a:{if(Xj){if(Xj>>>0>=1073741824){break a}Wj=Xj<<2;Yj=Mm(Wj);q[Zj+8>>2]=Yj;q[Zj+12>>2]=Yj;q[Zj+16>>2]=Wj+Yj;_j=Dn(Yj,0,Wj);Wj=Xj;while(1){_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j,Wj);ck=ck+1|0;Xj=q[ci+16>>2];if(ck>>>0<(q[hk>>2]-Xj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;bk=bk+1|0;if(($j|0)!=(bk|0)){continue}break}break e}h:{i:{j:{k:{if($j>>>0<=2){Yj=q[mk>>2];q[Yj>>2]=_j;Wj=1;Xj=q[Ye+12>>2];if(Xj>>>0>1){break k}break h}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}Yj=Wj;Wj=Xj+12|0;hd(Yj+Wj|0,q[ek>>2],q[ek+4>>2]);Wj=ak+q[Wj+q[kk>>2]>>2]|0;q[Wj>>2]=q[Wj>>2]+(1<>2]=0;eh(qk,z($j)^31,Zj+4|0);ek=ck+1|0;Wj=($j>>>1)-q[Zj+4>>2]|0;Yj=$j-Wj|0;l:{if((Yj|0)==(Wj|0)){Yj=Wj;break l}$j=q[Ye+84>>2];if(($j|0)==q[rk>>2]){break j}bk=q[$j>>2];dk=q[Ye+88>>2];fk=dk+1|0;q[Ye+88>>2]=fk;bk=bk&-2147483648>>>dk;m:{if((fk|0)==32){q[Ye+88>>2]=0;q[Ye+84>>2]=$j+4;if(bk){break m}break j}if(!bk){break j}}}$j=Yj;Yj=Wj;break i}while(1){_j=(Xj+ -1|0)==(_j|0)?0:_j+1|0;q[Yj+(Wj<<2)>>2]=_j;Wj=Wj+1|0;Xj=q[Ye+12>>2];if(Wj>>>0>>0){continue}break}break h}$j=Wj}bk=ak;Wj=q[lk>>2];Xj=Wj+Xj|0;ak=q[Xj>>2];bk=bk+ak|0;q[bk>>2]=q[bk>>2]+1;hd(Wj+w(ek,12)|0,ak,q[Xj+4>>2]);if(Yj){Wj=q[Zj+28>>2]+q[Zj+24>>2]|0;ak=q[Zj+16>>2];Xj=q[Zj+12>>2];bk=ak-Xj|0;if((Wj|0)==((bk?w(bk>>2,341)+ -1|0:0)|0)){re(Zj+8|0);ak=q[Zj+16>>2];Xj=q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;q[Ye+48>>2]=gk;q[Yj>>2]=q[dk+4>>2]>>>32-gk|uk<>>32-Wj}Wj=q[ck>>2]<<2;Yj=Wj+_j|0;q[Yj>>2]=q[Yj>>2]|q[Wj+sk>>2];Xj=Xj+1|0;if(Xj>>>0>2]){continue}break}}ck=0;Xj=q[ci+16>>2];o:{if((Xj|0)==q[hk>>2]){break o}while(1){Xj=w(ck,20)+Xj|0;Yj=q[nk>>2]+(q[Xj+4>>2]<<2)|0;ak=q[Xj>>2];_j=q[Xj+12>>2];p:{if(_j>>>0>3){break p}Wj=q[ci+12>>2];dk=Xj+16|0;if(!q[dk>>2]){Yj=Wj;break p}jk=Xj+12|0;Xj=0;while(1){Wj=Cn(Wj,(Xj<<2)+Yj|0,_j);_j=q[jk>>2];Wj=Wj+_j|0;Xj=Xj+1|0;if(Xj>>>0>2]){continue}break}Yj=q[ci+12>>2]}Xj=q[ci+28>>2];Xj=r[ak+84|0]?Xj:q[q[ak+68>>2]+(Xj<<2)>>2];if(Xj>>>0>=t[ak+80>>2]){break o}Wj=q[ak+40>>2];Cn(q[q[ak>>2]>>2]+w(Wj,Xj)|0,Yj,Wj);ck=ck+1|0;Xj=q[ci+16>>2];if(ck>>>0<(q[hk>>2]-Xj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;bk=bk+1|0;if((bk|0)==($j|0)){break e}Xj=q[Ye+12>>2];continue}}Xj=q[Zj+28>>2];if(Xj){continue}break}Yj=1}se(Zj+8|0);Xj=q[Zj+12>>2];Ye=q[Zj+16>>2];q:{if((Xj|0)==(Ye|0)){break q}while(1){An(q[Xj>>2]);Xj=Xj+4|0;if((Ye|0)!=(Xj|0)){continue}break}Ye=q[Zj+16>>2];Zh=q[Zj+12>>2];if((Ye|0)==(Zh|0)){break q}q[Zj+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[Zj+8>>2];if(Ye){An(Ye)}T=Zj+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!q[Fk>>2]){xk=wk;break h}Ek=vk+12|0;vk=0;while(1){wk=Cn(wk,(vk<<2)+xk|0,Ak);Ak=q[Ek>>2];wk=wk+Ak|0;vk=vk+1|0;if(vk>>>0>2]){continue}break}xk=q[ci+12>>2]}vk=q[ci+28>>2];vk=r[Bk+84|0]?vk:q[q[Bk+68>>2]+(vk<<2)>>2];if(vk>>>0>=t[Bk+80>>2]){break g}wk=vk;vk=q[Bk+40>>2];Cn(q[q[Bk>>2]>>2]+w(wk,vk)|0,xk,vk);Ck=Ck+1|0;vk=q[ci+16>>2];if(Ck>>>0<(q[Jk>>2]-vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Gk=Gk+1|0;if((zk|0)!=(Gk|0)){continue}break}break f}i:{j:{k:{l:{if(zk>>>0<=2){xk=q[Nk>>2];q[xk>>2]=Ak;wk=1;vk=q[Ye+12>>2];if(vk>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}xk=q[Lk>>2];Ek=Ck+1|0;Gk=w(Ek,12);wk=xk+Gk|0;if((wk|0)!=(Dk|0)){hd(wk,q[Dk>>2],q[Dk+4>>2]);xk=q[Lk>>2]}xk=Fk+q[xk+Gk>>2]|0;q[xk>>2]=q[xk>>2]+(1<>>1)-wk|0;vk=zk-wk|0;m:{if((vk|0)==(wk|0)){vk=wk;break m}xk=q[Ye+596>>2];if((xk|0)==q[Rk>>2]){break k}zk=q[xk>>2];Dk=q[Ye+600>>2];Hk=Dk+1|0;q[Ye+600>>2]=Hk;zk=zk&-2147483648>>>Dk;n:{if((Hk|0)==32){q[Ye+600>>2]=0;q[Ye+596>>2]=xk+4;if(zk){break n}break k}if(!zk){break k}}}xk=vk;vk=wk;break j}while(1){Ak=(vk+ -1|0)==(Ak|0)?0:Ak+1|0;q[xk+(wk<<2)>>2]=Ak;wk=wk+1|0;vk=q[Ye+12>>2];if(wk>>>0>>0){continue}break}break i}xk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((Ek|0)==q[Pk>>2]){q[wk>>2]=0;break p}q[wk>>2]=q[Ek>>2]<>>32-xk;xk=xk+q[Ye+560>>2]|0;q[Ye+560>>2]=xk;if((xk|0)!=32){break p}q[Ye+560>>2]=0;q[Kk>>2]=Ek+4;break p}Ek=q[Kk>>2];Qk=Ek+4|0;if((Qk|0)==q[Pk>>2]){q[wk>>2]=0;break p}Uk=q[Ek>>2];q[Kk>>2]=Qk;Ik=xk-Ik|0;q[Ye+560>>2]=Ik;q[wk>>2]=q[Ek+4>>2]>>>32-Ik|Uk<>>32-xk}xk=q[Ck>>2]<<2;wk=xk+Ak|0;q[wk>>2]=q[wk>>2]|q[xk+Sk>>2];vk=vk+1|0;if(vk>>>0>2]){continue}break}}Ck=0;vk=q[ci+16>>2];q:{if((vk|0)==q[Jk>>2]){break q}while(1){vk=w(Ck,20)+vk|0;xk=q[Ok>>2]+(q[vk+4>>2]<<2)|0;Bk=q[vk>>2];Ak=q[vk+12>>2];r:{if(Ak>>>0>3){break r}wk=q[ci+12>>2];Ek=vk+16|0;if(!q[Ek>>2]){xk=wk;break r}Hk=vk+12|0;vk=0;while(1){wk=Cn(wk,(vk<<2)+xk|0,Ak);Ak=q[Hk>>2];wk=wk+Ak|0;vk=vk+1|0;if(vk>>>0>2]){continue}break}xk=q[ci+12>>2]}vk=q[ci+28>>2];vk=r[Bk+84|0]?vk:q[q[Bk+68>>2]+(vk<<2)>>2];if(vk>>>0>=t[Bk+80>>2]){break q}wk=vk;vk=q[Bk+40>>2];Cn(q[q[Bk>>2]>>2]+w(wk,vk)|0,xk,vk);Ck=Ck+1|0;vk=q[ci+16>>2];if(Ck>>>0<(q[Jk>>2]-vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Fk=Fk+1|0;if((Fk|0)==(zk|0)){break f}vk=q[Ye+12>>2];continue}}vk=q[yk+28>>2]}if(vk){continue}break}wk=1}se(yk+8|0);vk=q[yk+12>>2];Ye=q[yk+16>>2];s:{if((vk|0)==(Ye|0)){break s}while(1){An(q[vk>>2]);vk=vk+4|0;if((Ye|0)!=(vk|0)){continue}break}Ye=q[yk+16>>2];Zh=q[yk+12>>2];if((Ye|0)==(Zh|0)){break s}q[yk+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[yk+8>>2];if(Ye){An(Ye)}T=yk+32|0;return wk}bn();F()}bn();F()}function de(q){ah(q);ah(q+16|0);ah(q+32|0);ah(q+48|0);ah(q- -64|0);ah(q+80|0);ah(q+96|0);ah(q+112|0);ah(q+128|0);ah(q+144|0);ah(q+160|0);ah(q+176|0);ah(q+192|0);ah(q+208|0);ah(q+224|0);ah(q+240|0);ah(q+256|0);ah(q+272|0);ah(q+288|0);ah(q+304|0);ah(q+320|0);ah(q+336|0);ah(q+352|0);ah(q+368|0);ah(q+384|0);ah(q+400|0);ah(q+416|0);ah(q+432|0);ah(q+448|0);ah(q+464|0);ah(q+480|0);ah(q+496|0)}function ee(Ye,Zh,ci){var Vk=0,Wk=0,Xk=0,Yk=0,Zk=0,_k=0,$k=0,al=0,bl=0,cl=0,dl=0,el=0,fl=0,gl=0,hl=0,il=0,jl=0,kl=0,ll=0,ml=0,nl=0,ol=0,pl=0,ql=0,rl=0,sl=0;Yk=T-32|0;T=Yk;Vk=q[Ye+12>>2];q[Yk+16>>2]=0;q[Yk+8>>2]=0;q[Yk+12>>2]=0;a:{if(Vk){if(Vk>>>0>=1073741824){break a}Wk=Vk<<2;Xk=Mm(Wk);q[Yk+8>>2]=Xk;q[Yk+12>>2]=Xk;q[Yk+16>>2]=Wk+Xk;Zk=Dn(Xk,0,Wk);Wk=Vk;while(1){Zk=Zk+4|0;Wk=Wk+ -1|0;if(Wk){continue}break}q[Yk+12>>2]=Zk}Wk=q[Ye+628>>2];_k=q[Wk>>2];if(_k){q[Wk+4>>2]=_k;An(_k);q[Wk+8>>2]=0;q[Wk>>2]=0;q[Wk+4>>2]=0;V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=bl+1|0;if((_k|0)!=(bl|0)){continue}break}break f}i:{j:{k:{l:{if(_k>>>0<=2){Xk=q[ll>>2];q[Xk>>2]=Zk;Wk=1;Vk=q[Ye+12>>2];if(Vk>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}Xk=$k+12|0;hd(Xk+Vk|0,q[dl>>2],q[dl+4>>2]);Xk=bl+q[Xk+q[jl>>2]>>2]|0;q[Xk>>2]=q[Xk>>2]+(1<>>1)-Wk|0;Vk=_k-Wk|0;m:{if((Vk|0)==(Wk|0)){Vk=Wk;break m}Xk=q[Ye+596>>2];if((Xk|0)==q[pl>>2]){break k}_k=q[Xk>>2];cl=q[Ye+600>>2];el=cl+1|0;q[Ye+600>>2]=el;_k=_k&-2147483648>>>cl;n:{if((el|0)==32){q[Ye+600>>2]=0;q[Ye+596>>2]=Xk+4;if(_k){break n}break k}if(!_k){break k}}}Xk=Vk;Vk=Wk;break j}while(1){Zk=(Vk+ -1|0)==(Zk|0)?0:Zk+1|0;q[Xk+(Wk<<2)>>2]=Zk;Wk=Wk+1|0;Vk=q[Ye+12>>2];if(Wk>>>0>>0){continue}break}break i}Xk=Wk}Wk=q[kl>>2];_k=Wk+$k|0;$k=q[_k>>2];bl=$k+bl|0;q[bl>>2]=q[bl>>2]+1;hd(Wk+w(dl,12)|0,$k,q[_k+4>>2]);if(Vk){$k=q[Yk+28>>2]+q[Yk+24>>2]|0;bl=q[Yk+16>>2];Wk=q[Yk+12>>2];_k=bl-Wk|0;if(($k|0)==((_k?w(_k>>2,341)+ -1|0:0)|0)){re(Yk+8|0);$k=q[Yk+24>>2]+q[Yk+28>>2]|0;bl=q[Yk+16>>2];Wk=q[Yk+12>>2]}_k=0;o:{if((Wk|0)==(bl|0)){break o}_k=Wk;Wk=($k>>>0)/341|0;_k=q[_k+(Wk<<2)>>2]+w($k-w(Wk,341)|0,12)|0}q[_k+8>>2]=al;q[_k+4>>2]=Zk;q[_k>>2]=Vk;q[Yk+28>>2]=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0)==q[gl>>2]){break q}while(1){Vk=w($k,20)+Vk|0;Xk=q[ml>>2]+(q[Vk+4>>2]<<2)|0;al=q[Vk>>2];Zk=q[Vk+12>>2];r:{if(Zk>>>0>3){break r}Wk=q[ci+12>>2];cl=Vk+16|0;if(!q[cl>>2]){Xk=Wk;break r}il=Vk+12|0;Vk=0;while(1){Wk=Cn(Wk,(Vk<<2)+Xk|0,Zk);Zk=q[il>>2];Wk=Wk+Zk|0;Vk=Vk+1|0;if(Vk>>>0>2]){continue}break}Xk=q[ci+12>>2]}Vk=q[ci+28>>2];Vk=r[al+84|0]?Vk:q[q[al+68>>2]+(Vk<<2)>>2];if(Vk>>>0>=t[al+80>>2]){break q}Wk=Vk;Vk=q[al+40>>2];Cn(q[q[al>>2]>>2]+w(Wk,Vk)|0,Xk,Vk);$k=$k+1|0;Vk=q[ci+16>>2];if($k>>>0<(q[gl>>2]-Vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;bl=bl+1|0;if((bl|0)==(_k|0)){break f}Vk=q[Ye+12>>2];continue}}Vk=q[Yk+28>>2]}if(Vk){continue}break}Xk=1}se(Yk+8|0);Vk=q[Yk+12>>2];Ye=q[Yk+16>>2];s:{if((Vk|0)==(Ye|0)){break s}while(1){An(q[Vk>>2]);Vk=Vk+4|0;if((Ye|0)!=(Vk|0)){continue}break}Ye=q[Yk+16>>2];Zh=q[Yk+12>>2];if((Ye|0)==(Zh|0)){break s}q[Yk+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[Yk+8>>2];if(Ye){An(Ye)}T=Yk+32|0;return Xk}bn();F()}bn();F()}function fe(Ye,Zh,ci){var tl=0,ul=0,vl=0,wl=0,xl=0,yl=0,zl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0,Ml=0,Nl=0,Ol=0,Pl=0,Ql=0,Rl=0,Sl=0;wl=T-32|0;T=wl;tl=q[Ye+12>>2];q[wl+16>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;a:{if(tl){if(tl>>>0>=1073741824){break a}ul=tl<<2;vl=Mm(ul);q[wl+8>>2]=vl;q[wl+12>>2]=vl;q[wl+16>>2]=ul+vl;yl=Dn(vl,0,ul);ul=tl;while(1){yl=yl+4|0;ul=ul+ -1|0;if(ul){continue}break}q[wl+12>>2]=yl}ul=q[Ye+628>>2];xl=q[ul>>2];if(xl){q[ul+4>>2]=xl;An(xl);q[ul+8>>2]=0;q[ul>>2]=0;q[ul+4>>2]=0;tl=q[Ye+12>>2];yl=q[wl+12>>2];vl=q[wl+8>>2]}q[ul>>2]=vl;q[ul+4>>2]=yl;q[ul+8>>2]=q[wl+16>>2];yl=0;q[wl+16>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;ul=0;b:{if(tl){if(tl>>>0>=1073741824){break b}vl=tl<<2;ul=Mm(vl);q[wl+8>>2]=ul;q[wl+12>>2]=ul;q[wl+16>>2]=ul+vl;yl=Dn(ul,0,vl);while(1){yl=yl+4|0;tl=tl+ -1|0;if(tl){continue}break}q[wl+12>>2]=yl}vl=q[Ye+640>>2];tl=q[vl>>2];if(tl){q[vl+4>>2]=tl;An(tl);q[vl+8>>2]=0;q[vl>>2]=0;q[vl+4>>2]=0;yl=q[wl+12>>2];ul=q[wl+8>>2]}q[vl>>2]=ul;q[vl+4>>2]=yl;q[vl+8>>2]=q[wl+16>>2];tl=wl+24|0;q[tl>>2]=0;q[tl+4>>2]=0;ul=wl+16|0;q[ul>>2]=0;q[ul+4>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;re(wl+8|0);xl=q[ul>>2];ul=q[wl+12>>2];vl=0;c:{if((xl|0)==(ul|0)){break c}vl=q[tl>>2]+q[wl+28>>2]|0;tl=(vl>>>0)/341|0;vl=q[ul+(tl<<2)>>2]+w(vl-w(tl,341)|0,12)|0}q[vl+4>>2]=0;q[vl+8>>2]=0;q[vl>>2]=Zh;ul=1;vl=q[wl+28>>2];tl=vl+1|0;q[wl+28>>2]=tl;d:{if(tl>>>0>>0){break d}Kl=Ye+640|0;Jl=Ye+628|0;Hl=ci+20|0;Ll=Ye+616|0;Ml=Ye+604|0;Il=Ye+556|0;Nl=Ye+548|0;Pl=Ye+588|0;while(1){Bl=q[wl+12>>2];ul=q[wl+24>>2];yl=tl+ -1|0;vl=ul+yl|0;xl=(vl>>>0)/341|0;vl=q[Bl+(xl<<2)>>2]+w(vl-w(xl,341)|0,12)|0;Al=q[vl+8>>2];xl=q[vl>>2];q[wl+28>>2]=yl;vl=q[wl+16>>2];yl=vl-Bl|0;if(((yl?w(yl>>2,341)+ -1|0:0)-(tl+ul|0)|0)+1>>>0>=682){An(q[vl+ -4>>2]);q[wl+16>>2]=q[wl+16>>2]+ -4}ul=0;if(xl>>>0>Zh>>>0){break d}vl=q[Jl>>2];zl=w(Al,12);Dl=zl+q[Kl>>2]|0;yl=nl(Ye,xl,Dl);if(yl>>>0>=t[Ye+12>>2]){break d}Bl=vl+zl|0;e:{f:{El=yl<<2;tl=q[Ye>>2]-q[El+q[Dl>>2]>>2]|0;if(!tl){if(!xl){break f}Dl=0;while(1){Al=0;tl=q[ci+16>>2];g:{if((tl|0)==q[Hl>>2]){break g}while(1){tl=w(Al,20)+tl|0;vl=q[Bl>>2]+(q[tl+4>>2]<<2)|0;zl=q[tl>>2];yl=q[tl+12>>2];h:{if(yl>>>0>3){break h}ul=q[ci+12>>2];El=tl+16|0;if(!q[El>>2]){vl=ul;break h}Cl=tl+12|0;tl=0;while(1){ul=Cn(ul,(tl<<2)+vl|0,yl);yl=q[Cl>>2];ul=ul+yl|0;tl=tl+1|0;if(tl>>>0>2]){continue}break}vl=q[ci+12>>2]}tl=q[ci+28>>2];tl=r[zl+84|0]?tl:q[q[zl+68>>2]+(tl<<2)>>2];if(tl>>>0>=t[zl+80>>2]){break g}ul=tl;tl=q[zl+40>>2];Cn(q[q[zl>>2]>>2]+w(ul,tl)|0,vl,tl);Al=Al+1|0;tl=q[ci+16>>2];if(Al>>>0<(q[Hl>>2]-tl|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Dl=Dl+1|0;if((xl|0)!=(Dl|0)){continue}break}break f}i:{j:{k:{l:{if(xl>>>0<=2){vl=q[Ll>>2];q[vl>>2]=yl;ul=1;tl=q[Ye+12>>2];if(tl>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}vl=q[Jl>>2];Cl=Al+1|0;Dl=w(Cl,12);ul=vl+Dl|0;if((ul|0)!=(Bl|0)){hd(ul,q[Bl>>2],q[Bl+4>>2]);vl=q[Jl>>2]}vl=El+q[vl+Dl>>2]|0;q[vl>>2]=q[vl>>2]+(1<>>1)-ul|0;tl=xl-ul|0;m:{if((tl|0)==(ul|0)){tl=ul;break m}vl=q[Ye+596>>2];if((vl|0)==q[Pl>>2]){break k}xl=q[vl>>2];Bl=q[Ye+600>>2];Fl=Bl+1|0;q[Ye+600>>2]=Fl;xl=xl&-2147483648>>>Bl;n:{if((Fl|0)==32){q[Ye+600>>2]=0;q[Ye+596>>2]=vl+4;if(xl){break n}break k}if(!xl){break k}}}vl=tl;tl=ul;break j}while(1){yl=(tl+ -1|0)==(yl|0)?0:yl+1|0;q[vl+(ul<<2)>>2]=yl;ul=ul+1|0;tl=q[Ye+12>>2];if(ul>>>0>>0){continue}break}break i}vl=ul}ul=q[Kl>>2];xl=ul+zl|0;Bl=q[xl>>2];zl=Bl+El|0;q[zl>>2]=q[zl>>2]+1;hd(ul+Dl|0,Bl,q[xl+4>>2]);if(tl){Bl=q[wl+28>>2]+q[wl+24>>2]|0;zl=q[wl+16>>2];ul=q[wl+12>>2];xl=zl-ul|0;if((Bl|0)==((xl?w(xl>>2,341)+ -1|0:0)|0)){re(wl+8|0);Bl=q[wl+24>>2]+q[wl+28>>2]|0;zl=q[wl+16>>2];ul=q[wl+12>>2]}xl=0;o:{if((ul|0)==(zl|0)){break o}xl=ul;ul=(Bl>>>0)/341|0;xl=q[xl+(ul<<2)>>2]+w(Bl-w(ul,341)|0,12)|0}q[xl+8>>2]=Al;q[xl+4>>2]=yl;q[xl>>2]=tl;q[wl+28>>2]=q[wl+28>>2]+1}if(!vl){break f}ul=q[wl+28>>2]+q[wl+24>>2]|0;xl=q[wl+16>>2];tl=q[wl+12>>2];Al=xl-tl|0;if((ul|0)==((Al?w(Al>>2,341)+ -1|0:0)|0)){re(wl+8|0);xl=q[wl+16>>2];ul=q[wl+24>>2]+q[wl+28>>2]|0;tl=q[wl+12>>2]}if((tl|0)==(xl|0)){tl=0}else{xl=tl;tl=(ul>>>0)/341|0;tl=q[xl+(tl<<2)>>2]+w(ul-w(tl,341)|0,12)|0}q[tl+8>>2]=Cl;q[tl+4>>2]=yl;q[tl>>2]=vl;tl=q[wl+28>>2]+1|0;q[wl+28>>2]=tl;break e}if(!xl){break f}El=0;while(1){if(tl){yl=q[Ml>>2];Fl=q[Ll>>2];Ql=q[Bl>>2];Rl=q[Dl>>2];tl=0;while(1){Al=Fl+(tl<<2)|0;q[yl+(q[Al>>2]<<2)>>2]=0;ul=q[Al>>2]<<2;vl=q[Ye>>2]-q[ul+Rl>>2]|0;p:{if(!vl){break p}ul=ul+yl|0;zl=q[Ye+560>>2];Gl=32-zl|0;if((vl|0)<=(Gl|0)){Cl=q[Il>>2];if((Cl|0)==q[Nl>>2]){q[ul>>2]=0;break p}q[ul>>2]=q[Cl>>2]<>>32-vl;vl=vl+q[Ye+560>>2]|0;q[Ye+560>>2]=vl;if((vl|0)!=32){break p}q[Ye+560>>2]=0;q[Il>>2]=Cl+4;break p}Cl=q[Il>>2];Ol=Cl+4|0;if((Ol|0)==q[Nl>>2]){q[ul>>2]=0;break p}Sl=q[Cl>>2];q[Il>>2]=Ol;Gl=vl-Gl|0;q[Ye+560>>2]=Gl;q[ul>>2]=q[Cl+4>>2]>>>32-Gl|Sl<>>32-vl}vl=q[Al>>2]<<2;ul=vl+yl|0;q[ul>>2]=q[ul>>2]|q[vl+Ql>>2];tl=tl+1|0;if(tl>>>0>2]){continue}break}}Al=0;tl=q[ci+16>>2];q:{if((tl|0)==q[Hl>>2]){break q}while(1){tl=w(Al,20)+tl|0;vl=q[Ml>>2]+(q[tl+4>>2]<<2)|0;zl=q[tl>>2];yl=q[tl+12>>2];r:{if(yl>>>0>3){break r}ul=q[ci+12>>2];Cl=tl+16|0;if(!q[Cl>>2]){vl=ul;break r}Fl=tl+12|0;tl=0;while(1){ul=Cn(ul,(tl<<2)+vl|0,yl);yl=q[Fl>>2];ul=ul+yl|0;tl=tl+1|0;if(tl>>>0>2]){continue}break}vl=q[ci+12>>2]}tl=q[ci+28>>2];tl=r[zl+84|0]?tl:q[q[zl+68>>2]+(tl<<2)>>2];if(tl>>>0>=t[zl+80>>2]){break q}ul=tl;tl=q[zl+40>>2];Cn(q[q[zl>>2]>>2]+w(ul,tl)|0,vl,tl);Al=Al+1|0;tl=q[ci+16>>2];if(Al>>>0<(q[Hl>>2]-tl|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;El=El+1|0;if((El|0)==(xl|0)){break f}tl=q[Ye+12>>2];continue}}tl=q[wl+28>>2]}if(tl){continue}break}ul=1}se(wl+8|0);tl=q[wl+12>>2];Ye=q[wl+16>>2];s:{if((tl|0)==(Ye|0)){break s}while(1){An(q[tl>>2]);tl=tl+4|0;if((Ye|0)!=(tl|0)){continue}break}Ye=q[wl+16>>2];Zh=q[wl+12>>2];if((Ye|0)==(Zh|0)){break s}q[wl+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[wl+8>>2];if(Ye){An(Ye)}T=wl+32|0;return ul}bn();F()}bn();F()}function ge(Ye,Zh){Ye=Ye|0;Zh=Zh|0;var ci=0,Tl=0,Ul=0,Vl=0,Wl=0,Xl=0,Zl=0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[q[(n[q[q[Ye>>2]+28>>2]](Ye)|0)+4>>2]+8>>2]+(Tl<<2)>>2];td(Tl,Vl);o[Tl+84|0]=1;q[Tl+72>>2]=q[Tl+68>>2];ci=ci+1|0;if((am|0)!=(ci|0)){continue}break}}Wl=1;Ye=Ld(Ul+672|0,Ul+704|0);k:{if(Zl>>>0>6){break k}l:{m:{switch(Zl-1|0){default:ci=Od(Ul+16|0,Xl);Zh=Md(ci,Zh,Ye);Nd(ci);if(Zh){break l}break k;case 0:ci=Od(Ul+16|0,Xl);Zh=Pd(ci,Zh,Ye);Nd(ci);if(Zh){break l}break k;case 1:ci=Sd(Ul+16|0,Xl);Zh=Qd(ci,Zh,Ye);Rd(ci);if(Zh){break l}break k;case 2:ci=Sd(Ul+16|0,Xl);Zh=Td(ci,Zh,Ye);Rd(ci);if(Zh){break l}break k;case 3:ci=Wd(Ul+16|0,Xl);Zh=Ud(ci,Zh,Ye);Vd(ci);if(Zh){break l}break k;case 4:ci=Wd(Ul+16|0,Xl);Zh=Xd(ci,Zh,Ye);Vd(ci);if(Zh){break l}break k;case 5:break m}}ci=Wd(Ul+16|0,Xl);Zh=Yd(ci,Zh,Ye);Vd(ci);if(!Zh){break k}}Wl=0}Zh=q[Ye+16>>2];if(Zh){q[Ye+20>>2]=Zh;An(Zh)}Zh=q[Ye>>2];if(Zh){q[Ye+4>>2]=Zh;An(Zh)}if(Wl){break h}}gm=1}Ye=q[Ul+704>>2];if(!Ye){break a}q[Ul+708>>2]=Ye;An(Ye);break a}bn();F()}bn();F()}Ye=q[Ul+672>>2];if(!Ye){break a}q[Ul+676>>2]=Ye;An(Ye)}T=Ul+720|0;return gm|0}function he(Ye,Zh,Yl){var km=0,lm=0,mm=0,nm=0;a:{if(Ye>>>0>5){break a}mm=q[Yl+16>>2];km=q[Yl+12>>2];lm=q[Yl+20>>2];if((km|0)<(lm|0)?1:(km|0)<=(lm|0)?t[Yl+8>>2]>mm>>>0?0:1:0){break a}km=r[mm+q[Yl>>2]|0];mm=mm+1|0;if(mm>>>0<1){lm=lm+1|0}q[Yl+16>>2]=mm;q[Yl+20>>2]=lm;lm=Zh;if(km&128){if(!he(Ye+1|0,Zh,Yl)){break a}Ye=q[Zh>>2]<<7;q[Zh>>2]=Ye;km=Ye|km&127}q[lm>>2]=km;nm=1}return nm}function ie(Ye,Zh){var Yl=0,om=0,pm=0,qm=0,rm=0,sm=0,tm=0;a:{b:{c:{om=q[Ye>>2];rm=(q[Ye+4>>2]-om|0)/24|0;Yl=rm+1|0;if(Yl>>>0<178956971){om=(q[Ye+8>>2]-om|0)/24|0;sm=om<<1;om=om>>>0<89478485?sm>>>0>>0?Yl:sm:178956970;pm=0;d:{if(!om){break d}if(om>>>0>=178956971){break c}pm=Mm(w(om,24))}Yl=pm+w(rm,24)|0;ve(Yl,Zh);rm=pm+w(om,24)|0;sm=Yl+24|0;Zh=q[Ye+4>>2];pm=q[Ye>>2];if((Zh|0)==(pm|0)){break b}while(1){Yl=Yl+ -24|0;q[Yl>>2]=1232;om=q[Zh+ -20>>2];qm=Yl+16|0;q[qm>>2]=0;q[Yl+8>>2]=0;q[Yl+12>>2]=0;q[Yl+4>>2]=om;om=Zh+ -16|0;q[Yl+8>>2]=q[om>>2];q[Yl+12>>2]=q[Zh+ -12>>2];tm=qm;qm=Zh+ -8|0;q[tm>>2]=q[qm>>2];q[qm>>2]=0;q[om>>2]=0;q[om+4>>2]=0;q[Yl+20>>2]=q[Zh+ -4>>2];Zh=Zh+ -24|0;if((pm|0)!=(Zh|0)){continue}break}pm=q[Ye+4>>2];Zh=q[Ye>>2];break a}bn();F()}ab(1780);F()}Zh=pm}q[Ye>>2]=Yl;q[Ye+8>>2]=rm;q[Ye+4>>2]=sm;if((Zh|0)!=(pm|0)){while(1){pm=pm+ -24|0;n[q[q[pm>>2]>>2]](pm)|0;if((Zh|0)!=(pm|0)){continue}break}}if(Zh){An(Zh)}}function je(Ye,Zh,um){var vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=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om+8>>2]=Pm;Dn(um,0,Zh);q[Om+4>>2]=Pm}Zh=q[Sm>>2]+ -1|0;h:{i:{if(Zh>>>0>4){break i}j:{switch(Zh-1|0){case 3:Zh=1;if(me(Ye,Qm,Wm)){break i}break h;case 1:Zh=1;if(ne(Ye,Qm,Wm)){break i}break h;case 0:case 2:break i;default:break j}}Zh=1;if(!oe(Ye,Qm,Wm)){break h}}Wm=o[Fm|0]+Wm|0;Zh=0}Fm=q[Om>>2];if(Fm){q[Om+4>>2]=Fm;An(Fm)}Fm=q[Om+16>>2];if(Fm){q[Om+20>>2]=Fm;An(Fm)}if(!Zh){break f}break d;case 0:case 2:case 4:case 5:case 6:break f;case 7:break g}}Sm=q[q[Zm>>2]+(Rm<<2)>>2];Vm=q[_m>>2];Zh=n[q[q[Ye>>2]+28>>2]](Ye)|0;Pm=q[Qm+56>>2];Tm=q[Zh+40>>2];Zh=Mm(32);q[Om+16>>2]=Zh;q[Om+20>>2]=24;q[Om+24>>2]=-2147483616;o[Zh+24|0]=0;Fm=r[1726]|r[1727]<<8|(r[1728]<<16|r[1729]<<24);um=r[1722]|r[1723]<<8|(r[1724]<<16|r[1725]<<24);o[Zh+16|0]=um;o[Zh+17|0]=um>>>8;o[Zh+18|0]=um>>>16;o[Zh+19|0]=um>>>24;o[Zh+20|0]=Fm;o[Zh+21|0]=Fm>>>8;o[Zh+22|0]=Fm>>>16;o[Zh+23|0]=Fm>>>24;Fm=r[1718]|r[1719]<<8|(r[1720]<<16|r[1721]<<24);um=r[1714]|r[1715]<<8|(r[1716]<<16|r[1717]<<24);o[Zh+8|0]=um;o[Zh+9|0]=um>>>8;o[Zh+10|0]=um>>>16;o[Zh+11|0]=um>>>24;o[Zh+12|0]=Fm;o[Zh+13|0]=Fm>>>8;o[Zh+14|0]=Fm>>>16;o[Zh+15|0]=Fm>>>24;Fm=r[1710]|r[1711]<<8|(r[1712]<<16|r[1713]<<24);um=r[1706]|r[1707]<<8|(r[1708]<<16|r[1709]<<24);o[Zh|0]=um;o[Zh+1|0]=um>>>8;o[Zh+2|0]=um>>>16;o[Zh+3|0]=um>>>24;o[Zh+4|0]=Fm;o[Zh+5|0]=Fm>>>8;o[Zh+6|0]=Fm>>>16;o[Zh+7|0]=Fm>>>24;k:{l:{Fm=Tm+16|0;um=Fm;Zh=q[um>>2];if(!Zh){break l}while(1){Um=q[Zh+16>>2]<(Pm|0);um=Um?um:Zh;Zh=q[(Um<<2)+Zh>>2];if(Zh){continue}break}if((um|0)==(Fm|0)|(Pm|0)>2]){break l}Zh=um+20|0;if(!ga(Zh,Om+16|0)){break l}Zh=gk(Zh,Om+16|0);break k}Zh=gk(Tm,Om+16|0)}if(o[Om+27|0]<=-1){An(q[Om+16>>2])}Fm=Rm+1|0;m:{if(Zh){ud(Qm,Sm);break m}Zh=Vm+w(Rm,24)|0;um=q[Zh+4>>2];Rm=o[Qm+24|0];Vm=Rm<<2;Pm=Mm((Rm|0)!=(Rm&1073741823)?-1:Vm);if(!ik(hk(Om+16|0),u[Zh+20>>2],-1<>2]){$m=q[q[Sm>>2]>>2]+q[Sm+48>>2]|0;an=Zh+8|0;Um=0;Tm=0;um=0;while(1){if((Rm|0)>=1){cn=q[an>>2];Zh=0;dn=u[Om+16>>2];while(1){Ym=Zh<<2;u[Ym+Pm>>2]=x(dn*x(q[$m+(um<<2)>>2]))+u[cn+Ym>>2];um=um+1|0;Zh=Zh+1|0;if((Rm|0)!=(Zh|0)){continue}break}}Cn(q[q[Qm- -64>>2]>>2]+Tm|0,Pm,Vm);Tm=Tm+Vm|0;Um=Um+1|0;if(Um>>>0>2]){continue}break}}An(Pm)}Rm=Fm}Zh=1;Xm=Xm+1|0;if((Xm|0)<(n[q[q[Ye>>2]+24>>2]](Ye)|0)){continue}break c}break}An(Pm)}Zh=0}T=Om+32|0;return Zh|0}bn();F()}bn();F()}function me(Ye,en,fn){var gn=0,hn=0,jn=0,kn=0,ln=0,mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0;hn=T-16|0;T=hn;gn=o[en+24|0];q[hn+8>>2]=0;q[hn>>2]=0;q[hn+4>>2]=0;a:{b:{if(gn){if((gn|0)<=-1){break b}jn=gn<<2;kn=Mm(jn);q[hn>>2]=kn;ln=jn+kn|0;q[hn+8>>2]=ln;Dn(kn,0,jn);q[hn+4>>2]=ln;pn=Mm(jn);jn=Dn(pn,0,jn)}else{jn=0}if(!q[en+80>>2]){break a}sn=en+40|0;un=en+48|0;vn=Ye+48|0;while(1){tn=q[en>>2];mn=q[tn>>2];qn=q[un>>2];Ye=q[sn>>2];ln=$n(Ye,q[sn+4>>2],rn,nn);on=mn;mn=ln+qn|0;ln=Cn(kn,on+mn|0,Ye);if(gn<<24>>24>=1){mn=gn&255;qn=q[vn>>2];gn=0;while(1){on=gn<<2;q[on+jn>>2]=q[(fn+gn<<2)+qn>>2]+q[ln+on>>2];gn=gn+1|0;if(gn>>>0>>0){continue}break}}Cn(q[tn>>2]+w(Ye,rn)|0,pn,Ye);Ye=rn+1|0;if(Ye>>>0<1){nn=nn+1|0}rn=Ye;if(!nn&Ye>>>0>=t[en+80>>2]|nn>>>0>0){break a}gn=r[en+24|0];continue}}bn();F()}if(jn){An(pn)}if(kn){q[hn+4>>2]=kn;An(kn)}T=hn+16|0;return 1}function ne(Ye,en,fn){var wn=0,xn=0,yn=0,zn=0,Bn=0,En=0,Fn=0,Gn=0,Hn=0,In=0,Jn=0,Kn=0,Ln=0,Mn=0,Nn=0;xn=T-16|0;T=xn;wn=o[en+24|0];q[xn+8>>2]=0;q[xn>>2]=0;q[xn+4>>2]=0;a:{b:{if(wn){if((wn|0)<=-1){break b}yn=wn<<1;zn=Mm(yn);q[xn>>2]=zn;Bn=yn+zn|0;q[xn+8>>2]=Bn;Dn(zn,0,yn);q[xn+4>>2]=Bn;Hn=Mm(yn);yn=Dn(Hn,0,yn)}else{yn=0}if(!q[en+80>>2]){break a}Kn=en+40|0;Mn=en+48|0;Nn=Ye+48|0;while(1){Ln=q[en>>2];En=q[Ln>>2];In=q[Mn>>2];Ye=q[Kn>>2];Bn=$n(Ye,q[Kn+4>>2],Jn,Fn);Gn=En;En=Bn+In|0;Bn=Cn(zn,Gn+En|0,Ye);if(wn<<24>>24>=1){En=wn&255;In=q[Nn>>2];wn=0;while(1){Gn=wn<<1;p[Gn+yn>>1]=s[Bn+Gn>>1]+s[(fn+wn<<2)+In>>1];wn=wn+1|0;if(wn>>>0>>0){continue}break}}Cn(q[Ln>>2]+w(Ye,Jn)|0,Hn,Ye);Ye=Jn+1|0;if(Ye>>>0<1){Fn=Fn+1|0}Jn=Ye;if(!Fn&Ye>>>0>=t[en+80>>2]|Fn>>>0>0){break a}wn=r[en+24|0];continue}}bn();F()}if(yn){An(Hn)}if(zn){q[xn+4>>2]=zn;An(zn)}T=xn+16|0;return 1}function oe(Ye,en,fn){var Dn=0,On=0,Pn=0,Qn=0,Rn=0,Sn=0,Tn=0,Un=0,Vn=0,Wn=0;On=T-32|0;T=On;Dn=o[en+24|0];q[On+24>>2]=0;q[On+16>>2]=0;q[On+20>>2]=0;a:{b:{c:{if(Dn){if((Dn|0)<=-1){break c}Pn=Mm(Dn);q[On+16>>2]=Pn;q[On+20>>2]=Pn;q[On+24>>2]=Dn+Pn;while(1){o[Pn|0]=0;Pn=q[On+20>>2]+1|0;q[On+20>>2]=Pn;Dn=Dn+ -1|0;if(Dn){continue}break}Pn=r[en+24|0]}q[On+8>>2]=0;q[On>>2]=0;q[On+4>>2]=0;if(Pn&255){if(Pn<<24>>24<=-1){break b}Pn=Pn<<24>>24;Dn=Mm(Pn);q[On>>2]=Dn;q[On+4>>2]=Dn;q[On+8>>2]=Dn+Pn;while(1){o[Dn|0]=0;Dn=q[On+4>>2]+1|0;q[On+4>>2]=Dn;Pn=Pn+ -1|0;if(Pn){continue}break}}if(!q[en+80>>2]){Dn=q[On>>2];break a}Pn=en+40|0;Un=en+48|0;Tn=en+24|0;while(1){Vn=q[On+16>>2];Wn=q[q[en>>2]>>2];Dn=q[Pn>>2];Qn=q[Un>>2]+$n(Dn,q[Pn+4>>2],Rn,Sn)|0;Dn=Cn(Vn,Wn+Qn|0,Dn);d:{if(o[Tn|0]<1){break d}Qn=Ye+48|0;o[q[On>>2]]=r[Dn|0]+r[q[Qn>>2]+(fn<<2)|0];Dn=1;if(o[Tn|0]<2){break d}while(1){o[q[On>>2]+Dn|0]=r[q[On+16>>2]+Dn|0]+r[q[Qn>>2]+(fn+Dn<<2)|0];Dn=Dn+1|0;if((Dn|0)>2];Dn=q[On>>2];Cn(q[q[en>>2]>>2]+w(Qn,Rn)|0,Dn,Qn);Rn=Rn+1|0;if(Rn>>>0<1){Sn=Sn+1|0}Qn=Rn;if(!Sn&Qn>>>0>2]|Sn>>>0<0){continue}break}break a}bn();F()}bn();F()}if(Dn){q[On+4>>2]=Dn;An(Dn)}Ye=q[On+16>>2];if(Ye){q[On+20>>2]=Ye;An(Ye)}T=On+32|0;return 1}function pe(Ye){Ye=Ye|0;var bn=0,en=0,fn=0,Cn=0;q[Ye>>2]=1596;bn=q[Ye+60>>2];if(bn){Cn=Ye- -64|0;en=q[Cn>>2];fn=bn;a:{if((bn|0)==(en|0)){break a}while(1){en=en+ -4|0;fn=q[en>>2];q[en>>2]=0;if(fn){Hb(fn)}if((bn|0)!=(en|0)){continue}break}fn=q[Ye+60>>2]}q[Cn>>2]=bn;An(fn)}bn=q[Ye+48>>2];if(bn){q[Ye+52>>2]=bn;An(bn)}bn=q[Ye+36>>2];if(bn){Cn=Ye+40|0;en=q[Cn>>2];fn=bn;b:{if((bn|0)==(en|0)){break b}while(1){en=en+ -24|0;n[q[q[en>>2]>>2]](en)|0;if((bn|0)!=(en|0)){continue}break}fn=q[Ye+36>>2]}q[Cn>>2]=bn;An(fn)}q[Ye>>2]=1384;bn=q[Ye+16>>2];if(bn){q[Ye+20>>2]=bn;An(bn)}bn=q[Ye+4>>2];if(bn){q[Ye+8>>2]=bn;An(bn)}return Ye|0}function qe(q){q=q|0;An(pe(q))}function re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]=q[ao+16>>2];q[ao+16>>2]=Xn;Ye=Ye+12|0;_n=q[Ye>>2];q[Ye>>2]=q[ao+20>>2];q[ao+20>>2]=_n;if((Xn|0)!=(Yn|0)){q[ao+16>>2]=Xn+(((Xn-$n|0)+ -4>>>2^-1)<<2)}if(!Zn){break a}An(Zn);break a}else{Yn=Yn+ -4|0;ue(ao+8|0,Yn);continue}}}ab(1780);F()}ab(1780);F()}ab(1780);F()}T=ao+32|0}function se(Ye){var io=0,jo=0,ko=0,lo=0,mo=0,no=0,oo=0;jo=q[Ye+16>>2];io=(jo>>>0)/341|0;ko=q[Ye+4>>2];no=q[Ye+8>>2];a:{if((ko|0)==(no|0)){mo=Ye+20|0;break a}lo=(io<<2)+ko|0;io=q[lo>>2]+w(jo-w(io,341)|0,12)|0;mo=Ye+20|0;jo=jo+q[mo>>2]|0;oo=(jo>>>0)/341|0;jo=q[(oo<<2)+ko>>2]+w(jo-w(oo,341)|0,12)|0;if((io|0)==(jo|0)){break a}while(1){io=io+12|0;if((io-q[lo>>2]|0)==4092){io=q[lo+4>>2];lo=lo+4|0}if((io|0)!=(jo|0)){continue}break}}q[mo>>2]=0;io=no-ko>>2;if(io>>>0>2){while(1){An(q[ko>>2]);ko=q[Ye+4>>2]+4|0;q[Ye+4>>2]=ko;io=q[Ye+8>>2]-ko>>2;if(io>>>0>2){continue}break}}io=io+ -1|0;if(io>>>0<=1){q[Ye+16>>2]=io-1|0?170:341}}function te(Ye,po){var qo=0,ro=0,so=0,to=0,uo=0,vo=0,wo=0;a:{so=q[Ye+8>>2];qo=q[Ye+12>>2];b:{if((so|0)!=(qo|0)){qo=so;break b}ro=q[Ye+4>>2];to=q[Ye>>2];if(ro>>>0>to>>>0){so=so-ro|0;vo=so>>2;to=((ro-to>>2)+1|0)/-2<<2;uo=to+ro|0;qo=Ye;if(so){En(uo,ro,so);ro=q[Ye+4>>2]}q[qo+4>>2]=ro+to;qo=uo+(vo<<2)|0;q[Ye+8>>2]=qo;break b}qo=qo-to|0;qo=qo?qo>>1:1;if(qo>>>0>=1073741824){break a}uo=qo<<2;vo=Mm(uo);wo=uo+vo|0;uo=vo+(qo&-4)|0;qo=uo;if((ro|0)!=(so|0)){qo=uo;while(1){q[qo>>2]=q[ro>>2];qo=qo+4|0;ro=ro+4|0;if((so|0)!=(ro|0)){continue}break}to=q[Ye>>2]}q[Ye+8>>2]=qo;q[Ye+4>>2]=uo;q[Ye>>2]=vo;q[Ye+12>>2]=wo;if(!to){break b}An(to);qo=q[Ye+8>>2]}q[qo>>2]=q[po>>2];q[Ye+8>>2]=q[Ye+8>>2]+4;return}ab(1780);F()}function ue(Ye,po){var xo=0,yo=0,zo=0,Ao=0,Bo=0,Co=0;a:{zo=q[Ye+4>>2];yo=q[Ye>>2];b:{if((zo|0)!=(yo|0)){xo=zo;break b}Ao=q[Ye+8>>2];xo=q[Ye+12>>2];if(Ao>>>0>>0){Bo=((xo-Ao>>2)+1|0)/2<<2;xo=Bo+Ao|0;yo=Ao-zo|0;if(yo){xo=xo-yo|0;En(xo,zo,yo);Ao=q[Ye+8>>2]}q[Ye+4>>2]=xo;q[Ye+8>>2]=Ao+Bo;break b}xo=xo-yo|0;xo=xo?xo>>1:1;if(xo>>>0>=1073741824){break a}yo=xo<<2;Bo=Mm(yo);Co=yo+Bo|0;xo=Bo+(xo+3&-4)|0;c:{if((zo|0)==(Ao|0)){yo=xo;break c}yo=xo;while(1){q[yo>>2]=q[zo>>2];yo=yo+4|0;zo=zo+4|0;if((Ao|0)!=(zo|0)){continue}break}zo=q[Ye>>2]}q[Ye+8>>2]=yo;q[Ye+4>>2]=xo;q[Ye>>2]=Bo;q[Ye+12>>2]=Co;if(!zo){break b}An(zo);xo=q[Ye+4>>2]}q[xo+ -4>>2]=q[po>>2];q[Ye+4>>2]=q[Ye+4>>2]+ -4;return}ab(1780);F()}function ve(Ye,An){var po=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0;q[Ye>>2]=1232;po=q[An+4>>2];q[Ye+16>>2]=0;q[Ye+8>>2]=0;q[Ye+12>>2]=0;q[Ye+4>>2]=po;a:{po=q[An+12>>2]-q[An+8>>2]|0;b:{if(!po){break b}Do=po>>2;if(Do>>>0>=1073741824){break a}po=Mm(po);q[Ye+8>>2]=po;Eo=Ye+12|0;q[Eo>>2]=po;q[Ye+16>>2]=po+(Do<<2);Fo=q[An+8>>2];Do=q[An+12>>2]-Fo|0;if((Do|0)<1){break b}Go=Eo,Ho=Cn(po,Fo,Do)+Do|0,q[Go>>2]=Ho}q[Ye+20>>2]=q[An+20>>2];return}bn();F()}function we(Ye){q[Ye+12>>2]=-1;q[Ye+16>>2]=0;q[Ye+4>>2]=0;q[Ye+8>>2]=0;q[Ye>>2]=1908}function xe(Ye,An,Io){Ye=Ye|0;An=An|0;Io=Io|0;q[Ye+4>>2]=An;An=q[q[q[An+4>>2]+8>>2]+(Io<<2)>>2];q[Ye+12>>2]=Io;q[Ye+8>>2]=An;return 1}function ye(Ye,An){Ye=Ye|0;An=An|0;q[Ye+12>>2]=-1;q[Ye+8>>2]=An;return 1}function ze(Ye,An,Io){Ye=Ye|0;An=An|0;Io=Io|0;var Jo=0,Ko=0;Jo=q[Ye+8>>2];a:{if(o[Jo+24|0]<1){break a}if(!td(Jo,q[An+4>>2]-q[An>>2]>>2)){break a}Ko=n[q[q[Ye>>2]+32>>2]](Ye,An,Io)|0}return Ko|0}function Ae(q,Ye,An){q=q|0;Ye=Ye|0;An=An|0;return 1}function Be(Ye){var An=0,Io=0,Lo=0,Mo=0,No=0,Oo=0,Po=0,Qo=0;a:{Lo=q[Ye+8>>2];if(r[Lo+84|0]){break a}An=q[Ye+16>>2];if(!An|!r[An+84|0]){break a}Io=q[Lo+72>>2];Mo=q[Lo+68>>2];o[An+84|0]=0;Io=Io-Mo>>2;No=q[An+68>>2];Mo=q[An+72>>2]-No>>2;b:{if(Io>>>0>Mo>>>0){md(An+68|0,Io-Mo|0,1992);Lo=q[Ye+8>>2];break b}if(Io>>>0>=Mo>>>0){break b}q[An+72>>2]=No+(Io<<2)}An=0;Mo=r[Lo+84|0];Oo=Lo+72|0;Po=Ye+16|0;Qo=Lo+68|0;while(1){if(An>>>0>=(Mo?0:q[Oo>>2]-q[Lo+68>>2]>>2)>>>0){break a}Io=An;No=q[q[Po>>2]+68>>2]+(An<<2)|0;if(!Mo){Io=q[q[Qo>>2]+(An<<2)>>2]}q[No>>2]=Io;An=An+1|0;continue}}return q[Ye+16>>2]}function Ce(Ye,Ro){Ye=Ye|0;Ro=Ro|0;var So=0,To=0,Uo=0;if((n[q[q[Ro>>2]+20>>2]](Ro)|0)>=1){while(1){So=bl(q[q[Ye+4>>2]+4>>2],n[q[q[Ro>>2]+24>>2]](Ro,To)|0);if((So|0)==-1){return 0}a:{Uo=q[Ye+4>>2];if(r[Uo+36|0]<=1){if(n[q[q[Ro>>2]+28>>2]](Ro,q[q[q[Uo+4>>2]+8>>2]+(So<<2)>>2])){break a}return 0}So=Pj(Uo,So);if(!So){return 0}if(n[q[q[Ro>>2]+28>>2]](Ro,So)){break a}return 0}To=To+1|0;if((To|0)<(n[q[q[Ro>>2]+20>>2]](Ro)|0)){continue}break}}return 1}function De(Ye,Ro,Vo){Ye=Ye|0;Ro=Ro|0;Vo=Vo|0;var Wo=0,Xo=0,Yo=0,Zo=0,_o=0,$o=0,ap=0,bp=0,cp=0,dp=0,ep=0;Wo=q[Ro+4>>2];Xo=q[Ro>>2];Ro=q[q[Ye+8>>2]+40>>2];Yo=Ro;Zo=Mm((Ro|0)>-1?Ro:-1);Wo=Wo-Xo|0;if((Wo|0)>=1){dp=Wo>>2;while(1){$o=q[Vo+12>>2];Wo=ep+q[Vo+20>>2]|0;ap=q[Vo+16>>2];_o=Ro+ap|0;if(_o>>>0>>0){Wo=Wo+1|0}Xo=Wo;if(($o|0)<(Wo|0)?1:($o|0)<=(Wo|0)?t[Vo+8>>2]>=_o>>>0?0:1:0){An(Zo);return 0}Wo=Cn(Zo,ap+q[Vo>>2]|0,Yo);q[Vo+16>>2]=_o;q[Vo+20>>2]=Xo;Cn(q[q[q[Ye+8>>2]- -64>>2]>>2]+bp|0,Wo,Yo);bp=Yo+bp|0;cp=cp+1|0;if((cp|0)<(dp|0)){continue}break}}An(Zo);return 1}function Ee(Ye){Ye=Ye|0;var Ro=0;q[Ye>>2]=1908;Ro=q[Ye+16>>2];q[Ye+16>>2]=0;if(Ro){Hb(Ro)}return Ye|0}function Fe(Ye){Ye=Ye|0;var Vo=0;q[Ye>>2]=1908;Vo=q[Ye+16>>2];q[Ye+16>>2]=0;if(Vo){Hb(Vo)}An(Ye)}function Ge(Ye,fp){var gp=0;wd(Ye);q[Ye+36>>2]=0;q[Ye+40>>2]=0;q[Ye>>2]=2004;q[Ye+44>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+56>>2]=0;gp=q[fp>>2];q[fp>>2]=0;q[Ye+60>>2]=gp}function He(Ye,fp){Ye=Ye|0;fp=fp|0;var hp=0,ip=0,jp=0,kp=0,lp=0,mp=0,np=0,op=0,pp=0,qp=0,rp=0,sp=0,tp=0;lp=T-16|0;T=lp;a:{if(!yd(Ye,fp)){break a}pp=Ye+36|0;mp=n[q[q[Ye>>2]+24>>2]](Ye)|0;jp=q[Ye+40>>2];ip=q[Ye+36>>2];hp=jp-ip>>2;b:{if(mp>>>0>hp>>>0){Ie(pp,mp-hp|0);break b}if(mp>>>0>=hp>>>0){break b}ip=ip+(mp<<2)|0;if((ip|0)!=(jp|0)){while(1){jp=jp+ -4|0;hp=q[jp>>2];q[jp>>2]=0;if(hp){n[q[q[hp>>2]+4>>2]](hp)}if((jp|0)!=(ip|0)){continue}break}}q[Ye+40>>2]=ip}op=1;if((mp|0)<1){break a}op=0;jp=0;while(1){kp=q[fp+16>>2];ip=q[fp+12>>2];hp=q[fp+20>>2];if((ip|0)<(hp|0)?1:(ip|0)<=(hp|0)?t[fp+8>>2]>kp>>>0?0:1:0){break a}np=r[kp+q[fp>>2]|0];kp=kp+1|0;if(kp>>>0<1){hp=hp+1|0}ip=fp;q[ip+16>>2]=kp;q[ip+20>>2]=hp;n[q[q[Ye>>2]+48>>2]](lp+8|0,Ye,np);hp=q[Ye+36>>2];ip=q[lp+8>>2];q[lp+8>>2]=0;kp=jp<<2;np=hp+kp|0;hp=q[np>>2];q[np>>2]=ip;if(hp){n[q[q[hp>>2]+4>>2]](hp)}hp=q[lp+8>>2];q[lp+8>>2]=0;if(hp){n[q[q[hp>>2]+4>>2]](hp)}hp=q[q[pp>>2]+kp>>2];if(!hp){break a}if(!(rp=hp,sp=n[q[q[Ye>>2]+28>>2]](Ye)|0,tp=n[q[q[Ye>>2]+20>>2]](Ye,jp)|0,qp=q[q[hp>>2]+8>>2],n[qp](rp|0,sp|0,tp|0)|0)){break a}jp=jp+1|0;if((mp|0)!=(jp|0)){continue}break}op=1}T=lp+16|0;return op|0}function Ie(Ye,fp){var up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0,Cp=0;vp=q[Ye+8>>2];wp=Ye+4|0;up=q[wp>>2];if(vp-up>>2>>>0>=fp>>>0){Ye=fp<<2;Bp=wp,Cp=Dn(up,0,Ye)+Ye|0,q[Bp>>2]=Cp;return}a:{wp=q[Ye>>2];xp=up-wp>>2;yp=xp+fp|0;if(yp>>>0<1073741824){xp=xp<<2;vp=vp-wp|0;Ap=vp>>1;vp=vp>>2>>>0<536870911?Ap>>>0>>0?yp:Ap:1073741823;if(vp){if(vp>>>0>=1073741824){break a}zp=Mm(vp<<2)}xp=xp+zp|0;Dn(xp,0,fp<<2);fp=(yp<<2)+zp|0;yp=(vp<<2)+zp|0;if((up|0)!=(wp|0)){while(1){up=up+ -4|0;vp=q[up>>2];q[up>>2]=0;xp=xp+ -4|0;q[xp>>2]=vp;if((up|0)!=(wp|0)){continue}break}wp=q[Ye>>2];up=q[Ye+4>>2]}q[Ye>>2]=xp;q[Ye+8>>2]=yp;q[Ye+4>>2]=fp;if((up|0)!=(wp|0)){while(1){up=up+ -4|0;Ye=q[up>>2];q[up>>2]=0;if(Ye){n[q[q[Ye>>2]+4>>2]](Ye)}if((up|0)!=(wp|0)){continue}break}}if(wp){An(wp)}return}bn();F()}ab(2144);F()}function Je(Ye,fp){Ye=Ye|0;fp=fp|0;var Dp=0,Ep=0,Fp=0,Gp=0,Hp=0,Ip=0,Jp=0;Dp=q[Ye+60>>2];a:{if(!Dp){break a}q[Dp+4>>2]=Ye+48;if(!n[q[q[Dp>>2]+12>>2]](Dp)){break a}b:{Ep=n[q[q[Ye>>2]+24>>2]](Ye)|0;if((Ep|0)<1){break b}Gp=Ye+60|0;Dp=0;while(1){c:{Hp=q[(n[q[q[Ye>>2]+28>>2]](Ye)|0)+4>>2];Ip=n[q[q[Ye>>2]+20>>2]](Ye,Dp)|0;Fp=q[Gp>>2];if(!n[q[q[Fp>>2]+8>>2]](Fp,q[q[Hp+8>>2]+(Ip<<2)>>2])){break c}Dp=Dp+1|0;if((Ep|0)!=(Dp|0)){continue}break b}break}return 0}if(!n[q[q[Ye>>2]+36>>2]](Ye,fp)){break a}if(!n[q[q[Ye>>2]+40>>2]](Ye,fp)){break a}Jp=n[q[q[Ye>>2]+44>>2]](Ye)|0}return Jp|0}function Ke(Ye,fp){Ye=Ye|0;fp=fp|0;var Kp=0,Lp=0,Mp=0,Np=0,Op=0;Kp=1;Lp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Lp|0)<1){break a}Np=Ye+48|0;Kp=0;Op=Ye+36|0;Ye=0;while(1){Mp=q[q[Op>>2]+(Ye<<2)>>2];if(!n[q[q[Mp>>2]+16>>2]](Mp,Np,fp)){break a}Ye=Ye+1|0;if((Lp|0)!=(Ye|0)){continue}break}Kp=1}return Kp|0}function Le(Ye,fp){Ye=Ye|0;fp=fp|0;var Pp=0,Qp=0,Rp=0,Sp=0,Tp=0;Pp=1;Qp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Qp|0)<1){break a}Sp=Ye+48|0;Pp=0;Tp=Ye+36|0;Ye=0;while(1){Rp=q[q[Tp>>2]+(Ye<<2)>>2];if(!n[q[q[Rp>>2]+20>>2]](Rp,Sp,fp)){break a}Ye=Ye+1|0;if((Qp|0)!=(Ye|0)){continue}break}Pp=1}return Pp|0}function Me(Ye){Ye=Ye|0;var fp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0;Wp=T-16|0;T=Wp;fp=1;Zp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Zp|0)<1){break a}dq=Ye+48|0;Yp=Ye+36|0;while(1){b:{c:{if(!q[(n[q[q[Ye>>2]+28>>2]](Ye)|0)+40>>2]){break c}_p=Xp<<2;fp=q[_p+q[Yp>>2]>>2];Up=q[fp+8>>2];$p=Be(fp);if(!$p){break c}fp=n[q[q[Ye>>2]+28>>2]](Ye)|0;aq=q[Up+56>>2];bq=q[fp+40>>2];fp=Mm(32);q[Wp>>2]=fp;q[Wp+4>>2]=24;q[Wp+8>>2]=-2147483616;o[fp+24|0]=0;Up=r[2076]|r[2077]<<8|(r[2078]<<16|r[2079]<<24);Vp=r[2072]|r[2073]<<8|(r[2074]<<16|r[2075]<<24);o[fp+16|0]=Vp;o[fp+17|0]=Vp>>>8;o[fp+18|0]=Vp>>>16;o[fp+19|0]=Vp>>>24;o[fp+20|0]=Up;o[fp+21|0]=Up>>>8;o[fp+22|0]=Up>>>16;o[fp+23|0]=Up>>>24;Up=r[2068]|r[2069]<<8|(r[2070]<<16|r[2071]<<24);Vp=r[2064]|r[2065]<<8|(r[2066]<<16|r[2067]<<24);o[fp+8|0]=Vp;o[fp+9|0]=Vp>>>8;o[fp+10|0]=Vp>>>16;o[fp+11|0]=Vp>>>24;o[fp+12|0]=Up;o[fp+13|0]=Up>>>8;o[fp+14|0]=Up>>>16;o[fp+15|0]=Up>>>24;Up=r[2060]|r[2061]<<8|(r[2062]<<16|r[2063]<<24);Vp=r[2056]|r[2057]<<8|(r[2058]<<16|r[2059]<<24);o[fp|0]=Vp;o[fp+1|0]=Vp>>>8;o[fp+2|0]=Vp>>>16;o[fp+3|0]=Vp>>>24;o[fp+4|0]=Up;o[fp+5|0]=Up>>>8;o[fp+6|0]=Up>>>16;o[fp+7|0]=Up>>>24;d:{e:{Vp=bq+16|0;Up=Vp;fp=q[Up>>2];if(!fp){break e}while(1){cq=q[fp+16>>2]<(aq|0);Up=cq?Up:fp;fp=q[(cq<<2)+fp>>2];if(fp){continue}break}if((Up|0)==(Vp|0)|(aq|0)>2]){break e}fp=Up+20|0;if(!ga(fp,Wp)){break e}fp=gk(fp,Wp);break d}fp=gk(bq,Wp)}if(o[Wp+11|0]<=-1){An(q[Wp>>2])}if(!fp){break c}ud(q[q[q[Yp>>2]+_p>>2]+8>>2],$p);break b}fp=q[q[Yp>>2]+(Xp<<2)>>2];if(n[q[q[fp>>2]+24>>2]](fp,dq)){break b}fp=0;break a}fp=1;Xp=Xp+1|0;if((Zp|0)!=(Xp|0)){continue}break}}T=Wp+16|0;return fp|0}function Ne(Ye,eq,fq){Ye=Ye|0;eq=eq|0;fq=fq|0;if(fq>>>0>3){q[Ye>>2]=0;return}a:{b:{switch(fq-1|0){default:eq=Mm(20);we(eq);break a;case 0:eq=Mm(24);Re(eq);break a;case 1:eq=Mm(36);Re(eq);q[eq+32>>2]=0;q[eq+24>>2]=-1;q[eq+28>>2]=0;q[eq>>2]=10764;break a;case 2:break b}}eq=Mm(28);Re(eq);q[eq+24>>2]=-1;q[eq>>2]=6744;q[Ye>>2]=eq;return}q[Ye>>2]=eq}function Oe(Ye){Ye=Ye|0;var eq=0,fq=0,gq=0,hq=0,iq=0;q[Ye>>2]=2004;eq=Ye+60|0;fq=q[eq>>2];q[eq>>2]=0;if(fq){n[q[q[fq>>2]+4>>2]](fq)}eq=q[Ye+48>>2];if(eq){q[Ye+52>>2]=eq;An(eq)}fq=q[Ye+36>>2];if(fq){eq=fq;iq=Ye+40|0;gq=q[iq>>2];hq=eq;a:{if((eq|0)==(gq|0)){break a}while(1){gq=gq+ -4|0;eq=q[gq>>2];q[gq>>2]=0;if(eq){n[q[q[eq>>2]+4>>2]](eq)}if((fq|0)!=(gq|0)){continue}break}hq=q[Ye+36>>2]}eq=hq;q[iq>>2]=fq;An(eq)}q[Ye>>2]=1384;eq=q[Ye+16>>2];if(eq){q[Ye+20>>2]=eq;An(eq)}eq=q[Ye+4>>2];if(eq){q[Ye+8>>2]=eq;An(eq)}return Ye|0}function Pe(Ye){Ye=Ye|0;var jq=0,kq=0,lq=0,mq=0,nq=0;q[Ye>>2]=2004;jq=Ye+60|0;kq=q[jq>>2];q[jq>>2]=0;if(kq){n[q[q[kq>>2]+4>>2]](kq)}jq=q[Ye+48>>2];if(jq){q[Ye+52>>2]=jq;An(jq)}kq=q[Ye+36>>2];if(kq){jq=kq;nq=Ye+40|0;lq=q[nq>>2];mq=jq;a:{if((jq|0)==(lq|0)){break a}while(1){lq=lq+ -4|0;jq=q[lq>>2];q[lq>>2]=0;if(jq){n[q[q[jq>>2]+4>>2]](jq)}if((kq|0)!=(lq|0)){continue}break}mq=q[Ye+36>>2]}jq=mq;q[nq>>2]=kq;An(jq)}q[Ye>>2]=1384;jq=q[Ye+16>>2];if(jq){q[Ye+20>>2]=jq;An(jq)}jq=q[Ye+4>>2];if(jq){q[Ye+8>>2]=jq;An(jq)}An(Ye)}function Qe(Ye,oq){Ye=Ye|0;oq=oq|0;var pq=0,qq=0;qq=q[Ye+16>>2];pq=0;a:{if(q[Ye+20>>2]-qq>>2<=(oq|0)){break a}oq=q[(oq<<2)+qq>>2];pq=0;if((oq|0)<0){break a}pq=Be(q[q[Ye+36>>2]+(oq<<2)>>2])}return pq|0}function Re(Ye){we(Ye);q[Ye+20>>2]=0;q[Ye>>2]=2220}function Se(q,Ye,oq){q=q|0;Ye=Ye|0;oq=oq|0;return xe(q,Ye,oq)|0}function Te(Ye,oq){Ye=Ye|0;oq=oq|0;var rq=0,sq=0;sq=q[Ye+4>>2];a:{if(sq){rq=1;if(r[sq+36|0]<2){break a}}rq=n[q[q[Ye>>2]+48>>2]](Ye,q[oq+4>>2]-q[oq>>2]>>2)|0}return rq|0}function Ue(Ye,oq,tq){Ye=Ye|0;oq=oq|0;tq=tq|0;var uq=0,vq=0,wq=0,xq=0,yq=0,zq=0,Aq=0,Bq=0,Cq=0,Dq=0;wq=T-16|0;T=wq;Aq=q[tq+8>>2];xq=q[tq+16>>2];yq=q[tq+12>>2];uq=yq;vq=q[tq+20>>2];a:{if((uq|0)<(vq|0)?1:(uq|0)<=(vq|0)?Aq>>>0>xq>>>0?0:1:0){break a}Bq=q[tq>>2];Cq=o[Bq+xq|0];uq=vq;zq=xq+1|0;if(zq>>>0<1){uq=uq+1|0}q[tq+16>>2]=zq;q[tq+20>>2]=uq;b:{if((Cq|0)==-2){break b}if((yq|0)<(uq|0)?1:(yq|0)<=(uq|0)?Aq>>>0>zq>>>0?0:1:0){break a}yq=o[zq+Bq|0];xq=xq+2|0;if(xq>>>0<2){vq=vq+1|0}uq=tq;q[uq+16>>2]=xq;q[uq+20>>2]=vq;n[q[q[Ye>>2]+40>>2]](wq+8|0,Ye,Cq,yq);vq=q[wq+8>>2];q[wq+8>>2]=0;uq=q[Ye+20>>2];q[Ye+20>>2]=vq;if(!uq){q[wq+8>>2]=0;break b}n[q[q[uq>>2]+4>>2]](uq);uq=q[wq+8>>2];q[wq+8>>2]=0;if(!uq){break b}n[q[q[uq>>2]+4>>2]](uq)}uq=q[Ye+20>>2];if(uq){if(!n[q[q[Ye>>2]+28>>2]](Ye,uq)){break a}}if(!n[q[q[Ye>>2]+36>>2]](Ye,oq,tq)){break a}tq=q[Ye+4>>2];if(!(!tq|r[tq+36|0]>1)){if(!n[q[q[Ye>>2]+48>>2]](Ye,q[oq+4>>2]-q[oq>>2]>>2)){break a}}Dq=1}T=wq+16|0;return Dq|0}function Ve(Ye,oq,tq,Eq){Ye=Ye|0;oq=oq|0;tq=tq|0;Eq=Eq|0;var Fq=0,Gq=0;Fq=T-48|0;T=Fq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0,cr=0,dr=0,er=0;Zq=q[Ye+8>>2];tq=q[Zq+28>>2]+ -1|0;if(tq>>>0>5){return 0}a:{b:{switch(tq-1|0){case 0:$q=o[Zq+24|0];ar=Mm(($q|0)>-1?$q:-1);tq=q[Ye+16>>2];Zq=0;c:{if(!q[tq+80>>2]){break c}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=($q|0)<1;dr=Ye+8|0;tq=0;while(1){Ye=0;if(!br){while(1){o[Ye+ar|0]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if(($q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[dr>>2]- -64>>2]>>2]+cr|0,ar,$q);cr=$q+cr|0;_q=_q+1|0;if((_q|0)!=(oq|0)){continue}break}break a;default:$q=o[Zq+24|0];ar=Mm(($q|0)>-1?$q:-1);tq=q[Ye+16>>2];Zq=0;d:{if(!q[tq+80>>2]){break d}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=($q|0)<1;dr=Ye+8|0;tq=0;while(1){Ye=0;if(!br){while(1){o[Ye+ar|0]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if(($q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[dr>>2]- -64>>2]>>2]+cr|0,ar,$q);cr=$q+cr|0;_q=_q+1|0;if((_q|0)!=(oq|0)){continue}break}break a;case 2:_q=o[Zq+24|0];Zq=_q+_q|0;ar=Mm(Zq>>>0<_q>>>0?-1:Zq);tq=q[Ye+16>>2];Zq=0;e:{if(!q[tq+80>>2]){break e}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=_q<<1;dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){p[(Ye<<1)+ar>>1]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 1:_q=o[Zq+24|0];Zq=_q+_q|0;ar=Mm(Zq>>>0<_q>>>0?-1:Zq);tq=q[Ye+16>>2];Zq=0;f:{if(!q[tq+80>>2]){break f}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=_q<<1;dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){p[(Ye<<1)+ar>>1]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 4:_q=o[Zq+24|0];br=_q<<2;ar=Mm((_q|0)!=(_q&1073741823)?-1:br);tq=q[Ye+16>>2];Zq=0;g:{if(!q[tq+80>>2]){break g}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){q[(Ye<<2)+ar>>2]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 3:break b}}_q=o[Zq+24|0];br=_q<<2;ar=Mm((_q|0)!=(_q&1073741823)?-1:br);tq=q[Ye+16>>2];Zq=0;h:{if(!q[tq+80>>2]){break h}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){q[(Ye<<2)+ar>>2]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}}An(ar);return 1}function _e(Ye){Ye=Ye|0;var oq=0,fr=0;q[Ye>>2]=2220;fr=Ye+20|0;oq=q[fr>>2];q[fr>>2]=0;if(oq){n[q[q[oq>>2]+4>>2]](oq)}q[Ye>>2]=1908;fr=Ye+16|0;oq=q[fr>>2];q[fr>>2]=0;if(oq){Hb(oq)}return Ye|0}function $e(Ye){Ye=Ye|0;var gr=0,hr=0;q[Ye>>2]=2220;hr=Ye+20|0;gr=q[hr>>2];q[hr>>2]=0;if(gr){n[q[q[gr>>2]+4>>2]](gr)}q[Ye>>2]=1908;hr=Ye+16|0;gr=q[hr>>2];q[hr>>2]=0;if(gr){Hb(gr)}An(Ye)}function af(Ye){Ye=Ye|0;return o[q[Ye+8>>2]+24|0]}function bf(Ye,ir,jr,kr,lr,mr){var nr=0,or=0,pr=0,qr=0;nr=T-32|0;T=nr;pr=q[q[q[ir+4>>2]+8>>2]+(kr<<2)>>2];a:{b:{if((n[q[q[ir>>2]+8>>2]](ir)|0)!=1|jr+ -1>>>0>5){break b}qr=n[q[q[ir>>2]+36>>2]](ir)|0;or=n[q[q[ir>>2]+44>>2]](ir,kr)|0;if(!(or?qr:0)){q[Ye>>2]=0;break a}kr=n[q[q[ir>>2]+40>>2]](ir,kr)|0;if(kr){ir=q[ir+44>>2];q[nr+12>>2]=kr;q[nr+8>>2]=ir;q[nr+20>>2]=or;q[nr+16>>2]=or+12;df(Ye,jr,pr,lr,nr+8|0,mr);if(q[Ye>>2]){break a}q[Ye>>2]=0;break b}ir=q[ir+44>>2];q[nr+12>>2]=qr;q[nr+8>>2]=ir;q[nr+20>>2]=or;q[nr+16>>2]=or+12;ef(Ye,jr,pr,lr,nr+8|0,mr);if(q[Ye>>2]){break a}q[Ye>>2]=0}q[Ye>>2]=0}T=nr+32|0}function cf(Ye,ir,jr){var kr=0,lr=0,mr=0,rr=0,sr=0,tr=0,ur=0,vr=0;q[Ye>>2]=3044;q[Ye+4>>2]=ir;ir=q[jr+8>>2];kr=q[jr+12>>2];lr=q[jr+16>>2];rr=q[jr+20>>2];sr=q[jr>>2];tr=q[jr+4>>2];q[Ye+40>>2]=0;mr=Ye+32|0;q[mr>>2]=0;q[mr+4>>2]=0;q[Ye+24>>2]=lr;q[Ye+28>>2]=rr;q[Ye+16>>2]=ir;q[Ye+20>>2]=kr;q[Ye+8>>2]=sr;q[Ye+12>>2]=tr;a:{ir=q[jr+28>>2]-q[jr+24>>2]|0;b:{if(!ir){break b}kr=ir>>2;if(kr>>>0>=1073741824){break a}ir=Mm(ir);q[Ye+32>>2]=ir;lr=Ye+36|0;q[lr>>2]=ir;q[Ye+40>>2]=ir+(kr<<2);kr=q[jr+24>>2];jr=q[jr+28>>2]-kr|0;if((jr|0)<1){break b}ur=lr,vr=Cn(ir,kr,jr)+jr|0,q[ur>>2]=vr}q[Ye>>2]=6584;return}bn();F()}function df(Ye,ir,jr,wr,xr,yr){ir=ir+ -1|0;if(ir>>>0>5){q[Ye>>2]=0;return}a:{b:{switch(ir-1|0){default:ir=Mm(60);ff(ir,jr,wr,xr);q[ir>>2]=2336;break a;case 0:ir=Mm(60);ff(ir,jr,wr,xr);q[ir>>2]=3100;break a;case 2:ir=Mm(112);ff(ir,jr,wr,xr);q[ir>>2]=3336;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;q[ir+88>>2]=0;q[ir+92>>2]=0;q[ir+96>>2]=0;q[ir+100>>2]=0;q[ir+104>>2]=0;q[ir+108>>2]=0;break a;case 1:ir=Mm(92);ff(ir,jr,wr,xr);q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=3584;q[ir+88>>2]=yr;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;break a;case 3:ir=Mm(104);ff(ir,jr,wr,xr);q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=3812;q[ir+84>>2]=0;jr=q[xr+4>>2];q[ir+88>>2]=q[xr>>2];q[ir+92>>2]=jr;jr=q[xr+12>>2];q[ir+96>>2]=q[xr+8>>2];q[ir+100>>2]=jr;break a;case 4:break b}}ir=Mm(124);ff(ir,jr,wr,xr);q[ir>>2]=4048;jr=ir- -64|0;q[jr>>2]=0;q[jr+4>>2]=0;jr=q[xr+4>>2];q[ir+72>>2]=q[xr>>2];q[ir+76>>2]=jr;jr=q[xr+12>>2];q[ir+80>>2]=q[xr+8>>2];q[ir+84>>2]=jr;q[ir+92>>2]=-1;q[ir+96>>2]=-1;q[ir+88>>2]=1;q[ir+60>>2]=4284;q[ir+100>>2]=-1;q[ir+104>>2]=-1;ah(ir+108|0);q[Ye>>2]=ir;return}q[Ye>>2]=ir}function ef(Ye,ir,jr,wr,xr,yr){ir=ir+ -1|0;if(ir>>>0>5){q[Ye>>2]=0;return}a:{b:{switch(ir-1|0){default:ir=Mm(60);Vf(ir,jr,wr,xr);q[ir>>2]=4676;break a;case 0:ir=Mm(60);Vf(ir,jr,wr,xr);q[ir>>2]=5100;break a;case 2:ir=Mm(112);Vf(ir,jr,wr,xr);q[ir>>2]=5324;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;q[ir+88>>2]=0;q[ir+92>>2]=0;q[ir+96>>2]=0;q[ir+100>>2]=0;q[ir+104>>2]=0;q[ir+108>>2]=0;break a;case 1:ir=Mm(92);Vf(ir,jr,wr,xr);q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=5560;q[ir+88>>2]=yr;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;break a;case 3:ir=Mm(104);Vf(ir,jr,wr,xr);q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=5776;q[ir+84>>2]=0;jr=q[xr+4>>2];q[ir+88>>2]=q[xr>>2];q[ir+92>>2]=jr;jr=q[xr+12>>2];q[ir+96>>2]=q[xr+8>>2];q[ir+100>>2]=jr;break a;case 4:break b}}ir=Mm(124);Vf(ir,jr,wr,xr);q[ir>>2]=6e3;jr=ir- -64|0;q[jr>>2]=0;q[jr+4>>2]=0;jr=q[xr+4>>2];q[ir+72>>2]=q[xr>>2];q[ir+76>>2]=jr;jr=q[xr+12>>2];q[ir+80>>2]=q[xr+8>>2];q[ir+84>>2]=jr;q[ir+92>>2]=-1;q[ir+96>>2]=-1;q[ir+88>>2]=1;q[ir+60>>2]=6220;q[ir+100>>2]=-1;q[ir+104>>2]=-1;ah(ir+108|0);q[Ye>>2]=ir;return}q[Ye>>2]=ir}function ff(Ye,ir,jr,wr){var xr=0,yr=0,zr=0,Ar=0,Br=0,Cr=0,Dr=0,Er=0;q[Ye>>2]=3044;q[Ye+4>>2]=ir;ir=q[jr+8>>2];xr=q[jr+12>>2];yr=q[jr+16>>2];Ar=q[jr+20>>2];Br=q[jr>>2];Cr=q[jr+4>>2];q[Ye+40>>2]=0;zr=Ye+32|0;q[zr>>2]=0;q[zr+4>>2]=0;q[Ye+24>>2]=yr;q[Ye+28>>2]=Ar;q[Ye+16>>2]=ir;q[Ye+20>>2]=xr;q[Ye+8>>2]=Br;q[Ye+12>>2]=Cr;a:{ir=q[jr+28>>2]-q[jr+24>>2]|0;b:{if(!ir){break b}xr=ir>>2;if(xr>>>0>=1073741824){break a}ir=Mm(ir);q[Ye+32>>2]=ir;yr=Ye+36|0;q[yr>>2]=ir;q[Ye+40>>2]=ir+(xr<<2);xr=q[jr+24>>2];jr=q[jr+28>>2]-xr|0;if((jr|0)<1){break b}Dr=yr,Er=Cn(ir,xr,jr)+jr|0,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=Vr+1|0;if((Vr|0)<(es|0)){continue}break}}An(as);return 1}function nf(Ye){Ye=Ye|0;var wr=0;q[Ye>>2]=3044;wr=q[Ye+32>>2];if(wr){q[Ye+36>>2]=wr;An(wr)}return Ye|0}function of(Ye,Pr,Qr,Rr,Sr,hs){Ye=Ye|0;Pr=Pr|0;Qr=Qr|0;Rr=Rr|0;Sr=Sr|0;hs=hs|0;var is=0,js=0,ks=0,ls=0,ms=0,ns=0,os=0,ps=0,qs=0,rs=0,ss=0,ts=0,us=0,vs=0,ws=0,xs=0,ys=0,zs=0,As=0,Bs=0,Cs=0,Ds=0;q[Ye+8>>2]=Sr;hs=Ye+32|0;is=q[hs>>2];Rr=q[Ye+36>>2]-is>>2;a:{if(Rr>>>0>>0){Fa(hs,Sr-Rr|0);break a}if(Rr>>>0<=Sr>>>0){break a}q[Ye+36>>2]=is+(Sr<<2)}hs=0;Rr=(Sr&1073741823)!=(Sr|0)?-1:Sr<<2;rs=Dn(Mm(Rr),0,Rr);ws=Dn(Mm(Rr),0,Rr);os=Ye+8|0;is=q[os>>2];b:{if((is|0)<1){break b}ps=Ye+16|0;Rr=Ye+32|0;qs=Ye+12|0;while(1){is=hs<<2;ls=q[is+rs>>2];ns=q[ps>>2];c:{if((ls|0)>(ns|0)){ks=q[Rr>>2];q[is+ks>>2]=ns;break c}ks=q[Rr>>2];is=is+ks|0;ns=q[qs>>2];if((ls|0)<(ns|0)){q[is>>2]=ns;break c}q[is>>2]=ls}hs=hs+1|0;is=q[os>>2];if((hs|0)<(is|0)){continue}break}if((is|0)<1){break b}Rr=0;os=Ye+16|0;ls=Ye+20|0;ps=Ye+8|0;qs=Ye+12|0;while(1){is=Rr<<2;hs=is+Qr|0;is=q[Pr+is>>2]+q[is+ks>>2]|0;q[hs>>2]=is;d:{if((is|0)>q[os>>2]){is=is-q[ls>>2]|0}else{if((is|0)>=q[qs>>2]){break d}is=is+q[ls>>2]|0}q[hs>>2]=is}Rr=Rr+1|0;is=q[ps>>2];if((Rr|0)<(is|0)){continue}break}}Rr=q[Ye+56>>2];xs=q[Rr>>2];Rr=q[Rr+4>>2]-xs|0;if((Rr|0)>=5){ys=Rr>>2;As=Sr<<2;Bs=q[Ye+52>>2];os=Ye+16|0;ps=Ye+32|0;qs=Ye+8|0;ns=Ye+20|0;us=Ye+12|0;ss=q[Ye+48>>2];Cs=ss+28|0;ls=1;while(1){e:{f:{g:{if(ys>>>0>ls>>>0){Ye=q[(ls<<2)+xs>>2];zs=(Sr|0)<1;if(!zs){Dn(rs,0,As)}if((Ye|0)==-1){Ye=w(Sr,ls);break f}Ds=q[ss>>2];ks=0;Rr=Ye;while(1){h:{if(q[Ds+(Rr>>>3&536870908)>>2]>>>(Rr&31)&1){break h}hs=q[q[q[ss+64>>2]+12>>2]+(Rr<<2)>>2];if((hs|0)==-1){break h}ms=q[Bs>>2];js=q[Cs>>2];vs=q[ms+(q[js+(hs<<2)>>2]<<2)>>2];if((vs|0)>=(ls|0)){break h}ts=hs+1|0;ts=q[ms+(q[js+(((ts>>>0)%3|0?ts:hs+ -2|0)<<2)>>2]<<2)>>2];if((ts|0)>=(ls|0)){break h}hs=q[ms+(q[js+(hs+((hs>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if((hs|0)>=(ls|0)){break h}i:{if(zs){break i}js=w(Sr,hs);ms=w(Sr,ts);vs=w(Sr,vs);hs=0;while(1){q[ws+(hs<<2)>>2]=(q[(hs+js<<2)+Qr>>2]+q[(hs+ms<<2)+Qr>>2]|0)-q[(hs+vs<<2)+Qr>>2];hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}hs=0;if((Sr|0)<=0){break i}while(1){js=hs<<2;ms=js+rs|0;q[ms>>2]=q[ms>>2]+q[js+ws>>2];hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}}ks=ks+1|0}hs=-1;Rr=((Rr>>>0)%3|0?-1:2)+Rr|0;j:{if((Rr|0)==-1|q[q[ss>>2]+(Rr>>>3&536870908)>>2]>>>(Rr&31)&1){break j}Rr=q[q[q[ss+64>>2]+12>>2]+(Rr<<2)>>2];if((Rr|0)==-1){break j}if((Rr>>>0)%3){hs=Rr+ -1|0;break j}hs=Rr+2|0}Rr=(Ye|0)==(hs|0)?-1:hs;if((Rr|0)!=-1){continue}break}Ye=w(Sr,ls);if(!ks){break f}hs=0;if((Sr|0)<=0){break g}while(1){Rr=(hs<<2)+rs|0;q[Rr>>2]=q[Rr>>2]/(ks|0);hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}break g}cn();F()}if((is|0)<1){break e}hs=0;while(1){Rr=hs<<2;is=q[Rr+rs>>2];js=q[os>>2];k:{if((is|0)>(js|0)){ks=q[ps>>2];q[Rr+ks>>2]=js;break k}ks=q[ps>>2];Rr=Rr+ks|0;js=q[us>>2];if((is|0)<(js|0)){q[Rr>>2]=js;break k}q[Rr>>2]=is}hs=hs+1|0;is=q[qs>>2];if((hs|0)<(is|0)){continue}break}Rr=0;if((is|0)<1){break e}Ye=Ye<<2;js=Ye+Qr|0;ms=Ye+Pr|0;while(1){hs=Rr<<2;Ye=hs+js|0;hs=q[hs+ms>>2]+q[hs+ks>>2]|0;q[Ye>>2]=hs;l:{if((hs|0)>q[os>>2]){hs=hs-q[ns>>2]|0}else{if((hs|0)>=q[us>>2]){break l}hs=hs+q[ns>>2]|0}q[Ye>>2]=hs}Rr=Rr+1|0;is=q[qs>>2];if((Rr|0)<(is|0)){continue}break}break e}if((is|0)<1){break e}js=(w(ls+ -1|0,Sr)<<2)+Qr|0;hs=0;while(1){Rr=hs<<2;is=q[Rr+js>>2];ms=q[os>>2];m:{if((is|0)>(ms|0)){ks=q[ps>>2];q[Rr+ks>>2]=ms;break m}ks=q[ps>>2];Rr=Rr+ks|0;ms=q[us>>2];if((is|0)<(ms|0)){q[Rr>>2]=ms;break m}q[Rr>>2]=is}hs=hs+1|0;is=q[qs>>2];if((hs|0)<(is|0)){continue}break}Rr=0;if((is|0)<1){break e}Ye=Ye<<2;js=Ye+Qr|0;ms=Ye+Pr|0;while(1){hs=Rr<<2;Ye=hs+js|0;hs=q[hs+ms>>2]+q[hs+ks>>2]|0;q[Ye>>2]=hs;n:{if((hs|0)>q[os>>2]){hs=hs-q[ns>>2]|0}else{if((hs|0)>=q[us>>2]){break n}hs=hs+q[ns>>2]|0}q[Ye>>2]=hs}Rr=Rr+1|0;is=q[qs>>2];if((Rr|0)<(is|0)){continue}break}}ls=ls+1|0;if((ls|0)<(ys|0)){continue}break}}An(ws);An(rs);return 1}function pf(Ye){Ye=Ye|0;var Pr=0;q[Ye>>2]=3336;Pr=q[Ye+96>>2];if(Pr){An(Pr)}Pr=q[Ye+84>>2];if(Pr){An(Pr)}Pr=q[Ye+72>>2];if(Pr){An(Pr)}Pr=q[Ye+60>>2];if(Pr){An(Pr)}q[Ye>>2]=3044;Pr=q[Ye+32>>2];if(Pr){q[Ye+36>>2]=Pr;An(Pr)}return Ye|0}function qf(Ye){Ye=Ye|0;var Qr=0;q[Ye>>2]=3336;Qr=q[Ye+96>>2];if(Qr){An(Qr)}Qr=q[Ye+84>>2];if(Qr){An(Qr)}Qr=q[Ye+72>>2];if(Qr){An(Qr)}Qr=q[Ye+60>>2];if(Qr){An(Qr)}q[Ye>>2]=3044;Qr=q[Ye+32>>2];if(Qr){q[Ye+36>>2]=Qr;An(Qr)}An(Ye)}function rf(q){q=q|0;return 4}function sf(Ye,Rr){Ye=Ye|0;Rr=Rr|0;var Sr=0,hs=0,Es=0,Fs=0,Gs=0,Hs=0,Is=0,Js=0,Ks=0,Ls=0,Ms=0;Js=T-32|0;T=Js;a:{if(s[Rr+38>>1]<=513){Es=q[Rr+16>>2];hs=q[Rr+12>>2];Sr=q[Rr+20>>2];if((hs|0)<(Sr|0)?1:(hs|0)<=(Sr|0)?t[Rr+8>>2]>Es>>>0?0:1:0){break a}Fs=r[Es+q[Rr>>2]|0];Es=Es+1|0;if(Es>>>0<1){Sr=Sr+1|0}q[Rr+16>>2]=Es;q[Rr+20>>2]=Sr;if(Fs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0;q[bt+24>>2]=0;q[bt+28>>2]=0;q[bt+16>>2]=0;q[bt+20>>2]=0;q[bt>>2]=0;Ys=0;if(Zs){Ad(bt+16|0,Zs,bt);at=q[bt+28>>2];Ys=q[_s>>2]}q[bt>>2]=0;Ys=Ys-at>>2;b:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break b}q[bt+32>>2]=(Zs<<2)+at;break b}Ad(bt+16|12,Zs-Ys|0,bt)}q[bt>>2]=0;_s=q[bt+40>>2];Ys=q[bt+44>>2]-_s>>2;c:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break c}q[bt+44>>2]=_s+(Zs<<2);break c}Ad(bt+40|0,Zs-Ys|0,bt)}q[bt>>2]=0;_s=q[bt+52>>2];Ys=q[bt+56>>2]-_s>>2;d:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break d}q[bt+56>>2]=_s+(Zs<<2);break d}Ad(bt+52|0,Zs-Ys|0,bt)}et=Ye+8|0;e:{if(q[et>>2]<=0){break e}ft=q[bt+16>>2];at=0;ht=Ye+16|0;Ys=Ye+32|0;dt=Ye+12|0;while(1){_s=at<<2;$s=q[_s+ft>>2];it=q[ht>>2];f:{if(($s|0)>(it|0)){ct=q[Ys>>2];q[_s+ct>>2]=it;break f}ct=q[Ys>>2];_s=_s+ct|0;it=q[dt>>2];if(($s|0)<(it|0)){q[_s>>2]=it;break f}q[_s>>2]=$s}at=at+1|0;_s=q[et>>2];if((at|0)<(_s|0)){continue}break}if((_s|0)<1){break e}Ys=0;et=Ye+16|0;at=Ye+20|0;ft=Ye+8|0;ht=Ye+12|0;while(1){$s=Ys<<2;_s=$s+Xs|0;$s=q[Rr+$s>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;g:{if(($s|0)>q[et>>2]){$s=$s-q[at>>2]|0}else{if(($s|0)>=q[ht>>2]){break g}$s=$s+q[at>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}}wt=q[Ye+52>>2];ft=q[Ye+48>>2];qt=Mm(16);Ys=qt;q[Ys>>2]=0;q[Ys+4>>2]=0;q[Ys+8>>2]=0;q[Ys+12>>2]=0;q[bt+8>>2]=0;q[bt>>2]=0;q[bt+4>>2]=0;h:{if(Zs){if(Zs>>>0>=1073741824){break h}Ys=Zs<<2;mt=Mm(Ys);q[bt>>2]=mt;_s=Ys+mt|0;q[bt+8>>2]=_s;Dn(mt,0,Ys);q[bt+4>>2]=_s}Ys=1;_s=q[Ye+56>>2];ut=q[_s>>2];_s=q[_s+4>>2]-ut|0;i:{if((_s|0)<5){break i}vt=_s>>2;xt=Zs<<2;ht=Ye+8|0;it=Ye+16|0;nt=Ye+32|0;ot=Ye+20|0;pt=Ye+12|0;yt=ft+28|0;et=1;while(1){j:{k:{l:{if(vt>>>0>et>>>0){m:{n:{ct=q[(et<<2)+ut>>2];if((ct|0)==-1){break n}gt=ct+((ct>>>0)%3|0?-1:2)|0;rt=gt>>>5;dt=1;st=1<<(gt&31);tt=q[ft>>2];_s=0;Ys=ct;o:{while(1){p:{if(q[tt+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break p}$s=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if(($s|0)==-1){break p}kt=q[wt>>2];at=q[yt>>2];lt=q[kt+(q[at+($s<<2)>>2]<<2)>>2];if((lt|0)>=(et|0)){break p}jt=$s+1|0;jt=q[kt+(q[at+(((jt>>>0)%3|0?jt:$s+ -2|0)<<2)>>2]<<2)>>2];if((jt|0)>=(et|0)){break p}$s=q[kt+(q[at+($s+(($s>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if(($s|0)>=(et|0)){break p}if((Zs|0)>=1){kt=q[(bt+16|0)+w(_s,12)>>2];$s=w(Zs,$s);jt=w(Zs,jt);lt=w(Zs,lt);at=0;while(1){q[kt+(at<<2)>>2]=(q[($s+at<<2)+Xs>>2]+q[(at+jt<<2)+Xs>>2]|0)-q[(at+lt<<2)+Xs>>2];at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}$s=4;_s=_s+1|0;if((_s|0)==4){break o}}q:{if(dt&1){at=-1;$s=Ys+1|0;Ys=($s>>>0)%3|0?$s:Ys+ -2|0;if((Ys|0)==-1|q[q[ft>>2]+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break q}Ys=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if((Ys|0)==-1){break q}$s=Ys+1|0;at=($s>>>0)%3|0?$s:Ys+ -2|0;break q}at=-1;Ys=((Ys>>>0)%3|0?-1:2)+Ys|0;if((Ys|0)==-1|q[q[ft>>2]+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break q}Ys=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if((Ys|0)==-1){break q}if((Ys>>>0)%3){at=Ys+ -1|0;break q}at=Ys+2|0}r:{if((at|0)==(ct|0)){break r}Ys=at;$s=(at|0)!=-1;at=($s|dt^-1)&1;Ys=at?Ys:-1;dt=$s&dt;if(!((gt|0)==-1|at)){if(q[q[ft>>2]+(rt<<2)>>2]&st){break r}$s=q[q[q[ft+64>>2]+12>>2]+(gt<<2)>>2];if(($s|0)==-1){break r}dt=0;if(($s>>>0)%3){Ys=$s+ -1|0}else{Ys=$s+2|0}}if((Ys|0)!=-1){continue}}break}$s=_s;if(($s|0)<1){break n}}gt=(Zs|0)<1;if(!gt){Dn(mt,0,xt)}Ys=$s+ -1|0;dt=(Ys<<2)+qt|0;Ys=w(Ys,12)+Ye|0;kt=Ys+60|0;rt=q[Ys- -64>>2];Ys=0;st=q[bt>>2];ct=0;_s=0;while(1){at=q[dt>>2];q[dt>>2]=at+1;if(rt>>>0<=at>>>0){break i}s:{if(q[q[kt>>2]+(at>>>3&536870908)>>2]>>>(at&31)&1){break s}_s=_s+1|0;if(gt){break s}tt=q[(bt+16|0)+w(ct,12)>>2];at=0;while(1){lt=at<<2;jt=lt+st|0;q[jt>>2]=q[jt>>2]+q[lt+tt>>2];at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}ct=ct+1|0;if(($s|0)!=(ct|0)){continue}break}dt=w(Zs,et);$s=dt;if(!_s){break m}at=0;if((Zs|0)>0){break l}break k}$s=w(Zs,et)}if(q[ht>>2]<1){break j}dt=(w(et+ -1|0,Zs)<<2)+Xs|0;at=0;while(1){Ys=at<<2;_s=q[Ys+dt>>2];gt=q[it>>2];t:{if((_s|0)>(gt|0)){ct=q[nt>>2];q[Ys+ct>>2]=gt;break t}ct=q[nt>>2];Ys=Ys+ct|0;gt=q[pt>>2];if((_s|0)<(gt|0)){q[Ys>>2]=gt;break t}q[Ys>>2]=_s}at=at+1|0;_s=q[ht>>2];if((at|0)<(_s|0)){continue}break}Ys=0;if((_s|0)<1){break j}_s=$s<<2;at=_s+Xs|0;dt=Rr+_s|0;while(1){$s=Ys<<2;_s=$s+at|0;$s=q[$s+dt>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;u:{if(($s|0)>q[it>>2]){$s=$s-q[ot>>2]|0}else{if(($s|0)>=q[pt>>2]){break u}$s=$s+q[ot>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}break j}cn();F()}while(1){Ys=(at<<2)+mt|0;q[Ys>>2]=q[Ys>>2]/(_s|0);at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}if(q[ht>>2]<1){break j}at=0;while(1){Ys=at<<2;_s=q[Ys+mt>>2];$s=q[it>>2];v:{if((_s|0)>($s|0)){ct=q[nt>>2];q[Ys+ct>>2]=$s;break v}ct=q[nt>>2];Ys=Ys+ct|0;$s=q[pt>>2];if((_s|0)<($s|0)){q[Ys>>2]=$s;break v}q[Ys>>2]=_s}at=at+1|0;_s=q[ht>>2];if((at|0)<(_s|0)){continue}break}Ys=0;if((_s|0)<1){break j}_s=dt<<2;at=_s+Xs|0;dt=Rr+_s|0;while(1){$s=Ys<<2;_s=$s+at|0;$s=q[$s+dt>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;w:{if(($s|0)>q[it>>2]){$s=$s-q[ot>>2]|0}else{if(($s|0)>=q[pt>>2]){break w}$s=$s+q[ot>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}}Ys=1;et=et+1|0;if((et|0)<(vt|0)){continue}break}}Ye=q[bt>>2];if(Ye){q[bt+4>>2]=Ye;An(Ye)}An(qt);Ye=q[bt+52>>2];if(Ye){q[bt+56>>2]=Ye;An(Ye)}Ye=q[bt+40>>2];if(Ye){q[bt+44>>2]=Ye;An(Ye)}Ye=q[bt+28>>2];if(Ye){q[bt+32>>2]=Ye;An(Ye)}Ye=q[bt+16>>2];if(Ye){q[bt+20>>2]=Ye;An(Ye)}T=bt- -64|0;return Ys|0}bn();F()}function wf(Ye){Ye=Ye|0;var Rr=0,Xs=0;q[Ye>>2]=3584;Rr=q[Ye+76>>2];if(Rr){An(Rr)}Xs=Ye+68|0;Rr=q[Xs>>2];q[Xs>>2]=0;if(Rr){An(Rr)}q[Ye>>2]=3044;Rr=q[Ye+32>>2];if(Rr){q[Ye+36>>2]=Rr;An(Rr)}return Ye|0}function xf(Ye){Ye=Ye|0;var Ys=0,Zs=0;q[Ye>>2]=3584;Ys=q[Ye+76>>2];if(Ys){An(Ys)}Zs=Ye+68|0;Ys=q[Zs>>2];q[Zs>>2]=0;if(Ys){An(Ys)}q[Ye>>2]=3044;Ys=q[Ye+32>>2];if(Ys){q[Ye+36>>2]=Ys;An(Ys)}An(Ye)}function yf(q){q=q|0;return 3}function zf(Ye){Ye=Ye|0;if(!(!q[Ye+60>>2]|!q[Ye+44>>2]|(!q[Ye+48>>2]|!q[Ye+52>>2]))){return q[Ye+56>>2]!=0|0}return 0}function Af(Ye,_s){Ye=Ye|0;_s=_s|0;var zt=0;if(!(q[_s+56>>2]|!_s|r[_s+24|0]!=3)){q[Ye+60>>2]=_s;zt=1}return zt|0}function Bf(Ye,_s){Ye=Ye|0;_s=_s|0;var At=0,Bt=0,Ct=0,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=x(mu-su);au=x(x(x(x(x(cu*eu)+x(0))+x(fu*nu))+x(gu*mu))/pu);gu=x(mu-x(gu*au));fu=x(nu-x(fu*au));cu=x(eu-x(cu*au));hu=x(E(x(x(x(gu*gu)+x(x(fu*fu)+x(x(cu*cu)+x(0))))/pu)))}eu=hu;Lt=Ye+80|0;_s=q[Lt>>2]+ -1|0;Mt=q[q[Ye+76>>2]+(_s>>>3&536870908)>>2];q[Lt>>2]=_s;cu=x(bu-iu);hu=x(x(cu*au)+iu);iu=x(lu-ou);bu=x(iu*eu);_s=Mt>>>(_s&31)&1;bu=x(hu+(_s?bu:x(-bu)));hu=x(x(iu*au)+ou);au=x(cu*eu);au=x(hu+(_s?x(-au):au));f:{if(((k(au),e(0))&2147483647)>>>0>=2139095041){_s=q[Ye+68>>2];q[_s>>2]=-2147483648;break f}_s=q[Ye+68>>2];Ye=_s;ku=C(+au+.5);g:{if(y(ku)<2147483648){Lt=~~ku;break g}Lt=-2147483648}q[Ye>>2]=Lt}Lt=((k(bu),e(0))&2147483647)>>>0>2139095040;ku=C(+bu+.5);h:{if(y(ku)<2147483648){Ye=~~ku;break h}Ye=-2147483648}q[_s+4>>2]=Lt?-2147483648:Ye;break c}i:{if(!ju){_s=q[Ye+72>>2];Mt=w(Ot,_s);break i}if((Mt|0)<=0){if(q[Ye+72>>2]<1){break c}Lt=q[Ye+68>>2];_s=0;while(1){q[Lt+(_s<<2)>>2]=0;_s=_s+1|0;if((_s|0)>2]){continue}break}break c}_s=q[Ye+72>>2];Mt=w(_s,Mt+ -1|0)}if((_s|0)<1){break c}Ot=q[Ye+68>>2];_s=0;while(1){q[Ot+(_s<<2)>>2]=q[(_s+Mt<<2)+Lt>>2];_s=_s+1|0;if((_s|0)>2]){continue}break}}T=Nt+48|0;return}cn();F()}function Ef(Ye){Ye=Ye|0;var _s=0;q[Ye>>2]=3812;_s=q[Ye+76>>2];if(_s){An(_s)}q[Ye>>2]=3044;_s=q[Ye+32>>2];if(_s){q[Ye+36>>2]=_s;An(_s)}return Ye|0}function Ff(Ye){Ye=Ye|0;var Lt=0;q[Ye>>2]=3812;Lt=q[Ye+76>>2];if(Lt){An(Lt)}q[Ye>>2]=3044;Lt=q[Ye+32>>2];if(Lt){q[Ye+36>>2]=Lt;An(Lt)}An(Ye)}function Gf(q){q=q|0;return 5}function Hf(Ye,Mt){Ye=Ye|0;Mt=Mt|0;var uu=0,vu=0,wu=0,xu=0,yu=0,zu=0,Au=0,Bu=0,Cu=0,Du=0,Eu=0;Bu=T-16|0;T=Bu;wu=q[Mt+12>>2];uu=q[Mt+20>>2];xu=q[Mt+16>>2];vu=xu+4|0;if(vu>>>0<4){uu=uu+1|0}yu=vu;vu=uu;a:{if((wu|0)<(uu|0)?1:(wu|0)<=(uu|0)?t[Mt+8>>2]>=yu>>>0?0:1:0){break a}uu=xu+q[Mt>>2]|0;uu=r[uu|0]|r[uu+1|0]<<8|(r[uu+2|0]<<16|r[uu+3|0]<<24);q[Mt+16>>2]=yu;q[Mt+20>>2]=vu;if((uu|0)<0){break a}uf(Ye+76|0,uu);yu=ah(Bu);b:{if(!bh(yu,Mt)){break b}if((uu|0)>=1){wu=1;while(1){xu=1<<(Au&31);zu=dh(yu);vu=q[Ye+76>>2]+(Au>>>3&536870908)|0;wu=wu^zu;zu=q[vu>>2]|xu;c:{if(!(wu&1)){break c}zu=q[vu>>2]&(xu^-1)}xu=zu;wu=wu^1;q[vu>>2]=xu;Au=Au+1|0;if((uu|0)!=(Au|0)){continue}break}}vu=q[Mt+12>>2];Au=vu;uu=q[Mt+20>>2];wu=uu;yu=q[Mt+16>>2];xu=yu+4|0;if(xu>>>0<4){uu=uu+1|0}Cu=q[Mt+8>>2];zu=xu;xu=uu;if((vu|0)<(uu|0)?1:(vu|0)<=(uu|0)?Cu>>>0>=zu>>>0?0:1:0){break b}Du=q[Mt>>2];uu=Du+yu|0;vu=r[uu|0]|r[uu+1|0]<<8|(r[uu+2|0]<<16|r[uu+3|0]<<24);q[Mt+16>>2]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)){break b}break a;case 0:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=r[b|0];q[e+4>>2]=0;b=b+1|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 1:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;h=p[b>>1];q[e>>2]=h;q[e+4>>2]=h>>31;b=b+2|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 2:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=s[b>>1];q[e+4>>2]=0;b=b+2|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 3:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;h=q[b>>2];q[e>>2]=h;q[e+4>>2]=h>>31;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 4:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=0;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 5:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){h=q[b+4>>2];e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 6:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){h=q[b+4>>2];e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 7:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24<1){break c}g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;g=e;i=u[b>>2];f:{if(x(y(i))=x(1)?i>x(0)?~~x(A(x(C(x(i/x(4294967296)))),x(4294967296)))>>>0:~~x(D(x(x(i-x(~~i>>>0>>>0))/x(4294967296))))>>>0:0;k=~~i>>>0;break f}h=-2147483648;k=0}q[g>>2]=k;q[e+4>>2]=h;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}break c;case 8:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24<1){break d}g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;g=e;j=v[b>>3];g:{if(y(j)<0x8000000000000000){h=y(j)>=1?j>0?~~A(C(j/4294967296),4294967295)>>>0:~~D((j- +(~~j>>>0>>>0))/4294967296)>>>0:0;k=~~j>>>0;break g}h=-2147483648;k=0}q[g>>2]=k;q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}break d;case 9:break e}}e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=r[b|0];q[e+4>>2]=0;b=b+1|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}Dn((e<<3)+d|0,0,c-e<<3);break b}if((e|0)>=(c|0)){break b}break a}if((e|0)>=(c|0)){break b}Dn((e<<3)+d|0,0,c-e<<3)}return}Dn((e<<3)+d|0,0,c-e<<3)}function Lf(a){a=a|0;var b=0;q[a>>2]=4048;q[a>>2]=3044;b=q[a+32>>2];if(b){q[a+36>>2]=b;An(b)}return a|0}function Mf(a){a=a|0;var c=0;q[a>>2]=4048;q[a>>2]=3044;c=q[a+32>>2];if(c){q[a+36>>2]=c;An(c)}An(a)}function Nf(a){a=a|0;return 6}function Of(a){a=a|0;var d=0;a:{if(!q[a- -64>>2]|!q[a+68>>2]|(!q[a+44>>2]|!q[a+48>>2])){break a}if(!q[a+52>>2]|!q[a+56>>2]){break a}d=q[a+92>>2]!=-1}return d|0}function Pf(a,l){a=a|0;l=l|0;var m=0;if(!(q[l+56>>2]|r[l+24|0]!=3)){q[a- -64>>2]=l;m=1}return m|0}function Qf(a,l){a=a|0;l=l|0;var n=0,o=0,p=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;w=q[l+12>>2];p=w;o=q[l+20>>2];u=o;x=q[l+16>>2];n=x+4|0;if(n>>>0<4){o=o+1|0}y=q[l+8>>2];t=n;n=o;a:{if((p|0)<(n|0)?1:(p|0)<=(n|0)?y>>>0>=t>>>0?0:1:0){break a}z=q[l>>2];o=x+z|0;p=r[o|0]|r[o+1|0]<<8|(r[o+2|0]<<16|r[o+3|0]<<24);q[l+16>>2]=t;q[l+20>>2]=n;n=w;o=u;v=x+8|0;if(v>>>0<8){o=o+1|0}if((n|0)<(o|0)?1:(n|0)<=(o|0)?y>>>0>=v>>>0?0:1:0){break a}n=t+z|0;n=r[n|0]|r[n+1|0]<<8|(r[n+2|0]<<16|r[n+3|0]<<24);q[l+16>>2]=v;q[l+20>>2]=o;if((p|0)>(n|0)){break a}q[a+16>>2]=n;q[a+12>>2]=p;t=p;p=(n>>31)-((p>>31)+(n>>>0

>>0)|0)|0;n=n-t|0;if(!p&n>>>0>2147483646|p>>>0>0){break a}p=n+1|0;q[a+20>>2]=p;t=a+24|0;n=(p|0)/2|0;q[t>>2]=n;q[a+28>>2]=0-n;if(!(p&1)){q[t>>2]=n+ -1}if(s[l+38>>1]<=513){if((w|0)<(o|0)?1:(w|0)<=(o|0)?y>>>0>v>>>0?0:1:0){break a}n=r[v+z|0];o=u;u=x+9|0;if(u>>>0<9){o=o+1|0}p=l;q[p+16>>2]=u;q[p+20>>2]=o;if(n>>>0>1){break a}q[a+88>>2]=n-1|0?0:1}A=bh(a+108|0,l)}return A|0}function Rf(a,l,r,s,B,C){a=a|0;l=l|0;r=r|0;s=s|0;B=B|0;C=C|0;var D=0,E=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;E=T-32|0;T=E;q[a+68>>2]=C;s=q[a+56>>2];B=q[s>>2];C=s+4|0;D=q[C>>2];q[E+24>>2]=0;q[E+16>>2]=0;q[E+20>>2]=0;a:{B=D-B|0;if((B|0)<1){break a}s=q[s>>2];if((s|0)!=q[C>>2]){P=B>>2;Q=a+60|0;R=a+108|0;K=a+8|0;L=a+16|0;M=a+32|0;N=a+20|0;O=a+12|0;S=a+56|0;while(1){Sf(Q,q[(I<<2)+s>>2],E+16|0);B=q[E+20>>2];D=B>>31;C=q[E+16>>2];G=C>>31;J=q[E+24>>2];H=J>>31;s=0;H=H^H+J;D=H+((D^B+D)+(G^C+G)|0)|0;if(D>>>0>>0){s=1}b:{if(!(s|D)){q[E+16>>2]=q[a+104>>2];break b}G=q[a+104>>2];H=G>>31;B=ao($n(G,H,B,B>>31),V,D,s);q[E+20>>2]=B;s=ao($n(G,H,C,C>>31),V,D,s);q[E+16>>2]=s;C=s;s=s>>31;s=(G-(C+s^s)|0)+((B|0)<0?B:0-B|0)|0;if((J|0)>=0){q[E+24>>2]=s;break b}q[E+24>>2]=0-s}s=dh(R);C=q[E+16>>2];c:{if(!s){B=q[E+20>>2];break c}q[E+24>>2]=0-q[E+24>>2];B=0-q[E+20>>2]|0;q[E+20>>2]=B;C=0-C|0;q[E+16>>2]=C}d:{if((C|0)>=0){s=q[a+104>>2];C=s+q[E+24>>2]|0;s=s+B|0;break d}e:{if((B|0)<=-1){C=q[E+24>>2];s=C>>31;s=s^s+C;break e}C=q[E+24>>2];s=C>>31;s=q[a+100>>2]-(s^s+C)|0}if((C|0)<=-1){C=B;B=B>>31;C=C+B^B;break d}C=B;B=B>>31;C=q[a+100>>2]-(C+B^B)|0}B=q[a+100>>2];f:{if(!(s|C)){C=B;s=B;break f}if(!((B|0)!=(C|0)|s)){s=C;break f}if(!((s|0)!=(B|0)|C)){C=s;break f}g:{if(s){break g}D=q[a+104>>2];if((D|0)>=(C|0)){break g}C=(D<<1)-C|0;s=0;break f}h:{if((s|0)!=(B|0)){break h}D=q[a+104>>2];if((D|0)<=(C|0)){break h}C=(D<<1)-C|0;break f}i:{if((B|0)!=(C|0)){break i}B=q[a+104>>2];if((B|0)<=(s|0)){break i}s=(B<<1)-s|0;break f}if(C){break f}C=0;B=q[a+104>>2];if((B|0)>=(s|0)){break f}s=(B<<1)-s|0}q[E+12>>2]=C;q[E+8>>2]=s;j:{if(q[K>>2]<1){break j}C=0;while(1){D=q[L>>2];k:{if((s|0)>(D|0)){B=q[M>>2];q[B+(C<<2)>>2]=D;break k}B=q[M>>2];D=B+(C<<2)|0;G=q[O>>2];if((s|0)<(G|0)){q[D>>2]=G;break k}q[D>>2]=s}C=C+1|0;D=q[K>>2];if((C|0)<(D|0)){s=q[(E+8|0)+(C<<2)>>2];continue}break}s=0;if((D|0)<1){break j}C=I<<3;G=C+r|0;J=l+C|0;while(1){D=s<<2;C=D+G|0;D=q[D+J>>2]+q[B+D>>2]|0;q[C>>2]=D;l:{if((D|0)>q[L>>2]){H=D-q[N>>2]|0}else{if((D|0)>=q[O>>2]){break l}H=D+q[N>>2]|0}q[C>>2]=H}s=s+1|0;if((s|0)>2]){continue}break}}I=I+1|0;if((I|0)>=(P|0)){break a}B=q[S>>2];s=q[B>>2];if(q[B+4>>2]-s>>2>>>0>I>>>0){continue}break}}cn();F()}T=E+32|0;return 1}function Sf(a,l,s){a=a|0;l=l|0;s=s|0;var B=0,C=0,U=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0;C=T-96|0;T=C;B=q[a+16>>2];o[C+92|0]=1;q[C+88>>2]=l;q[C+84>>2]=l;q[C+80>>2]=B;W=q[a+20>>2];U=q[W>>2];a:{b:{c:{d:{B=q[q[B+28>>2]+(l<<2)>>2];if(q[W+4>>2]-U>>2>>>0>B>>>0){B=q[q[a+8>>2]+(q[U+(B<<2)>>2]<<2)>>2];U=q[a+4>>2];if(!r[U+84|0]){B=q[q[U+68>>2]+(B<<2)>>2]}q[C+72>>2]=0;q[C+76>>2]=0;W=C- -64|0;q[W>>2]=0;q[W+4>>2]=0;q[C+56>>2]=0;q[C+60>>2]=0;Kf(U,B,o[U+24|0],C+56|0);if((l|0)==-1){break a}B=l+1|0;W=(B>>>0)%3|0?B:l+ -2|0;ea=((l>>>0)%3|0?-1:2)+l|0;la=a+28|0;X=!q[la>>2];ma=a+20|0;na=a+16|0;oa=a+8|0;while(1){U=W;B=ea;e:{if(X){break e}B=l+1|0;U=(B>>>0)%3|0?B:l+ -2|0;B=l+ -1|0;if((l>>>0)%3){break e}B=l+2|0}X=q[ma>>2];l=q[X>>2];U=q[q[q[na>>2]+28>>2]+(U<<2)>>2];if(q[X+4>>2]-l>>2>>>0<=U>>>0){break d}U=q[q[oa>>2]+(q[l+(U<<2)>>2]<<2)>>2];X=a+4|0;l=q[X>>2];if(!r[l+84|0]){U=q[q[l+68>>2]+(U<<2)>>2]}q[C+48>>2]=0;q[C+52>>2]=0;q[C+40>>2]=0;q[C+44>>2]=0;q[C+32>>2]=0;q[C+36>>2]=0;Kf(l,U,o[l+24|0],C+32|0);U=q[ma>>2];l=q[U>>2];B=q[q[q[na>>2]+28>>2]+(B<<2)>>2];if(q[U+4>>2]-l>>2>>>0<=B>>>0){break c}U=q[q[oa>>2]+(q[l+(B<<2)>>2]<<2)>>2];l=q[X>>2];if(!r[l+84|0]){U=q[q[l+68>>2]+(U<<2)>>2]}X=C+24|0;B=X;q[B>>2]=0;q[B+4>>2]=0;_=C+16|0;B=_;q[B>>2]=0;q[B+4>>2]=0;q[C+8>>2]=0;q[C+12>>2]=0;Kf(l,U,o[l+24|0],C+8|0);B=q[C+8>>2];l=q[C+56>>2];fa=B-l|0;ga=q[C+60>>2];U=q[C+12>>2]-(ga+(B>>>0>>0)|0)|0;ha=q[C+40>>2];B=q[C+64>>2];pa=ha-B|0;ia=q[C+68>>2];ha=q[C+44>>2]-(ia+(ha>>>0>>0)|0)|0;ja=$n(fa,U,pa,ha);ka=Y-ja|0;$=$-(V+(Y>>>0>>0)|0)|0;Y=q[_>>2];ja=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F()}cn();F()}if((a|0)<0?1:(a|0)<=0?B>>>0>=536870913?0:1:0){break a}l=a>>>29;a=(a&536870911)<<3|B>>>29;Y=ao(Y,$,a,l);Z=ao(Z,ca,a,l);aa=ao(aa,da,a,l)}q[s+8>>2]=Y;q[s+4>>2]=Z;q[s>>2]=aa;T=C+96|0}function Tf(a,l){a=a|0;l=l|0;if(l>>>0<=1){q[a+28>>2]=l;a=1}else{a=0}return a|0}function Uf(a){var l=0,s=0,F=0;l=q[a+8>>2];F=q[a>>2];a:{if(r[a+12|0]){b:{c:{d:{e:{if((l|0)==-1){break e}s=l+1|0;l=(s>>>0)%3|0?s:l+ -2|0;if((l|0)==-1|q[q[F>>2]+(l>>>3&536870908)>>2]>>>(l&31)&1){break e}l=q[q[q[F+64>>2]+12>>2]+(l<<2)>>2];if((l|0)!=-1){break d}}q[a+8>>2]=-1;break c}s=l+1|0;l=(s>>>0)%3|0?s:l+ -2|0;q[a+8>>2]=l;if((l|0)!=-1){break b}}l=-1;s=q[a+4>>2];f:{if((s|0)==-1){break f}s=s+((s>>>0)%3|0?-1:2)|0;if((s|0)==-1|q[q[F>>2]+(s>>>3&536870908)>>2]>>>(s&31)&1){break f}F=q[q[q[F+64>>2]+12>>2]+(s<<2)>>2];if((F|0)==-1){break f}if((F>>>0)%3){l=F+ -1|0;break f}l=F+2|0}o[a+12|0]=0;q[a+8>>2]=l;return}if((l|0)!=q[a+4>>2]){break a}q[a+8>>2]=-1;return}s=-1;g:{if((l|0)==-1){break g}l=l+((l>>>0)%3|0?-1:2)|0;if((l|0)==-1|q[q[F>>2]+(l>>>3&536870908)>>2]>>>(l&31)&1){break g}l=q[q[q[F+64>>2]+12>>2]+(l<<2)>>2];if((l|0)==-1){break g}if((l>>>0)%3){s=l+ -1|0;break g}s=l+2|0}q[a+8>>2]=s}}function Vf(a,r,T,V){var ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0;q[a>>2]=3044;q[a+4>>2]=r;r=q[T+8>>2];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(V|0)){continue}break}}if((Aa|0)<1){break e}V=0;while(1){a=V<<2;Aa=q[a+Na>>2];Da=q[Ha>>2];g:{if((Aa|0)>(Da|0)){Ba=q[Ga>>2];q[a+Ba>>2]=Da;break g}Ba=q[Ga>>2];a=a+Ba|0;Da=q[Ea>>2];if((Aa|0)<(Da|0)){q[a>>2]=Da;break g}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}V=0;if((Aa|0)<1){break e}a=Ma<<2;Ma=a+T|0;Da=a+r|0;while(1){Aa=V<<2;a=Aa+Ma|0;Aa=q[Aa+Da>>2]+q[Aa+Ba>>2]|0;q[a>>2]=Aa;h:{if((Aa|0)>q[Ha>>2]){Aa=Aa-q[Ja>>2]|0}else{if((Aa|0)>=q[Ea>>2]){break h}Aa=Aa+q[Ja>>2]|0}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}break e}cn();F()}if((Aa|0)<1){break e}Da=(w(Ca+ -1|0,za)<<2)+T|0;V=0;while(1){a=V<<2;Aa=q[a+Da>>2];Ka=q[Ha>>2];i:{if((Aa|0)>(Ka|0)){Ba=q[Ga>>2];q[a+Ba>>2]=Ka;break i}Ba=q[Ga>>2];a=a+Ba|0;Ka=q[Ea>>2];if((Aa|0)<(Ka|0)){q[a>>2]=Ka;break i}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}V=0;if((Aa|0)<1){break e}a=Ma<<2;Ma=a+T|0;Da=a+r|0;while(1){Aa=V<<2;a=Aa+Ma|0;Aa=q[Aa+Da>>2]+q[Aa+Ba>>2]|0;q[a>>2]=Aa;j:{if((Aa|0)>q[Ha>>2]){Aa=Aa-q[Ja>>2]|0}else{if((Aa|0)>=q[Ea>>2]){break j}Aa=Aa+q[Ja>>2]|0}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}}Ca=Ca+1|0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kb=za<<2;lb=q[a+52>>2];Za=a+16|0;_a=a+32|0;Wa=a+8|0;bb=a+20|0;cb=a+12|0;Va=1;while(1){e:{f:{g:{if(fb>>>0>Va>>>0){Aa=q[(Va<<2)+eb>>2];hb=(za|0)<1;if(!hb){Dn($a,0,kb)}if((Aa|0)==-1){a=w(za,Va);break f}ib=q[gb+12>>2];Ya=0;V=Aa;while(1){a=q[ib+(V<<2)>>2];h:{if((a|0)==-1){break h}Ua=-1;ab=q[lb>>2];Sa=q[gb>>2];jb=q[ab+(q[Sa+(a<<2)>>2]<<2)>>2];Xa=a+1|0;Xa=(Xa>>>0)%3|0?Xa:a+ -2|0;if((Xa|0)!=-1){Xa=q[Sa+(Xa<<2)>>2]}else{Xa=-1}a=a+((a>>>0)%3|0?-1:2)|0;if((a|0)!=-1){Ua=q[Sa+(a<<2)>>2]}if((jb|0)>=(Va|0)){break h}a=q[(Xa<<2)+ab>>2];if((a|0)>=(Va|0)){break h}Sa=q[ab+(Ua<<2)>>2];if((Sa|0)>=(Va|0)){break h}i:{if(hb){break i}Ua=w(za,Sa);a=w(a,za);ab=w(za,jb);Sa=0;while(1){q[db+(Sa<<2)>>2]=(q[(Sa+Ua<<2)+T>>2]+q[(a+Sa<<2)+T>>2]|0)-q[(Sa+ab<<2)+T>>2];Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}Sa=0;if((za|0)<=0){break i}while(1){a=Sa<<2;Ua=a+$a|0;q[Ua>>2]=q[Ua>>2]+q[a+db>>2];Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}}Ya=Ya+1|0}V=((V>>>0)%3|0?-1:2)+V|0;a=-1;j:{if((V|0)==-1){break j}V=q[ib+(V<<2)>>2];a=-1;if((V|0)==-1){break j}a=V+ -1|0;if((V>>>0)%3){break j}a=V+2|0}V=(a|0)==(Aa|0)?-1:a;if((V|0)!=-1){continue}break}a=w(za,Va);if(!Ya){break f}Sa=0;if((za|0)<=0){break g}while(1){V=(Sa<<2)+$a|0;q[V>>2]=q[V>>2]/(Ya|0);Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}break g}cn();F()}if((Ta|0)<1){break e}Sa=0;while(1){V=Sa<<2;Aa=q[V+$a>>2];Ta=q[Za>>2];k:{if((Aa|0)>(Ta|0)){Ua=q[_a>>2];q[V+Ua>>2]=Ta;break k}Ua=q[_a>>2];V=V+Ua|0;Ta=q[cb>>2];if((Aa|0)<(Ta|0)){q[V>>2]=Ta;break k}q[V>>2]=Aa}Sa=Sa+1|0;Ta=q[Wa>>2];if((Sa|0)<(Ta|0)){continue}break}Aa=0;if((Ta|0)<1){break e}a=a<<2;Sa=a+T|0;Ya=a+r|0;while(1){V=Aa<<2;a=V+Sa|0;V=q[V+Ya>>2]+q[V+Ua>>2]|0;q[a>>2]=V;l:{if((V|0)>q[Za>>2]){V=V-q[bb>>2]|0}else{if((V|0)>=q[cb>>2]){break l}V=V+q[bb>>2]|0}q[a>>2]=V}Aa=Aa+1|0;Ta=q[Wa>>2];if((Aa|0)<(Ta|0)){continue}break}break e}if((Ta|0)<1){break e}Ya=(w(Va+ -1|0,za)<<2)+T|0;Sa=0;while(1){V=Sa<<2;Aa=q[V+Ya>>2];Ta=q[Za>>2];m:{if((Aa|0)>(Ta|0)){Ua=q[_a>>2];q[V+Ua>>2]=Ta;break m}Ua=q[_a>>2];V=V+Ua|0;Ta=q[cb>>2];if((Aa|0)<(Ta|0)){q[V>>2]=Ta;break m}q[V>>2]=Aa}Sa=Sa+1|0;Ta=q[Wa>>2];if((Sa|0)<(Ta|0)){continue}break}Aa=0;if((Ta|0)<1){break e}a=a<<2;Sa=a+T|0;Ya=a+r|0;while(1){V=Aa<<2;a=V+Sa|0;V=q[V+Ya>>2]+q[V+Ua>>2]|0;q[a>>2]=V;n:{if((V|0)>q[Za>>2]){V=V-q[bb>>2]|0}else{if((V|0)>=q[cb>>2]){break n}V=V+q[bb>>2]|0}q[a>>2]=V}Aa=Aa+1|0;Ta=q[Wa>>2];if((Aa|0)<(Ta|0)){continue}break}}Va=Va+1|0;if((Va|0)<(fb|0)){continue}break}}An(db);An($a);return 1}function Yf(a){a=a|0;var r=0;q[a>>2]=5324;r=q[a+96>>2];if(r){An(r)}r=q[a+84>>2];if(r){An(r)}r=q[a+72>>2];if(r){An(r)}r=q[a+60>>2];if(r){An(r)}q[a>>2]=3044;r=q[a+32>>2];if(r){q[a+36>>2]=r;An(r)}return a|0}function Zf(a){a=a|0;var T=0;q[a>>2]=5324;T=q[a+96>>2];if(T){An(T)}T=q[a+84>>2];if(T){An(T)}T=q[a+72>>2];if(T){An(T)}T=q[a+60>>2];if(T){An(T)}q[a>>2]=3044;T=q[a+32>>2];if(T){q[a+36>>2]=T;An(T)}An(a)}function _f(a,V,za,Aa,mb,nb){a=a|0;V=V|0;za=za|0;Aa=Aa|0;mb=mb|0;nb=nb|0;var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0,Hb=0,Ib=0,Jb=0,Kb=0,Lb=0,Mb=0;qb=T+ -64|0;T=qb;q[a+8>>2]=mb;nb=a+32|0;rb=q[nb>>2];Aa=q[a+36>>2]-rb>>2;a:{if(Aa>>>0>>0){Fa(nb,mb-Aa|0);break a}if(Aa>>>0<=mb>>>0){break a}q[a+36>>2]=rb+(mb<<2)}q[qb+56>>2]=0;q[qb+60>>2]=0;q[qb+48>>2]=0;q[qb+52>>2]=0;q[qb+40>>2]=0;q[qb+44>>2]=0;Aa=qb+32|0;q[Aa>>2]=0;q[Aa+4>>2]=0;q[qb+24>>2]=0;q[qb+28>>2]=0;q[qb+16>>2]=0;q[qb+20>>2]=0;q[qb>>2]=0;nb=0;if(mb){Ad(qb+16|0,mb,qb);pb=q[qb+28>>2];nb=q[Aa>>2]}q[qb>>2]=0;Aa=nb-pb>>2;b:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break b}q[qb+32>>2]=(mb<<2)+pb;break b}Ad(qb+16|12,mb-Aa|0,qb)}q[qb>>2]=0;nb=q[qb+40>>2];Aa=q[qb+44>>2]-nb>>2;c:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break c}q[qb+44>>2]=nb+(mb<<2);break c}Ad(qb+40|0,mb-Aa|0,qb)}q[qb>>2]=0;nb=q[qb+52>>2];Aa=q[qb+56>>2]-nb>>2;d:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break d}q[qb+56>>2]=nb+(mb<<2);break d}Ad(qb+52|0,mb-Aa|0,qb)}tb=a+8|0;e:{if(q[tb>>2]<=0){break e}vb=q[qb+16>>2];pb=0;sb=a+16|0;Aa=a+32|0;Ab=a+12|0;while(1){nb=pb<<2;ob=q[nb+vb>>2];wb=q[sb>>2];f:{if((ob|0)>(wb|0)){rb=q[Aa>>2];q[nb+rb>>2]=wb;break f}rb=q[Aa>>2];nb=nb+rb|0;wb=q[Ab>>2];if((ob|0)<(wb|0)){q[nb>>2]=wb;break f}q[nb>>2]=ob}pb=pb+1|0;nb=q[tb>>2];if((pb|0)<(nb|0)){continue}break}if((nb|0)<1){break e}nb=0;tb=a+16|0;pb=a+20|0;vb=a+8|0;sb=a+12|0;while(1){ob=nb<<2;Aa=ob+za|0;ob=q[V+ob>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;g:{if((ob|0)>q[tb>>2]){ob=ob-q[pb>>2]|0}else{if((ob|0)>=q[sb>>2]){break g}ob=ob+q[pb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}}Lb=q[a+52>>2];Ib=q[a+48>>2];Hb=Mm(16);Aa=Hb;q[Aa>>2]=0;q[Aa+4>>2]=0;q[Aa+8>>2]=0;q[Aa+12>>2]=0;q[qb+8>>2]=0;q[qb>>2]=0;q[qb+4>>2]=0;h:{if(mb){if(mb>>>0>=1073741824){break h}Aa=mb<<2;Bb=Mm(Aa);q[qb>>2]=Bb;nb=Aa+Bb|0;q[qb+8>>2]=nb;Dn(Bb,0,Aa);q[qb+4>>2]=nb}rb=1;Aa=q[a+56>>2];Jb=q[Aa>>2];Aa=q[Aa+4>>2]-Jb|0;i:{if((Aa|0)<5){break i}Kb=Aa>>2;Mb=mb<<2;vb=a+8|0;Ab=a+16|0;wb=a+32|0;Eb=a+20|0;Fb=a+12|0;tb=1;while(1){j:{k:{l:{if(Kb>>>0>tb>>>0){m:{n:{rb=q[(tb<<2)+Jb>>2];if((rb|0)==-1){break n}ub=q[Ib+12>>2];Db=rb+((rb>>>0)%3|0?-1:2)|0;Gb=ub+(Db<<2)|0;sb=1;nb=0;Aa=rb;o:{while(1){ob=q[ub+(Aa<<2)>>2];p:{if((ob|0)==-1){break p}pb=-1;zb=q[Lb>>2];xb=q[Ib>>2];Cb=q[zb+(q[xb+(ob<<2)>>2]<<2)>>2];yb=ob+1|0;yb=(yb>>>0)%3|0?yb:ob+ -2|0;if((yb|0)!=-1){yb=q[xb+(yb<<2)>>2]}else{yb=-1}ob=ob+((ob>>>0)%3|0?-1:2)|0;if((ob|0)!=-1){pb=q[xb+(ob<<2)>>2]}if((Cb|0)>=(tb|0)){break p}ob=q[(yb<<2)+zb>>2];if((ob|0)>=(tb|0)){break p}pb=q[zb+(pb<<2)>>2];if((pb|0)>=(tb|0)){break p}xb=q[(qb+16|0)+w(nb,12)>>2];if((mb|0)>=1){zb=w(mb,pb);ob=w(mb,ob);Cb=w(mb,Cb);pb=0;while(1){q[xb+(pb<<2)>>2]=(q[(pb+zb<<2)+za>>2]+q[(ob+pb<<2)+za>>2]|0)-q[(pb+Cb<<2)+za>>2];pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}ob=4;nb=nb+1|0;if((nb|0)==4){break o}}q:{if(sb&1){xb=Aa+1|0;Aa=(xb>>>0)%3|0?xb:Aa+ -2|0;ob=-1;if((Aa|0)==-1){break q}Aa=q[ub+(Aa<<2)>>2];ob=-1;if((Aa|0)==-1){break q}ob=Aa+1|0;ob=(ob>>>0)%3|0?ob:Aa+ -2|0;break q}Aa=((Aa>>>0)%3|0?-1:2)+Aa|0;ob=-1;if((Aa|0)==-1){break q}Aa=q[ub+(Aa<<2)>>2];ob=-1;if((Aa|0)==-1){break q}ob=Aa+ -1|0;if((Aa>>>0)%3){break q}ob=Aa+2|0}r:{if((ob|0)==(rb|0)){break r}Aa=ob;ob=(ob|0)!=-1;pb=(ob|sb^-1)&1;Aa=pb?Aa:-1;sb=ob&sb;if(!((Db|0)==-1|pb)){ob=q[Gb>>2];if((ob|0)==-1){break r}sb=0;if((ob>>>0)%3){Aa=ob+ -1|0}else{Aa=ob+2|0}}if((Aa|0)!=-1){continue}}break}ob=nb;if((ob|0)<1){break n}}ub=(mb|0)<1;if(!ub){Dn(Bb,0,Mb)}Aa=ob+ -1|0;sb=(Aa<<2)+Hb|0;Aa=w(Aa,12)+a|0;xb=Aa+60|0;zb=q[Aa- -64>>2];rb=0;Cb=q[qb>>2];Aa=0;nb=0;while(1){pb=q[sb>>2];q[sb>>2]=pb+1;if(zb>>>0<=pb>>>0){break i}s:{if(q[q[xb>>2]+(pb>>>3&536870908)>>2]>>>(pb&31)&1){break s}nb=nb+1|0;if(ub){break s}yb=q[(qb+16|0)+w(Aa,12)>>2];pb=0;while(1){Db=pb<<2;Gb=Db+Cb|0;q[Gb>>2]=q[Gb>>2]+q[yb+Db>>2];pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}Aa=Aa+1|0;if((ob|0)!=(Aa|0)){continue}break}ob=w(mb,tb);Aa=ob;if(!nb){break m}pb=0;if((mb|0)>0){break l}break k}Aa=w(mb,tb)}if(q[vb>>2]<1){break j}sb=(w(tb+ -1|0,mb)<<2)+za|0;pb=0;while(1){nb=pb<<2;ob=q[nb+sb>>2];ub=q[Ab>>2];t:{if((ob|0)>(ub|0)){rb=q[wb>>2];q[nb+rb>>2]=ub;break t}rb=q[wb>>2];nb=nb+rb|0;ub=q[Fb>>2];if((ob|0)<(ub|0)){q[nb>>2]=ub;break t}q[nb>>2]=ob}pb=pb+1|0;ob=q[vb>>2];if((pb|0)<(ob|0)){continue}break}nb=0;if((ob|0)<1){break j}Aa=Aa<<2;pb=Aa+za|0;sb=V+Aa|0;while(1){ob=nb<<2;Aa=ob+pb|0;ob=q[ob+sb>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;u:{if((ob|0)>q[Ab>>2]){ob=ob-q[Eb>>2]|0}else{if((ob|0)>=q[Fb>>2]){break u}ob=ob+q[Eb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}break j}cn();F()}while(1){Aa=(pb<<2)+Bb|0;q[Aa>>2]=q[Aa>>2]/(nb|0);pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}if(q[vb>>2]<1){break j}pb=0;while(1){Aa=pb<<2;nb=q[Aa+Bb>>2];sb=q[Ab>>2];v:{if((nb|0)>(sb|0)){rb=q[wb>>2];q[Aa+rb>>2]=sb;break v}rb=q[wb>>2];Aa=Aa+rb|0;sb=q[Fb>>2];if((nb|0)<(sb|0)){q[Aa>>2]=sb;break v}q[Aa>>2]=nb}pb=pb+1|0;Aa=q[vb>>2];if((pb|0)<(Aa|0)){continue}break}nb=0;if((Aa|0)<1){break j}Aa=ob<<2;pb=Aa+za|0;sb=V+Aa|0;while(1){ob=nb<<2;Aa=ob+pb|0;ob=q[ob+sb>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;w:{if((ob|0)>q[Ab>>2]){ob=ob-q[Eb>>2]|0}else{if((ob|0)>=q[Fb>>2]){break w}ob=ob+q[Eb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}}rb=1;tb=tb+1|0;if((tb|0)<(Kb|0)){continue}break}}a=q[qb>>2];if(a){q[qb+4>>2]=a;An(a)}An(Hb);a=q[qb+52>>2];if(a){q[qb+56>>2]=a;An(a)}a=q[qb+40>>2];if(a){q[qb+44>>2]=a;An(a)}a=q[qb+28>>2];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ec*fc)+x(0))+x(gc*oc))+x(hc*nc))/qc);hc=x(nc-x(hc*bc));gc=x(oc-x(gc*bc));ec=x(fc-x(ec*bc));ic=x(E(x(x(x(hc*hc)+x(x(gc*gc)+x(x(ec*ec)+x(0))))/qc)))}fc=ic;nb=a+80|0;mb=q[nb>>2]+ -1|0;Nb=q[q[a+76>>2]+(mb>>>3&536870908)>>2];q[nb>>2]=mb;ec=x(dc-jc);ic=x(x(ec*bc)+jc);jc=x(mc-pc);dc=x(jc*fc);mb=Nb>>>(mb&31)&1;dc=x(ic+(mb?dc:x(-dc)));ic=x(x(jc*bc)+pc);bc=x(ec*fc);bc=x(ic+(mb?x(-bc):bc));e:{if(((k(bc),e(0))&2147483647)>>>0>=2139095041){mb=q[a+68>>2];q[mb>>2]=-2147483648;break e}mb=q[a+68>>2];a=mb;lc=C(+bc+.5);f:{if(y(lc)<2147483648){nb=~~lc;break f}nb=-2147483648}q[a>>2]=nb}nb=((k(dc),e(0))&2147483647)>>>0>2139095040;lc=C(+dc+.5);g:{if(y(lc)<2147483648){a=~~lc;break g}a=-2147483648}q[mb+4>>2]=nb?-2147483648:a;break b}h:{if(!kc){mb=q[a+72>>2];Nb=w(Pb,mb);break h}if((Nb|0)<=0){if(q[a+72>>2]<1){break b}nb=q[a+68>>2];mb=0;while(1){q[nb+(mb<<2)>>2]=0;mb=mb+1|0;if((mb|0)>2]){continue}break}break b}mb=q[a+72>>2];Nb=w(mb,Nb+ -1|0)}if((mb|0)<1){break b}Pb=q[a+68>>2];mb=0;while(1){q[Pb+(mb<<2)>>2]=q[(mb+Nb<<2)+nb>>2];mb=mb+1|0;if((mb|0)>2]){continue}break}}T=Ob+48|0;return}cn();F()}function dg(a){a=a|0;var mb=0;q[a>>2]=5776;mb=q[a+76>>2];if(mb){An(mb)}q[a>>2]=3044;mb=q[a+32>>2];if(mb){q[a+36>>2]=mb;An(mb)}return a|0}function eg(a){a=a|0;var nb=0;q[a>>2]=5776;nb=q[a+76>>2];if(nb){An(nb)}q[a>>2]=3044;nb=q[a+32>>2];if(nb){q[a+36>>2]=nb;An(nb)}An(a)}function fg(a,Nb,vc,wc,xc,yc){a=a|0;Nb=Nb|0;vc=vc|0;wc=wc|0;xc=xc|0;yc=yc|0;var zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0,Fc=0,Gc=0,Hc=0,Ic=0,Jc=0,Kc=0;wc=0;a:{if((xc|0)!=2){break a}q[a+8>>2]=2;q[a- -64>>2]=yc;wc=a+32|0;xc=q[wc>>2];yc=q[a+36>>2]-xc|0;zc=yc>>2;b:{if(zc>>>0<=1){Fa(wc,2-zc|0);break b}if((yc|0)==8){break b}q[a+36>>2]=xc+8}wc=1;xc=q[a+56>>2];yc=q[xc+4>>2];xc=q[xc>>2];zc=yc-xc|0;if((zc|0)<1){break a}if((xc|0)!=(yc|0)){Hc=a+60|0;Ic=zc>>2;zc=a+8|0;Dc=a+16|0;Ec=a+32|0;Fc=a+20|0;Gc=a+12|0;Jc=a+56|0;while(1){if(!gg(Hc,q[(Bc<<2)+xc>>2],vc,Bc)){wc=0;break a}c:{if(q[zc>>2]<1){break c}xc=0;while(1){wc=xc<<2;yc=q[(wc+a|0)+68>>2];Ac=q[Dc>>2];d:{if((yc|0)>(Ac|0)){Cc=q[Ec>>2];q[wc+Cc>>2]=Ac;break d}Cc=q[Ec>>2];wc=wc+Cc|0;Ac=q[Gc>>2];if((yc|0)<(Ac|0)){q[wc>>2]=Ac;break d}q[wc>>2]=yc}xc=xc+1|0;wc=q[zc>>2];if((xc|0)<(wc|0)){continue}break}yc=0;if((wc|0)<1){break c}wc=Bc<<3;Ac=wc+vc|0;Kc=Nb+wc|0;while(1){xc=yc<<2;wc=xc+Ac|0;xc=q[xc+Kc>>2]+q[xc+Cc>>2]|0;q[wc>>2]=xc;e:{if((xc|0)>q[Dc>>2]){xc=xc-q[Fc>>2]|0}else{if((xc|0)>=q[Gc>>2]){break e}xc=xc+q[Fc>>2]|0}q[wc>>2]=xc}yc=yc+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32>>2];if(Nb){q[a+36>>2]=Nb;An(Nb)}return a|0}function ig(a){a=a|0;var vc=0;q[a>>2]=6e3;q[a>>2]=3044;vc=q[a+32>>2];if(vc){q[a+36>>2]=vc;An(vc)}An(a)}function jg(a,wc,gd,hd,id,jd){a=a|0;wc=wc|0;gd=gd|0;hd=hd|0;id=id|0;jd=jd|0;var kd=0,ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0,yd=0;ld=T-32|0;T=ld;q[a+68>>2]=jd;hd=q[a+56>>2];id=q[hd>>2];jd=hd+4|0;kd=q[jd>>2];q[ld+24>>2]=0;q[ld+16>>2]=0;q[ld+20>>2]=0;a:{id=kd-id|0;if((id|0)<1){break a}hd=q[hd>>2];if((hd|0)!=q[jd>>2]){vd=id>>2;wd=a+60|0;xd=a+108|0;qd=a+8|0;rd=a+16|0;sd=a+32|0;td=a+20|0;ud=a+12|0;yd=a+56|0;while(1){kg(wd,q[(od<<2)+hd>>2],ld+16|0);id=q[ld+20>>2];kd=id>>31;jd=q[ld+16>>2];md=jd>>31;pd=q[ld+24>>2];nd=pd>>31;hd=0;nd=nd^nd+pd;kd=nd+((kd^id+kd)+(md^jd+md)|0)|0;if(kd>>>0>>0){hd=1}b:{if(!(hd|kd)){q[ld+16>>2]=q[a+104>>2];break b}md=q[a+104>>2];nd=md>>31;id=ao($n(md,nd,id,id>>31),V,kd,hd);q[ld+20>>2]=id;hd=ao($n(md,nd,jd,jd>>31),V,kd,hd);q[ld+16>>2]=hd;jd=hd;hd=hd>>31;hd=(md-(jd+hd^hd)|0)+((id|0)<0?id:0-id|0)|0;if((pd|0)>=0){q[ld+24>>2]=hd;break b}q[ld+24>>2]=0-hd}hd=dh(xd);jd=q[ld+16>>2];c:{if(!hd){id=q[ld+20>>2];break c}q[ld+24>>2]=0-q[ld+24>>2];id=0-q[ld+20>>2]|0;q[ld+20>>2]=id;jd=0-jd|0;q[ld+16>>2]=jd}d:{if((jd|0)>=0){hd=q[a+104>>2];jd=hd+q[ld+24>>2]|0;hd=hd+id|0;break d}e:{if((id|0)<=-1){jd=q[ld+24>>2];hd=jd>>31;hd=hd^hd+jd;break e}jd=q[ld+24>>2];hd=jd>>31;hd=q[a+100>>2]-(hd^hd+jd)|0}if((jd|0)<=-1){jd=id;id=id>>31;jd=jd+id^id;break d}jd=id;id=id>>31;jd=q[a+100>>2]-(jd+id^id)|0}id=q[a+100>>2];f:{if(!(hd|jd)){jd=id;hd=id;break f}if(!((id|0)!=(jd|0)|hd)){hd=jd;break f}if(!((hd|0)!=(id|0)|jd)){jd=hd;break f}g:{if(hd){break g}kd=q[a+104>>2];if((kd|0)>=(jd|0)){break g}jd=(kd<<1)-jd|0;hd=0;break f}h:{if((hd|0)!=(id|0)){break h}kd=q[a+104>>2];if((kd|0)<=(jd|0)){break h}jd=(kd<<1)-jd|0;break f}i:{if((id|0)!=(jd|0)){break i}id=q[a+104>>2];if((id|0)<=(hd|0)){break i}hd=(id<<1)-hd|0;break f}if(jd){break f}jd=0;id=q[a+104>>2];if((id|0)>=(hd|0)){break f}hd=(id<<1)-hd|0}q[ld+12>>2]=jd;q[ld+8>>2]=hd;j:{if(q[qd>>2]<1){break j}jd=0;while(1){kd=q[rd>>2];k:{if((hd|0)>(kd|0)){id=q[sd>>2];q[id+(jd<<2)>>2]=kd;break k}id=q[sd>>2];kd=id+(jd<<2)|0;md=q[ud>>2];if((hd|0)<(md|0)){q[kd>>2]=md;break k}q[kd>>2]=hd}jd=jd+1|0;kd=q[qd>>2];if((jd|0)<(kd|0)){hd=q[(ld+8|0)+(jd<<2)>>2];continue}break}hd=0;if((kd|0)<1){break j}jd=od<<3;md=jd+gd|0;pd=wc+jd|0;while(1){kd=hd<<2;jd=kd+md|0;kd=q[kd+pd>>2]+q[id+kd>>2]|0;q[jd>>2]=kd;l:{if((kd|0)>q[rd>>2]){nd=kd-q[td>>2]|0}else{if((kd|0)>=q[ud>>2]){break l}nd=kd+q[td>>2]|0}q[jd>>2]=nd}hd=hd+1|0;if((hd|0)>2]){continue}break}}od=od+1|0;if((od|0)>=(vd|0)){break a}id=q[yd>>2];hd=q[id>>2];if(q[id+4>>2]-hd>>2>>>0>od>>>0){continue}break}}cn();F()}T=ld+32|0;return 1}function kg(a,wc,gd){a=a|0;wc=wc|0;gd=gd|0;var hd=0,id=0,jd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0,Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0,Od=0,Pd=0,Qd=0,Rd=0,Sd=0,Td=0,Ud=0,Vd=0;jd=T-96|0;T=jd;id=q[a+16>>2];o[jd+92|0]=1;q[jd+88>>2]=wc;q[jd+84>>2]=wc;q[jd+80>>2]=id;hd=-1;hd=(wc|0)!=-1?q[q[id>>2]+(wc<<2)>>2]:hd;zd=q[a+20>>2];id=q[zd>>2];a:{b:{c:{d:{if(q[zd+4>>2]-id>>2>>>0>hd>>>0){id=q[q[a+8>>2]+(q[id+(hd<<2)>>2]<<2)>>2];hd=q[a+4>>2];if(!r[hd+84|0]){id=q[q[hd+68>>2]+(id<<2)>>2]}q[jd+72>>2]=0;q[jd+76>>2]=0;zd=jd- -64|0;q[zd>>2]=0;q[zd+4>>2]=0;q[jd+56>>2]=0;q[jd+60>>2]=0;Kf(hd,id,o[hd+24|0],jd+56|0);if((wc|0)==-1){break a}hd=wc+1|0;zd=(hd>>>0)%3|0?hd:wc+ -2|0;Jd=((wc>>>0)%3|0?-1:2)+wc|0;Qd=a+28|0;Ad=!q[Qd>>2];Rd=a+20|0;Sd=a+8|0;Td=jd+48|0;while(1){id=zd;hd=Jd;e:{if(Ad){break e}hd=wc+1|0;id=(hd>>>0)%3|0?hd:wc+ -2|0;hd=wc+ -1|0;if((wc>>>0)%3){break e}hd=wc+2|0}wc=-1;wc=(id|0)!=-1?q[q[q[a+16>>2]>>2]+(id<<2)>>2]:wc;Ad=q[Rd>>2];id=q[Ad>>2];if(q[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F()}cn();F()}cn();F()}if((a|0)<0?1:(a|0)<=0?hd>>>0>=536870913?0:1:0){break a}wc=a>>>29;a=(a&536870911)<<3|hd>>>29;Bd=ao(Bd,Ed,a,wc);Cd=ao(Cd,Hd,a,wc);Fd=ao(Fd,Id,a,wc)}q[gd+8>>2]=Bd;q[gd+4>>2]=Cd;q[gd>>2]=Fd;T=jd+96|0}function lg(a){var wc=0,gd=0,Wd=0;wc=q[a+8>>2];Wd=q[a>>2];a:{if(r[a+12|0]){b:{c:{d:{e:{if((wc|0)==-1){break e}gd=wc+1|0;wc=(gd>>>0)%3|0?gd:wc+ -2|0;if((wc|0)==-1){break e}wc=q[q[Wd+12>>2]+(wc<<2)>>2];if((wc|0)!=-1){break d}}q[a+8>>2]=-1;break c}gd=wc+1|0;wc=(gd>>>0)%3|0?gd:wc+ -2|0;q[a+8>>2]=wc;if((wc|0)!=-1){break b}}gd=q[a+4>>2];wc=-1;f:{if((gd|0)==-1){break f}gd=gd+((gd>>>0)%3|0?-1:2)|0;wc=-1;if((gd|0)==-1){break f}gd=q[q[Wd+12>>2]+(gd<<2)>>2];wc=-1;if((gd|0)==-1){break f}wc=gd+ -1|0;if((gd>>>0)%3){break f}wc=gd+2|0}o[a+12|0]=0;q[a+8>>2]=wc;return}if((wc|0)!=q[a+4>>2]){break a}q[a+8>>2]=-1;return}gd=-1;g:{if((wc|0)==-1){break g}wc=wc+((wc>>>0)%3|0?-1:2)|0;gd=-1;if((wc|0)==-1){break g}wc=q[q[Wd+12>>2]+(wc<<2)>>2];gd=-1;if((wc|0)==-1){break g}gd=wc+ -1|0;if((wc>>>0)%3){break g}gd=wc+2|0}q[a+8>>2]=gd}}function mg(a,Xd,Yd,Zd,_d,$d){a=a|0;Xd=Xd|0;Yd=Yd|0;Zd=Zd|0;_d=_d|0;$d=$d|0;var ae=0,be=0,ce=0,de=0,ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0,ne=0;q[a+8>>2]=_d;be=a+32|0;ae=q[be>>2];$d=q[a+36>>2]-ae>>2;a:{if($d>>>0<_d>>>0){Fa(be,_d-$d|0);break a}if($d>>>0<=_d>>>0){break a}q[a+36>>2]=ae+(_d<<2)}be=0;$d=(_d&1073741823)!=(_d|0)?-1:_d<<2;ke=Dn(Mm($d),0,$d);ee=a+8|0;ae=q[ee>>2];b:{if((ae|0)<1){break b}ge=a+16|0;$d=a+32|0;he=a+12|0;while(1){ae=be<<2;de=q[ae+ke>>2];ce=q[ge>>2];c:{if((de|0)>(ce|0)){fe=q[$d>>2];q[ae+fe>>2]=ce;break c}fe=q[$d>>2];ae=ae+fe|0;ce=q[he>>2];if((de|0)<(ce|0)){q[ae>>2]=ce;break c}q[ae>>2]=de}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}if((ae|0)<1){break b}be=0;ee=a+16|0;de=a+20|0;ge=a+8|0;he=a+12|0;while(1){ae=be<<2;$d=ae+Yd|0;ae=q[Xd+ae>>2]+q[ae+fe>>2]|0;q[$d>>2]=ae;d:{if((ae|0)>q[ee>>2]){ae=ae-q[de>>2]|0}else{if((ae|0)>=q[he>>2]){break d}ae=ae+q[de>>2]|0}q[$d>>2]=ae}be=be+1|0;ae=q[ge>>2];if((be|0)<(ae|0)){continue}break}}if((_d|0)<(Zd|0)){me=0-_d<<2;de=a+16|0;fe=a+32|0;ee=a+8|0;ge=a+20|0;he=a+12|0;$d=_d;while(1){e:{if((ae|0)<1){break e}je=$d<<2;le=je+Yd|0;ne=le+me|0;be=0;while(1){a=be<<2;ae=q[a+ne>>2];ie=q[de>>2];f:{if((ae|0)>(ie|0)){ce=q[fe>>2];q[a+ce>>2]=ie;break f}ce=q[fe>>2];a=a+ce|0;ie=q[he>>2];if((ae|0)<(ie|0)){q[a>>2]=ie;break f}q[a>>2]=ae}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}be=0;if((ae|0)<1){break e}je=Xd+je|0;while(1){ae=be<<2;a=ae+le|0;ae=q[ae+je>>2]+q[ae+ce>>2]|0;q[a>>2]=ae;g:{if((ae|0)>q[de>>2]){ae=ae-q[ge>>2]|0}else{if((ae|0)>=q[he>>2]){break g}ae=ae+q[ge>>2]|0}q[a>>2]=ae}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}}$d=_d+$d|0;if(($d|0)<(Zd|0)){continue}break}}An(ke);return 1}function ng(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var Zd=0;a:{if(!Se(a,Xd,Yd)){break a}a=q[a+8>>2];if(r[a+24|0]!=3){break a}Zd=q[a+28>>2]==9}return Zd|0}function og(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var _d=0,$d=0,oe=0,pe=0,qe=0;a:{if(r[q[a+4>>2]+36|0]<=1){_d=q[Yd+16>>2];$d=q[Yd+12>>2];oe=q[Yd+20>>2];qe=oe;pe=0;if(($d|0)<(qe|0)?1:($d|0)<=(qe|0)?t[Yd+8>>2]>_d>>>0?0:1:0){break a}$d=r[_d+q[Yd>>2]|0];_d=_d+1|0;if(_d>>>0<1){oe=oe+1|0}q[Yd+16>>2]=_d;q[Yd+20>>2]=oe;q[a+24>>2]=$d}pe=Xe(a,Xd,Yd)}return pe|0}function pg(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var re=0,se=0,te=0,ue=0,ve=0;re=T-16|0;T=re;a:{b:{if(r[q[a+4>>2]+36|0]<=1){Xd=q[a+24>>2];break b}ue=q[Yd+16>>2];se=q[Yd+12>>2];te=q[Yd+20>>2];Xd=te;ve=0;if((se|0)<(Xd|0)?1:(se|0)<=(Xd|0)?t[Yd+8>>2]>ue>>>0?0:1:0){break a}Xd=r[ue+q[Yd>>2]|0];se=ue+1|0;if(se>>>0<1){te=te+1|0}q[Yd+16>>2]=se;q[Yd+20>>2]=te;q[a+24>>2]=Xd}q[re+12>>2]=-1;q[re+8>>2]=1116;q[(re+8|0)+4>>2]=Xd;ve=ld(re+8|0,q[a+16>>2])}a=ve;T=re+16|0;return a|0}function qg(a,Xd){a=a|0;Xd=Xd|0;var Yd=0,we=0,xe=0,ye=0,ze=0,Ae=x(0),Be=0,Ce=0;we=T-32|0;T=we;ye=o[q[a+8>>2]+24|0];Yd=q[a+16>>2];if(q[Yd+80>>2]){ze=q[q[Yd>>2]>>2]+q[Yd+48>>2]|0}q[we+8>>2]=-1;q[we+12>>2]=-1;q[we>>2]=-1;q[we+4>>2]=-1;a:{Yd=q[a+24>>2];if(Yd+ -2>>>0>28){break a}q[we>>2]=Yd;Yd=-1<>2]=xe;q[we+4>>2]=Yd^-1;q[we+12>>2]=(xe|0)/2;if(!Xd){xe=1;break a}ye=ye<<2;Yd=0;Ce=a+8|0;a=0;while(1){Ae=x(x(1)/x(xe|0));xe=Yd<<2;rg(x(Ae*x(q[xe+ze>>2])),x(Ae*x(q[(xe|4)+ze>>2])),we+20|0);Cn(q[q[q[Ce>>2]- -64>>2]>>2]+a|0,we+20|0,ye);xe=1;Be=Be+1|0;if((Be|0)==(Xd|0)){break a}Yd=Yd+2|0;a=a+ye|0;xe=q[we+8>>2];continue}}T=we+32|0;return xe|0}function rg(a,Xd,De){var Ee=0,Fe=0,Ge=x(0),He=x(0),Ie=x(0),Je=0,Ke=0;Ge=x(a+Xd);a:{b:{Ie=x(a-Xd);if(Ie<=x(.5)^1|Ie>=x(-.5)^1|Ge>=x(.5)^1){break b}Fe=1;if(!(Ge<=x(1.5))){break b}He=Xd;break a}c:{if(!!(Ge<=x(.5))){He=x(x(.5)-a);a=x(x(.5)-Xd);break c}if(!!(Ge>=x(1.5))){He=x(x(1.5)-a);a=x(x(1.5)-Xd);break c}if(!!(Ie<=x(-.5))){He=x(a+x(.5));a=x(Xd+x(-.5));break c}He=x(a+x(-.5));a=x(Xd+x(.5))}Ie=x(a-He);Ge=x(He+a);Fe=-1}Ee=+He;Xd=x(Ee+Ee+ -1);Ee=+a;a=x(Ee+Ee+ -1);Ke=Fe;Fe=+Ie;Fe=Fe+Fe;Ee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q[Xd+36>>2]=Qe;q[Xd+32>>2]=Le;q[Xd+28>>2]=We;q[Xd+24>>2]=Ve;q[Xd+64>>2]=Qe;q[Xd+60>>2]=Le;q[Xd+56>>2]=We;q[Xd+52>>2]=Ve;q[Xd+44>>2]=0;q[Xd+48>>2]=0;q[Xd>>2]=9748;q[Xd+72>>2]=-1;q[Xd+76>>2]=-1;q[Xd+68>>2]=1;q[Xd+40>>2]=10168;break a}q[a>>2]=0}q[a>>2]=0;return}q[Xd+80>>2]=-1;q[Xd+84>>2]=-1;ah(Xd+88|0);q[a>>2]=Xd}function vg(a){a=a|0;q[a>>2]=6860;return a|0}function wg(a){a=a|0;q[a>>2]=6860;An(a)}function xg(a){a=a|0;var Xd=0;a:{if(!q[a+44>>2]|!q[a+48>>2]|(!q[a+24>>2]|!q[a+28>>2])){break a}if(!q[a+32>>2]|!q[a+36>>2]){break a}Xd=q[a+72>>2]!=-1}return Xd|0}function yg(a,De){a=a|0;De=De|0;var Le=0;if(!(q[De+56>>2]|r[De+24|0]!=3)){q[a+44>>2]=De;Le=1}return Le|0}function zg(a,De){a=a|0;De=De|0;var Pe=0,Qe=0,Ze=0,_e=0,$e=0,af=0,bf=0,cf=0,df=0,ef=0,ff=0;$e=q[De+12>>2];Pe=$e;Qe=q[De+20>>2];Ze=Qe;af=q[De+16>>2];_e=af+4|0;if(_e>>>0<4){Qe=Qe+1|0}bf=q[De+8>>2];a:{if((Pe|0)<(Qe|0)?1:(Pe|0)<=(Qe|0)?bf>>>0>=_e>>>0?0:1:0){break a}cf=q[De>>2];Pe=af+cf|0;df=r[Pe|0]|r[Pe+1|0]<<8|(r[Pe+2|0]<<16|r[Pe+3|0]<<24);q[De+16>>2]=_e;q[De+20>>2]=Qe;ef=s[De+38>>1];if(ef>>>0<=513){Pe=$e;Qe=Ze;Ze=af+8|0;if(Ze>>>0<8){Qe=Qe+1|0}_e=Ze;if((Pe|0)<(Qe|0)?1:(Pe|0)<=(Qe|0)?bf>>>0>=_e>>>0?0:1:0){break a}q[De+16>>2]=_e;q[De+20>>2]=Qe}if(!(df&1)){break a}Pe=z(df)^31;if(Pe+ -1>>>0>28){break a}q[a+8>>2]=Pe+1;Pe=-2<>2]=Ze;q[a+12>>2]=Pe^-1;q[a+20>>2]=(Ze|0)/2;if(ef>>>0<=513){if(($e|0)<(Qe|0)?1:($e|0)<=(Qe|0)?bf>>>0>_e>>>0?0:1:0){break a}Pe=r[_e+cf|0];Ze=_e+1|0;if(Ze>>>0<1){Qe=Qe+1|0}q[De+16>>2]=Ze;q[De+20>>2]=Qe;if(Pe>>>0>1){break a}q[a+68>>2]=Pe-1|0?0:1}ff=bh(a+88|0,De)}return ff|0}function Ag(a,De,gf,hf,jf,kf){a=a|0;De=De|0;gf=gf|0;hf=hf|0;jf=jf|0;kf=kf|0;var lf=0,mf=0,nf=0,of=0,pf=0,qf=0,rf=0,sf=0,tf=0,uf=0,vf=0;lf=T-48|0;T=lf;rf=a+8|0;hf=q[rf>>2];if(hf+ -2>>>0<=28){q[a+72>>2]=hf;hf=-1<>2]=jf;q[a+76>>2]=hf^-1;q[a+84>>2]=(jf|0)/2}q[a+48>>2]=kf;hf=q[a+36>>2];jf=q[hf>>2];kf=hf+4|0;mf=q[kf>>2];q[lf+16>>2]=0;q[lf+8>>2]=0;q[lf+12>>2]=0;a:{jf=mf-jf|0;if((jf|0)<1){break a}hf=q[hf>>2];if((hf|0)!=q[kf>>2]){sf=jf>>2;tf=a+40|0;uf=a+88|0;vf=a+36|0;while(1){Sf(tf,q[(pf<<2)+hf>>2],lf+8|0);jf=q[lf+12>>2];mf=jf>>31;kf=q[lf+8>>2];of=kf>>31;qf=q[lf+16>>2];nf=qf>>31;hf=0;nf=nf^nf+qf;mf=nf+((mf^jf+mf)+(of^kf+of)|0)|0;if(mf>>>0>>0){hf=1}b:{if(!(hf|mf)){q[lf+8>>2]=q[a+84>>2];break b}of=q[a+84>>2];nf=of;nf=nf>>31;jf=ao($n(of,nf,jf,jf>>31),V,mf,hf);q[lf+12>>2]=jf;hf=ao($n(of,nf,kf,kf>>31),V,mf,hf);q[lf+8>>2]=hf;kf=hf;hf=hf>>31;hf=(of-(kf+hf^hf)|0)+((jf|0)<0?jf:0-jf|0)|0;if((qf|0)>=0){q[lf+16>>2]=hf;break b}q[lf+16>>2]=0-hf}hf=dh(uf);kf=q[lf+8>>2];c:{if(!hf){jf=q[lf+12>>2];break c}q[lf+16>>2]=0-q[lf+16>>2];jf=0-q[lf+12>>2]|0;q[lf+12>>2]=jf;kf=0-kf|0;q[lf+8>>2]=kf}d:{if((kf|0)>=0){kf=q[a+84>>2];hf=kf+q[lf+16>>2]|0;kf=jf+kf|0;break d}e:{if((jf|0)<=-1){hf=q[lf+16>>2];kf=hf>>31;kf=kf^hf+kf;break e}hf=q[lf+16>>2];kf=hf>>31;kf=q[a+80>>2]-(kf^hf+kf)|0}if((hf|0)<=-1){hf=jf>>31;hf=hf+jf^hf;break d}hf=jf>>31;hf=q[a+80>>2]-(hf+jf^hf)|0}jf=q[a+80>>2];f:{if(!(hf|kf)){hf=jf;kf=hf;break f}if(!((hf|0)!=(jf|0)|kf)){kf=hf;break f}if(!((jf|0)!=(kf|0)|hf)){hf=kf;break f}g:{if(kf){break g}mf=q[a+84>>2];if((mf|0)>=(hf|0)){break g}hf=(mf<<1)-hf|0;kf=0;break f}h:{if((jf|0)!=(kf|0)){break h}mf=q[a+84>>2];if((mf|0)<=(hf|0)){break h}hf=(mf<<1)-hf|0;break f}i:{if((hf|0)!=(jf|0)){break i}jf=q[a+84>>2];if((jf|0)<=(kf|0)){break i}kf=(jf<<1)-kf|0;break f}if(hf){break f}hf=0;jf=q[a+84>>2];if((jf|0)>=(kf|0)){break f}kf=(jf<<1)-kf|0}jf=pf<<3;mf=jf+De|0;of=q[mf+4>>2];q[lf+40>>2]=q[mf>>2];q[lf+44>>2]=of;q[lf+28>>2]=hf;q[lf+24>>2]=kf;Bg(lf+32|0,rf,lf+24|0,lf+40|0);hf=gf+jf|0;q[hf>>2]=q[lf+32>>2];q[hf+4>>2]=q[lf+36>>2];pf=pf+1|0;if((pf|0)>=(sf|0)){break a}jf=q[vf>>2];hf=q[jf>>2];if(q[jf+4>>2]-hf>>2>>>0>pf>>>0){continue}break}}cn();F()}T=lf+48|0;return 1}function Bg(a,De,gf,hf){var jf=0,kf=0,wf=0,xf=0,yf=0,zf=0,Af=0,Bf=0;xf=De+12|0;Af=q[xf>>2];kf=q[gf+4>>2]-Af|0;jf=q[gf>>2]-Af|0;q[gf>>2]=jf;q[gf+4>>2]=kf;wf=kf>>31;yf=wf+kf^wf;wf=jf>>31;xf=q[xf>>2];Bf=(yf+(wf+jf^wf)|0)<=(xf|0);if(!Bf){a:{b:{if((jf|0)>=0){zf=1;yf=1;if((kf|0)>-1){break a}wf=1;zf=-1;yf=-1;if((jf|0)>=1){break b}break a}wf=-1;zf=-1;yf=-1;if((kf|0)<1){break a}}zf=(kf|0)<1?-1:1;yf=wf}wf=kf<<1;kf=w(xf,zf);wf=wf-kf|0;q[gf+4>>2]=wf;xf=w(xf,yf);jf=(jf<<1)-xf|0;q[gf>>2]=jf;c:{if((w(yf,zf)|0)>=0){wf=0-wf|0;q[gf>>2]=wf;jf=0-jf|0;break c}q[gf>>2]=wf}kf=(jf+kf|0)/2|0;q[gf+4>>2]=kf;jf=(xf+wf|0)/2|0;q[gf>>2]=jf;xf=q[De+12>>2]}jf=q[hf>>2]+jf|0;q[a>>2]=jf;gf=q[hf+4>>2]+kf|0;q[a+4>>2]=gf;d:{if((xf|0)<(jf|0)){jf=jf-q[De+4>>2]|0;break d}if((jf|0)>=(0-xf|0)){break d}jf=q[De+4>>2]+jf|0}q[a>>2]=jf;e:{if((xf|0)<(gf|0)){gf=gf-q[De+4>>2]|0;break e}if((gf|0)>=(0-xf|0)){break e}gf=q[De+4>>2]+gf|0}q[a+4>>2]=gf;if(!Bf){f:{g:{if((jf|0)>=0){De=1;hf=1;if((gf|0)>-1){break f}kf=1;De=-1;hf=-1;if((jf|0)>=1){break g}break f}kf=-1;De=-1;hf=-1;if((gf|0)<1){break f}}De=(gf|0)<1?-1:1;hf=kf}wf=w(De,xf);kf=(gf<<1)-wf|0;q[a+4>>2]=kf;yf=w(hf,xf);gf=(jf<<1)-yf|0;q[a>>2]=gf;h:{if((w(De,hf)|0)>=0){kf=0-kf|0;q[a>>2]=kf;gf=0-gf|0;break h}q[a>>2]=kf}gf=(gf+wf|0)/2|0;q[a+4>>2]=gf;jf=(kf+yf|0)/2|0;q[a>>2]=jf}q[a>>2]=jf+Af;q[a+4>>2]=gf+Af}function Cg(a,De){a=a|0;De=De|0;var gf=0,hf=0,Cf=0,Df=0,Ef=0,Ff=0,Gf=0,Hf=0,If=0;gf=q[De+12>>2];Ff=gf;Cf=gf;gf=q[De+20>>2];Df=gf;Ef=q[De+16>>2];hf=Ef+4|0;if(hf>>>0<4){gf=gf+1|0}Gf=q[De+8>>2];Hf=hf;hf=gf;a:{if((Cf|0)<(gf|0)?1:(Cf|0)<=(gf|0)?Gf>>>0>=Hf>>>0?0:1:0){break a}gf=Ef+q[De>>2]|0;Cf=r[gf|0]|r[gf+1|0]<<8|(r[gf+2|0]<<16|r[gf+3|0]<<24);q[De+16>>2]=Hf;q[De+20>>2]=hf;if(s[De+38>>1]<=513){gf=Df;hf=Ef+8|0;if(hf>>>0<8){gf=gf+1|0}Df=hf;hf=gf;if((Ff|0)<(gf|0)?1:(Ff|0)<=(gf|0)?Gf>>>0>=Df>>>0?0:1:0){break a}q[De+16>>2]=Df;q[De+20>>2]=hf}if(!(Cf&1)){break a}De=z(Cf)^31;if(De+ -1>>>0>28){break a}If=1;q[a+8>>2]=De+1;gf=-2<>2]=De;q[a+12>>2]=gf^-1;q[a+20>>2]=(De|0)/2}return If|0}function Dg(a){a=a|0;q[a>>2]=7796;return a|0}function Eg(a){a=a|0;q[a>>2]=7796;An(a)}function Fg(a,De,Jf,Kf,Lf,Mf){a=a|0;De=De|0;Jf=Jf|0;Kf=Kf|0;Lf=Lf|0;Mf=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q[pg+8>>2];sg=og>>31;ug=q[pg+16>>2];rg=ug>>31;mg=0;rg=rg^rg+ug;qg=rg+((qg^ng+qg)+(sg^og+sg)|0)|0;if(qg>>>0>>0){mg=1}b:{if(!(mg|qg)){q[pg+8>>2]=q[a+84>>2];break b}sg=q[a+84>>2];rg=sg;rg=rg>>31;ng=ao($n(sg,rg,ng,ng>>31),V,qg,mg);q[pg+12>>2]=ng;mg=ao($n(sg,rg,og,og>>31),V,qg,mg);q[pg+8>>2]=mg;og=mg;mg=mg>>31;mg=(sg-(og+mg^mg)|0)+((ng|0)<0?ng:0-ng|0)|0;if((ug|0)>=0){q[pg+16>>2]=mg;break b}q[pg+16>>2]=0-mg}mg=dh(yg);og=q[pg+8>>2];c:{if(!mg){ng=q[pg+12>>2];break c}q[pg+16>>2]=0-q[pg+16>>2];ng=0-q[pg+12>>2]|0;q[pg+12>>2]=ng;og=0-og|0;q[pg+8>>2]=og}d:{if((og|0)>=0){og=q[a+84>>2];mg=og+q[pg+16>>2]|0;og=ng+og|0;break d}e:{if((ng|0)<=-1){mg=q[pg+16>>2];og=mg>>31;og=og^mg+og;break e}mg=q[pg+16>>2];og=mg>>31;og=q[a+80>>2]-(og^mg+og)|0}if((mg|0)<=-1){mg=ng>>31;mg=mg+ng^mg;break d}mg=ng>>31;mg=q[a+80>>2]-(mg+ng^mg)|0}ng=q[a+80>>2];f:{if(!(mg|og)){mg=ng;og=mg;break f}if(!((mg|0)!=(ng|0)|og)){og=mg;break f}if(!((ng|0)!=(og|0)|mg)){mg=og;break f}g:{if(og){break g}qg=q[a+84>>2];if((qg|0)>=(mg|0)){break g}mg=(qg<<1)-mg|0;og=0;break f}h:{if((ng|0)!=(og|0)){break h}qg=q[a+84>>2];if((qg|0)<=(mg|0)){break h}mg=(qg<<1)-mg|0;break f}i:{if((mg|0)!=(ng|0)){break i}ng=q[a+84>>2];if((ng|0)<=(og|0)){break i}og=(ng<<1)-og|0;break f}if(mg){break f}mg=0;ng=q[a+84>>2];if((ng|0)>=(og|0)){break f}og=(ng<<1)-og|0}ng=tg<<3;qg=ng+De|0;sg=q[qg+4>>2];qg=q[qg>>2];q[pg+36>>2]=mg;q[pg+32>>2]=og;q[pg+24>>2]=qg;q[pg+28>>2]=sg;Lg(pg+40|0,vg,pg+32|0,pg+24|0);mg=lg+ng|0;q[mg>>2]=q[pg+40>>2];q[mg+4>>2]=q[pg+44>>2];tg=tg+1|0;if((tg|0)>=(wg|0)){break a}ng=q[zg>>2];mg=q[ng>>2];if(q[ng+4>>2]-mg>>2>>>0>tg>>>0){continue}break}}cn();F()}T=pg+48|0;return 1}function Lg(a,De,lg,mg){var ng=0,og=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0;Bg=De+12|0;Eg=q[Bg>>2];og=q[lg+4>>2]-Eg|0;ng=q[lg>>2]-Eg|0;q[lg>>2]=ng;q[lg+4>>2]=og;Ag=og>>31;Cg=Ag+og^Ag;Ag=ng>>31;Bg=q[Bg>>2];Fg=(Cg+(Ag+ng^Ag)|0)<=(Bg|0);if(!Fg){a:{b:{if((ng|0)>=0){Ag=1;Dg=1;if((og|0)>-1){break a}Cg=1;Ag=-1;Dg=-1;if((ng|0)>=1){break b}break a}Cg=-1;Ag=-1;Dg=-1;if((og|0)<1){break a}}Ag=(og|0)<1?-1:1;Dg=Cg}Cg=og<<1;og=w(Ag,Bg);Cg=Cg-og|0;q[lg+4>>2]=Cg;Bg=w(Bg,Dg);ng=(ng<<1)-Bg|0;q[lg>>2]=ng;c:{if((w(Ag,Dg)|0)>=0){Cg=0-Cg|0;q[lg>>2]=Cg;ng=0-ng|0;break c}q[lg>>2]=Cg}og=(ng+og|0)/2|0;q[lg+4>>2]=og;ng=(Bg+Cg|0)/2|0;q[lg>>2]=ng}d:{e:{f:{g:{h:{i:{j:{k:{if(!ng){if(og){break j}Bg=1;Dg=0;break k}Bg=1;Ag=(ng|0)<0&(og|0)<1;if((ng|0)>=1){Dg=(og|0)>-1?2:1;if(Ag){break k}break i}Dg=(og|0)>0?3:0;if(!Ag){break i}}Ag=og;Cg=ng;break d}if((og|0)>=1){break f}break h}Ag=Dg+ -1|0;if(Ag>>>0>2){Ag=og;og=ng;Dg=0;break e}switch(Ag-1|0){case 0:break g;case 1:break f;default:break h}}Ag=0-ng|0;Dg=1;break e}Ag=0-og|0;og=0-ng|0;Dg=2;break e}Ag=ng;og=0-og|0;Dg=3}ng=lg;Cg=og;q[ng>>2]=og;q[ng+4>>2]=Ag;Bg=0}og=q[mg>>2]+Cg|0;q[a>>2]=og;ng=q[mg+4>>2]+Ag|0;q[a+4>>2]=ng;Ag=q[De+12>>2];l:{if((Ag|0)<(og|0)){og=og-q[De+4>>2]|0;break l}if((og|0)>=(0-Ag|0)){break l}og=q[De+4>>2]+og|0}q[a>>2]=og;m:{if((Ag|0)<(ng|0)){ng=ng-q[De+4>>2]|0;break m}if((ng|0)>=(0-Ag|0)){break m}ng=q[De+4>>2]+ng|0}q[a+4>>2]=ng;n:{if(Bg){lg=ng;ng=og;break n}De=(4-Dg&3)+ -1|0;o:{if(De>>>0>2){lg=ng;ng=og;break o}p:{switch(De-1|0){default:lg=0-og|0;break o;case 0:lg=0-ng|0;ng=0-og|0;break o;case 1:break p}}ng=0-ng|0;lg=og}q[a>>2]=ng;q[a+4>>2]=lg}if(!Fg){q:{r:{if((ng|0)>=0){De=1;Bg=1;if((lg|0)>-1){break q}og=1;De=-1;Bg=-1;if((ng|0)>=1){break r}break q}og=-1;De=-1;Bg=-1;if((lg|0)<1){break q}}De=(lg|0)<1?-1:1;Bg=og}mg=lg<<1;lg=w(De,Ag);og=mg-lg|0;q[a+4>>2]=og;mg=w(Ag,Bg);ng=(ng<<1)-mg|0;q[a>>2]=ng;s:{if((w(De,Bg)|0)>=0){og=0-og|0;q[a>>2]=og;ng=0-ng|0;break s}q[a>>2]=og}lg=(lg+ng|0)/2|0;q[a+4>>2]=lg;ng=(mg+og|0)/2|0;q[a>>2]=ng}q[a>>2]=ng+Eg;q[a+4>>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ng+4>>2]=q[Qg+28>>2];if((Pg|0)<(Og|0)){eh=0-Pg<<2;a=Pg;while(1){ah=a<<2;dh=ah+De|0;gh=q[dh>>2];dh=q[dh+4>>2];ah=Ng+ah|0;fh=ah+eh|0;hh=q[fh+4>>2];q[Qg+16>>2]=q[fh>>2];q[Qg+20>>2]=hh;q[Qg+8>>2]=gh;q[Qg+12>>2]=dh;Lg(Qg+24|0,ch,Qg+16|0,Qg+8|0);q[ah>>2]=q[Qg+24>>2];q[ah+4>>2]=q[Qg+28>>2];a=a+Pg|0;if((a|0)<(Og|0)){continue}break}}An(bh);T=Qg+32|0;return 1}function Rg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;if(Se(a,De,Ng)){a=q[q[q[q[De+4>>2]+8>>2]+(Ng<<2)>>2]+28>>2]==9}else{a=0}return a|0}function Sg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;var Og=0;a:{if(r[q[a+4>>2]+36|0]<=1){Og=0;if(!n[q[q[a>>2]+52>>2]](a)){break a}}Og=Xe(a,De,Ng)}return Og|0}function Tg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;De=T-32|0;T=De;a:{if(r[q[a+4>>2]+36|0]>=2){Ng=0;if(!n[q[q[a>>2]+52>>2]](a)){break a}}q[De+24>>2]=0;q[De+28>>2]=0;q[De+16>>2]=0;q[De+20>>2]=0;q[De+12>>2]=-1;q[De+8>>2]=1232;gd(De+8|0,q[a+24>>2],q[a+28>>2],o[q[a+8>>2]+24|0],u[a+32>>2]);Ng=ld(De+8|0,q[a+16>>2]);q[De+8>>2]=1232;a=q[De+16>>2];if(!a){break a}q[De+20>>2]=a;An(a)}T=De+32|0;return Ng|0}function Ug(a,De){a=a|0;De=De|0;return n[q[q[a>>2]+56>>2]](a,De)|0}function Vg(a){a=a|0;var De=0,Ng=0,Pg=0,Qg=0,ih=0,jh=0,kh=0,lh=0,mh=0,nh=0;De=o[q[a+8>>2]+24|0];Pg=De<<2;De=Mm((De|0)!=(De&1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xh=0,yh=0,zh=0,Ah=0,Bh=0,Ch=0,Dh=x(0);sh=T-16|0;T=sh;qh=q[a+24>>2];rh=o[q[a+8>>2]+24|0];th=rh<<2;uh=Mm((rh&1073741823)!=(rh|0)?-1:th);vh=hk(sh+8|0);a:{if(!ik(vh,u[a+32>>2],-1<>2];qh=0;b:{if(!q[ph+80>>2]){break b}qh=q[q[ph>>2]>>2]+q[ph+48>>2]|0}if(!oh){ph=1;break a}zh=(rh|0)<1;Ah=a+28|0;Bh=a+8|0;a=0;while(1){if(!zh){Ch=q[Ah>>2];Dh=u[vh>>2];ph=0;while(1){wh=ph<<2;u[wh+uh>>2]=x(Dh*x(q[(a<<2)+qh>>2]))+u[Ch+wh>>2];a=a+1|0;ph=ph+1|0;if((rh|0)!=(ph|0)){continue}break}}Cn(q[q[q[Bh>>2]- -64>>2]>>2]+xh|0,uh,th);xh=th+xh|0;ph=1;yh=yh+1|0;if((yh|0)!=(oh|0)){continue}break}}An(uh);T=sh+16|0;return ph|0}function Xg(a){a=a|0;var oh=0,Eh=0;q[a>>2]=10764;Eh=a+28|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){An(oh)}q[a>>2]=2220;Eh=a+20|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){n[q[q[oh>>2]+4>>2]](oh)}q[a>>2]=1908;Eh=a+16|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){Hb(oh)}return a|0}function Yg(a){a=a|0;var Fh=0,Gh=0;q[a>>2]=10764;Gh=a+28|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){An(Fh)}q[a>>2]=2220;Gh=a+20|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){n[q[q[Fh>>2]+4>>2]](Fh)}q[a>>2]=1908;Gh=a+16|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){Hb(Fh)}An(a)}function Zg(a){q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=0;q[a+8>>2]=0;q[a+12>>2]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){break a}ai=a;c:{d:{switch(Yh-1|0){default:q[a+4>>2]=Zh;a=r[$h|0]&63;break c;case 0:if((Vh|0)<2){break a}q[a+4>>2]=Vh+ -2;a=(Vh+Wh|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c;case 1:break d}}if((Vh|0)<3){break a}q[a+4>>2]=Vh+ -3;a=(Vh+Wh|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0]}a=a+4096|0;q[ai+8>>2]=a;if(a>>>0>1048575){break a}a=Uh+Xh|0;if(a>>>0>>0){Th=Th+1|0}q[Jh+16>>2]=a;q[Jh+20>>2]=Th;bi=1}T=_h+16|0;return bi}function ch(a,Jh,ci){var di=0,ei=0,fi=0,gi=0;a:{if(a>>>0>5){break a}fi=q[ci+16>>2];di=q[ci+12>>2];ei=q[ci+20>>2];if((di|0)<(ei|0)?1:(di|0)<=(ei|0)?t[ci+8>>2]>fi>>>0?0:1:0){break a}di=r[fi+q[ci>>2]|0];fi=fi+1|0;if(fi>>>0<1){ei=ei+1|0}q[ci+16>>2]=fi;q[ci+20>>2]=ei;ei=Jh;if(di&128){if(!ch(a+1|0,Jh,ci)){break a}a=q[Jh>>2]<<7;q[Jh>>2]=a;di=a|di&127}q[ei>>2]=di;gi=1}return gi}function dh(a){var Jh=0,ci=0,hi=0,ii=0,ji=0;hi=0-r[a+12|0]|0;ci=q[a+8>>2];a:{if(ci>>>0>4095){break a}Jh=q[a+4>>2];if((Jh|0)<1){break a}Jh=Jh+ -1|0;q[a+4>>2]=Jh;ci=r[Jh+q[a>>2]|0]|ci<<8;q[a+8>>2]=ci}hi=hi&255;Jh=w(hi,ci>>>8);ii=ci&255;ji=ii>>>0>>0;q[a+8>>2]=ji?Jh+ii|0:(ci-hi|0)-Jh|0;return ji}function eh(a,ki,li){var mi=0,ni=0,oi=0,pi=0,qi=0,ri=0;if(!ki){q[li>>2]=0;return}pi=0-r[a+12|0]&255;ni=q[a+8>>2];while(1){qi=mi<<1;a:{if(ni>>>0>4095){break a}mi=q[a+4>>2];if((mi|0)<1){break a}mi=mi+ -1|0;q[a+4>>2]=mi;ni=r[mi+q[a>>2]|0]|ni<<8;q[a+8>>2]=ni}oi=ni&255;mi=oi>>>0>>0;ri=oi;oi=w(ni>>>8,pi);ni=mi?ri+oi|0:(ni-pi|0)-oi|0;q[a+8>>2]=ni;mi=mi|qi;ki=ki+ -1|0;if(ki){continue}break}q[li>>2]=mi}function fh(a,ki){var li=0,si=0,ti=0;ti=T-32|0;T=ti;a:{if(ki>>>0<=1){if(ki-1){li=Mm(44);ki=li;q[ki>>2]=0;q[ki+4>>2]=0;q[ki+40>>2]=0;q[ki+32>>2]=0;q[ki+36>>2]=0;q[ki+24>>2]=0;q[ki+28>>2]=0;q[ki+16>>2]=0;q[ki+20>>2]=0;q[ki+8>>2]=0;q[ki+12>>2]=0;Ij(ki);q[ki>>2]=13760;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}li=Mm(44);ki=li;q[ki>>2]=0;q[ki+4>>2]=0;q[ki+40>>2]=0;q[ki+32>>2]=0;q[ki+36>>2]=0;q[ki+24>>2]=0;q[ki+28>>2]=0;q[ki+16>>2]=0;q[ki+20>>2]=0;q[ki+8>>2]=0;q[ki+12>>2]=0;Ij(ki);q[ki>>2]=13668;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(32);q[ti>>2]=ki;q[ti+4>>2]=28;q[ti+8>>2]=-2147483616;o[ki+28|0]=0;li=r[10912]|r[10913]<<8|(r[10914]<<16|r[10915]<<24);o[ki+24|0]=li;o[ki+25|0]=li>>>8;o[ki+26|0]=li>>>16;o[ki+27|0]=li>>>24;li=r[10908]|r[10909]<<8|(r[10910]<<16|r[10911]<<24);si=r[10904]|r[10905]<<8|(r[10906]<<16|r[10907]<<24);o[ki+16|0]=si;o[ki+17|0]=si>>>8;o[ki+18|0]=si>>>16;o[ki+19|0]=si>>>24;o[ki+20|0]=li;o[ki+21|0]=li>>>8;o[ki+22|0]=li>>>16;o[ki+23|0]=li>>>24;li=r[10900]|r[10901]<<8|(r[10902]<<16|r[10903]<<24);si=r[10896]|r[10897]<<8|(r[10898]<<16|r[10899]<<24);o[ki+8|0]=si;o[ki+9|0]=si>>>8;o[ki+10|0]=si>>>16;o[ki+11|0]=si>>>24;o[ki+12|0]=li;o[ki+13|0]=li>>>8;o[ki+14|0]=li>>>16;o[ki+15|0]=li>>>24;li=r[10892]|r[10893]<<8|(r[10894]<<16|r[10895]<<24);si=r[10888]|r[10889]<<8|(r[10890]<<16|r[10891]<<24);o[ki|0]=si;o[ki+1|0]=si>>>8;o[ki+2|0]=si>>>16;o[ki+3|0]=si>>>24;o[ki+4|0]=li;o[ki+5|0]=li>>>8;o[ki+6|0]=li>>>16;o[ki+7|0]=li>>>24;q[ti+16>>2]=-1;ki=Rm(ti+16|4,ti);q[a>>2]=q[ti+16>>2];Rm(a+4|0,ki);q[a+16>>2]=0;if(o[ki+11|0]<=-1){An(q[ki>>2])}if(o[ti+11|0]>-1){break a}An(q[ti>>2])}T=ti+32|0}function gh(a,ki){var ui=0,vi=0,wi=0;wi=T-32|0;T=wi;a:{if(ki>>>0<=1){if(ki-1){ki=Mm(48);Rh(ki);q[ki>>2]=13064;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(52);Rh(ki);q[ki+48>>2]=0;q[ki>>2]=11164;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(32);q[wi>>2]=ki;q[wi+4>>2]=28;q[wi+8>>2]=-2147483616;o[ki+28|0]=0;ui=r[10912]|r[10913]<<8|(r[10914]<<16|r[10915]<<24);o[ki+24|0]=ui;o[ki+25|0]=ui>>>8;o[ki+26|0]=ui>>>16;o[ki+27|0]=ui>>>24;ui=r[10908]|r[10909]<<8|(r[10910]<<16|r[10911]<<24);vi=r[10904]|r[10905]<<8|(r[10906]<<16|r[10907]<<24);o[ki+16|0]=vi;o[ki+17|0]=vi>>>8;o[ki+18|0]=vi>>>16;o[ki+19|0]=vi>>>24;o[ki+20|0]=ui;o[ki+21|0]=ui>>>8;o[ki+22|0]=ui>>>16;o[ki+23|0]=ui>>>24;ui=r[10900]|r[10901]<<8|(r[10902]<<16|r[10903]<<24);vi=r[10896]|r[10897]<<8|(r[10898]<<16|r[10899]<<24);o[ki+8|0]=vi;o[ki+9|0]=vi>>>8;o[ki+10|0]=vi>>>16;o[ki+11|0]=vi>>>24;o[ki+12|0]=ui;o[ki+13|0]=ui>>>8;o[ki+14|0]=ui>>>16;o[ki+15|0]=ui>>>24;ui=r[10892]|r[10893]<<8|(r[10894]<<16|r[10895]<<24);vi=r[10888]|r[10889]<<8|(r[10890]<<16|r[10891]<<24);o[ki|0]=vi;o[ki+1|0]=vi>>>8;o[ki+2|0]=vi>>>16;o[ki+3|0]=vi>>>24;o[ki+4|0]=ui;o[ki+5|0]=ui>>>8;o[ki+6|0]=ui>>>16;o[ki+7|0]=ui>>>24;q[wi+16>>2]=-1;ki=Rm(wi+16|4,wi);q[a>>2]=q[wi+16>>2];Rm(a+4|0,ki);q[a+16>>2]=0;if(o[ki+11|0]<=-1){An(q[ki>>2])}if(o[wi+11|0]>-1){break a}An(q[wi>>2])}T=wi+32|0}function hh(a,ki){var xi=0,yi=0,zi=0;xi=T-80|0;T=xi;yi=q[ki+36>>2];q[xi+72>>2]=q[ki+32>>2];q[xi+76>>2]=yi;zi=q[ki+28>>2];yi=xi- -64|0;q[yi>>2]=q[ki+24>>2];q[yi+4>>2]=zi;yi=q[ki+20>>2];q[xi+56>>2]=q[ki+16>>2];q[xi+60>>2]=yi;yi=q[ki+12>>2];q[xi+48>>2]=q[ki+8>>2];q[xi+52>>2]=yi;yi=q[ki+4>>2];q[xi+40>>2]=q[ki>>2];q[xi+44>>2]=yi;Jj(xi+8|0,xi+40|0,xi+24|0);ki=q[xi+8>>2];a:{if(ki){q[a>>2]=ki;Rm(a+4|0,xi+8|4);if(o[xi+23|0]>=0){break a}An(q[xi+12>>2]);break a}if(o[xi+23|0]<=-1){An(q[xi+12>>2])}ki=r[xi+31|0];q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;q[a+8>>2]=0;q[a+12>>2]=0}T=xi+80|0}function ih(a,ki,Ai,Bi){var Ci=0,Di=0,Ei=0;Ci=T-80|0;T=Ci;Di=q[Ai+36>>2];q[Ci+72>>2]=q[Ai+32>>2];q[Ci+76>>2]=Di;Ei=q[Ai+28>>2];Di=Ci- -64|0;q[Di>>2]=q[Ai+24>>2];q[Di+4>>2]=Ei;Di=q[Ai+20>>2];q[Ci+56>>2]=q[Ai+16>>2];q[Ci+60>>2]=Di;Di=q[Ai+12>>2];q[Ci+48>>2]=q[Ai+8>>2];q[Ci+52>>2]=Di;Di=q[Ai+4>>2];q[Ci+40>>2]=q[Ai>>2];q[Ci+44>>2]=Di;Jj(a,Ci+40|0,Ci+24|0);a:{if(q[a>>2]){break a}Ei=a+4|0;if(o[a+15|0]<=-1){An(q[Ei>>2])}if(r[Ci+31|0]){q[Ci+8>>2]=0;q[Ci>>2]=0;q[Ci+4>>2]=0;ki=Mm(32);q[Ci>>2]=ki;q[Ci+4>>2]=27;q[Ci+8>>2]=-2147483616;o[ki+27|0]=0;Ai=r[10940]|r[10941]<<8|(r[10942]<<16|r[10943]<<24);o[ki+23|0]=Ai;o[ki+24|0]=Ai>>>8;o[ki+25|0]=Ai>>>16;o[ki+26|0]=Ai>>>24;Ai=r[10937]|r[10938]<<8|(r[10939]<<16|r[10940]<<24);Bi=r[10933]|r[10934]<<8|(r[10935]<<16|r[10936]<<24);o[ki+16|0]=Bi;o[ki+17|0]=Bi>>>8;o[ki+18|0]=Bi>>>16;o[ki+19|0]=Bi>>>24;o[ki+20|0]=Ai;o[ki+21|0]=Ai>>>8;o[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=0;q[Hi+44>>2]=Bi;Mj(a,Hi,ki,Ai,Bi);if(!q[a>>2]){if(o[Gi+11|0]<=-1){An(q[Gi>>2])}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}if(!Hi){break b}n[q[q[Hi>>2]+4>>2]](Hi)}a=q[Fi+16>>2];q[Fi+16>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}if(o[Fi+15|0]>-1){break a}An(q[Fi+4>>2])}T=Fi+80|0}function kh(a,ki){var Ai=0,Bi=0,Ii=0;Ii=T-16|0;T=Ii;q[Ii+12>>2]=ki;ki=Mm(32);q[Ii>>2]=ki;q[Ii+4>>2]=24;q[Ii+8>>2]=-2147483616;o[ki+24|0]=0;Ai=r[10986]|r[10987]<<8|(r[10988]<<16|r[10989]<<24);Bi=r[10982]|r[10983]<<8|(r[10984]<<16|r[10985]<<24);o[ki+16|0]=Bi;o[ki+17|0]=Bi>>>8;o[ki+18|0]=Bi>>>16;o[ki+19|0]=Bi>>>24;o[ki+20|0]=Ai;o[ki+21|0]=Ai>>>8;o[ki+22|0]=Ai>>>16;o[ki+23|0]=Ai>>>24;Ai=r[10978]|r[10979]<<8|(r[10980]<<16|r[10981]<<24);Bi=r[10974]|r[10975]<<8|(r[10976]<<16|r[10977]<<24);o[ki+8|0]=Bi;o[ki+9|0]=Bi>>>8;o[ki+10|0]=Bi>>>16;o[ki+11|0]=Bi>>>24;o[ki+12|0]=Ai;o[ki+13|0]=Ai>>>8;o[ki+14|0]=Ai>>>16;o[ki+15|0]=Ai>>>24;Ai=r[10970]|r[10971]<<8|(r[10972]<<16|r[10973]<<24);Bi=r[10966]|r[10967]<<8|(r[10968]<<16|r[10969]<<24);o[ki|0]=Bi;o[ki+1|0]=Bi>>>8;o[ki+2|0]=Bi>>>16;o[ki+3|0]=Bi>>>24;o[ki+4|0]=Ai;o[ki+5|0]=Ai>>>8;o[ki+6|0]=Ai>>>16;o[ki+7|0]=Ai>>>24;ek(lh(a,Ii+12|0),Ii);if(o[Ii+11|0]<=-1){An(q[Ii>>2])}T=Ii+16|0}function lh(a,ki){var Ji=0,Ki=0,Li=0,Mi=0,Ni=0,Oi=0,Pi=0,Qi=0;Li=T-32|0;T=Li;Mi=a+16|0;Ki=q[Mi>>2];a:{b:{if(!Ki){break b}Oi=q[ki>>2];Ji=Mi;while(1){Ni=q[Ki+16>>2]<(Oi|0);Ji=Ni?Ji:Ki;Ki=q[(Ni<<2)+Ki>>2];if(Ki){continue}break}if((Ji|0)==(Mi|0)){break b}if((Oi|0)>=q[Ji+16>>2]){break a}}Oi=ck(Li+16|0);ki=q[ki>>2];Ni=Li+8|0;q[Ni>>2]=0;q[Ni+4>>2]=0;q[Li>>2]=ki;q[Li+4>>2]=Ni;Ji=q[Oi>>2];Pi=Oi+4|0;if((Ji|0)!=(Pi|0)){Qi=Li|4;while(1){ki=Ji;Ki=Ji+16|0;mh(Qi,Ni,Ki,Ki);Ki=q[Ji+4>>2];c:{if(!Ki){Ji=q[ki+8>>2];if((ki|0)==q[Ji>>2]){break c}ki=ki+8|0;while(1){Ki=q[ki>>2];ki=Ki+8|0;Ji=q[Ki+8>>2];if((Ki|0)!=q[Ji>>2]){continue}break}break c}while(1){Ji=Ki;Ki=q[Ji>>2];if(Ki){continue}break}}if((Ji|0)!=(Pi|0)){continue}break}}ki=a+16|0;Ki=q[ki>>2];d:{if(Ki){Mi=q[Li>>2];while(1){Ji=q[Ki+16>>2];e:{if((Mi|0)<(Ji|0)){Ji=q[Ki>>2];if(Ji){break e}ki=Ki;break d}if((Ji|0)>=(Mi|0)){break d}ki=Ki+4|0;Ji=q[Ki+4>>2];if(!Ji){break d}Ki=ki}ki=Ki;Ki=Ji;continue}}Ki=Mi;ki=Ki}Ji=q[ki>>2];if(!Ji){Ji=Mm(32);q[Ji+16>>2]=q[Li>>2];q[Ji+20>>2]=q[Li+4>>2];Mi=Ji+24|0;Pi=q[Li+8>>2];q[Mi>>2]=Pi;Qi=q[Li+12>>2];q[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break f}if(!_i){break d}bj=(aj|0)<0?q[Xi>>2]:Xi;Zi=(fj|0)<0?q[Yi>>2]:Yi;break e}if((gj|0)>-1){break e}}_i=q[ki>>2];h:{i:{if(q[a>>2]==(ki|0)){Yi=ki;break i}j:{if(!_i){Wi=ki;while(1){Yi=q[Wi+8>>2];$i=q[Yi>>2]==(Wi|0);Wi=Yi;if($i){continue}break}break j}Wi=_i;while(1){Yi=Wi;Wi=q[Yi+4>>2];if(Wi){continue}break}}Zi=r[Xi+11|0];Wi=Zi<<24>>24<0;aj=r[Yi+27|0];$i=aj<<24>>24<0;k:{Zi=Wi?q[Xi+4>>2]:Zi;aj=$i?q[Yi+20>>2]:aj;bj=Zi>>>0>>0?Zi:aj;if(bj){cj=Yi+16|0;Wi=cm($i?q[cj>>2]:cj,Wi?q[Xi>>2]:Xi,bj);if(Wi){break k}}if(aj>>>0>>0){break i}break h}if((Wi|0)>-1){break h}}if(!_i){q[Vi>>2]=ki;return ki}q[Vi>>2]=Yi;return Yi+4|0}return ph(a,Vi,Xi)}Yi=cm(Zi,bj,_i);if(Yi){break c}}if(dj){break b}break a}if((Yi|0)>-1){break a}}bj=ki+4|0;_i=q[bj>>2];l:{if(_i){Yi=_i;while(1){Wi=Yi;Yi=q[Yi>>2];if(Yi){continue}break}break l}Wi=q[ki+8>>2];if(q[Wi>>2]==(ki|0)){break l}Yi=ki+8|0;while(1){Zi=q[Yi>>2];Yi=Zi+8|0;Wi=q[Zi+8>>2];if((Zi|0)!=q[Wi>>2]){continue}break}}m:{n:{if((Wi|0)==(ej|0)){break n}Zi=r[Wi+27|0];Yi=Zi<<24>>24<0;o:{Zi=Yi?q[Wi+20>>2]:Zi;cj=Zi>>>0<$i>>>0?Zi:$i;if(cj){dj=(aj|0)<0?q[Xi>>2]:Xi;aj=Wi+16|0;Yi=cm(dj,Yi?q[aj>>2]:aj,cj);if(Yi){break o}}if($i>>>0>>0){break n}break m}if((Yi|0)>-1){break m}}if(!_i){q[Vi>>2]=ki;return bj}q[Vi>>2]=Wi;return Wi}return ph(a,Vi,Xi)}q[Vi>>2]=ki;q[Wi>>2]=ki;return Wi}function ph(a,ki,Vi){var Wi=0,Xi=0,hj=0,ij=0,jj=0,kj=0,lj=0,mj=0,nj=0;a:{Wi=a+4|0;a=q[Wi>>2];if(a){hj=r[Vi+11|0];ij=hj<<24>>24<0;hj=ij?q[Vi+4>>2]:hj;lj=ij?q[Vi>>2]:Vi;while(1){Vi=a+16|0;Xi=r[a+27|0];ij=Xi<<24>>24<0;jj=ij?q[a+20>>2]:Xi;mj=jj>>>0>>0;b:{c:{d:{e:{f:{g:{h:{Xi=mj?jj:hj;if(Xi){kj=ij?q[Vi>>2]:Vi;nj=cm(lj,kj,Xi);if(nj){break h}}if(hj>>>0>>0){break g}if(!Xi){break e}kj=ij?q[Vi>>2]:Vi;break f}if((nj|0)>-1){break f}}Vi=q[a>>2];if(Vi){break b}q[ki>>2]=a;return a}Vi=cm(kj,lj,Xi);if(Vi){break d}}if(mj){break c}break a}if((Vi|0)>-1){break a}}Wi=a+4|0;Vi=q[a+4>>2];if(!Vi){break a}a=Wi}Wi=a;a=Vi;continue}}q[ki>>2]=Wi;return Wi}q[ki>>2]=a;return Wi}function qh(a,ki,Vi,oj){var pj=0,qj=0,rj=0,sj=0,tj=0;if(!a){return 1}pj=q[Vi+16>>2];sj=q[Vi+12>>2];rj=q[Vi+20>>2];qj=rj;a:{if((sj|0)<(qj|0)?1:(sj|0)<=(qj|0)?t[Vi+8>>2]>pj>>>0?0:1:0){break a}qj=r[pj+q[Vi>>2]|0];pj=pj+1|0;if(pj>>>0<1){rj=rj+1|0}q[Vi+16>>2]=pj;q[Vi+20>>2]=rj;if(qj>>>0>1){break a}if(qj-1){return rh(a,ki,Vi,oj)}tj=sh(a,Vi,oj)}return tj}function rh(a,ki,Vi,oj){var uj=0,vj=0,wj=0,xj=0,yj=0,zj=0,Aj=0,Bj=0,Cj=0,Dj=0,Ej=0,Fj=0,Gj=0,Hj=0,Ij=0,Jj=0;uj=T+ -64|0;T=uj;q[uj+56>>2]=0;q[uj+48>>2]=0;q[uj+52>>2]=0;q[uj+40>>2]=0;q[uj+44>>2]=0;q[uj+32>>2]=0;q[uj+36>>2]=0;q[uj+24>>2]=0;q[uj+28>>2]=0;q[uj+16>>2]=0;q[uj+20>>2]=0;q[uj+8>>2]=0;q[uj+12>>2]=0;a:{if(!th(uj+8|0,Vi)){break a}if(!uh(uj+8|0,Vi)|(q[uj+20>>2]?0:a)){break a}_j(Vi,0,0);if(a){xj=q[uj+56>>2];Fj=q[uj+36>>2];Gj=q[uj+48>>2];Hj=q[uj+24>>2];while(1){b:{if(xj>>>0>16383){break b}vj=q[uj+52>>2];while(1){if((vj|0)<1){break b}vj=vj+ -1|0;q[uj+52>>2]=vj;xj=r[vj+Gj|0]|xj<<8;q[uj+56>>2]=xj;if(xj>>>0<16384){continue}break}}wj=xj&4095;Dj=q[(wj<<2)+Hj>>2];yj=(Dj<<3)+Fj|0;xj=(w(q[yj>>2],xj>>>12)+wj|0)-q[yj+4>>2]|0;q[uj+56>>2]=xj;if((ki|0)>=1){if(!r[Vi+36|0]){wj=0;break a}yj=ki+zj|0;while(1){c:{if((Dj|0)<1){Bj=0;break c}wj=q[Vi+32>>2];Ij=q[Vi+28>>2];Jj=q[Vi+24>>2];vj=0;Bj=0;while(1){Aj=(wj>>>3)+Jj|0;d:{if(Aj>>>0>=Ij>>>0){Cj=0;break d}Cj=r[Aj|0];Aj=wj+1|0;q[Vi+32>>2]=Aj;Cj=Cj>>>(wj&7)&1;wj=Aj}Bj=Cj<>2]=Bj;zj=zj+1|0;if((yj|0)!=(zj|0)){continue}break}zj=yj}Ej=ki+Ej|0;if(Ej>>>0>>0){continue}break}}ak(Vi);wj=1}a=q[uj+36>>2];if(a){q[uj+40>>2]=a;An(a)}a=q[uj+24>>2];if(a){q[uj+28>>2]=a;An(a)}a=q[uj+8>>2];if(a){q[uj+12>>2]=a;An(a)}T=uj- -64|0;return wj}function sh(a,ki,Vi){var oj=0,Kj=0,Lj=0,Mj=0;a:{b:{Kj=q[ki+16>>2];Lj=q[ki+12>>2];oj=q[ki+20>>2];c:{if((Lj|0)<(oj|0)?1:(Lj|0)<=(oj|0)?t[ki+8>>2]>Kj>>>0?0:1:0){break c}Lj=r[Kj+q[ki>>2]|0];Kj=Kj+1|0;if(Kj>>>0<1){oj=oj+1|0}q[ki+16>>2]=Kj;q[ki+20>>2]=oj;oj=Lj+ -1|0;if(oj>>>0>17){break c}d:{e:{switch(oj-1|0){case 7:return wh(a,ki,Vi);case 8:return xh(a,ki,Vi);case 9:return yh(a,ki,Vi);case 10:return zh(a,ki,Vi);case 12:case 13:case 14:case 15:break a;case 16:break d;case 11:break e;default:break b}}return Ah(a,ki,Vi)}Mj=Bh(a,ki,Vi)}return Mj}return vh(a,ki,Vi)}return Bh(a,ki,Vi)}function th(a,ki){var Vi=0,Nj=0,Oj=0,Pj=0,Qj=0,Rj=0,Sj=0,Tj=0,Uj=0,Vj=0,Wj=0,Xj=0,Yj=0;a:{Vi=s[ki+38>>1];if(!Vi){break a}Sj=a+12|0;b:{if(Vi>>>0<=511){Nj=q[ki+12>>2];Vi=q[ki+20>>2];Oj=q[ki+16>>2];Qj=Oj+4|0;if(Qj>>>0<4){Vi=Vi+1|0}if((Nj|0)<(Vi|0)?1:(Nj|0)<=(Vi|0)?t[ki+8>>2]>=Qj>>>0?0:1:0){break a}Vi=Oj+q[ki>>2]|0;Oj=r[Vi|0]|r[Vi+1|0]<<8|(r[Vi+2|0]<<16|r[Vi+3|0]<<24);q[Sj>>2]=Oj;Nj=q[ki+20>>2];Qj=q[ki+16>>2]+4|0;if(Qj>>>0<4){Nj=Nj+1|0}Vi=ki;q[Vi+16>>2]=Qj;q[Vi+20>>2]=Nj;break b}if(!Ch(1,Sj,ki)){break a}Oj=q[Sj>>2]}Nj=q[a>>2];Vi=q[a+4>>2]-Nj>>2;c:{if(Oj>>>0>Vi>>>0){Fa(a,Oj-Vi|0);Oj=q[a+12>>2];break c}if(Oj>>>0>=Vi>>>0){break c}q[a+4>>2]=Nj+(Oj<<2)}if(!Oj){Yj=1;break a}Wj=q[ki+8>>2];Qj=q[ki+12>>2];while(1){Pj=q[ki+16>>2];Vi=q[ki+20>>2];if((Qj|0)<(Vi|0)?1:(Qj|0)<=(Vi|0)?Wj>>>0>Pj>>>0?0:1:0){break a}Xj=q[ki>>2];Tj=r[Xj+Pj|0];Pj=Pj+1|0;if(Pj>>>0<1){Vi=Vi+1|0}q[ki+16>>2]=Pj;q[ki+20>>2]=Vi;Uj=Tj>>>2;d:{e:{f:{Vj=Tj&3;if(Vj>>>0>3){Nj=0;break f}Nj=0;g:{switch(Vj-1|0){case 0:case 1:break f;case 2:break g;default:break e}}Vi=Rj+Uj|0;if(Vi>>>0>=Oj>>>0){return 0}Dn(q[a>>2]+(Rj<<2)|0,0,(Tj&252)+4|0);Rj=Vi;break d}while(1){if((Qj|0)<(Vi|0)?1:(Qj|0)<=(Vi|0)?Wj>>>0>Pj>>>0?0:1:0){return 0}Tj=r[Pj+Xj|0];Pj=Pj+1|0;if(Pj>>>0<1){Vi=Vi+1|0}q[ki+16>>2]=Pj;q[ki+20>>2]=Vi;Uj=Tj<<(Nj<<3|6)|Uj;Nj=Nj+1|0;if((Vj|0)!=(Nj|0)){continue}break}}q[q[a>>2]+(Rj<<2)>>2]=Uj}Rj=Rj+1|0;Oj=q[Sj>>2];if(Rj>>>0>>0){continue}break}Rj=a+16|0;Sj=q[a>>2];ki=q[a+16>>2];Vi=q[a+20>>2]-ki|0;Nj=Vi>>2;h:{if(Nj>>>0<=4095){Fa(Rj,4096-Nj|0);break h}if((Vi|0)==16384){break h}q[a+20>>2]=ki+16384}i:{ki=a+28|0;Vi=q[ki>>2];Nj=q[a+32>>2]-Vi>>3;if(Oj>>>0>Nj>>>0){Dh(ki,Oj-Nj|0);Vi=q[ki>>2];break i}if(Oj>>>0>>0){q[a+32>>2]=(Oj<<3)+Vi}if(Oj){break i}return 0}ki=0;Nj=0;while(1){a=Sj+(ki<<2)|0;Qj=q[a>>2];Pj=(ki<<3)+Vi|0;q[Pj+4>>2]=Nj;q[Pj>>2]=Qj;a=q[a>>2]+Nj|0;if(a>>>0>4096){break a}if(Nj>>>0>>0){Qj=q[Rj>>2];while(1){q[Qj+(Nj<<2)>>2]=ki;Nj=Nj+1|0;if((a|0)!=(Nj|0)){continue}break}}Nj=a;ki=ki+1|0;if((Oj|0)!=(ki|0)){continue}break}return(a|0)==4096}return Yj}function uh(a,ki){var Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0,fk=0;bk=T-16|0;T=bk;a:{b:{if(s[ki+38>>1]<=511){_j=q[ki+12>>2];ek=_j;Zj=q[ki+20>>2];$j=q[ki+16>>2];ak=$j+8|0;if(ak>>>0<8){Zj=Zj+1|0}ck=q[ki+8>>2];if((_j|0)<(Zj|0)?1:(_j|0)<=(Zj|0)?ck>>>0>=ak>>>0?0:1:0){break a}_j=$j+q[ki>>2]|0;$j=r[_j+4|0]|r[_j+5|0]<<8|(r[_j+6|0]<<16|r[_j+7|0]<<24);_j=r[_j|0]|r[_j+1|0]<<8|(r[_j+2|0]<<16|r[_j+3|0]<<24);q[bk+8>>2]=_j;q[bk+12>>2]=$j;q[ki+16>>2]=ak;q[ki+20>>2]=Zj;break b}if(!Eh(1,bk+8|0,ki)){break a}ak=q[ki+16>>2];Zj=q[ki+20>>2];ck=q[ki+8>>2];ek=q[ki+12>>2];_j=q[bk+8>>2];$j=q[bk+12>>2]}dk=ck-ak|0;ck=ek-(Zj+(ck>>>0>>0)|0)|0;if((ck|0)==($j|0)&_j>>>0>dk>>>0|$j>>>0>ck>>>0){break a}$j=Zj+$j|0;Zj=ak;dk=Zj+_j|0;if(dk>>>0>>0){$j=$j+1|0}q[ki+16>>2]=dk;q[ki+20>>2]=$j;Zj=_j;if((Zj|0)<1){break a}ak=ak+q[ki>>2]|0;q[a+40>>2]=ak;ki=a;c:{d:{e:{f:{g:{_j=Zj+ -1|0;$j=ak+_j|0;switch((r[$j|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=_j;a=r[$j|0]&63;break c}if((Zj|0)<2){break a}q[a+44>>2]=Zj+ -2;a=(Zj+ak|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Zj|0)<3){break a}q[a+44>>2]=Zj+ -3;a=(Zj+ak|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Zj+ -4;a=(Zj+ak|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+16384|0;q[ki+48>>2]=a;fk=a>>>0<4194304}T=bk+16|0;return fk}function vh(a,ki,gk){var hk=0,ik=0,jk=0,kk=0,lk=0,mk=0,nk=0,ok=0;hk=T+ -64|0;T=hk;q[hk+56>>2]=0;q[hk+48>>2]=0;q[hk+52>>2]=0;q[hk+40>>2]=0;q[hk+44>>2]=0;q[hk+32>>2]=0;q[hk+36>>2]=0;q[hk+24>>2]=0;q[hk+28>>2]=0;q[hk+16>>2]=0;q[hk+20>>2]=0;q[hk+8>>2]=0;q[hk+12>>2]=0;a:{if(!th(hk+8|0,ki)|(q[hk+20>>2]?0:a)){break a}ik=uh(hk+8|0,ki);if(!a|!ik){break a}ki=q[hk+56>>2];mk=q[hk+36>>2];nk=q[hk+48>>2];ok=q[hk+24>>2];while(1){b:{if(ki>>>0>16383){break b}ik=q[hk+52>>2];while(1){if((ik|0)<1){break b}ik=ik+ -1|0;q[hk+52>>2]=ik;ki=r[ik+nk|0]|ki<<8;q[hk+56>>2]=ki;if(ki>>>0<16384){continue}break}}ik=ki&4095;kk=q[(ik<<2)+ok>>2];lk=(kk<<3)+mk|0;ki=(w(q[lk>>2],ki>>>12)+ik|0)-q[lk+4>>2]|0;q[hk+56>>2]=ki;q[(jk<<2)+gk>>2]=kk;ik=1;jk=jk+1|0;if((jk|0)!=(a|0)){continue}break}}a=q[hk+36>>2];if(a){q[hk+40>>2]=a;An(a)}a=q[hk+24>>2];if(a){q[hk+28>>2]=a;An(a)}a=q[hk+8>>2];if(a){q[hk+12>>2]=a;An(a)}T=hk- -64|0;return ik}function wh(a,ki,gk){var pk=0,qk=0,rk=0,sk=0,tk=0,uk=0,vk=0,wk=0;pk=T+ -64|0;T=pk;q[pk+56>>2]=0;q[pk+48>>2]=0;q[pk+52>>2]=0;q[pk+40>>2]=0;q[pk+44>>2]=0;q[pk+32>>2]=0;q[pk+36>>2]=0;q[pk+24>>2]=0;q[pk+28>>2]=0;q[pk+16>>2]=0;q[pk+20>>2]=0;q[pk+8>>2]=0;q[pk+12>>2]=0;a:{if(!Fh(pk+8|0,ki)|(q[pk+20>>2]?0:a)){break a}qk=Gh(pk+8|0,ki);if(!a|!qk){break a}ki=q[pk+56>>2];uk=q[pk+36>>2];vk=q[pk+48>>2];wk=q[pk+24>>2];while(1){b:{if(ki>>>0>32767){break b}qk=q[pk+52>>2];while(1){if((qk|0)<1){break b}qk=qk+ -1|0;q[pk+52>>2]=qk;ki=r[qk+vk|0]|ki<<8;q[pk+56>>2]=ki;if(ki>>>0<32768){continue}break}}qk=ki&8191;sk=q[(qk<<2)+wk>>2];tk=(sk<<3)+uk|0;ki=(w(q[tk>>2],ki>>>13)+qk|0)-q[tk+4>>2]|0;q[pk+56>>2]=ki;q[(rk<<2)+gk>>2]=sk;qk=1;rk=rk+1|0;if((rk|0)!=(a|0)){continue}break}}a=q[pk+36>>2];if(a){q[pk+40>>2]=a;An(a)}a=q[pk+24>>2];if(a){q[pk+28>>2]=a;An(a)}a=q[pk+8>>2];if(a){q[pk+12>>2]=a;An(a)}T=pk- -64|0;return qk}function xh(a,ki,gk){var xk=0,yk=0,zk=0,Ak=0,Bk=0,Ck=0,Dk=0,Ek=0;xk=T+ -64|0;T=xk;q[xk+56>>2]=0;q[xk+48>>2]=0;q[xk+52>>2]=0;q[xk+40>>2]=0;q[xk+44>>2]=0;q[xk+32>>2]=0;q[xk+36>>2]=0;q[xk+24>>2]=0;q[xk+28>>2]=0;q[xk+16>>2]=0;q[xk+20>>2]=0;q[xk+8>>2]=0;q[xk+12>>2]=0;a:{if(!Hh(xk+8|0,ki)|(q[xk+20>>2]?0:a)){break a}yk=Ih(xk+8|0,ki);if(!a|!yk){break a}ki=q[xk+56>>2];Ck=q[xk+36>>2];Dk=q[xk+48>>2];Ek=q[xk+24>>2];while(1){b:{if(ki>>>0>131071){break b}yk=q[xk+52>>2];while(1){if((yk|0)<1){break b}yk=yk+ -1|0;q[xk+52>>2]=yk;ki=r[yk+Dk|0]|ki<<8;q[xk+56>>2]=ki;if(ki>>>0<131072){continue}break}}yk=ki&32767;Ak=q[(yk<<2)+Ek>>2];Bk=(Ak<<3)+Ck|0;ki=(w(q[Bk>>2],ki>>>15)+yk|0)-q[Bk+4>>2]|0;q[xk+56>>2]=ki;q[(zk<<2)+gk>>2]=Ak;yk=1;zk=zk+1|0;if((zk|0)!=(a|0)){continue}break}}a=q[xk+36>>2];if(a){q[xk+40>>2]=a;An(a)}a=q[xk+24>>2];if(a){q[xk+28>>2]=a;An(a)}a=q[xk+8>>2];if(a){q[xk+12>>2]=a;An(a)}T=xk- -64|0;return yk}function yh(a,ki,gk){var Fk=0,Gk=0,Hk=0,Ik=0,Jk=0,Kk=0,Lk=0,Mk=0;Fk=T+ -64|0;T=Fk;q[Fk+56>>2]=0;q[Fk+48>>2]=0;q[Fk+52>>2]=0;q[Fk+40>>2]=0;q[Fk+44>>2]=0;q[Fk+32>>2]=0;q[Fk+36>>2]=0;q[Fk+24>>2]=0;q[Fk+28>>2]=0;q[Fk+16>>2]=0;q[Fk+20>>2]=0;q[Fk+8>>2]=0;q[Fk+12>>2]=0;a:{if(!Jh(Fk+8|0,ki)|(q[Fk+20>>2]?0:a)){break a}Gk=Kh(Fk+8|0,ki);if(!a|!Gk){break a}ki=q[Fk+56>>2];Kk=q[Fk+36>>2];Lk=q[Fk+48>>2];Mk=q[Fk+24>>2];while(1){b:{if(ki>>>0>262143){break b}Gk=q[Fk+52>>2];while(1){if((Gk|0)<1){break b}Gk=Gk+ -1|0;q[Fk+52>>2]=Gk;ki=r[Gk+Lk|0]|ki<<8;q[Fk+56>>2]=ki;if(ki>>>0<262144){continue}break}}Gk=ki&65535;Ik=q[(Gk<<2)+Mk>>2];Jk=(Ik<<3)+Kk|0;ki=(w(q[Jk>>2],ki>>>16)+Gk|0)-q[Jk+4>>2]|0;q[Fk+56>>2]=ki;q[(Hk<<2)+gk>>2]=Ik;Gk=1;Hk=Hk+1|0;if((Hk|0)!=(a|0)){continue}break}}a=q[Fk+36>>2];if(a){q[Fk+40>>2]=a;An(a)}a=q[Fk+24>>2];if(a){q[Fk+28>>2]=a;An(a)}a=q[Fk+8>>2];if(a){q[Fk+12>>2]=a;An(a)}T=Fk- -64|0;return Gk}function zh(a,ki,gk){var Nk=0,Ok=0,Pk=0,Qk=0,Rk=0,Sk=0,Tk=0,Uk=0;Nk=T+ -64|0;T=Nk;q[Nk+56>>2]=0;q[Nk+48>>2]=0;q[Nk+52>>2]=0;q[Nk+40>>2]=0;q[Nk+44>>2]=0;q[Nk+32>>2]=0;q[Nk+36>>2]=0;q[Nk+24>>2]=0;q[Nk+28>>2]=0;q[Nk+16>>2]=0;q[Nk+20>>2]=0;q[Nk+8>>2]=0;q[Nk+12>>2]=0;a:{if(!Lh(Nk+8|0,ki)|(q[Nk+20>>2]?0:a)){break a}Ok=Mh(Nk+8|0,ki);if(!a|!Ok){break a}ki=q[Nk+56>>2];Sk=q[Nk+36>>2];Tk=q[Nk+48>>2];Uk=q[Nk+24>>2];while(1){b:{if(ki>>>0>1048575){break b}Ok=q[Nk+52>>2];while(1){if((Ok|0)<1){break b}Ok=Ok+ -1|0;q[Nk+52>>2]=Ok;ki=r[Ok+Tk|0]|ki<<8;q[Nk+56>>2]=ki;if(ki>>>0<1048576){continue}break}}Ok=ki&262143;Qk=q[(Ok<<2)+Uk>>2];Rk=(Q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a)}a=q[Vk+8>>2];if(a){q[Vk+12>>2]=a;An(a)}T=Vk- -64|0;return Wk}function Bh(a,ki,gk){var bl=0,cl=0,dl=0,el=0,fl=0,gl=0,hl=0,il=0;bl=T+ -64|0;T=bl;q[bl+56>>2]=0;q[bl+48>>2]=0;q[bl+52>>2]=0;q[bl+40>>2]=0;q[bl+44>>2]=0;q[bl+32>>2]=0;q[bl+36>>2]=0;q[bl+24>>2]=0;q[bl+28>>2]=0;q[bl+16>>2]=0;q[bl+20>>2]=0;q[bl+8>>2]=0;q[bl+12>>2]=0;a:{if(!Ph(bl+8|0,ki)|(q[bl+20>>2]?0:a)){break a}cl=Qh(bl+8|0,ki);if(!a|!cl){break a}ki=q[bl+56>>2];gl=q[bl+36>>2];hl=q[bl+48>>2];il=q[bl+24>>2];while(1){b:{if(ki>>>0>4194303){break b}cl=q[bl+52>>2];while(1){if((cl|0)<1){break b}cl=cl+ -1|0;q[bl+52>>2]=cl;ki=r[cl+hl|0]|ki<<8;q[bl+56>>2]=ki;if(ki>>>0<4194304){continue}break}}cl=ki&1048575;el=q[(cl<<2)+il>>2];fl=(el<<3)+gl|0;ki=(w(q[fl>>2],ki>>>20)+cl|0)-q[fl+4>>2]|0;q[bl+56>>2]=ki;q[(dl<<2)+gk>>2]=el;cl=1;dl=dl+1|0;if((dl|0)!=(a|0)){continue}break}}a=q[bl+36>>2];if(a){q[bl+40>>2]=a;An(a)}a=q[bl+24>>2];if(a){q[bl+28>>2]=a;An(a)}a=q[bl+8>>2];if(a){q[bl+12>>2]=a;An(a)}T=bl- -64|0;return cl}function Ch(a,ki,gk){var jl=0,kl=0,ll=0,ml=0;a:{if(a>>>0>5){break a}ll=q[gk+16>>2];jl=q[gk+12>>2];kl=q[gk+20>>2];if((jl|0)<(kl|0)?1:(jl|0)<=(kl|0)?t[gk+8>>2]>ll>>>0?0:1:0){break a}jl=r[ll+q[gk>>2]|0];ll=ll+1|0;if(ll>>>0<1){kl=kl+1|0}q[gk+16>>2]=ll;q[gk+20>>2]=kl;kl=ki;if(jl&128){if(!Ch(a+1|0,ki,gk)){break a}a=q[ki>>2]<<7;q[ki>>2]=a;jl=a|jl&127}q[kl>>2]=jl;ml=1}return ml}function Dh(a,ki){var gk=0,nl=0,ol=0,pl=0,ql=0,rl=0,sl=0;a:{b:{ol=q[a+8>>2];gk=a+4|0;nl=q[gk>>2];c:{if(ol-nl>>3>>>0>=ki>>>0){while(1){q[nl>>2]=0;q[nl+4>>2]=0;nl=q[gk>>2]+8|0;q[gk>>2]=nl;ki=ki+ -1|0;if(ki){continue}break c}}pl=q[a>>2];ql=nl-pl|0;gk=ql>>3;nl=gk+ki|0;if(nl>>>0>=536870912){break b}sl=gk<<3;ol=ol-pl|0;gk=ol>>2;ol=ol>>3>>>0<268435455?gk>>>0>>0?nl:gk:536870911;gk=0;d:{if(!ol){break d}if(ol>>>0>=536870912){break a}rl=Mm(ol<<3);gk=rl}nl=sl+gk|0;Dn(nl,0,ki<<3);ol=gk+(ol<<3)|0;while(1){nl=nl+8|0;ki=ki+ -1|0;if(ki){continue}break}if((ql|0)>=1){Cn(rl,pl,ql)}q[a>>2]=gk;q[a+8>>2]=ol;q[a+4>>2]=nl;if(!pl){break c}An(pl)}return}bn();F()}ab(10991);F()}function Eh(a,ki,tl){var ul=0,vl=0,wl=0,xl=0,yl=0,zl=0;a:{if(a>>>0>10){break a}wl=q[tl+16>>2];ul=q[tl+12>>2];vl=q[tl+20>>2];xl=vl;if((ul|0)<(xl|0)?1:(ul|0)<=(xl|0)?t[tl+8>>2]>wl>>>0?0:1:0){break a}yl=o[wl+q[tl>>2]|0];ul=wl+1|0;if(ul>>>0<1){vl=vl+1|0}q[tl+16>>2]=ul;q[tl+20>>2]=vl;xl=ki;wl=ki;ul=yl;b:{if((ul|0)<=-1){if(!Eh(a+1|0,ki,tl)){break a}a=ki;tl=q[ki+4>>2];ki=q[ki>>2];vl=tl<<7|ki>>>25;ki=ki<<7;q[a>>2]=ki;q[a+4>>2]=vl;a=ul&127|ki;break b}vl=0;a=ul&255}q[wl>>2]=a;q[xl+4>>2]=vl;zl=1}return zl}function Fh(a,ki){var tl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0;a:{tl=s[ki+38>>1];if(!tl){break a}Fl=a+12|0;b:{if(tl>>>0<=511){Al=q[ki+12>>2];tl=q[ki+20>>2];Bl=q[ki+16>>2];Dl=Bl+4|0;if(Dl>>>0<4){tl=tl+1|0}if((Al|0)<(tl|0)?1:(Al|0)<=(tl|0)?t[ki+8>>2]>=Dl>>>0?0:1:0){break a}tl=Bl+q[ki>>2]|0;Bl=r[tl|0]|r[tl+1|0]<<8|(r[tl+2|0]<<16|r[tl+3|0]<<24);q[Fl>>2]=Bl;Al=q[ki+20>>2];Dl=q[ki+16>>2]+4|0;if(Dl>>>0<4){Al=Al+1|0}tl=ki;q[tl+16>>2]=Dl;q[tl+20>>2]=Al;break b}if(!Ch(1,Fl,ki)){break a}Bl=q[Fl>>2]}Al=q[a>>2];tl=q[a+4>>2]-Al>>2;c:{if(Bl>>>0>tl>>>0){Fa(a,Bl-tl|0);Bl=q[a+12>>2];break c}if(Bl>>>0>=tl>>>0){break c}q[a+4>>2]=Al+(Bl<<2)}if(!Bl){Ll=1;break a}Jl=q[ki+8>>2];Dl=q[ki+12>>2];while(1){Cl=q[ki+16>>2];tl=q[ki+20>>2];if((Dl|0)<(tl|0)?1:(Dl|0)<=(tl|0)?Jl>>>0>Cl>>>0?0:1:0){break a}Kl=q[ki>>2];Gl=r[Kl+Cl|0];Cl=Cl+1|0;if(Cl>>>0<1){tl=tl+1|0}q[ki+16>>2]=Cl;q[ki+20>>2]=tl;Hl=Gl>>>2;d:{e:{f:{Il=Gl&3;if(Il>>>0>3){Al=0;break f}Al=0;g:{switch(Il-1|0){case 0:case 1:break f;case 2:break g;default:break e}}tl=El+Hl|0;if(tl>>>0>=Bl>>>0){return 0}Dn(q[a>>2]+(El<<2)|0,0,(Gl&252)+4|0);El=tl;break d}while(1){if((Dl|0)<(tl|0)?1:(Dl|0)<=(tl|0)?Jl>>>0>Cl>>>0?0:1:0){return 0}Gl=r[Cl+Kl|0];Cl=Cl+1|0;if(Cl>>>0<1){tl=tl+1|0}q[ki+16>>2]=Cl;q[ki+20>>2]=tl;Hl=Gl<<(Al<<3|6)|Hl;Al=Al+1|0;if((Il|0)!=(Al|0)){continue}break}}q[q[a>>2]+(El<<2)>>2]=Hl}El=El+1|0;Bl=q[Fl>>2];if(El>>>0>>0){continue}break}El=a+16|0;Fl=q[a>>2];ki=q[a+16>>2];tl=q[a+20>>2]-ki|0;Al=tl>>2;h:{if(Al>>>0<=8191){Fa(El,8192-Al|0);break h}if((tl|0)==32768){break h}q[a+20>>2]=ki+32768}i:{ki=a+28|0;tl=q[ki>>2];Al=q[a+32>>2]-tl>>3;if(Bl>>>0>Al>>>0){Dh(ki,Bl-Al|0);tl=q[ki>>2];break i}if(Bl>>>0>>0){q[a+32>>2]=(Bl<<3)+tl}if(Bl){break i}return 0}ki=0;Al=0;while(1){a=Fl+(ki<<2)|0;Dl=q[a>>2];Cl=(ki<<3)+tl|0;q[Cl+4>>2]=Al;q[Cl>>2]=Dl;a=q[a>>2]+Al|0;if(a>>>0>8192){break a}if(Al>>>0>>0){Dl=q[El>>2];while(1){q[Dl+(Al<<2)>>2]=ki;Al=Al+1|0;if((a|0)!=(Al|0)){continue}break}}Al=a;ki=ki+1|0;if((Bl|0)!=(ki|0)){continue}break}return(a|0)==8192}return Ll}function Gh(a,ki){var Ml=0,Nl=0,Ol=0,Pl=0,Ql=0,Rl=0,Sl=0,Tl=0,Ul=0;Ql=T-16|0;T=Ql;a:{b:{if(s[ki+38>>1]<=511){Nl=q[ki+12>>2];Tl=Nl;Ml=q[ki+20>>2];Ol=q[ki+16>>2];Pl=Ol+8|0;if(Pl>>>0<8){Ml=Ml+1|0}Rl=q[ki+8>>2];if((Nl|0)<(Ml|0)?1:(Nl|0)<=(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|0)?1:(Zl|0)<=(Vl|0)?dm>>>0>Yl>>>0?0:1:0){return 0}am=r[Yl+em|0];Yl=Yl+1|0;if(Yl>>>0<1){Vl=Vl+1|0}q[ki+16>>2]=Yl;q[ki+20>>2]=Vl;bm=am<<(Wl<<3|6)|bm;Wl=Wl+1|0;if((cm|0)!=(Wl|0)){continue}break}}q[q[a>>2]+(_l<<2)>>2]=bm}_l=_l+1|0;Xl=q[$l>>2];if(_l>>>0>>0){continue}break}_l=a+16|0;$l=q[a>>2];ki=q[a+16>>2];Vl=q[a+20>>2]-ki|0;Wl=Vl>>2;h:{if(Wl>>>0<=32767){Fa(_l,32768-Wl|0);break h}if((Vl|0)==131072){break h}q[a+20>>2]=ki+131072}i:{ki=a+28|0;Vl=q[ki>>2];Wl=q[a+32>>2]-Vl>>3;if(Xl>>>0>Wl>>>0){Dh(ki,Xl-Wl|0);Vl=q[ki>>2];break i}if(Xl>>>0>>0){q[a+32>>2]=(Xl<<3)+Vl}if(Xl){break i}return 0}ki=0;Wl=0;while(1){a=$l+(ki<<2)|0;Zl=q[a>>2];Yl=(ki<<3)+Vl|0;q[Yl+4>>2]=Wl;q[Yl>>2]=Zl;a=q[a>>2]+Wl|0;if(a>>>0>32768){break a}if(Wl>>>0>>0){Zl=q[_l>>2];while(1){q[Zl+(Wl<<2)>>2]=ki;Wl=Wl+1|0;if((a|0)!=(Wl|0)){continue}break}}Wl=a;ki=ki+1|0;if((Xl|0)!=(ki|0)){continue}break}return(a|0)==32768}return fm}function Ih(a,ki){var gm=0,hm=0,im=0,jm=0,km=0,lm=0,mm=0,nm=0,om=0;km=T-16|0;T=km;a:{b:{if(s[ki+38>>1]<=511){hm=q[ki+12>>2];nm=hm;gm=q[ki+20>>2];im=q[ki+16>>2];jm=im+8|0;if(jm>>>0<8){gm=gm+1|0}lm=q[ki+8>>2];if((hm|0)<(gm|0)?1:(hm|0)<=(gm|0)?lm>>>0>=jm>>>0?0:1:0){break a}hm=im+q[ki>>2]|0;im=r[hm+4|0]|r[hm+5|0]<<8|(r[hm+6|0]<<16|r[hm+7|0]<<24);hm=r[hm|0]|r[hm+1|0]<<8|(r[hm+2|0]<<16|r[hm+3|0]<<24);q[km+8>>2]=hm;q[km+12>>2]=im;q[ki+16>>2]=jm;q[ki+20>>2]=gm;break b}if(!Eh(1,km+8|0,ki)){break a}jm=q[ki+16>>2];gm=q[ki+20>>2];lm=q[ki+8>>2];nm=q[ki+12>>2];hm=q[km+8>>2];im=q[km+12>>2]}mm=lm-jm|0;lm=nm-(gm+(lm>>>0>>0)|0)|0;if((lm|0)==(im|0)&hm>>>0>mm>>>0|im>>>0>lm>>>0){break a}im=gm+im|0;gm=jm;mm=gm+hm|0;if(mm>>>0>>0){im=im+1|0}q[ki+16>>2]=mm;q[ki+20>>2]=im;gm=hm;if((gm|0)<1){break a}jm=jm+q[ki>>2]|0;q[a+40>>2]=jm;ki=a;c:{d:{e:{f:{g:{hm=gm+ -1|0;im=jm+hm|0;switch((r[im|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=hm;a=r[im|0]&63;break c}if((gm|0)<2){break a}q[a+44>>2]=gm+ -2;a=(gm+jm|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((gm|0)<3){break a}q[a+44>>2]=gm+ -3;a=(gm+jm|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=gm+ -4;a=(gm+jm|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+131072|0;q[ki+48>>2]=a;om=a>>>0<33554432}T=km+16|0;return om}function Jh(a,ki){var pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0;a:{pm=s[ki+38>>1];if(!pm){break a}vm=a+12|0;b:{if(pm>>>0<=511){qm=q[ki+12>>2];pm=q[ki+20>>2];rm=q[ki+16>>2];tm=rm+4|0;if(tm>>>0<4){pm=pm+1|0}if((qm|0)<(pm|0)?1:(qm|0)<=(pm|0)?t[ki+8>>2]>=tm>>>0?0:1:0){break a}pm=rm+q[ki>>2]|0;rm=r[pm|0]|r[pm+1|0]<<8|(r[pm+2|0]<<16|r[pm+3|0]<<24);q[vm>>2]=rm;qm=q[ki+20>>2];tm=q[ki+16>>2]+4|0;if(tm>>>0<4){qm=qm+1|0}pm=ki;q[pm+16>>2]=tm;q[pm+20>>2]=qm;break b}if(!Ch(1,vm,ki)){break a}rm=q[vm>>2]}qm=q[a>>2];pm=q[a+4>>2]-qm>>2;c:{if(rm>>>0>pm>>>0){Fa(a,rm-pm|0);rm=q[a+12>>2];break c}if(rm>>>0>=pm>>>0){break c}q[a+4>>2]=qm+(rm<<2)}if(!rm){Bm=1;break a}zm=q[ki+8>>2];tm=q[ki+12>>2];while(1){sm=q[ki+16>>2];pm=q[ki+20>>2];if((tm|0)<(pm|0)?1:(tm|0)<=(pm|0)?zm>>>0>sm>>>0?0:1:0){break a}Am=q[ki>>2];wm=r[Am+sm|0];sm=sm+1|0;if(sm>>>0<1){pm=pm+1|0}q[ki+16>>2]=sm;q[ki+20>>2]=pm;xm=wm>>>2;d:{e:{f:{ym=wm&3;if(ym>>>0>3){qm=0;break f}qm=0;g:{switch(ym-1|0){case 0:case 1:break f;case 2:break g;default:break e}}pm=um+xm|0;if(pm>>>0>=rm>>>0){return 0}Dn(q[a>>2]+(um<<2)|0,0,(wm&252)+4|0);um=pm;break d}while(1){if((tm|0)<(pm|0)?1:(tm|0)<=(pm|0)?zm>>>0>sm>>>0?0:1:0){return 0}wm=r[sm+Am|0];sm=sm+1|0;if(sm>>>0<1){pm=pm+1|0}q[ki+16>>2]=sm;q[ki+20>>2]=pm;xm=wm<<(qm<<3|6)|xm;qm=qm+1|0;if((ym|0)!=(qm|0)){continue}break}}q[q[a>>2]+(um<<2)>>2]=xm}um=um+1|0;rm=q[vm>>2];if(um>>>0>>0){continue}break}um=a+16|0;vm=q[a>>2];ki=q[a+16>>2];pm=q[a+20>>2]-ki|0;qm=pm>>2;h:{if(qm>>>0<=65535){Fa(um,65536-qm|0);break h}if((pm|0)==262144){break h}q[a+20>>2]=ki+262144}i:{ki=a+28|0;pm=q[ki>>2];qm=q[a+32>>2]-pm>>3;if(rm>>>0>qm>>>0){Dh(ki,rm-qm|0);pm=q[ki>>2];break i}if(rm>>>0>>0){q[a+32>>2]=(rm<<3)+pm}if(rm){break i}return 0}ki=0;qm=0;while(1){a=vm+(ki<<2)|0;tm=q[a>>2];sm=(ki<<3)+pm|0;q[sm+4>>2]=qm;q[sm>>2]=tm;a=q[a>>2]+qm|0;if(a>>>0>65536){break a}if(qm>>>0>>0){tm=q[um>>2];while(1){q[tm+(qm<<2)>>2]=ki;qm=qm+1|0;if((a|0)!=(qm|0)){continue}break}}qm=a;ki=ki+1|0;if((rm|0)!=(ki|0)){continue}break}return(a|0)==65536}return Bm}function Kh(a,ki){var Cm=0,Dm=0,Em=0,Fm=0,Gm=0,Hm=0,Im=0,Jm=0,Km=0;Gm=T-16|0;T=Gm;a:{b:{if(s[ki+38>>1]<=511){Dm=q[ki+12>>2];Jm=Dm;Cm=q[ki+20>>2];Em=q[ki+16>>2];Fm=Em+8|0;if(Fm>>>0<8){Cm=Cm+1|0}Hm=q[ki+8>>2];if((Dm|0)<(Cm|0)?1:(Dm|0)<=(Cm|0)?Hm>>>0>=Fm>>>0?0:1:0){break a}Dm=Em+q[ki>>2]|0;Em=r[Dm+4|0]|r[Dm+5|0]<<8|(r[Dm+6|0]<<16|r[Dm+7|0]<<24);Dm=r[Dm|0]|r[Dm+1|0]<<8|(r[Dm+2|0]<<16|r[Dm+3|0]<<24);q[Gm+8>>2]=Dm;q[Gm+12>>2]=Em;q[ki+16>>2]=Fm;q[ki+20>>2]=Cm;break b}if(!Eh(1,Gm+8|0,ki)){break a}Fm=q[ki+16>>2];Cm=q[ki+20>>2];Hm=q[ki+8>>2];Jm=q[ki+12>>2];Dm=q[Gm+8>>2];Em=q[Gm+12>>2]}Im=Hm-Fm|0;Hm=Jm-(Cm+(Hm>>>0>>0)|0)|0;if((Hm|0)==(Em|0)&Dm>>>0>Im>>>0|Em>>>0>Hm>>>0){break a}Em=Cm+Em|0;Cm=Fm;Im=Cm+Dm|0;if(Im>>>0>>0){Em=Em+1|0}q[ki+16>>2]=Im;q[ki+20>>2]=Em;Cm=Dm;if((Cm|0)<1){break a}Fm=Fm+q[ki>>2]|0;q[a+40>>2]=Fm;ki=a;c:{d:{e:{f:{g:{Dm=Cm+ -1|0;Em=Fm+Dm|0;switch((r[Em|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=Dm;a=r[Em|0]&63;break c}if((Cm|0)<2){break a}q[a+44>>2]=Cm+ -2;a=(Cm+Fm|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Cm|0)<3){break a}q[a+44>>2]=Cm+ -3;a=(Cm+Fm|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Cm+ -4;a=(Cm+Fm|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+262144|0;q[ki+48>>2]=a;Km=a>>>0<67108864}T=Gm+16|0;return Km}function Lh(a,ki){var Lm=0,Mm=0,Nm=0,Om=0,Pm=0,Qm=0,Rm=0,Sm=0,Tm=0,Um=0,Vm=0,Wm=0,Xm=0;a:{Lm=s[ki+38>>1];if(!Lm){break a}Rm=a+12|0;b:{if(Lm>>>0<=511){Mm=q[ki+12>>2];Lm=q[ki+20>>2];Nm=q[ki+16>>2];Pm=Nm+4|0;if(Pm>>>0<4){Lm=Lm+1|0}if((Mm|0)<(Lm|0)?1:(Mm|0)<=(Lm|0)?t[ki+8>>2]>=Pm>>>0?0:1:0){break a}Lm=Nm+q[ki>>2]|0;Nm=r[Lm|0]|r[Lm+1|0]<<8|(r[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|0;Mm=Lm>>2;h:{if(Mm>>>0<=262143){Fa(Qm,262144-Mm|0);break h}if((Lm|0)==1048576){break h}q[a+20>>2]=ki- -1048576}i:{ki=a+28|0;Lm=q[ki>>2];Mm=q[a+32>>2]-Lm>>3;if(Nm>>>0>Mm>>>0){Dh(ki,Nm-Mm|0);Lm=q[ki>>2];break i}if(Nm>>>0>>0){q[a+32>>2]=(Nm<<3)+Lm}if(Nm){break i}return 0}ki=0;Mm=0;while(1){a=Rm+(ki<<2)|0;Pm=q[a>>2];Om=(ki<<3)+Lm|0;q[Om+4>>2]=Mm;q[Om>>2]=Pm;a=q[a>>2]+Mm|0;if(a>>>0>262144){break a}if(Mm>>>0>>0){Pm=q[Qm>>2];while(1){q[Pm+(Mm<<2)>>2]=ki;Mm=Mm+1|0;if((a|0)!=(Mm|0)){continue}break}}Mm=a;ki=ki+1|0;if((Nm|0)!=(ki|0)){continue}break}return(a|0)==262144}return Xm}function Mh(a,ki){var Ym=0,Zm=0,_m=0,$m=0,an=0,bn=0,cn=0,dn=0,en=0;an=T-16|0;T=an;a:{b:{if(s[ki+38>>1]<=511){Zm=q[ki+12>>2];dn=Zm;Ym=q[ki+20>>2];_m=q[ki+16>>2];$m=_m+8|0;if($m>>>0<8){Ym=Ym+1|0}bn=q[ki+8>>2];if((Zm|0)<(Ym|0)?1:(Zm|0)<=(Ym|0)?bn>>>0>=$m>>>0?0:1:0){break a}Zm=_m+q[ki>>2]|0;_m=r[Zm+4|0]|r[Zm+5|0]<<8|(r[Zm+6|0]<<16|r[Zm+7|0]<<24);Zm=r[Zm|0]|r[Zm+1|0]<<8|(r[Zm+2|0]<<16|r[Zm+3|0]<<24);q[an+8>>2]=Zm;q[an+12>>2]=_m;q[ki+16>>2]=$m;q[ki+20>>2]=Ym;break b}if(!Eh(1,an+8|0,ki)){break a}$m=q[ki+16>>2];Ym=q[ki+20>>2];bn=q[ki+8>>2];dn=q[ki+12>>2];Zm=q[an+8>>2];_m=q[an+12>>2]}cn=bn-$m|0;bn=dn-(Ym+(bn>>>0<$m>>>0)|0)|0;if((bn|0)==(_m|0)&Zm>>>0>cn>>>0|_m>>>0>bn>>>0){break a}_m=Ym+_m|0;Ym=$m;cn=Ym+Zm|0;if(cn>>>0>>0){_m=_m+1|0}q[ki+16>>2]=cn;q[ki+20>>2]=_m;Ym=Zm;if((Ym|0)<1){break a}$m=$m+q[ki>>2]|0;q[a+40>>2]=$m;ki=a;c:{d:{e:{f:{g:{Zm=Ym+ -1|0;_m=$m+Zm|0;switch((r[_m|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=Zm;a=r[_m|0]&63;break c}if((Ym|0)<2){break a}q[a+44>>2]=Ym+ -2;a=(Ym+$m|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Ym|0)<3){break a}q[a+44>>2]=Ym+ -3;a=(Ym+$m|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Ym+ -4;a=(Ym+$m|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a- -1048576|0;q[ki+48>>2]=a;en=a>>>0<268435456}T=an+16|0;return en}function Nh(a,ki){var fn=0,gn=0,hn=0,jn=0,kn=0,ln=0,mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0;a:{fn=s[ki+38>>1];if(!fn){break a}mn=a+12|0;b:{if(fn>>>0<=511){gn=q[ki+12>>2];fn=q[ki+20>>2];hn=q[ki+16>>2];kn=hn+4|0;if(kn>>>0<4){fn=fn+1|0}if((gn|0)<(fn|0)?1:(gn|0)<=(fn|0)?t[ki+8>>2]>=kn>>>0?0:1:0){break a}fn=hn+q[ki>>2]|0;hn=r[fn|0]|r[fn+1|0]<<8|(r[fn+2|0]<<16|r[fn+3|0]<<24);q[mn>>2]=hn;gn=q[ki+20>>2];kn=q[ki+16>>2]+4|0;if(kn>>>0<4){gn=gn+1|0}fn=ki;q[fn+16>>2]=kn;q[fn+20>>2]=gn;break b}if(!Ch(1,mn,ki)){break a}hn=q[mn>>2]}gn=q[a>>2];fn=q[a+4>>2]-gn>>2;c:{if(hn>>>0>fn>>>0){Fa(a,hn-fn|0);hn=q[a+12>>2];break c}if(hn>>>0>=fn>>>0){break c}q[a+4>>2]=gn+(hn<<2)}if(!hn){sn=1;break a}qn=q[ki+8>>2];kn=q[ki+12>>2];while(1){jn=q[ki+16>>2];fn=q[ki+20>>2];if((kn|0)<(fn|0)?1:(kn|0)<=(fn|0)?qn>>>0>jn>>>0?0:1:0){break a}rn=q[ki>>2];nn=r[rn+jn|0];jn=jn+1|0;if(jn>>>0<1){fn=fn+1|0}q[ki+16>>2]=jn;q[ki+20>>2]=fn;on=nn>>>2;d:{e:{f:{pn=nn&3;if(pn>>>0>3){gn=0;break f}gn=0;g:{switch(pn-1|0){case 0:case 1:break f;case 2:break g;default:break e}}fn=ln+on|0;if(fn>>>0>=hn>>>0){return 0}Dn(q[a>>2]+(ln<<2)|0,0,(nn&252)+4|0);ln=fn;break d}while(1){if((kn|0)<(fn|0)?1:(kn|0)<=(fn|0)?qn>>>0>jn>>>0?0:1:0){return 0}nn=r[jn+rn|0];jn=jn+1|0;if(jn>>>0<1){fn=fn+1|0}q[ki+16>>2]=jn;q[ki+20>>2]=fn;on=nn<<(gn<<3|6)|on;gn=gn+1|0;if((pn|0)!=(gn|0)){continue}break}}q[q[a>>2]+(ln<<2)>>2]=on}ln=ln+1|0;hn=q[mn>>2];if(ln>>>0>>0){continue}break}ln=a+16|0;mn=q[a>>2];ki=q[a+16>>2];fn=q[a+20>>2]-ki|0;gn=fn>>2;h:{if(gn>>>0<=524287){Fa(ln,524288-gn|0);break h}if((fn|0)==2097152){break h}q[a+20>>2]=ki+2097152}i:{ki=a+28|0;fn=q[ki>>2];gn=q[a+32>>2]-fn>>3;if(hn>>>0>gn>>>0){Dh(ki,hn-gn|0);fn=q[ki>>2];break i}if(hn>>>0>>0){q[a+32>>2]=(hn<<3)+fn}if(hn){break i}return 0}ki=0;gn=0;while(1){a=mn+(ki<<2)|0;kn=q[a>>2];jn=(ki<<3)+fn|0;q[jn+4>>2]=gn;q[jn>>2]=kn;a=q[a>>2]+gn|0;if(a>>>0>524288){break a}if(gn>>>0>>0){kn=q[ln>>2];while(1){q[kn+(gn<<2)>>2]=ki;gn=gn+1|0;if((a|0)!=(gn|0)){continue}break}}gn=a;ki=ki+1|0;if((hn|0)!=(ki|0)){continue}break}return(a|0)==524288}return sn}function Oh(a,ki){var tn=0,un=0,vn=0,wn=0,xn=0,yn=0,zn=0,An=0,Bn=0;xn=T-16|0;T=xn;a:{b:{if(s[ki+38>>1]<=511){un=q[ki+12>>2];An=un;tn=q[ki+20>>2];vn=q[ki+16>>2];wn=vn+8|0;if(wn>>>0<8){tn=tn+1|0}yn=q[ki+8>>2];if((un|0)<(tn|0)?1:(un|0)<=(tn|0)?yn>>>0>=wn>>>0?0:1:0){break a}un=vn+q[ki>>2]|0;vn=r[un+4|0]|r[un+5|0]<<8|(r[un+6|0]<<16|r[un+7|0]<<24);un=r[un|0]|r[un+1|0]<<8|(r[un+2|0]<<16|r[un+3|0]<<24);q[xn+8>>2]=un;q[xn+12>>2]=vn;q[ki+16>>2]=wn;q[ki+20>>2]=tn;break b}if(!Eh(1,xn+8|0,ki)){break a}wn=q[ki+16>>2];tn=q[ki+20>>2];yn=q[ki+8>>2];An=q[ki+12>>2];un=q[xn+8>>2];vn=q[xn+12>>2]}zn=yn-wn|0;yn=An-(tn+(yn>>>0>>0)|0)|0;if((yn|0)==(vn|0)&un>>>0>zn>>>0|vn>>>0>yn>>>0){break a}vn=tn+vn|0;tn=wn;zn=tn+un|0;if(zn>>>0>>0){vn=vn+1|0}q[ki+16>>2]=zn;q[ki+20>>2]=vn;tn=un;if((tn|0)<1){break a}wn=wn+q[ki>>2]|0;q[a+40>>2]=wn;ki=a;c:{d:{e:{f:{g:{un=tn+ -1|0;vn=wn+un|0;switch((r[vn|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=un;a=r[vn|0]&63;break c}if((tn|0)<2){break a}q[a+44>>2]=tn+ -2;a=(tn+wn|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((tn|0)<3){break a}q[a+44>>2]=tn+ -3;a=(tn+wn|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=tn+ -4;a=(tn+wn|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+2097152|0;q[ki+48>>2]=a;Bn=a>>>0<536870912}T=xn+16|0;return Bn}function Ph(a,ki){var Cn=0,En=0,Fn=0,Gn=0,Hn=0,In=0,Jn=0,Kn=0,Ln=0,Mn=0,Nn=0,On=0,Pn=0;a:{Cn=s[ki+38>>1];if(!Cn){break a}Jn=a+12|0;b:{if(Cn>>>0<=511){En=q[ki+12>>2];Cn=q[ki+20>>2];Fn=q[ki+16>>2];Hn=Fn+4|0;if(Hn>>>0<4){Cn=Cn+1|0}if((En|0)<(Cn|0)?1:(En|0)<=(Cn|0)?t[ki+8>>2]>=Hn>>>0?0:1:0){break a}Cn=Fn+q[ki>>2]|0;Fn=r[Cn|0]|r[Cn+1|0]<<8|(r[Cn+2|0]<<16|r[Cn+3|0]<<24);q[Jn>>2]=Fn;En=q[ki+20>>2];Hn=q[ki+16>>2]+4|0;if(Hn>>>0<4){En=En+1|0}Cn=ki;q[Cn+16>>2]=Hn;q[Cn+20>>2]=En;break b}if(!Ch(1,Jn,ki)){break a}Fn=q[Jn>>2]}En=q[a>>2];Cn=q[a+4>>2]-En>>2;c:{if(Fn>>>0>Cn>>>0){Fa(a,Fn-Cn|0);Fn=q[a+12>>2];break c}if(Fn>>>0>=Cn>>>0){break c}q[a+4>>2]=En+(Fn<<2)}if(!Fn){Pn=1;break a}Nn=q[ki+8>>2];Hn=q[ki+12>>2];while(1){Gn=q[ki+16>>2];Cn=q[ki+20>>2];if((Hn|0)<(Cn|0)?1:(Hn|0)<=(Cn|0)?Nn>>>0>Gn>>>0?0:1:0){break a}On=q[ki>>2];Kn=r[On+Gn|0];Gn=Gn+1|0;if(Gn>>>0<1){Cn=Cn+1|0}q[ki+16>>2]=Gn;q[ki+20>>2]=Cn;Ln=Kn>>>2;d:{e:{f:{Mn=Kn&3;if(Mn>>>0>3){En=0;break f}En=0;g:{switch(Mn-1|0){case 0:case 1:break f;case 2:break g;default:break e}}Cn=In+Ln|0;if(Cn>>>0>=Fn>>>0){return 0}Dn(q[a>>2]+(In<<2)|0,0,(Kn&252)+4|0);In=Cn;break d}while(1){if((Hn|0)<(Cn|0)?1:(Hn|0)<=(Cn|0)?Nn>>>0>Gn>>>0?0:1:0){return 0}Kn=r[Gn+On|0];Gn=Gn+1|0;if(Gn>>>0<1){Cn=Cn+1|0}q[ki+16>>2]=Gn;q[ki+20>>2]=Cn;Ln=Kn<<(En<<3|6)|Ln;En=En+1|0;if((Mn|0)!=(En|0)){continue}break}}q[q[a>>2]+(In<<2)>>2]=Ln}In=In+1|0;Fn=q[Jn>>2];if(In>>>0>>0){continue}break}In=a+16|0;Jn=q[a>>2];ki=q[a+16>>2];Cn=q[a+20>>2]-ki|0;En=Cn>>2;h:{if(En>>>0<=1048575){Fa(In,1048576-En|0);break h}if((Cn|0)==4194304){break h}q[a+20>>2]=ki+4194304}i:{ki=a+28|0;Cn=q[ki>>2];En=q[a+32>>2]-Cn>>3;if(Fn>>>0>En>>>0){Dh(ki,Fn-En|0);Cn=q[ki>>2];break i}if(Fn>>>0>>0){q[a+32>>2]=(Fn<<3)+Cn}if(Fn){break i}return 0}ki=0;En=0;while(1){a=Jn+(ki<<2)|0;Hn=q[a>>2];Gn=(ki<<3)+Cn|0;q[Gn+4>>2]=En;q[Gn>>2]=Hn;a=q[a>>2]+En|0;if(a>>>0>1048576){break a}if(En>>>0>>0){Hn=q[In>>2];while(1){q[Hn+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;break c}if((Dn|0)<2){break a}q[a+44>>2]=Dn+ -2;a=(Dn+Sn|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Dn|0)<3){break a}q[a+44>>2]=Dn+ -3;a=(Dn+Sn|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Dn+ -4;a=(Dn+Sn|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+4194304|0;q[ki+48>>2]=a;Xn=a>>>0<1073741824}T=Tn+16|0;return Xn}function Rh(a){Ij(a);q[a+44>>2]=0;q[a>>2]=11068}function Sh(a){a=a|0;if(q[a+44>>2]){return n[q[q[a>>2]+48>>2]](a)|0}return 0}function Th(a){a=a|0;var ki=0,Yn=0,Zn=0,_n=0,$n=0;q[a>>2]=13300;ki=q[a+20>>2];if(ki){q[a+24>>2]=ki;An(ki)}Zn=q[a+8>>2];if(Zn){ki=Zn;$n=a+12|0;Yn=q[$n>>2];_n=ki;a:{if((ki|0)==(Yn|0)){break a}while(1){Yn=Yn+ -4|0;ki=q[Yn>>2];q[Yn>>2]=0;if(ki){n[q[q[ki>>2]+4>>2]](ki)}if((Yn|0)!=(Zn|0)){continue}break}_n=q[a+8>>2]}ki=_n;q[$n>>2]=Zn;An(ki)}return a|0}function Uh(a,ao){a=a|0;ao=ao|0;a=q[a+48>>2];return n[q[q[a>>2]+20>>2]](a,ao)|0}function Vh(a){a=a|0;var ao=0,bo=0,co=0,eo=0;ao=q[a+32>>2];co=q[ao+16>>2];eo=q[ao+12>>2];bo=q[ao+20>>2];if((eo|0)>(bo|0)?1:(eo|0)>=(bo|0)?t[ao+8>>2]<=co>>>0?0:1:0){eo=r[co+q[ao>>2]|0];co=co+1|0;if(co>>>0<1){bo=bo+1|0}q[ao+16>>2]=co;q[ao+20>>2]=bo;ao=q[a+48>>2];q[a+48>>2]=0;if(ao){n[q[q[ao>>2]+4>>2]](ao)}a:{b:{if(eo>>>0>2){break b}c:{switch(eo-1|0){default:bo=Mm(384);bi(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao);break b;case 0:bo=Mm(424);Ei(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao);break b;case 1:break c}}bo=Mm(440);Ji(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao)}bo=q[a+48>>2];if(bo){break a}return 0}a=n[q[q[bo>>2]+8>>2]](bo,a)|0}else{a=0}return a|0}function Wh(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+24>>2]](a)|0}function Xh(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+28>>2]](a)|0}function Yh(a){a=a|0;var fo=0,go=0,ho=0,io=0,jo=0;q[a>>2]=11164;fo=a+48|0;go=q[fo>>2];q[fo>>2]=0;if(go){n[q[q[go>>2]+4>>2]](go)}q[a>>2]=13300;fo=q[a+20>>2];if(fo){q[a+24>>2]=fo;An(fo)}go=q[a+8>>2];if(go){fo=go;jo=a+12|0;ho=q[jo>>2];io=fo;a:{if((fo|0)==(ho|0)){break a}while(1){ho=ho+ -4|0;fo=q[ho>>2];q[ho>>2]=0;if(fo){n[q[q[fo>>2]+4>>2]](fo)}if((go|0)!=(ho|0)){continue}break}io=q[a+8>>2]}fo=io;q[jo>>2]=go;An(fo)}return a|0}function Zh(a){a=a|0;var ko=0,lo=0,mo=0,no=0,oo=0;q[a>>2]=11164;ko=a+48|0;lo=q[ko>>2];q[ko>>2]=0;if(lo){n[q[q[lo>>2]+4>>2]](lo)}q[a>>2]=13300;ko=q[a+20>>2];if(ko){q[a+24>>2]=ko;An(ko)}lo=q[a+8>>2];if(lo){ko=lo;oo=a+12|0;mo=q[oo>>2];no=ko;a:{if((ko|0)==(mo|0)){break a}while(1){mo=mo+ -4|0;ko=q[mo>>2];q[mo>>2]=0;if(ko){n[q[q[ko>>2]+4>>2]](ko)}if((lo|0)!=(mo|0)){continue}break}no=q[a+8>>2]}ko=no;q[oo>>2]=lo;An(ko)}An(a)}function _h(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+36>>2]](a)|0}function $h(a,po){a=a|0;po=po|0;a=q[a+48>>2];return n[q[q[a>>2]+12>>2]](a,po)|0}function ai(a,po){a=a|0;po=po|0;a=q[a+48>>2];return n[q[q[a>>2]+16>>2]](a,po)|0}function bi(a){q[a>>2]=11272;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0)}function ci(a){Yj(a);Yj(a+40|0);ah(a+80|0);Yj(a+96|0);q[a+144>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0}function di(a,po){a=a|0;po=po|0;q[a+4>>2]=po;return 1}function ei(a,po){a=a|0;po=po|0;var qo=0,ro=0,so=0,to=0,uo=0;qo=q[a+216>>2];to=a+220|0;if((qo|0)!=q[to>>2]){while(1){a:{qo=q[w(so,144)+qo>>2];if((qo|0)<0){break a}uo=q[a+4>>2];ro=q[uo+8>>2];if((qo|0)>=q[uo+12>>2]-ro>>2){break a}qo=q[ro+(qo<<2)>>2];if((n[q[q[qo>>2]+24>>2]](qo)|0)<1){break a}ro=0;while(1){if((n[q[q[qo>>2]+20>>2]](qo,ro)|0)!=(po|0)){ro=ro+1|0;if((ro|0)<(n[q[q[qo>>2]+24>>2]](qo)|0)){continue}break a}break}a=q[a+216>>2]+w(so,144)|0;return(r[a+100|0]?a+4|0:0)|0}so=so+1|0;qo=q[a+216>>2];if(so>>>0<(q[to>>2]-qo|0)/144>>>0){continue}break}}return 0}function fi(a,po){a=a|0;po=po|0;var vo=0,wo=0,xo=0,yo=0,zo=0;vo=q[a+216>>2];yo=a+220|0;if((vo|0)!=q[yo>>2]){while(1){a:{vo=q[w(xo,144)+vo>>2];if((vo|0)<0){break a}zo=q[a+4>>2];wo=q[zo+8>>2];if((vo|0)>=q[zo+12>>2]-wo>>2){break a}vo=q[wo+(vo<<2)>>2];if((n[q[q[vo>>2]+24>>2]](vo)|0)<1){break a}wo=0;while(1){if((n[q[q[vo>>2]+20>>2]](vo,wo)|0)!=(po|0)){wo=wo+1|0;if((wo|0)<(n[q[q[vo>>2]+24>>2]](vo)|0)){continue}break a}break}return(q[a+216>>2]+w(xo,144)|0)+104|0}xo=xo+1|0;vo=q[a+216>>2];if(xo>>>0<(q[yo>>2]-vo|0)/144>>>0){continue}break}}return a+184|0}function gi(a,po){a=a|0;po=po|0;var Ao=0,Bo=0,Co=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0,No=0,Oo=0;Do=T-80|0;T=Do;a:{b:{Mo=q[a+4>>2];Ao=q[Mo+32>>2];Io=q[Ao+8>>2];Ho=q[Ao+16>>2];Ko=q[Ao+12>>2];Bo=Ko;Fo=q[Ao+20>>2];Eo=Fo;c:{if((Bo|0)<(Eo|0)?1:(Bo|0)<=(Eo|0)?Io>>>0>Ho>>>0?0:1:0){break c}No=q[Ao>>2];Jo=r[No+Ho|0];Bo=Fo;Go=Ho+1|0;if(Go>>>0<1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>2];q[Xo>>2]=q[So>>2];q[Xo+4>>2]=po;po=q[Qo+8>>2];q[To>>2]=q[Qo+4>>2];q[To+4>>2]=po;a:{b:{Po=Ro;po=q[Qo+28>>2];if(po){So=Ro+32|0;c:{if(po>>>0<=q[Ro+40>>2]<<5>>>0){To=po+ -1>>>5;po=q[So>>2];break c}So=q[So>>2];if(So){An(So);q[Ro+40>>2]=0;q[Ro+32>>2]=0;q[Ro+36>>2]=0;po=q[Qo+28>>2]}if((po|0)<=-1){break b}To=po+ -1>>>5;So=To+1|0;po=Mm(So<<2);q[Ro+40>>2]=So;q[Ro+36>>2]=0;q[Ro+32>>2]=po}En(po,q[Qo+24>>2],(To<<2)+4|0);po=q[Qo+28>>2]}else{po=0}q[Po+36>>2]=po;Xo=Ro;po=q[Wo>>2];if(po){d:{if(po>>>0<=q[Ro+52>>2]<<5>>>0){Po=po+ -1>>>5;po=q[Uo>>2];break d}Po=q[Uo>>2];if(Po){An(Po);q[Ro+52>>2]=0;q[Ro+44>>2]=0;q[Ro+48>>2]=0;po=q[Qo+40>>2]}if((po|0)<=-1){break a}Po=po+ -1>>>5;To=Po+1|0;po=Mm(To<<2);q[Ro+52>>2]=To;q[Ro+48>>2]=0;q[Ro+44>>2]=po}En(po,q[Qo+36>>2],(Po<<2)+4|0);po=q[Qo+40>>2]}else{po=0}q[Xo+48>>2]=po;vd(_o,q[Qo+48>>2],q[Qo+52>>2]);q[a>>2]=Ro;q[Qo>>2]=12756;a=q[Qo+48>>2];if(a){q[Qo+52>>2]=a;An(a)}q[Qo>>2]=12572;a=q[Qo+36>>2];if(a){An(a)}a=q[Qo+24>>2];if(a){An(a)}T=Qo- -64|0;return}bn();F()}bn();F()}function ii(a,po,Po){var ap=0,bp=0,cp=0,dp=0,ep=0,fp=0,gp=0;ap=T-112|0;T=ap;gp=q[q[po+4>>2]+44>>2];bp=Mm(120);q[bp>>2]=12124;q[bp+116>>2]=0;q[bp+112>>2]=Po;q[bp+108>>2]=gp;q[bp+12>>2]=0;q[bp+16>>2]=0;q[bp+4>>2]=0;q[bp+20>>2]=0;q[bp+24>>2]=0;q[bp+28>>2]=0;q[bp+32>>2]=0;q[bp+36>>2]=0;q[bp+40>>2]=0;q[bp+44>>2]=0;q[bp+48>>2]=0;q[bp+52>>2]=0;q[bp+56>>2]=0;q[bp+60>>2]=0;q[bp+8>>2]=12336;ep=bp- -64|0;q[ep>>2]=0;q[ep+4>>2]=0;q[bp+72>>2]=0;q[bp+76>>2]=0;q[bp+80>>2]=0;q[bp+84>>2]=0;q[bp+88>>2]=0;q[bp+104>>2]=0;q[bp+96>>2]=0;q[bp+100>>2]=0;po=q[po+8>>2];q[ap+48>>2]=0;q[ap+52>>2]=0;q[ap+40>>2]=0;q[ap+44>>2]=0;ep=ap+24|0;cp=ep;q[cp>>2]=0;q[cp+4>>2]=0;cp=ap- -64|0;q[cp>>2]=0;q[cp+4>>2]=0;q[ap+72>>2]=0;q[ap+76>>2]=0;cp=ap+80|0;q[cp>>2]=0;q[cp+4>>2]=0;q[ap+88>>2]=0;q[ap+104>>2]=0;q[ap+32>>2]=0;q[ap+36>>2]=0;q[ap+16>>2]=0;q[ap+20>>2]=0;q[ap+56>>2]=0;q[ap+60>>2]=0;q[ap+8>>2]=12336;q[ap+96>>2]=0;q[ap+100>>2]=0;q[ap+12>>2]=po;dp=q[po>>2];fp=q[po+4>>2];o[ap+111|0]=0;bb(ap+32|0,(fp-dp>>2>>>0)/3|0,ap+111|0);dp=q[ap+12>>2];fp=q[dp+28>>2];dp=q[dp+24>>2];o[ap+111|0]=0;bb(ap+44|0,fp-dp>>2,ap+111|0);q[ap+28>>2]=bp;q[ep>>2]=gp;q[ap+20>>2]=Po;q[ap+16>>2]=po;ki(bp,ap+8|0);q[a>>2]=bp;q[ap+8>>2]=12336;a=q[ap+96>>2];if(a){q[ap+100>>2]=a;An(a)}a=q[cp>>2];if(a){q[ap+84>>2]=a;An(a)}a=q[ap+68>>2];if(a){q[ap+72>>2]=a;An(a)}a=q[ap+56>>2];if(a){q[ap+60>>2]=a;An(a)}q[ap+8>>2]=12572;a=q[ap+44>>2];if(a){An(a)}a=q[ap+32>>2];if(a){An(a)}T=ap+112|0}function ji(a,po){var Po=0,hp=0,ip=0,jp=0,kp=0,lp=0,mp=0,np=0,op=0;hp=q[a+8>>2];ip=a+4|0;Po=q[ip>>2];if(hp-Po>>2>>>0>=po>>>0){a=po<<2;np=ip,op=Dn(Po,0,a)+a|0,q[np>>2]=op;return}a:{ip=q[a>>2];jp=Po-ip>>2;kp=jp+po|0;if(kp>>>0<1073741824){jp=jp<<2;hp=hp-ip|0;mp=hp>>1;hp=hp>>2>>>0<536870911?mp>>>0>>0?kp:mp:1073741823;if(hp){if(hp>>>0>=1073741824){break a}lp=Mm(hp<<2)}jp=jp+lp|0;Dn(jp,0,po<<2);po=(kp<<2)+lp|0;kp=(hp<<2)+lp|0;if((Po|0)!=(ip|0)){while(1){Po=Po+ -4|0;hp=q[Po>>2];q[Po>>2]=0;jp=jp+ -4|0;q[jp>>2]=hp;if((Po|0)!=(ip|0)){continue}break}ip=q[a>>2];Po=q[a+4>>2]}q[a>>2]=jp;q[a+8>>2]=kp;q[a+4>>2]=po;if((Po|0)!=(ip|0)){while(1){Po=Po+ -4|0;a=q[Po>>2];q[Po>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}if((Po|0)!=(ip|0)){continue}break}}if(ip){An(ip)}return}bn();F()}ab(12024);F()}function ki(a,po){var pp=0;pp=q[po+8>>2];q[a+12>>2]=q[po+4>>2];q[a+16>>2]=pp;q[a+28>>2]=q[po+20>>2];pp=q[po+16>>2];q[a+20>>2]=q[po+12>>2];q[a+24>>2]=pp;$i(a+32|0,po+24|0);$i(a+44|0,po+36|0);if((a+8|0)==(po|0)){q[a+92>>2]=q[po+84>>2];return}vd(a+56|0,q[po+48>>2],q[po+52>>2]);vd(a+68|0,q[po+60>>2],q[po- -64>>2]);vd(a+80|0,q[po+72>>2],q[po+76>>2]);q[a+92>>2]=q[po+84>>2];hd(a+96|0,q[po+88>>2],q[po+92>>2])}function li(a,po,qp){a=a|0;po=po|0;qp=qp|0;var rp=0,sp=0;rp=T-16|0;T=rp;q[a+4>>2]=po;po=q[po+64>>2];sp=q[po+4>>2];po=q[po>>2];o[rp+15|0]=0;bb(a+24|0,(sp-po>>2>>>0)/3|0,rp+15|0);po=q[a+4>>2];sp=q[po+56>>2];po=q[po+52>>2];o[rp+14|0]=0;bb(a+36|0,sp-po>>2,rp+14|0);po=q[qp+12>>2];q[a+16>>2]=q[qp+8>>2];q[a+20>>2]=po;po=q[qp+4>>2];q[a+8>>2]=q[qp>>2];q[a+12>>2]=po;T=rp+16|0}function mi(a){a=a|0;var po=0;q[a>>2]=11760;po=q[a+48>>2];if(po){q[a+52>>2]=po;An(po)}q[a>>2]=12012;po=q[a+36>>2];if(po){An(po)}po=q[a+24>>2];if(po){An(po)}return a|0}function ni(a){a=a|0;var qp=0,tp=0,up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0,Cp=0,Dp=0,Ep=0,Fp=0,Gp=0;zp=T+ -64|0;T=zp;q[a+132>>2]=0;if(q[a+148>>2]){up=a+144|0;tp=q[up>>2];if(tp){while(1){qp=q[tp>>2];An(tp);tp=qp;if(qp){continue}break}}q[up>>2]=0;qp=q[a+140>>2];if(qp){up=a+136|0;tp=0;while(1){q[q[up>>2]+(tp<<2)>>2]=0;tp=tp+1|0;if((qp|0)!=(tp|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{tp=q[a+4>>2];up=r[tp+36|0];qp=up<<8|r[tp+37|0];g:{if(qp>>>0>513){break g}xp=q[tp+32>>2];if(qp>>>0<=511){wp=q[xp+12>>2];qp=q[xp+20>>2];yp=q[xp+16>>2];vp=yp+4|0;if(vp>>>0<4){qp=qp+1|0}Ap=vp;vp=qp;if((wp|0)<(qp|0)?1:(wp|0)<=(qp|0)?t[xp+8>>2]>=Ap>>>0?0:1:0){break f}qp=yp+q[xp>>2]|0;qp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp>>2]=qp;q[xp+16>>2]=Ap;q[xp+20>>2]=vp;q[a+132>>2]=qp;break g}if(!oi(1,zp,xp)){break f}tp=q[a+4>>2];up=r[tp+36|0];q[a+132>>2]=q[zp>>2]}tp=q[tp+32>>2];h:{i:{j:{if((up&255)>>>0<=1){up=0;xp=q[tp+12>>2];qp=q[tp+20>>2];wp=q[tp+16>>2];vp=wp+4|0;if(vp>>>0<4){qp=qp+1|0}yp=vp;vp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?t[tp+8>>2]>=yp>>>0?0:1:0){break a}qp=wp+q[tp>>2]|0;qp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+60>>2]=qp;q[tp+16>>2]=yp;q[tp+20>>2]=vp;q[a+156>>2]=qp;Dp=a+156|0;break j}up=0;if(!oi(1,zp+60|0,tp)){break a}qp=q[a+4>>2];tp=q[qp+32>>2];qp=r[qp+36|0];q[a+156>>2]=q[zp+60>>2];Dp=a+156|0;if(qp>>>0>1){break i}}xp=q[tp+12>>2];qp=q[tp+20>>2];wp=q[tp+16>>2];vp=wp+4|0;if(vp>>>0<4){qp=qp+1|0}Ap=vp;vp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?t[tp+8>>2]>=Ap>>>0?0:1:0){break a}qp=wp+q[tp>>2]|0;yp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+56>>2]=yp;q[tp+16>>2]=Ap;q[tp+20>>2]=vp;break h}if(!oi(1,zp+56|0,tp)){break a}yp=q[zp+56>>2]}if(yp>>>0>1431655765|t[Dp>>2]>w(yp,3)>>>0){break a}Bp=q[a+4>>2];vp=q[Bp+32>>2];Fp=q[vp+8>>2];Cp=q[vp+16>>2];xp=q[vp+12>>2];qp=xp;tp=q[vp+20>>2];if((qp|0)<(tp|0)?1:(qp|0)<=(tp|0)?Fp>>>0>Cp>>>0?0:1:0){break a}Gp=q[vp>>2];Ap=r[Gp+Cp|0];qp=tp;Ep=Cp+1|0;if(Ep>>>0<1){qp=qp+1|0}q[vp+16>>2]=Ep;q[vp+20>>2]=qp;k:{if(r[Bp+36|0]<=1){qp=tp;tp=Cp+5|0;if(tp>>>0<5){qp=qp+1|0}wp=tp;tp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?Fp>>>0>=wp>>>0?0:1:0){break a}qp=Ep+Gp|0;xp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+52>>2]=xp;q[vp+16>>2]=wp;q[vp+20>>2]=tp;break k}if(!oi(1,zp+52|0,vp)){break a}xp=q[zp+52>>2]}if(yp>>>0>>0|yp>>>0>((xp>>>0)/3|0)+xp>>>0){break a}qp=q[a+4>>2];vp=q[qp+32>>2];l:{if(r[qp+36|0]<=1){wp=q[vp+12>>2];qp=q[vp+20>>2];Cp=q[vp+16>>2];tp=Cp+4|0;if(tp>>>0<4){qp=qp+1|0}Bp=tp;tp=qp;if((wp|0)<(qp|0)?1:(wp|0)<=(qp|0)?t[vp+8>>2]>=Bp>>>0?0:1:0){break a}qp=Cp+q[vp>>2]|0;wp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+48>>2]=wp;q[vp+16>>2]=Bp;q[vp+20>>2]=tp;break l}if(!oi(1,zp+48|0,vp)){break a}wp=q[zp+48>>2]}if(wp>>>0>xp>>>0){break a}q[a+28>>2]=q[a+24>>2];tp=Mm(88);jk(tp);qp=q[a+8>>2];q[a+8>>2]=tp;vp=a+8|0;if(qp){wa(vp,qp);if(!q[vp>>2]){break a}}qp=q[a+160>>2];q[a+164>>2]=qp;m:{if(q[a+168>>2]-qp>>2>>>0>=yp>>>0){break m}if(yp>>>0>=1073741824){break e}up=yp<<2;tp=Mm(up);q[a+164>>2]=tp;q[a+160>>2]=tp;q[a+168>>2]=tp+up;if(!qp){break m}An(qp)}qp=q[a+172>>2];q[a+176>>2]=qp;n:{if(q[a+180>>2]-qp>>2>>>0>=yp>>>0){break n}if(yp>>>0>=1073741824){break d}up=yp<<2;tp=Mm(up);q[a+176>>2]=tp;q[a+172>>2]=tp;q[a+180>>2]=tp+up;if(!qp){break n}An(qp)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];Cp=a+216|0;tp=q[a+220>>2];up=q[a+216>>2];if((tp|0)==(up|0)){break c}while(1){qp=q[tp+ -12>>2];if(qp){q[tp+ -8>>2]=qp;An(qp)}qp=q[tp+ -28>>2];if(qp){q[tp+ -24>>2]=qp;An(qp)}qp=tp+ -144|0;Bp=q[tp+ -40>>2];if(Bp){q[tp+ -36>>2]=Bp;An(Bp)}pi(tp+ -140|0);tp=qp;if((up|0)!=(qp|0)){continue}break}qp=q[Cp>>2];break b}up=0;break a}ab(12024);F()}ab(12024);F()}qp=up}q[a+220>>2]=up;tp=(up-qp|0)/144|0;o:{if(tp>>>0>>0){qi(Cp,Ap-tp|0);break o}if(tp>>>0<=Ap>>>0){break o}tp=qp+w(Ap,144)|0;if((tp|0)!=(up|0)){while(1){qp=q[up+ -12>>2];if(qp){q[up+ -8>>2]=qp;An(qp)}qp=q[up+ -28>>2];if(qp){q[up+ -24>>2]=qp;An(qp)}qp=up+ -144|0;Bp=q[up+ -40>>2];if(Bp){q[up+ -36>>2]=Bp;An(Bp)}pi(up+ -140|0);up=qp;if((qp|0)!=(tp|0)){continue}break}}q[a+220>>2]=tp}up=0;if(!tk(q[vp>>2],yp,q[Dp>>2]+wp|0)){break a}qp=q[a+156>>2];o[zp|0]=1;bb(a+120|0,qp+wp|0,zp);tp=q[a+4>>2];qp=s[tp+36>>1];qp=(qp<<24|qp<<8&16711680)>>>16;p:{if(qp>>>0<=513){wp=q[tp+32>>2];q:{if(qp>>>0<=511){yp=q[wp+12>>2];qp=q[wp+20>>2];Dp=q[wp+16>>2];tp=Dp+4|0;if(tp>>>0<4){qp=qp+1|0}Bp=tp;tp=qp;if((yp|0)<(qp|0)?1:(yp|0)<=(qp|0)?t[wp+8>>2]>=Bp>>>0?0:1:0){break a}qp=Dp+q[wp>>2]|0;yp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+44>>2]=yp;q[wp+16>>2]=Bp;q[wp+20>>2]=tp;break q}if(!oi(1,zp+44|0,wp)){break a}yp=q[zp+44>>2]}if(!yp){break a}qp=q[q[a+4>>2]+32>>2];tp=q[qp+8>>2];wp=q[qp+16>>2];qp=q[qp+12>>2]-(q[qp+20>>2]+(tp>>>0>>0)|0)|0;if((qp|0)<0?1:(qp|0)<=0?tp-wp>>>0>=yp>>>0?0:1:0){break a}wp=Yj(zp);tp=q[q[a+4>>2]+32>>2];qp=q[tp+16>>2];Dp=q[tp+8>>2];Zj(wp,(qp+q[tp>>2]|0)+yp|0,(Dp-qp|0)-yp|0,s[tp+38>>1]);tp=ri(a,wp);if((tp|0)==-1){break a}qp=tp;wp=qp>>31;break p}qp=-1;wp=-1;if((ri(a,q[tp+32>>2])|0)==-1){break a}}q[a+376>>2]=a;Dp=a+232|0;tp=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];Bp=q[tp>>2]+q[tp+16>>2]|0;yp=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];tp=q[yp+8>>2];up=q[yp+16>>2];Zj(Dp,Bp,tp-up|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);q[a+372>>2]=Ap;up=0;tp=Yj(zp);r:{if(!si(Dp,tp)){break r}yp=ti(a,xp);if((yp|0)==-1){break r}xp=q[q[a+4>>2]+32>>2];up=q[tp+16>>2];Ap=up+q[tp>>2]|0;tp=q[tp+8>>2];Zj(xp,Ap,tp-up|0,s[xp+38>>1]);tp=q[a+4>>2];up=s[tp+36>>1];xp=(up<<24|up<<8&16711680)>>>16;if(xp>>>0<=513){up=q[tp+32>>2];Ap=up;Bp=up;tp=wp+q[up+20>>2]|0;up=qp+q[up+16>>2]|0;if(up>>>0>>0){tp=tp+1|0}q[Bp+16>>2]=up;q[Ap+20>>2]=tp}s:{if(q[a+220>>2]==q[a+216>>2]){break s}tp=q[vp>>2];qp=q[tp+4>>2];tp=q[tp>>2];t:{if(xp>>>0>=513){if((qp|0)==(tp|0)){break s}tp=0;break t}if((qp|0)==(tp|0)){break s}tp=0;while(1){if(ui(a,tp)){tp=tp+3|0;qp=q[vp>>2];if(tp>>>0>2]-q[qp>>2]>>2>>>0){continue}break s}break}up=0;break r}while(1){if(vi(a,tp)){tp=tp+3|0;qp=q[vp>>2];if(tp>>>0>2]-q[qp>>2]>>2>>>0){continue}break s}break}up=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}tp=q[a+216>>2];wp=a+220|0;if((tp|0)!=q[wp>>2]){xp=0;while(1){qp=w(xp,144);Ek((qp+tp|0)+4|0,q[vp>>2]);up=q[Cp>>2];Ap=qp+up|0;tp=q[Ap+132>>2];Ap=q[Ap+136>>2];if((tp|0)!=(Ap|0)){while(1){Gk((qp+up|0)+4|0,q[tp>>2]);up=q[Cp>>2];tp=tp+4|0;if((Ap|0)!=(tp|0)){continue}break}}Fk((qp+up|0)+4|0);xp=xp+1|0;tp=q[a+216>>2];if(xp>>>0<(q[wp>>2]-tp|0)/144>>>0){continue}break}}qp=q[a+8>>2];wi(a+184|0,q[qp+28>>2]-q[qp+24>>2]>>2);up=q[a+216>>2];if((up|0)!=q[wp>>2]){tp=0;xp=a+220|0;while(1){qp=w(tp,144)+up|0;up=q[qp+60>>2]-q[qp+56>>2]>>2;Ap=qp+104|0;qp=q[vp>>2];qp=q[qp+28>>2]-q[qp+24>>2]>>2;wi(Ap,(up|0)<(qp|0)?qp:up);tp=tp+1|0;up=q[a+216>>2];if(tp>>>0<(q[xp>>2]-up|0)/144>>>0){continue}break}}up=xi(a,yp)}}T=zp- -64|0;return up|0}function oi(a,Hp,Ip){var Jp=0,Kp=0,Lp=0,Mp=0;a:{if(a>>>0>5){break a}Lp=q[Ip+16>>2];Jp=q[Ip+12>>2];Kp=q[Ip+20>>2];if((Jp|0)<(Kp|0)?1:(Jp|0)<=(Kp|0)?t[Ip+8>>2]>Lp>>>0?0:1:0){break a}Jp=r[Lp+q[Ip>>2]|0];Lp=Lp+1|0;if(Lp>>>0<1){Kp=Kp+1|0}q[Ip+16>>2]=Lp;q[Ip+20>>2]=Kp;Kp=Hp;if(Jp&128){if(!oi(a+1|0,Hp,Ip)){break a}a=q[Hp>>2]<<7;q[Hp>>2]=a;Jp=a|Jp&127}q[Kp>>2]=Jp;Mp=1}return Mp}function pi(a){var Hp=0;Hp=q[a+84>>2];if(Hp){q[a+88>>2]=Hp;An(Hp)}Hp=q[a+72>>2];if(Hp){q[a+76>>2]=Hp;An(Hp)}Hp=q[a+52>>2];if(Hp){q[a+56>>2]=Hp;An(Hp)}Hp=q[a+40>>2];if(Hp){q[a+44>>2]=Hp;An(Hp)}Hp=q[a+28>>2];if(Hp){q[a+32>>2]=Hp;An(Hp)}Hp=q[a+12>>2];if(Hp){An(Hp)}a=q[a>>2];if(a){An(a)}}function qi(a,Ip){var Np=0,Op=0,Pp=0,Qp=0,Rp=0,Sp=0;Op=T-32|0;T=Op;a:{b:{Pp=q[a+8>>2];Qp=a+4|0;Np=q[Qp>>2];c:{if((Pp-Np|0)/144>>>0>=Ip>>>0){while(1){q[Np>>2]=-1;Dk(Np+4|0);q[Np+104>>2]=0;q[Np+108>>2]=0;o[Np+100|0]=1;q[Np+112>>2]=0;q[Np+116>>2]=0;q[Np+120>>2]=0;q[Np+124>>2]=0;q[Np+128>>2]=0;q[Np+132>>2]=0;q[Np+136>>2]=0;q[Np+140>>2]=0;Np=q[Qp>>2]+144|0;q[Qp>>2]=Np;Ip=Ip+ -1|0;if(Ip){continue}break c}}Rp=q[a>>2];Sp=(Np-Rp|0)/144|0;Np=Sp+Ip|0;if(Np>>>0>=29826162){break b}q[Op+24>>2]=a+8;Qp=0;q[Op+20>>2]=0;Pp=(Pp-Rp|0)/144|0;Rp=Pp<<1;Pp=Pp>>>0<14913080?Rp>>>0>>0?Np:Rp:29826161;if(Pp){if(Pp>>>0>=29826162){break a}Qp=Mm(w(Pp,144))}q[Op+8>>2]=Qp;Np=w(Sp,144)+Qp|0;q[Op+16>>2]=Np;q[Op+20>>2]=w(Pp,144)+Qp;q[Op+12>>2]=Np;while(1){q[Np>>2]=-1;Dk(Np+4|0);q[Np+104>>2]=0;q[Np+108>>2]=0;o[Np+100|0]=1;q[Np+112>>2]=0;q[Np+116>>2]=0;q[Np+120>>2]=0;q[Np+124>>2]=0;q[Np+128>>2]=0;q[Np+132>>2]=0;q[Np+136>>2]=0;q[Np+140>>2]=0;Np=q[Op+16>>2]+144|0;q[Op+16>>2]=Np;Ip=Ip+ -1|0;if(Ip){continue}break}Ip=q[a+4>>2];Pp=q[a>>2];d:{if((Ip|0)==(Pp|0)){Qp=q[Op+12>>2];break d}Qp=q[Op+12>>2];while(1){Ip=Ip+ -144|0;Qp=vj(Qp+ -144|0,Ip);if((Ip|0)!=(Pp|0)){continue}break}q[Op+12>>2]=Qp;Ip=q[a+4>>2];Pp=q[a>>2]}q[a>>2]=Qp;q[Op+12>>2]=Pp;q[a+4>>2]=Np;q[Op+16>>2]=Ip;a=a+8|0;Ip=q[a>>2];q[a>>2]=q[Op+20>>2];q[Op+8>>2]=Pp;q[Op+20>>2]=Ip;wj(Op+8|0)}T=Op+32|0;return}bn();F()}ab(12024);F()}function ri(a,Ip){var Tp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0,eq=0,fq=0,gq=0;Vp=T-32|0;T=Vp;a:{b:{if(r[q[a+4>>2]+36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=iq;iq=jq;lq=hq-iq|0;oq=q[nq+12>>2];iq=kq-((hq>>>0>>0)+mq|0)|0;hq=q[nq+8>>2];if((oq|0)==(iq|0)&hq>>>0<=lq>>>0|oq>>>0>>0){break b}}hq=0;break a}kq=mq+oq|0;jq=hq+jq|0;if(jq>>>0>>0){kq=kq+1|0}q[a+16>>2]=jq;q[a+20>>2]=kq;c:{if(s[a+38>>1]<=513){hq=q[a+4>>2];q[a+96>>2]=q[a>>2];q[a+100>>2]=hq;jq=a+32|0;hq=jq;iq=q[hq+4>>2];q[a+128>>2]=q[hq>>2];q[a+132>>2]=iq;iq=a+24|0;hq=iq;kq=q[hq+4>>2];q[a+120>>2]=q[hq>>2];q[a+124>>2]=kq;kq=a+16|0;hq=kq;lq=q[hq+4>>2];q[a+112>>2]=q[hq>>2];q[a+116>>2]=lq;lq=a+8|0;hq=lq;mq=q[hq+4>>2];q[a+104>>2]=q[hq>>2];q[a+108>>2]=mq;d:{hq=a+96|0;if(_j(hq,1,nq+8|0)){mq=q[hq+4>>2];q[a>>2]=q[hq>>2];q[a+4>>2]=mq;mq=q[hq+36>>2];q[jq>>2]=q[hq+32>>2];q[jq+4>>2]=mq;jq=q[hq+28>>2];q[iq>>2]=q[hq+24>>2];q[iq+4>>2]=jq;iq=q[hq+20>>2];mq=iq;jq=q[hq+16>>2];q[kq>>2]=jq;q[kq+4>>2]=iq;iq=q[hq+12>>2];kq=iq;hq=q[hq+8>>2];q[lq>>2]=hq;q[lq+4>>2]=iq;iq=jq;lq=hq-iq|0;oq=q[nq+12>>2];iq=kq-((hq>>>0>>0)+mq|0)|0;hq=q[nq+8>>2];if((oq|0)==(iq|0)&hq>>>0<=lq>>>0|oq>>>0>>0){break d}}hq=0;break a}kq=mq+oq|0;jq=hq+jq|0;if(jq>>>0>>0){kq=kq+1|0}q[a+16>>2]=jq;q[a+20>>2]=kq;break c}hq=0;if(!bh(a+80|0,a)){break a}}hq=0;if(!Ai(a)){break a}hq=q[a+4>>2];q[Ip>>2]=q[a>>2];q[Ip+4>>2]=hq;hq=q[a+36>>2];q[Ip+32>>2]=q[a+32>>2];q[Ip+36>>2]=hq;hq=q[a+28>>2];q[Ip+24>>2]=q[a+24>>2];q[Ip+28>>2]=hq;hq=q[a+20>>2];q[Ip+16>>2]=q[a+16>>2];q[Ip+20>>2]=hq;hq=q[a+12>>2];q[Ip+8>>2]=q[a+8>>2];q[Ip+12>>2]=hq;hq=1}T=nq+16|0;return hq}function ti(a,Ip){var pq=0,qq=0,rq=0,sq=0,tq=0,uq=0,vq=0,wq=0,xq=0,yq=0,zq=0,Aq=0,Bq=0,Cq=0,Dq=0,Eq=0,Fq=0,Gq=0,Hq=0,Iq=0,Jq=0,Kq=0,Lq=0;sq=T-96|0;T=sq;q[sq+72>>2]=0;q[sq+64>>2]=0;q[sq+68>>2]=0;q[sq+48>>2]=0;q[sq+52>>2]=0;q[sq+40>>2]=0;q[sq+44>>2]=0;q[sq+56>>2]=1065353216;q[sq+32>>2]=0;q[sq+24>>2]=0;q[sq+28>>2]=0;Jq=q[a+124>>2];a:{b:{c:{d:{if((Ip|0)>=1){Iq=a+8|0;Fq=q[a+216>>2]!=q[a+220>>2];Gq=a+40|0;while(1){e:{f:{g:{h:{i:{j:{k:{if(!r[a+308|0]){break k}l:{m:{wq=q[a+296>>2];yq=q[a+304>>2];pq=wq+(yq>>>3)|0;uq=q[a+300>>2];if(pq>>>0>=uq>>>0){break m}pq=r[pq|0];qq=yq+1|0;q[a+304>>2]=qq;if(!(pq>>>(yq&7)&1)){break m}pq=qq>>>3;rq=wq+pq|0;n:{if(rq>>>0>=uq>>>0){rq=qq;qq=0;break n}vq=r[rq|0];rq=yq+2|0;q[a+304>>2]=rq;pq=rq>>>3;qq=vq>>>(qq&7)&1}pq=pq+wq|0;if(pq>>>0>>0){pq=r[pq|0];q[a+304>>2]=rq+1;pq=pq>>>(rq&7)<<1&2}else{pq=0}pq=(qq|pq)<<1|1;switch(pq+ -2|0){case 0:case 2:case 4:break h;case 5:break j;case 1:case 3:break l;default:break k}}qq=q[sq+68>>2];if((qq|0)==q[sq+64>>2]){break d}wq=-1;Aq=q[Iq>>2];uq=q[Aq+24>>2];rq=uq;vq=qq+ -4|0;Dq=q[vq>>2];pq=-1;o:{if((Dq|0)==-1){break o}qq=Dq+1|0;qq=(qq>>>0)%3|0?qq:Dq+ -2|0;pq=-1;if((qq|0)==-1){break o}pq=q[q[Aq>>2]+(qq<<2)>>2]}rq=q[rq+(pq<<2)>>2];if((rq|0)!=-1){qq=rq+1|0;wq=(qq>>>0)%3|0?qq:rq+ -2|0}rq=q[Aq+12>>2];Bq=w(tq,3);qq=Bq+1|0;q[rq+(Dq<<2)>>2]=qq;qq=qq<<2;q[qq+rq>>2]=Dq;zq=Bq+2|0;q[rq+(wq<<2)>>2]=zq;yq=zq<<2;q[yq+rq>>2]=wq;Cq=q[Aq>>2];q[Cq+(Bq<<2)>>2]=pq;rq=qq+Cq|0;xq=-1;p:{if((wq|0)==-1){break p}qq=wq+1|0;qq=(qq>>>0)%3|0?qq:wq+ -2|0;xq=-1;if((qq|0)==-1){break p}xq=q[Cq+(qq<<2)>>2]}q[rq>>2]=xq;q:{r:{if((Dq|0)!=-1){qq=Dq+((Dq>>>0)%3|0?-1:2)|0;if((qq|0)!=-1){break r}}q[yq+Cq>>2]=-1;break q}qq=q[Cq+(qq<<2)>>2];q[yq+Cq>>2]=qq;if((qq|0)==-1){break q}q[uq+(qq<<2)>>2]=zq}rq=q[a+120>>2]+(pq>>>3&536870908)|0;qq=q[rq>>2];Kq=rq,Lq=eo(pq)&qq,q[Kq>>2]=Lq;q[vq>>2]=Bq;break e}rq=q[sq+68>>2];if((rq|0)==q[sq+64>>2]){break d}yq=q[Iq>>2];qq=q[yq+12>>2];zq=w(tq,3);wq=(pq|0)==5;uq=zq+(wq?2:1)|0;pq=uq<<2;Cq=q[rq+ -4>>2];q[qq+pq>>2]=Cq;q[qq+(Cq<<2)>>2]=uq;vq=yq+24|0;rq=yq+28|0;qq=q[rq>>2];s:{if((qq|0)!=q[yq+32>>2]){q[qq>>2]=-1;Aq=qq+4|0;q[rq>>2]=Aq;break s}zi(vq,11312);Aq=q[rq>>2]}rq=-1;qq=q[Iq>>2];yq=q[qq+24>>2];if(q[qq+28>>2]-yq>>2>(Jq|0)){break c}rq=zq+2|0;Bq=q[qq>>2];xq=Bq+pq|0;qq=Aq-q[vq>>2]|0;pq=(qq>>2)+ -1|0;q[xq>>2]=pq;if(qq){q[yq+(pq<<2)>>2]=uq}rq=wq?zq:rq;qq=Bq+(wq+zq<<2)|0;t:{u:{v:{if((Cq|0)!=-1){pq=Cq+((Cq>>>0)%3|0?-1:2)|0;if((pq|0)==-1){break v}pq=q[Bq+(pq<<2)>>2];q[Bq+(rq<<2)>>2]=pq;if((pq|0)==-1){break u}q[yq+(pq<<2)>>2]=rq;break u}q[Bq+(rq<<2)>>2]=-1;rq=-1;break t}q[Bq+(rq<<2)>>2]=-1}pq=Cq+1|0;pq=(pq>>>0)%3|0?pq:Cq+ -2|0;rq=-1;if((pq|0)==-1){break t}rq=q[Bq+(pq<<2)>>2]}q[qq>>2]=rq;q[q[sq+68>>2]+ -4>>2]=zq;break i}rq=-1;pq=q[sq+68>>2];Aq=q[sq+64>>2];if((pq|0)==(Aq|0)){break c}qq=pq+ -4|0;Eq=q[qq>>2];q[sq+68>>2]=qq;zq=q[sq+44>>2];w:{if(!zq){pq=qq;break w}uq=q[sq+40>>2];yq=co(zq)>>>0>1;vq=zq+2147483647&tq;x:{if(!yq){break x}vq=tq;if(tq>>>0>>0){break x}vq=(tq>>>0)%(zq>>>0)|0}uq=q[uq+(vq<<2)>>2];if(!uq){pq=qq;break w}xq=q[uq>>2];if(!xq){pq=qq;break w}uq=zq+ -1|0;y:{while(1){wq=q[xq+4>>2];z:{if((wq|0)!=(tq|0)){A:{if(!yq){wq=wq&uq;break A}if(wq>>>0>>0){break A}wq=(wq>>>0)%(zq>>>0)|0}if((wq|0)==(vq|0)){break z}pq=qq;break w}if(q[xq+8>>2]==(tq|0)){break y}}xq=q[xq>>2];if(xq){continue}break}pq=qq;break w}vq=xq+12|0;if((qq|0)!=q[sq+72>>2]){q[qq>>2]=q[vq>>2];q[sq+68>>2]=pq;break w}zi(sq- -64|0,vq);pq=q[sq+68>>2];Aq=q[sq+64>>2]}if((pq|0)==(Aq|0)){break c}Dq=q[pq+ -4>>2];vq=(Dq|0)==-1;Hq=q[Iq>>2];if(q[q[Hq+12>>2]+(Dq<<2)>>2]!=-1?!vq:0){break c}yq=(Eq|0)==-1;zq=Hq+12|0;uq=q[zq>>2];if(q[uq+(Eq<<2)>>2]!=-1?!yq:0){break c}Cq=w(tq,3);Aq=Cq+2|0;q[uq+(Dq<<2)>>2]=Aq;Bq=Aq<<2;q[Bq+uq>>2]=Dq;qq=Cq+1|0;q[uq+(Eq<<2)>>2]=qq;wq=uq;uq=qq<<2;q[wq+uq>>2]=Eq;if(vq){break g}wq=-1;vq=q[Hq>>2];xq=vq+(Cq<<2)|0;qq=Dq+((Dq>>>0)%3|0?-1:2)|0;if((qq|0)!=-1){wq=q[(qq<<2)+vq>>2]}q[xq>>2]=wq;qq=Dq+1|0;qq=(qq>>>0)%3|0?qq:Dq+ -2|0;if((qq|0)==-1){break f}rq=q[(qq<<2)+vq>>2];break f}q[sq>>2]=w(tq,3);pq=q[Iq>>2];rq=pq+24|0;uq=q[pq+32>>2];qq=pq+28|0;pq=q[qq>>2];B:{if((uq|0)!=(pq|0)){q[pq>>2]=-1;pq=pq+4|0;q[qq>>2]=pq;break B}zi(rq,11312);pq=q[qq>>2]}Aq=q[Iq>>2];wq=q[Aq>>2];qq=q[sq>>2];yq=pq-q[rq>>2]|0;zq=yq>>2;rq=zq+ -1|0;q[wq+(qq<<2)>>2]=rq;qq=qq+1|0;uq=Aq+24|0;vq=Aq+28|0;pq=q[vq>>2];C:{if((pq|0)!=q[Aq+32>>2]){q[pq>>2]=-1;pq=pq+4|0;q[vq>>2]=pq;break C}zi(uq,11312);pq=q[vq>>2];wq=q[Aq>>2]}q[(qq<<2)+wq>>2]=(pq-q[uq>>2]>>2)+ -1;pq=q[sq>>2]+2|0;uq=q[Iq>>2];qq=uq+28|0;vq=q[qq>>2];D:{if((vq|0)!=q[uq+32>>2]){q[vq>>2]=-1;wq=vq+4|0;q[qq>>2]=wq;break D}zi(uq+24|0,11312);wq=q[qq>>2]}q[q[uq>>2]+(pq<<2)>>2]=(wq-q[uq+24>>2]>>2)+ -1;pq=q[Iq>>2];qq=q[pq+24>>2];if(q[pq+28>>2]-qq>>2>(Jq|0)){break d}pq=q[sq>>2];E:{F:{if(!yq){wq=1;q[qq+(zq<<2)>>2]=pq+1;break F}q[qq+(rq<<2)>>2]=pq;wq=0;if((yq|0)==-4){break F}q[qq+(zq<<2)>>2]=q[sq>>2]+1;wq=zq+1|0;if((wq|0)==-1){break E}}q[qq+(wq<<2)>>2]=q[sq>>2]+2}pq=q[sq+68>>2];if((pq|0)!=q[sq+72>>2]){q[pq>>2]=q[sq>>2];q[sq+68>>2]=pq+4;break i}zi(sq- -64|0,sq)}xq=q[Gq>>2];if((xq|0)==q[a+36>>2]){break e}uq=(tq^-1)+Ip|0;while(1){rq=-1;pq=q[xq+ -8>>2];if(pq>>>0>uq>>>0){break c}if((pq|0)!=(uq|0)){break e}qq=r[xq+ -4|0];pq=xq+ -12|0;vq=q[pq>>2];q[Gq>>2]=pq;if((vq|0)<0){break c}rq=q[q[sq+68>>2]+ -4>>2];q[sq+20>>2]=(vq^-1)+Ip;q[sq+88>>2]=sq+20;Bi(sq,sq+40|0,sq+20|0,sq+88|0);vq=q[sq>>2];G:{if(qq&1){pq=-1;if((rq|0)==-1){break G}pq=rq+1|0;pq=(pq>>>0)%3|0?pq:rq+ -2|0;break G}pq=-1;if((rq|0)==-1){break G}pq=rq+ -1|0;if((rq>>>0)%3){break G}pq=rq+2|0}q[vq+12>>2]=pq;xq=q[Gq>>2];if((xq|0)!=q[a+36>>2]){continue}break}break e}F()}wq=-1;vq=q[Hq>>2];q[vq+(Cq<<2)>>2]=-1}q[uq+vq>>2]=rq;H:{I:{J:{if(!yq){qq=Eq+((Eq>>>0)%3|0?-1:2)|0;if((qq|0)==-1){break J}qq=q[(qq<<2)+vq>>2];q[vq+Bq>>2]=qq;if((qq|0)==-1){break I}q[q[Hq+24>>2]+(qq<<2)>>2]=Aq;break I}q[vq+Bq>>2]=-1;xq=-1;rq=-1;break H}q[vq+Bq>>2]=-1}xq=-1;qq=Eq+1|0;qq=(qq>>>0)%3|0?qq:Eq+ -2|0;rq=-1;if((qq|0)==-1){break H}xq=q[(qq<<2)+vq>>2];rq=qq}q[sq>>2]=xq;uq=q[Hq+24>>2];if((wq|0)!=-1){q[uq+(wq<<2)>>2]=q[uq+(xq<<2)>>2]}K:{if((rq|0)==-1){break K}vq=q[Hq>>2];while(1){q[vq+(rq<<2)>>2]=wq;qq=rq+1|0;qq=(qq>>>0)%3|0?qq:rq+ -2|0;if((qq|0)==-1){break K}rq=q[q[zq>>2]+(qq<<2)>>2];if((rq|0)==-1){break K}qq=rq+1|0;rq=(qq>>>0)%3|0?qq:rq+ -2|0;if((rq|0)!=-1){continue}break}}q[uq+(q[sq>>2]<<2)>>2]=-1;L:{if(Fq){break L}qq=q[sq+28>>2];if((qq|0)!=q[sq+32>>2]){q[qq>>2]=q[sq>>2];q[sq+28>>2]=qq+4;break L}zi(sq+24|0,sq);pq=q[sq+68>>2]}q[pq+ -4>>2]=Cq}tq=tq+1|0;if((tq|0)!=(Ip|0)){continue}break}wq=Ip}rq=-1;xq=q[a+8>>2];if(q[xq+28>>2]-q[xq+24>>2]>>2>(Jq|0)){break c}tq=q[sq+68>>2];if((tq|0)!=q[sq+64>>2]){Dq=a+72|0;qq=a+60|0;Aq=a+312|0;Fq=a+8|0;Cq=a+68|0;Jq=a+80|0;Hq=a+76|0;while(1){pq=tq+ -4|0;Ip=q[pq>>2];q[sq+68>>2]=pq;q[sq>>2]=Ip;M:{N:{O:{P:{if(s[a+270>>1]<=513){if(!r[a+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0;q[uq>>2]=vq;Bq=q[a+120>>2];tq=Gq>>>0>>0?-1:xq;vq=Bq+(tq>>>3&536870908)|0;pq=q[vq>>2];Kq=vq,Lq=eo(tq)&pq,q[Kq>>2]=Lq;Ip=(Gq|0)!=-1?q[zq>>2]:Ip;vq=Bq+(Ip>>>3&536870908)|0;pq=q[vq>>2];Kq=vq,Lq=eo(Ip)&pq,q[Kq>>2]=Lq;tq=-1;tq=(yq|0)!=-1?q[uq>>2]:tq;pq=Bq+(tq>>>3&536870908)|0;Ip=q[pq>>2];Kq=pq,Lq=eo(tq)&Ip,q[Kq>>2]=Lq;tq=q[a+64>>2];pq=q[Cq>>2];if((tq|0)==pq<<5){if((tq+1|0)<=-1){break a}Ip=qq;if(tq>>>0<=1073741822){vq=tq+32&-32;pq=pq<<6;pq=pq>>>0>>0?vq:pq}else{pq=2147483647}cb(Ip,pq);tq=q[a+64>>2]}wq=wq+1|0;q[a+64>>2]=tq+1;Ip=q[a+60>>2]+(tq>>>3&536870908)|0;q[Ip>>2]=q[Ip>>2]|1<<(tq&31);Ip=q[Hq>>2];if((Ip|0)!=q[Jq>>2]){q[Ip>>2]=q[sq+88>>2];q[Hq>>2]=Ip+4;break M}zi(Dq,sq+88|0);break M}tq=q[a+64>>2];pq=q[Cq>>2];if((tq|0)==pq<<5){if((tq+1|0)<=-1){break a}Ip=qq;if(tq>>>0<=1073741822){vq=tq+32&-32;pq=pq<<6;pq=pq>>>0>>0?vq:pq}else{pq=2147483647}cb(Ip,pq);tq=q[a+64>>2]}q[a+64>>2]=tq+1;pq=q[a+60>>2]+(tq>>>3&536870908)|0;Ip=q[pq>>2];Kq=pq,Lq=eo(tq)&Ip,q[Kq>>2]=Lq;Ip=q[Hq>>2];if((Ip|0)!=q[Jq>>2]){q[Ip>>2]=q[sq>>2];q[Hq>>2]=Ip+4;break M}zi(Dq,sq)}tq=q[sq+68>>2];if((tq|0)!=q[sq+64>>2]){continue}break}xq=q[a+8>>2]}if(((q[xq+4>>2]-q[xq>>2]>>2>>>0)/3|0)!=(wq|0)){break c}rq=q[xq+28>>2]-q[xq+24>>2]>>2;Fq=q[sq+24>>2];uq=q[sq+28>>2];if((Fq|0)==(uq|0)){break b}vq=a+8|0;while(1){zq=q[Fq>>2];wq=q[xq+24>>2];tq=rq+ -1|0;T:{if(q[wq+(tq<<2)>>2]!=-1){pq=rq;break T}wq=q[xq+24>>2];while(1){tq=rq+ -2|0;pq=rq+ -1|0;rq=pq;if(q[(tq<<2)+wq>>2]==-1){continue}break}}if(!(tq>>>0>>0)){q[sq>>2]=xq;Ip=tq<<2;rq=q[Ip+wq>>2];o[sq+12|0]=1;q[sq+8>>2]=rq;q[sq+4>>2]=rq;if((rq|0)!=-1){while(1){q[q[xq>>2]+(rq<<2)>>2]=zq;lg(sq);xq=q[vq>>2];rq=q[sq+8>>2];if((rq|0)!=-1){continue}break}}qq=Ip;Ip=q[xq+24>>2];qq=qq+Ip|0;if((zq|0)!=-1){q[Ip+(zq<<2)>>2]=q[qq>>2]}q[qq>>2]=-1;yq=1<<(zq&31);Ip=q[a+120>>2];rq=Ip+(zq>>>3&536870908)|0;qq=rq;wq=Ip+(tq>>>3&536870908)|0;Ip=1<<(tq&31);tq=yq|q[rq>>2];U:{if(q[wq>>2]&Ip){break U}tq=q[rq>>2]&(yq^-1)}q[qq>>2]=tq;q[wq>>2]=q[wq>>2]&(Ip^-1);pq=pq+ -1|0}rq=pq;Fq=Fq+4|0;if((uq|0)!=(Fq|0)){continue}break}break c}rq=-1}Fq=q[sq+24>>2]}if(Fq){q[sq+28>>2]=Fq;An(Fq)}tq=q[sq+48>>2];if(tq){while(1){a=q[tq>>2];An(tq);tq=a;if(tq){continue}break}}a=q[sq+40>>2];q[sq+40>>2]=0;if(a){An(a)}a=q[sq+64>>2];if(a){q[sq+68>>2]=a;An(a)}T=sq+96|0;return rq}bn();F()}function ui(a,Ip){var Mq=0,Nq=0,Oq=0,Pq=0,Qq=0,Rq=0,Sq=0,Tq=0,Uq=0,V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Ip+1|0;q[Yq+20>>2]=(Xq>>>0)%3|0?Xq:Ip+ -2|0;if((Ip>>>0)%3){Xq=Ip+ -1|0;break a}Xq=Ip+2|0}q[Yq+24>>2]=Xq;er=(Ip|0)==-1?-1:(Ip>>>0)/3|0;ar=a+220|0;fr=a+8|0;gr=a+368|0;while(1){b:{c:{if((Ip|0)!=-1){Xq=q[q[q[fr>>2]+12>>2]+(Ip<<2)>>2];if((Xq|0)!=-1){break c}}Xq=0;Zq=q[a+216>>2];_q=q[ar>>2];if((Zq|0)==(_q|0)){break b}while(1){q[Yq+12>>2]=Ip;$q=w(Xq,144)+Zq|0;dr=$q+136|0;br=q[dr>>2];d:{if(br>>>0>2]){q[br>>2]=Ip;q[dr>>2]=br+4;break d}ya($q+132|0,Yq+12|0);_q=q[ar>>2];Zq=q[a+216>>2]}Xq=Xq+1|0;if(Xq>>>0<(_q-Zq|0)/144>>>0){continue}break}break b}if((Xq>>>0)/3>>>0>>0){break b}Xq=0;if(q[ar>>2]==q[a+216>>2]){break b}while(1){e:{if(!dh(q[gr>>2]+(Xq<<4)|0)){break e}Zq=q[a+216>>2];q[Yq+12>>2]=Ip;Zq=Zq+w(Xq,144)|0;$q=Zq+136|0;_q=q[$q>>2];if(_q>>>0>2]){q[_q>>2]=Ip;q[$q>>2]=_q+4;break e}ya(Zq+132|0,Yq+12|0)}Xq=Xq+1|0;if(Xq>>>0<(q[ar>>2]-q[a+216>>2]|0)/144>>>0){continue}break}}cr=cr+1|0;if((cr|0)!=3){Ip=q[(Yq+16|0)+(cr<<2)>>2];continue}break}T=Yq+32|0;return 1}function wi(a,Ip){var hr=0,ir=0,jr=0,kr=0,lr=0;ir=q[a+12>>2];hr=q[a+16>>2]-ir>>2;a:{if(hr>>>0>>0){Fa(a+12|0,Ip-hr|0);break a}if(hr>>>0<=Ip>>>0){break a}q[a+16>>2]=ir+(Ip<<2)}b:{hr=q[a>>2];c:{if(q[a+8>>2]-hr>>2>>>0>=Ip>>>0){break c}if(Ip>>>0>=1073741824){break b}kr=a+4|0;ir=q[kr>>2];jr=Ip<<2;Ip=Mm(jr);jr=Ip+jr|0;ir=ir-hr|0;lr=ir+Ip|0;if((ir|0)>=1){Cn(Ip,hr,ir)}q[a>>2]=Ip;q[a+8>>2]=jr;q[kr>>2]=lr;if(!hr){break c}An(hr)}return}ab(12024);F()}function xi(a,Ip){var mr=0,nr=0,or=0,pr=0,qr=0,rr=0,sr=0,tr=0,ur=0,vr=0,wr=0,xr=0,yr=0,zr=0,Ar=0,Br=0;nr=T-48|0;T=nr;mr=q[a+8>>2];or=q[mr>>2];qr=q[mr+4>>2];mr=q[q[a+4>>2]+44>>2];q[nr+40>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;or=(qr-or>>2>>>0)/3|0;pr=q[mr+96>>2];qr=(q[mr+100>>2]-pr|0)/12|0;a:{if(or>>>0>qr>>>0){Ci(mr+96|0,or-qr|0,nr+32|0);break a}if(or>>>0>=qr>>>0){break a}q[mr+100>>2]=pr+w(or,12)}b:{if(q[a+216>>2]==q[a+220>>2]){ur=q[a+4>>2];mr=q[ur+44>>2];or=q[mr+100>>2];sr=q[mr+96>>2];if((or|0)!=(sr|0)){vr=(or-sr|0)/12|0;wr=nr+40|0;mr=0;while(1){q[wr>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;qr=nr;c:{d:{e:{pr=w(mr,3);if((pr|0)==-1){or=-1;q[nr+32>>2]=-1;rr=0;break e}or=q[q[q[a+8>>2]>>2]+(pr<<2)>>2];q[nr+32>>2]=or;rr=pr+1|0;if((rr|0)!=-1){break e}q[nr+36>>2]=-1;pr=0;break d}q[nr+36>>2]=q[q[q[a+8>>2]>>2]+(rr<<2)>>2];pr=pr+2|0;xr=-1;if((pr|0)==-1){break c}}xr=q[q[q[a+8>>2]>>2]+(pr<<2)>>2]}q[qr+40>>2]=xr;qr=sr+w(mr,12)|0;q[qr>>2]=or;q[qr+4>>2]=q[nr+36>>2];q[qr+8>>2]=q[nr+40>>2];mr=mr+1|0;if(mr>>>0>>0){continue}break}}q[q[ur+4>>2]+80>>2]=Ip;mr=1;break b}q[nr+40>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;pr=q[a+8>>2];Ip=q[pr>>2];mr=q[pr+4>>2];q[nr+24>>2]=0;q[nr+16>>2]=0;q[nr+20>>2]=0;f:{g:{h:{Ip=mr-Ip|0;if(Ip){or=Ip>>2;if(or>>>0>=1073741824){break h}mr=Mm(Ip);q[nr+16>>2]=mr;q[nr+24>>2]=mr+(or<<2);Ar=nr,Br=Dn(mr,0,Ip)+Ip|0,q[Ar+20>>2]=Br}if((q[pr+28>>2]-q[pr+24>>2]|0)<1){break g}ur=a+220|0;vr=a+8|0;while(1){or=q[q[pr+24>>2]+(sr<<2)>>2];i:{if((or|0)==-1){break i}j:{if(q[q[a+120>>2]+(sr>>>3&536870908)>>2]>>>(sr&31)&1){break j}Ip=q[ur>>2];wr=q[a+216>>2];if((Ip|0)==(wr|0)){break j}xr=(Ip-wr|0)/144|0;yr=((or>>>0)%3|0?-1:2)+or|0;rr=0;while(1){zr=or<<2;tr=wr+w(rr,144)|0;Ip=q[zr+q[q[tr+68>>2]>>2]>>2];k:{if(!(q[q[tr+16>>2]+(Ip>>>3&536870908)>>2]>>>(Ip&31)&1)){break k}Ip=or;mr=-1;l:{if((yr|0)==-1){break l}qr=q[q[pr+12>>2]+(yr<<2)>>2];mr=-1;if((qr|0)==-1){break l}mr=qr+ -1|0;if((qr>>>0)%3){break l}mr=qr+2|0}if((Ip|0)==(mr|0)){break k}tr=q[tr+32>>2];zr=q[tr+zr>>2];while(1){Ip=0;if((mr|0)==-1){break f}if((zr|0)!=q[tr+(mr<<2)>>2]){or=mr;break j}qr=or;mr=((mr>>>0)%3|0?-1:2)+mr|0;Ip=-1;m:{if((mr|0)==-1){break m}mr=q[q[pr+12>>2]+(mr<<2)>>2];Ip=-1;if((mr|0)==-1){break m}Ip=mr+ -1|0;if((mr>>>0)%3){break m}Ip=mr+2|0}mr=Ip;if((qr|0)!=(mr|0)){continue}break}}rr=rr+1|0;if(rr>>>0>>0){continue}break}}Ip=q[nr+36>>2];q[q[nr+16>>2]+(or<<2)>>2]=Ip-q[nr+32>>2]>>2;q[nr>>2]=or;n:{if(t[nr+40>>2]>Ip>>>0){q[Ip>>2]=or;q[nr+36>>2]=Ip+4;break n}ya(nr+32|0,nr);pr=q[vr>>2]}if((or|0)==-1){break i}Ip=((or>>>0)%3|0?-1:2)+or|0;if((Ip|0)==-1){break i}Ip=q[q[pr+12>>2]+(Ip<<2)>>2];if((Ip|0)==-1){break i}mr=Ip+((Ip>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}qr=or;if((mr|0)==(or|0)){break i}while(1){Ip=mr;o:{p:{mr=q[ur>>2];rr=q[a+216>>2];if((mr|0)==(rr|0)){break p}wr=(mr-rr|0)/144|0;mr=0;while(1){yr=q[(rr+w(mr,144)|0)+32>>2];tr=Ip<<2;if(q[yr+tr>>2]==q[yr+(qr<<2)>>2]){mr=mr+1|0;if(mr>>>0>>0){continue}break p}break}mr=q[nr+36>>2];q[tr+q[nr+16>>2]>>2]=mr-q[nr+32>>2]>>2;q[nr>>2]=Ip;if(t[nr+40>>2]>mr>>>0){q[mr>>2]=Ip;q[nr+36>>2]=mr+4;break o}ya(nr+32|0,nr);pr=q[vr>>2];break o}mr=q[nr+16>>2];q[mr+(Ip<<2)>>2]=q[mr+(qr<<2)>>2]}if((Ip|0)==-1){break i}mr=Ip+((Ip>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}mr=q[q[pr+12>>2]+(mr<<2)>>2];if((mr|0)==-1){break i}mr=mr+((mr>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}qr=Ip;if((mr|0)!=(or|0)){continue}break}}sr=sr+1|0;if((sr|0)>2]-q[pr+24>>2]>>2){continue}break}break g}bn();F()}or=q[a+4>>2];a=q[or+44>>2];Ip=q[a+100>>2];a=q[a+96>>2];if((Ip|0)!=(a|0)){qr=(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r=Ir>>1;Jr=Ir>>2>>>0<536870911?Lr>>>0>>0?Jr:Lr:1073741823;Ir=0;b:{if(!Jr){break b}if(Jr>>>0>=1073741824){break a}Ir=Mm(Jr<<2)}Lr=Nr+Ir|0;q[Lr>>2]=q[Ip>>2];Ip=Ir+(Jr<<2)|0;Jr=Lr+4|0;if((Mr|0)>=1){Cn(Ir,Kr,Mr)}q[a>>2]=Ir;q[a+8>>2]=Ip;q[a+4>>2]=Jr;if(Kr){An(Kr)}return}bn();F()}ab(12024);F()}function Ai(a){var Ip=0,Or=0,Pr=0,Qr=0;Or=1;Pr=q[a+140>>2];a:{if((Pr|0)<1){break a}Ip=Pr<<4;Or=Mm((Pr|0)!=(Pr&268435455)?-1:Ip|4);q[Or>>2]=Pr;Or=Or+4|0;Pr=Or+Ip|0;Ip=Or;while(1){Ip=ah(Ip)+16|0;if((Pr|0)!=(Ip|0)){continue}break}Qr=q[a+136>>2];q[a+136>>2]=Or;if(Qr){Pr=Qr+ -4|0;Or=q[Pr>>2];if(Or){Ip=Qr+(Or<<4)|0;while(1){Ip=Ip+ -16|0;if((Qr|0)!=(Ip|0)){continue}break}}An(Pr)}Or=1;if(q[a+140>>2]<1){break a}Or=0;Ip=0;while(1){if(!bh(q[a+136>>2]+(Ip<<4)|0,a)){break a}Ip=Ip+1|0;if((Ip|0)>2]){continue}break}Or=1}return Or}function Bi(a,Rr,Sr,Tr){var Ur=0,Vr=0,Wr=0,Xr=0,Yr=0,Zr=x(0),_r=0,$r=x(0),as=0;Ur=q[Sr>>2];as=a;a:{b:{Vr=q[Rr+4>>2];if(!Vr){break b}_r=q[Rr>>2];Xr=co(Vr);Sr=Vr+ -1&Ur;c:{if(Xr>>>0<=1){break c}Sr=Ur;if(Ur>>>0>>0){break c}Sr=(Ur>>>0)%(Vr>>>0)|0}Wr=Sr;Sr=q[(Sr<<2)+_r>>2];if(!Sr){break b}_r=Vr+ -1|0;Xr=Xr>>>0>1;while(1){Sr=q[Sr>>2];if(!Sr){break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>>2]=a;q[Tr+8>>2]=q[Sr+8>>2];Tr=q[bs>>2]+12|0;q[bs>>2]=Tr;Rr=Rr+ -1|0;if(Rr){continue}break c}}cs=q[a>>2];es=(Tr-cs|0)/12|0;bs=es+Rr|0;if(bs>>>0>=357913942){break b}ds=(ds-cs|0)/12|0;cs=ds<<1;bs=ds>>>0<178956970?cs>>>0>>0?bs:cs:357913941;Tr=0;d:{if(!bs){break d}if(bs>>>0>=357913942){break a}Tr=Mm(w(bs,12))}ds=Tr+w(bs,12)|0;bs=Tr+w(es,12)|0;Tr=bs;while(1){cs=q[Sr+4>>2];q[Tr>>2]=q[Sr>>2];q[Tr+4>>2]=cs;q[Tr+8>>2]=q[Sr+8>>2];Tr=Tr+12|0;Rr=Rr+ -1|0;if(Rr){continue}break}cs=a+4|0;Rr=q[a>>2];Sr=q[cs>>2]-Rr|0;bs=bs+w((Sr|0)/-12|0,12)|0;if((Sr|0)>=1){Cn(bs,Rr,Sr)}q[a>>2]=bs;q[a+8>>2]=ds;q[cs>>2]=Tr;if(!Rr){break c}An(Rr)}return}bn();F()}ab(12024);F()}function Di(a){a=a|0;return q[a+8>>2]}function Ei(a){q[a>>2]=11324;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0);q[a+396>>2]=0;q[a+388>>2]=0;q[a+392>>2]=0;q[a+380>>2]=0;q[a+384>>2]=0;ah(a+400|0);q[a+416>>2]=-1;q[a+420>>2]=-1}function Fi(a){a=a|0;var Rr=0,Sr=0,fs=0,gs=0,hs=0,is=0,js=0,ks=0,ls=0,ms=0,ns=0,os=0,ps=0,qs=0,rs=0,ss=0,ts=0;ks=T+ -64|0;T=ks;q[a+132>>2]=0;if(q[a+148>>2]){fs=a+144|0;Sr=q[fs>>2];if(Sr){while(1){Rr=q[Sr>>2];An(Sr);Sr=Rr;if(Rr){continue}break}}q[fs>>2]=0;Rr=q[a+140>>2];if(Rr){fs=a+136|0;Sr=0;while(1){q[q[fs>>2]+(Sr<<2)>>2]=0;Sr=Sr+1|0;if((Rr|0)!=(Sr|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{Sr=q[a+4>>2];fs=r[Sr+36|0];Rr=fs<<8|r[Sr+37|0];g:{if(Rr>>>0>513){break g}is=q[Sr+32>>2];if(Rr>>>0<=511){gs=q[is+12>>2];Rr=q[is+20>>2];js=q[is+16>>2];hs=js+4|0;if(hs>>>0<4){Rr=Rr+1|0}ls=hs;hs=Rr;if((gs|0)<(Rr|0)?1:(gs|0)<=(Rr|0)?t[is+8>>2]>=ls>>>0?0:1:0){break f}Rr=js+q[is>>2]|0;Rr=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks>>2]=Rr;q[is+16>>2]=ls;q[is+20>>2]=hs;q[a+132>>2]=Rr;break g}if(!oi(1,ks,is)){break f}Sr=q[a+4>>2];fs=r[Sr+36|0];q[a+132>>2]=q[ks>>2]}Sr=q[Sr+32>>2];h:{i:{j:{if((fs&255)>>>0<=1){fs=0;is=q[Sr+12>>2];Rr=q[Sr+20>>2];gs=q[Sr+16>>2];hs=gs+4|0;if(hs>>>0<4){Rr=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>>0>=gs>>>0?0:1:0){break a}Rr=qs+rs|0;is=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks+52>>2]=is;q[hs+16>>2]=gs;q[hs+20>>2]=Sr;break k}if(!oi(1,ks+52|0,hs)){break a}is=q[ks+52>>2]}if(js>>>0>>0|js>>>0>((is>>>0)/3|0)+is>>>0){break a}Rr=q[a+4>>2];hs=q[Rr+32>>2];l:{if(r[Rr+36|0]<=1){gs=q[hs+12>>2];Rr=q[hs+20>>2];ms=q[hs+16>>2];Sr=ms+4|0;if(Sr>>>0<4){Rr=Rr+1|0}os=Sr;Sr=Rr;if((gs|0)<(Rr|0)?1:(gs|0)<=(Rr|0)?t[hs+8>>2]>=os>>>0?0:1:0){break a}Rr=ms+q[hs>>2]|0;ms=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks+48>>2]=ms;q[hs+16>>2]=os;q[hs+20>>2]=Sr;break l}if(!oi(1,ks+48|0,hs)){break a}ms=q[ks+48>>2]}if(ms>>>0>is>>>0){break a}q[a+28>>2]=q[a+24>>2];Sr=Mm(88);jk(Sr);Rr=q[a+8>>2];q[a+8>>2]=Sr;hs=a+8|0;if(Rr){wa(hs,Rr);if(!q[hs>>2]){break a}}Rr=q[a+160>>2];q[a+164>>2]=Rr;m:{if(q[a+168>>2]-Rr>>2>>>0>=js>>>0){break m}if(js>>>0>=1073741824){break e}fs=js<<2;Sr=Mm(fs);q[a+164>>2]=Sr;q[a+160>>2]=Sr;q[a+168>>2]=Sr+fs;if(!Rr){break m}An(Rr)}Rr=q[a+172>>2];q[a+176>>2]=Rr;n:{if(q[a+180>>2]-Rr>>2>>>0>=js>>>0){break n}if(js>>>0>=1073741824){break d}fs=js<<2;Sr=Mm(fs);q[a+176>>2]=Sr;q[a+172>>2]=Sr;q[a+180>>2]=Sr+fs;if(!Rr){break n}An(Rr)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];os=a+216|0;Sr=q[a+220>>2];fs=q[a+216>>2];if((Sr|0)==(fs|0)){break c}while(1){Rr=q[Sr+ -12>>2];if(Rr){q[Sr+ -8>>2]=Rr;An(Rr)}Rr=q[Sr+ -28>>2];if(Rr){q[Sr+ -24>>2]=Rr;An(Rr)}Rr=Sr+ -144|0;gs=q[Sr+ -40>>2];if(gs){q[Sr+ -36>>2]=gs;An(gs)}pi(Sr+ -140|0);Sr=Rr;if((fs|0)!=(Rr|0)){continue}break}Rr=q[os>>2];break b}fs=0;break a}ab(12024);F()}ab(12024);F()}Rr=fs}q[a+220>>2]=fs;Sr=(fs-Rr|0)/144|0;o:{if(Sr>>>0>>0){qi(os,ls-Sr|0);break o}if(Sr>>>0<=ls>>>0){break o}Sr=Rr+w(ls,144)|0;if((Sr|0)!=(fs|0)){while(1){Rr=q[fs+ -12>>2];if(Rr){q[fs+ -8>>2]=Rr;An(Rr)}Rr=q[fs+ -28>>2];if(Rr){q[fs+ -24>>2]=Rr;An(Rr)}Rr=fs+ -144|0;gs=q[fs+ -40>>2];if(gs){q[fs+ -36>>2]=gs;An(gs)}pi(fs+ -140|0);fs=Rr;if((Rr|0)!=(Sr|0)){continue}break}}q[a+220>>2]=Sr}fs=0;if(!tk(q[hs>>2],js,q[ns>>2]+ms|0)){break a}Rr=q[a+156>>2];o[ks|0]=1;bb(a+120|0,Rr+ms|0,ks);Sr=q[a+4>>2];Rr=s[Sr+36>>1];Rr=(Rr<<24|Rr<<8&16711680)>>>16;p:{if(Rr>>>0<=513){gs=q[Sr+32>>2];q:{if(Rr>>>0<=511){js=q[gs+12>>2];Rr=q[gs+20>>2];ns=q[gs+16>>2];Sr=ns+4|0;if(Sr>>>0<4){Rr=Rr+1|0}ps=Sr;Sr=Rr;if((js|0)<(Rr|0)?1:(js|0)<=(Rr|0)?t[gs+8>>2]>=ps>>>0?0:1:0){break a}Rr=ns+q[gs>>2]|0;js=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks+44>>2]=js;q[gs+16>>2]=ps;q[gs+20>>2]=Sr;break q}if(!oi(1,ks+44|0,gs)){break a}js=q[ks+44>>2]}if(!js){break a}Rr=q[q[a+4>>2]+32>>2];Sr=q[Rr+8>>2];gs=q[Rr+16>>2];Rr=q[Rr+12>>2]-(q[Rr+20>>2]+(Sr>>>0>>0)|0)|0;if((Rr|0)<0?1:(Rr|0)<=0?Sr-gs>>>0>=js>>>0?0:1:0){break a}gs=Yj(ks);Sr=q[q[a+4>>2]+32>>2];Rr=q[Sr+16>>2];ns=q[Sr+8>>2];Zj(gs,(Rr+q[Sr>>2]|0)+js|0,(ns-Rr|0)-js|0,s[Sr+38>>1]);Sr=ri(a,gs);if((Sr|0)==-1){break a}Rr=Sr;gs=Rr>>31;break p}Rr=-1;gs=-1;if((ri(a,q[Sr+32>>2])|0)==-1){break a}}q[a+376>>2]=a;ns=a+232|0;Sr=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];ps=q[Sr>>2]+q[Sr+16>>2]|0;js=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];Sr=q[js+8>>2];fs=q[js+16>>2];Zj(ns,ps,Sr-fs|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);ss=a,ts=n[q[q[a>>2]+36>>2]](a)|0,q[ss+380>>2]=ts;q[a+372>>2]=ls;q[a+384>>2]=q[a+156>>2]+ms;fs=0;Sr=Yj(ks);r:{if(!Gi(ns,Sr)){break r}js=Hi(a,is);if((js|0)==-1){break r}is=q[q[a+4>>2]+32>>2];fs=q[Sr+16>>2];ls=fs+q[Sr>>2]|0;Sr=q[Sr+8>>2];Zj(is,ls,Sr-fs|0,s[is+38>>1]);Sr=q[a+4>>2];fs=s[Sr+36>>1];is=(fs<<24|fs<<8&16711680)>>>16;if(is>>>0<=513){fs=q[Sr+32>>2];ls=fs;ps=fs;Sr=gs+q[fs+20>>2]|0;fs=Rr+q[fs+16>>2]|0;if(fs>>>0>>0){Sr=Sr+1|0}q[ps+16>>2]=fs;q[ls+20>>2]=Sr}s:{if(q[a+220>>2]==q[a+216>>2]){break s}Sr=q[hs>>2];Rr=q[Sr+4>>2];Sr=q[Sr>>2];t:{if(is>>>0>=513){if((Rr|0)==(Sr|0)){break s}Sr=0;break t}if((Rr|0)==(Sr|0)){break s}Sr=0;while(1){if(ui(a,Sr)){Sr=Sr+3|0;Rr=q[hs>>2];if(Sr>>>0>2]-q[Rr>>2]>>2>>>0){continue}break s}break}fs=0;break r}while(1){if(vi(a,Sr)){Sr=Sr+3|0;Rr=q[hs>>2];if(Sr>>>0>2]-q[Rr>>2]>>2>>>0){continue}break s}break}fs=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}Sr=q[a+216>>2];gs=a+220|0;if((Sr|0)!=q[gs>>2]){is=0;while(1){Rr=w(is,144);Ek((Rr+Sr|0)+4|0,q[hs>>2]);fs=q[os>>2];ls=Rr+fs|0;Sr=q[ls+132>>2];ls=q[ls+136>>2];if((Sr|0)!=(ls|0)){while(1){Gk((Rr+fs|0)+4|0,q[Sr>>2]);fs=q[os>>2];Sr=Sr+4|0;if((ls|0)!=(Sr|0)){continue}break}}Fk((Rr+fs|0)+4|0);is=is+1|0;Sr=q[a+216>>2];if(is>>>0<(q[gs>>2]-Sr|0)/144>>>0){continue}break}}Rr=q[a+8>>2];wi(a+184|0,q[Rr+28>>2]-q[Rr+24>>2]>>2);fs=q[a+216>>2];if((fs|0)!=q[gs>>2]){Sr=0;is=a+220|0;while(1){Rr=w(Sr,144)+fs|0;fs=q[Rr+60>>2]-q[Rr+56>>2]>>2;ls=Rr+104|0;Rr=q[hs>>2];Rr=q[Rr+28>>2]-q[Rr+24>>2]>>2;wi(ls,(fs|0)<(Rr|0)?Rr:fs);Sr=Sr+1|0;fs=q[a+216>>2];if(Sr>>>0<(q[is>>2]-fs|0)/144>>>0){continue}break}}fs=xi(a,js)}}T=ks- -64|0;return fs|0}function Gi(a,us){var vs=0,ws=0,xs=0,ys=0,zs=0,As=0,Bs=0;ys=T-16|0;T=ys;a:{if(!si(a,us)){break a}zs=q[us+12>>2];vs=q[us+20>>2];As=q[us+16>>2];xs=As+4|0;if(xs>>>0<4){vs=vs+1|0}ws=xs;xs=vs;if((zs|0)<(vs|0)?1:(zs|0)<=(vs|0)?t[us+8>>2]>=ws>>>0?0:1:0){break a}vs=As+q[us>>2]|0;vs=r[vs|0]|r[vs+1|0]<<8|(r[vs+2|0]<<16|r[vs+3|0]<<24);q[us+16>>2]=ws;q[us+20>>2]=xs;if((vs|0)<0){break a}ws=q[a+152>>2];if((vs|0)>=(ws|0)){break a}q[ys+12>>2]=0;xs=q[a+156>>2];vs=q[a+160>>2]-xs>>2;b:{if(ws>>>0>vs>>>0){Ad(a+156|0,ws-vs|0,ys+12|0);break b}if(ws>>>0>=vs>>>0){break b}q[a+160>>2]=xs+(ws<<2)}Bs=bh(a+168|0,us)}T=ys+16|0;return Bs}function Hi(a,us){var Cs=0,Ds=0,Es=0,Fs=0,Gs=0,Hs=0,Is=0,Js=0,Ks=0,Ls=0,Ms=0,Ns=0,Os=0,Ps=0,Qs=0,Rs=0,Ss=0,Ts=0,Us=0,Vs=0,Ws=0,Xs=0,Ys=0,Zs=0,_s=0,$s=0,at=0;Gs=T-96|0;T=Gs;q[Gs+72>>2]=0;q[Gs+64>>2]=0;q[Gs+68>>2]=0;q[Gs+48>>2]=0;q[Gs+52>>2]=0;q[Gs+40>>2]=0;q[Gs+44>>2]=0;q[Gs+56>>2]=1065353216;q[Gs+32>>2]=0;q[Gs+24>>2]=0;q[Gs+28>>2]=0;Ss=q[a+124>>2];a:{b:{c:{if((us|0)>=1){Ts=a+400|0;Us=a+232|0;Zs=a+296|0;Vs=a+8|0;_s=a+388|0;Ys=q[a+216>>2]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0;if((Ds|0)==-1){break u}Ds=q[Ps+(Ds<<2)>>2];q[Ps+(Es<<2)>>2]=Ds;if((Ds|0)==-1){break t}q[Is+(Ds<<2)>>2]=Es;break t}q[Ps+(Es<<2)>>2]=-1;Cs=-1;break s}q[Ps+(Es<<2)>>2]=-1}Ds=Ms+1|0;Ds=(Ds>>>0)%3|0?Ds:Ms+ -2|0;Cs=-1;if((Ds|0)==-1){break s}Cs=q[Ps+(Ds<<2)>>2]}q[Fs>>2]=Cs;Ds=q[Gs+68>>2];q[Ds+ -4>>2]=Qs;break p;default:Ds=q[Gs+68>>2];Os=q[Gs+64>>2];if((Ds|0)==(Os|0)){break c}Cs=Ds+ -4|0;Xs=q[Cs>>2];q[Gs+68>>2]=Cs;Is=q[Gs+44>>2];v:{if(!Is){Ds=Cs;break v}Js=q[Gs+40>>2];Ks=co(Is)>>>0>1;Hs=Is+2147483647&Ls;w:{if(!Ks){break w}Fs=Ls;Hs=Fs;if(Fs>>>0>>0){break w}Hs=(Ls>>>0)%(Is>>>0)|0}Fs=Hs;Hs=q[Js+(Fs<<2)>>2];if(!Hs){Ds=Cs;break v}Js=q[Hs>>2];if(!Js){Ds=Cs;break v}Hs=Is+ -1|0;x:{while(1){Ns=q[Js+4>>2];y:{if((Ls|0)!=(Ns|0)){z:{if(!Ks){Ns=Hs&Ns;break z}if(Ns>>>0>>0){break z}Ns=(Ns>>>0)%(Is>>>0)|0}if((Fs|0)==(Ns|0)){break y}Ds=Cs;break v}if(q[Js+8>>2]==(Ls|0)){break x}}Js=q[Js>>2];if(Js){continue}break}Ds=Cs;break v}Fs=Js+12|0;if((Cs|0)!=q[Gs+72>>2]){q[Cs>>2]=q[Fs>>2];q[Gs+68>>2]=Ds;break v}zi(Gs- -64|0,Fs);Ds=q[Gs+68>>2];Os=q[Gs+64>>2]}if((Ds|0)==(Os|0)){break c}Ms=q[Ds+ -4>>2];Fs=(Ms|0)==-1;Rs=q[Vs>>2];if(q[q[Rs+12>>2]+(Ms<<2)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1){q[Fs+(Es<<2)>>2]=Ns;Cs=Es+1|0;Cs=(Cs>>>0)%3|0?Cs:Es+ -2|0;if((Cs|0)==-1){break I}Es=q[q[Is>>2]+(Cs<<2)>>2];if((Es|0)==-1){break I}Cs=Es+1|0;Es=(Cs>>>0)%3|0?Cs:Es+ -2|0;if((Es|0)!=-1){continue}break}}q[Hs+(q[Gs>>2]<<2)>>2]=-1;J:{if(Ys){break J}Cs=q[Gs+28>>2];if((Cs|0)!=q[Gs+32>>2]){q[Cs>>2]=q[Gs>>2];q[Gs+28>>2]=Cs+4;break J}zi(Gs+24|0,Gs);Ds=q[Gs+68>>2]}q[Ds+ -4>>2]=Ps;Cs=0}Ii(Us,q[Ds+ -4>>2]);K:{if(!Cs){break K}Ds=q[Ws>>2];if((Ds|0)==q[a+36>>2]){break K}Hs=(Ls^-1)+us|0;while(1){Es=-1;Cs=q[Ds+ -8>>2];if(Cs>>>0>Hs>>>0){break c}if((Cs|0)!=(Hs|0)){break K}Cs=r[Ds+ -4|0];Ds=Ds+ -12|0;Fs=q[Ds>>2];q[Ws>>2]=Ds;if((Fs|0)<0){break c}Es=q[q[Gs+68>>2]+ -4>>2];q[Gs+20>>2]=(Fs^-1)+us;q[Gs+88>>2]=Gs+20;Bi(Gs,Gs+40|0,Gs+20|0,Gs+88|0);Fs=q[Gs>>2];L:{if(Cs&1){Cs=-1;if((Es|0)==-1){break L}Ds=Es+1|0;Cs=(Ds>>>0)%3|0?Ds:Es+ -2|0;break L}Cs=-1;if((Es|0)==-1){break L}Cs=Es+ -1|0;if((Es>>>0)%3){break L}Cs=Es+2|0}q[Fs+12>>2]=Cs;Ds=q[Ws>>2];if((Ds|0)!=q[a+36>>2]){continue}break}}Ls=Ls+1|0;if((Ls|0)!=(us|0)){continue}break}Hs=us}Es=-1;Js=q[a+8>>2];if(q[Js+28>>2]-q[Js+24>>2]>>2>(Ss|0)){break c}Ds=q[Gs+68>>2];if((Ds|0)!=q[Gs+64>>2]){Ps=a+72|0;us=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Ls=Ls+ -1|0}Es=Ls;us=us+4|0;if((Ks|0)!=(us|0)){continue}break}}us=q[Gs+24>>2]}if(us){q[Gs+28>>2]=us;An(us)}Ds=q[Gs+48>>2];if(Ds){while(1){a=q[Ds>>2];An(Ds);Ds=a;if(Ds){continue}break}}a=q[Gs+40>>2];q[Gs+40>>2]=0;if(a){An(a)}a=q[Gs+64>>2];if(a){q[Gs+68>>2]=a;An(a)}T=Gs+96|0;return Es}bn();F()}function Ii(a,us){var bt=0,ct=0,dt=0,et=0,ft=0;ct=-1;ft=-1;a:{if((us|0)==-1){break a}bt=us+1|0;ct=(bt>>>0)%3|0?bt:us+ -2|0;ft=us+ -1|0;if((us>>>0)%3){break a}ft=us+2|0}bt=q[a+184>>2];b:{if(bt>>>0>7){break b}c:{d:{switch(bt-2|0){default:dt=q[a+148>>2];bt=-1;bt=(ct|0)!=-1?q[q[dt>>2]+(ct<<2)>>2]:bt;ct=1;et=bt<<2;bt=q[a+156>>2];et=et+bt|0;q[et>>2]=q[et>>2]+1;bt=(((ft|0)!=-1?q[q[dt>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 3:et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+1;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+1;ct=2;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 1:et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+1;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+2;ct=1;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 0:case 2:case 4:break b;case 5:break d}}et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+2;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+2;ct=2;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0}q[bt>>2]=q[bt>>2]+ct;bt=q[a+184>>2]}e:{if(bt>>>0>5){break e}f:{switch(bt-1|0){case 0:case 1:case 2:case 3:break e;default:break f}}bt=a;ft=bt;bt=q[bt+156>>2];ct=-1;g:{if((us|0)==-1){break g}ct=us+1|0;us=(ct>>>0)%3|0?ct:us+ -2|0;ct=-1;if((us|0)==-1){break g}ct=q[q[q[a+148>>2]>>2]+(us<<2)>>2]}q[ft+188>>2]=q[bt+(ct<<2)>>2]>5?0:5;return}q[a+188>>2]=-1}function Ji(a){q[a>>2]=11372;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0);q[a+388>>2]=0;q[a+392>>2]=0;q[a+380>>2]=0;q[a+384>>2]=0;q[a+416>>2]=0;q[a+420>>2]=0;q[a+412>>2]=7;q[a+404>>2]=-1;q[a+408>>2]=2;q[a+396>>2]=0;q[a+400>>2]=-1;q[a+424>>2]=0;q[a+428>>2]=0;q[a+432>>2]=0;q[a+436>>2]=0}function Ki(a){a=a|0;var us=0,gt=0,ht=0,it=0,jt=0,kt=0,lt=0,mt=0,nt=0,ot=0,pt=0,qt=0,rt=0,st=0,tt=0,ut=0,vt=0;mt=T+ -64|0;T=mt;q[a+132>>2]=0;if(q[a+148>>2]){ht=a+144|0;gt=q[ht>>2];if(gt){while(1){us=q[gt>>2];An(gt);gt=us;if(us){continue}break}}q[ht>>2]=0;us=q[a+140>>2];if(us){ht=a+136|0;gt=0;while(1){q[q[ht>>2]+(gt<<2)>>2]=0;gt=gt+1|0;if((us|0)!=(gt|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{gt=q[a+4>>2];ht=r[gt+36|0];us=ht<<8|r[gt+37|0];g:{if(us>>>0>513){break g}kt=q[gt+32>>2];if(us>>>0<=511){it=q[kt+12>>2];us=q[kt+20>>2];lt=q[kt+16>>2];jt=lt+4|0;if(jt>>>0<4){us=us+1|0}nt=jt;jt=us;if((it|0)<(us|0)?1:(it|0)<=(us|0)?t[kt+8>>2]>=nt>>>0?0:1:0){break f}us=lt+q[kt>>2]|0;us=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt>>2]=us;q[kt+16>>2]=nt;q[kt+20>>2]=jt;q[a+132>>2]=us;break g}if(!oi(1,mt,kt)){break f}gt=q[a+4>>2];ht=r[gt+36|0];q[a+132>>2]=q[mt>>2]}gt=q[gt+32>>2];h:{i:{j:{if((ht&255)>>>0<=1){ht=0;kt=q[gt+12>>2];us=q[gt+20>>2];it=q[gt+16>>2];jt=it+4|0;if(jt>>>0<4){us=us+1|0}lt=jt;jt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?t[gt+8>>2]>=lt>>>0?0:1:0){break a}us=it+q[gt>>2]|0;us=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+60>>2]=us;q[gt+16>>2]=lt;q[gt+20>>2]=jt;q[a+156>>2]=us;pt=a+156|0;break j}ht=0;if(!oi(1,mt+60|0,gt)){break a}us=q[a+4>>2];gt=q[us+32>>2];us=r[us+36|0];q[a+156>>2]=q[mt+60>>2];pt=a+156|0;if(us>>>0>1){break i}}kt=q[gt+12>>2];us=q[gt+20>>2];it=q[gt+16>>2];jt=it+4|0;if(jt>>>0<4){us=us+1|0}nt=jt;jt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?t[gt+8>>2]>=nt>>>0?0:1:0){break a}us=it+q[gt>>2]|0;lt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+56>>2]=lt;q[gt+16>>2]=nt;q[gt+20>>2]=jt;break h}if(!oi(1,mt+56|0,gt)){break a}lt=q[mt+56>>2]}if(lt>>>0>1431655765|t[pt>>2]>w(lt,3)>>>0){break a}qt=q[a+4>>2];jt=q[qt+32>>2];rt=q[jt+8>>2];ot=q[jt+16>>2];kt=q[jt+12>>2];us=kt;gt=q[jt+20>>2];if((us|0)<(gt|0)?1:(us|0)<=(gt|0)?rt>>>0>ot>>>0?0:1:0){break a}tt=q[jt>>2];nt=r[tt+ot|0];us=gt;st=ot+1|0;if(st>>>0<1){us=us+1|0}q[jt+16>>2]=st;q[jt+20>>2]=us;k:{if(r[qt+36|0]<=1){us=gt;gt=ot+5|0;if(gt>>>0<5){us=us+1|0}it=gt;gt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?rt>>>0>=it>>>0?0:1:0){break a}us=st+tt|0;kt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+52>>2]=kt;q[jt+16>>2]=it;q[jt+20>>2]=gt;break k}if(!oi(1,mt+52|0,jt)){break a}kt=q[mt+52>>2]}if(lt>>>0>>0|lt>>>0>((kt>>>0)/3|0)+kt>>>0){break a}us=q[a+4>>2];jt=q[us+32>>2];l:{if(r[us+36|0]<=1){it=q[jt+12>>2];us=q[jt+20>>2];ot=q[jt+16>>2];gt=ot+4|0;if(gt>>>0<4){us=us+1|0}qt=gt;gt=us;if((it|0)<(us|0)?1:(it|0)<=(us|0)?t[jt+8>>2]>=qt>>>0?0:1:0){break a}us=ot+q[jt>>2]|0;ot=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+48>>2]=ot;q[jt+16>>2]=qt;q[jt+20>>2]=gt;break l}if(!oi(1,mt+48|0,jt)){break a}ot=q[mt+48>>2]}if(ot>>>0>kt>>>0){break a}q[a+28>>2]=q[a+24>>2];gt=Mm(88);jk(gt);us=q[a+8>>2];q[a+8>>2]=gt;jt=a+8|0;if(us){wa(jt,us);if(!q[jt>>2]){break a}}us=q[a+160>>2];q[a+164>>2]=us;m:{if(q[a+168>>2]-us>>2>>>0>=lt>>>0){break m}if(lt>>>0>=1073741824){break e}ht=lt<<2;gt=Mm(ht);q[a+164>>2]=gt;q[a+160>>2]=gt;q[a+168>>2]=gt+ht;if(!us){break m}An(us)}us=q[a+172>>2];q[a+176>>2]=us;n:{if(q[a+180>>2]-us>>2>>>0>=lt>>>0){break n}if(lt>>>0>=1073741824){break d}ht=lt<<2;gt=Mm(ht);q[a+176>>2]=gt;q[a+172>>2]=gt;q[a+180>>2]=gt+ht;if(!us){break n}An(us)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];qt=a+216|0;gt=q[a+220>>2];ht=q[a+216>>2];if((gt|0)==(ht|0)){break c}while(1){us=q[gt+ -12>>2];if(us){q[gt+ -8>>2]=us;An(us)}us=q[gt+ -28>>2];if(us){q[gt+ -24>>2]=us;An(us)}us=gt+ -144|0;it=q[gt+ -40>>2];if(it){q[gt+ -36>>2]=it;An(it)}pi(gt+ -140|0);gt=us;if((ht|0)!=(us|0)){continue}break}us=q[qt>>2];break b}ht=0;break a}ab(12024);F()}ab(12024);F()}us=ht}q[a+220>>2]=ht;gt=(ht-us|0)/144|0;o:{if(gt>>>0>>0){qi(qt,nt-gt|0);break o}if(gt>>>0<=nt>>>0){break o}gt=us+w(nt,144)|0;if((gt|0)!=(ht|0)){while(1){us=q[ht+ -12>>2];if(us){q[ht+ -8>>2]=us;An(us)}us=q[ht+ -28>>2];if(us){q[ht+ -24>>2]=us;An(us)}us=ht+ -144|0;it=q[ht+ -40>>2];if(it){q[ht+ -36>>2]=it;An(it)}pi(ht+ -140|0);ht=us;if((us|0)!=(gt|0)){continue}break}}q[a+220>>2]=gt}ht=0;if(!tk(q[jt>>2],lt,q[pt>>2]+ot|0)){break a}us=q[a+156>>2];o[mt|0]=1;bb(a+120|0,us+ot|0,mt);gt=q[a+4>>2];us=s[gt+36>>1];us=(us<<24|us<<8&16711680)>>>16;p:{if(us>>>0<=513){it=q[gt+32>>2];q:{if(us>>>0<=511){lt=q[it+12>>2];us=q[it+20>>2];pt=q[it+16>>2];gt=pt+4|0;if(gt>>>0<4){us=us+1|0}rt=gt;gt=us;if((lt|0)<(us|0)?1:(lt|0)<=(us|0)?t[it+8>>2]>=rt>>>0?0:1:0){break a}us=pt+q[it>>2]|0;lt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+44>>2]=lt;q[it+16>>2]=rt;q[it+20>>2]=gt;break q}if(!oi(1,mt+44|0,it)){break a}lt=q[mt+44>>2]}if(!lt){break a}us=q[q[a+4>>2]+32>>2];gt=q[us+8>>2];it=q[us+16>>2];us=q[us+12>>2]-(q[us+20>>2]+(gt>>>0>>0)|0)|0;if((us|0)<0?1:(us|0)<=0?gt-it>>>0>=lt>>>0?0:1:0){break a}it=Yj(mt);gt=q[q[a+4>>2]+32>>2];us=q[gt+16>>2];pt=q[gt+8>>2];Zj(it,(us+q[gt>>2]|0)+lt|0,(pt-us|0)-lt|0,s[gt+38>>1]);gt=ri(a,it);if((gt|0)==-1){break a}us=gt;it=us>>31;break p}us=-1;it=-1;if((ri(a,q[gt+32>>2])|0)==-1){break a}}q[a+376>>2]=a;pt=a+232|0;gt=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];rt=q[gt>>2]+q[gt+16>>2]|0;lt=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];gt=q[lt+8>>2];ht=q[lt+16>>2];Zj(pt,rt,gt-ht|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);ut=a,vt=n[q[q[a>>2]+36>>2]](a)|0,q[ut+380>>2]=vt;q[a+372>>2]=nt;q[a+384>>2]=q[a+156>>2]+ot;ht=0;gt=Yj(mt);r:{if(!Li(pt,gt)){break r}lt=Mi(a,kt);if((lt|0)==-1){break r}kt=q[q[a+4>>2]+32>>2];ht=q[gt+16>>2];nt=ht+q[gt>>2]|0;gt=q[gt+8>>2];Zj(kt,nt,gt-ht|0,s[kt+38>>1]);gt=q[a+4>>2];ht=s[gt+36>>1];kt=(ht<<24|ht<<8&16711680)>>>16;if(kt>>>0<=513){ht=q[gt+32>>2];nt=ht;rt=ht;gt=it+q[ht+20>>2]|0;ht=us+q[ht+16>>2]|0;if(ht>>>0>>0){gt=gt+1|0}q[rt+16>>2]=ht;q[nt+20>>2]=gt}s:{if(q[a+220>>2]==q[a+216>>2]){break s}gt=q[jt>>2];us=q[gt+4>>2];gt=q[gt>>2];t:{if(kt>>>0>=513){if((us|0)==(gt|0)){break s}gt=0;break t}if((us|0)==(gt|0)){break s}gt=0;while(1){if(ui(a,gt)){gt=gt+3|0;us=q[jt>>2];if(gt>>>0>2]-q[us>>2]>>2>>>0){continue}break s}break}ht=0;break r}while(1){if(vi(a,gt)){gt=gt+3|0;us=q[jt>>2];if(gt>>>0>2]-q[us>>2]>>2>>>0){continue}break s}break}ht=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}gt=q[a+216>>2];it=a+220|0;if((gt|0)!=q[it>>2]){kt=0;while(1){us=w(kt,144);Ek((us+gt|0)+4|0,q[jt>>2]);ht=q[qt>>2];nt=us+ht|0;gt=q[nt+132>>2];nt=q[nt+136>>2];if((gt|0)!=(nt|0)){while(1){Gk((us+ht|0)+4|0,q[gt>>2]);ht=q[qt>>2];gt=gt+4|0;if((nt|0)!=(gt|0)){continue}break}}Fk((us+ht|0)+4|0);kt=kt+1|0;gt=q[a+216>>2];if(kt>>>0<(q[it>>2]-gt|0)/144>>>0){continue}break}}us=q[a+8>>2];wi(a+184|0,q[us+28>>2]-q[us+24>>2]>>2);ht=q[a+216>>2];if((ht|0)!=q[it>>2]){gt=0;kt=a+220|0;while(1){us=w(gt,144)+ht|0;ht=q[us+60>>2]-q[us+56>>2]>>2;nt=us+104|0;us=q[jt>>2];us=q[us+28>>2]-q[us+24>>2]>>2;wi(nt,(ht|0)<(us|0)?us:ht);gt=gt+1|0;ht=q[a+216>>2];if(gt>>>0<(q[kt>>2]-ht|0)/144>>>0){continue}break}}ht=xi(a,lt)}}T=mt- -64|0;return ht|0}function Li(a,wt){var xt=0,yt=0,zt=0,At=0,Bt=0,Ct=0,Dt=0,Et=0,Ft=0,Gt=0,Ht=0,It=0;Et=T-16|0;T=Et;xt=q[a+144>>2];xt=s[(n[q[q[xt>>2]+32>>2]](xt)|0)+36>>1];a:{if((xt<<24|xt<<8&16711680)>>>16>>>0<=513){xt=q[a+4>>2];q[a+40>>2]=q[a>>2];q[a+44>>2]=xt;zt=a+32|0;xt=zt;yt=q[xt+4>>2];q[a+72>>2]=q[xt>>2];q[a+76>>2]=yt;yt=q[a+28>>2];xt=a- -64|0;q[xt>>2]=q[a+24>>2];q[xt+4>>2]=yt;xt=q[a+20>>2];q[a+56>>2]=q[a+16>>2];q[a+60>>2]=xt;xt=q[a+12>>2];q[a+48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+12>>2];xt=q[xt+8>>2];q[Bt>>2]=xt;q[Bt+4>>2]=yt;Bt=xt-zt|0;Dt=q[Et+12>>2];yt=yt-((xt>>>0>>0)+Ct|0)|0;xt=q[Et+8>>2];if((Dt|0)==(yt|0)&xt>>>0<=Bt>>>0|Dt>>>0>>0){break d}}At=0;break a}At=Ct+Dt|0;zt=xt+zt|0;if(zt>>>0>>0){At=At+1|0}q[a+16>>2]=zt;q[a+20>>2]=At;break c}At=0;if(!bh(a+80|0,a)){break a}}At=0;if(!Ai(a)){break a}xt=q[a+4>>2];q[wt>>2]=q[a>>2];q[wt+4>>2]=xt;xt=q[a+36>>2];q[wt+32>>2]=q[a+32>>2];q[wt+36>>2]=xt;xt=q[a+28>>2];q[wt+24>>2]=q[a+24>>2];q[wt+28>>2]=xt;xt=q[a+20>>2];q[wt+16>>2]=q[a+16>>2];q[wt+20>>2]=xt;xt=q[a+12>>2];q[wt+8>>2]=q[a+8>>2];q[wt+12>>2]=xt;xt=q[a+144>>2];xt=s[(n[q[q[xt>>2]+32>>2]](xt)|0)+36>>1];e:{if((xt<<24|xt<<8&16711680)>>>16>>>0<=513){xt=q[a+144>>2];f:{if(r[(n[q[q[xt>>2]+32>>2]](xt)|0)+36|0]<=1){yt=q[wt+12>>2];xt=q[wt+20>>2];Bt=q[wt+16>>2];zt=Bt+4|0;if(zt>>>0<4){xt=xt+1|0}Ct=zt;zt=xt;if((yt|0)<(xt|0)?1:(yt|0)<=(xt|0)?t[wt+8>>2]>=Ct>>>0?0:1:0){break a}xt=Bt+q[wt>>2]|0;yt=r[xt|0]|r[xt+1|0]<<8|(r[xt+2|0]<<16|r[xt+3|0]<<24);q[Et+8>>2]=yt;q[wt+16>>2]=Ct;q[wt+20>>2]=zt;break f}if(!oi(1,Et+8|0,wt)){break a}yt=q[Et+8>>2]}xt=q[a+152>>2];if(yt>>>0>=xt>>>0){break a}Bt=q[wt+16>>2];yt=q[wt+12>>2];zt=q[wt+20>>2];if((yt|0)<(zt|0)?1:(yt|0)<=(zt|0)?t[wt+8>>2]>Bt>>>0?0:1:0){break a}Ct=r[Bt+q[wt>>2]|0];Bt=Bt+1|0;if(Bt>>>0<1){zt=zt+1|0}yt=wt;q[yt+16>>2]=Bt;q[yt+20>>2]=zt;if(Ct){break a}q[a+176>>2]=2;q[a+180>>2]=7;break e}q[a+176>>2]=2;q[a+180>>2]=7;xt=q[a+152>>2]}if((xt|0)<0){break a}q[Et+8>>2]=0;At=2;Bt=q[a+156>>2];yt=q[a+160>>2]-Bt>>2;g:{if(xt>>>0>yt>>>0){Ad(a+156|0,xt-yt|0,Et+8|0);At=q[a+176>>2];zt=q[a+180>>2];break g}zt=7;if(xt>>>0>=yt>>>0){break g}q[a+160>>2]=Bt+(xt<<2)}Bt=a+184|0;zt=(zt-At|0)+1|0;At=a+188|0;xt=q[At>>2];Ct=q[a+184>>2];yt=(xt-Ct|0)/12|0;h:{if(zt>>>0>yt>>>0){Ni(Bt,zt-yt|0);zt=q[At>>2];break h}if(zt>>>0>=yt>>>0){zt=xt;break h}zt=Ct+w(zt,12)|0;if((zt|0)!=(xt|0)){while(1){yt=xt+ -12|0;At=q[yt>>2];if(At){q[xt+ -8>>2]=At;An(At)}xt=yt;if((xt|0)!=(zt|0)){continue}break}}q[a+188>>2]=zt}Ct=a+196|0;xt=q[a+184>>2];yt=(zt-xt|0)/12|0;Dt=q[a+196>>2];At=q[a+200>>2]-Dt>>2;i:{if(yt>>>0>At>>>0){Fa(Ct,yt-At|0);zt=q[a+188>>2];xt=q[a+184>>2];break i}if(yt>>>0>=At>>>0){break i}q[a+200>>2]=Dt+(yt<<2)}At=1;if((xt|0)==(zt|0)){break a}xt=0;It=a+188|0;while(1){oi(1,Et+8|0,wt);zt=q[Et+8>>2];if(zt){yt=q[Bt>>2];Ft=w(xt,12);At=yt+Ft|0;Gt=At+4|0;Ht=q[At>>2];Dt=q[Gt>>2]-Ht>>2;j:{if(zt>>>0>Dt>>>0){Fa(At,zt-Dt|0);yt=q[Bt>>2];break j}if(zt>>>0>=Dt>>>0){break j}q[Gt>>2]=(zt<<2)+Ht}qh(zt,1,wt,q[yt+Ft>>2]);q[q[Ct>>2]+(xt<<2)>>2]=zt}At=1;xt=xt+1|0;if(xt>>>0<(q[It>>2]-q[a+184>>2]|0)/12>>>0){continue}break}}T=Et+16|0;return At} + + + +function Mi(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,p=0,u=0,v=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,G=0,H=0,I=0;g=T-96|0;T=g;q[g+72>>2]=0;q[g+64>>2]=0;q[g+68>>2]=0;q[g+48>>2]=0;q[g+52>>2]=0;q[g+40>>2]=0;q[g+44>>2]=0;q[g+56>>2]=1065353216;q[g+32>>2]=0;q[g+24>>2]=0;q[g+28>>2]=0;C=q[a+124>>2];a:{b:{c:{if((b|0)>=1){A=a+232|0;B=a+8|0;D=a+40|0;G=a+388|0;E=q[a+216>>2]!=q[a+220>>2];while(1){h=Oi(A);d:{if(!h){d=q[g+68>>2];if((d|0)==q[g+64>>2]){e=-1;break c}n=-1;u=q[B>>2];i=q[u+24>>2];f=i;h=d+ -4|0;v=q[h>>2];c=-1;e:{if((v|0)==-1){break e}e=v+1|0;e=(e>>>0)%3|0?e:v+ -2|0;c=-1;if((e|0)==-1){break e}c=q[q[u>>2]+(e<<2)>>2]}f=q[f+(c<<2)>>2];if((f|0)!=-1){e=f+1|0;n=(e>>>0)%3|0?e:f+ -2|0}f=q[u+12>>2];x=w(j,3);e=x+1|0;q[f+(v<<2)>>2]=e;e=e<<2;q[e+f>>2]=v;y=x+2|0;q[f+(n<<2)>>2]=y;k=y<<2;q[k+f>>2]=n;p=q[u>>2];q[p+(x<<2)>>2]=c;m=e+p|0;f=-1;f:{if((n|0)==-1){break f}e=n+1|0;e=(e>>>0)%3|0?e:n+ -2|0;f=-1;if((e|0)==-1){break f}f=q[p+(e<<2)>>2]}q[m>>2]=f;g:{h:{if((v|0)!=-1){e=v+((v>>>0)%3|0?-1:2)|0;if((e|0)!=-1){break h}}q[k+p>>2]=-1;break g}e=q[p+(e<<2)>>2];q[k+p>>2]=e;if((e|0)==-1){break g}q[i+(e<<2)>>2]=y}f=q[a+120>>2]+(c>>>3&536870908)|0;e=q[f>>2];H=f,I=eo(c)&e,q[H>>2]=I;q[h>>2]=x;c=0;break d}e=-1;d=h+ -1|0;if(d>>>0>6){break c}i:{j:{k:{l:{switch(d-1|0){case 1:case 3:f=q[g+68>>2];if((f|0)==q[g+64>>2]){break c}e=q[B>>2];c=q[e+12>>2];y=w(j,3);i=(h|0)==5;h=y+(i?2:1)|0;d=h<<2;p=q[f+ -4>>2];q[c+d>>2]=p;q[c+(p<<2)>>2]=h;f=e+24|0;m=q[e+32>>2];e=e+28|0;c=q[e>>2];m:{if((m|0)!=(c|0)){q[c>>2]=-1;u=c+4|0;q[e>>2]=u;break m}zi(f,11312);u=q[e>>2]}e=-1;c=q[B>>2];k=q[c+24>>2];if(q[c+28>>2]-k>>2>(C|0)){break c}e=y+2|0;x=q[c>>2];m=x+d|0;c=u-q[f>>2]|0;d=(c>>2)+ -1|0;q[m>>2]=d;if(c){q[k+(d<<2)>>2]=h}e=i?y:e;f=x+(i+y<<2)|0;n:{o:{p:{if((p|0)!=-1){d=p+((p>>>0)%3|0?-1:2)|0;if((d|0)==-1){break p}d=q[x+(d<<2)>>2];q[x+(e<<2)>>2]=d;if((d|0)==-1){break o}q[k+(d<<2)>>2]=e;break o}q[x+(e<<2)>>2]=-1;c=-1;break n}q[x+(e<<2)>>2]=-1}d=p+1|0;d=(d>>>0)%3|0?d:p+ -2|0;c=-1;if((d|0)==-1){break n}c=q[x+(d<<2)>>2]}q[f>>2]=c;d=q[g+68>>2];q[d+ -4>>2]=y;break k;default:d=q[g+68>>2];u=q[g+64>>2];if((d|0)==(u|0)){break c}c=d+ -4|0;z=q[c>>2];q[g+68>>2]=c;k=q[g+44>>2];q:{if(!k){d=c;break q}i=co(k)>>>0>1;r:{if(!i){f=k+2147483647&j;break r}f=j;if(f>>>0>>0){break r}f=(j>>>0)%(k>>>0)|0}h=q[q[g+40>>2]+(f<<2)>>2];if(!h){d=c;break q}l=q[h>>2];if(!l){d=c;break q}h=k+ -1|0;s:{while(1){n=q[l+4>>2];t:{if((j|0)!=(n|0)){u:{if(!i){n=h&n;break u}if(n>>>0>>0){break u}n=(n>>>0)%(k>>>0)|0}if((f|0)==(n|0)){break t}d=c;break q}if(q[l+8>>2]==(j|0)){break s}}l=q[l>>2];if(l){continue}break}d=c;break q}f=l+12|0;if((c|0)!=q[g+72>>2]){q[c>>2]=q[f>>2];q[g+68>>2]=d;break q}zi(g- -64|0,f);d=q[g+68>>2];u=q[g+64>>2]}if((d|0)==(u|0)){break c}p=q[d+ -4>>2];f=(p|0)==-1;v=q[B>>2];if(q[q[v+12>>2]+(p<<2)>>2]!=-1?!f:0){break c}i=(z|0)==-1;k=v+12|0;h=q[k>>2];if(q[h+(z<<2)>>2]!=-1?!i:0){break c}x=w(j,3);y=x+2|0;q[h+(p<<2)>>2]=y;u=y<<2;q[u+h>>2]=p;c=x+1|0;q[h+(z<<2)>>2]=c;m=h;h=c<<2;q[m+h>>2]=z;if(f){break j}n=-1;m=q[v>>2];f=m+(x<<2)|0;c=p+((p>>>0)%3|0?-1:2)|0;if((c|0)!=-1){n=q[(c<<2)+m>>2]}q[f>>2]=n;c=p+1|0;c=(c>>>0)%3|0?c:p+ -2|0;if((c|0)==-1){break i}e=q[(c<<2)+m>>2];break i;case 5:break l;case 0:case 2:case 4:break c}}q[g>>2]=w(j,3);d=q[B>>2];f=d+24|0;i=q[d+32>>2];c=d+28|0;d=q[c>>2];v:{if((i|0)!=(d|0)){q[d>>2]=-1;m=d+4|0;q[c>>2]=m;break v}zi(f,11312);m=q[c>>2]}u=q[B>>2];n=q[u>>2];d=q[g>>2];k=m-q[f>>2]|0;y=k>>2;c=y+ -1|0;q[n+(d<<2)>>2]=c;d=d+1|0;i=u+24|0;h=u+28|0;f=q[h>>2];w:{if((f|0)!=q[u+32>>2]){q[f>>2]=-1;m=f+4|0;q[h>>2]=m;break w}zi(i,11312);m=q[h>>2];n=q[u>>2]}q[(d<<2)+n>>2]=(m-q[i>>2]>>2)+ -1;d=q[g>>2]+2|0;i=q[B>>2];f=i+28|0;h=q[f>>2];x:{if((h|0)!=q[i+32>>2]){q[h>>2]=-1;n=h+4|0;q[f>>2]=n;break x}zi(i+24|0,11312);n=q[f>>2]}q[q[i>>2]+(d<<2)>>2]=(n-q[i+24>>2]>>2)+ -1;d=q[B>>2];f=q[d+24>>2];if(q[d+28>>2]-f>>2>(C|0)){break c}d=q[g>>2];y:{z:{if(!k){e=1;q[f+(y<<2)>>2]=d+1;break z}q[f+(c<<2)>>2]=d;e=0;if((k|0)==-4){break z}q[f+(y<<2)>>2]=q[g>>2]+1;e=y+1|0;if((e|0)==-1){break y}}q[f+(e<<2)>>2]=q[g>>2]+2}d=q[g+68>>2];if((d|0)!=q[g+72>>2]){q[d>>2]=q[g>>2];d=d+4|0;q[g+68>>2]=d;break k}zi(g- -64|0,g);d=q[g+68>>2]}c=1;break d}n=-1;m=q[v>>2];q[m+(x<<2)>>2]=-1}q[h+m>>2]=e;A:{B:{C:{if(!i){c=z+((z>>>0)%3|0?-1:2)|0;if((c|0)==-1){break C}c=q[(c<<2)+m>>2];q[u+m>>2]=c;if((c|0)==-1){break B}q[q[v+24>>2]+(c<<2)>>2]=y;break B}q[u+m>>2]=-1;l=-1;e=-1;break A}q[u+m>>2]=-1}l=-1;c=z+1|0;c=(c>>>0)%3|0?c:z+ -2|0;e=-1;if((c|0)==-1){break A}l=q[(c<<2)+m>>2];e=c}q[g>>2]=l;h=q[G>>2];f=n<<2;c=h+f|0;q[c>>2]=q[c>>2]+q[h+(l<<2)>>2];h=q[v+24>>2];if((n|0)!=-1){q[f+h>>2]=q[h+(q[g>>2]<<2)>>2]}D:{if((e|0)==-1){break D}f=q[v>>2];while(1){q[f+(e<<2)>>2]=n;c=e+1|0;c=(c>>>0)%3|0?c:e+ -2|0;if((c|0)==-1){break D}e=q[q[k>>2]+(c<<2)>>2];if((e|0)==-1){break D}c=e+1|0;e=(c>>>0)%3|0?c:e+ -2|0;if((e|0)!=-1){continue}break}}q[h+(q[g>>2]<<2)>>2]=-1;E:{if(E){break E}c=q[g+28>>2];if((c|0)!=q[g+32>>2]){q[c>>2]=q[g>>2];q[g+28>>2]=c+4;break E}zi(g+24|0,g);d=q[g+68>>2]}q[d+ -4>>2]=x;c=0}Pi(A,q[d+ -4>>2]);F:{if(!c){break F}d=q[D>>2];if((d|0)==q[a+36>>2]){break F}h=(j^-1)+b|0;while(1){e=-1;c=q[d+ -8>>2];if(c>>>0>h>>>0){break c}if((c|0)!=(h|0)){break F}c=r[d+ -4|0];d=d+ -12|0;f=q[d>>2];q[D>>2]=d;if((f|0)<0){break c}e=q[q[g+68>>2]+ -4>>2];q[g+20>>2]=(f^-1)+b;q[g+88>>2]=g+20;Bi(g,g+40|0,g+20|0,g+88|0);f=q[g>>2];G:{if(c&1){c=-1;if((e|0)==-1){break G}d=e+1|0;c=(d>>>0)%3|0?d:e+ -2|0;break G}c=-1;if((e|0)==-1){break G}c=e+ -1|0;if((e>>>0)%3){break G}c=e+2|0}q[f+12>>2]=c;d=q[D>>2];if((d|0)!=q[a+36>>2]){continue}break}}j=j+1|0;if((j|0)!=(b|0)){continue}break}h=b}e=-1;l=q[a+8>>2];if(q[l+28>>2]-q[l+24>>2]>>2>(C|0)){break c}d=q[g+68>>2];if((d|0)!=q[g+64>>2]){C=a+72|0;b=a+60|0;y=a+312|0;G=a+352|0;E=a+8|0;D=a+68|0;x=a+80|0;v=a+76|0;while(1){c=d+ -4|0;d=q[c>>2];q[g+68>>2]=c;q[g>>2]=d;H:{I:{J:{K:{if(s[a+270>>1]<=513){if(!r[a+364|0]){break J}c=q[a+360>>2];d=q[G>>2]+(c>>>3)|0;if(d>>>0>=t[a+356>>2]){break I}d=r[d|0];q[a+360>>2]=c+1;c=d>>>(c&7)&1;break K}c=dh(y)}if(!c){break I}}k=q[E>>2];z=q[k>>2];if((h|0)>=((q[k+4>>2]-z>>2>>>0)/3|0)){break c}j=-1;l=-1;i=q[k+24>>2];f=i;A=q[g>>2];d=-1;L:{if((A|0)==-1){break L}c=A+1|0;c=(c>>>0)%3|0?c:A+ -2|0;d=-1;if((c|0)==-1){break L}d=q[z+(c<<2)>>2]}f=q[f+(d<<2)>>2];M:{if((f|0)==-1){break M}c=f+1|0;c=(c>>>0)%3|0?c:f+ -2|0;if((c|0)==-1){break M}j=c+1|0;j=(j>>>0)%3|0?j:c+ -2|0;if((j|0)!=-1){l=q[z+(j<<2)>>2]}j=c}p=-1;m=-1;i=q[i+(l<<2)>>2];f=-1;N:{if((i|0)==-1){break N}c=i+1|0;c=(c>>>0)%3|0?c:i+ -2|0;f=-1;if((c|0)==-1){break N}f=c+1|0;f=(f>>>0)%3|0?f:c+ -2|0;if((f|0)!=-1){m=q[z+(f<<2)>>2]}f=c}c=w(h,3);q[g+88>>2]=c;i=q[k+12>>2];q[i+(c<<2)>>2]=A;q[i+(A<<2)>>2]=c;c=q[g+88>>2]+1|0;q[i+(c<<2)>>2]=j;q[i+(j<<2)>>2]=c;c=q[g+88>>2]+2|0;q[i+(c<<2)>>2]=f;q[i+(f<<2)>>2]=c;c=q[g+88>>2];q[z+(c<<2)>>2]=l;u=c+1|0;k=z+(u<<2)|0;q[k>>2]=m;i=c+2|0;f=z+(i<<2)|0;q[f>>2]=d;A=q[a+120>>2];j=u>>>0>>0?-1:l;c=A+(j>>>3&536870908)|0;d=q[c>>2];H=c,I=eo(j)&d,q[H>>2]=I;p=(u|0)!=-1?q[k>>2]:p;c=A+(p>>>3&536870908)|0;d=q[c>>2];H=c,I=eo(p)&d,q[H>>2]=I;d=-1;d=(i|0)!=-1?q[f>>2]:d;j=A+(d>>>3&536870908)|0;c=q[j>>2];H=j,I=eo(d)&c,q[H>>2]=I;d=q[a+64>>2];f=q[D>>2];if((d|0)==f<<5){if((d+1|0)<=-1){break a}c=b;if(d>>>0<=1073741822){j=d+32&-32;d=f<<6;d=d>>>0>>0?j:d}else{d=2147483647}cb(c,d);d=q[a+64>>2]}h=h+1|0;q[a+64>>2]=d+1;c=q[a+60>>2]+(d>>>3&536870908)|0;q[c>>2]=q[c>>2]|1<<(d&31);d=q[v>>2];if((d|0)!=q[x>>2]){q[d>>2]=q[g+88>>2];q[v>>2]=d+4;break H}zi(C,g+88|0);break H}d=q[a+64>>2];f=q[D>>2];if((d|0)==f<<5){if((d+1|0)<=-1){break a}c=b;if(d>>>0<=1073741822){j=d+32&-32;d=f<<6;d=d>>>0>>0?j:d}else{d=2147483647}cb(c,d);d=q[a+64>>2]}q[a+64>>2]=d+1;j=q[a+60>>2]+(d>>>3&536870908)|0;c=q[j>>2];H=j,I=eo(d)&c,q[H>>2]=I;d=q[v>>2];if((d|0)!=q[x>>2]){q[d>>2]=q[g>>2];q[v>>2]=d+4;break H}zi(C,g)}d=q[g+68>>2];if((d|0)!=q[g+64>>2]){continue}break}l=q[a+8>>2]}if(((q[l+4>>2]-q[l>>2]>>2>>>0)/3|0)!=(h|0)){break c}e=q[l+28>>2]-q[l+24>>2]>>2;b=q[g+24>>2];i=q[g+28>>2];if((b|0)==(i|0)){break b}f=a+8|0;while(1){k=q[b>>2];h=q[l+24>>2];d=e+ -1|0;O:{if(q[h+(d<<2)>>2]!=-1){j=e;break O}h=q[l+24>>2];while(1){d=e+ -2|0;j=e+ -1|0;e=j;if(q[(d<<2)+h>>2]==-1){continue}break}}if(d>>>0>=k>>>0){q[g>>2]=l;c=d<<2;e=q[c+h>>2];o[g+12|0]=1;q[g+8>>2]=e;q[g+4>>2]=e;if((e|0)!=-1){while(1){q[q[l>>2]+(e<<2)>>2]=k;lg(g);l=q[f>>2];e=q[g+8>>2];if((e|0)!=-1){continue}break}}e=c;c=q[l+24>>2];e=e+c|0;if((k|0)!=-1){q[c+(k<<2)>>2]=q[e>>2]}q[e>>2]=-1;E=1<<(k&31);e=q[a+120>>2];k=e+(k>>>3&536870908)|0;c=k;h=e+(d>>>3&536870908)|0;d=1<<(d&31);e=E|q[k>>2];P:{if(q[h>>2]&d){break P}e=q[k>>2]&(E^-1)}q[c>>2]=e;q[h>>2]=q[h>>2]&(d^-1);j=j+ -1|0}e=j;b=b+4|0;if((i|0)!=(b|0)){continue}break}}b=q[g+24>>2]}if(b){q[g+28>>2]=b;An(b)}d=q[g+48>>2];if(d){while(1){a=q[d>>2];An(d);d=a;if(d){continue}break}}a=q[g+40>>2];q[g+40>>2]=0;if(a){An(a)}a=q[g+64>>2];if(a){q[g+68>>2]=a;An(a)}T=g+96|0;return e}bn();F()}function Ni(a,b){var o=0,r=0,s=0,t=0,J=0,K=0,L=0,M=0,N=0;s=q[a+8>>2];t=a+4|0;o=q[t>>2];if((s-o|0)/12>>>0>=b>>>0){a=w(b,12);M=t,N=Dn(o,0,a)+a|0,q[M>>2]=N;return}a:{t=q[a>>2];r=(o-t|0)/12|0;J=r+b|0;if(J>>>0<357913942){L=w(r,12);s=(s-t|0)/12|0;r=s<<1;r=s>>>0<178956970?r>>>0>>0?J:r:357913941;if(r){if(r>>>0>=357913942){break a}K=Mm(w(r,12))}s=K+L|0;Dn(s,0,w(b,12));b=w(J,12)+K|0;J=w(r,12)+K|0;if((o|0)!=(t|0)){while(1){s=s+ -12|0;q[s>>2]=0;q[s+4>>2]=0;r=s+8|0;q[r>>2]=0;o=o+ -12|0;q[s>>2]=q[o>>2];q[s+4>>2]=q[o+4>>2];K=r;r=o+8|0;q[K>>2]=q[r>>2];q[r>>2]=0;q[o>>2]=0;q[o+4>>2]=0;if((o|0)!=(t|0)){continue}break}t=q[a>>2];o=q[a+4>>2]}q[a>>2]=s;q[a+8>>2]=J;q[a+4>>2]=b;if((o|0)!=(t|0)){while(1){a=o+ -12|0;b=q[a>>2];if(b){q[o+ -8>>2]=b;An(b)}o=a;if((o|0)!=(t|0)){continue}break}}if(t){An(t)}return}bn();F()}ab(12024);F()}function Oi(a){var b=0,F=0,O=0,P=0,Q=0,R=0,S=0;b=q[a+172>>2];if((b|0)!=-1){F=q[a+196>>2]+(b<<2)|0;O=q[F>>2];b=O+ -1|0;q[F>>2]=b;if((O|0)<1){return 9}F=a;a=q[(q[q[q[a+184>>2]+w(q[a+172>>2],12)>>2]+(b<<2)>>2]<<2)+12096>>2];q[F+168>>2]=a;return a}b=7;F=q[a+144>>2];F=s[(n[q[q[F>>2]+32>>2]](F)|0)+36>>1];a:{if((F<<24|F<<8&16711680)>>>16>>>0>513){break a}if(!r[a+76|0]){q[a+168>>2]=1;return 1}b=0;Q=q[a- -64>>2];O=q[a+72>>2];F=Q+(O>>>3)|0;R=q[a+68>>2];if(F>>>0>=R>>>0){break a}P=r[F|0];F=O+1|0;q[a+72>>2]=F;if(!(P>>>(O&7)&1)){break a}P=F>>>3;b=Q+P|0;b:{if(b>>>0>=R>>>0){b=F;F=0;break b}S=r[b|0];b=O+2|0;q[a+72>>2]=b;P=b>>>3;F=S>>>(F&7)&1}O=P+Q|0;if(O>>>0>>0){O=r[O|0];q[a+72>>2]=b+1;b=O>>>(b&7)<<1&2}else{b=0}b=(F|b)<<1|1}q[a+168>>2]=b;return b}function Pi(a,w){var T=0,U=0,V=0,W=0,X=0;W=-1;U=-1;a:{if((w|0)==-1){break a}U=w+1|0;W=(U>>>0)%3|0?U:w+ -2|0;U=w+ -1|0;if((w>>>0)%3){break a}U=w+2|0}T=q[a+168>>2];b:{if(T>>>0>7){break b}c:{d:{switch(T-2|0){default:T=q[a+148>>2];V=1;w=q[a+156>>2];X=w+(((W|0)!=-1?q[q[T>>2]+(W<<2)>>2]:-1)<<2)|0;q[X>>2]=q[X>>2]+1;w=(((U|0)!=-1?q[q[T>>2]+(U<<2)>>2]:-1)<<2)+w|0;break c;case 3:V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+1;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+1;T=-1;T=(U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:T;V=2;w=w+(T<<2)|0;break c;case 1:V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+1;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+2;w=(((U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:-1)<<2)+w|0;V=1;break c;case 0:case 2:case 4:break b;case 5:break d}}V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+2;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+2;T=-1;T=(U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:T;V=2;w=w+(T<<2)|0}q[w>>2]=q[w>>2]+V}T=-1;T=(W|0)!=-1?q[q[q[a+148>>2]>>2]+(W<<2)>>2]:T;W=q[a+176>>2];w=W;U=a;T=q[q[a+156>>2]+(T<<2)>>2];if((T|0)>=(w|0)){a=q[a+180>>2];w=(T|0)>(a|0)?a:T}q[U+172>>2]=w-W}function Qi(a){a=a|0;var w=0,Y=0,Z=0,_=0,$=0;q[a>>2]=11272;w=a+368|0;Z=q[w>>2];q[w>>2]=0;if(Z){Y=Z+ -4|0;w=q[Y>>2];if(w){w=Z+(w<<4)|0;while(1){w=w+ -16|0;if((Z|0)!=(w|0)){continue}break}}An(Y)}Z=q[a+216>>2];if(Z){$=a+220|0;w=q[$>>2];Y=Z;a:{if((Z|0)==(w|0)){break a}while(1){Y=q[w+ -12>>2];if(Y){q[w+ -8>>2]=Y;An(Y)}Y=q[w+ -28>>2];if(Y){q[w+ -24>>2]=Y;An(Y)}Y=w+ -144|0;_=q[w+ -40>>2];if(_){q[w+ -36>>2]=_;An(_)}pi(w+ -140|0);w=Y;if((Z|0)!=(w|0)){continue}break}Y=q[a+216>>2]}q[$>>2]=Z;An(Y)}w=q[a+196>>2];if(w){q[a+200>>2]=w;An(w)}w=q[a+184>>2];if(w){q[a+188>>2]=w;An(w)}w=q[a+172>>2];if(w){q[a+176>>2]=w;An(w)}w=q[a+160>>2];if(w){q[a+164>>2]=w;An(w)}w=q[a+144>>2];if(w){while(1){Z=q[w>>2];An(w);w=Z;if(w){continue}break}}Z=a+136|0;w=q[Z>>2];q[Z>>2]=0;if(w){An(w)}w=q[a+120>>2];if(w){An(w)}w=q[a+108>>2];if(w){An(w)}w=q[a+96>>2];if(w){An(w)}w=q[a+72>>2];if(w){q[a+76>>2]=w;An(w)}w=q[a+60>>2];if(w){An(w)}w=q[a+48>>2];if(w){q[a+52>>2]=w;An(w)}w=q[a+36>>2];if(w){q[a+40>>2]=w;An(w)}w=q[a+24>>2];if(w){q[a+28>>2]=w;An(w)}w=q[a+12>>2];if(w){q[a+16>>2]=w;An(w)}w=q[a+8>>2];q[a+8>>2]=0;if(w){wa(a+8|0,w)}return a|0}function Ri(a){a=a|0;An(Qi(a))}function Si(a){a=a|0;var aa=0,ba=0,ca=0,da=0,ea=0;q[a>>2]=11324;aa=q[a+388>>2];if(aa){q[a+392>>2]=aa;An(aa)}aa=a+368|0;ca=q[aa>>2];q[aa>>2]=0;if(ca){ba=ca+ -4|0;aa=q[ba>>2];if(aa){aa=ca+(aa<<4)|0;while(1){aa=aa+ -16|0;if((ca|0)!=(aa|0)){continue}break}}An(ba)}ca=q[a+216>>2];if(ca){ea=a+220|0;aa=q[ea>>2];ba=ca;a:{if((ca|0)==(aa|0)){break a}while(1){ba=q[aa+ -12>>2];if(ba){q[aa+ -8>>2]=ba;An(ba)}ba=q[aa+ -28>>2];if(ba){q[aa+ -24>>2]=ba;An(ba)}ba=aa+ -144|0;da=q[aa+ -40>>2];if(da){q[aa+ -36>>2]=da;An(da)}pi(aa+ -140|0);aa=ba;if((ca|0)!=(aa|0)){continue}break}ba=q[a+216>>2]}q[ea>>2]=ca;An(ba)}aa=q[a+196>>2];if(aa){q[a+200>>2]=aa;An(aa)}aa=q[a+184>>2];if(aa){q[a+188>>2]=aa;An(aa)}aa=q[a+172>>2];if(aa){q[a+176>>2]=aa;An(aa)}aa=q[a+160>>2];if(aa){q[a+164>>2]=aa;An(aa)}aa=q[a+144>>2];if(aa){while(1){ca=q[aa>>2];An(aa);aa=ca;if(aa){continue}break}}ca=a+136|0;aa=q[ca>>2];q[ca>>2]=0;if(aa){An(aa)}aa=q[a+120>>2];if(aa){An(aa)}aa=q[a+108>>2];if(aa){An(aa)}aa=q[a+96>>2];if(aa){An(aa)}aa=q[a+72>>2];if(aa){q[a+76>>2]=aa;An(aa)}aa=q[a+60>>2];if(aa){An(aa)}aa=q[a+48>>2];if(aa){q[a+52>>2]=aa;An(aa)}aa=q[a+36>>2];if(aa){q[a+40>>2]=aa;An(aa)}aa=q[a+24>>2];if(aa){q[a+28>>2]=aa;An(aa)}aa=q[a+12>>2];if(aa){q[a+16>>2]=aa;An(aa)}aa=q[a+8>>2];q[a+8>>2]=0;if(aa){wa(a+8|0,aa)}return a|0}function Ti(a){a=a|0;An(Si(a))}function Ui(a){a=a|0;var fa=0,ga=0,ha=0,ia=0,ja=0;q[a>>2]=11372;Vi(a+232|0);ia=q[a+216>>2];if(ia){ga=ia;ja=a+220|0;fa=q[ja>>2];ha=ga;a:{if((ga|0)==(fa|0)){break a}while(1){ga=q[fa+ -12>>2];if(ga){q[fa+ -8>>2]=ga;An(ga)}ga=q[fa+ -28>>2];if(ga){q[fa+ -24>>2]=ga;An(ga)}ga=fa+ -144|0;ha=q[fa+ -40>>2];if(ha){q[fa+ -36>>2]=ha;An(ha)}pi(fa+ -140|0);fa=ga;if((ia|0)!=(fa|0)){continue}break}ha=q[a+216>>2]}ga=ha;q[ja>>2]=ia;An(ga)}fa=q[a+196>>2];if(fa){q[a+200>>2]=fa;An(fa)}fa=q[a+184>>2];if(fa){q[a+188>>2]=fa;An(fa)}fa=q[a+172>>2];if(fa){q[a+176>>2]=fa;An(fa)}fa=q[a+160>>2];if(fa){q[a+164>>2]=fa;An(fa)}fa=q[a+144>>2];if(fa){while(1){ga=q[fa>>2];An(fa);fa=ga;if(fa){continue}break}}fa=a+136|0;ga=q[fa>>2];q[fa>>2]=0;if(ga){An(ga)}fa=q[a+120>>2];if(fa){An(fa)}fa=q[a+108>>2];if(fa){An(fa)}fa=q[a+96>>2];if(fa){An(fa)}fa=q[a+72>>2];if(fa){q[a+76>>2]=fa;An(fa)}fa=q[a+60>>2];if(fa){An(fa)}fa=q[a+48>>2];if(fa){q[a+52>>2]=fa;An(fa)}fa=q[a+36>>2];if(fa){q[a+40>>2]=fa;An(fa)}fa=q[a+24>>2];if(fa){q[a+28>>2]=fa;An(fa)}fa=q[a+12>>2];if(fa){q[a+16>>2]=fa;An(fa)}fa=q[a+8>>2];q[a+8>>2]=0;if(fa){wa(a+8|0,fa)}return a|0}function Vi(a){var ka=0,la=0,ma=0,na=0,oa=0;ka=q[a+196>>2];if(ka){q[a+200>>2]=ka;An(ka)}ka=q[a+184>>2];if(ka){oa=a+188|0;la=q[oa>>2];ma=ka;a:{if((ka|0)==(la|0)){break a}while(1){ma=la+ -12|0;na=q[ma>>2];if(na){q[la+ -8>>2]=na;An(na)}la=ma;if((la|0)!=(ka|0)){continue}break}ma=q[a+184>>2]}q[oa>>2]=ka;An(ma)}ka=q[a+156>>2];if(ka){q[a+160>>2]=ka;An(ka)}ka=a+136|0;a=q[ka>>2];q[ka>>2]=0;if(a){la=a+ -4|0;ka=q[la>>2];if(ka){ka=a+(ka<<4)|0;while(1){ka=ka+ -16|0;if((a|0)!=(ka|0)){continue}break}}An(la)}}function Wi(a){a=a|0;An(Ui(a))}function Xi(a){a=a|0;var pa=0;q[a>>2]=11760;pa=q[a+48>>2];if(pa){q[a+52>>2]=pa;An(pa)}q[a>>2]=12012;pa=q[a+36>>2];if(pa){An(pa)}pa=q[a+24>>2];if(pa){An(pa)}An(a)}function Yi(a){a=a|0;var qa=0;q[a>>2]=12012;qa=q[a+36>>2];if(qa){An(qa)}qa=q[a+24>>2];if(qa){An(qa)}return a|0}function Zi(a){a=a|0;var ra=0;q[a>>2]=12012;ra=q[a+36>>2];if(ra){An(ra)}ra=q[a+24>>2];if(ra){An(ra)}An(a)}function _i(a,sa,ta){a=a|0;sa=sa|0;ta=ta|0;var ua=0,va=0;ua=T-16|0;T=ua;q[a+4>>2]=sa;va=q[sa+4>>2];sa=q[sa>>2];o[ua+15|0]=0;bb(a+24|0,(va-sa>>2>>>0)/3|0,ua+15|0);sa=q[a+4>>2];va=q[sa+28>>2];sa=q[sa+24>>2];o[ua+14|0]=0;bb(a+36|0,va-sa>>2,ua+14|0);sa=q[ta+12>>2];q[a+16>>2]=q[ta+8>>2];q[a+20>>2]=sa;sa=q[ta+4>>2];q[a+8>>2]=q[ta>>2];q[a+12>>2]=sa;T=ua+16|0}function $i(a,sa){var ta=0,wa=0,xa=0;a:{if((a|0)!=(sa|0)){xa=a;ta=q[sa+4>>2];wa=0;b:{if(!ta){break b}c:{if(ta>>>0<=q[a+8>>2]<<5>>>0){wa=q[a>>2];break c}wa=q[a>>2];if(wa){An(wa);q[a+8>>2]=0;q[a>>2]=0;q[a+4>>2]=0;ta=q[sa+4>>2]}if((ta|0)<=-1){break a}ta=(ta+ -1>>>5)+1|0;wa=Mm(ta<<2);q[a+8>>2]=ta;q[a+4>>2]=0;q[a>>2]=wa;ta=q[sa+4>>2]}En(wa,q[sa>>2],(ta+ -1>>>3&536870908)+4|0);wa=q[sa+4>>2]}q[xa+4>>2]=wa}return}bn();F()}function aj(a){a=a|0;var sa=0;q[a>>2]=12336;sa=q[a+88>>2];if(sa){q[a+92>>2]=sa;An(sa)}sa=q[a+72>>2];if(sa){q[a+76>>2]=sa;An(sa)}sa=q[a+60>>2];if(sa){q[a- -64>>2]=sa;An(sa)}sa=q[a+48>>2];if(sa){q[a+52>>2]=sa;An(sa)}q[a>>2]=12572;sa=q[a+36>>2];if(sa){An(sa)}sa=q[a+24>>2];if(sa){An(sa)}return a|0}function bj(a){a=a|0;var ya=0;q[a>>2]=12124;q[a+8>>2]=12336;ya=q[a+96>>2];if(ya){q[a+100>>2]=ya;An(ya)}ya=q[a+80>>2];if(ya){q[a+84>>2]=ya;An(ya)}ya=q[a+68>>2];if(ya){q[a+72>>2]=ya;An(ya)}ya=q[a+56>>2];if(ya){q[a+60>>2]=ya;An(ya)}q[a+8>>2]=12572;ya=q[a+44>>2];if(ya){An(ya)}ya=q[a+32>>2];if(ya){An(ya)}return a|0}function cj(a){a=a|0;var za=0;q[a>>2]=12124;q[a+8>>2]=12336;za=q[a+96>>2];if(za){q[a+100>>2]=za;An(za)}za=q[a+80>>2];if(za){q[a+84>>2]=za;An(za)}za=q[a+68>>2];if(za){q[a+72>>2]=za;An(za)}za=q[a+56>>2];if(za){q[a+60>>2]=za;An(za)}q[a+8>>2]=12572;za=q[a+44>>2];if(za){An(za)}za=q[a+32>>2];if(za){An(za)}An(a)}function dj(a,Aa){a=a|0;Aa=Aa|0;var Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0;Ja=q[a+12>>2];Ba=q[a+108>>2];Ca=q[Ba+80>>2];o[Aa+84|0]=0;Fa=q[Aa+68>>2];Da=q[Aa+72>>2]-Fa>>2;a:{if(Ca>>>0>Da>>>0){md(Aa+68|0,Ca-Da|0,12324);Ba=q[a+108>>2];Ca=q[Ba+80>>2];break a}if(Ca>>>0>=Da>>>0){break a}q[Aa+72>>2]=Fa+(Ca<<2)}Ia=q[Ba+96>>2];Ba=q[Ba+100>>2]-Ia|0;Ka=(Ba|0)/12|0;if(!Ba){return 1}La=Aa+68|0;Aa=0;b:{while(1){c:{if((Aa|0)==1431655765){break c}Ba=q[Ja>>2]+(w(A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]-Oa>>2;c:{if(Aa>>>0>Ma>>>0){Ad(Na,Aa-Ma|0,Pa+12|0);break c}if(Aa>>>0>=Ma>>>0){break c}q[a+100>>2]=Oa+(Aa<<2)}Oa=a+8|0;d:{e:{Aa=q[a+116>>2];if(Aa){Na=q[Aa>>2];Ma=1;if((Na|0)==q[Aa+4>>2]){break d}Aa=0;while(1){if(!fj(Oa,q[(Aa<<2)+Na>>2])){break e}Ma=q[a+116>>2];Na=q[Ma>>2];Aa=Aa+1|0;if(Aa>>>0>2]-Na>>2>>>0){continue}break}Ma=1;break d}Aa=0;a=q[a+12>>2];a=(q[a+4>>2]-q[a>>2]>>2>>>0)/3|0;Ma=1;if((a|0)<=0){break d}while(1){if(!fj(Oa,w(Aa,3))){break e}Aa=Aa+1|0;if(Aa>>>0>>0){continue}break}Ma=1;break d}Ma=0}T=Pa+16|0;return Ma|0}ab(12024);F()}function fj(a,Ua){var Va=0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0;Ya=T-32|0;T=Ya;q[Ya+8>>2]=Ua;a:{if(q[a+92>>2]==q[a+88>>2]){break a}Xa=a+52|0;Va=q[Xa>>2];b:{if((Va|0)!=q[a+56>>2]){q[Va>>2]=Ua;q[Xa>>2]=Va+4;break b}zi(a+48|0,Ya+8|0)}q[a+84>>2]=0;Ua=-1;Xa=-1;Va=q[Ya+8>>2];c:{if((Va|0)==-1){break c}Wa=q[a+4>>2];Za=Va+1|0;Za=(Za>>>0)%3|0?Za:Va+ -2|0;if((Za|0)!=-1){Ua=q[q[Wa>>2]+(Za<<2)>>2]}Va=Va+((Va>>>0)%3|0?-1:2)|0;if((Va|0)==-1){break c}Xa=q[q[Wa>>2]+(Va<<2)>>2]}Va=q[a+36>>2];Wa=Va+(Ua>>>3&536870908)|0;Za=q[Wa>>2];$a=1<<(Ua&31);if(!(Za&$a)){q[Wa>>2]=Za|$a;Va=-1;Wa=q[Ya+8>>2];if((Wa|0)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&536870908)>>2]>>>(Wa&31)&1){break t}Wa=0;ab=Xa;_a=q[q[_a>>2]+(Ua<<2)>>2];if(!(q[q[$a>>2]+(_a>>>3&536870908)>>2]>>>(_a&31)&1)){_a=q[cb>>2]+(_a<<2)|0;Wa=q[_a>>2];q[_a>>2]=Wa+1;Wa=(Wa|0)<1?2:1}if((Wa|0)<=q[a+84>>2]?ab:0){break r}q[Ya+24>>2]=Ua;bb=w(Wa,12)+a|0;ab=bb+52|0;_a=q[ab>>2];u:{if((_a|0)!=q[bb+56>>2]){q[_a>>2]=Ua;q[ab>>2]=_a+4;break u}zi(bb+48|0,Ya+24|0)}if(q[a+84>>2]<=(Wa|0)){break t}q[a+84>>2]=Wa}if(Xa){break m}}Ua=-1;Xa=0;Ua=(Va|0)!=-1?q[q[q[db>>2]>>2]+(Va<<2)>>2]:Ua;if(!(q[q[$a>>2]+(Ua>>>3&536870908)>>2]>>>(Ua&31)&1)){Xa=q[cb>>2]+(Ua<<2)|0;Ua=q[Xa>>2];q[Xa>>2]=Ua+1;Xa=(Ua|0)<1?2:1}if((Xa|0)>q[a+84>>2]){break q}Ua=Va}q[Ya+8>>2]=Ua;Xa=q[Za>>2];continue}break}q[Ya+24>>2]=Va;Wa=w(Xa,12)+a|0;_a=Wa+52|0;Ua=q[_a>>2];v:{if((Ua|0)!=q[Wa+56>>2]){q[Ua>>2]=Va;q[_a>>2]=Ua+4;break v}zi(Wa+48|0,Ya+24|0)}Va=q[a+84>>2];if((Va|0)<=(Xa|0)){break l}q[a+84>>2]=Xa;Va=Xa;break l}Va=q[a+84>>2]}if((Va|0)<3){continue}break}}q[Ya+8>>2]=-1}T=Ya+32|0;return 1}function gj(a){a=a|0;var Ua=0;q[a>>2]=12336;Ua=q[a+88>>2];if(Ua){q[a+92>>2]=Ua;An(Ua)}Ua=q[a+72>>2];if(Ua){q[a+76>>2]=Ua;An(Ua)}Ua=q[a+60>>2];if(Ua){q[a- -64>>2]=Ua;An(Ua)}Ua=q[a+48>>2];if(Ua){q[a+52>>2]=Ua;An(Ua)}q[a>>2]=12572;Ua=q[a+36>>2];if(Ua){An(Ua)}Ua=q[a+24>>2];if(Ua){An(Ua)}An(a)}function hj(a){a=a|0;var gb=0;q[a>>2]=12572;gb=q[a+36>>2];if(gb){An(gb)}gb=q[a+24>>2];if(gb){An(gb)}return a|0}function ij(a){a=a|0;var hb=0;q[a>>2]=12572;hb=q[a+36>>2];if(hb){An(hb)}hb=q[a+24>>2];if(hb){An(hb)}An(a)}function jj(a){a=a|0;var ib=0;q[a>>2]=12756;ib=q[a+48>>2];if(ib){q[a+52>>2]=ib;An(ib)}q[a>>2]=12572;ib=q[a+36>>2];if(ib){An(ib)}ib=q[a+24>>2];if(ib){An(ib)}return a|0}function kj(a){a=a|0;var jb=0,kb=0;q[a>>2]=12592;kb=a+8|0;q[kb>>2]=12756;jb=q[a+56>>2];if(jb){q[a+60>>2]=jb;An(jb)}q[kb>>2]=12572;jb=q[a+44>>2];if(jb){An(jb)}jb=q[a+32>>2];if(jb){An(jb)}return a|0}function lj(a){a=a|0;var lb=0,mb=0;q[a>>2]=12592;mb=a+8|0;q[mb>>2]=12756;lb=q[a+56>>2];if(lb){q[a+60>>2]=lb;An(lb)}q[mb>>2]=12572;lb=q[a+44>>2];if(lb){An(lb)}lb=q[a+32>>2];if(lb){An(lb)}An(a)}function mj(a,nb){a=a|0;nb=nb|0;var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0;wb=q[a+12>>2];ob=q[a+68>>2];pb=q[ob+80>>2];o[nb+84|0]=0;sb=q[nb+68>>2];qb=q[nb+72>>2]-sb>>2;a:{if(pb>>>0>qb>>>0){md(nb+68|0,pb-qb|0,12324);ob=q[a+68>>2];pb=q[ob+80>>2];break a}if(pb>>>0>=qb>>>0){break a}q[nb+72>>2]=sb+(pb<<2)}vb=q[ob+96>>2];ob=q[ob+100>>2]-vb|0;xb=(ob|0)/12|0;if(!ob){return 1}yb=nb+68|0;nb=0;b:{while(1){c:{if((nb|0)==1431655765){break c}ob=q[wb>>2]+(w(nb,3)<<2)|0;sb=q[ob>>2];if((sb|0)==-1){break c}qb=w(nb,12)+vb|0;tb=q[qb>>2];if(tb>>>0>=pb>>>0){break c}rb=sb<<2;sb=q[q[a+72>>2]+12>>2];rb=q[rb+sb>>2];if(rb>>>0>=pb>>>0){break c}ub=tb<<2;tb=q[yb>>2];q[ub+tb>>2]=rb;rb=q[ob+4>>2];if((rb|0)==-1){break c}ub=q[qb+4>>2];if(ub>>>0>=pb>>>0){break c}rb=q[sb+(rb<<2)>>2];if(rb>>>0>=pb>>>0){break c}q[tb+(ub<<2)>>2]=rb;ob=q[ob+8>>2];if((ob|0)==-1){break c}qb=q[qb+8>>2];if(qb>>>0>=pb>>>0){break c}ob=q[sb+(ob<<2)>>2];if(ob>>>0>=pb>>>0){break c}q[tb+(qb<<2)>>2]=ob;ob=1;nb=nb+1|0;if(nb>>>0>>0){continue}break b}break}ob=0}return ob|0}function nj(a){a=a|0;var nb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0;Bb=q[a+4>>2];nb=q[Bb>>2];a:{zb=q[a+12>>2];Ab=q[zb+28>>2]-q[zb+24>>2]|0;zb=Ab>>2;b:{if(q[Bb+8>>2]-nb>>2>>>0>=zb>>>0){break b}if(zb>>>0>=1073741824){break a}Eb=Bb+4|0;Cb=q[Eb>>2];Db=zb<<2;zb=Mm(Ab);Db=Db+zb|0;Ab=Cb-nb|0;Cb=Ab+zb|0;if((Ab|0)>=1){Cn(zb,nb,Ab)}q[Bb>>2]=zb;q[Bb+8>>2]=Db;q[Eb>>2]=Cb;if(!nb){break b}An(nb)}zb=a+8|0;c:{d:{nb=q[a+76>>2];if(nb){Bb=q[nb>>2];Ab=1;if((Bb|0)==q[nb+4>>2]){break c}nb=0;while(1){if(!oj(zb,q[(nb<<2)+Bb>>2])){break d}Ab=q[a+76>>2];Bb=q[Ab>>2];nb=nb+1|0;if(nb>>>0>2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Jb=0;break a}zi(Pb,Kb+24|0);break h}q[Kb+24>>2]=-1}q[Nb>>2]=q[Nb>>2]+ -4}Jb=1;Fb=q[Nb>>2];if((Fb|0)!=q[a+48>>2]){continue}break}}T=Kb+32|0;return Jb}function pj(a){a=a|0;var Fb=0;q[a>>2]=12756;Fb=q[a+48>>2];if(Fb){q[a+52>>2]=Fb;An(Fb)}q[a>>2]=12572;Fb=q[a+36>>2];if(Fb){An(Fb)}Fb=q[a+24>>2];if(Fb){An(Fb)}An(a)}function qj(a){a=a|0;var Vb=0,Wb=0;q[a>>2]=12884;Wb=a+8|0;q[Wb>>2]=11760;Vb=q[a+56>>2];if(Vb){q[a+60>>2]=Vb;An(Vb)}q[Wb>>2]=12012;Vb=q[a+44>>2];if(Vb){An(Vb)}Vb=q[a+32>>2];if(Vb){An(Vb)}return a|0}function rj(a){a=a|0;var Xb=0,Yb=0;q[a>>2]=12884;Yb=a+8|0;q[Yb>>2]=11760;Xb=q[a+56>>2];if(Xb){q[a+60>>2]=Xb;An(Xb)}q[Yb>>2]=12012;Xb=q[a+44>>2];if(Xb){An(Xb)}Xb=q[a+32>>2];if(Xb){An(Xb)}An(a)}function sj(a,Zb){a=a|0;Zb=Zb|0;var _b=0,$b=0,ac=0,bc=0,cc=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0;dc=q[a+12>>2];_b=q[a+68>>2];$b=q[_b+80>>2];o[Zb+84|0]=0;cc=q[Zb+68>>2];ac=q[Zb+72>>2]-cc>>2;a:{if($b>>>0>ac>>>0){md(Zb+68|0,$b-ac|0,12324);_b=q[a+68>>2];$b=q[_b+80>>2];break a}if($b>>>0>=ac>>>0){break a}q[Zb+72>>2]=cc+($b<<2)}fc=q[_b+96>>2];_b=q[_b+100>>2]-fc|0;gc=(_b|0)/12|0;if(!_b){return 1}hc=q[dc+28>>2];ic=Zb+68|0;Zb=0;b:{while(1){c:{_b=(w(Zb,3)<<2)+hc|0;dc=q[_b>>2];if((dc|0)==-1){break c}ac=w(Zb,12)+fc|0;cc=q[ac>>2];if(cc>>>0>=$b>>>0){break c}bc=dc<<2;dc=q[q[a+72>>2]+12>>2];bc=q[bc+dc>>2];if(bc>>>0>=$b>>>0){break c}ec=cc<<2;cc=q[ic>>2];q[ec+cc>>2]=bc;bc=q[_b+4>>2];if((bc|0)==-1){break c}ec=q[ac+4>>2];if(ec>>>0>=$b>>>0){break c}bc=q[dc+(bc<<2)>>2];if(bc>>>0>=$b>>>0){break c}q[cc+(ec<<2)>>2]=bc;_b=q[_b+8>>2];if((_b|0)==-1){break c}ac=q[ac+8>>2];if(ac>>>0>=$b>>>0){break c}_b=q[dc+(_b<<2)>>2];if(_b>>>0>=$b>>>0){break c}q[cc+(ac<<2)>>2]=_b;_b=1;Zb=Zb+1|0;if(Zb>>>0>>0){continue}break b}break}_b=0}return _b|0}function tj(a){a=a|0;var Zb=0,jc=0,kc=0,lc=0,mc=0,nc=0,oc=0;lc=q[a+4>>2];Zb=q[lc>>2];a:{jc=q[a+12>>2];kc=q[jc+56>>2]-q[jc+52>>2]|0;jc=kc>>2;b:{if(q[lc+8>>2]-Zb>>2>>>0>=jc>>>0){break b}if(jc>>>0>=1073741824){break a}oc=lc+4|0;mc=q[oc>>2];nc=jc<<2;jc=Mm(kc);nc=nc+jc|0;kc=mc-Zb|0;mc=kc+jc|0;if((kc|0)>=1){Cn(jc,Zb,kc)}q[lc>>2]=jc;q[lc+8>>2]=nc;q[oc>>2]=mc;if(!Zb){break b}An(Zb)}jc=a+8|0;c:{d:{Zb=q[a+76>>2];if(Zb){lc=q[Zb>>2];kc=1;if((lc|0)==q[Zb+4>>2]){break c}Zb=0;while(1){if(!uj(jc,q[(Zb<<2)+lc>>2])){break d}kc=q[a+76>>2];lc=q[kc>>2];Zb=Zb+1|0;if(Zb>>>0>2]-lc>>2>>>0){continue}break}return 1}Zb=0;a=q[q[a+12>>2]+64>>2];a=(q[a+4>>2]-q[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!uj(jc,w(Zb,3))){break d}Zb=Zb+1|0;if(Zb>>>0>>0){continue}break}return 1}kc=0}return kc|0}ab(12024);F()}function uj(a,pc){var qc=0,rc=0,sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0;uc=T-32|0;T=uc;q[uc+8>>2]=pc;a:{if((pc|0)==-1){qc=1;break a}qc=1;tc=(pc>>>0)/3|0;if(q[q[a+24>>2]+(tc>>>3&268435452)>>2]>>>(tc&31)&1){break a}tc=a+52|0;qc=q[a+48>>2];q[tc>>2]=qc;zc=a+48|0;b:{if((qc|0)!=q[a+56>>2]){q[qc>>2]=pc;q[tc>>2]=qc+4;break b}zi(zc,uc+8|0)}rc=-1;qc=q[a+4>>2];pc=q[uc+8>>2];c:{if((pc|0)==-1){tc=q[qc+28>>2];qc=q[tc+ -4>>2];break c}tc=q[qc+28>>2];qc=pc+1|0;qc=q[tc+(((qc>>>0)%3|0?qc:pc+ -2|0)<<2)>>2];if((pc>>>0)%3){rc=pc+ -1|0;break c}rc=pc+2|0}if((qc|0)==-1){qc=0;break a}tc=q[(rc<<2)+tc>>2];if((tc|0)==-1){qc=0;break a}pc=q[a+36>>2];sc=pc+(qc>>>3&536870908)|0;rc=q[sc>>2];vc=1<<(qc&31);if(!(rc&vc)){q[sc>>2]=rc|vc;rc=-1;pc=q[uc+8>>2];if((pc|0)!=-1){sc=pc+1|0;rc=(sc>>>0)%3|0?sc:pc+ -2|0}q[uc+16>>2]=rc;pc=q[a+20>>2];sc=(rc>>>0)/3|0;rc=q[(q[q[a+16>>2]+96>>2]+w(sc,12)|0)+(rc-w(sc,3)<<2)>>2];q[uc+24>>2]=rc;sc=q[pc+4>>2];vc=sc+4|0;pc=q[vc>>2];d:{if((pc|0)!=q[sc+8>>2]){q[pc>>2]=rc;q[vc>>2]=pc+4;break d}zi(sc,uc+24|0)}sc=a+12|0;rc=q[sc>>2];vc=rc+4|0;pc=q[vc>>2];e:{if((pc|0)!=q[rc+8>>2]){q[pc>>2]=q[uc+16>>2];q[vc>>2]=pc+4;break e}zi(rc,uc+16|0);rc=q[sc>>2]}q[q[rc+12>>2]+(qc<<2)>>2]=q[rc+24>>2];q[rc+24>>2]=q[rc+24>>2]+1;pc=q[a+36>>2]}pc=(tc>>>3&536870908)+pc|0;qc=q[pc>>2];sc=1<<(tc&31);if(!(qc&sc)){q[pc>>2]=qc|sc;pc=uc;rc=pc;sc=q[pc+8>>2];qc=-1;f:{if((sc|0)==-1){break f}qc=sc+ -1|0;if((sc>>>0)%3){break f}qc=sc+2|0}q[rc+16>>2]=qc;pc=q[a+20>>2];sc=(qc>>>0)/3|0;sc=q[(q[q[a+16>>2]+96>>2]+w(sc,12)|0)+(qc-w(sc,3)<<2)>>2];q[uc+24>>2]=sc;qc=q[pc+4>>2];rc=qc+4|0;pc=q[rc>>2];g:{if((pc|0)!=q[qc+8>>2]){q[pc>>2]=sc;q[rc>>2]=pc+4;break g}zi(qc,uc+24|0)}sc=a+12|0;qc=q[sc>>2];rc=qc+4|0;pc=q[rc>>2];h:{if((pc|0)!=q[qc+8>>2]){q[pc>>2]=q[uc+16>>2];q[rc>>2]=pc+4;break h}zi(qc,uc+16|0);qc=q[sc>>2]}q[q[qc+12>>2]+(tc<<2)>>2]=q[qc+24>>2];q[qc+24>>2]=q[qc+24>>2]+1}vc=a+52|0;pc=q[vc>>2];if((pc|0)==q[a+48>>2]){qc=1;break a}xc=a+24|0;yc=a+4|0;Bc=a+36|0;Cc=a+16|0;Dc=a+20|0;Ec=a+56|0;while(1){tc=pc+ -4|0;pc=q[tc>>2];q[uc+8>>2]=pc;qc=(pc>>>0)/3|0;i:{j:{k:{if((pc|0)==-1){break k}pc=q[xc>>2]+(qc>>>3&268435452)|0;sc=q[pc>>2];qc=1<<(qc&31);if(sc&qc){break k}q[pc>>2]=qc|sc;rc=q[yc>>2];pc=q[uc+8>>2];qc=q[q[rc+28>>2]+(pc<<2)>>2];if((qc|0)!=-1){break j}qc=0;break a}q[vc>>2]=tc;break i}l:{m:{n:{while(1){o:{p:{tc=q[Bc>>2]+(qc>>>3&536870908)|0;sc=q[tc>>2];wc=1<<(qc&31);if(sc&wc){break p}Ac=qc<<2;qc=q[Ac+q[rc+40>>2]>>2];pc=1;q:{if((qc|0)==-1){break q}pc=qc+1|0;pc=(pc>>>0)%3|0?pc:qc+ -2|0;r:{if((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1){break r}qc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2];if((qc|0)==-1){break r}rc=qc+1|0;pc=0;if((((rc>>>0)%3|0?rc:qc+ -2|0)|0)!=-1){break q}}pc=1}qc=pc;q[tc>>2]=sc|wc;pc=q[uc+8>>2];q[uc+16>>2]=pc;tc=q[Dc>>2];sc=(pc>>>0)/3|0;sc=q[(q[q[Cc>>2]+96>>2]+w(sc,12)|0)+(pc-w(sc,3)<<2)>>2];q[uc+24>>2]=sc;tc=q[tc+4>>2];rc=tc+4|0;pc=q[rc>>2];s:{if((pc|0)!=q[tc+8>>2]){q[pc>>2]=sc;q[rc>>2]=pc+4;break s}zi(tc,uc+24|0)}sc=a+12|0;pc=q[sc>>2];rc=pc+4|0;tc=q[rc>>2];t:{if((tc|0)!=q[pc+8>>2]){q[tc>>2]=q[uc+16>>2];q[rc>>2]=tc+4;break t}zi(pc,uc+16|0);pc=q[sc>>2]}q[q[pc+12>>2]+Ac>>2]=q[pc+24>>2];q[pc+24>>2]=q[pc+24>>2]+1;rc=q[yc>>2];pc=q[uc+8>>2];if(qc){break p}qc=-1;u:{if((pc|0)==-1){break u}tc=pc+1|0;pc=(tc>>>0)%3|0?tc:pc+ -2|0;if((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1){break u}qc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2]}q[uc+8>>2]=qc;pc=(qc>>>0)/3|0;break o}if((pc|0)==-1){break m}tc=-1;sc=uc;wc=pc+1|0;wc=(wc>>>0)%3|0?wc:pc+ -2|0;qc=-1;v:{if((wc|0)==-1){break v}qc=-1;if(q[q[rc>>2]+(wc>>>3&536870908)>>2]>>>(wc&31)&1){break v}qc=q[q[q[rc+64>>2]+12>>2]+(wc<<2)>>2]}q[sc+24>>2]=qc;pc=((pc>>>0)%3|0?-1:2)+pc|0;if(!((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1)){tc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2]}sc=(tc>>>0)/3|0;pc=(qc>>>0)/3|0;rc=(qc|0)==-1;w:{if(rc){pc=-1;rc=1;break w}rc=rc?-1:pc;rc=q[q[xc>>2]+(rc>>>3&536870908)>>2]>>>(rc&31)&1}x:{if((tc|0)!=-1){wc=(tc|0)==-1?-1:sc;wc=q[q[xc>>2]+(wc>>>3&536870908)>>2]&1<<(wc&31);if(rc){qc=tc;pc=sc;if(!wc){break x}break l}if(wc){break x}pc=q[vc>>2];q[pc+ -4>>2]=tc;if((pc|0)==q[Ec>>2]){break n}q[pc>>2]=q[uc+24>>2];q[vc>>2]=pc+4;break i}if(rc){break l}}q[uc+8>>2]=qc}qc=q[xc>>2]+(pc>>>3&536870908)|0;q[qc>>2]=q[qc>>2]|1<<(pc&31);rc=q[yc>>2];pc=q[uc+8>>2];qc=q[q[rc+28>>2]+(pc<<2)>>2];if((qc|0)!=-1){continue}break}qc=0;break a}zi(zc,uc+24|0);break i}q[uc+24>>2]=-1}q[vc>>2]=q[vc>>2]+ -4}qc=1;pc=q[vc>>2];if((pc|0)!=q[a+48>>2]){continue}break}}T=uc+32|0;return qc}function vj(a,pc){var Fc=0,Gc=0,Hc=0;q[a>>2]=q[pc>>2];q[a+4>>2]=q[pc+4>>2];q[a+8>>2]=q[pc+8>>2];Fc=pc+12|0;q[a+12>>2]=q[Fc>>2];q[Fc>>2]=0;q[pc+4>>2]=0;q[pc+8>>2]=0;Fc=pc+16|0;q[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|0,Zc+8|0);break f}Kc=q[Zc+12>>2];q[Xc>>2]=q[Zc+8>>2];q[Xc+4>>2]=Kc;q[Xc+8>>2]=q[cd>>2];q[Yc>>2]=q[Yc>>2]+12}gd=gd+1|0;if((hd|0)==(gd|0)){break c}Yc=q[ld>>2];Kc=Yc;bd=q[Kc+16>>2];Xc=q[Kc+20>>2];q[cd>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;$c=q[Kc+12>>2];ad=$c;ed=q[Kc+8>>2];fd=ed;Kc=Xc;_c=bd+2|0;if(_c>>>0<2){Kc=Kc+1|0}dd=_c;_c=Kc;if(($c|0)>(Kc|0)?1:($c|0)>=(Kc|0)?fd>>>0

>>0?0:1:0){continue}break}break d}g:{if(t[q[a+44>>2]+80>>2]>2097151){break g}_c=s[a+36>>1];if((_c<<24|_c<<8&16711680)>>>16>>>0<514){break g}if(!hd){break c}_c=Zc+16|0;q[_c>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;if(!Aj(1,Zc+4|0,Yc)){break d}Kc=a+32|0;$c=a+44|0;while(1){q[Zc+8>>2]=q[Zc+4>>2];if(!Aj(1,Zc+4|0,q[Kc>>2])){break d}q[Zc+12>>2]=q[Zc+4>>2];if(!Aj(1,Zc+4|0,q[Kc>>2])){break d}q[Zc+16>>2]=q[Zc+4>>2];Yc=q[$c>>2];ad=Yc+100|0;Xc=q[ad>>2];h:{if((Xc|0)==q[Yc+104>>2]){Cj(Yc+96|0,Zc+8|0);break h}Yc=q[Zc+12>>2];q[Xc>>2]=q[Zc+8>>2];q[Xc+4>>2]=Yc;q[Xc+8>>2]=q[_c>>2];q[ad>>2]=q[ad>>2]+12}cd=cd+1|0;if((cd|0)==(hd|0)){break c}Xc=q[Kc>>2];q[_c>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;if(Aj(1,Zc+4|0,Xc)){continue}break}break d}if(!hd){break c}gd=Zc+16|0;q[gd>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2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8>>2]=0;q[Zc+12>>2]=0;$c=q[Kc+12>>2];ad=$c;ed=q[Kc+8>>2];fd=ed;Kc=Xc;_c=bd+4|0;if(_c>>>0<4){Kc=Kc+1|0}dd=_c;_c=Kc;if(($c|0)>(Kc|0)?1:($c|0)>=(Kc|0)?fd>>>0
>>0?0:1:0){continue}break}}dd=0;break a}q[q[a+4>>2]+80>>2]=id;dd=1}T=Zc+32|0;return dd|0}function Aj(a,md,nd){var od=0,pd=0,qd=0,rd=0;a:{if(a>>>0>5){break a}qd=q[nd+16>>2];od=q[nd+12>>2];pd=q[nd+20>>2];if((od|0)<(pd|0)?1:(od|0)<=(pd|0)?t[nd+8>>2]>qd>>>0?0:1:0){break a}od=r[qd+q[nd>>2]|0];qd=qd+1|0;if(qd>>>0<1){pd=pd+1|0}q[nd+16>>2]=qd;q[nd+20>>2]=pd;pd=md;if(od&128){if(!Aj(a+1|0,md,nd)){break a}a=q[md>>2]<<7;q[md>>2]=a;od=a|od&127}q[pd>>2]=od;rd=1}return rd}function Bj(a,md){var nd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0,yd=0,zd=0,Ad=0;nd=T-32|0;T=nd;q[nd+24>>2]=0;q[nd+16>>2]=0;q[nd+20>>2]=0;a:{ud=w(md,3);if(ud){if(ud>>>0>=1073741824){break a}sd=w(md,12);vd=Mm(sd);q[nd+16>>2]=vd;q[nd+24>>2]=(ud<<2)+vd;zd=nd,Ad=Dn(vd,0,sd)+sd|0,q[zd+20>>2]=Ad}b:{if(!qh(ud,1,q[a+32>>2],vd)){break b}td=1;if(!md){break b}yd=a+44|0;vd=0;while(1){ud=nd+8|0;q[ud>>2]=0;q[nd>>2]=0;q[nd+4>>2]=0;a=q[nd+16>>2]+(vd<<2)|0;sd=q[a>>2];td=sd>>>1;sd=(sd&1?0-td|0:td)+wd|0;q[nd>>2]=sd;td=q[a+4>>2];wd=td>>>1;sd=sd+(td&1?0-wd|0:wd)|0;q[nd+4>>2]=sd;a=q[a+8>>2];td=a>>>1;wd=sd+(a&1?0-td|0:td)|0;q[ud>>2]=wd;sd=q[yd>>2];td=sd+100|0;a=q[td>>2];c:{if((a|0)!=q[sd+104>>2]){sd=q[nd+4>>2];q[a>>2]=q[nd>>2];q[a+4>>2]=sd;q[a+8>>2]=q[ud>>2];q[td>>2]=q[td>>2]+12;break c}Cj(sd+96|0,nd)}vd=vd+3|0;td=1;xd=xd+1|0;if((xd|0)!=(md|0)){continue}break}}a=q[nd+16>>2];if(a){q[nd+20>>2]=a;An(a)}T=nd+32|0;return td}bn();F()}function Cj(a,md){var Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;a:{Ed=q[a>>2];Fd=q[a+4>>2]-Ed|0;Bd=(Fd|0)/12|0;Cd=Bd+1|0;if(Cd>>>0<357913942){Gd=w(Bd,12);Dd=(q[a+8>>2]-Ed|0)/12|0;Bd=Dd<<1;Dd=Dd>>>0<178956970?Bd>>>0>>0?Cd:Bd:357913941;Bd=0;b:{if(!Dd){break b}if(Dd>>>0>=357913942){break a}Bd=Mm(w(Dd,12))}Cd=Gd+Bd|0;Gd=q[md+4>>2];q[Cd>>2]=q[md>>2];q[Cd+4>>2]=Gd;q[Cd+8>>2]=q[md+8>>2];md=Cd+w((Fd|0)/-12|0,12)|0;Bd=Bd+w(Dd,12)|0;Cd=Cd+12|0;if((Fd|0)>=1){Cn(md,Ed,Fd)}q[a>>2]=md;q[a+8>>2]=Bd;q[a+4>>2]=Cd;if(Ed){An(Ed)}return}bn();F()}ab(13160);F()}function Dj(a,md){a=a|0;md=md|0;var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0;Kd=T-16|0;T=Kd;Ld=Mm(64);Hd=Mm(12);q[Hd+8>>2]=q[q[a+4>>2]+80>>2];q[Hd>>2]=13236;q[Hd+4>>2]=0;q[Kd+8>>2]=Hd;Ge(Ld,Kd+8|0);a:{if((md|0)>=0){Hd=q[a+12>>2];Md=a+8|0;Nd=q[Md>>2];Id=Hd-Nd>>2;b:{if((Id|0)>(md|0)){break b}Jd=md+1|0;if(Id>>>0<=md>>>0){ji(Md,Jd-Id|0);break b}if(Jd>>>0>=Id>>>0){break b}Jd=Nd+(Jd<<2)|0;if((Jd|0)!=(Hd|0)){while(1){Hd=Hd+ -4|0;Id=q[Hd>>2];q[Hd>>2]=0;if(Id){n[q[q[Id>>2]+4>>2]](Id)}if((Hd|0)!=(Jd|0)){continue}break}}q[a+12>>2]=Jd}md=q[Md>>2]+(md<<2)|0;a=q[md>>2];q[md>>2]=Ld;Id=1;if(!a){break a}n[q[q[a>>2]+4>>2]](a);break a}n[q[q[Ld>>2]+4>>2]](Ld)}a=q[Kd+8>>2];q[Kd+8>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}T=Kd+16|0;return Id|0}function Ej(a){a=a|0;var md=0,Od=0,Pd=0,Qd=0,Rd=0;q[a>>2]=13300;md=q[a+20>>2];if(md){q[a+24>>2]=md;An(md)}Pd=q[a+8>>2];if(Pd){md=Pd;Rd=a+12|0;Od=q[Rd>>2];Qd=md;a:{if((md|0)==(Od|0)){break a}while(1){Od=Od+ -4|0;md=q[Od>>2];q[Od>>2]=0;if(md){n[q[q[md>>2]+4>>2]](md)}if((Od|0)!=(Pd|0)){continue}break}Qd=q[a+8>>2]}md=Qd;q[Rd>>2]=Pd;An(md)}An(a)}function Fj(a,Sd){a=a|0;Sd=Sd|0;o[Sd+84|0]=1;q[Sd+72>>2]=q[Sd+68>>2];return 1}function Gj(a){a=a|0;var Sd=0,Td=0,Ud=0,Vd=0;a:{Sd=q[a+8>>2];b:{if((Sd|0)<0){break b}Td=q[a+4>>2];Vd=q[Td>>2];Ud=q[Td+4>>2]-Vd>>2;c:{if(Sd>>>0>Ud>>>0){Hj(Td,Sd-Ud|0);Sd=q[a+8>>2];break c}if(Sd>>>0>=Ud>>>0){break c}q[Td+4>>2]=Vd+(Sd<<2)}Vd=1;if((Sd|0)<1){break b}a=q[a+4>>2];Td=q[a>>2];Ud=q[a+4>>2]-Td>>2;a=0;while(1){if((a|0)==(Ud|0)){break a}q[Td+(a<<2)>>2]=a;a=a+1|0;if((a|0)<(Sd|0)){continue}break}}return Vd|0}cn();F()}function Hj(a,Wd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Yd=q[a+8>>2];Zd=a+4|0;Xd=q[Zd>>2];if(Yd-Xd>>2>>>0>=Wd>>>0){a=Wd<<2;ce=Zd,de=Dn(Xd,0,a)+a|0,q[ce>>2]=de;return}a:{Zd=q[a>>2];$d=Xd-Zd|0;Xd=$d>>2;_d=Xd+Wd|0;if(_d>>>0<1073741824){be=Xd<<2;Yd=Yd-Zd|0;Xd=Yd>>1;Yd=Yd>>2>>>0<536870911?Xd>>>0<_d>>>0?_d:Xd:1073741823;Xd=0;b:{if(!Yd){break b}if(Yd>>>0>=1073741824){break a}ae=Mm(Yd<<2);Xd=ae}Dn(be+Xd|0,0,Wd<<2);Wd=Xd+(_d<<2)|0;_d=Xd+(Yd<<2)|0;if(($d|0)>=1){Cn(ae,Zd,$d)}q[a>>2]=Xd;q[a+8>>2]=_d;q[a+4>>2]=Wd;if(Zd){An(Zd)}return}bn();F()}ab(13160);F()}function Ij(a){q[a+40>>2]=0;q[a>>2]=13300;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;q[a+32>>2]=0;p[a+36>>1]=0}function Jj(a,Wd,ee){var fe=0,ge=0,he=0,ie=0,je=0,ke=0;ge=T-16|0;T=ge;ie=q[Wd+12>>2];fe=q[Wd+20>>2];he=q[Wd+16>>2];je=he+5|0;if(je>>>0<5){fe=fe+1|0}a:{if((ie|0)<(fe|0)?1:(ie|0)<=(fe|0)?t[Wd+8>>2]>=je>>>0?0:1:0){Wd=Mm(32);q[ge>>2]=Wd;q[ge+4>>2]=29;q[ge+8>>2]=-2147483616;o[Wd+29|0]=0;ee=r[13369]|r[13370]<<8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=0;o[Wd+16|0]=r[13396];ee=r[13392]|r[13393]<<8|(r[13394]<<16|r[13395]<<24);fe=r[13388]|r[13389]<<8|(r[13390]<<16|r[13391]<<24);o[Wd+8|0]=fe;o[Wd+9|0]=fe>>>8;o[Wd+10|0]=fe>>>16;o[Wd+11|0]=fe>>>24;o[Wd+12|0]=ee;o[Wd+13|0]=ee>>>8;o[Wd+14|0]=ee>>>16;o[Wd+15|0]=ee>>>24;ee=r[13384]|r[13385]<<8|(r[13386]<<16|r[13387]<<24);fe=r[13380]|r[13381]<<8|(r[13382]<<16|r[13383]<<24);o[Wd|0]=fe;o[Wd+1|0]=fe>>>8;o[Wd+2|0]=fe>>>16;o[Wd+3|0]=fe>>>24;o[Wd+4|0]=ee;o[Wd+5|0]=ee>>>8;o[Wd+6|0]=ee>>>16;o[Wd+7|0]=ee>>>24;q[a>>2]=-1;Rm(a+4|0,ge);if(o[ge+11|0]>-1){break a}An(q[ge>>2]);break a}fe=q[Wd+12>>2];if((fe|0)<(he|0)?1:(fe|0)<=(he|0)?t[Wd+8>>2]>je>>>0?0:1:0){Wd=Mm(32);q[ge>>2]=Wd;q[ge+4>>2]=29;q[ge+8>>2]=-2147483616;o[Wd+29|0]=0;ee=r[13369]|r[13370]<<8|(r[13371]<<16|r[13372]<<24);fe=r[13365]|r[13366]<<8|(r[13367]<<16|r[13368]<<24);o[Wd+21|0]=fe;o[Wd+22|0]=fe>>>8;o[Wd+23|0]=fe>>>16;o[Wd+24|0]=fe>>>24;o[Wd+25|0]=ee;o[Wd+26|0]=ee>>>8;o[Wd+27|0]=ee>>>16;o[Wd+28|0]=ee>>>24;ee=q[3341];fe=q[3340];o[Wd+16|0]=fe;o[Wd+17|0]=fe>>>8;o[Wd+18|0]=fe>>>16;o[Wd+19|0]=fe>>>24;o[Wd+20|0]=ee;o[Wd+21|0]=ee>>>8;o[Wd+22|0]=ee>>>16;o[Wd+23|0]=ee>>>24;ee=q[3339];fe=q[3338];o[Wd+8|0]=fe;o[Wd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[Wd+4|0]=ee;o[Wd+5|0]=ee>>>8;o[Wd+6|0]=ee>>>16;o[Wd+7|0]=ee>>>24;q[a>>2]=-2;Rm(a+4|0,ge);if(o[ge+11|0]>-1){break a}An(q[ge>>2]);break a}he=ee;ee=je+q[Wd>>2]|0;p[he+10>>1]=r[ee|0]|r[ee+1|0]<<8;ee=Wd;he=Wd;fe=q[Wd+20>>2];Wd=q[Wd+16>>2]+2|0;if(Wd>>>0<2){fe=fe+1|0}q[he+16>>2]=Wd;q[ee+20>>2]=fe;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0}T=ge+16|0}function Kj(a,Wd){var ee=0,le=0,me=0,ne=0;le=T-48|0;T=le;ee=Mm(36);me=ee+4|0;q[me>>2]=0;q[me+4>>2]=0;ne=ee+16|0;q[ne>>2]=0;q[ne+4>>2]=0;q[ee>>2]=me;q[ee+32>>2]=0;q[ee+24>>2]=0;q[ee+28>>2]=0;q[ee+12>>2]=ne;q[le+40>>2]=ee;ee=le+32|0;q[ee>>2]=0;a:{if(!Ok(ee,q[Wd+32>>2],q[le+40>>2])){q[le+24>>2]=0;q[le+16>>2]=0;q[le+20>>2]=0;Wd=Mm(32);q[le+16>>2]=Wd;q[le+20>>2]=26;q[le+24>>2]=-2147483616;o[Wd+26|0]=0;ee=r[13422]|r[13423]<<8;o[Wd+24|0]=ee;o[Wd+25|0]=ee>>>8;ee=r[13418]|r[13419]<<8|(r[13420]<<16|r[13421]<<24);me=r[13414]|r[13415]<<8|(r[13416]<<16|r[13417]<<24);o[Wd+16|0]=me;o[Wd+17|0]=me>>>8;o[Wd+18|0]=me>>>16;o[Wd+19|0]=me>>>24;o[Wd+20|0]=ee;o[Wd+21|0]=ee>>>8;o[Wd+22|0]=ee>>>16;o[Wd+23|0]=ee>>>24;ee=r[13410]|r[13411]<<8|(r[13412]<<16|r[13413]<<24);me=r[13406]|r[13407]<<8|(r[13408]<<16|r[13409]<<24);o[Wd+8|0]=me;o[Wd+9|0]=me>>>8;o[Wd+10|0]=me>>>16;o[Wd+11|0]=me>>>24;o[Wd+12|0]=ee;o[Wd+13|0]=ee>>>8;o[Wd+14|0]=ee>>>16;o[Wd+15|0]=ee>>>24;ee=r[13402]|r[13403]<<8|(r[13404]<<16|r[13405]<<24);me=r[13398]|r[13399]<<8|(r[13400]<<16|r[13401]<<24);o[Wd|0]=me;o[Wd+1|0]=me>>>8;o[Wd+2|0]=me>>>16;o[Wd+3|0]=me>>>24;o[Wd+4|0]=ee;o[Wd+5|0]=ee>>>8;o[Wd+6|0]=ee>>>16;o[Wd+7|0]=ee>>>24;q[a>>2]=-1;Rm(a+4|0,le+16|0);if(o[le+27|0]>-1){break a}An(q[le+16>>2]);break a}Wd=q[Wd+4>>2];q[le+8>>2]=0;me=q[le+40>>2];q[le+40>>2]=0;ee=q[Wd+4>>2];q[Wd+4>>2]=me;b:{if(!ee){q[le+8>>2]=0;break b}Lj(ee);Wd=q[le+8>>2];q[le+8>>2]=0;if(!Wd){break b}Lj(Wd)}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}a=q[le+40>>2];q[le+40>>2]=0;if(a){Lj(a)}T=le+48|0}function Lj(a){var Wd=0,oe=0,pe=0,qe=0,re=0;if(a){pe=q[a+24>>2];if(pe){Wd=pe;re=a+28|0;oe=q[re>>2];qe=Wd;a:{if((oe|0)==(Wd|0)){break a}while(1){oe=oe+ -4|0;Wd=q[oe>>2];q[oe>>2]=0;if(Wd){Hc(Wd+12|0,q[Wd+16>>2]);Ic(Wd,q[Wd+4>>2]);An(Wd)}if((oe|0)!=(pe|0)){continue}break}qe=q[a+24>>2]}Wd=qe;q[re>>2]=pe;An(Wd)}Hc(a+12|0,q[a+16>>2]);Ic(a,q[a+4>>2]);An(a)}}function Mj(a,se,te,ue,ve){var we=0,xe=0;we=T-32|0;T=we;q[se+32>>2]=ue;q[se+40>>2]=te;q[se+4>>2]=ve;Jj(a,ue,we+16|0);a:{if(q[a>>2]){break a}te=a+4|0;if(o[a+15|0]<=-1){An(q[te>>2])}ve=r[we+23|0];if((n[q[q[se>>2]+8>>2]](se)|0)!=(ve|0)){se=Mm(64);q[we>>2]=se;q[we+4>>2]=50;q[we+8>>2]=-2147483584;o[se+50|0]=0;ue=r[13473]|r[13474]<<8;o[se+48|0]=ue;o[se+49|0]=ue>>>8;ue=r[13469]|r[13470]<<8|(r[13471]<<16|r[13472]<<24);ve=r[13465]|r[13466]<<8|(r[13467]<<16|r[13468]<<24);o[se+40|0]=ve;o[se+41|0]=ve>>>8;o[se+42|0]=ve>>>16;o[se+43|0]=ve>>>24;o[se+44|0]=ue;o[se+45|0]=ue>>>8;o[se+46|0]=ue>>>16;o[se+47|0]=ue>>>24;ue=r[13461]|r[13462]<<8|(r[13463]<<16|r[13464]<<24);ve=r[13457]|r[13458]<<8|(r[13459]<<16|r[13460]<<24);o[se+32|0]=ve;o[se+33|0]=ve>>>8;o[se+34|0]=ve>>>16;o[se+35|0]=ve>>>24;o[se+36|0]=ue;o[se+37|0]=ue>>>8;o[se+38|0]=ue>>>16;o[se+39|0]=ue>>>24;ue=r[13453]|r[13454]<<8|(r[13455]<<16|r[13456]<<24);ve=r[13449]|r[13450]<<8|(r[13451]<<16|r[13452]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13445]|r[13446]<<8|(r[13447]<<16|r[13448]<<24);ve=r[13441]|r[13442]<<8|(r[13443]<<16|r[13444]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13437]|r[13438]<<8|(r[13439]<<16|r[13440]<<24);ve=r[13433]|r[13434]<<8|(r[13435]<<16|r[13436]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13429]|r[13430]<<8|(r[13431]<<16|r[13432]<<24);ve=r[13425]|r[13426]<<8|(r[13427]<<16|r[13428]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}ue=r[we+21|0];o[se+36|0]=ue;xe=r[we+22|0];o[se+37|0]=xe;if((ue+ -1&255)>>>0>=2){se=Mm(32);q[we>>2]=se;q[we+4>>2]=22;q[we+8>>2]=-2147483616;o[se+22|0]=0;ue=r[13494]|r[13495]<<8|(r[13496]<<16|r[13497]<<24);ve=r[13490]|r[13491]<<8|(r[13492]<<16|r[13493]<<24);o[se+14|0]=ve;o[se+15|0]=ve>>>8;o[se+16|0]=ve>>>16;o[se+17|0]=ve>>>24;o[se+18|0]=ue;o[se+19|0]=ue>>>8;o[se+20|0]=ue>>>16;o[se+21|0]=ue>>>24;ue=r[13488]|r[13489]<<8|(r[13490]<<16|r[13491]<<24);ve=r[13484]|r[13485]<<8|(r[13486]<<16|r[13487]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13480]|r[13481]<<8|(r[13482]<<16|r[13483]<<24);ve=r[13476]|r[13477]<<8|(r[13478]<<16|r[13479]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-5;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!((ue|0)!=2|(ve?2:3)>>>0>=xe>>>0)){se=Mm(32);q[we>>2]=se;q[we+4>>2]=22;q[we+8>>2]=-2147483616;o[se+22|0]=0;ue=r[13517]|r[13518]<<8|(r[13519]<<16|r[13520]<<24);ve=r[13513]|r[13514]<<8|(r[13515]<<16|r[13516]<<24);o[se+14|0]=ve;o[se+15|0]=ve>>>8;o[se+16|0]=ve>>>16;o[se+17|0]=ve>>>24;o[se+18|0]=ue;o[se+19|0]=ue>>>8;o[se+20|0]=ue>>>16;o[se+21|0]=ue>>>24;ue=r[13511]|r[13512]<<8|(r[13513]<<16|r[13514]<<24);ve=r[13507]|r[13508]<<8|(r[13509]<<16|r[13510]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13503]|r[13504]<<8|(r[13505]<<16|r[13506]<<24);ve=r[13499]|r[13500]<<8|(r[13501]<<16|r[13502]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-5;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}ue=ue<<8|xe;p[q[se+32>>2]+38>>1]=ue;b:{if((ue&65535)>>>0<259|p[we+26>>1]>-1){break b}Kj(a,se);if(q[a>>2]){break a}if(o[te+11|0]>-1){break b}An(q[te>>2])}if(!n[q[q[se>>2]+12>>2]](se)){se=Mm(48);q[we>>2]=se;q[we+4>>2]=33;q[we+8>>2]=-2147483600;o[se+33|0]=0;o[se+32|0]=r[13554];ue=r[13550]|r[13551]<<8|(r[13552]<<16|r[13553]<<24);ve=r[13546]|r[13547]<<8|(r[13548]<<16|r[13549]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13542]|r[13543]<<8|(r[13544]<<16|r[13545]<<24);ve=r[13538]|r[13539]<<8|(r[13540]<<16|r[13541]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13534]|r[13535]<<8|(r[13536]<<16|r[13537]<<24);ve=r[13530]|r[13531]<<8|(r[13532]<<16|r[13533]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13526]|r[13527]<<8|(r[13528]<<16|r[13529]<<24);ve=r[13522]|r[13523]<<8|(r[13524]<<16|r[13525]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!n[q[q[se>>2]+20>>2]](se)){se=Mm(32);q[we>>2]=se;q[we+4>>2]=31;q[we+8>>2]=-2147483616;o[se+31|0]=0;ue=r[13583]|r[13584]<<8|(r[13585]<<16|r[13586]<<24);ve=r[13579]|r[13580]<<8|(r[13581]<<16|r[13582]<<24);o[se+23|0]=ve;o[se+24|0]=ve>>>8;o[se+25|0]=ve>>>16;o[se+26|0]=ve>>>24;o[se+27|0]=ue;o[se+28|0]=ue>>>8;o[se+29|0]=ue>>>16;o[se+30|0]=ue>>>24;ue=r[13576]|r[13577]<<8|(r[13578]<<16|r[13579]<<24);ve=r[13572]|r[13573]<<8|(r[13574]<<16|r[13575]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13568]|r[13569]<<8|(r[13570]<<16|r[13571]<<24);ve=r[13564]|r[13565]<<8|(r[13566]<<16|r[13567]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13560]|r[13561]<<8|(r[13562]<<16|r[13563]<<24);ve=r[13556]|r[13557]<<8|(r[13558]<<16|r[13559]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!n[q[q[se>>2]+24>>2]](se)){se=Mm(48);q[we>>2]=se;q[we+4>>2]=34;q[we+8>>2]=-2147483600;o[se+34|0]=0;ue=r[13620]|r[13621]<<8;o[se+32|0]=ue;o[se+33|0]=ue>>>8;ue=r[13616]|r[13617]<<8|(r[13618]<<16|r[13619]<<24);ve=r[13612]|r[13613]<<8|(r[13614]<<16|r[13615]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13608]|r[13609]<<8|(r[13610]<<16|r[13611]<<24);ve=r[13604]|r[13605]<<8|(r[13606]<<16|r[13607]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13600]|r[13601]<<8|(r[13602]<<16|r[13603]<<24);ve=r[13596]|r[13597]<<8|(r[13598]<<16|r[13599]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13592]|r[13593]<<8|(r[13594]<<16|r[13595]<<24);ve=r[13588]|r[13589]<<8|(r[13590]<<16|r[13591]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}T=we+32|0}function Nj(a){a=a|0;var se=0,te=0,ue=0,ve=0,ye=0,ze=0,Ae=0,Be=0,Ce=0,De=0,Ee=0,Fe=0;a:{se=q[a+32>>2];ve=q[se+16>>2];ze=q[se+12>>2];ue=q[se+20>>2];b:{if((ze|0)<(ue|0)?1:(ze|0)<=(ue|0)?t[se+8>>2]>ve>>>0?0:1:0){break b}ye=r[ve+q[se>>2]|0];Ae=ve+1|0;if(Ae>>>0<1){ue=ue+1|0}q[se+16>>2]=Ae;q[se+20>>2]=ue;c:{if(!ye){break c}while(1){if(n[q[q[a>>2]+16>>2]](a,te)){te=te+1|0;if((ye|0)!=(te|0)){continue}break c}break}return 0}te=q[a+8>>2];ue=q[a+12>>2];if((te|0)!=(ue|0)){while(1){se=q[te>>2];if(!n[q[q[se>>2]+8>>2]](se,a,q[a+4>>2])){break b}te=te+4|0;if((ue|0)!=(te|0)){continue}break}}d:{if(!ye){break d}te=0;ue=a+8|0;while(1){se=q[q[ue>>2]+(te<<2)>>2];if(!n[q[q[se>>2]+12>>2]](se,q[a+32>>2])){break a}te=te+1|0;if((ye|0)!=(te|0)){continue}break}if(!ye){break d}ve=a+20|0;Be=a+8|0;ze=a+24|0;while(1){te=0;Ae=Ce<<2;se=q[Ae+q[Be>>2]>>2];ue=n[q[q[se>>2]+24>>2]](se)|0;if((ue|0)>0){while(1){se=q[q[Be>>2]+Ae>>2];se=n[q[q[se>>2]+20>>2]](se,te)|0;De=q[a+20>>2];Ee=q[ze>>2]-De>>2;e:{if(se>>>0>>0){break e}Fe=se+1|0;if(Fe>>>0>Ee>>>0){Fa(ve,Fe-Ee|0);De=q[ve>>2];break e}if(Fe>>>0>=Ee>>>0){break e}q[ze>>2]=(Fe<<2)+De}q[(se<<2)+De>>2]=Ce;te=te+1|0;if((ue|0)!=(te|0)){continue}break}}Ce=Ce+1|0;if((Ce|0)!=(ye|0)){continue}break}}Be=0;if(!n[q[q[a>>2]+28>>2]](a)){break b}Be=n[q[q[a>>2]+32>>2]](a)|0}return Be|0}return 0}function Oj(a){a=a|0;var Ge=0,He=0,Ie=0,Je=0;He=1;Ge=q[a+8>>2];Ie=q[a+12>>2];a:{if((Ge|0)==(Ie|0)){break a}while(1){Je=q[Ge>>2];if(n[q[q[Je>>2]+16>>2]](Je,q[a+32>>2])){Ge=Ge+4|0;if((Ie|0)!=(Ge|0)){continue}break a}break}He=0}return He|0}function Pj(a,Ke){var Le=0,Me=0;a:{if((Ke|0)<0){break a}Le=q[a+4>>2];if(q[Le+12>>2]-q[Le+8>>2]>>2<=(Ke|0)){break a}a=q[q[a+8>>2]+(q[q[a+20>>2]+(Ke<<2)>>2]<<2)>>2];Me=n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ue=q[$e+20>>2];ef=bf;bf=q[$e+16>>2];$e=bf+4|0;if($e>>>0<4){Ue=Ue+1|0}df=$e;$e=Ue;if((cf|0)>(Ue|0)?1:(cf|0)>=(Ue|0)?ef>>>0>>0?0:1:0){Ue=bf+q[af>>2]|0;Ue=r[Ue|0]|r[Ue+1|0]<<8|(r[Ue+2|0]<<16|r[Ue+3|0]<<24);q[af+16>>2]=df;q[af+20>>2]=$e;q[q[a+4>>2]+80>>2]=Ue;a=1}else{a=0}return a|0}function Tj(a,ff,gf){var hf=0,jf=0,kf=0;if((ff|0)>0){while(1){jf=hf<<2;kf=q[jf+a>>2];q[gf+jf>>2]=0-(kf&1)^kf>>>1;hf=hf+1|0;if((hf|0)!=(ff|0)){continue}break}}}function Uj(a){q[a+16>>2]=0;q[a+20>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0}function Vj(a,q,ff,gf){return Wj(a,q,ff,gf)}function Wj(a,ff,gf,lf){var mf=0,nf=0,of=0;a:{if(!ff){ff=gf;lf=ff>>>0<0?lf+1|0:lf;if((lf|0)<0?1:(lf|0)<=0?ff>>>0>=0?0:1:0){return 0}lf=q[a>>2];gf=q[a+4>>2]-lf|0;if(gf>>>0>>0){Ha(a,ff-gf|0);break a}if(gf>>>0<=ff>>>0){break a}q[a+4>>2]=ff+lf;break a}if((lf|0)<0?1:(lf|0)<=0?gf>>>0>=0?0:1:0){return 0}nf=gf;if(gf>>>0<0){lf=lf+1|0}of=q[a>>2];mf=q[a+4>>2]-of|0;b:{if((lf|0)<0?1:(lf|0)<=0?nf>>>0>mf>>>0?0:1:0){break b}lf=nf;if(mf>>>0>>0){Ha(a,lf-mf|0);break b}if(mf>>>0<=lf>>>0){break b}q[a+4>>2]=lf+of}if(!gf){break a}En(q[a>>2],ff,gf)}ff=a+24|0;gf=ff;lf=ff;a=q[ff+4>>2];ff=q[ff>>2]+1|0;if(ff>>>0<1){a=a+1|0}q[lf>>2]=ff;q[gf+4>>2]=a;return 1}function Xj(a,ff){var gf=0,lf=0;lf=q[a>>2];gf=q[a+4>>2]-lf|0;a:{if(gf>>>0>>0){Ha(a,ff-gf|0);break a}if(gf>>>0<=ff>>>0){break a}q[a+4>>2]=ff+lf}ff=a+24|0;gf=ff;lf=ff;a=q[ff+4>>2];ff=q[ff>>2]+1|0;if(ff>>>0<1){a=a+1|0}q[lf>>2]=ff;q[gf+4>>2]=a}function Yj(a){p[a+38>>1]=0;q[a>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;o[a+29|0]=0;o[a+30|0]=0;o[a+31|0]=0;o[a+32|0]=0;o[a+33|0]=0;o[a+34|0]=0;o[a+35|0]=0;o[a+36|0]=0;return a}function Zj(a,ff,pf,qf){p[a+38>>1]=qf;q[a>>2]=ff;q[a+16>>2]=0;q[a+20>>2]=0;q[a+8>>2]=pf;q[a+12>>2]=0}function _j(a,ff,pf){var qf=0,rf=0,sf=0,tf=0;a:{b:{if(!ff){break b}if(s[a+38>>1]<=513){rf=q[a+12>>2];ff=q[a+20>>2];sf=q[a+16>>2];tf=sf+8|0;if(tf>>>0<8){ff=ff+1|0}if((rf|0)<(ff|0)?1:(rf|0)<=(ff|0)?t[a+8>>2]>=tf>>>0?0:1:0){break a}ff=sf+q[a>>2]|0;qf=r[ff+4|0]|r[ff+5|0]<<8|(r[ff+6|0]<<16|r[ff+7|0]<<24);q[pf>>2]=r[ff|0]|r[ff+1|0]<<8|(r[ff+2|0]<<16|r[ff+3|0]<<24);q[pf+4>>2]=qf;pf=q[a+20>>2];qf=q[a+16>>2]+8|0;if(qf>>>0<8){pf=pf+1|0}q[a+16>>2]=qf;q[a+20>>2]=pf;break b}if(!$j(1,pf,a)){break a}}o[a+36|0]=1;q[a+32>>2]=0;ff=q[a+16>>2];pf=ff+q[a>>2]|0;q[a+24>>2]=pf;qf=a;a=q[a+8>>2];q[qf+28>>2]=pf+(a-ff|0);qf=1}return qf}function $j(a,ff,pf){var uf=0,vf=0,wf=0,xf=0,yf=0,zf=0;a:{if(a>>>0>10){break a}wf=q[pf+16>>2];uf=q[pf+12>>2];vf=q[pf+20>>2];xf=vf;if((uf|0)<(xf|0)?1:(uf|0)<=(xf|0)?t[pf+8>>2]>wf>>>0?0:1:0){break a}yf=o[wf+q[pf>>2]|0];uf=wf+1|0;if(uf>>>0<1){vf=vf+1|0}q[pf+16>>2]=uf;q[pf+20>>2]=vf;xf=ff;wf=ff;uf=yf;b:{if((uf|0)<=-1){if(!$j(a+1|0,ff,pf)){break a}a=ff;pf=q[ff+4>>2];ff=q[ff>>2];vf=pf<<7|ff>>>25;ff=ff<<7;q[a>>2]=ff;q[a+4>>2]=vf;a=uf&127|ff;break b}vf=0;a=uf&255}q[wf>>2]=a;q[xf+4>>2]=vf;zf=1}return zf}function ak(a){var ff=0,pf=0,Af=0,Bf=0,Cf=0,Df=0;o[a+36|0]=0;Af=q[a+20>>2];Bf=a;Cf=a;Df=q[a+16>>2];a=q[a+32>>2]+7|0;if(a>>>0<7){ff=1}pf=ff>>>3;a=ff<<29|a>>>3;ff=Df+a|0;pf=pf+Af|0;q[Cf+16>>2]=ff;q[Bf+20>>2]=ff>>>0>>0?pf+1|0:pf}function bk(a){a=a+ -1|0;if(a>>>0<=10){return q[(a<<2)+13848>>2]}return-1}function ck(a){var Ef=0;Ef=a+4|0;q[Ef>>2]=0;q[Ef+4>>2]=0;q[a>>2]=Ef;return a}function dk(a,Ff,Gf,Hf){var If=0,Jf=0,Kf=0,Lf=0;If=T-16|0;T=If;Lf=a;Jf=ph(Ff,If+12|0,Gf);Gf=q[Jf>>2];if(Gf){Ff=0}else{Gf=Mm(40);Rm(Gf+16|0,q[Hf>>2]);q[Gf+36>>2]=0;q[Gf+28>>2]=0;q[Gf+32>>2]=0;q[Gf+8>>2]=q[If+12>>2];q[Gf>>2]=0;q[Gf+4>>2]=0;q[Jf>>2]=Gf;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hf=Pf}return Hf}function gk(a,Ff){var Tf=0;Ff=fk(a,Ff);a:{if((Ff|0)==(a+4|0)){break a}a=Ff+28|0;if(o[Ff+39|0]<=-1){a=q[a>>2]}a=bm(a);if((a|0)==-1){break a}Tf=(a|0)!=0}return Tf}function hk(a){q[a>>2]=1065353216;return a}function ik(a,q,Ff){if((Ff|0)<1){return 0}u[a>>2]=q/x(Ff|0);return 1}function jk(a){var Ff=0;q[a>>2]=0;q[a+4>>2]=0;q[a+56>>2]=0;q[a+48>>2]=0;q[a+52>>2]=0;q[a+40>>2]=0;q[a+44>>2]=0;q[a+32>>2]=0;q[a+36>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;Ff=a- -64|0;q[Ff>>2]=0;q[Ff+4>>2]=0;q[a+72>>2]=0;q[a+76>>2]=0;q[a+80>>2]=0;q[a+84>>2]=0;q[a+60>>2]=a}function kk(a,Uf){var Vf=0,Wf=0,Xf=0;Xf=T-16|0;T=Xf;Wf=Mm(88);Vf=Wf;q[Vf>>2]=0;q[Vf+4>>2]=0;q[Vf+56>>2]=0;q[Vf+48>>2]=0;q[Vf+52>>2]=0;q[Vf+40>>2]=0;q[Vf+44>>2]=0;q[Vf+32>>2]=0;q[Vf+36>>2]=0;q[Vf+24>>2]=0;q[Vf+28>>2]=0;q[Vf+16>>2]=0;q[Vf+20>>2]=0;q[Vf+8>>2]=0;q[Vf+12>>2]=0;Vf=Vf- -64|0;q[Vf>>2]=0;q[Vf+4>>2]=0;q[Wf+72>>2]=0;q[Wf+76>>2]=0;q[Wf+80>>2]=0;q[Wf+84>>2]=0;q[Wf+60>>2]=Wf;q[Xf+8>>2]=Wf;a:{if(lk(Wf,Uf)){q[a>>2]=q[Xf+8>>2];q[Xf+8>>2]=0;break a}q[a>>2]=0;a=q[Xf+8>>2];q[Xf+8>>2]=0;if(!a){break a}wa(Xf+8|0,a)}T=Xf+16|0}function lk(a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2)|0;gg=dg+(eg<<2)|0;if((hg|0)>=1){Cn(ig,fg,hg)}q[a>>2]=dg;q[a+8>>2]=gg;q[a+4>>2]=Uf;if(fg){An(fg)}return}bn();F()}ab(13904);F()}function nk(a,Uf){var mg=0,ng=0,og=0,pg=0,qg=0,rg=0,sg=0,tg=0,ug=0,vg=0,wg=0,xg=0,yg=0,zg=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0,Gg=0;og=T-48|0;T=og;if(Uf){Dg=a+12|0;ng=a+4|0;tg=q[ng>>2];ug=q[a>>2];rg=tg-ug|0;pg=rg>>2;mg=q[a+12>>2];qg=q[a+16>>2]-mg>>2;a:{if(pg>>>0>qg>>>0){qk(Dg,pg-qg|0);tg=q[ng>>2];ug=q[a>>2];rg=tg-ug|0;pg=rg>>2;break a}if(pg>>>0>=qg>>>0){break a}q[a+16>>2]=mg+(pg<<2)}ng=0;q[og+40>>2]=0;q[og+32>>2]=0;q[og+36>>2]=0;b:{c:{d:{if(!pg){mg=0;qg=0;break d}if(pg>>>0>=1073741824){break c}mg=Mm(rg);q[og+36>>2]=mg;q[og+32>>2]=mg;q[og+40>>2]=(pg<<2)+mg;qg=mg}e:{if(!rg){break e}sg=a+4|0;ng=qg;wg=ng;rg=0;while(1){vg=q[(rg<<2)+ug>>2];wg=wg-ng>>2;if(vg>>>0>=wg>>>0){q[og+16>>2]=0;mg=vg+1|0;f:{if(mg>>>0>wg>>>0){Ad(og+32|0,mg-wg|0,og+16|0);tg=q[sg>>2];ug=q[a>>2];break f}if(mg>>>0>=wg>>>0){break f}q[og+36>>2]=(mg<<2)+ng}mg=q[og+32>>2];qg=mg}ng=(vg<<2)+mg|0;q[ng>>2]=q[ng>>2]+1;rg=rg+1|0;ng=tg-ug|0;pg=ng>>2;if(rg>>>0>=pg>>>0){break e}wg=q[og+36>>2];ng=mg;continue}}q[og+24>>2]=0;q[og+16>>2]=0;q[og+20>>2]=0;rg=0;g:{if(ng){if(pg>>>0>=536870912){break g}rg=Mm(ng<<1);q[og+16>>2]=rg;q[og+20>>2]=rg;ng=pg<<3;q[og+24>>2]=ng+rg;ng=Dn(rg,255,ng);while(1){ng=ng+8|0;pg=pg+ -1|0;if(pg){continue}break}q[og+20>>2]=ng}q[og+8>>2]=0;q[og>>2]=0;q[og+4>>2]=0;ng=q[og+36>>2]-qg|0;Ag=ng>>2;h:{if(ng){if(Ag>>>0>=1073741824){break h}xg=Mm(ng);q[og>>2]=xg;q[og+8>>2]=(Ag<<2)+xg;pg=0;sg=Dn(xg,0,ng);q[og+4>>2]=sg+ng;ng=0;while(1){qg=ng<<2;q[qg+sg>>2]=pg;pg=q[mg+qg>>2]+pg|0;ng=ng+1|0;if(ng>>>0>>0){continue}break}}if((tg|0)==(ug|0)){break b}Gg=tg-ug>>2;sg=0;Eg=q[og+32>>2];while(1){Bg=sg<<2;wg=q[Bg+ug>>2];tg=-1;ng=sg+1|0;mg=(ng>>>0)%3|0?ng:sg+ -2|0;if((mg|0)!=-1){tg=q[(mg<<2)+ug>>2]}yg=-1;qg=(sg>>>0)%3|0;mg=(qg?-1:2)+sg|0;if((mg|0)!=-1){yg=q[(mg<<2)+ug>>2]}i:{j:{if(qg){break j}k:{if((tg|0)==(yg|0)){break k}mg=q[ug+Bg>>2];if((mg|0)==(tg|0)){break k}if((mg|0)!=(yg|0)){break j}}q[a+40>>2]=q[a+40>>2]+1;ng=sg+3|0;break i}mg=yg<<2;Cg=q[mg+Eg>>2];l:{m:{if((Cg|0)<1){break m}mg=q[mg+xg>>2];pg=0;while(1){vg=(mg<<3)+rg|0;qg=q[vg>>2];if((qg|0)==-1){break m}n:{if((qg|0)!=(tg|0)){break n}zg=q[vg+4>>2];if((zg|0)!=-1){qg=q[(zg<<2)+ug>>2]}else{qg=-1}if((qg|0)==(wg|0)){break n}while(1){qg=mg;pg=pg+1|0;o:{if((pg|0)>=(Cg|0)){break o}Fg=(qg<<3)+rg|0;mg=qg+1|0;wg=(mg<<3)+rg|0;vg=q[wg>>2];q[Fg>>2]=vg;q[Fg+4>>2]=q[wg+4>>2];if((vg|0)!=-1){continue}}break}q[(qg<<3)+rg>>2]=-1;if((zg|0)==-1){break m}mg=q[Dg>>2];q[mg+Bg>>2]=zg;q[mg+(zg<<2)>>2]=sg;break l}mg=mg+1|0;pg=pg+1|0;if((Cg|0)!=(pg|0)){continue}break}}mg=tg<<2;qg=q[mg+Eg>>2];if((qg|0)<1){break l}mg=q[mg+xg>>2];pg=0;while(1){vg=(mg<<3)+rg|0;if(q[vg>>2]==-1){q[vg>>2]=yg;q[vg+4>>2]=sg;break l}mg=mg+1|0;pg=pg+1|0;if((qg|0)!=(pg|0)){continue}break}}}sg=ng;if(sg>>>0>>0){continue}break}break b}bn();F()}bn();F()}ab(13904);F()}q[Uf>>2]=Ag;if(xg){q[og+4>>2]=xg;An(xg)}a=q[og+16>>2];if(a){q[og+20>>2]=a;An(a)}a=q[og+32>>2];if(a){q[og+36>>2]=a;An(a)}a=1}else{a=0}T=og+48|0;return a}function ok(a){var Uf=0,Hg=0,Ig=0,Jg=0,Kg=0,Lg=0,Mg=0,Ng=0,Og=0,Pg=0,Qg=0,Rg=0,Sg=0,Tg=0,Ug=0;Ig=T-48|0;T=Ig;Qg=a+4|0;Uf=q[Qg>>2];Og=q[a>>2];o[Ig+16|0]=0;Rg=rk(Ig+32|0,Uf-Og>>2,Ig+16|0);q[Ig+24>>2]=0;q[Ig+16>>2]=0;q[Ig+20>>2]=0;Uf=q[Qg>>2];Mg=q[a>>2];Ng=a+12|0;while(1){Sg=0;Lg=0;a:{if((Uf|0)==(Mg|0)){break a}while(1){Jg=q[Rg>>2];b:{if(q[Jg+(Lg>>>3&536870908)>>2]>>>(Lg&31)&1){break b}Kg=q[Ig+16>>2];q[Ig+20>>2]=Kg;Uf=Lg;while(1){Hg=Uf+1|0;Og=Uf;Uf=(Hg>>>0)%3|0?Hg:Uf+ -2|0;c:{if((Uf|0)==-1){break c}Uf=q[q[Ng>>2]+(Uf<<2)>>2];if((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+((Wg>>>0)%3|0?-1:2)|0;if((Wg|0)==-1){break e}bh=q[ch>>2];while(1){Yg=(Wg>>>3&536870908)+bh|0;q[Yg>>2]=q[Yg>>2]|1<<(Wg&31);if(Zg){q[q[a>>2]+(Wg<<2)>>2]=q[$g+8>>2]}Wg=((Wg>>>0)%3|0?-1:2)+Wg|0;if((Wg|0)==-1){break e}Wg=q[q[hh>>2]+(Wg<<2)>>2];if((Wg|0)==-1){break e}Wg=Wg+((Wg>>>0)%3|0?-1:2)|0;if((Wg|0)!=-1){continue}break}}eh=eh+1|0;if((eh|0)!=3){continue}break}}ih=ih+1|0;Wg=q[a>>2];if(ih>>>0<(q[gh>>2]-Wg>>2>>>0)/3>>>0){continue}break b}break}bn();F()}q[a+44>>2]=0;Vg=q[ah>>2];Wg=q[ah+4>>2];Yg=Wg>>>5;Zg=Wg&31;if(Yg|Zg){Yg=(Yg<<2)+Vg|0;Xg=Vg;Wg=0;while(1){if(!(q[Xg>>2]>>>Wg&1)){lh=lh+1|0;q[a+44>>2]=lh}_g=(Wg|0)==31;Wg=_g?0:Wg+1|0;Xg=_g?Xg+4|0:Xg;if((Yg|0)!=(Xg|0)|(Wg|0)!=(Zg|0)){continue}break}}a=q[ch>>2];if(a){An(a);Vg=q[ah>>2]}if(Vg){An(Vg)}T=$g+48|0}function qk(a,Vg){var rh=0,sh=0,th=0,uh=0,vh=0,wh=0;th=q[a+8>>2];rh=q[a+4>>2];if(th-rh>>2>>>0>=Vg>>>0){while(1){q[rh>>2]=q[3475];rh=rh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}q[a+4>>2]=rh;return}a:{uh=q[a>>2];vh=rh-uh|0;wh=vh>>2;rh=wh+Vg|0;if(rh>>>0<1073741824){th=th-uh|0;sh=th>>1;rh=th>>2>>>0<536870911?sh>>>0>>0?rh:sh:1073741823;sh=0;b:{if(!rh){break b}if(rh>>>0>=1073741824){break a}sh=Mm(rh<<2)}th=sh+(rh<<2)|0;rh=sh+(wh<<2)|0;while(1){q[rh>>2]=q[3475];rh=rh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}if((vh|0)>=1){Cn(sh,uh,vh)}q[a>>2]=sh;q[a+8>>2]=th;q[a+4>>2]=rh;if(uh){An(uh)}return}bn();F()}ab(13904);F()}function rk(a,Vg,xh){var yh=0,zh=0,Ah=0;q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;a:{b:{if(!Vg){break b}if((Vg|0)<=-1){break a}zh=Vg+ -1>>>5;Ah=zh+1|0;yh=Mm(Ah<<2);q[a+8>>2]=Ah;q[a>>2]=yh;Ah=r[xh|0];q[a+4>>2]=Vg;q[(Vg>>>0<33?yh:yh+(zh<<2)|0)>>2]=0;xh=Vg>>>5;zh=xh<<2;if(Ah){yh=Dn(yh,255,zh);Vg=Vg&31;if(!Vg){break b}xh=yh+(xh<<2)|0;q[xh>>2]=q[xh>>2]|-1>>>32-Vg;return a}yh=Dn(yh,0,zh);Vg=Vg&31;if(!Vg){break b}xh=yh+(xh<<2)|0;q[xh>>2]=q[xh>>2]&(-1>>>32-Vg^-1)}return a}bn();F()}function sk(a,Vg){var xh=0,Bh=0,Ch=0,Dh=0,Eh=0,Fh=0;a:{Ch=q[a>>2];Fh=q[a+4>>2]-Ch|0;xh=Fh>>3;Bh=xh+1|0;if(Bh>>>0<536870912){Dh=xh<<3;Eh=q[a+8>>2]-Ch|0;xh=Eh>>2;Bh=Eh>>3>>>0<268435455?xh>>>0>>0?Bh:xh:536870911;xh=0;b:{if(!Bh){break b}if(Bh>>>0>=536870912){break a}xh=Mm(Bh<<3)}Dh=Dh+xh|0;Eh=q[Vg+4>>2];q[Dh>>2]=q[Vg>>2];q[Dh+4>>2]=Eh;Vg=xh+(Bh<<3)|0;Bh=Dh+8|0;if((Fh|0)>=1){Cn(xh,Ch,Fh)}q[a>>2]=xh;q[a+8>>2]=Vg;q[a+4>>2]=Bh;if(Ch){An(Ch)}return}bn();F()}ab(13904);F()}function tk(a,Vg,Gh){var Hh=0,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lh=Mm(Mh);q[a>>2]=Lh;q[a+4>>2]=Lh;q[a+8>>2]=Lh+Mh;while(1){q[Lh>>2]=q[Gh>>2];Lh=Lh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}q[a+4>>2]=Lh;return}bn();F()}function vk(a){al(a);q[a+84>>2]=0;q[a+88>>2]=0;q[a>>2]=13980;q[a+92>>2]=0;q[a+96>>2]=0;q[a+100>>2]=0;q[a+104>>2]=0;return a}function wk(a){a=a|0;var Vg=0,Gh=0,Qh=0,Rh=0,Sh=0;q[a>>2]=14380;Vg=q[a+68>>2];if(Vg){q[a+72>>2]=Vg;An(Vg)}Vg=q[a+56>>2];if(Vg){q[a+60>>2]=Vg;An(Vg)}Vg=q[a+44>>2];if(Vg){q[a+48>>2]=Vg;An(Vg)}Vg=q[a+32>>2];if(Vg){q[a+36>>2]=Vg;An(Vg)}Vg=q[a+20>>2];if(Vg){q[a+24>>2]=Vg;An(Vg)}Qh=q[a+8>>2];if(Qh){Vg=Qh;Sh=a+12|0;Gh=q[Sh>>2];Rh=Vg;a:{if((Vg|0)==(Gh|0)){break a}while(1){Gh=Gh+ -4|0;Vg=q[Gh>>2];q[Gh>>2]=0;if(Vg){Hb(Vg)}if((Gh|0)!=(Qh|0)){continue}break}Rh=q[a+8>>2]}Vg=Rh;q[Sh>>2]=Qh;An(Vg)}Vg=q[a+4>>2];q[a+4>>2]=0;if(Vg){Lj(Vg)}return a|0}function xk(a){a=a|0;var Th=0;q[a>>2]=13980;Th=q[a+96>>2];if(Th){q[a+100>>2]=Th;An(Th)}Th=q[a+84>>2];if(Th){q[a+88>>2]=Th;An(Th)}wk(a);return a|0}function yk(a){a=a|0;var Uh=0;q[a>>2]=13980;Uh=q[a+96>>2];if(Uh){q[a+100>>2]=Uh;An(Uh)}Uh=q[a+84>>2];if(Uh){q[a+88>>2]=Uh;An(Uh)}wk(a);An(a)}function zk(a,Vh,Wh){a=a|0;Vh=Vh|0;Wh=Wh|0;var Xh=0,Yh=0;Xh=T-16|0;T=Xh;Yh=q[Wh>>2];q[Wh>>2]=0;q[Xh+8>>2]=Yh;gl(a,Vh,Xh+8|0);Wh=q[Xh+8>>2];q[Xh+8>>2]=0;if(Wh){Hb(Wh)}Yh=q[a+84>>2];Wh=q[a+88>>2]-Yh>>2;a:{if((Wh|0)>(Vh|0)){break a}Vh=Vh+1|0;if(Vh>>>0>Wh>>>0){Ak(a+84|0,Vh-Wh|0);break a}if(Vh>>>0>=Wh>>>0){break a}q[a+88>>2]=Yh+(Vh<<2)}T=Xh+16|0}function Ak(a,Vh){var Wh=0,Zh=0,_h=0,$h=0,ai=0,bi=0;_h=q[a+8>>2];Wh=q[a+4>>2];if(_h-Wh>>2>>>0>=Vh>>>0){while(1){q[Wh>>2]=1;Wh=Wh+4|0;Vh=Vh+ -1|0;if(Vh){continue}break}q[a+4>>2]=Wh;return}a:{$h=q[a>>2];ai=Wh-$h|0;bi=ai>>2;Wh=bi+Vh|0;if(Wh>>>0<1073741824){_h=_h-$h|0;Zh=_h>>1;Wh=_h>>2>>>0<536870911?Zh>>>0>>0?Wh:Zh:1073741823;Zh=0;b:{if(!Wh){break b}if(Wh>>>0>=1073741824){break a}Zh=Mm(Wh<<2)}_h=Zh+(Wh<<2)|0;Wh=Zh+(bi<<2)|0;while(1){q[Wh>>2]=1;Wh=Wh+4|0;Vh=Vh+ -1|0;if(Vh){continue}break}if((ai|0)>=1){Cn(Zh,$h,ai)}q[a>>2]=Zh;q[a+8>>2]=_h;q[a+4>>2]=Wh;if($h){An($h)}return}bn();F()}ab(14024);F()}function Bk(a,Vh){a=a|0;Vh=Vh|0;var ci=0,di=0,ei=0;jl(a,Vh);a:{if((Vh|0)<0){break a}ci=q[a+88>>2];di=q[a+84>>2];if(ci-di>>2<=(Vh|0)){break a}Vh=di+(Vh<<2)|0;di=Vh+4|0;ci=ci-di|0;ei=ci>>2;if(ci){En(Vh,di,ci)}q[a+88>>2]=Vh+(ei<<2)}}function Ck(a,Vh){var fi=0,gi=0,hi=0,ii=0,ji=0,ki=0;a:{hi=q[a>>2];ji=q[a+4>>2]-hi|0;fi=ji>>2;gi=fi+1|0;if(gi>>>0<1073741824){ki=fi<<2;fi=q[a+8>>2]-hi|0;ii=fi>>1;gi=fi>>2>>>0<536870911?ii>>>0>>0?gi:ii:1073741823;fi=0;b:{if(!gi){break b}if(gi>>>0>=1073741824){break a}fi=Mm(gi<<2)}ii=ki+fi|0;q[ii>>2]=q[Vh>>2];Vh=fi+(gi<<2)|0;gi=ii+4|0;if((ji|0)>=1){Cn(fi,hi,ji)}q[a>>2]=fi;q[a+8>>2]=Vh;q[a+4>>2]=gi;if(hi){An(hi)}return}bn();F()}ab(14092);F()}function Dk(a){q[a>>2]=0;q[a+4>>2]=0;o[a+24|0]=1;q[a+16>>2]=0;q[a+20>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+28>>2]=0;q[a+32>>2]=0;q[a+36>>2]=0;q[a+40>>2]=0;q[a+44>>2]=0;q[a+48>>2]=0;q[a+52>>2]=0;q[a+56>>2]=0;q[a+60>>2]=0;q[a+64>>2]=0;q[a+72>>2]=0;q[a+76>>2]=0;q[a+80>>2]=0;q[a+84>>2]=0;q[a+88>>2]=0;q[a+92>>2]=0;q[a+68>>2]=a}function Ek(a,Vh){var li=0,mi=0,ni=0,oi=0,pi=0,qi=0,ri=0,si=0;qi=T-16|0;T=qi;a:{b:{if(Vh){q[a+88>>2]=0;q[a+92>>2]=0;li=a+84|0;mi=q[li>>2];q[li>>2]=0;if(mi){An(mi)}q[a+76>>2]=0;q[a+80>>2]=0;li=a+72|0;mi=q[li>>2];q[li>>2]=0;if(mi){An(mi)}mi=Vh+4|0;li=q[mi>>2];ni=q[Vh>>2];o[qi+15|0]=0;bb(a,li-ni>>2,qi+15|0);ni=Vh+28|0;li=q[ni>>2];oi=q[Vh+24>>2];o[qi+14|0]=0;bb(a+12|0,li-oi>>2,qi+14|0);uk(a+28|0,q[mi>>2]-q[Vh>>2]>>2,14160);mi=q[a+52>>2];oi=q[ni>>2]-q[Vh+24>>2]|0;li=oi>>2;c:{if(q[a+60>>2]-mi>>2>>>0>=li>>>0){break c}if(li>>>0>=1073741824){break b}ri=a+56|0;pi=q[ri>>2];si=li<<2;li=Mm(oi);si=si+li|0;oi=pi-mi|0;pi=oi+li|0;if((oi|0)>=1){Cn(li,mi,oi)}q[a+52>>2]=li;q[a+60>>2]=si;q[ri>>2]=pi;if(!mi){break c}An(mi)}mi=q[a+40>>2];ni=q[ni>>2]-q[Vh+24>>2]|0;li=ni>>2;d:{if(q[a+48>>2]-mi>>2>>>0>=li>>>0){break d}if(li>>>0>=1073741824){break a}oi=a+44|0;ri=q[oi>>2];pi=li<<2;li=Mm(ni);pi=pi+li|0;ni=ri-mi|0;ri=ni+li|0;if((ni|0)>=1){Cn(li,mi,ni)}q[a+40>>2]=li;q[a+48>>2]=pi;q[oi>>2]=ri;if(!mi){break d}An(mi)}o[a+24|0]=1;q[a+64>>2]=Vh}T=qi+16|0;return}ab(14164);F()}ab(14164);F()}function Fk(a){var Vh=0,ti=0,ui=0,vi=0,wi=0,xi=0,yi=0,Ai=0,Bi=0,Ci=0,Di=0,Ei=0,Fi=0;ui=T-32|0;T=ui;xi=a+56|0;q[xi>>2]=q[a+52>>2];yi=a+44|0;q[yi>>2]=q[a+40>>2];Vh=q[a+64>>2];if(q[Vh+28>>2]!=q[Vh+24>>2]){Bi=a+40|0;Ci=a+52|0;Di=a+60|0;Ei=a+48|0;while(1){ti=q[q[Vh+24>>2]+(Ai<<2)>>2];a:{if((ti|0)==-1){break a}q[ui+24>>2]=wi;Vh=q[xi>>2];b:{if((Vh|0)!=q[Di>>2]){q[Vh>>2]=wi;q[xi>>2]=Vh+4;break b}Hk(Ci,ui+24|0)}q[ui+16>>2]=ti;q[ui+8>>2]=0;c:{if(!(q[q[a+12>>2]+(Ai>>>3&536870908)>>2]>>>(Ai&31)&1)){break c}d:{Vh=ti+1|0;Vh=(Vh>>>0)%3|0?Vh:ti+ -2|0;if(!((Vh|0)==-1|q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){Vh=q[q[q[a+64>>2]+12>>2]+(Vh<<2)>>2];if((Vh|0)!=-1){break d}}q[ui+8>>2]=-1;break c}vi=Vh+1|0;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;q[ui+8>>2]=Vh;if((Vh|0)==-1){break c}while(1){q[ui+16>>2]=Vh;e:{vi=Vh+1|0;ti=Vh;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;if(!((Vh|0)==-1|q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){Vh=q[q[q[a+64>>2]+12>>2]+(Vh<<2)>>2];if((Vh|0)!=-1){break e}}q[ui+8>>2]=-1;break c}vi=Vh+1|0;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;q[ui+8>>2]=Vh;if((Vh|0)!=-1){continue}break}}Fi=a+28|0;q[q[Fi>>2]+(ti<<2)>>2]=q[ui+24>>2];Vh=q[yi>>2];f:{if((Vh|0)!=q[Ei>>2]){q[Vh>>2]=q[ui+16>>2];q[yi>>2]=Vh+4;break f}zi(Bi,ui+16|0)}wi=wi+1|0;Vh=q[a+64>>2];g:{vi=q[ui+16>>2];if((vi|0)==-1){break g}ti=vi+((vi>>>0)%3|0?-1:2)|0;if((ti|0)==-1){break g}ti=q[q[Vh+12>>2]+(ti<<2)>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;q[ui+8>>2]=ti;if((ti|0)==-1|(ti|0)==(vi|0)){break a}while(1){Vh=ti+1|0;Vh=(Vh>>>0)%3|0?Vh:ti+ -2|0;h:{if(!(q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){break h}q[ui+24>>2]=wi;Vh=q[xi>>2];i:{if((Vh|0)!=q[Di>>2]){q[Vh>>2]=wi;q[xi>>2]=Vh+4;break i}Hk(Ci,ui+24|0)}wi=wi+1|0;Vh=q[yi>>2];if((Vh|0)!=q[Ei>>2]){q[Vh>>2]=q[ui+8>>2];q[yi>>2]=Vh+4;break h}zi(Bi,ui+8|0)}q[q[Fi>>2]+(q[ui+8>>2]<<2)>>2]=q[ui+24>>2];Vh=q[a+64>>2];ti=q[ui+8>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;if((ti|0)==-1){break g}ti=q[q[Vh+12>>2]+(ti<<2)>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;q[ui+8>>2]=ti;if((ti|0)==-1){break a}if(q[ui+16>>2]!=(ti|0)){continue}break}break a}q[ui+8>>2]=-1}Ai=Ai+1|0;if(Ai>>>0>2]-q[Vh+24>>2]>>2>>>0){continue}break}}T=ui+32|0}function Gk(a,zi){var Gi=0,Hi=0,Ii=0,Ji=0,Ki=0,Li=0;Ii=q[a>>2];Gi=Ii+(zi>>>3&536870908)|0;q[Gi>>2]=q[Gi>>2]|1<<(zi&31);Ki=q[a+64>>2];Ji=(zi|0)==-1;Gi=-1;a:{if(Ji){break a}Hi=zi+1|0;Hi=(Hi>>>0)%3|0?Hi:zi+ -2|0;Gi=-1;if((Hi|0)==-1){break a}Gi=q[q[Ki>>2]+(Hi<<2)>>2]}Hi=q[a+12>>2];Li=(Gi>>>3&536870908)+Hi|0;q[Li>>2]=q[Li>>2]|1<<(Gi&31);b:{c:{if(!Ji){Gi=-1;Ji=((zi>>>0)%3|0?-1:2)+zi|0;if((Ji|0)!=-1){Gi=q[q[Ki>>2]+(Ji<<2)>>2]}Ji=Hi+(Gi>>>3&536870908)|0;q[Ji>>2]=q[Ji>>2]|1<<(Gi&31);zi=q[q[Ki+12>>2]+(zi<<2)>>2];if((zi|0)==-1){break b}o[a+24|0]=0;a=(zi>>>3&536870908)+Ii|0;q[a>>2]=q[a>>2]|1<<(zi&31);a=-1;Gi=-1;Ii=zi+1|0;Ii=(Ii>>>0)%3|0?Ii:zi+ -2|0;if((Ii|0)!=-1){Gi=q[q[Ki>>2]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+4>>2]=zi}if((Vi|0)!=(Zi|0)){zi=0;$i=r[Ui+84|0];aj=Ui+68|0;while(1){_i=w(zi,12);Si=_i+Zi|0;Ui=q[Si>>2];c:{if($i){Vi=Si+8|0;Si=Si+4|0;break c}Xi=q[aj>>2];Vi=Xi+(q[Si+8>>2]<<2)|0;Ui=q[Xi+(Ui<<2)>>2];Si=Xi+(q[Si+4>>2]<<2)|0}Xi=q[Si>>2];Si=Wi+_i|0;q[Si+8>>2]=q[Vi>>2];q[Si+4>>2]=Xi;q[Si>>2]=Ui;zi=zi+1|0;if(zi>>>0>>0){continue}break}}kk(a,Ti);a=q[Ti>>2];if(!a){break a}q[Ti+4>>2]=a;An(a);break a}bn();F()}T=Ti+16|0}function Jk(a,zi,bj){var cj=0,dj=0,ej=0,fj=0,gj=0,hj=0,ij=0,jj=0,kj=0,lj=0,mj=0,nj=0,oj=0,pj=0,qj=0,rj=0;hj=T-16|0;T=hj;gj=w(zi,12)+a|0;ij=gj+12|0;nj=gj+8|0;q[ij>>2]=q[nj>>2];q[hj+8>>2]=(bj|0)==-1?-1:(bj>>>0)/3|0;oj=gj+16|0;pj=a+4|0;ej=bj;while(1){gj=dj;jj=(dj|0)==1;a:{b:{if(!jj){dj=q[hj+8>>2];break b}if((ej|0)==-1){ej=-1;Kk(a,-1);break a}if((ej|0)==-1|(Kk(a,((ej>>>0)%3|0?-1:2)+ej|0)|0)==-1){break a}bj=ej+1|0;cj=(bj>>>0)%3|0?bj:ej+ -2|0;if((cj|0)==-1){break a}bj=cj+1|0;bj=(bj>>>0)%3|0?bj:cj+ -2|0;if((bj|0)==-1){break a}cj=q[q[q[pj>>2]+12>>2]+(bj<<2)>>2];if((cj|0)==-1){break a}bj=cj+1|0;bj=(bj>>>0)%3|0?bj:cj+ -2|0;if((bj|0)==-1){break a}dj=(bj>>>0)/3|0;q[hj+8>>2]=dj}kj=1<<(dj&31);lj=q[a+56>>2]+(dj>>>3&536870908)|0;mj=q[lj>>2];c:{if(kj&mj){break c}fj=0;while(1){q[lj>>2]=kj|mj;cj=q[ij>>2];d:{if((cj|0)!=q[oj>>2]){q[cj>>2]=dj;q[ij>>2]=cj+4;break d}Ck(nj,hj+8|0)}cj=fj+1|0;e:{if(!fj){break e}if(cj&1){if((bj|0)==-1){bj=-1;break e}fj=bj+1|0;bj=(fj>>>0)%3|0?fj:bj+ -2|0;break e}ej=jj?bj:ej;if((bj|0)==-1){bj=-1;break e}if((bj>>>0)%3){bj=bj+ -1|0;break e}bj=bj+2|0}bj=Kk(a,bj);if((bj|0)!=-1){dj=(bj>>>0)/3|0;q[hj+8>>2]=dj;fj=cj;kj=1<<(dj&31);lj=q[a+56>>2]+(dj>>>3&268435452)|0;mj=q[lj>>2];if(!(kj&mj)){continue}}break}if(!(cj&1)|(gj|0)!=1){break c}jj=q[ij>>2]+ -4|0;dj=q[jj>>2];fj=q[a+56>>2]+(dj>>>3&536870908)|0;cj=q[fj>>2];qj=fj,rj=eo(dj)&cj,q[qj>>2]=rj;q[ij>>2]=jj}dj=1;if(!gj){continue}}break}q[((zi<<2)+a|0)+44>>2]=ej;zi=q[ij>>2];ej=q[nj>>2];if((zi|0)!=(ej|0)){fj=zi-ej>>2;cj=q[a+56>>2];bj=0;while(1){gj=q[ej+(bj<<2)>>2];zi=cj+(gj>>>3&536870908)|0;a=q[zi>>2];qj=zi,rj=eo(gj)&a,q[qj>>2]=rj;bj=bj+1|0;if(bj>>>0>>0){continue}break}}T=hj+16|0}function Kk(a,zi){var bj=0,sj=0,tj=0,uj=0,vj=0;sj=-1;uj=-1;tj=-1;a:{b:{if((zi|0)==-1){break b}vj=1;uj=q[q[q[a+4>>2]+12>>2]+(zi<<2)>>2];bj=zi+1|0;bj=(bj>>>0)%3|0?bj:zi+ -2|0;if((bj|0)>=0){tj=(bj>>>0)/3|0;tj=q[(q[q[a>>2]+96>>2]+w(tj,12)|0)+(bj-w(tj,3)<<2)>>2]}c:{if((uj|0)==-1){break c}vj=0;bj=((uj>>>0)%3|0?-1:2)+uj|0;if((bj|0)<0){break c}sj=(bj>>>0)/3|0;sj=q[(q[q[a>>2]+96>>2]+w(sj,12)|0)+(bj-w(sj,3)<<2)>>2]}bj=-1;if((sj|0)!=(tj|0)){break a}tj=-1;d:{zi=((zi>>>0)%3|0?-1:2)+zi|0;if((zi|0)>=0){sj=(zi>>>0)/3|0;sj=q[(q[q[a>>2]+96>>2]+w(sj,12)|0)+(zi-w(sj,3)<<2)>>2];if(vj){break b}break d}sj=-1;if(!vj){break d}break b}zi=uj+1|0;zi=(zi>>>0)%3|0?zi:uj+ -2|0;if((zi|0)<0){break b}tj=q[q[a>>2]+96>>2];a=(zi>>>0)/3|0;tj=q[(tj+w(a,12)|0)+(zi-w(a,3)<<2)>>2]}bj=(sj|0)==(tj|0)?uj:-1}return bj}function Lk(a,zi){var wj=0,xj=0,yj=0,zj=0,Aj=0,Bj=0,Cj=0,Dj=0,Ej=0,Fj=0,Gj=0;xj=T-48|0;T=xj;q[xj+40>>2]=0;q[xj+32>>2]=0;q[xj+36>>2]=0;wj=Mm(8);q[wj+4>>2]=zi;q[wj>>2]=0;zi=wj+8|0;q[xj+40>>2]=zi;q[xj+36>>2]=zi;q[xj+32>>2]=wj;a:{b:{c:{d:{while(1){zi=zi+ -8|0;Bj=q[zi+4>>2];Gj=q[zi>>2];q[xj+36>>2]=zi;if(Gj){q[xj+24>>2]=0;q[xj+16>>2]=0;q[xj+20>>2]=0;Dj=1;zi=q[a>>2];Aj=q[zi+16>>2];zj=q[zi+12>>2];wj=q[zi+20>>2];e:{if((zj|0)<(wj|0)?1:(zj|0)<=(wj|0)?t[zi+8>>2]>Aj>>>0?0:1:0){break e}yj=r[Aj+q[zi>>2]|0];zj=Aj+1|0;if(zj>>>0<1){wj=wj+1|0}q[zi+16>>2]=zj;q[zi+20>>2]=wj;Wm(xj+16|0,yj);if(yj){zj=q[a>>2];Fj=_m(xj+16|0);Cj=q[zj+12>>2];Aj=q[zj+20>>2];Ej=q[zj+16>>2];zi=yj;wj=Ej+zi|0;if(wj>>>0>>0){Aj=Aj+1|0}if((Cj|0)<(Aj|0)?1:(Cj|0)<=(Aj|0)?t[zj+8>>2]>=wj>>>0?0:1:0){break e}Cn(Fj,Ej+q[zj>>2]|0,yj);wj=zj;zj=wj;Aj=q[wj+20>>2];yj=zi+q[wj+16>>2]|0;if(yj>>>0>>0){Aj=Aj+1|0}q[zj+16>>2]=yj;q[wj+20>>2]=Aj}Bj=Mm(24);wj=Bj+4|0;q[wj>>2]=0;q[wj+4>>2]=0;zi=Bj+16|0;q[zi>>2]=0;q[zi+4>>2]=0;q[Bj>>2]=wj;q[Bj+12>>2]=zi;q[xj+8>>2]=Bj;_k(Gj,xj+16|0,xj+8|0);zi=q[xj+8>>2];Dj=0;q[xj+8>>2]=0;if(!zi){break e}Hc(zi+12|0,q[zi+16>>2]);Ic(zi,q[zi+4>>2]);An(zi)}if(o[xj+27|0]<=-1){An(q[xj+16>>2])}if(Dj){break b}}if(!Bj){break b}q[xj+16>>2]=0;if(!Mk(1,xj+16|0,q[a>>2])){break b}zi=0;wj=q[xj+16>>2];if(wj){while(1){if(!Nk(a,Bj)){break b}zi=zi+1|0;if(zi>>>0>>0){continue}break}}q[xj+4>>2]=0;if(!Mk(1,xj+4|0,q[a>>2])){break b}Aj=q[xj+4>>2];if(Aj){Dj=0;while(1){zi=q[xj+36>>2];wj=q[xj+40>>2];f:{if(zi>>>0>>0){q[zi+4>>2]=0;q[zi>>2]=Bj;q[xj+36>>2]=q[xj+36>>2]+8;break f}Cj=q[xj+32>>2];Fj=zi-Cj|0;zi=Fj>>3;Ej=zi+1|0;if(Ej>>>0>=536870912){break d}zj=zi<<3;yj=wj-Cj|0;wj=yj>>2;yj=yj>>3>>>0<268435455?wj>>>0>>0?Ej:wj:536870911;zi=0;g:{if(!yj){break g}if(yj>>>0>=536870912){break c}zi=Mm(yj<<3)}wj=zj+zi|0;q[wj+4>>2]=0;q[wj>>2]=Bj;yj=zi+(yj<<3)|0;wj=wj+8|0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r[ek+1|0];ek=ek+1|0;ak=ak+1|0;if((bk|0)==r[ak|0]){continue}break}break d}if(!fk){break e}if(cm(ak?bk:$j,ek,fk)){break c}}ik=q[ck>>2];a=1}if((gk|0)>-1){break b}}An(q[$j>>2])}if(a>>>0>3){break a}f:{switch(a-1|0){case 0:case 1:break a;default:break f}}ck=ck+4|0;if((hk|0)!=(ck|0)){continue}break}}ik=0}T=$j+16|0;return ik}function Qk(a,zi){var Vj=0,lk=0,mk=0;lk=q[zi>>2];if(!lk){return}Vj=a+28|0;mk=q[Vj>>2];if(mk>>>0>2]){q[zi>>2]=0;q[mk>>2]=lk;q[Vj>>2]=q[Vj>>2]+4;return}Rk(a+24|0,zi)}function Rk(a,zi){var nk=0,ok=0,pk=0,qk=0,rk=0;a:{b:{c:{pk=q[a>>2];qk=q[a+4>>2]-pk>>2;nk=qk+1|0;if(nk>>>0<1073741824){pk=q[a+8>>2]-pk|0;rk=pk>>1;nk=pk>>2>>>0<536870911?rk>>>0>>0?nk:rk:1073741823;if(nk){if(nk>>>0>=1073741824){break c}ok=Mm(nk<<2)}pk=q[zi>>2];q[zi>>2]=0;zi=(qk<<2)+ok|0;q[zi>>2]=pk;pk=(nk<<2)+ok|0;qk=zi+4|0;nk=q[a+4>>2];ok=q[a>>2];if((nk|0)==(ok|0)){break b}while(1){nk=nk+ -4|0;rk=q[nk>>2];q[nk>>2]=0;zi=zi+ -4|0;q[zi>>2]=rk;if((nk|0)!=(ok|0)){continue}break}ok=q[a+4>>2];nk=q[a>>2];break a}bn();F()}ab(14300);F()}nk=ok}q[a>>2]=zi;q[a+8>>2]=pk;q[a+4>>2]=qk;if((nk|0)!=(ok|0)){while(1){ok=ok+ -4|0;a=q[ok>>2];q[ok>>2]=0;if(a){Hc(a+12|0,q[a+16>>2]);Ic(a,q[a+4>>2]);An(a)}if((nk|0)!=(ok|0)){continue}break}}if(nk){An(nk)}}function Sk(a,zi,sk,tk){var uk=0,vk=0,wk=0,xk=0;uk=T-16|0;T=uk;xk=a;vk=ph(zi,uk+12|0,sk);sk=q[vk>>2];if(sk){zi=0}else{sk=Mm(32);Rm(sk+16|0,q[tk>>2]);q[sk+28>>2]=0;q[sk+8>>2]=q[uk+12>>2];q[sk>>2]=0;q[sk+4>>2]=0;q[vk>>2]=sk;tk=sk;wk=q[q[zi>>2]>>2];if(wk){q[zi>>2]=wk;tk=q[vk>>2]}nh(q[zi+4>>2],tk);zi=zi+8|0;q[zi>>2]=q[zi>>2]+1;zi=1}o[xk+4|0]=zi;q[a>>2]=sk;T=uk+16|0}function Tk(a,zi){var sk=0,tk=0,yk=0;sk=q[zi+4>>2];a:{if(!sk){tk=q[zi+8>>2];if(q[tk>>2]==(zi|0)){break a}yk=zi+8|0;while(1){sk=q[yk>>2];yk=sk+8|0;tk=q[sk+8>>2];if((sk|0)!=q[tk>>2]){continue}break}break a}while(1){tk=sk;sk=q[sk>>2];if(sk){continue}break}}if(q[a>>2]==(zi|0)){q[a>>2]=tk}tk=a+8|0;q[tk>>2]=q[tk>>2]+ -1;$k(q[a+4>>2],zi);a=q[zi+28>>2];if(a){q[zi+32>>2]=a;An(a)}if(o[zi+27|0]<=-1){An(q[zi+16>>2])}An(zi)}function Uk(a,zi,zk){var Ak=0,Bk=0,Ck=0,Dk=0,Ek=0;Ak=Mm(40);o[a+8|0]=0;q[a+4>>2]=zi+4;q[a>>2]=Ak;zi=zk+8|0;q[Ak+24>>2]=q[zi>>2];Bk=q[zk+4>>2];q[Ak+16>>2]=q[zk>>2];q[Ak+20>>2]=Bk;q[zk>>2]=0;q[zk+4>>2]=0;q[zi>>2]=0;q[Ak+36>>2]=0;q[Ak+28>>2]=0;q[Ak+32>>2]=0;Ck=zk+16|0;Bk=q[Ck>>2];zi=q[zk+12>>2];Dk=Bk-zi|0;if(Dk){zi=Ak+28|0;Ha(zi,Dk);Bk=q[Ck>>2];Ek=q[zi>>2];zi=q[zk+12>>2]}Cn(Ek,zi,Bk-zi|0);o[a+8|0]=1}function Vk(a,zi,zk){var Fk=0;Fk=a+4|0;a=fk(a,zi);a:{if((Fk|0)==(a|0)){break a}zi=q[a+32>>2];a=q[a+28>>2];if((zi-a|0)!=4){break a}q[zk>>2]=r[a|0]|r[a+1|0]<<8|(r[a+2|0]<<16|r[a+3|0]<<24)}}function Wk(a,zi,zk){var Gk=0,Hk=0,Ik=0,Jk=0;a:{zi=fk(a,zi);b:{if((zi|0)==(a+4|0)){break b}a=q[zi+28>>2];Gk=q[zi+32>>2];if((a|0)==(Gk|0)){break b}a=Gk-a|0;if(a&3){break b}Gk=a>>>2;Jk=zk+4|0;Hk=q[Jk>>2];a=q[zk>>2];Ik=Hk-a>>2;c:{if(Gk>>>0>Ik>>>0){Fa(zk,Gk-Ik|0);Hk=q[Jk>>2];a=q[zk>>2];break c}if(Gk>>>0>=Ik>>>0){break c}Hk=(Gk<<2)+a|0;q[zk+4>>2]=Hk}if((a|0)==(Hk|0)){break a}zk=a;a=q[zi+28>>2];Cn(zk,a,q[zi+32>>2]-a|0)}return}cn();F()}function Xk(a,zi,zk){var Kk=0;Kk=a+4|0;a=fk(a,zi);a:{if((Kk|0)==(a|0)){break a}zi=q[a+32>>2];a=q[a+28>>2];if((zi-a|0)!=8){break a}zi=r[a+4|0]|r[a+5|0]<<8|(r[a+6|0]<<16|r[a+7|0]<<24);q[zk>>2]=r[a|0]|r[a+1|0]<<8|(r[a+2|0]<<16|r[a+3|0]<<24);q[zk+4>>2]=zi}}function Yk(a,zi,zk){var Lk=0,Mk=0,Nk=0;Lk=a+4|0;a=fk(a,zi);a:{if((Lk|0)==(a|0)){break a}zi=a+32|0;Lk=q[zi>>2];Mk=q[a+28>>2];if((Lk|0)==(Mk|0)){break a}Wm(zk,Lk-Mk|0);zk=_m(zk);a=q[a+28>>2];Cn(zk,a,q[zi>>2]-a|0);Nk=1}return Nk}function Zk(a,zi,zk){var Ok=0,Pk=0,Qk=0,Rk=0;Ok=T+ -64|0;T=Ok;Pk=fk(a,zi);if((Pk|0)!=(a+4|0)){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[Sk+12|0]=r[zk+12|0];o[zk+12|0]=1;o[zi+12|0]=1;zi=q[zk+4>>2];a=q[zi>>2];q[zk+4>>2]=a;if(a){q[a+8>>2]=zk}q[zi+8>>2]=q[zk+8>>2];a=q[zk+8>>2];q[((zk|0)==q[a>>2]?a:a+4|0)>>2]=zi;q[zi>>2]=zk;q[zk+8>>2]=zi}function al(a){q[a>>2]=14380;Dn(a+4|0,0,80);return a}function bl(a,zi){var Zk=0;Zk=-1;a:{if((zi|0)==-1|(zi|0)>4){break a}zi=w(zi,12)+a|0;a=q[zi+20>>2];if((q[zi+24>>2]-a|0)<1){break a}Zk=q[a>>2]}return Zk}function cl(a){var zi=0,_k=0;zi=q[a+20>>2];a:{if((q[a+24>>2]-zi|0)<1){break a}zi=q[zi>>2];if((zi|0)==-1){break a}_k=q[q[a+8>>2]+(zi<<2)>>2]}return _k}function dl(a,$k){var al=0,bl=0,cl=0;al=q[a+8>>2];a=q[a+12>>2];a:{if((al|0)==(a|0)){break a}cl=a-al>>2;a=0;while(1){bl=q[(a<<2)+al>>2];if(q[bl+60>>2]==($k|0)){break a}a=a+1|0;if(a>>>0>>0){continue}break}bl=0}return bl}function el(a,$k){var dl=0,el=0;dl=q[a+8>>2];a=q[a+12>>2];if((dl|0)!=(a|0)){el=a-dl>>2;a=0;while(1){if(q[q[(a<<2)+dl>>2]+60>>2]==($k|0)){return a}a=a+1|0;if(a>>>0>>0){continue}break}}return-1}function fl(a,$k){var fl=0,gl=0,hl=0,il=0,jl=0;fl=T-16|0;T=fl;gl=a+12|0;hl=q[gl>>2];il=q[a+8>>2];jl=q[$k>>2];q[$k>>2]=0;q[fl+8>>2]=jl;n[q[q[a>>2]+8>>2]](a,hl-il>>2,fl+8|0);$k=q[fl+8>>2];q[fl+8>>2]=0;if($k){Hb($k)}T=fl+16|0;return(q[gl>>2]-q[a+8>>2]>>2)+ -1|0}function gl(a,$k,kl){a=a|0;$k=$k|0;kl=kl|0;var ll=0,ml=0,nl=0,ol=0,pl=0,ql=0;ol=T-16|0;T=ol;q[ol+12>>2]=$k;pl=a+8|0;ll=q[a+12>>2];ql=q[a+8>>2];ml=ll-ql>>2;a:{if((ml|0)>($k|0)){break a}nl=$k+1|0;if(nl>>>0>ml>>>0){hl(pl,nl-ml|0);break a}if(nl>>>0>=ml>>>0){break a}ml=ql+(nl<<2)|0;if((ml|0)!=(ll|0)){while(1){ll=ll+ -4|0;nl=q[ll>>2];q[ll>>2]=0;if(nl){Hb(nl)}if((ll|0)!=(ml|0)){continue}break}}q[a+12>>2]=ml}ll=q[q[kl>>2]+56>>2];b:{if((ll|0)>4){break b}ll=w(ll,12)+a|0;ml=ll+24|0;a=q[ml>>2];if((a|0)!=q[ll+28>>2]){q[a>>2]=$k;q[ml>>2]=a+4;break b}il(ll+20|0,ol+12|0)}$k=q[kl>>2];a=q[ol+12>>2];q[$k+60>>2]=a;ll=q[pl>>2];q[kl>>2]=0;kl=ll+(a<<2)|0;a=q[kl>>2];q[kl>>2]=$k;if(a){Hb(a)}T=ol+16|0}function hl(a,$k){var kl=0,rl=0,sl=0,tl=0,ul=0,vl=0,wl=0,xl=0,yl=0;rl=q[a+8>>2];sl=a+4|0;kl=q[sl>>2];if(rl-kl>>2>>>0>=$k>>>0){a=$k<<2;xl=sl,yl=Dn(kl,0,a)+a|0,q[xl>>2]=yl;return}a:{sl=q[a>>2];tl=kl-sl>>2;ul=tl+$k|0;if(ul>>>0<1073741824){tl=tl<<2;rl=rl-sl|0;wl=rl>>1;rl=rl>>2>>>0<536870911?wl>>>0