@antv/g-webgpu 2.0.56 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +4 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +10 -10
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +6 -9
- package/types/index.d.ts +1 -3
- package/types/index.d.ts.map +1 -1
package/dist/index.umd.min.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g-webgpu
|
|
3
3
|
* @description A renderer implemented by WebGPU
|
|
4
|
-
* @version 2.
|
|
5
|
-
* @date 12/
|
|
4
|
+
* @version 2.1.1
|
|
5
|
+
* @date 12/24/2025, 11:58:24 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
9
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,function(e,t){"use strict";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 n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function i(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function d(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function
|
|
9
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,function(e,t){"use strict";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 n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function i(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function d(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function _(e,t,r){return t=c(t),d(e,f()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function v(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function R(e,t){if(e){if("string"==typeof e)return E(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}}function T(e){return function(e){if(Array.isArray(e))return E(e)}(e)||v(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;a.length>n;n++)-1===t.indexOf(r=a[n])&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},m.apply(null,arguments)}function g(e,t,r,n){var i=m(c(1&n?e.prototype:e),t,r);return 2&n&&"function"==typeof i?function(e){return i.apply(r,e)}:i}function S(e){if(Array.isArray(e))return e}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e,t){return S(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||R(e,t)||y()}function P(e,t){this.v=e,this.k=t}function N(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}N=function(e,t,r,n){function a(t,r){N(e,t,function(e){return this._invoke(t,r,e)})}t?i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},N(e,t,r,n)}function M(){
|
|
10
10
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
11
|
-
var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var u=Object.create((n&&n.prototype instanceof s?n:s).prototype);return N(u,"_invoke",function(r,n,i){var a,s,u,l=0,c=i||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,r){return a=t,s=0,u=e,d.n=r,o}};function h(r,n){for(s=r,u=n,t=0;!f&&l&&!i&&c.length>t;t++){var i,a=c[t],h=d.p,_=a[2];r>3?(i=_===n)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):h>=a[0]&&((i=2>r&&a[1]>h)?(s=0,d.v=n,d.n=a[1]):_>h&&(i=3>r||a[0]>n||n>_)&&(a[4]=r,a[5]=n,d.n=_,s=0))}if(i||r>1)return o;throw f=!0,n}return function(i,c,_){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&h(c,_),s=c,u=_;(t=2>s?e:u)||!f;){a||(s?3>s?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(l=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,2>s&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),2>s&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(f=0>d.n)?u:r.call(n,d))!==o)break}catch(t){a=e,s=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,i,a),!0),u}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(N(t={},n,function(){return this}),t),f=l.prototype=s.prototype=Object.create(c);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,N(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,N(f,"constructor",l),N(l,"constructor",u),u.displayName="GeneratorFunction",N(l,i,"GeneratorFunction"),N(f),N(f,i,"Generator"),N(f,n,function(){return this}),N(f,"toString",function(){return"[object Generator]"}),(M=function(){return{w:a,m:d}})()}function O(e,t){function r(n,i,a,o){try{var s=e[n](i),u=s.value;return u instanceof P?t.resolve(u.v).then(function(e){r("next",e,a,o)},function(e){r("throw",e,a,o)}):t.resolve(u).then(function(e){s.value=e,a(s)},function(e){return r("throw",e,a,o)})}catch(e){o(e)}}var n;this.next||(N(O.prototype),N(O.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),N(this,"_invoke",function(e,i,a){function o(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(o,o):o()},!0)}function I(e,t,r,n,i){return new O(M().w(e,t,r,n),i||Promise)}function x(e,t,r,n,i){var a=I(e,t,r,n,i);return a.next().then(function(e){return e.done?e.value:a.next()})}function B(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function D(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(r(e)+" is not iterable")}function b(){var e=M(),t=e.m(b),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var i={throw:1,return:2,break:3,continue:3};function a(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,i[e],t)},delegateYield:function(e,i,a){return t.resultName=i,r(n.d,D(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,i){n.p=t.prev,n.n=t.next;try{return e(r,i)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(b=function(){return{wrap:function(t,r,n,i){return e.w(a(t),r,n,i&&i.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new P(e,t)},AsyncIterator:O,async:function(e,t,r,i,o){return(n(t)?I:x)(a(e),t,r,i,o)},keys:B,values:D}})()}function L(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function F(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){L(a,n,i,o,s,"next",e)}function s(e){L(a,n,i,o,s,"throw",e)}o(void 0)})}}function U(e){return null==e}function k(e){return"string"==typeof e}var w=function(e,t,r){return t>e?t:e>r?r:e};function G(e){return"number"==typeof e}var V=1e-6,X="undefined"!=typeof Float32Array?Float32Array:Array;function W(){var e=new X(16);return X!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function H(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function z(e,t,r,n,i,a,o,s,u,l,c,f,d,h,_,p){var E=new X(16);return E[0]=e,E[1]=t,E[2]=r,E[3]=n,E[4]=i,E[5]=a,E[6]=o,E[7]=s,E[8]=u,E[9]=l,E[10]=c,E[11]=f,E[12]=d,E[13]=h,E[14]=_,E[15]=p,E}function Y(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function K(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],f=t[9],d=t[10],h=t[11],_=t[12],p=t[13],E=t[14],v=t[15],R=r*s-n*o,m=r*u-i*o,T=r*l-a*o,g=n*u-i*s,A=n*l-a*s,y=i*l-a*u,S=c*p-f*_,C=c*E-d*_,P=c*v-h*_,N=f*E-d*p,M=f*v-h*p,O=d*v-h*E,I=R*O-m*M+T*N+g*P-A*C+y*S;return I?(e[0]=(s*O-u*M+l*N)*(I=1/I),e[1]=(i*M-n*O-a*N)*I,e[2]=(p*y-E*A+v*g)*I,e[3]=(d*A-f*y-h*g)*I,e[4]=(u*P-o*O-l*C)*I,e[5]=(r*O-i*P+a*C)*I,e[6]=(E*T-_*y-v*m)*I,e[7]=(c*y-d*T+h*m)*I,e[8]=(o*M-s*P+l*S)*I,e[9]=(n*P-r*M-a*S)*I,e[10]=(_*A-p*T+v*R)*I,e[11]=(f*T-c*A-h*R)*I,e[12]=(s*C-o*N-u*S)*I,e[13]=(r*N-n*C+i*S)*I,e[14]=(p*m-_*g-E*R)*I,e[15]=(c*g-f*m+d*R)*I,e):null}function j(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],d=t[9],h=t[10],_=t[11],p=t[12],E=t[13],v=t[14],R=t[15],m=r[0],T=r[1],g=r[2],A=r[3];return e[0]=m*n+T*s+g*f+A*p,e[1]=m*i+T*u+g*d+A*E,e[2]=m*a+T*l+g*h+A*v,e[3]=m*o+T*c+g*_+A*R,e[4]=(m=r[4])*n+(T=r[5])*s+(g=r[6])*f+(A=r[7])*p,e[5]=m*i+T*u+g*d+A*E,e[6]=m*a+T*l+g*h+A*v,e[7]=m*o+T*c+g*_+A*R,e[8]=(m=r[8])*n+(T=r[9])*s+(g=r[10])*f+(A=r[11])*p,e[9]=m*i+T*u+g*d+A*E,e[10]=m*a+T*l+g*h+A*v,e[11]=m*o+T*c+g*_+A*R,e[12]=(m=r[12])*n+(T=r[13])*s+(g=r[14])*f+(A=r[15])*p,e[13]=m*i+T*u+g*d+A*E,e[14]=m*a+T*l+g*h+A*v,e[15]=m*o+T*c+g*_+A*R,e}function Z(e,t,r){var n=r[0],i=r[1],a=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function q(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Q(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=n+n,u=i+i,l=a+a,c=n*s,f=n*u,d=n*l,h=i*u,_=i*l,p=a*l,E=o*s,v=o*u,R=o*l;return e[0]=1-(h+p),e[1]=f+R,e[2]=d-v,e[3]=0,e[4]=f-R,e[5]=1-(c+p),e[6]=_+E,e[7]=0,e[8]=d+v,e[9]=_-E,e[10]=1-(c+h),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function $(e,t){var r=t[0],n=t[1],i=t[2],a=t[4],o=t[5],s=t[6],u=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(a*a+o*o+s*s),e[2]=Math.sqrt(u*u+l*l+c*c),e}function J(e,t,r,n,i){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o}else e[10]=-1,e[14]=-2*n;return e}function ee(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e}function te(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}var re,ne=j,ie=Object.freeze({__proto__:null,add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],f=t[9],d=t[10],h=t[11],_=t[12],p=t[13],E=t[14],v=t[15],R=r*s-n*o,m=r*u-i*o,T=r*l-a*o,g=n*u-i*s,A=n*l-a*s,y=i*l-a*u,S=c*p-f*_,C=c*E-d*_,P=c*v-h*_,N=f*E-d*p,M=f*v-h*p,O=d*v-h*E;return e[0]=s*O-u*M+l*N,e[1]=i*M-n*O-a*N,e[2]=p*y-E*A+v*g,e[3]=d*A-f*y-h*g,e[4]=u*P-o*O-l*C,e[5]=r*O-i*P+a*C,e[6]=E*T-_*y-v*m,e[7]=c*y-d*T+h*m,e[8]=o*M-s*P+l*S,e[9]=n*P-r*M-a*S,e[10]=_*A-p*T+v*R,e[11]=f*T-c*A-h*R,e[12]=s*C-o*N-u*S,e[13]=r*N-n*C+i*S,e[14]=p*m-_*g-E*R,e[15]=c*g-f*m+d*R,e},clone:function(e){var t=new X(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy:H,create:W,decompose:function(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var i=n[0],a=n[1],o=n[2],s=n[4],u=n[5],l=n[6],c=n[8],f=n[9],d=n[10];r[0]=Math.sqrt(i*i+a*a+o*o),r[1]=Math.sqrt(s*s+u*u+l*l),r[2]=Math.sqrt(c*c+f*f+d*d);var h=1/r[0],_=1/r[1],p=1/r[2],E=i*h,v=a*_,R=o*p,m=s*h,T=u*_,g=l*p,A=c*h,y=f*_,S=d*p,C=E+T+S,P=0;return C>0?(e[3]=.25*(P=2*Math.sqrt(C+1)),e[0]=(g-y)/P,e[1]=(A-R)/P,e[2]=(v-m)/P):E>T&&E>S?(e[3]=(g-y)/(P=2*Math.sqrt(1+E-T-S)),e[0]=.25*P,e[1]=(v+m)/P,e[2]=(A+R)/P):T>S?(e[3]=(A-R)/(P=2*Math.sqrt(1+T-E-S)),e[0]=(v+m)/P,e[1]=.25*P,e[2]=(g+y)/P):(e[3]=(v-m)/(P=2*Math.sqrt(1+S-E-T)),e[0]=(A+R)/P,e[1]=(g+y)/P,e[2]=.25*P),e},determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[4],a=e[5],o=e[6],s=e[8],u=e[9],l=e[10],c=e[12],f=e[13],d=e[14],h=t*a-r*i,_=t*o-n*i,p=r*o-n*a,E=s*f-u*c,v=s*d-l*c,R=u*d-l*f;return e[7]*(t*R-r*v+n*E)-e[3]*(i*R-a*v+o*E)+e[15]*(s*p-u*_+l*h)-e[11]*(c*p-f*_+d*h)},equals:function(e,t){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],c=e[8],f=e[9],d=e[10],h=e[11],_=e[12],p=e[13],E=e[14],v=e[15],R=t[0],m=t[1],T=t[2],g=t[3],A=t[4],y=t[5],S=t[6],C=t[7],P=t[8],N=t[9],M=t[10],O=t[11],I=t[12],x=t[13],B=t[14],D=t[15];return!(Math.abs(r-R)>V*Math.max(1,Math.abs(r),Math.abs(R))||Math.abs(n-m)>V*Math.max(1,Math.abs(n),Math.abs(m))||Math.abs(i-T)>V*Math.max(1,Math.abs(i),Math.abs(T))||Math.abs(a-g)>V*Math.max(1,Math.abs(a),Math.abs(g))||Math.abs(o-A)>V*Math.max(1,Math.abs(o),Math.abs(A))||Math.abs(s-y)>V*Math.max(1,Math.abs(s),Math.abs(y))||Math.abs(u-S)>V*Math.max(1,Math.abs(u),Math.abs(S))||Math.abs(l-C)>V*Math.max(1,Math.abs(l),Math.abs(C))||Math.abs(c-P)>V*Math.max(1,Math.abs(c),Math.abs(P))||Math.abs(f-N)>V*Math.max(1,Math.abs(f),Math.abs(N))||Math.abs(d-M)>V*Math.max(1,Math.abs(d),Math.abs(M))||Math.abs(h-O)>V*Math.max(1,Math.abs(h),Math.abs(O))||Math.abs(_-I)>V*Math.max(1,Math.abs(_),Math.abs(I))||Math.abs(p-x)>V*Math.max(1,Math.abs(p),Math.abs(x))||Math.abs(E-B)>V*Math.max(1,Math.abs(E),Math.abs(B))||Math.abs(v-D)>V*Math.max(1,Math.abs(v),Math.abs(D)))},exactEquals:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},frob:function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])},fromQuat:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,d=i*o,h=i*s,_=i*u,p=a*o,E=a*s,v=a*u;return e[0]=1-f-_,e[1]=c+v,e[2]=d-E,e[3]=0,e[4]=c-v,e[5]=1-l-_,e[6]=h+p,e[7]=0,e[8]=d+E,e[9]=h-p,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromQuat2:function(e,t){var r=new X(3),n=-t[0],i=-t[1],a=-t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=n*n+i*i+a*a+o*o;return f>0?(r[0]=2*(s*o+c*n+u*a-l*i)/f,r[1]=2*(u*o+c*i+l*n-s*a)/f,r[2]=2*(l*o+c*a+s*i-u*n)/f):(r[0]=2*(s*o+c*n+u*a-l*i),r[1]=2*(u*o+c*i+l*n-s*a),r[2]=2*(l*o+c*a+s*i-u*n)),Q(e,t,r),e},fromRotation:function(e,t,r){var n,i,a,o=r[0],s=r[1],u=r[2],l=Math.sqrt(o*o+s*s+u*u);return V>l?null:(o*=l=1/l,s*=l,u*=l,n=Math.sin(t),e[0]=o*o*(a=1-(i=Math.cos(t)))+i,e[1]=s*o*a+u*n,e[2]=u*o*a-s*n,e[3]=0,e[4]=o*s*a-u*n,e[5]=s*s*a+i,e[6]=u*s*a+o*n,e[7]=0,e[8]=o*u*a+s*n,e[9]=s*u*a-o*n,e[10]=u*u*a+i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromRotationTranslation:Q,fromRotationTranslationScale:function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,d=i*l,h=i*c,_=a*l,p=a*c,E=o*c,v=s*u,R=s*l,m=s*c,T=n[0],g=n[1],A=n[2];return e[0]=(1-(_+E))*T,e[1]=(d+m)*T,e[2]=(h-R)*T,e[3]=0,e[4]=(d-m)*g,e[5]=(1-(f+E))*g,e[6]=(p+v)*g,e[7]=0,e[8]=(h+R)*A,e[9]=(p-v)*A,e[10]=(1-(f+_))*A,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},fromRotationTranslationScaleOrigin:function(e,t,r,n,i){var a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,d=a*l,h=a*c,_=a*f,p=o*c,E=o*f,v=s*f,R=u*l,m=u*c,T=u*f,g=n[0],A=n[1],y=n[2],S=i[0],C=i[1],P=i[2],N=(1-(p+v))*g,M=(h+T)*g,O=(_-m)*g,I=(h-T)*A,x=(1-(d+v))*A,B=(E+R)*A,D=(_+m)*y,b=(E-R)*y,L=(1-(d+p))*y;return e[0]=N,e[1]=M,e[2]=O,e[3]=0,e[4]=I,e[5]=x,e[6]=B,e[7]=0,e[8]=D,e[9]=b,e[10]=L,e[11]=0,e[12]=r[0]+S-(N*S+I*C+D*P),e[13]=r[1]+C-(M*S+x*C+b*P),e[14]=r[2]+P-(O*S+B*C+L*P),e[15]=1,e},fromScaling:function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromTranslation:q,fromValues:z,fromXRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},frustum:function(e,t,r,n,i,a,o){var s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},getRotation:function(e,t){var r=new X(3);$(r,t);var n=1/r[0],i=1/r[1],a=1/r[2],o=t[0]*n,s=t[1]*i,u=t[2]*a,l=t[4]*n,c=t[5]*i,f=t[6]*a,d=t[8]*n,h=t[9]*i,_=t[10]*a,p=o+c+_,E=0;return p>0?(e[3]=.25*(E=2*Math.sqrt(p+1)),e[0]=(f-h)/E,e[1]=(d-u)/E,e[2]=(s-l)/E):o>c&&o>_?(e[3]=(f-h)/(E=2*Math.sqrt(1+o-c-_)),e[0]=.25*E,e[1]=(s+l)/E,e[2]=(d+u)/E):c>_?(e[3]=(d-u)/(E=2*Math.sqrt(1+c-o-_)),e[0]=(s+l)/E,e[1]=.25*E,e[2]=(f+h)/E):(e[3]=(s-l)/(E=2*Math.sqrt(1+_-o-c)),e[0]=(d+u)/E,e[1]=(f+h)/E,e[2]=.25*E),e},getScaling:$,getTranslation:function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},identity:Y,invert:K,lookAt:function(e,t,r,n){var i,a,o,s,u,l,c,f,d,h,_=t[0],p=t[1],E=t[2],v=n[0],R=n[1],m=n[2],T=r[0],g=r[1],A=r[2];return V>Math.abs(_-T)&&V>Math.abs(p-g)&&V>Math.abs(E-A)?Y(e):(d=E-A,(h=Math.sqrt((i=R*(d*=h=1/Math.sqrt((c=_-T)*c+(f=p-g)*f+d*d))-m*(f*=h))*i+(a=m*(c*=h)-v*d)*a+(o=v*f-R*c)*o))?(i*=h=1/h,a*=h,o*=h):(i=0,a=0,o=0),(h=Math.sqrt((s=f*o-d*a)*s+(u=d*i-c*o)*u+(l=c*a-f*i)*l))?(s*=h=1/h,u*=h,l*=h):(s=0,u=0,l=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=a,e[5]=u,e[6]=f,e[7]=0,e[8]=o,e[9]=l,e[10]=d,e[11]=0,e[12]=-(i*_+a*p+o*E),e[13]=-(s*_+u*p+l*E),e[14]=-(c*_+f*p+d*E),e[15]=1,e)},mul:ne,multiply:j,multiplyScalar:function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},multiplyScalarAndAdd:function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},ortho:ee,orthoNO:ee,orthoZO:function(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=a*l,e[15]=1,e},perspective:J,perspectiveFromFieldOfView:function(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},perspectiveNO:J,perspectiveZO:function(e,t,r,n,i){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var o=1/(n-i);e[10]=i*o,e[14]=i*n*o}else e[10]=-1,e[14]=-n;return e},rotate:function(e,t,r,n){var i,a,o,s,u,l,c,f,d,h,_,p,E,v,R,m,T,g,A,y,S,C,P,N,M=n[0],O=n[1],I=n[2],x=Math.sqrt(M*M+O*O+I*I);return V>x?null:(M*=x=1/x,O*=x,I*=x,i=Math.sin(r),u=t[1],l=t[2],c=t[3],d=t[5],h=t[6],_=t[7],E=t[9],v=t[10],R=t[11],A=M*O*(o=1-(a=Math.cos(r)))-I*i,y=O*O*o+a,S=I*O*o+M*i,C=M*I*o+O*i,P=O*I*o-M*i,N=I*I*o+a,e[0]=(s=t[0])*(m=M*M*o+a)+(f=t[4])*(T=O*M*o+I*i)+(p=t[8])*(g=I*M*o-O*i),e[1]=u*m+d*T+E*g,e[2]=l*m+h*T+v*g,e[3]=c*m+_*T+R*g,e[4]=s*A+f*y+p*S,e[5]=u*A+d*y+E*S,e[6]=l*A+h*y+v*S,e[7]=c*A+_*y+R*S,e[8]=s*C+f*P+p*N,e[9]=u*C+d*P+E*N,e[10]=l*C+h*P+v*N,e[11]=c*C+_*P+R*N,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[4],o=t[5],s=t[6],u=t[7],l=t[8],c=t[9],f=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+l*n,e[5]=o*i+c*n,e[6]=s*i+f*n,e[7]=u*i+d*n,e[8]=l*i-a*n,e[9]=c*i-o*n,e[10]=f*i-s*n,e[11]=d*i-u*n,e},rotateY:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],u=t[3],l=t[8],c=t[9],f=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-l*n,e[1]=o*i-c*n,e[2]=s*i-f*n,e[3]=u*i-d*n,e[8]=a*n+l*i,e[9]=o*n+c*i,e[10]=s*n+f*i,e[11]=u*n+d*i,e},rotateZ:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],u=t[3],l=t[4],c=t[5],f=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+l*n,e[1]=o*i+c*n,e[2]=s*i+f*n,e[3]=u*i+d*n,e[4]=l*i-a*n,e[5]=c*i-o*n,e[6]=f*i-s*n,e[7]=d*i-u*n,e},scale:Z,set:function(e,t,r,n,i,a,o,s,u,l,c,f,d,h,_,p,E){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a,e[5]=o,e[6]=s,e[7]=u,e[8]=l,e[9]=c,e[10]=f,e[11]=d,e[12]=h,e[13]=_,e[14]=p,e[15]=E,e},str:function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},sub:te,subtract:te,targetTo:function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=n[0],u=n[1],l=n[2],c=i-r[0],f=a-r[1],d=o-r[2],h=c*c+f*f+d*d;h>0&&(c*=h=1/Math.sqrt(h),f*=h,d*=h);var _=u*d-l*f,p=l*c-s*d,E=s*f-u*c;return(h=_*_+p*p+E*E)>0&&(_*=h=1/Math.sqrt(h),p*=h,E*=h),e[0]=_,e[1]=p,e[2]=E,e[3]=0,e[4]=f*E-d*p,e[5]=d*_-c*E,e[6]=c*p-f*_,e[7]=0,e[8]=c,e[9]=f,e[10]=d,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},translate:function(e,t,r){var n,i,a,o,s,u,l,c,f,d,h,_,p=r[0],E=r[1],v=r[2];return t===e?(e[12]=t[0]*p+t[4]*E+t[8]*v+t[12],e[13]=t[1]*p+t[5]*E+t[9]*v+t[13],e[14]=t[2]*p+t[6]*E+t[10]*v+t[14],e[15]=t[3]*p+t[7]*E+t[11]*v+t[15]):(i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],d=t[9],h=t[10],_=t[11],e[0]=n=t[0],e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e[6]=l,e[7]=c,e[8]=f,e[9]=d,e[10]=h,e[11]=_,e[12]=n*p+s*E+f*v+t[12],e[13]=i*p+u*E+d*v+t[13],e[14]=a*p+l*E+h*v+t[14],e[15]=o*p+c*E+_*v+t[15]),e},transpose:function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}});function ae(e,t,r){var n=new X(3);return n[0]=e,n[1]=t,n[2]=r,n}re=new X(3),X!=Float32Array&&(re[0]=0,re[1]=0,re[2]=0);var oe=function(e,t){return oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},oe(e,t)};function se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function r(){this.constructor=e}oe(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var ue=function(){return ue=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ue.apply(this,arguments)};function le(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})}function ce(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function fe(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function de(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function he(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function _e(e,t,r,n,i,a,o,s,u,l){var c,f,d,h,_,p=e,E=t,v=r,R=n,m=s,T=u,g=120*Math.PI/180,A=Math.PI/180*(+i||0),y=[];if(l)f=l[0],d=l[1],h=l[2],_=l[3];else{E=(c=he(p,E,-A)).y;var S=((p=c.x)-(m=(c=he(m,T,-A)).x))/2,C=(E-(T=c.y))/2,P=S*S/(v*v)+C*C/(R*R);P>1&&(v*=P=Math.sqrt(P),R*=P);var N=v*v,M=R*R,O=(a===o?-1:1)*Math.sqrt(Math.abs((N*M-N*C*C-M*S*S)/(N*C*C+M*S*S)));h=O*v*C/R+(p+m)/2,f=Math.asin(((E-(_=O*-R*S/v+(E+T)/2))/R*1e9|0)/1e9),d=Math.asin(((T-_)/R*1e9|0)/1e9),0>(f=h>p?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=h>m?Math.PI-d:d)&&(d=2*Math.PI+d),o&&f>d&&(f-=2*Math.PI),!o&&d>f&&(d-=2*Math.PI)}var I=d-f;if(Math.abs(I)>g){var x=d,B=m,D=T;y=_e(m=h+v*Math.cos(d=f+g*(o&&d>f?1:-1)),T=_+R*Math.sin(d),v,R,i,0,o,B,D,[d,x,h,_])}I=d-f;var b=Math.cos(f),L=Math.sin(f),F=Math.cos(d),U=Math.sin(d),k=Math.tan(I/4),w=4/3*v*k,G=4/3*R*k,V=[p,E],X=[p+w*L,E-G*b],W=[m+w*U,T-G*F],H=[m,T];if(X[0]=2*V[0]-X[0],X[1]=2*V[1]-X[1],l)return X.concat(W,H,y);for(var z=[],Y=0,K=(y=X.concat(W,H,y)).length;K>Y;Y+=1)z[Y]=Y%2?he(y[Y-1],y[Y],A).y:he(y[Y],y[Y+1],A).x;return z}"function"==typeof SuppressedError&&SuppressedError;var pe={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,a||e,o),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,a=Array(i);i>n;n++)a[n]=t[n].fn;return a},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var u,l,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d,h=c.length;for(l=0;h>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,i);break;default:if(!u)for(d=1,u=Array(f-1);f>d;d++)u[d-1]=arguments[d];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||o(this,a);else{for(var u=0,l=[],c=s.length;c>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[a]=1===l.length?l[0]:l:o(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&o(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(pe);var Ee,ve,Re,me,Te,ge,Ae,ye,Se,Ce,Pe,Ne,Me,Oe,Ie,xe,Be,De,be,Le,Fe,Ue,ke,we,Ge,Ve,Xe,We=pe.exports;function He(e,t,r,n){return{dimension:xe.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:Be.SAMPLED}}function ze(e,t,r){return e<<16|t<<8|r}function Ye(e){return e>>>8&255}function Ke(e){return e>>>16&255}function je(e){return 255&e}function Ze(e){switch(e){case we.F32:case we.U32:case we.S32:return 4;case we.U16:case we.S16:case we.F16:return 2;case we.U8:case we.S8:return 1;default:throw Error("whoops")}}function qe(e){return Ze(Ke(e))}function Qe(e){var t=je(e);if(t&Ve.Depth)return Le.Depth;if(t&Ve.Normalized)return Le.Float;var r=Ke(e);if(r===we.F16||r===we.F32)return Le.Float;if(r===we.U8||r===we.U16||r===we.U32)return Le.Uint;if(r===we.S8||r===we.S16||r===we.S32)return Le.Sint;throw Error("whoops")}function $e(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function Je(e){if(null!=e)return e;throw Error("Missing object")}function et(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function tt(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(Ee||(Ee={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool",e[e.RenderBundle=11]="RenderBundle"}(ve||(ve={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(Re||(Re={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(me||(me={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(Te||(Te={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(ge||(ge={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(Ae||(Ae={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(ye||(ye={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(Se||(Se={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(Ce||(Ce={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(Pe||(Pe={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(Ne||(Ne={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(Me||(Me={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}(Oe||(Oe={})),function(e){e.LOADED="loaded"}(Ie||(Ie={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(xe||(xe={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET",e[e.STORAGE=4]="STORAGE"}(Be||(Be={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(De||(De={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(be||(be={})),function(e){e[e.Float=0]="Float",e[e.UnfilterableFloat=1]="UnfilterableFloat",e[e.Uint=2]="Uint",e[e.Sint=3]="Sint",e[e.Depth=4]="Depth"}(Le||(Le={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(Fe||(Fe={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(Ue||(Ue={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(ke||(ke={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(we||(we={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(Ge||(Ge={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget",e[e.Luminance=32]="Luminance"}(Ve||(Ve={})),function(e){e[e.ALPHA=ze(we.U8,Ge.A,Ve.None)]="ALPHA",e[e.U8_LUMINANCE=ze(we.U8,Ge.A,Ve.Luminance)]="U8_LUMINANCE",e[e.F16_LUMINANCE=ze(we.F16,Ge.A,Ve.Luminance)]="F16_LUMINANCE",e[e.F32_LUMINANCE=ze(we.F32,Ge.A,Ve.Luminance)]="F32_LUMINANCE",e[e.F16_R=ze(we.F16,Ge.R,Ve.None)]="F16_R",e[e.F16_RG=ze(we.F16,Ge.RG,Ve.None)]="F16_RG",e[e.F16_RGB=ze(we.F16,Ge.RGB,Ve.None)]="F16_RGB",e[e.F16_RGBA=ze(we.F16,Ge.RGBA,Ve.None)]="F16_RGBA",e[e.F32_R=ze(we.F32,Ge.R,Ve.None)]="F32_R",e[e.F32_RG=ze(we.F32,Ge.RG,Ve.None)]="F32_RG",e[e.F32_RGB=ze(we.F32,Ge.RGB,Ve.None)]="F32_RGB",e[e.F32_RGBA=ze(we.F32,Ge.RGBA,Ve.None)]="F32_RGBA",e[e.U8_R=ze(we.U8,Ge.R,Ve.None)]="U8_R",e[e.U8_R_NORM=ze(we.U8,Ge.R,Ve.Normalized)]="U8_R_NORM",e[e.U8_RG=ze(we.U8,Ge.RG,Ve.None)]="U8_RG",e[e.U8_RG_NORM=ze(we.U8,Ge.RG,Ve.Normalized)]="U8_RG_NORM",e[e.U8_RGB=ze(we.U8,Ge.RGB,Ve.None)]="U8_RGB",e[e.U8_RGB_NORM=ze(we.U8,Ge.RGB,Ve.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=ze(we.U8,Ge.RGB,Ve.sRGB|Ve.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=ze(we.U8,Ge.RGBA,Ve.None)]="U8_RGBA",e[e.U8_RGBA_NORM=ze(we.U8,Ge.RGBA,Ve.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=ze(we.U8,Ge.RGBA,Ve.sRGB|Ve.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=ze(we.U16,Ge.R,Ve.None)]="U16_R",e[e.U16_R_NORM=ze(we.U16,Ge.R,Ve.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=ze(we.U16,Ge.RG,Ve.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=ze(we.U16,Ge.RGBA,Ve.Normalized)]="U16_RGBA_NORM",e[e.U16_RGBA=ze(we.U16,Ge.RGBA,Ve.None)]="U16_RGBA",e[e.U16_RGB=ze(we.U16,Ge.RGB,Ve.None)]="U16_RGB",e[e.U16_RG=ze(we.U16,Ge.RG,Ve.None)]="U16_RG",e[e.U32_R=ze(we.U32,Ge.R,Ve.None)]="U32_R",e[e.U32_RG=ze(we.U32,Ge.RG,Ve.None)]="U32_RG",e[e.U32_RGB=ze(we.U32,Ge.RGB,Ve.None)]="U32_RGB",e[e.U32_RGBA=ze(we.U32,Ge.RGBA,Ve.None)]="U32_RGBA",e[e.S8_R=ze(we.S8,Ge.R,Ve.None)]="S8_R",e[e.S8_R_NORM=ze(we.S8,Ge.R,Ve.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=ze(we.S8,Ge.RG,Ve.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=ze(we.S8,Ge.RGB,Ve.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=ze(we.S8,Ge.RGBA,Ve.Normalized)]="S8_RGBA_NORM",e[e.S16_R=ze(we.S16,Ge.R,Ve.None)]="S16_R",e[e.S16_RG=ze(we.S16,Ge.RG,Ve.None)]="S16_RG",e[e.S16_RG_NORM=ze(we.S16,Ge.RG,Ve.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=ze(we.S16,Ge.RGB,Ve.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=ze(we.S16,Ge.RGBA,Ve.None)]="S16_RGBA",e[e.S16_RGBA_NORM=ze(we.S16,Ge.RGBA,Ve.Normalized)]="S16_RGBA_NORM",e[e.S32_R=ze(we.S32,Ge.R,Ve.None)]="S32_R",e[e.S32_RG=ze(we.S32,Ge.RG,Ve.None)]="S32_RG",e[e.S32_RGB=ze(we.S32,Ge.RGB,Ve.None)]="S32_RGB",e[e.S32_RGBA=ze(we.S32,Ge.RGBA,Ve.None)]="S32_RGBA",e[e.U16_RGBA_5551=ze(we.U16_PACKED_5551,Ge.RGBA,Ve.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=ze(we.U16_PACKED_565,Ge.RGB,Ve.Normalized)]="U16_RGB_565",e[e.BC1=ze(we.BC1,Ge.RGBA,Ve.Normalized)]="BC1",e[e.BC1_SRGB=ze(we.BC1,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC1_SRGB",e[e.BC2=ze(we.BC2,Ge.RGBA,Ve.Normalized)]="BC2",e[e.BC2_SRGB=ze(we.BC2,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC2_SRGB",e[e.BC3=ze(we.BC3,Ge.RGBA,Ve.Normalized)]="BC3",e[e.BC3_SRGB=ze(we.BC3,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=ze(we.BC4_UNORM,Ge.R,Ve.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=ze(we.BC4_SNORM,Ge.R,Ve.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=ze(we.BC5_UNORM,Ge.RG,Ve.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=ze(we.BC5_SNORM,Ge.RG,Ve.Normalized)]="BC5_SNORM",e[e.D24=ze(we.D24,Ge.R,Ve.Depth)]="D24",e[e.D24_S8=ze(we.D24S8,Ge.RG,Ve.Depth|Ve.Stencil)]="D24_S8",e[e.D32F=ze(we.D32F,Ge.R,Ve.Depth)]="D32F",e[e.D32F_S8=ze(we.D32FS8,Ge.RG,Ve.Depth|Ve.Stencil)]="D32F_S8",e[e.U8_RGB_RT=ze(we.U8,Ge.RGB,Ve.RenderTarget|Ve.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=ze(we.U8,Ge.RGBA,Ve.RenderTarget|Ve.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=ze(we.U8,Ge.RGBA,Ve.RenderTarget|Ve.Normalized|Ve.sRGB)]="U8_RGBA_RT_SRGB"}(Xe||(Xe={}));var rt=tt(0,0,0,0),nt=tt(0,0,0,1),it=tt(1,1,1,0),at=tt(1,1,1,1);function ot(e){return!(!e||e&e-1)}function st(e,t){return null!=e?e:t}function ut(e,t,r){e.length=t,e.fill(r)}function lt(e,t){var r=t-1;return e+r&~r}function ct(e,t){return((e+t-1)/t|0)*t}function ft(e,t,r){return r?e|=t:e&=~t,e}function dt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function ht(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function _t(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e.mask=t.mask,e}function pt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),ht(e.rgbBlendState,t.rgbBlendState),ht(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Et(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=pt(e[r],t[r])}function vt(e,t){void 0!==t.attachmentsState&&Et(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=st(t.depthCompare,e.depthCompare),e.depthWrite=st(t.depthWrite,e.depthWrite),e.stencilWrite=st(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&_t(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&_t(e.stencilBack,t.stencilBack),e.cullMode=st(t.cullMode,e.cullMode),e.frontFace=st(t.frontFace,e.frontFace),e.polygonOffset=st(t.polygonOffset,e.polygonOffset),e.polygonOffsetFactor=st(t.polygonOffsetFactor,e.polygonOffsetFactor),e.polygonOffsetUnits=st(t.polygonOffsetUnits,e.polygonOffsetUnits)}function Rt(e){var t=Object.assign({},e);return t.attachmentsState=[],Et(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&et(t.blendConstant),t.stencilFront=_t(void 0,e.stencilFront),t.stencilBack=_t(void 0,e.stencilBack),t}var mt={blendMode:Ae.ADD,blendSrcFactor:ge.ONE,blendDstFactor:ge.ZERO},Tt={attachmentsState:[{channelWriteMask:De.ALL,rgbBlendState:mt,alphaBlendState:mt}],blendConstant:et(rt),depthWrite:!0,depthCompare:Re.LEQUAL,stencilWrite:!1,stencilFront:{compare:Re.ALWAYS,passOp:be.KEEP,depthFailOp:be.KEEP,failOp:be.KEEP},stencilBack:{compare:Re.ALWAYS,passOp:be.KEEP,depthFailOp:be.KEEP,failOp:be.KEEP},cullMode:Te.NONE,frontFace:me.CCW,polygonOffset:!1,polygonOffsetFactor:0,polygonOffsetUnits:0};var gt=function(e,t){void 0===e&&(e=null),void 0===t&&(t=Tt);var r=Rt(t);return null!==e&&vt(r,e),r}({depthCompare:Re.ALWAYS,depthWrite:!1},Tt);function At(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Et(e.attachmentsState,Tt.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var yt,St={texture:null,sampler:null,formatKind:Le.Float,dimension:xe.TEXTURE_2D};function Ct(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Pt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function Nt(e,t){return e.texture===t.texture&&e.binding===t.binding}function Mt(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function Ot(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function It(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!Ct(e.samplerBindings,t.samplerBindings,Ot)&&(!!Ct(e.uniformBufferBindings,t.uniformBufferBindings,Mt)&&(!!Ct(e.storageBufferBindings,t.storageBufferBindings,Mt)&&!!Ct(e.storageTextureBindings,t.storageTextureBindings,Nt))))}function xt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function Bt(e,t){return!!xt(e.rgbBlendState,t.rgbBlendState)&&(!!xt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Dt(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp&&e.mask===t.mask}function bt(e,t){return e.id===t.id}function Lt(e,t){return e===t}function Ft(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!Ct(e.attachmentsState,t.attachmentsState,Bt)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!Dt(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!Dt(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset||e.polygonOffsetFactor!==t.polygonOffsetFactor||e.polygonOffsetUnits!==t.polygonOffsetUnits);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!bt(e.program,t.program)&&(!!Ct(e.colorAttachmentFormats,t.colorAttachmentFormats,Lt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function Ut(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function kt(e,t){return U(e)?U(t):!U(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&Ct(e.attributes,t.attributes,Ut))}function wt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Ct(e.vertexBufferDescriptors,t.vertexBufferDescriptors,kt)&&!!bt(e.program,t.program))}function Gt(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function Vt(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function Xt(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function Wt(e){return{binding:e.binding,texture:e.texture}}function Ht(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function zt(e){return U(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:Pt(e.attributes,Ht)}}var Yt=/([^[]*)(\[[0-9]+\])?/;function Kt(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(Yt);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function jt(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function Zt(e,t,r,n){var i=null,a=null;return function(o,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),a=c,f=!0;else{$e(a===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(l[d]!==i[d]){f=!0;break}}return f&&(n(o,e,s,l),i.set(l)),f}}function qt(e,t,r,n){e[t](r,n)}function Qt(e,t,r,n){e[t](r,!1,n)}var $t={},Jt={},er={},tr=[0];function rr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(tr[0]=e,e=tr);var i=e.length;if(e instanceof r)return e;var a=n[i];a||(a=new r(i),n[i]=a);for(var o=0;i>o;o++)a[o]=e[o];return a}function nr(e,t){return rr(e,t,Float32Array,$t)}function ir(e,t){return rr(e,t,Int32Array,Jt)}function ar(e,t){return rr(e,t,Uint32Array,er)}var or=((yt={})[Ee.FLOAT]=Zt.bind(null,"uniform1fv",nr,1,qt),yt[Ee.FLOAT_VEC2]=Zt.bind(null,"uniform2fv",nr,2,qt),yt[Ee.FLOAT_VEC3]=Zt.bind(null,"uniform3fv",nr,3,qt),yt[Ee.FLOAT_VEC4]=Zt.bind(null,"uniform4fv",nr,4,qt),yt[Ee.INT]=Zt.bind(null,"uniform1iv",ir,1,qt),yt[Ee.INT_VEC2]=Zt.bind(null,"uniform2iv",ir,2,qt),yt[Ee.INT_VEC3]=Zt.bind(null,"uniform3iv",ir,3,qt),yt[Ee.INT_VEC4]=Zt.bind(null,"uniform4iv",ir,4,qt),yt[Ee.BOOL]=Zt.bind(null,"uniform1iv",ir,1,qt),yt[Ee.BOOL_VEC2]=Zt.bind(null,"uniform2iv",ir,2,qt),yt[Ee.BOOL_VEC3]=Zt.bind(null,"uniform3iv",ir,3,qt),yt[Ee.BOOL_VEC4]=Zt.bind(null,"uniform4iv",ir,4,qt),yt[Ee.FLOAT_MAT2]=Zt.bind(null,"uniformMatrix2fv",nr,4,Qt),yt[Ee.FLOAT_MAT3]=Zt.bind(null,"uniformMatrix3fv",nr,9,Qt),yt[Ee.FLOAT_MAT4]=Zt.bind(null,"uniformMatrix4fv",nr,16,Qt),yt[Ee.UNSIGNED_INT]=Zt.bind(null,"uniform1uiv",ar,1,qt),yt[Ee.UNSIGNED_INT_VEC2]=Zt.bind(null,"uniform2uiv",ar,2,qt),yt[Ee.UNSIGNED_INT_VEC3]=Zt.bind(null,"uniform3uiv",ar,3,qt),yt[Ee.UNSIGNED_INT_VEC4]=Zt.bind(null,"uniform4uiv",ar,4,qt),yt[Ee.FLOAT_MAT2x3]=Zt.bind(null,"uniformMatrix2x3fv",nr,6,Qt),yt[Ee.FLOAT_MAT2x4]=Zt.bind(null,"uniformMatrix2x4fv",nr,8,Qt),yt[Ee.FLOAT_MAT3x2]=Zt.bind(null,"uniformMatrix3x2fv",nr,6,Qt),yt[Ee.FLOAT_MAT3x4]=Zt.bind(null,"uniformMatrix3x4fv",nr,12,Qt),yt[Ee.FLOAT_MAT4x2]=Zt.bind(null,"uniformMatrix4x2fv",nr,8,Qt),yt[Ee.FLOAT_MAT4x3]=Zt.bind(null,"uniformMatrix4x3fv",nr,12,Qt),yt[Ee.SAMPLER_2D]=jt,yt[Ee.SAMPLER_CUBE]=jt,yt[Ee.SAMPLER_3D]=jt,yt[Ee.SAMPLER_2D_SHADOW]=jt,yt[Ee.SAMPLER_2D_ARRAY]=jt,yt[Ee.SAMPLER_2D_ARRAY_SHADOW]=jt,yt[Ee.SAMPLER_CUBE_SHADOW]=jt,yt[Ee.INT_SAMPLER_2D]=jt,yt[Ee.INT_SAMPLER_3D]=jt,yt[Ee.INT_SAMPLER_CUBE]=jt,yt[Ee.INT_SAMPLER_2D_ARRAY]=jt,yt[Ee.UNSIGNED_INT_SAMPLER_2D]=jt,yt[Ee.UNSIGNED_INT_SAMPLER_3D]=jt,yt[Ee.UNSIGNED_INT_SAMPLER_CUBE]=jt,yt[Ee.UNSIGNED_INT_SAMPLER_2D_ARRAY]=jt,yt);function sr(e,t,r){var n=or[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var ur={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121};function lr(e,t){return"#define ".concat(e," ").concat(t)}function cr(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function fr(e){return[e,""]}function dr(e,t,r,n,i){var a;void 0===n&&(n=null),void 0===i&&(i=!0);var o="#version 100"===e.glslVersion,s="frag"===t&&(null===(a=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===a?void 0:a.length)>1,u=r.replace("\r\n","\n").split("\n").map(function(e){return e.replace(/[/][/].*$/,"")}).filter(function(e){return!(!e||/^\s+$/.test(e))}),l="";null!==n&&(l=Object.keys(n).map(function(e){return lr(e,n[e])}).join("\n"));var c=u.find(function(e){return e.startsWith("precision")})||"precision mediump float;",f=i?u.filter(function(e){return!e.startsWith("precision")}).join("\n"):u.join("\n"),d="";if(e.viewportOrigin===Fe.UPPER_LEFT&&(d+="".concat(lr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===Ue.ZERO&&(d+="".concat(lr("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var h=0,_=0,p=0;f=f.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(h,", binding = ").concat(_++,") uniform ").concat(n)}),h++,_=0,$e(e.separateSamplerTextures),f=f.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(e,r,n,i,a){var o=cr(n);null===o&&(o=_++);var s=de(fr(i),2),u=s[0],l=s[1];return"frag"===t?"\nlayout(set = ".concat(h,", binding = ").concat(2*o+0,") uniform texture").concat(u," T_").concat(a,";\nlayout(set = ").concat(h,", binding = ").concat(2*o+1,") uniform sampler").concat(l," S_").concat(a,";").trim():""}),f=f.replace("frag"===t?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,function(e,t){return"layout(location = ".concat(p++,") ").concat(t)}),d+="".concat(lr("gl_VertexID","gl_VertexIndex"),"\n"),d+="".concat(lr("gl_InstanceID","gl_InstanceIndex"),"\n"),c=c.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var E=0;f=f.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(e,t,r,n,i){var a=cr(r);return null===a&&(a=E++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(a)})}if(f=(f=(f=f.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"SAMPLER_".concat(t,"(P_").concat(r,")")})).replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"PP_SAMPLER_".concat(t,"(P_").concat(r,")")})).replace(/\bPU_TEXTURE\((.*?)\)/g,function(e,t){return"TEXTURE(P_".concat(t,")")}),e.separateSamplerTextures)f=f.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){var n=de(fr(t),2),i=n[1];return"texture".concat(n[0]," T_P_").concat(r,", sampler").concat(i," S_P_").concat(r)}),f=(f=(f=f.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"T_".concat(r,", S_").concat(r)})).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")})).replace(/\bTEXTURE\((.*?)\)/g,function(e,t){return"T_".concat(t)});else{var v=[];f=(f=(f=f.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"sampler".concat(t," P_").concat(r)})).replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return r})).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return v.push([r,t]),r}),o&&v.forEach(function(e){var t=de(e,2),r=t[0],n=t[1];f=f.replace(RegExp("texture\\(".concat(r),"g"),function(){return"texture".concat(n,"(").concat(r)})}),f=f.replace(/\bTEXTURE\((.*?)\)/g,function(e,t){return t})}var R="".concat(o?"":e.glslVersion,"\n").concat(o&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(o&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?c:"","\n").concat(d||"").concat(l?l+"\n":"","\n").concat(f,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(R=R.replace(/^\b(out)\b/g,function(e,t){return"layout(location = 0) ".concat(t)})),o){if("frag"===t&&(R=R.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")})),"vert"===t&&(R=(R=R.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")})).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")})),R=R.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,function(e,t){return t.trim().replace(/^.*$/gm,function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""})}),"frag"===t)if(s){var m=[];R=R.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,function(e,t){return m.push(t),"vec4 ".concat(t,";\n")});var T=R.lastIndexOf("}");R=R.substring(0,T)+"\n ".concat(m.map(function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")}).join("\n"))+R.substring(T)}else{var g;if(R=R.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(e,t,r){return g=r,"".concat(t," ").concat(r,";\n")}),g){T=R.lastIndexOf("}");R=R.substring(0,T)+"\n gl_FragColor = vec4(".concat(g,");\n")+R.substring(T)}}R=R.replace(/^\s*layout\((.*)\)/gm,"")}return R}var hr,_r=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return se(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(We);function pr(e){return void 0!==hr?hr:"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext?(hr=!0,!0):hr=!(!e||2!==e._version)}function Er(e){if(je(e)&Ve.Normalized)return!1;var t=Ke(e);return t===we.S8||t===we.S16||t===we.S32||(t===we.U8||t===we.U16||t===we.U32)}function vr(e){return e&Ne.INDEX?Ee.ELEMENT_ARRAY_BUFFER:e&Ne.VERTEX?Ee.ARRAY_BUFFER:e&Ne.UNIFORM?Ee.UNIFORM_BUFFER:void 0}function Rr(e){var t=Ke(e),r=Ye(e),n=je(e),i=function(e){switch(e){case we.U8:return Ee.UNSIGNED_BYTE;case we.U16:return Ee.UNSIGNED_SHORT;case we.U32:return Ee.UNSIGNED_INT;case we.S8:return Ee.BYTE;case we.S16:return Ee.SHORT;case we.S32:return Ee.INT;case we.F16:return Ee.HALF_FLOAT;case we.F32:return Ee.FLOAT;default:throw Error("whoops")}}(t),a=function(e){switch(e){case Ge.R:return 1;case Ge.RG:return 2;case Ge.RGB:return 3;case Ge.RGBA:return 4;default:return 1}}(r);return{size:a,type:i,normalized:!!(n&Ve.Normalized)}}function mr(e){switch(e){case ye.CLAMP_TO_EDGE:return Ee.CLAMP_TO_EDGE;case ye.REPEAT:return Ee.REPEAT;case ye.MIRRORED_REPEAT:return Ee.MIRRORED_REPEAT;default:throw Error("whoops")}}function Tr(e,t){if(t===Ce.LINEAR&&e===Se.BILINEAR)return Ee.LINEAR_MIPMAP_LINEAR;if(t===Ce.LINEAR&&e===Se.POINT)return Ee.NEAREST_MIPMAP_LINEAR;if(t===Ce.NEAREST&&e===Se.BILINEAR)return Ee.LINEAR_MIPMAP_NEAREST;if(t===Ce.NEAREST&&e===Se.POINT)return Ee.NEAREST_MIPMAP_NEAREST;if(t===Ce.NO_MIP&&e===Se.BILINEAR)return Ee.LINEAR;if(t===Ce.NO_MIP&&e===Se.POINT)return Ee.NEAREST;throw Error("Unknown texture filter mode")}function gr(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}se(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(_r),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=ve.Buffer;var a=n.viewOrSize,o=n.usage,s=n.hint,u=void 0===s?Me.STATIC:s,l=r.uniformBufferMaxPageByteSize,c=r.gl,f=o&Ne.UNIFORM;f||(pr(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,h=G(a)?lt(a,4):lt(a.byteLength,4);if(i.gl_buffer_pages=[],f){for(var _=h;_>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(_,l),o,u)),_-=l;d=l}else i.gl_buffer_pages.push(i.createBufferPage(h,o,u)),d=h;return i.pageByteSize=d,i.byteSize=h,i.usage=o,i.gl_target=vr(o),G(a)||i.setSubData(0,new Uint8Array(a.buffer)),f||(pr(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}se(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,a=this.pageByteSize,o=e+n,s=e,u=e%a;o>s;){var l=pr(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=gr(this,s);if(c.ubo)return;i.bindBuffer(l,c),pr(i)?i.bufferSubData(l,u,t,r,Math.min(o-s,a)):i.bufferSubData(l,u,t),s+=a,u=0,r+=a,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&Ne.UNIFORM;if(!pr(n)&&i)return{ubo:!0};var a=this.device.ensureResourceExists(n.createBuffer()),o=vr(t),s=function(e){switch(e){case Me.STATIC:return Ee.STATIC_DRAW;case Me.DYNAMIC:return Ee.DYNAMIC_DRAW}}(r);return n.bindBuffer(o,a),n.bufferData(o,e,s),a}}(_r),function(e){function t(t){var r,n,i,a,o,s=t.device,u=t.descriptor,l=e.call(this,{id:t.id,device:s})||this;l.type=ve.InputLayout;var c=u.vertexBufferDescriptors,f=u.indexBufferFormat,d=u.program;$e(f===Xe.U16_R||f===Xe.U32_R||null===f);var h=null!==f?function(e){switch(e){case Xe.U8_R:return Ee.UNSIGNED_BYTE;case Xe.U16_R:return Ee.UNSIGNED_SHORT;case Xe.U32_R:return Ee.UNSIGNED_INT;default:throw Error("whoops")}}(f):null,_=null!==f?qe(f):null,p=l.device.gl,E=l.device.ensureResourceExists(pr(p)?p.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());pr(p)?p.bindVertexArray(E):s.OES_vertex_array_object.bindVertexArrayOES(E),p.bindBuffer(p.ARRAY_BUFFER,gr(l.device.fallbackVertexBuffer));try{for(var v=fe(u.vertexBufferDescriptors),R=v.next();!R.done;R=v.next()){var m=R.value,T=m.stepMode,g=m.attributes;try{for(var A=(i=void 0,fe(g)),y=A.next();!y.done;y=A.next()){var S=y.value,C=S.shaderLocation,P=S.format,N=S.divisor,M=void 0===N?1:N,O=pr(p)?C:null===(o=d.attributes[C])||void 0===o?void 0:o.location,I=Rr(P);if(S.vertexFormat=I,!U(O))Er(P),p.vertexAttribPointer(O,I.size,I.type,I.normalized,0,0),T===Oe.INSTANCE&&(pr(p)?p.vertexAttribDivisor(O,M):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(O,M)),p.enableVertexAttribArray(O)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(a=A.return)&&a.call(A)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{R&&!R.done&&(n=v.return)&&n.call(v)}finally{if(r)throw r.error}}return pr(p)?p.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),l.vertexBufferDescriptors=c,l.vao=E,l.indexBufferFormat=f,l.indexBufferType=h,l.indexBufferCompByteSize=_,l.program=d,l}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(pr(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(_r);var Ar,yr=function(e){function t(t){var r=t.device,n=t.descriptor,i=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=ve.Texture,n=ue({dimension:xe.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var o,s,u=a.device.gl,l=a.clampmipLevelCount(n);if(a.immutable=n.usage===Be.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=Qe(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=l>=1,!i){s=a.device.ensureResourceExists(u.createTexture());var c=a.device.translateTextureType(n.format),f=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===xe.TEXTURE_2D){if(u.bindTexture(o=Ee.TEXTURE_2D,s),a.immutable)if(pr(u))u.texStorage2D(o,l,f,n.width,n.height);else{var d=(f===Ee.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==Xe.D32F&&a.format!==Xe.D24_S8||pr(u)||r.WEBGL_depth_texture)&&(u.texImage2D(o,d,f,n.width,n.height,0,f,c,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR),u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_S,Ee.CLAMP_TO_EDGE),u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_T,Ee.CLAMP_TO_EDGE)))}$e(1===n.depthOrArrayLayers)}else if(n.dimension===xe.TEXTURE_2D_ARRAY)u.bindTexture(o=Ee.TEXTURE_2D_ARRAY,s),a.immutable&&pr(u)&&u.texStorage3D(o,l,f,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===xe.TEXTURE_3D)u.bindTexture(o=Ee.TEXTURE_3D,s),a.immutable&&pr(u)&&u.texStorage3D(o,l,f,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==xe.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(o=Ee.TEXTURE_CUBE_MAP,s),a.immutable&&pr(u)&&u.texStorage2D(o,l,f,n.width,n.height),$e(6===n.depthOrArrayLayers)}}return a.gl_texture=s,a.gl_target=o,a.mipLevelCount=l,a}return se(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_UNORM:case we.BC4_SNORM:case we.BC5_UNORM:case we.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===Ee.TEXTURE_3D||this.gl_target===Ee.TEXTURE_2D_ARRAY,i=this.gl_target===Ee.TEXTURE_CUBE_MAP,a=Object.prototype.toString.call(e[0])in ur;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var o,s,u=e[0];a?(o=this.width,s=this.height):(s=u.height,this.width=o=u.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var l=this.device.translateTextureFormat(this.format),c=pr(r)?this.device.translateInternalTextureFormat(this.format):l,f=this.device.translateTextureType(this.format);this.preprocessImage();for(var d=0;this.depthOrArrayLayers>d;d++){var h=e[d],_=this.gl_target;i&&(_=Ee.TEXTURE_CUBE_MAP_POSITIVE_X+d%6),this.immutable?r.texSubImage2D(_,t,0,0,o,s,l,f,h):pr(r)?n?r.texImage3D(_,t,c,o,s,this.depthOrArrayLayers,0,l,f,h):r.texImage2D(_,t,c,o,s,0,l,f,h):a?r.texImage2D(_,t,l,o,s,0,l,f,h):r.texImage2D(_,t,l,l,f,h)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===xe.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&Ke(e.format)===we.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(Ee.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(Ee.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(Ee.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!pr(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,Ee.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,Ee.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,Ee.TEXTURE_MAG_FILTER,Ee.LINEAR)):t.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!pr(this.device.gl)&&(!ot(this.width)||!ot(this.height))},t}(_r);let Sr;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=ve.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var a=i.device.gl,o=n.format,s=n.width,u=n.height,l=n.sampleCount,c=void 0===l?1:l,f=n.texture,d=!1;if(o!==Xe.D32F&&o!==Xe.D24_S8||!f||pr(a)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(a.createRenderbuffer()),a.bindRenderbuffer(a.RENDERBUFFER,i.gl_renderbuffer);var h=i.device.translateTextureInternalFormat(o,!0);pr(a)&&c>1?a.renderbufferStorageMultisample(Ee.RENDERBUFFER,c,h,s,u):a.renderbufferStorage(Ee.RENDERBUFFER,h,s,u)}return i.format=o,i.width=s,i.height=u,i.sampleCount=c,i}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(_r),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(Ar||(Ar={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=ve.Program,i.uniformSetters={},i.attributes=[];var a=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(a.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=Ar.NeedsCompile,i.tryCompileProgram(),i}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){$e(this.compileState===Ar.NeedsCompile);var e=this.descriptor,t=e.vertex,r=e.fragment,n=this.device.gl;(null==t?void 0:t.glsl)&&(null==r?void 0:r.glsl)&&(this.gl_shader_vert=this.compileShader(t.postprocess?t.postprocess(t.glsl):t.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.postprocess?r.postprocess(r.glsl):r.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=Ar.Compiling,pr(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""}),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,function(e,n,i){var a=Number(n);return r.push({location:isNaN(a)?t[n]:a,name:i}),""}),r}(this.rawVertexGLSL,n),a=function(r){var n=t.getActiveAttrib(o.gl_program,r),a=n.name,s=n.type,u=n.size,l=t.getAttribLocation(o.gl_program,a),c=null===(e=i.find(function(e){return e.name===a}))||void 0===e?void 0:e.location;0>l||U(c)||(o.attributes[c]={name:a,location:l,type:s,size:u})},o=this,s=0;r>s;s++)a(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=Kt(n.name).name,a=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=sr(e,a,n),n&&n.size>1)for(var o=0;n.size>o;o++)a=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(o,"]")),this.uniformSetters["".concat(i,"[").concat(o,"]")]=sr(e,a,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!pr(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var a=e[n];a instanceof yr&&(a=a.textureIndex),i(a)}}}return this}}(_r),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.QueryPool;var i=n.device.gl;if(pr(i)){var a=r.type;n.gl_query=dt(r.elemCount,function(){return n.device.ensureResourceExists(i.createQuery())}),n.gl_query_type=function(e){if(e===ke.OcclusionConservative)return Ee.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(a)}return n}se(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(pr(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(pr(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(_r),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.Readback,r.gl_pbo=null,r.gl_sync=null,r}se(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise(function(i,a){!function o(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(o,w(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):a()}()})},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,a){return le(this,void 0,void 0,function(){var o;return ce(this,function(s){switch(s.label){case 0:return pr(o=this.device.gl)?(this.gl_sync=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0),o.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),o.bindBuffer(e,t),o.getBufferSubData(e,r,n,i,a),o.bindBuffer(e,null),[2,n];case 2:return[2]}})})},t.prototype.readTexture=function(e,t,r,n,i,a,o,s){return void 0===o&&(o=0),void 0===s&&(s=a.byteLength||0),le(this,void 0,void 0,function(){var u,l,c,f,d;return ce(this,function(h){var _;return u=this.device.gl,c=this.device.translateTextureFormat((l=e).format),f=this.device.translateTextureType(l.format),d=Ze(Ke(_=l.format))*Ye(_),pr(u)?(this.gl_pbo=this.device.ensureResourceExists(u.createBuffer()),u.bindBuffer(u.PIXEL_PACK_BUFFER,this.gl_pbo),u.bufferData(u.PIXEL_PACK_BUFFER,s,u.STREAM_READ),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.bindFramebuffer(Ee.READ_FRAMEBUFFER,this.device.readbackFramebuffer),u.framebufferTexture2D(Ee.READ_FRAMEBUFFER,Ee.COLOR_ATTACHMENT0,Ee.TEXTURE_2D,l.gl_texture,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,this.gl_pbo),u.readPixels(t,r,n,i,c,f,o*d),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(u.PIXEL_PACK_BUFFER,this.gl_pbo,0,a,o,0)]):[2,this.readTextureSync(e,t,r,n,i,a,o,s)]})})},t.prototype.readTextureSync=function(e,t,r,n,i,a,o,s){void 0===s&&(s=a.byteLength||0);var u=this.device.gl,l=e,c=this.device.translateTextureType(l.format);return u.bindFramebuffer(Ee.FRAMEBUFFER,this.device.readbackFramebuffer),u.framebufferTexture2D(Ee.FRAMEBUFFER,Ee.COLOR_ATTACHMENT0,Ee.TEXTURE_2D,l.gl_texture,0),u.pixelStorei(u.PACK_ALIGNMENT,4),u.readPixels(t,r,n,i,u.RGBA,c,a),a},t.prototype.readBuffer=function(e,t,r,n,i){return le(this,void 0,void 0,function(){var a;return ce(this,function(o){return pr(a=this.device.gl)?[2,this.getBufferSubDataAsync(a.ARRAY_BUFFER,gr(e,t),t,r,n,i)]:[2,Promise.reject()]})})},t.prototype.destroy=function(){e.prototype.destroy.call(this),pr(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(_r),function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=ve.RenderPipeline,a.drawMode=function(e){switch(e){case Pe.TRIANGLES:return Ee.TRIANGLES;case Pe.POINTS:return Ee.POINTS;case Pe.TRIANGLE_STRIP:return Ee.TRIANGLE_STRIP;case Pe.LINES:return Ee.LINES;case Pe.LINE_STRIP:return Ee.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=i.topology)&&void 0!==r?r:Pe.TRIANGLES),a.program=i.program,a.inputLayout=i.inputLayout,a.megaState=ue(ue({},Rt(Tt)),i.megaStateDescriptor),a.colorAttachmentFormats=i.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=i.depthStencilAttachmentFormat,a.sampleCount=null!==(n=i.sampleCount)&&void 0!==n?n:1,a}se(t,e)}(_r),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.ComputePipeline,n.descriptor=r,n}se(t,e)}(_r),function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Sampler;var o=a.device.gl;if(pr(o)){var s=a.device.ensureResourceExists(o.createSampler());o.samplerParameteri(s,Ee.TEXTURE_WRAP_S,mr(i.addressModeU)),o.samplerParameteri(s,Ee.TEXTURE_WRAP_T,mr(i.addressModeV)),o.samplerParameteri(s,Ee.TEXTURE_WRAP_R,mr(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),o.samplerParameteri(s,Ee.TEXTURE_MIN_FILTER,Tr(i.minFilter,i.mipmapFilter)),o.samplerParameteri(s,Ee.TEXTURE_MAG_FILTER,Tr(i.magFilter,Ce.NO_MIP)),void 0!==i.lodMinClamp&&o.samplerParameterf(s,Ee.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&o.samplerParameterf(s,Ee.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(o.samplerParameteri(s,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.samplerParameteri(s,o.TEXTURE_COMPARE_FUNC,i.compareFunction));var u=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;u>1&&null!==a.device.EXT_texture_filter_anisotropic&&($e(i.minFilter===Se.BILINEAR&&i.magFilter===Se.BILINEAR&&i.mipmapFilter===Ce.LINEAR),o.samplerParameterf(s,a.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u)),a.gl_sampler=s}else a.descriptor=i;return a}se(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,a=this.descriptor;this.isNPOT(t,r)?i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR):i.texParameteri(e,Ee.TEXTURE_MIN_FILTER,Tr(a.minFilter,a.mipmapFilter)),i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_S,mr(a.addressModeU)),i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_T,mr(a.addressModeV)),i.texParameteri(e,Ee.TEXTURE_MAG_FILTER,Tr(a.magFilter,Ce.NO_MIP));var o=null!==(n=a.maxAnisotropy)&&void 0!==n?n:1;o>1&&null!==this.device.EXT_texture_filter_anisotropic&&($e(a.minFilter===Se.BILINEAR&&a.magFilter===Se.BILINEAR&&a.mipmapFilter===Ce.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o))},t.prototype.destroy=function(){e.prototype.destroy.call(this),pr(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!ot(e)||!ot(t)}}(_r),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ve.RenderBundle,t.commands=[],t}se(t,e),t.prototype.push=function(e){this.commands.push(e)},t.prototype.replay=function(){this.commands.forEach(function(e){return e()})}}(_r);const Cr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Cr.decode();let Pr=null;function Nr(){return null!==Pr&&0!==Pr.byteLength||(Pr=new Uint8Array(Sr.memory.buffer)),Pr}function Mr(e,t){return e>>>=0,Cr.decode(Nr().subarray(e,e+t))}const Or=Array(128).fill(void 0);Or.push(void 0,null,!0,!1);let Ir=Or.length;function xr(e){return Or[e]}function Br(e){const t=xr(e);return function(e){132>e||(Or[e]=Ir,Ir=e)}(e),t}let Dr=0;const br="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Lr="function"==typeof br.encodeInto?function(e,t){return br.encodeInto(e,t)}:function(e,t){const r=br.encode(e);return t.set(r),{read:e.length,written:r.length}};function Fr(e,t,r){if(void 0===r){const r=br.encode(e),n=t(r.length,1)>>>0;return Nr().subarray(n,n+r.length).set(r),Dr=r.length,n}let n=e.length,i=t(n,1)>>>0;const a=Nr();let o=0;for(;n>o;o++){const t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==n){0!==o&&(e=e.slice(o)),i=r(i,n,n=o+3*e.length,1)>>>0;const t=Nr().subarray(i+o,i+n);o+=Lr(e,t).written}return Dr=o,i}let Ur=null;function kr(){return null!==Ur&&0!==Ur.byteLength||(Ur=new Int32Array(Sr.memory.buffer)),Ur}function wr(e,t,r){let n,i;try{const s=Sr.__wbindgen_add_to_stack_pointer(-16),u=Fr(e,Sr.__wbindgen_malloc,Sr.__wbindgen_realloc),l=Dr,c=Fr(t,Sr.__wbindgen_malloc,Sr.__wbindgen_realloc);Sr.glsl_compile(s,u,l,c,Dr,r);var a=kr()[s/4+0],o=kr()[s/4+1];return n=a,i=o,Mr(a,o)}finally{Sr.__wbindgen_add_to_stack_pointer(16),Sr.__wbindgen_free(n,i,1)}}class Gr{static __wrap(e){e>>>=0;const t=Object.create(Gr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Sr.__wbg_wgslcomposer_free(e)}constructor(){const e=Sr.wgslcomposer_new();return Gr.__wrap(e)}load_composable(e){const t=Fr(e,Sr.__wbindgen_malloc,Sr.__wbindgen_realloc);Sr.wgslcomposer_load_composable(this.__wbg_ptr,t,Dr)}wgsl_compile(e){let t,r;try{const a=Sr.__wbindgen_add_to_stack_pointer(-16),o=Fr(e,Sr.__wbindgen_malloc,Sr.__wbindgen_realloc);Sr.wgslcomposer_wgsl_compile(a,this.__wbg_ptr,o,Dr);var n=kr()[a/4+0],i=kr()[a/4+1];return t=n,r=i,Mr(n,i)}finally{Sr.__wbindgen_add_to_stack_pointer(16),Sr.__wbindgen_free(t,r,1)}}}function Vr(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){Ir===Or.length&&Or.push(Or.length+1);const t=Ir;return Ir=Or[t],Or[t]=e,t}(Mr(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){Br(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(xr(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(xr(e),xr(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(Mr(e,t))},e}async function Xr(e){if(void 0!==Sr)return Sr;const t=Vr();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return Sr=e.exports,Xr.__wbindgen_wasm_module=t,Ur=null,Pr=null,Sr}(r,n)}var Wr,Hr;function zr(e){if(e===Xe.U8_R_NORM)return"r8unorm";if(e===Xe.S8_R_NORM)return"r8snorm";if(e===Xe.U8_RG_NORM)return"rg8unorm";if(e===Xe.S8_RG_NORM)return"rg8snorm";if(e===Xe.U32_R)return"r32uint";if(e===Xe.S32_R)return"r32sint";if(e===Xe.F32_R)return"r32float";if(e===Xe.U16_RG)return"rg16uint";if(e===Xe.S16_RG)return"rg16sint";if(e===Xe.F16_RG)return"rg16float";if(e===Xe.U8_RGBA_RT)return"bgra8unorm";if(e===Xe.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===Xe.U8_RGBA_NORM)return"rgba8unorm";if(e===Xe.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===Xe.S8_RGBA_NORM)return"rgba8snorm";if(e===Xe.U32_RG)return"rg32uint";if(e===Xe.S32_RG)return"rg32sint";if(e===Xe.F32_RG)return"rg32float";if(e===Xe.U16_RGBA)return"rgba16uint";if(e===Xe.S16_RGBA)return"rgba16sint";if(e===Xe.F16_RGBA)return"rgba16float";if(e===Xe.F32_RGBA)return"rgba32float";if(e===Xe.U32_RGBA)return"rgba32uint";if(e===Xe.S32_RGBA)return"rgba32sint";if(e===Xe.D24)return"depth24plus";if(e===Xe.D24_S8)return"depth24plus-stencil8";if(e===Xe.D32F)return"depth32float";if(e===Xe.D32F_S8)return"depth32float-stencil8";if(e===Xe.BC1)return"bc1-rgba-unorm";if(e===Xe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Xe.BC2)return"bc2-rgba-unorm";if(e===Xe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Xe.BC3)return"bc3-rgba-unorm";if(e===Xe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Xe.BC4_SNORM)return"bc4-r-snorm";if(e===Xe.BC4_UNORM)return"bc4-r-unorm";if(e===Xe.BC5_SNORM)return"bc5-rg-snorm";if(e===Xe.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function Yr(e){if(e===xe.TEXTURE_2D)return"2d";if(e===xe.TEXTURE_CUBE_MAP)return"cube";if(e===xe.TEXTURE_2D_ARRAY)return"2d-array";if(e===xe.TEXTURE_3D)return"3d";throw Error("whoops")}function Kr(e){if(e===ye.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===ye.REPEAT)return"repeat";if(e===ye.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function jr(e){if(e===Se.BILINEAR)return"linear";if(e===Se.POINT)return"nearest";throw Error("whoops")}function Zr(e){if(e===Ce.LINEAR)return"linear";if(e===Ce.NEAREST)return"nearest";if(e===Ce.NO_MIP)return"nearest";throw Error("whoops")}function qr(e){return e.gpuBuffer}function Qr(e){return e.gpuSampler}function $r(e){if(e===ke.OcclusionConservative)return"occlusion";throw Error("whoops")}function Jr(e){switch(e){case Pe.TRIANGLES:return"triangle-list";case Pe.POINTS:return"point-list";case Pe.TRIANGLE_STRIP:return"triangle-strip";case Pe.LINES:return"line-list";case Pe.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function en(e){if(e===Te.NONE)return"none";if(e===Te.FRONT)return"front";if(e===Te.BACK)return"back";throw Error("whoops")}function tn(e){if(e===me.CCW)return"ccw";if(e===me.CW)return"cw";throw Error("whoops")}function rn(e){if(e===ge.ZERO)return"zero";if(e===ge.ONE)return"one";if(e===ge.SRC)return"src";if(e===ge.ONE_MINUS_SRC)return"one-minus-src";if(e===ge.DST)return"dst";if(e===ge.ONE_MINUS_DST)return"one-minus-dst";if(e===ge.SRC_ALPHA)return"src-alpha";if(e===ge.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===ge.DST_ALPHA)return"dst-alpha";if(e===ge.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===ge.CONST)return"constant";if(e===ge.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===ge.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function nn(e){if(e===Ae.ADD)return"add";if(e===Ae.SUBSTRACT)return"subtract";if(e===Ae.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===Ae.MIN)return"min";if(e===Ae.MAX)return"max";throw Error("whoops")}function an(e){return{operation:nn(e.blendMode),srcFactor:rn(e.blendSrcFactor),dstFactor:rn(e.blendDstFactor)}}function on(e){return e.blendMode===Ae.ADD&&e.blendSrcFactor===ge.ONE&&e.blendDstFactor===ge.ZERO}function sn(e){return on(e.rgbBlendState)&&on(e.alphaBlendState)?void 0:{color:an(e.rgbBlendState),alpha:an(e.alphaBlendState)}}function un(e,t){return t.attachmentsState.map(function(t,r){return function(e,t){return{format:zr(t),blend:sn(e),writeMask:e.channelWriteMask}}(t,e[r])})}function ln(e){if(e===Re.NEVER)return"never";if(e===Re.LESS)return"less";if(e===Re.EQUAL)return"equal";if(e===Re.LEQUAL)return"less-equal";if(e===Re.GREATER)return"greater";if(e===Re.NOTEQUAL)return"not-equal";if(e===Re.GEQUAL)return"greater-equal";if(e===Re.ALWAYS)return"always";throw Error("whoops")}function cn(e){if(e===be.KEEP)return"keep";if(e===be.REPLACE)return"replace";if(e===be.ZERO)return"zero";if(e===be.DECREMENT_CLAMP)return"decrement-clamp";if(e===be.DECREMENT_WRAP)return"decrement-wrap";if(e===be.INCREMENT_CLAMP)return"increment-clamp";if(e===be.INCREMENT_WRAP)return"increment-wrap";if(e===be.INVERT)return"invert";throw Error("whoops")}function fn(e){if(e===Oe.VERTEX)return"vertex";if(e===Oe.INSTANCE)return"instance";throw Error("whoops")}function dn(e){if(e===Xe.U8_R)return"uint8x2";if(e===Xe.U8_RG)return"uint8x2";if(e===Xe.U8_RGB)return"uint8x4";if(e===Xe.U8_RGBA)return"uint8x4";if(e===Xe.U8_RG_NORM)return"unorm8x2";if(e===Xe.U8_RGBA_NORM)return"unorm8x4";if(e===Xe.S8_RGB_NORM)return"snorm8x4";if(e===Xe.S8_RGBA_NORM)return"snorm8x4";if(e===Xe.U16_RG_NORM)return"unorm16x2";if(e===Xe.U16_RGBA_NORM)return"unorm16x4";if(e===Xe.S16_RG_NORM)return"snorm16x2";if(e===Xe.S16_RGBA_NORM)return"snorm16x4";if(e===Xe.S16_RG)return"uint16x2";if(e===Xe.F16_RG)return"float16x2";if(e===Xe.F16_RGBA)return"float16x4";if(e===Xe.F32_R)return"float32";if(e===Xe.F32_RG)return"float32x2";if(e===Xe.F32_RGB)return"float32x3";if(e===Xe.F32_RGBA)return"float32x4";throw"whoops"}function hn(e,t,r,n){switch(void 0===r&&(r=!1),e){case Xe.S8_R:case Xe.S8_R_NORM:case Xe.S8_RG_NORM:case Xe.S8_RGB_NORM:case Xe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case Xe.U8_R:case Xe.U8_R_NORM:case Xe.U8_RG:case Xe.U8_RG_NORM:case Xe.U8_RGB:case Xe.U8_RGB_NORM:case Xe.U8_RGB_SRGB:case Xe.U8_RGBA:case Xe.U8_RGBA_NORM:case Xe.U8_RGBA_SRGB:var a=(ArrayBuffer,new Uint8Array(t));return n&&a.set(new Uint8Array(n)),a;case Xe.S16_R:case Xe.S16_RG:case Xe.S16_RG_NORM:case Xe.S16_RGB_NORM:case Xe.S16_RGBA:case Xe.S16_RGBA_NORM:var o=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&o.set(new Int16Array(n)),o;case Xe.U16_R:case Xe.U16_RGB:case Xe.U16_RGBA_5551:case Xe.U16_RGBA_NORM:case Xe.U16_RG_NORM:case Xe.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case Xe.S32_R:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&u.set(new Int32Array(n)),u;case Xe.U32_R:case Xe.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&l.set(new Uint32Array(n)),l;case Xe.F32_R:case Xe.F32_RG:case Xe.F32_RGB:case Xe.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}function _n(e){var t=(32768&e)>>15,r=(31744&e)>>10,n=1023&e;return 0===r?(t?-1:1)*Math.pow(2,-14)*(n/1024):31==r?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,r-15)*(1+n/1024)}function pn(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(Wr||(Wr={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Hr||(Hr={}));var En=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return se(t,e),t.prototype.destroy=function(){},t}(We),vn=function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Bindings;var o=i.pipeline;$e(!!o);var s=i.uniformBufferBindings,u=i.storageBufferBindings,l=i.samplerBindings,c=i.storageTextureBindings;a.numUniformBuffers=(null==s?void 0:s.length)||0;var f=[[],[],[],[]],d=0;if(s&&s.length)for(var h=0;s.length>h;h++){var _=i.uniformBufferBindings[h],p=_.binding,E=_.size,v=_.offset,R={buffer:qr(_.buffer),offset:null!=v?v:0,size:E};f[0].push({binding:null!=p?p:d++,resource:R})}if(l&&l.length){d=0;for(h=0;l.length>h;h++){var m=ue(ue({},l[h]),St),T=null!==(p=i.samplerBindings[h]).texture?p.texture:a.device.getFallbackTexture(m);if(m.dimension=T.dimension,m.formatKind=Qe(T.format),f[1].push({binding:null!==(r=p.textureBinding)&&void 0!==r?r:d++,resource:T.gpuTextureView}),-1!==p.samplerBinding){var g=Qr(null!==p.sampler?p.sampler:a.device.getFallbackSampler(m));f[1].push({binding:null!==(n=p.samplerBinding)&&void 0!==n?n:d++,resource:g})}}}if(u&&u.length){d=0;for(h=0;u.length>h;h++){var A=i.storageBufferBindings[h];p=A.binding,E=A.size,v=A.offset,R={buffer:qr(A.buffer),offset:null!=v?v:0,size:E};f[2].push({binding:null!=p?p:d++,resource:R})}}if(c&&c.length){d=0;for(h=0;c.length>h;h++){var y=i.storageTextureBindings[h];f[3].push({binding:null!=(p=y.binding)?p:d++,resource:(T=y.texture).gpuTextureView})}}var S=f.findLastIndex(function(e){return!!e.length});return a.gpuBindGroup=f.map(function(e,t){return S>=t&&a.device.device.createBindGroup({layout:o.getBindGroupLayout(t),entries:e})}),a}return se(t,e),t}(En),Rn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.Buffer;var i=r.usage,a=r.viewOrSize,o=!!(i&Ne.MAP_READ);n.usage=function(e){var t=0;return e&Ne.INDEX&&(t|=GPUBufferUsage.INDEX),e&Ne.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&Ne.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&Ne.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&Ne.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),e&Ne.INDIRECT&&(t|=GPUBufferUsage.INDIRECT),t|GPUBufferUsage.COPY_DST}(i),o&&(n.usage=Ne.MAP_READ|Ne.COPY_DST);var s=!G(a);(n.view=G(a)?null:a,n.size=G(a)?lt(a,4):lt(a.byteLength,4),G(a))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!o&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(a&&a.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(a),n.gpuBuffer.unmap());return n}return se(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,a=t.byteOffset+r,o=a+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(a,o));(t=new Uint8Array(s)).set(u),r=0,a=0,o=s,n=s}for(var l=15728640,c=0;o-(a+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,a+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,a+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(En),mn=function(){function e(){this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null},e.prototype.beginComputePass=function(e){$e(null===this.gpuComputePassEncoder),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=Je(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){var t=this,r=e;r.gpuBindGroup.forEach(function(e,n){e&&t.gpuComputePassEncoder.setBindGroup(n,r.gpuBindGroup[n])})},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),Tn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var i=r.program.computeStage;if(null===i)return n;var a={layout:"auto",compute:ue({},i)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return se(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(En),gn=function(e){function t(t){var r,n,i,a,o=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=ve.InputLayout;var u=[];try{for(var l=fe(o.vertexBufferDescriptors),c=l.next();!c.done;c=l.next()){var f=c.value,d=f.attributes;u.push({arrayStride:f.arrayStride,stepMode:fn(f.stepMode),attributes:[]});try{for(var h=(i=void 0,fe(d)),_=h.next();!_.done;_=h.next()){var p=_.value,E=p.offset;u[u.length-1].attributes.push({shaderLocation:p.shaderLocation,format:dn(p.format),offset:E})}}catch(e){i={error:e}}finally{try{_&&!_.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===Xe.U16_R)return"uint16";if(e===Xe.U32_R)return"uint32";throw Error("whoops")}}(o.indexBufferFormat),s.buffers=u,s}return se(t,e),t}(En),An=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return se(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,a=e.entryPoint,o=e.postprocess,s=e.wgsl;if(!s)try{s=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var u=function(e){if(!s.includes(e))return"continue";s=(s=s.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")})};try{for(var l=fe(["u_TextureFramebufferDepth"]),c=l.next();!c.done;c=l.next()){u(c.value)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return o&&(s=o(s)),{module:this.device.device.createShaderModule({code:s}),entryPoint:a||"main"}},t}(En),yn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:$r(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return se(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(En),Sn=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.Readback,r}return se(t,e),t.prototype.readTexture=function(e,t,r,n,i,a,o,s){return void 0===o&&(o=0),le(this,void 0,void 0,function(){var s,u,l,c,f,d,h;return ce(this,function(_){return u=pn((s=e).gpuTextureformat),d=this.device.createBuffer({usage:Ne.STORAGE|Ne.MAP_READ|Ne.COPY_DST,hint:Me.STATIC,viewOrSize:f=(c=256*Math.ceil((l=Math.ceil(n/u.width)*u.length)/256))*i}),(h=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:s.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([h.finish()]),[2,this.readBuffer(d,0,a.byteLength===f?a:null,o,f,s.format,!0,!1,l,c,i)]})})},t.prototype.readTextureSync=function(e,t,r,n,i,a,o,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,a,o,s,u,l,c){var f=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===a&&(a=Xe.U8_RGB),void 0===o&&(o=!1),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=0);var d=e,h=i||d.size,_=r||d.view,p=_&&_.constructor&&_.constructor.BYTES_PER_ELEMENT||qe(a),E=d;if(!(d.usage&Ne.MAP_READ&&d.usage&Ne.COPY_DST)){var v=this.device.device.createCommandEncoder();E=this.device.createBuffer({usage:Ne.STORAGE|Ne.MAP_READ|Ne.COPY_DST,hint:Me.STATIC,viewOrSize:h}),v.copyBufferToBuffer(d.gpuBuffer,t,E.gpuBuffer,0,h),this.device.device.queue.submit([v.finish()])}return new Promise(function(e,r){E.gpuBuffer.mapAsync(Hr.READ,t,h).then(function(){var r=E.gpuBuffer.getMappedRange(t,h),n=_;if(o)n=null===n?hn(a,h,!0,r):hn(a,n.buffer,void 0,r);else if(null===n)switch(p){case 1:(n=new Uint8Array(h)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(h/2,r);break;case 4:(n=new Float32Array(h/4)).set(new Float32Array(r))}else switch(p){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(h/2,r,_);break;case 4:var i=_&&_.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}if(u!==l){1!==p||o||(u*=2,l*=2);for(var s=new Uint8Array(n.buffer),d=u,v=0,R=1;c>R;++R){v=R*l;for(var m=0;u>m;++m)s[d++]=s[v++]}n=0===p||o?new Uint8Array(s.buffer,0,d):new Float32Array(s.buffer,0,d/4)}E.gpuBuffer.unmap(),e(n)},function(e){return r(e)})})},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n=new Uint16Array(t);e--;)r[e]=_n(n[e]);return r},t}(En),Cn=function(){function e(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getEncoder=function(){var e;return(null===(e=this.renderBundle)||void 0===e?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder},e.prototype.getTextureView=function(e,t){return $e(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,a,o;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var u=0;e.colorAttachment.length>u;u++){var l=e.colorAttachment[u],c=e.colorResolveTo[u];if(null===l&&null!==c&&(l=c,c=null),this.gfxColorAttachment[u]=l,this.gfxColorResolveTo[u]=c,this.gfxColorAttachmentLevel[u]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[u])||0,this.gfxColorResolveToLevel[u]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[u])||0,null===l){this.gpuColorAttachments.length=u,this.gfxColorAttachment.length=u,this.gfxColorResolveTo.length=u;break}void 0===this.gpuColorAttachments[u]&&(this.gpuColorAttachments[u]={}),(d=this.gpuColorAttachments[u]).view=this.getTextureView(l,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[u])||0);var f=null!==(a=null===(i=e.colorClearColor)||void 0===i?void 0:i[u])&&void 0!==a?a:"load";"load"===f?d.loadOp="load":(d.loadOp="clear",d.clearValue=f),d.storeOp=(null===(o=e.colorStore)||void 0===o?void 0:o[u])?"store":"discard",d.resolveTarget=void 0,null!==c&&(l.sampleCount>1?d.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[u]):d.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var d,h=e.depthStencilAttachment;(d=this.gpuDepthStencilAttachment).view=h.gpuTextureView,!!(je(h.format)&Ve.Depth)?("load"===e.depthClearValue?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),d.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0),!!(je(h.format)&Ve.Stencil)?("load"===e.stencilClearValue?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),d.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=U(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e,t){$e(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(t),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,a){void 0===i&&(i=0),void 0===a&&(a=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,a)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=Je(e.gpuRenderPipeline);this.getEncoder().setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=this.getEncoder(),i=e;null!==r&&n.setIndexBuffer(qr(r.buffer),Je(i.indexFormat),r.offset);for(var a=0;t.length>a;a++){var o=t[a];null!==o&&n.setVertexBuffer(a,qr(o.buffer),o.offset)}}},e.prototype.setBindings=function(e){var t=e,r=this.getEncoder();t.gpuBindGroup.forEach(function(e,n){e&&r.setBindGroup(n,t.gpuBindGroup[n])})},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.getEncoder().draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.getEncoder().drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.getEncoder().drawIndirect(qr(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.getEncoder().drawIndexedIndirect(qr(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.beginBundle=function(e){this.renderBundle=e},e.prototype.endBundle=function(){this.renderBundle.finish()},e.prototype.executeBundles=function(e){this.gpuRenderPassEncoder.executeBundles(e.map(function(e){return e.renderBundle}))},e.prototype.finish=function(){var e;null===(e=this.gpuRenderPassEncoder)||void 0===e||e.end(),this.gpuRenderPassEncoder=null;for(var t=0;this.gfxColorAttachment.length>t;t++){var r=this.gfxColorAttachment[t],n=this.gfxColorResolveTo[t];null!==r&&null!==n&&1===r.sampleCount&&this.copyAttachment(n,this.gfxColorAttachmentLevel[t],r,this.gfxColorResolveToLevel[t])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null},e.prototype.copyAttachment=function(e,t,r,n){$e(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},a={texture:e.gpuTexture,mipLevel:t};$e(r.width>>>n===e.width>>>t),$e(r.height>>>n===e.height>>>t),$e(!!(r.usage&Wr.COPY_SRC)),$e(!!(e.usage&Wr.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(i,a,[e.width,e.height,1])},e}(),Pn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return se(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(En),Nn=function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Sampler;var o=i.lodMinClamp,s=i.mipmapFilter===Ce.NO_MIP?i.lodMinClamp:i.lodMaxClamp,u=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return u>1&&$e(i.minFilter===Se.BILINEAR&&i.magFilter===Se.BILINEAR&&i.mipmapFilter===Ce.LINEAR),a.gpuSampler=a.device.device.createSampler({addressModeU:Kr(i.addressModeU),addressModeV:Kr(i.addressModeV),addressModeW:Kr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:o,lodMaxClamp:s,minFilter:jr(i.minFilter),magFilter:jr(i.magFilter),mipmapFilter:Zr(i.mipmapFilter),compare:void 0!==i.compareFunction?ln(i.compareFunction):void 0,maxAnisotropy:u}),a}return se(t,e),t}(En),Mn=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Texture,a.flipY=!1;var o=r.format,s=r.dimension,u=r.width,l=r.height,c=r.depthOrArrayLayers,f=r.mipLevelCount,d=r.usage,h=r.pixelStore;return a.flipY=!!(null==h?void 0:h.unpackFlipY),a.device.createTextureShared({format:o,dimension:null!=s?s:xe.TEXTURE_2D,width:u,height:l,depthOrArrayLayers:null!=c?c:1,mipLevelCount:null!=f?f:1,usage:d,sampleCount:null!=i?i:1},a,n),a}return se(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,a={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},o=e.createTexture(a),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s],flipY:this.flipY},{texture:o,origin:[0,0,s]},[n,i]);return[o,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,a,o=this,s=this.device.device;if(this.isImageBitmapOrCanvases(e))n=(r=de(this.textureFromImageBitmapOrCanvas(s,e,this.depthOrArrayLayers),3))[0],i=r[1],a=r[2];else if(this.isVideo(e))n=s.importExternalTexture({source:e[0]});else{var u=pn(this.gpuTextureformat),l=Math.ceil(this.width/u.width)*u.length;e.forEach(function(e){s.queue.writeTexture({texture:o.gpuTexture},e,{bytesPerRow:l},{width:o.width,height:o.height})})}this.width=i,this.height=a,n&&(this.gpuTexture=n),this.gpuTextureView=this.gpuTexture.createView({dimension:Yr(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(En),On=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.RenderBundle,r.renderBundleEncoder=r.device.device.createRenderBundleEncoder({colorFormats:[r.device.swapChainFormat]}),r}return se(t,e),t.prototype.finish=function(){this.renderBundle=this.renderBundleEncoder.finish()},t}(En),In=function(){function e(e,t,r,n,i,a){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Wr.RENDER_ATTACHMENT|Wr.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Fe.UPPER_LEFT,this.clipSpaceNearZ=Ue.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.WGSLComposer=a,this.fallbackTexture2D=this.createFallbackTexture(xe.TEXTURE_2D,Le.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(xe.TEXTURE_2D,Le.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(xe.TEXTURE_2D_ARRAY,Le.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(xe.TEXTURE_3D,Le.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(xe.TEXTURE_CUBE_MAP,Le.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:ye.REPEAT,addressModeV:ye.REPEAT,minFilter:Se.POINT,magFilter:Se.POINT,mipmapFilter:Ce.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:ye.REPEAT,addressModeV:ye.REPEAT,minFilter:Se.POINT,magFilter:Se.POINT,mipmapFilter:Ce.NEAREST,compareFunction:Re.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Mn({id:0,device:this,descriptor:{format:Xe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:xe.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){$e(0===this.frameCommandEncoderPool.length)},e.prototype.endFrame=function(){$e(this.frameCommandEncoderPool.every(function(e){return null!==e})),this.device.queue.submit(this.frameCommandEncoderPool.map(function(e){return e.finish()})),this.frameCommandEncoderPool=[]},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new Rn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Mn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new Nn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Mn({id:this.getNextUniqueId(),device:this,descriptor:ue(ue({},e),{dimension:xe.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:Be.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=ve.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,a=e.sampleCount,o=e.mipLevelCount,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;$e(!!(l&Wr.RENDER_ATTACHMENT));var c=new Mn({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:xe.TEXTURE_2D,mipLevelCount:o,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=a,c.gpuTexture=s,c.gpuTextureView=u,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=dr(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=dr(this.queryVendorInfo(),"frag",e.fragment.glsl)),new An({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createProgramSimple=function(e){return new An({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,a=zr(e.format),o=function(e){if(e===xe.TEXTURE_2D)return"2d";if(e===xe.TEXTURE_CUBE_MAP)return"2d";if(e===xe.TEXTURE_2D_ARRAY)return"2d";if(e===xe.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Be.SAMPLED&&(t|=Wr.TEXTURE_BINDING|Wr.COPY_DST|Wr.COPY_SRC),e&Be.STORAGE&&(t|=Wr.TEXTURE_BINDING|Wr.STORAGE_BINDING|Wr.COPY_SRC|Wr.COPY_DST),e&Be.RENDER_TARGET&&(t|=Wr.RENDER_ATTACHMENT|Wr.TEXTURE_BINDING|Wr.COPY_SRC|Wr.COPY_DST),t}(e.usage);if(t.gpuTextureformat=a,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:a,dimension:o,sampleCount:e.sampleCount,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},e.prototype.getFallbackSampler=function(e){return e.formatKind===Le.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===xe.TEXTURE_2D)return e.formatKind===Le.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===xe.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===xe.TEXTURE_3D)return this.fallbackTexture3D;if(t===xe.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===Le.Float?Xe.U8_RGBA_NORM:Xe.D24,usage:Be.SAMPLED,width:1,height:1,depthOrArrayLayers:e===xe.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new vn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new gn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new Tn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Pn({id:this.getNextUniqueId(),device:this,descriptor:ue({},e)})},e.prototype.createQueryPool=function(e,t){return new yn({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,i=n.program,a=i.vertexStage,o=i.fragmentStage;if(null!==a&&null!==o){var s=n.megaStateDescriptor||{},u=s.stencilBack,l=s.stencilFront,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(s,["stencilBack","stencilFront"]),f=Rt(Tt);n.megaStateDescriptor=ue(ue(ue({},f),{stencilBack:ue(ue({},f.stencilBack),u),stencilFront:ue(ue({},f.stencilFront),l)}),c);var d=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach(function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=pt(void 0,d))});var h,_,p=(h=null!==(r=n.topology)&&void 0!==r?r:Pe.TRIANGLES,_=n.megaStateDescriptor,{topology:Jr(h),cullMode:en(_.cullMode),frontFace:tn(_.frontFace)}),E=un(n.colorAttachmentFormats,n.megaStateDescriptor),v=function(e,t){if(!U(e))return{format:zr(e),depthWriteEnabled:!!t.depthWrite,depthCompare:ln(t.depthCompare),depthBias:t.polygonOffset?t.polygonOffsetUnits:0,depthBiasSlopeScale:t.polygonOffset?t.polygonOffsetFactor:0,stencilFront:{compare:ln(t.stencilFront.compare),passOp:cn(t.stencilFront.passOp),failOp:cn(t.stencilFront.failOp),depthFailOp:cn(t.stencilFront.depthFailOp)},stencilBack:{compare:ln(t.stencilBack.compare),passOp:cn(t.stencilBack.passOp),failOp:cn(t.stencilBack.failOp),depthFailOp:cn(t.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),R=void 0;null!==n.inputLayout&&(R=n.inputLayout.buffers);var m=n.sampleCount,T={layout:"auto",vertex:ue(ue({},a),{buffers:R}),primitive:p,depthStencil:v,multisample:{count:m},fragment:ue(ue({},o),{targets:E})};e.gpuRenderPipeline=this.device.createRenderPipeline(T)}}},e.prototype.createReadback=function(){return new Sn({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderBundle=function(){return new On({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();void 0===t&&(t=new Cn(this));var r=this.frameCommandEncoderPool.pop();return void 0===r&&(r=this.device.createCommandEncoder()),t.beginRenderPass(r,e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();void 0===e&&(e=new mn);var t=this.frameCommandEncoderPool.pop();return void 0===t&&(t=this.device.createCommandEncoder()),e.beginComputePass(t),e},e.prototype.submitPass=function(e){var t=e;t instanceof Cn?(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.renderPassPool.push(t)):t instanceof mn&&(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.computePassPool.push(t))},e.prototype.copySubTexture2D=function(e,t,r,n,i,a,o){var s=this.device.createCommandEncoder(),u=e,l=n,c={texture:l.gpuTexture,origin:[i,a,0],mipLevel:0,aspect:"all"},f={texture:u.gpuTexture,origin:[t,r,0],mipLevel:0,aspect:"all"};$e(!!(l.usage&Wr.COPY_SRC)),$e(!!(u.usage&Wr.COPY_DST)),s.copyTextureToTexture(c,f,[l.width,l.height,o||1]),this.device.queue.submit([s.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_SNORM:case we.BC4_UNORM:case we.BC5_SNORM:case we.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_SNORM:case we.BC4_UNORM:case we.BC5_SNORM:case we.BC5_UNORM:return 4;default:return 1}}(e);return t%n===0&&r%n===0&&this.featureTextureCompressionBC}switch(e){case Xe.U16_RGBA_NORM:case Xe.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===ve.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===ve.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ve.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ve.Sampler){(r=e).gpuSampler.label=t}else if(e.type===ve.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),xn=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return le(this,void 0,void 0,function(){var t,r,n,i,a,o;return ce(this,function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc","float32-filterable"].filter(function(e){return t.features.has(e)}),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(a=this.pluginOptions.onContextLost,i.lost.then(function(){a&&a()})),null===i)return[2,null];if(!(o=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,Xr(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new In(t,i,e,o,wr,Gr&&new Gr)]}})})},e}();function Bn(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=R(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}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(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}var Dn={exports:{}};function bn(e,t,r){r=r||2;var n,i,a,o,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,d=Ln(e,0,f,r,!0),h=[];if(!d||d.next===d.prev)return h;if(c&&(d=function(e,t,r,n){var i,a,o,s=[];for(i=0,a=t.length;a>i;i++)(o=Ln(e,t[i]*n,a-1>i?t[i+1]*n:e.length,n,!1))===o.next&&(o.steiner=!0),s.push(Yn(o));for(s.sort(Xn),i=0;s.length>i;i++)r=Wn(s[i],r);return r}(e,t,d,r)),e.length>80*r){n=a=e[0],i=o=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(u=e[_+1])&&(i=u),s>a&&(a=s),u>o&&(o=u);l=0!==(l=Math.max(a-n,o-i))?32767/l:0}return Un(d,h,r,n,i,l,0),h}function Ln(e,t,r,n,i){var a,o;if(i===ai(e,t,r,n)>0)for(a=t;r>a;a+=n)o=ri(a,e[a],e[a+1],o);else for(a=r-n;a>=t;a-=n)o=ri(a,e[a],e[a+1],o);return o&&qn(o,o.next)&&(ni(o),o=o.next),o}function Fn(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!qn(n,n.next)&&0!==Zn(n.prev,n,n.next))n=n.next;else{if(ni(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function Un(e,t,r,n,i,a,o){if(e){!o&&a&&function(e,t,r,n){var i=e;do{0===i.z&&(i.z=zn(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,a,o,s,u,l=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,n=r,s=0,t=0;l>t&&(s++,n=n.nextZ);t++);for(u=l;s>0||u>0&&n;)0===s||0!==u&&n&&r.z>n.z?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,s--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=n}a.nextZ=null,l*=2}while(o>1)}(i)}(e,n,i,a);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,a?wn(e,n,i,a):kn(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(u.i/r|0),ni(e),e=u.next,l=u.next;else if((e=u)===l){o?1===o?Un(e=Gn(Fn(e),t,r),t,r,n,i,a,2):2===o&&Vn(e,t,r,n,i,a):Un(Fn(e),t,r,n,i,a,1);break}}}function kn(e){var t=e.prev,r=e,n=e.next;if(Zn(t,r,n)>=0)return!1;for(var i=t.x,a=r.x,o=n.x,s=t.y,u=r.y,l=n.y,c=a>i?o>i?i:o:o>a?a:o,f=u>s?l>s?s:l:l>u?u:l,d=i>a?i>o?i:o:a>o?a:o,h=s>u?s>l?s:l:u>l?u:l,_=n.next;_!==t;){if(_.x>=c&&d>=_.x&&_.y>=f&&h>=_.y&&Kn(i,s,a,u,o,l,_.x,_.y)&&Zn(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function wn(e,t,r,n){var i=e.prev,a=e,o=e.next;if(Zn(i,a,o)>=0)return!1;for(var s=i.x,u=a.x,l=o.x,c=i.y,f=a.y,d=o.y,h=u>s?l>s?s:l:l>u?u:l,_=f>c?d>c?c:d:d>f?f:d,p=s>u?s>l?s:l:u>l?u:l,E=c>f?c>d?c:d:f>d?f:d,v=zn(h,_,t,r,n),R=zn(p,E,t,r,n),m=e.prevZ,T=e.nextZ;m&&m.z>=v&&T&&R>=T.z;){if(m.x>=h&&p>=m.x&&m.y>=_&&E>=m.y&&m!==i&&m!==o&&Kn(s,c,u,f,l,d,m.x,m.y)&&Zn(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,T.x>=h&&p>=T.x&&T.y>=_&&E>=T.y&&T!==i&&T!==o&&Kn(s,c,u,f,l,d,T.x,T.y)&&Zn(T.prev,T,T.next)>=0)return!1;T=T.nextZ}for(;m&&m.z>=v;){if(m.x>=h&&p>=m.x&&m.y>=_&&E>=m.y&&m!==i&&m!==o&&Kn(s,c,u,f,l,d,m.x,m.y)&&Zn(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;T&&R>=T.z;){if(T.x>=h&&p>=T.x&&T.y>=_&&E>=T.y&&T!==i&&T!==o&&Kn(s,c,u,f,l,d,T.x,T.y)&&Zn(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Gn(e,t,r){var n=e;do{var i=n.prev,a=n.next.next;!qn(i,a)&&Qn(i,n,n.next,a)&&ei(i,a)&&ei(a,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(a.i/r|0),ni(n),ni(n.next),n=e=a),n=n.next}while(n!==e);return Fn(n)}function Vn(e,t,r,n,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&jn(o,s)){var u=ti(o,s);return o=Fn(o,o.next),u=Fn(u,u.next),Un(o,t,r,n,i,a,0),void Un(u,t,r,n,i,a,0)}s=s.next}o=o.next}while(o!==e)}function Xn(e,t){return e.x-t.x}function Wn(e,t){var r=function(e,t){var r,n=t,i=e.x,a=e.y,o=-1/0;do{if(n.y>=a&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>o&&(o=s,r=n.next.x>n.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;var u,l=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!Kn(f>a?i:o,a,c,f,f>a?o:i,a,n.x,n.y)||(u=Math.abs(a-n.y)/(i-n.x),ei(n,e)&&(d>u||u===d&&(n.x>r.x||n.x===r.x&&Hn(r,n)))&&(r=n,d=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=ti(r,e);return Fn(n,n.next),Fn(r,r.next)}function Hn(e,t){return 0>Zn(e.prev,e,t.prev)&&0>Zn(t.next,e,e.next)}function zn(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Yn(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function Kn(e,t,r,n,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(n-s)>=(r-o)*(t-s)&&(r-o)*(a-s)>=(i-o)*(n-s)}function jn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Qn(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ei(e,t)&&ei(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(Zn(e.prev,e,t.prev)||Zn(e,t.prev,t))||qn(e,t)&&Zn(e.prev,e,e.next)>0&&Zn(t.prev,t,t.next)>0)}function Zn(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function qn(e,t){return e.x===t.x&&e.y===t.y}function Qn(e,t,r,n){var i=Jn(Zn(e,t,r)),a=Jn(Zn(e,t,n)),o=Jn(Zn(r,n,e)),s=Jn(Zn(r,n,t));return i!==a&&o!==s||(!(0!==i||!$n(e,r,t))||(!(0!==a||!$n(e,n,t))||(!(0!==o||!$n(r,e,n))||!(0!==s||!$n(r,t,n)))))}function $n(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function Jn(e){return e>0?1:0>e?-1:0}function ei(e,t){return 0>Zn(e.prev,e,e.next)?Zn(e,t,e.next)>=0&&Zn(e,e.prev,t)>=0:0>Zn(e,t,e.prev)||0>Zn(e,e.next,t)}function ti(e,t){var r=new ii(e.i,e.x,e.y),n=new ii(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function ri(e,t,r,n){var i=new ii(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ni(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 ii(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ai(e,t,r,n){for(var i=0,a=t,o=r-n;r>a;a+=n)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}Dn.exports=bn,Dn.exports.default=bn,bn.deviation=function(e,t,r,n){var i=t&&t.length,a=Math.abs(ai(e,0,i?t[0]*r:e.length,r));if(i)for(var o=0,s=t.length;s>o;o++){a-=Math.abs(ai(e,t[o]*r,s-1>o?t[o+1]*r:e.length,r))}var u=0;for(o=0;n.length>o;o+=3){var l=n[o]*r,c=n[o+1]*r,f=n[o+2]*r;u+=Math.abs((e[l]-e[f])*(e[c+1]-e[l+1])-(e[l]-e[c])*(e[f+1]-e[l+1]))}return 0===a&&0===u?0:Math.abs((u-a)/a)},bn.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var a=0;e[i].length>a;a++)for(var o=0;t>o;o++)r.vertices.push(e[i][a][o]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var oi=Dn.exports;
|
|
11
|
+
var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function a(r,n,i,a){var u=Object.create((n&&n.prototype instanceof s?n:s).prototype);return N(u,"_invoke",function(r,n,i){var a,s,u,l=0,c=i||[],f=!1,d={p:0,n:0,v:e,a:_,f:_.bind(e,4),d:function(t,r){return a=t,s=0,u=e,d.n=r,o}};function _(r,n){for(s=r,u=n,t=0;!f&&l&&!i&&c.length>t;t++){var i,a=c[t],_=d.p,h=a[2];r>3?(i=h===n)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):_>=a[0]&&((i=2>r&&a[1]>_)?(s=0,d.v=n,d.n=a[1]):h>_&&(i=3>r||a[0]>n||n>h)&&(a[4]=r,a[5]=n,d.n=h,s=0))}if(i||r>1)return o;throw f=!0,n}return function(i,c,h){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&_(c,h),s=c,u=h;(t=2>s?e:u)||!f;){a||(s?3>s?(s>1&&(d.n=-1),_(s,u)):d.n=u:d.v=u);try{if(l=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,2>s&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),2>s&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(f=0>d.n)?u:r.call(n,d))!==o)break}catch(t){a=e,s=1,u=t}finally{l=1}}return{value:t,done:f}}}(r,i,a),!0),u}var o={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(N(t={},n,function(){return this}),t),f=l.prototype=s.prototype=Object.create(c);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,N(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=l,N(f,"constructor",l),N(l,"constructor",u),u.displayName="GeneratorFunction",N(l,i,"GeneratorFunction"),N(f),N(f,i,"Generator"),N(f,n,function(){return this}),N(f,"toString",function(){return"[object Generator]"}),(M=function(){return{w:a,m:d}})()}function O(e,t){function r(n,i,a,o){try{var s=e[n](i),u=s.value;return u instanceof P?t.resolve(u.v).then(function(e){r("next",e,a,o)},function(e){r("throw",e,a,o)}):t.resolve(u).then(function(e){s.value=e,a(s)},function(e){return r("throw",e,a,o)})}catch(e){o(e)}}var n;this.next||(N(O.prototype),N(O.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),N(this,"_invoke",function(e,i,a){function o(){return new t(function(t,n){r(e,a,t,n)})}return n=n?n.then(o,o):o()},!0)}function I(e,t,r,n,i){return new O(M().w(e,t,r,n),i||Promise)}function x(e,t,r,n,i){var a=I(e,t,r,n,i);return a.next().then(function(e){return e.done?e.value:a.next()})}function B(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}}function D(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(r(e)+" is not iterable")}function b(){var e=M(),t=e.m(b),r=(Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__).constructor;function n(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===r||"GeneratorFunction"===(t.displayName||t.name))}var i={throw:1,return:2,break:3,continue:3};function a(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,i[e],t)},delegateYield:function(e,i,a){return t.resultName=i,r(n.d,D(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,i){n.p=t.prev,n.n=t.next;try{return e(r,i)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(b=function(){return{wrap:function(t,r,n,i){return e.w(a(t),r,n,i&&i.reverse())},isGeneratorFunction:n,mark:e.m,awrap:function(e,t){return new P(e,t)},AsyncIterator:O,async:function(e,t,r,i,o){return(n(t)?I:x)(a(e),t,r,i,o)},keys:B,values:D}})()}function L(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function F(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){L(a,n,i,o,s,"next",e)}function s(e){L(a,n,i,o,s,"throw",e)}o(void 0)})}}function U(e){return null==e}function k(e){return"string"==typeof e}var w=function(e,t,r){return t>e?t:e>r?r:e};function G(e){return"number"==typeof e}var V=1e-6,X="undefined"!=typeof Float32Array?Float32Array:Array;function W(){var e=new X(16);return X!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function H(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Y(e,t,r,n,i,a,o,s,u,l,c,f,d,_,h,p){var E=new X(16);return E[0]=e,E[1]=t,E[2]=r,E[3]=n,E[4]=i,E[5]=a,E[6]=o,E[7]=s,E[8]=u,E[9]=l,E[10]=c,E[11]=f,E[12]=d,E[13]=_,E[14]=h,E[15]=p,E}function z(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function K(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],f=t[9],d=t[10],_=t[11],h=t[12],p=t[13],E=t[14],v=t[15],R=r*s-n*o,T=r*u-i*o,A=r*l-a*o,m=n*u-i*s,g=n*l-a*s,S=i*l-a*u,y=c*p-f*h,C=c*E-d*h,P=c*v-_*h,N=f*E-d*p,M=f*v-_*p,O=d*v-_*E,I=R*O-T*M+A*N+m*P-g*C+S*y;return I?(e[0]=(s*O-u*M+l*N)*(I=1/I),e[1]=(i*M-n*O-a*N)*I,e[2]=(p*S-E*g+v*m)*I,e[3]=(d*g-f*S-_*m)*I,e[4]=(u*P-o*O-l*C)*I,e[5]=(r*O-i*P+a*C)*I,e[6]=(E*A-h*S-v*T)*I,e[7]=(c*S-d*A+_*T)*I,e[8]=(o*M-s*P+l*y)*I,e[9]=(n*P-r*M-a*y)*I,e[10]=(h*g-p*A+v*R)*I,e[11]=(f*A-c*g-_*R)*I,e[12]=(s*C-o*N-u*y)*I,e[13]=(r*N-n*C+i*y)*I,e[14]=(p*T-h*m-E*R)*I,e[15]=(c*m-f*T+d*R)*I,e):null}function j(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],d=t[9],_=t[10],h=t[11],p=t[12],E=t[13],v=t[14],R=t[15],T=r[0],A=r[1],m=r[2],g=r[3];return e[0]=T*n+A*s+m*f+g*p,e[1]=T*i+A*u+m*d+g*E,e[2]=T*a+A*l+m*_+g*v,e[3]=T*o+A*c+m*h+g*R,e[4]=(T=r[4])*n+(A=r[5])*s+(m=r[6])*f+(g=r[7])*p,e[5]=T*i+A*u+m*d+g*E,e[6]=T*a+A*l+m*_+g*v,e[7]=T*o+A*c+m*h+g*R,e[8]=(T=r[8])*n+(A=r[9])*s+(m=r[10])*f+(g=r[11])*p,e[9]=T*i+A*u+m*d+g*E,e[10]=T*a+A*l+m*_+g*v,e[11]=T*o+A*c+m*h+g*R,e[12]=(T=r[12])*n+(A=r[13])*s+(m=r[14])*f+(g=r[15])*p,e[13]=T*i+A*u+m*d+g*E,e[14]=T*a+A*l+m*_+g*v,e[15]=T*o+A*c+m*h+g*R,e}function Z(e,t,r){var n=r[0],i=r[1],a=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function q(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Q(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=n+n,u=i+i,l=a+a,c=n*s,f=n*u,d=n*l,_=i*u,h=i*l,p=a*l,E=o*s,v=o*u,R=o*l;return e[0]=1-(_+p),e[1]=f+R,e[2]=d-v,e[3]=0,e[4]=f-R,e[5]=1-(c+p),e[6]=h+E,e[7]=0,e[8]=d+v,e[9]=h-E,e[10]=1-(c+_),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function J(e,t){var r=t[0],n=t[1],i=t[2],a=t[4],o=t[5],s=t[6],u=t[8],l=t[9],c=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(a*a+o*o+s*s),e[2]=Math.sqrt(u*u+l*l+c*c),e}function $(e,t,r,n,i){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o}else e[10]=-1,e[14]=-2*n;return e}function ee(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e}function te(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}var re,ne=j,ie=Object.freeze({__proto__:null,add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],c=t[8],f=t[9],d=t[10],_=t[11],h=t[12],p=t[13],E=t[14],v=t[15],R=r*s-n*o,T=r*u-i*o,A=r*l-a*o,m=n*u-i*s,g=n*l-a*s,S=i*l-a*u,y=c*p-f*h,C=c*E-d*h,P=c*v-_*h,N=f*E-d*p,M=f*v-_*p,O=d*v-_*E;return e[0]=s*O-u*M+l*N,e[1]=i*M-n*O-a*N,e[2]=p*S-E*g+v*m,e[3]=d*g-f*S-_*m,e[4]=u*P-o*O-l*C,e[5]=r*O-i*P+a*C,e[6]=E*A-h*S-v*T,e[7]=c*S-d*A+_*T,e[8]=o*M-s*P+l*y,e[9]=n*P-r*M-a*y,e[10]=h*g-p*A+v*R,e[11]=f*A-c*g-_*R,e[12]=s*C-o*N-u*y,e[13]=r*N-n*C+i*y,e[14]=p*T-h*m-E*R,e[15]=c*m-f*T+d*R,e},clone:function(e){var t=new X(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},copy:H,create:W,decompose:function(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var i=n[0],a=n[1],o=n[2],s=n[4],u=n[5],l=n[6],c=n[8],f=n[9],d=n[10];r[0]=Math.sqrt(i*i+a*a+o*o),r[1]=Math.sqrt(s*s+u*u+l*l),r[2]=Math.sqrt(c*c+f*f+d*d);var _=1/r[0],h=1/r[1],p=1/r[2],E=i*_,v=a*h,R=o*p,T=s*_,A=u*h,m=l*p,g=c*_,S=f*h,y=d*p,C=E+A+y,P=0;return C>0?(e[3]=.25*(P=2*Math.sqrt(C+1)),e[0]=(m-S)/P,e[1]=(g-R)/P,e[2]=(v-T)/P):E>A&&E>y?(e[3]=(m-S)/(P=2*Math.sqrt(1+E-A-y)),e[0]=.25*P,e[1]=(v+T)/P,e[2]=(g+R)/P):A>y?(e[3]=(g-R)/(P=2*Math.sqrt(1+A-E-y)),e[0]=(v+T)/P,e[1]=.25*P,e[2]=(m+S)/P):(e[3]=(v-T)/(P=2*Math.sqrt(1+y-E-A)),e[0]=(g+R)/P,e[1]=(m+S)/P,e[2]=.25*P),e},determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[4],a=e[5],o=e[6],s=e[8],u=e[9],l=e[10],c=e[12],f=e[13],d=e[14],_=t*a-r*i,h=t*o-n*i,p=r*o-n*a,E=s*f-u*c,v=s*d-l*c,R=u*d-l*f;return e[7]*(t*R-r*v+n*E)-e[3]*(i*R-a*v+o*E)+e[15]*(s*p-u*h+l*_)-e[11]*(c*p-f*h+d*_)},equals:function(e,t){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],c=e[8],f=e[9],d=e[10],_=e[11],h=e[12],p=e[13],E=e[14],v=e[15],R=t[0],T=t[1],A=t[2],m=t[3],g=t[4],S=t[5],y=t[6],C=t[7],P=t[8],N=t[9],M=t[10],O=t[11],I=t[12],x=t[13],B=t[14],D=t[15];return!(Math.abs(r-R)>V*Math.max(1,Math.abs(r),Math.abs(R))||Math.abs(n-T)>V*Math.max(1,Math.abs(n),Math.abs(T))||Math.abs(i-A)>V*Math.max(1,Math.abs(i),Math.abs(A))||Math.abs(a-m)>V*Math.max(1,Math.abs(a),Math.abs(m))||Math.abs(o-g)>V*Math.max(1,Math.abs(o),Math.abs(g))||Math.abs(s-S)>V*Math.max(1,Math.abs(s),Math.abs(S))||Math.abs(u-y)>V*Math.max(1,Math.abs(u),Math.abs(y))||Math.abs(l-C)>V*Math.max(1,Math.abs(l),Math.abs(C))||Math.abs(c-P)>V*Math.max(1,Math.abs(c),Math.abs(P))||Math.abs(f-N)>V*Math.max(1,Math.abs(f),Math.abs(N))||Math.abs(d-M)>V*Math.max(1,Math.abs(d),Math.abs(M))||Math.abs(_-O)>V*Math.max(1,Math.abs(_),Math.abs(O))||Math.abs(h-I)>V*Math.max(1,Math.abs(h),Math.abs(I))||Math.abs(p-x)>V*Math.max(1,Math.abs(p),Math.abs(x))||Math.abs(E-B)>V*Math.max(1,Math.abs(E),Math.abs(B))||Math.abs(v-D)>V*Math.max(1,Math.abs(v),Math.abs(D)))},exactEquals:function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},frob:function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])},fromQuat:function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,d=i*o,_=i*s,h=i*u,p=a*o,E=a*s,v=a*u;return e[0]=1-f-h,e[1]=c+v,e[2]=d-E,e[3]=0,e[4]=c-v,e[5]=1-l-h,e[6]=_+p,e[7]=0,e[8]=d+E,e[9]=_-p,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromQuat2:function(e,t){var r=new X(3),n=-t[0],i=-t[1],a=-t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=n*n+i*i+a*a+o*o;return f>0?(r[0]=2*(s*o+c*n+u*a-l*i)/f,r[1]=2*(u*o+c*i+l*n-s*a)/f,r[2]=2*(l*o+c*a+s*i-u*n)/f):(r[0]=2*(s*o+c*n+u*a-l*i),r[1]=2*(u*o+c*i+l*n-s*a),r[2]=2*(l*o+c*a+s*i-u*n)),Q(e,t,r),e},fromRotation:function(e,t,r){var n,i,a,o=r[0],s=r[1],u=r[2],l=Math.sqrt(o*o+s*s+u*u);return V>l?null:(o*=l=1/l,s*=l,u*=l,n=Math.sin(t),e[0]=o*o*(a=1-(i=Math.cos(t)))+i,e[1]=s*o*a+u*n,e[2]=u*o*a-s*n,e[3]=0,e[4]=o*s*a-u*n,e[5]=s*s*a+i,e[6]=u*s*a+o*n,e[7]=0,e[8]=o*u*a+s*n,e[9]=s*u*a-o*n,e[10]=u*u*a+i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromRotationTranslation:Q,fromRotationTranslationScale:function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,d=i*l,_=i*c,h=a*l,p=a*c,E=o*c,v=s*u,R=s*l,T=s*c,A=n[0],m=n[1],g=n[2];return e[0]=(1-(h+E))*A,e[1]=(d+T)*A,e[2]=(_-R)*A,e[3]=0,e[4]=(d-T)*m,e[5]=(1-(f+E))*m,e[6]=(p+v)*m,e[7]=0,e[8]=(_+R)*g,e[9]=(p-v)*g,e[10]=(1-(f+h))*g,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},fromRotationTranslationScaleOrigin:function(e,t,r,n,i){var a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,d=a*l,_=a*c,h=a*f,p=o*c,E=o*f,v=s*f,R=u*l,T=u*c,A=u*f,m=n[0],g=n[1],S=n[2],y=i[0],C=i[1],P=i[2],N=(1-(p+v))*m,M=(_+A)*m,O=(h-T)*m,I=(_-A)*g,x=(1-(d+v))*g,B=(E+R)*g,D=(h+T)*S,b=(E-R)*S,L=(1-(d+p))*S;return e[0]=N,e[1]=M,e[2]=O,e[3]=0,e[4]=I,e[5]=x,e[6]=B,e[7]=0,e[8]=D,e[9]=b,e[10]=L,e[11]=0,e[12]=r[0]+y-(N*y+I*C+D*P),e[13]=r[1]+C-(M*y+x*C+b*P),e[14]=r[2]+P-(O*y+B*C+L*P),e[15]=1,e},fromScaling:function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromTranslation:q,fromValues:Y,fromXRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},frustum:function(e,t,r,n,i,a,o){var s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},getRotation:function(e,t){var r=new X(3);J(r,t);var n=1/r[0],i=1/r[1],a=1/r[2],o=t[0]*n,s=t[1]*i,u=t[2]*a,l=t[4]*n,c=t[5]*i,f=t[6]*a,d=t[8]*n,_=t[9]*i,h=t[10]*a,p=o+c+h,E=0;return p>0?(e[3]=.25*(E=2*Math.sqrt(p+1)),e[0]=(f-_)/E,e[1]=(d-u)/E,e[2]=(s-l)/E):o>c&&o>h?(e[3]=(f-_)/(E=2*Math.sqrt(1+o-c-h)),e[0]=.25*E,e[1]=(s+l)/E,e[2]=(d+u)/E):c>h?(e[3]=(d-u)/(E=2*Math.sqrt(1+c-o-h)),e[0]=(s+l)/E,e[1]=.25*E,e[2]=(f+_)/E):(e[3]=(s-l)/(E=2*Math.sqrt(1+h-o-c)),e[0]=(d+u)/E,e[1]=(f+_)/E,e[2]=.25*E),e},getScaling:J,getTranslation:function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},identity:z,invert:K,lookAt:function(e,t,r,n){var i,a,o,s,u,l,c,f,d,_,h=t[0],p=t[1],E=t[2],v=n[0],R=n[1],T=n[2],A=r[0],m=r[1],g=r[2];return V>Math.abs(h-A)&&V>Math.abs(p-m)&&V>Math.abs(E-g)?z(e):(d=E-g,(_=Math.sqrt((i=R*(d*=_=1/Math.sqrt((c=h-A)*c+(f=p-m)*f+d*d))-T*(f*=_))*i+(a=T*(c*=_)-v*d)*a+(o=v*f-R*c)*o))?(i*=_=1/_,a*=_,o*=_):(i=0,a=0,o=0),(_=Math.sqrt((s=f*o-d*a)*s+(u=d*i-c*o)*u+(l=c*a-f*i)*l))?(s*=_=1/_,u*=_,l*=_):(s=0,u=0,l=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=a,e[5]=u,e[6]=f,e[7]=0,e[8]=o,e[9]=l,e[10]=d,e[11]=0,e[12]=-(i*h+a*p+o*E),e[13]=-(s*h+u*p+l*E),e[14]=-(c*h+f*p+d*E),e[15]=1,e)},mul:ne,multiply:j,multiplyScalar:function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},multiplyScalarAndAdd:function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},ortho:ee,orthoNO:ee,orthoZO:function(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=a*l,e[15]=1,e},perspective:$,perspectiveFromFieldOfView:function(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},perspectiveNO:$,perspectiveZO:function(e,t,r,n,i){var a=1/Math.tan(t/2);if(e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var o=1/(n-i);e[10]=i*o,e[14]=i*n*o}else e[10]=-1,e[14]=-n;return e},rotate:function(e,t,r,n){var i,a,o,s,u,l,c,f,d,_,h,p,E,v,R,T,A,m,g,S,y,C,P,N,M=n[0],O=n[1],I=n[2],x=Math.sqrt(M*M+O*O+I*I);return V>x?null:(M*=x=1/x,O*=x,I*=x,i=Math.sin(r),u=t[1],l=t[2],c=t[3],d=t[5],_=t[6],h=t[7],E=t[9],v=t[10],R=t[11],g=M*O*(o=1-(a=Math.cos(r)))-I*i,S=O*O*o+a,y=I*O*o+M*i,C=M*I*o+O*i,P=O*I*o-M*i,N=I*I*o+a,e[0]=(s=t[0])*(T=M*M*o+a)+(f=t[4])*(A=O*M*o+I*i)+(p=t[8])*(m=I*M*o-O*i),e[1]=u*T+d*A+E*m,e[2]=l*T+_*A+v*m,e[3]=c*T+h*A+R*m,e[4]=s*g+f*S+p*y,e[5]=u*g+d*S+E*y,e[6]=l*g+_*S+v*y,e[7]=c*g+h*S+R*y,e[8]=s*C+f*P+p*N,e[9]=u*C+d*P+E*N,e[10]=l*C+_*P+v*N,e[11]=c*C+h*P+R*N,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[4],o=t[5],s=t[6],u=t[7],l=t[8],c=t[9],f=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+l*n,e[5]=o*i+c*n,e[6]=s*i+f*n,e[7]=u*i+d*n,e[8]=l*i-a*n,e[9]=c*i-o*n,e[10]=f*i-s*n,e[11]=d*i-u*n,e},rotateY:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],u=t[3],l=t[8],c=t[9],f=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-l*n,e[1]=o*i-c*n,e[2]=s*i-f*n,e[3]=u*i-d*n,e[8]=a*n+l*i,e[9]=o*n+c*i,e[10]=s*n+f*i,e[11]=u*n+d*i,e},rotateZ:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),a=t[0],o=t[1],s=t[2],u=t[3],l=t[4],c=t[5],f=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+l*n,e[1]=o*i+c*n,e[2]=s*i+f*n,e[3]=u*i+d*n,e[4]=l*i-a*n,e[5]=c*i-o*n,e[6]=f*i-s*n,e[7]=d*i-u*n,e},scale:Z,set:function(e,t,r,n,i,a,o,s,u,l,c,f,d,_,h,p,E){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a,e[5]=o,e[6]=s,e[7]=u,e[8]=l,e[9]=c,e[10]=f,e[11]=d,e[12]=_,e[13]=h,e[14]=p,e[15]=E,e},str:function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},sub:te,subtract:te,targetTo:function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=n[0],u=n[1],l=n[2],c=i-r[0],f=a-r[1],d=o-r[2],_=c*c+f*f+d*d;_>0&&(c*=_=1/Math.sqrt(_),f*=_,d*=_);var h=u*d-l*f,p=l*c-s*d,E=s*f-u*c;return(_=h*h+p*p+E*E)>0&&(h*=_=1/Math.sqrt(_),p*=_,E*=_),e[0]=h,e[1]=p,e[2]=E,e[3]=0,e[4]=f*E-d*p,e[5]=d*h-c*E,e[6]=c*p-f*h,e[7]=0,e[8]=c,e[9]=f,e[10]=d,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},translate:function(e,t,r){var n,i,a,o,s,u,l,c,f,d,_,h,p=r[0],E=r[1],v=r[2];return t===e?(e[12]=t[0]*p+t[4]*E+t[8]*v+t[12],e[13]=t[1]*p+t[5]*E+t[9]*v+t[13],e[14]=t[2]*p+t[6]*E+t[10]*v+t[14],e[15]=t[3]*p+t[7]*E+t[11]*v+t[15]):(i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],d=t[9],_=t[10],h=t[11],e[0]=n=t[0],e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e[6]=l,e[7]=c,e[8]=f,e[9]=d,e[10]=_,e[11]=h,e[12]=n*p+s*E+f*v+t[12],e[13]=i*p+u*E+d*v+t[13],e[14]=a*p+l*E+_*v+t[14],e[15]=o*p+c*E+h*v+t[15]),e},transpose:function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}});function ae(e,t,r){var n=new X(3);return n[0]=e,n[1]=t,n[2]=r,n}re=new X(3),X!=Float32Array&&(re[0]=0,re[1]=0,re[2]=0);var oe=function(e,t){return oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},oe(e,t)};function se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function r(){this.constructor=e}oe(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var ue=function(){return ue=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ue.apply(this,arguments)};function le(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})}function ce(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function fe(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function de(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function _e(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function he(e,t,r,n,i,a,o,s,u,l){var c,f,d,_,h,p=e,E=t,v=r,R=n,T=s,A=u,m=120*Math.PI/180,g=Math.PI/180*(+i||0),S=[];if(l)f=l[0],d=l[1],_=l[2],h=l[3];else{E=(c=_e(p,E,-g)).y;var y=((p=c.x)-(T=(c=_e(T,A,-g)).x))/2,C=(E-(A=c.y))/2,P=y*y/(v*v)+C*C/(R*R);P>1&&(v*=P=Math.sqrt(P),R*=P);var N=v*v,M=R*R,O=(a===o?-1:1)*Math.sqrt(Math.abs((N*M-N*C*C-M*y*y)/(N*C*C+M*y*y)));_=O*v*C/R+(p+T)/2,f=Math.asin(((E-(h=O*-R*y/v+(E+A)/2))/R*1e9|0)/1e9),d=Math.asin(((A-h)/R*1e9|0)/1e9),0>(f=_>p?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=_>T?Math.PI-d:d)&&(d=2*Math.PI+d),o&&f>d&&(f-=2*Math.PI),!o&&d>f&&(d-=2*Math.PI)}var I=d-f;if(Math.abs(I)>m){var x=d,B=T,D=A;S=he(T=_+v*Math.cos(d=f+m*(o&&d>f?1:-1)),A=h+R*Math.sin(d),v,R,i,0,o,B,D,[d,x,_,h])}I=d-f;var b=Math.cos(f),L=Math.sin(f),F=Math.cos(d),U=Math.sin(d),k=Math.tan(I/4),w=4/3*v*k,G=4/3*R*k,V=[p,E],X=[p+w*L,E-G*b],W=[T+w*U,A-G*F],H=[T,A];if(X[0]=2*V[0]-X[0],X[1]=2*V[1]-X[1],l)return X.concat(W,H,S);for(var Y=[],z=0,K=(S=X.concat(W,H,S)).length;K>z;z+=1)Y[z]=z%2?_e(S[z-1],S[z],g).y:_e(S[z],S[z+1],g).x;return Y}"function"==typeof SuppressedError&&SuppressedError;var pe={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,a||e,o),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,a=Array(i);i>n;n++)a[n]=t[n].fn;return a},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var u,l,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var d,_=c.length;for(l=0;_>l;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,i);break;default:if(!u)for(d=1,u=Array(f-1);f>d;d++)u[d-1]=arguments[d];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||o(this,a);else{for(var u=0,l=[],c=s.length;c>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[a]=1===l.length?l[0]:l:o(this,a)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&o(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(pe);var Ee,ve,Re,Te,Ae,me,ge,Se,ye,Ce,Pe,Ne,Me,Oe,Ie,xe,Be,De,be,Le,Fe,Ue,ke,we,Ge,Ve,Xe,We=pe.exports;function He(e,t,r,n){return{dimension:xe.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:Be.SAMPLED}}function Ye(e,t,r){return e<<16|t<<8|r}function ze(e){return e>>>8&255}function Ke(e){return e>>>16&255}function je(e){return 255&e}function Ze(e){switch(e){case we.F32:case we.U32:case we.S32:return 4;case we.U16:case we.S16:case we.F16:return 2;case we.U8:case we.S8:return 1;default:throw Error("whoops")}}function qe(e){return Ze(Ke(e))}function Qe(e){var t=je(e);if(t&Ve.Depth)return Le.Depth;if(t&Ve.Normalized)return Le.Float;var r=Ke(e);if(r===we.F16||r===we.F32)return Le.Float;if(r===we.U8||r===we.U16||r===we.U32)return Le.Uint;if(r===we.S8||r===we.S16||r===we.S32)return Le.Sint;throw Error("whoops")}function Je(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function $e(e){if(null!=e)return e;throw Error("Missing object")}function et(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function tt(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(Ee||(Ee={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool",e[e.RenderBundle=11]="RenderBundle"}(ve||(ve={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(Re||(Re={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(Te||(Te={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(Ae||(Ae={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(me||(me={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(ge||(ge={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(Se||(Se={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(ye||(ye={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(Ce||(Ce={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(Pe||(Pe={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(Ne||(Ne={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(Me||(Me={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}(Oe||(Oe={})),function(e){e.LOADED="loaded"}(Ie||(Ie={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(xe||(xe={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET",e[e.STORAGE=4]="STORAGE"}(Be||(Be={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(De||(De={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(be||(be={})),function(e){e[e.Float=0]="Float",e[e.UnfilterableFloat=1]="UnfilterableFloat",e[e.Uint=2]="Uint",e[e.Sint=3]="Sint",e[e.Depth=4]="Depth"}(Le||(Le={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(Fe||(Fe={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(Ue||(Ue={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(ke||(ke={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(we||(we={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(Ge||(Ge={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget",e[e.Luminance=32]="Luminance"}(Ve||(Ve={})),function(e){e[e.ALPHA=Ye(we.U8,Ge.A,Ve.None)]="ALPHA",e[e.U8_LUMINANCE=Ye(we.U8,Ge.A,Ve.Luminance)]="U8_LUMINANCE",e[e.F16_LUMINANCE=Ye(we.F16,Ge.A,Ve.Luminance)]="F16_LUMINANCE",e[e.F32_LUMINANCE=Ye(we.F32,Ge.A,Ve.Luminance)]="F32_LUMINANCE",e[e.F16_R=Ye(we.F16,Ge.R,Ve.None)]="F16_R",e[e.F16_RG=Ye(we.F16,Ge.RG,Ve.None)]="F16_RG",e[e.F16_RGB=Ye(we.F16,Ge.RGB,Ve.None)]="F16_RGB",e[e.F16_RGBA=Ye(we.F16,Ge.RGBA,Ve.None)]="F16_RGBA",e[e.F32_R=Ye(we.F32,Ge.R,Ve.None)]="F32_R",e[e.F32_RG=Ye(we.F32,Ge.RG,Ve.None)]="F32_RG",e[e.F32_RGB=Ye(we.F32,Ge.RGB,Ve.None)]="F32_RGB",e[e.F32_RGBA=Ye(we.F32,Ge.RGBA,Ve.None)]="F32_RGBA",e[e.U8_R=Ye(we.U8,Ge.R,Ve.None)]="U8_R",e[e.U8_R_NORM=Ye(we.U8,Ge.R,Ve.Normalized)]="U8_R_NORM",e[e.U8_RG=Ye(we.U8,Ge.RG,Ve.None)]="U8_RG",e[e.U8_RG_NORM=Ye(we.U8,Ge.RG,Ve.Normalized)]="U8_RG_NORM",e[e.U8_RGB=Ye(we.U8,Ge.RGB,Ve.None)]="U8_RGB",e[e.U8_RGB_NORM=Ye(we.U8,Ge.RGB,Ve.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=Ye(we.U8,Ge.RGB,Ve.sRGB|Ve.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=Ye(we.U8,Ge.RGBA,Ve.None)]="U8_RGBA",e[e.U8_RGBA_NORM=Ye(we.U8,Ge.RGBA,Ve.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=Ye(we.U8,Ge.RGBA,Ve.sRGB|Ve.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=Ye(we.U16,Ge.R,Ve.None)]="U16_R",e[e.U16_R_NORM=Ye(we.U16,Ge.R,Ve.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=Ye(we.U16,Ge.RG,Ve.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=Ye(we.U16,Ge.RGBA,Ve.Normalized)]="U16_RGBA_NORM",e[e.U16_RGBA=Ye(we.U16,Ge.RGBA,Ve.None)]="U16_RGBA",e[e.U16_RGB=Ye(we.U16,Ge.RGB,Ve.None)]="U16_RGB",e[e.U16_RG=Ye(we.U16,Ge.RG,Ve.None)]="U16_RG",e[e.U32_R=Ye(we.U32,Ge.R,Ve.None)]="U32_R",e[e.U32_RG=Ye(we.U32,Ge.RG,Ve.None)]="U32_RG",e[e.U32_RGB=Ye(we.U32,Ge.RGB,Ve.None)]="U32_RGB",e[e.U32_RGBA=Ye(we.U32,Ge.RGBA,Ve.None)]="U32_RGBA",e[e.S8_R=Ye(we.S8,Ge.R,Ve.None)]="S8_R",e[e.S8_R_NORM=Ye(we.S8,Ge.R,Ve.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=Ye(we.S8,Ge.RG,Ve.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=Ye(we.S8,Ge.RGB,Ve.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=Ye(we.S8,Ge.RGBA,Ve.Normalized)]="S8_RGBA_NORM",e[e.S16_R=Ye(we.S16,Ge.R,Ve.None)]="S16_R",e[e.S16_RG=Ye(we.S16,Ge.RG,Ve.None)]="S16_RG",e[e.S16_RG_NORM=Ye(we.S16,Ge.RG,Ve.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=Ye(we.S16,Ge.RGB,Ve.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=Ye(we.S16,Ge.RGBA,Ve.None)]="S16_RGBA",e[e.S16_RGBA_NORM=Ye(we.S16,Ge.RGBA,Ve.Normalized)]="S16_RGBA_NORM",e[e.S32_R=Ye(we.S32,Ge.R,Ve.None)]="S32_R",e[e.S32_RG=Ye(we.S32,Ge.RG,Ve.None)]="S32_RG",e[e.S32_RGB=Ye(we.S32,Ge.RGB,Ve.None)]="S32_RGB",e[e.S32_RGBA=Ye(we.S32,Ge.RGBA,Ve.None)]="S32_RGBA",e[e.U16_RGBA_5551=Ye(we.U16_PACKED_5551,Ge.RGBA,Ve.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=Ye(we.U16_PACKED_565,Ge.RGB,Ve.Normalized)]="U16_RGB_565",e[e.BC1=Ye(we.BC1,Ge.RGBA,Ve.Normalized)]="BC1",e[e.BC1_SRGB=Ye(we.BC1,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC1_SRGB",e[e.BC2=Ye(we.BC2,Ge.RGBA,Ve.Normalized)]="BC2",e[e.BC2_SRGB=Ye(we.BC2,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC2_SRGB",e[e.BC3=Ye(we.BC3,Ge.RGBA,Ve.Normalized)]="BC3",e[e.BC3_SRGB=Ye(we.BC3,Ge.RGBA,Ve.Normalized|Ve.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=Ye(we.BC4_UNORM,Ge.R,Ve.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=Ye(we.BC4_SNORM,Ge.R,Ve.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=Ye(we.BC5_UNORM,Ge.RG,Ve.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=Ye(we.BC5_SNORM,Ge.RG,Ve.Normalized)]="BC5_SNORM",e[e.D24=Ye(we.D24,Ge.R,Ve.Depth)]="D24",e[e.D24_S8=Ye(we.D24S8,Ge.RG,Ve.Depth|Ve.Stencil)]="D24_S8",e[e.D32F=Ye(we.D32F,Ge.R,Ve.Depth)]="D32F",e[e.D32F_S8=Ye(we.D32FS8,Ge.RG,Ve.Depth|Ve.Stencil)]="D32F_S8",e[e.U8_RGB_RT=Ye(we.U8,Ge.RGB,Ve.RenderTarget|Ve.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=Ye(we.U8,Ge.RGBA,Ve.RenderTarget|Ve.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=Ye(we.U8,Ge.RGBA,Ve.RenderTarget|Ve.Normalized|Ve.sRGB)]="U8_RGBA_RT_SRGB"}(Xe||(Xe={}));var rt=tt(0,0,0,0),nt=tt(0,0,0,1),it=tt(1,1,1,0),at=tt(1,1,1,1);function ot(e){return!(!e||e&e-1)}function st(e,t){return null!=e?e:t}function ut(e,t,r){e.length=t,e.fill(r)}function lt(e,t){var r=t-1;return e+r&~r}function ct(e,t){return((e+t-1)/t|0)*t}function ft(e,t,r){return r?e|=t:e&=~t,e}function dt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function _t(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function ht(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e.mask=t.mask,e}function pt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),_t(e.rgbBlendState,t.rgbBlendState),_t(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Et(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=pt(e[r],t[r])}function vt(e,t){void 0!==t.attachmentsState&&Et(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=st(t.depthCompare,e.depthCompare),e.depthWrite=st(t.depthWrite,e.depthWrite),e.stencilWrite=st(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&ht(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&ht(e.stencilBack,t.stencilBack),e.cullMode=st(t.cullMode,e.cullMode),e.frontFace=st(t.frontFace,e.frontFace),e.polygonOffset=st(t.polygonOffset,e.polygonOffset),e.polygonOffsetFactor=st(t.polygonOffsetFactor,e.polygonOffsetFactor),e.polygonOffsetUnits=st(t.polygonOffsetUnits,e.polygonOffsetUnits)}function Rt(e){var t=Object.assign({},e);return t.attachmentsState=[],Et(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&et(t.blendConstant),t.stencilFront=ht(void 0,e.stencilFront),t.stencilBack=ht(void 0,e.stencilBack),t}var Tt={blendMode:ge.ADD,blendSrcFactor:me.ONE,blendDstFactor:me.ZERO},At={attachmentsState:[{channelWriteMask:De.ALL,rgbBlendState:Tt,alphaBlendState:Tt}],blendConstant:et(rt),depthWrite:!0,depthCompare:Re.LEQUAL,stencilWrite:!1,stencilFront:{compare:Re.ALWAYS,passOp:be.KEEP,depthFailOp:be.KEEP,failOp:be.KEEP},stencilBack:{compare:Re.ALWAYS,passOp:be.KEEP,depthFailOp:be.KEEP,failOp:be.KEEP},cullMode:Ae.NONE,frontFace:Te.CCW,polygonOffset:!1,polygonOffsetFactor:0,polygonOffsetUnits:0};var mt=function(e,t){void 0===e&&(e=null),void 0===t&&(t=At);var r=Rt(t);return null!==e&&vt(r,e),r}({depthCompare:Re.ALWAYS,depthWrite:!1},At);function gt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Et(e.attachmentsState,At.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var St,yt={texture:null,sampler:null,formatKind:Le.Float,dimension:xe.TEXTURE_2D};function Ct(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Pt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function Nt(e,t){return e.texture===t.texture&&e.binding===t.binding}function Mt(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function Ot(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function It(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!Ct(e.samplerBindings,t.samplerBindings,Ot)&&(!!Ct(e.uniformBufferBindings,t.uniformBufferBindings,Mt)&&(!!Ct(e.storageBufferBindings,t.storageBufferBindings,Mt)&&!!Ct(e.storageTextureBindings,t.storageTextureBindings,Nt))))}function xt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function Bt(e,t){return!!xt(e.rgbBlendState,t.rgbBlendState)&&(!!xt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Dt(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp&&e.mask===t.mask}function bt(e,t){return e.id===t.id}function Lt(e,t){return e===t}function Ft(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!Ct(e.attachmentsState,t.attachmentsState,Bt)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!Dt(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!Dt(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset||e.polygonOffsetFactor!==t.polygonOffsetFactor||e.polygonOffsetUnits!==t.polygonOffsetUnits);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!bt(e.program,t.program)&&(!!Ct(e.colorAttachmentFormats,t.colorAttachmentFormats,Lt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function Ut(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function kt(e,t){return U(e)?U(t):!U(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&Ct(e.attributes,t.attributes,Ut))}function wt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Ct(e.vertexBufferDescriptors,t.vertexBufferDescriptors,kt)&&!!bt(e.program,t.program))}function Gt(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function Vt(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function Xt(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function Wt(e){return{binding:e.binding,texture:e.texture}}function Ht(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function Yt(e){return U(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:Pt(e.attributes,Ht)}}var zt=/([^[]*)(\[[0-9]+\])?/;function Kt(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(zt);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function jt(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function Zt(e,t,r,n){var i=null,a=null;return function(o,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),a=c,f=!0;else{Je(a===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(l[d]!==i[d]){f=!0;break}}return f&&(n(o,e,s,l),i.set(l)),f}}function qt(e,t,r,n){e[t](r,n)}function Qt(e,t,r,n){e[t](r,!1,n)}var Jt={},$t={},er={},tr=[0];function rr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(tr[0]=e,e=tr);var i=e.length;if(e instanceof r)return e;var a=n[i];a||(a=new r(i),n[i]=a);for(var o=0;i>o;o++)a[o]=e[o];return a}function nr(e,t){return rr(e,t,Float32Array,Jt)}function ir(e,t){return rr(e,t,Int32Array,$t)}function ar(e,t){return rr(e,t,Uint32Array,er)}var or=((St={})[Ee.FLOAT]=Zt.bind(null,"uniform1fv",nr,1,qt),St[Ee.FLOAT_VEC2]=Zt.bind(null,"uniform2fv",nr,2,qt),St[Ee.FLOAT_VEC3]=Zt.bind(null,"uniform3fv",nr,3,qt),St[Ee.FLOAT_VEC4]=Zt.bind(null,"uniform4fv",nr,4,qt),St[Ee.INT]=Zt.bind(null,"uniform1iv",ir,1,qt),St[Ee.INT_VEC2]=Zt.bind(null,"uniform2iv",ir,2,qt),St[Ee.INT_VEC3]=Zt.bind(null,"uniform3iv",ir,3,qt),St[Ee.INT_VEC4]=Zt.bind(null,"uniform4iv",ir,4,qt),St[Ee.BOOL]=Zt.bind(null,"uniform1iv",ir,1,qt),St[Ee.BOOL_VEC2]=Zt.bind(null,"uniform2iv",ir,2,qt),St[Ee.BOOL_VEC3]=Zt.bind(null,"uniform3iv",ir,3,qt),St[Ee.BOOL_VEC4]=Zt.bind(null,"uniform4iv",ir,4,qt),St[Ee.FLOAT_MAT2]=Zt.bind(null,"uniformMatrix2fv",nr,4,Qt),St[Ee.FLOAT_MAT3]=Zt.bind(null,"uniformMatrix3fv",nr,9,Qt),St[Ee.FLOAT_MAT4]=Zt.bind(null,"uniformMatrix4fv",nr,16,Qt),St[Ee.UNSIGNED_INT]=Zt.bind(null,"uniform1uiv",ar,1,qt),St[Ee.UNSIGNED_INT_VEC2]=Zt.bind(null,"uniform2uiv",ar,2,qt),St[Ee.UNSIGNED_INT_VEC3]=Zt.bind(null,"uniform3uiv",ar,3,qt),St[Ee.UNSIGNED_INT_VEC4]=Zt.bind(null,"uniform4uiv",ar,4,qt),St[Ee.FLOAT_MAT2x3]=Zt.bind(null,"uniformMatrix2x3fv",nr,6,Qt),St[Ee.FLOAT_MAT2x4]=Zt.bind(null,"uniformMatrix2x4fv",nr,8,Qt),St[Ee.FLOAT_MAT3x2]=Zt.bind(null,"uniformMatrix3x2fv",nr,6,Qt),St[Ee.FLOAT_MAT3x4]=Zt.bind(null,"uniformMatrix3x4fv",nr,12,Qt),St[Ee.FLOAT_MAT4x2]=Zt.bind(null,"uniformMatrix4x2fv",nr,8,Qt),St[Ee.FLOAT_MAT4x3]=Zt.bind(null,"uniformMatrix4x3fv",nr,12,Qt),St[Ee.SAMPLER_2D]=jt,St[Ee.SAMPLER_CUBE]=jt,St[Ee.SAMPLER_3D]=jt,St[Ee.SAMPLER_2D_SHADOW]=jt,St[Ee.SAMPLER_2D_ARRAY]=jt,St[Ee.SAMPLER_2D_ARRAY_SHADOW]=jt,St[Ee.SAMPLER_CUBE_SHADOW]=jt,St[Ee.INT_SAMPLER_2D]=jt,St[Ee.INT_SAMPLER_3D]=jt,St[Ee.INT_SAMPLER_CUBE]=jt,St[Ee.INT_SAMPLER_2D_ARRAY]=jt,St[Ee.UNSIGNED_INT_SAMPLER_2D]=jt,St[Ee.UNSIGNED_INT_SAMPLER_3D]=jt,St[Ee.UNSIGNED_INT_SAMPLER_CUBE]=jt,St[Ee.UNSIGNED_INT_SAMPLER_2D_ARRAY]=jt,St);function sr(e,t,r){var n=or[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var ur={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121};function lr(e,t){return"#define ".concat(e," ").concat(t)}function cr(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function fr(e){return[e,""]}function dr(e,t,r,n,i){var a;void 0===n&&(n=null),void 0===i&&(i=!0);var o="#version 100"===e.glslVersion,s="frag"===t&&(null===(a=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===a?void 0:a.length)>1,u=r.replace("\r\n","\n").split("\n").map(function(e){return e.replace(/[/][/].*$/,"")}).filter(function(e){return!(!e||/^\s+$/.test(e))}),l="";null!==n&&(l=Object.keys(n).map(function(e){return lr(e,n[e])}).join("\n"));var c=u.find(function(e){return e.startsWith("precision")})||"precision mediump float;",f=i?u.filter(function(e){return!e.startsWith("precision")}).join("\n"):u.join("\n"),d="";if(e.viewportOrigin===Fe.UPPER_LEFT&&(d+="".concat(lr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===Ue.ZERO&&(d+="".concat(lr("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,h=0,p=0;f=f.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(h++,") uniform ").concat(n)}),_++,h=0,Je(e.separateSamplerTextures),f=f.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(e,r,n,i,a){var o=cr(n);null===o&&(o=h++);var s=de(fr(i),2),u=s[0],l=s[1];return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(2*o+0,") uniform texture").concat(u," T_").concat(a,";\nlayout(set = ").concat(_,", binding = ").concat(2*o+1,") uniform sampler").concat(l," S_").concat(a,";").trim():""}),f=f.replace("frag"===t?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,function(e,t){return"layout(location = ".concat(p++,") ").concat(t)}),d+="".concat(lr("gl_VertexID","gl_VertexIndex"),"\n"),d+="".concat(lr("gl_InstanceID","gl_InstanceIndex"),"\n"),c=c.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var E=0;f=f.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(e,t,r,n,i){var a=cr(r);return null===a&&(a=E++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(a)})}if(f=(f=(f=f.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"SAMPLER_".concat(t,"(P_").concat(r,")")})).replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"PP_SAMPLER_".concat(t,"(P_").concat(r,")")})).replace(/\bPU_TEXTURE\((.*?)\)/g,function(e,t){return"TEXTURE(P_".concat(t,")")}),e.separateSamplerTextures)f=f.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){var n=de(fr(t),2),i=n[1];return"texture".concat(n[0]," T_P_").concat(r,", sampler").concat(i," S_P_").concat(r)}),f=(f=(f=f.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"T_".concat(r,", S_").concat(r)})).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")})).replace(/\bTEXTURE\((.*?)\)/g,function(e,t){return"T_".concat(t)});else{var v=[];f=(f=(f=f.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return"sampler".concat(t," P_").concat(r)})).replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return r})).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(e,t,r){return v.push([r,t]),r}),o&&v.forEach(function(e){var t=de(e,2),r=t[0],n=t[1];f=f.replace(RegExp("texture\\(".concat(r),"g"),function(){return"texture".concat(n,"(").concat(r)})}),f=f.replace(/\bTEXTURE\((.*?)\)/g,function(e,t){return t})}var R="".concat(o?"":e.glslVersion,"\n").concat(o&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(o&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?c:"","\n").concat(d||"").concat(l?l+"\n":"","\n").concat(f,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(R=R.replace(/^\b(out)\b/g,function(e,t){return"layout(location = 0) ".concat(t)})),o){if("frag"===t&&(R=R.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")})),"vert"===t&&(R=(R=R.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")})).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")})),R=R.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,function(e,t){return t.trim().replace(/^.*$/gm,function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""})}),"frag"===t)if(s){var T=[];R=R.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,function(e,t){return T.push(t),"vec4 ".concat(t,";\n")});var A=R.lastIndexOf("}");R=R.substring(0,A)+"\n ".concat(T.map(function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")}).join("\n"))+R.substring(A)}else{var m;if(R=R.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(e,t,r){return m=r,"".concat(t," ").concat(r,";\n")}),m){A=R.lastIndexOf("}");R=R.substring(0,A)+"\n gl_FragColor = vec4(".concat(m,");\n")+R.substring(A)}}R=R.replace(/^\s*layout\((.*)\)/gm,"")}return R}var _r,hr=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return se(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(We);function pr(e){return void 0!==_r?_r:"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext?(_r=!0,!0):_r=!(!e||2!==e._version)}function Er(e){if(je(e)&Ve.Normalized)return!1;var t=Ke(e);return t===we.S8||t===we.S16||t===we.S32||(t===we.U8||t===we.U16||t===we.U32)}function vr(e){return e&Ne.INDEX?Ee.ELEMENT_ARRAY_BUFFER:e&Ne.VERTEX?Ee.ARRAY_BUFFER:e&Ne.UNIFORM?Ee.UNIFORM_BUFFER:void 0}function Rr(e){var t=Ke(e),r=ze(e),n=je(e),i=function(e){switch(e){case we.U8:return Ee.UNSIGNED_BYTE;case we.U16:return Ee.UNSIGNED_SHORT;case we.U32:return Ee.UNSIGNED_INT;case we.S8:return Ee.BYTE;case we.S16:return Ee.SHORT;case we.S32:return Ee.INT;case we.F16:return Ee.HALF_FLOAT;case we.F32:return Ee.FLOAT;default:throw Error("whoops")}}(t),a=function(e){switch(e){case Ge.R:return 1;case Ge.RG:return 2;case Ge.RGB:return 3;case Ge.RGBA:return 4;default:return 1}}(r);return{size:a,type:i,normalized:!!(n&Ve.Normalized)}}function Tr(e){switch(e){case Se.CLAMP_TO_EDGE:return Ee.CLAMP_TO_EDGE;case Se.REPEAT:return Ee.REPEAT;case Se.MIRRORED_REPEAT:return Ee.MIRRORED_REPEAT;default:throw Error("whoops")}}function Ar(e,t){if(t===Ce.LINEAR&&e===ye.BILINEAR)return Ee.LINEAR_MIPMAP_LINEAR;if(t===Ce.LINEAR&&e===ye.POINT)return Ee.NEAREST_MIPMAP_LINEAR;if(t===Ce.NEAREST&&e===ye.BILINEAR)return Ee.LINEAR_MIPMAP_NEAREST;if(t===Ce.NEAREST&&e===ye.POINT)return Ee.NEAREST_MIPMAP_NEAREST;if(t===Ce.NO_MIP&&e===ye.BILINEAR)return Ee.LINEAR;if(t===Ce.NO_MIP&&e===ye.POINT)return Ee.NEAREST;throw Error("Unknown texture filter mode")}function mr(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}se(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(hr),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=ve.Buffer;var a=n.viewOrSize,o=n.usage,s=n.hint,u=void 0===s?Me.STATIC:s,l=r.uniformBufferMaxPageByteSize,c=r.gl,f=o&Ne.UNIFORM;f||(pr(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,_=G(a)?lt(a,4):lt(a.byteLength,4);if(i.gl_buffer_pages=[],f){for(var h=_;h>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(h,l),o,u)),h-=l;d=l}else i.gl_buffer_pages.push(i.createBufferPage(_,o,u)),d=_;return i.pageByteSize=d,i.byteSize=_,i.usage=o,i.gl_target=vr(o),G(a)||i.setSubData(0,new Uint8Array(a.buffer)),f||(pr(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}se(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,a=this.pageByteSize,o=e+n,s=e,u=e%a;o>s;){var l=pr(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=mr(this,s);if(c.ubo)return;i.bindBuffer(l,c),pr(i)?i.bufferSubData(l,u,t,r,Math.min(o-s,a)):i.bufferSubData(l,u,t),s+=a,u=0,r+=a,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&Ne.UNIFORM;if(!pr(n)&&i)return{ubo:!0};var a=this.device.ensureResourceExists(n.createBuffer()),o=vr(t),s=function(e){switch(e){case Me.STATIC:return Ee.STATIC_DRAW;case Me.DYNAMIC:return Ee.DYNAMIC_DRAW}}(r);return n.bindBuffer(o,a),n.bufferData(o,e,s),a}}(hr),function(e){function t(t){var r,n,i,a,o,s=t.device,u=t.descriptor,l=e.call(this,{id:t.id,device:s})||this;l.type=ve.InputLayout;var c=u.vertexBufferDescriptors,f=u.indexBufferFormat,d=u.program;Je(f===Xe.U16_R||f===Xe.U32_R||null===f);var _=null!==f?function(e){switch(e){case Xe.U8_R:return Ee.UNSIGNED_BYTE;case Xe.U16_R:return Ee.UNSIGNED_SHORT;case Xe.U32_R:return Ee.UNSIGNED_INT;default:throw Error("whoops")}}(f):null,h=null!==f?qe(f):null,p=l.device.gl,E=l.device.ensureResourceExists(pr(p)?p.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());pr(p)?p.bindVertexArray(E):s.OES_vertex_array_object.bindVertexArrayOES(E),p.bindBuffer(p.ARRAY_BUFFER,mr(l.device.fallbackVertexBuffer));try{for(var v=fe(u.vertexBufferDescriptors),R=v.next();!R.done;R=v.next()){var T=R.value,A=T.stepMode,m=T.attributes;try{for(var g=(i=void 0,fe(m)),S=g.next();!S.done;S=g.next()){var y=S.value,C=y.shaderLocation,P=y.format,N=y.divisor,M=void 0===N?1:N,O=pr(p)?C:null===(o=d.attributes[C])||void 0===o?void 0:o.location,I=Rr(P);if(y.vertexFormat=I,!U(O))Er(P),p.vertexAttribPointer(O,I.size,I.type,I.normalized,0,0),A===Oe.INSTANCE&&(pr(p)?p.vertexAttribDivisor(O,M):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(O,M)),p.enableVertexAttribArray(O)}}catch(e){i={error:e}}finally{try{S&&!S.done&&(a=g.return)&&a.call(g)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{R&&!R.done&&(n=v.return)&&n.call(v)}finally{if(r)throw r.error}}return pr(p)?p.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),l.vertexBufferDescriptors=c,l.vao=E,l.indexBufferFormat=f,l.indexBufferType=_,l.indexBufferCompByteSize=h,l.program=d,l}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(pr(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(hr);var gr,Sr=function(e){function t(t){var r=t.device,n=t.descriptor,i=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=ve.Texture,n=ue({dimension:xe.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var o,s,u=a.device.gl,l=a.clampmipLevelCount(n);if(a.immutable=n.usage===Be.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=Qe(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=l>=1,!i){s=a.device.ensureResourceExists(u.createTexture());var c=a.device.translateTextureType(n.format),f=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===xe.TEXTURE_2D){if(u.bindTexture(o=Ee.TEXTURE_2D,s),a.immutable)if(pr(u))u.texStorage2D(o,l,f,n.width,n.height);else{var d=(f===Ee.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==Xe.D32F&&a.format!==Xe.D24_S8||pr(u)||r.WEBGL_depth_texture)&&(u.texImage2D(o,d,f,n.width,n.height,0,f,c,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR),u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_S,Ee.CLAMP_TO_EDGE),u.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_T,Ee.CLAMP_TO_EDGE)))}Je(1===n.depthOrArrayLayers)}else if(n.dimension===xe.TEXTURE_2D_ARRAY)u.bindTexture(o=Ee.TEXTURE_2D_ARRAY,s),a.immutable&&pr(u)&&u.texStorage3D(o,l,f,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===xe.TEXTURE_3D)u.bindTexture(o=Ee.TEXTURE_3D,s),a.immutable&&pr(u)&&u.texStorage3D(o,l,f,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==xe.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(o=Ee.TEXTURE_CUBE_MAP,s),a.immutable&&pr(u)&&u.texStorage2D(o,l,f,n.width,n.height),Je(6===n.depthOrArrayLayers)}}return a.gl_texture=s,a.gl_target=o,a.mipLevelCount=l,a}return se(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_UNORM:case we.BC4_SNORM:case we.BC5_UNORM:case we.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===Ee.TEXTURE_3D||this.gl_target===Ee.TEXTURE_2D_ARRAY,i=this.gl_target===Ee.TEXTURE_CUBE_MAP,a=Object.prototype.toString.call(e[0])in ur;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var o,s,u=e[0];a?(o=this.width,s=this.height):(s=u.height,this.width=o=u.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var l=this.device.translateTextureFormat(this.format),c=pr(r)?this.device.translateInternalTextureFormat(this.format):l,f=this.device.translateTextureType(this.format);this.preprocessImage();for(var d=0;this.depthOrArrayLayers>d;d++){var _=e[d],h=this.gl_target;i&&(h=Ee.TEXTURE_CUBE_MAP_POSITIVE_X+d%6),this.immutable?r.texSubImage2D(h,t,0,0,o,s,l,f,_):pr(r)?n?r.texImage3D(h,t,c,o,s,this.depthOrArrayLayers,0,l,f,_):r.texImage2D(h,t,c,o,s,0,l,f,_):a?r.texImage2D(h,t,l,o,s,0,l,f,_):r.texImage2D(h,t,l,l,f,_)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===xe.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&Ke(e.format)===we.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(Ee.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(Ee.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(Ee.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!pr(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,Ee.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,Ee.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,Ee.TEXTURE_MAG_FILTER,Ee.LINEAR)):t.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!pr(this.device.gl)&&(!ot(this.width)||!ot(this.height))},t}(hr);let yr;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=ve.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var a=i.device.gl,o=n.format,s=n.width,u=n.height,l=n.sampleCount,c=void 0===l?1:l,f=n.texture,d=!1;if(o!==Xe.D32F&&o!==Xe.D24_S8||!f||pr(a)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(a.createRenderbuffer()),a.bindRenderbuffer(a.RENDERBUFFER,i.gl_renderbuffer);var _=i.device.translateTextureInternalFormat(o,!0);pr(a)&&c>1?a.renderbufferStorageMultisample(Ee.RENDERBUFFER,c,_,s,u):a.renderbufferStorage(Ee.RENDERBUFFER,_,s,u)}return i.format=o,i.width=s,i.height=u,i.sampleCount=c,i}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(hr),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(gr||(gr={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=ve.Program,i.uniformSetters={},i.attributes=[];var a=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(a.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=gr.NeedsCompile,i.tryCompileProgram(),i}se(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){Je(this.compileState===gr.NeedsCompile);var e=this.descriptor,t=e.vertex,r=e.fragment,n=this.device.gl;(null==t?void 0:t.glsl)&&(null==r?void 0:r.glsl)&&(this.gl_shader_vert=this.compileShader(t.postprocess?t.postprocess(t.glsl):t.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.postprocess?r.postprocess(r.glsl):r.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=gr.Compiling,pr(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""}),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,function(e,n,i){var a=Number(n);return r.push({location:isNaN(a)?t[n]:a,name:i}),""}),r}(this.rawVertexGLSL,n),a=function(r){var n=t.getActiveAttrib(o.gl_program,r),a=n.name,s=n.type,u=n.size,l=t.getAttribLocation(o.gl_program,a),c=null===(e=i.find(function(e){return e.name===a}))||void 0===e?void 0:e.location;0>l||U(c)||(o.attributes[c]={name:a,location:l,type:s,size:u})},o=this,s=0;r>s;s++)a(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=Kt(n.name).name,a=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=sr(e,a,n),n&&n.size>1)for(var o=0;n.size>o;o++)a=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(o,"]")),this.uniformSetters["".concat(i,"[").concat(o,"]")]=sr(e,a,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!pr(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var a=e[n];a instanceof Sr&&(a=a.textureIndex),i(a)}}}return this}}(hr),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.QueryPool;var i=n.device.gl;if(pr(i)){var a=r.type;n.gl_query=dt(r.elemCount,function(){return n.device.ensureResourceExists(i.createQuery())}),n.gl_query_type=function(e){if(e===ke.OcclusionConservative)return Ee.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(a)}return n}se(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(pr(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(pr(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(hr),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.Readback,r.gl_pbo=null,r.gl_sync=null,r}se(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise(function(i,a){!function o(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(o,w(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):a()}()})},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,a){return le(this,void 0,void 0,function(){var o;return ce(this,function(s){switch(s.label){case 0:return pr(o=this.device.gl)?(this.gl_sync=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0),o.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),o.bindBuffer(e,t),o.getBufferSubData(e,r,n,i,a),o.bindBuffer(e,null),[2,n];case 2:return[2]}})})},t.prototype.readTexture=function(e,t,r,n,i,a,o,s){return void 0===o&&(o=0),void 0===s&&(s=a.byteLength||0),le(this,void 0,void 0,function(){var u,l,c,f,d;return ce(this,function(_){var h;return u=this.device.gl,c=this.device.translateTextureFormat((l=e).format),f=this.device.translateTextureType(l.format),d=Ze(Ke(h=l.format))*ze(h),pr(u)?(this.gl_pbo=this.device.ensureResourceExists(u.createBuffer()),u.bindBuffer(u.PIXEL_PACK_BUFFER,this.gl_pbo),u.bufferData(u.PIXEL_PACK_BUFFER,s,u.STREAM_READ),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.bindFramebuffer(Ee.READ_FRAMEBUFFER,this.device.readbackFramebuffer),u.framebufferTexture2D(Ee.READ_FRAMEBUFFER,Ee.COLOR_ATTACHMENT0,Ee.TEXTURE_2D,l.gl_texture,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,this.gl_pbo),u.readPixels(t,r,n,i,c,f,o*d),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(u.PIXEL_PACK_BUFFER,this.gl_pbo,0,a,o,0)]):[2,this.readTextureSync(e,t,r,n,i,a,o,s)]})})},t.prototype.readTextureSync=function(e,t,r,n,i,a,o,s){void 0===s&&(s=a.byteLength||0);var u=this.device.gl,l=e,c=this.device.translateTextureType(l.format);return u.bindFramebuffer(Ee.FRAMEBUFFER,this.device.readbackFramebuffer),u.framebufferTexture2D(Ee.FRAMEBUFFER,Ee.COLOR_ATTACHMENT0,Ee.TEXTURE_2D,l.gl_texture,0),u.pixelStorei(u.PACK_ALIGNMENT,4),u.readPixels(t,r,n,i,u.RGBA,c,a),a},t.prototype.readBuffer=function(e,t,r,n,i){return le(this,void 0,void 0,function(){var a;return ce(this,function(o){return pr(a=this.device.gl)?[2,this.getBufferSubDataAsync(a.ARRAY_BUFFER,mr(e,t),t,r,n,i)]:[2,Promise.reject()]})})},t.prototype.destroy=function(){e.prototype.destroy.call(this),pr(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(hr),function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=ve.RenderPipeline,a.drawMode=function(e){switch(e){case Pe.TRIANGLES:return Ee.TRIANGLES;case Pe.POINTS:return Ee.POINTS;case Pe.TRIANGLE_STRIP:return Ee.TRIANGLE_STRIP;case Pe.LINES:return Ee.LINES;case Pe.LINE_STRIP:return Ee.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=i.topology)&&void 0!==r?r:Pe.TRIANGLES),a.program=i.program,a.inputLayout=i.inputLayout,a.megaState=ue(ue({},Rt(At)),i.megaStateDescriptor),a.colorAttachmentFormats=i.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=i.depthStencilAttachmentFormat,a.sampleCount=null!==(n=i.sampleCount)&&void 0!==n?n:1,a}se(t,e)}(hr),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.ComputePipeline,n.descriptor=r,n}se(t,e)}(hr),function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Sampler;var o=a.device.gl;if(pr(o)){var s=a.device.ensureResourceExists(o.createSampler());o.samplerParameteri(s,Ee.TEXTURE_WRAP_S,Tr(i.addressModeU)),o.samplerParameteri(s,Ee.TEXTURE_WRAP_T,Tr(i.addressModeV)),o.samplerParameteri(s,Ee.TEXTURE_WRAP_R,Tr(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),o.samplerParameteri(s,Ee.TEXTURE_MIN_FILTER,Ar(i.minFilter,i.mipmapFilter)),o.samplerParameteri(s,Ee.TEXTURE_MAG_FILTER,Ar(i.magFilter,Ce.NO_MIP)),void 0!==i.lodMinClamp&&o.samplerParameterf(s,Ee.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&o.samplerParameterf(s,Ee.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(o.samplerParameteri(s,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.samplerParameteri(s,o.TEXTURE_COMPARE_FUNC,i.compareFunction));var u=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;u>1&&null!==a.device.EXT_texture_filter_anisotropic&&(Je(i.minFilter===ye.BILINEAR&&i.magFilter===ye.BILINEAR&&i.mipmapFilter===Ce.LINEAR),o.samplerParameterf(s,a.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u)),a.gl_sampler=s}else a.descriptor=i;return a}se(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,a=this.descriptor;this.isNPOT(t,r)?i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_MIN_FILTER,Ee.LINEAR):i.texParameteri(e,Ee.TEXTURE_MIN_FILTER,Ar(a.minFilter,a.mipmapFilter)),i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_S,Tr(a.addressModeU)),i.texParameteri(Ee.TEXTURE_2D,Ee.TEXTURE_WRAP_T,Tr(a.addressModeV)),i.texParameteri(e,Ee.TEXTURE_MAG_FILTER,Ar(a.magFilter,Ce.NO_MIP));var o=null!==(n=a.maxAnisotropy)&&void 0!==n?n:1;o>1&&null!==this.device.EXT_texture_filter_anisotropic&&(Je(a.minFilter===ye.BILINEAR&&a.magFilter===ye.BILINEAR&&a.mipmapFilter===Ce.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o))},t.prototype.destroy=function(){e.prototype.destroy.call(this),pr(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!ot(e)||!ot(t)}}(hr),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=ve.RenderBundle,t.commands=[],t}se(t,e),t.prototype.push=function(e){this.commands.push(e)},t.prototype.replay=function(){this.commands.forEach(function(e){return e()})}}(hr);const Cr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Cr.decode();let Pr=null;function Nr(){return null!==Pr&&0!==Pr.byteLength||(Pr=new Uint8Array(yr.memory.buffer)),Pr}function Mr(e,t){return e>>>=0,Cr.decode(Nr().subarray(e,e+t))}const Or=Array(128).fill(void 0);Or.push(void 0,null,!0,!1);let Ir=Or.length;function xr(e){return Or[e]}function Br(e){const t=xr(e);return function(e){132>e||(Or[e]=Ir,Ir=e)}(e),t}let Dr=0;const br="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Lr="function"==typeof br.encodeInto?function(e,t){return br.encodeInto(e,t)}:function(e,t){const r=br.encode(e);return t.set(r),{read:e.length,written:r.length}};function Fr(e,t,r){if(void 0===r){const r=br.encode(e),n=t(r.length,1)>>>0;return Nr().subarray(n,n+r.length).set(r),Dr=r.length,n}let n=e.length,i=t(n,1)>>>0;const a=Nr();let o=0;for(;n>o;o++){const t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==n){0!==o&&(e=e.slice(o)),i=r(i,n,n=o+3*e.length,1)>>>0;const t=Nr().subarray(i+o,i+n);o+=Lr(e,t).written}return Dr=o,i}let Ur=null;function kr(){return null!==Ur&&0!==Ur.byteLength||(Ur=new Int32Array(yr.memory.buffer)),Ur}function wr(e,t,r){let n,i;try{const s=yr.__wbindgen_add_to_stack_pointer(-16),u=Fr(e,yr.__wbindgen_malloc,yr.__wbindgen_realloc),l=Dr,c=Fr(t,yr.__wbindgen_malloc,yr.__wbindgen_realloc);yr.glsl_compile(s,u,l,c,Dr,r);var a=kr()[s/4+0],o=kr()[s/4+1];return n=a,i=o,Mr(a,o)}finally{yr.__wbindgen_add_to_stack_pointer(16),yr.__wbindgen_free(n,i,1)}}class Gr{static __wrap(e){e>>>=0;const t=Object.create(Gr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();yr.__wbg_wgslcomposer_free(e)}constructor(){const e=yr.wgslcomposer_new();return Gr.__wrap(e)}load_composable(e){const t=Fr(e,yr.__wbindgen_malloc,yr.__wbindgen_realloc);yr.wgslcomposer_load_composable(this.__wbg_ptr,t,Dr)}wgsl_compile(e){let t,r;try{const a=yr.__wbindgen_add_to_stack_pointer(-16),o=Fr(e,yr.__wbindgen_malloc,yr.__wbindgen_realloc);yr.wgslcomposer_wgsl_compile(a,this.__wbg_ptr,o,Dr);var n=kr()[a/4+0],i=kr()[a/4+1];return t=n,r=i,Mr(n,i)}finally{yr.__wbindgen_add_to_stack_pointer(16),yr.__wbindgen_free(t,r,1)}}}function Vr(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){Ir===Or.length&&Or.push(Or.length+1);const t=Ir;return Ir=Or[t],Or[t]=e,t}(Mr(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){Br(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(xr(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(xr(e),xr(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(Mr(e,t))},e}async function Xr(e){if(void 0!==yr)return yr;const t=Vr();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return yr=e.exports,Xr.__wbindgen_wasm_module=t,Ur=null,Pr=null,yr}(r,n)}var Wr,Hr;function Yr(e){if(e===Xe.U8_R_NORM)return"r8unorm";if(e===Xe.S8_R_NORM)return"r8snorm";if(e===Xe.U8_RG_NORM)return"rg8unorm";if(e===Xe.S8_RG_NORM)return"rg8snorm";if(e===Xe.U32_R)return"r32uint";if(e===Xe.S32_R)return"r32sint";if(e===Xe.F32_R)return"r32float";if(e===Xe.U16_RG)return"rg16uint";if(e===Xe.S16_RG)return"rg16sint";if(e===Xe.F16_RG)return"rg16float";if(e===Xe.U8_RGBA_RT)return"bgra8unorm";if(e===Xe.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===Xe.U8_RGBA_NORM)return"rgba8unorm";if(e===Xe.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===Xe.S8_RGBA_NORM)return"rgba8snorm";if(e===Xe.U32_RG)return"rg32uint";if(e===Xe.S32_RG)return"rg32sint";if(e===Xe.F32_RG)return"rg32float";if(e===Xe.U16_RGBA)return"rgba16uint";if(e===Xe.S16_RGBA)return"rgba16sint";if(e===Xe.F16_RGBA)return"rgba16float";if(e===Xe.F32_RGBA)return"rgba32float";if(e===Xe.U32_RGBA)return"rgba32uint";if(e===Xe.S32_RGBA)return"rgba32sint";if(e===Xe.D24)return"depth24plus";if(e===Xe.D24_S8)return"depth24plus-stencil8";if(e===Xe.D32F)return"depth32float";if(e===Xe.D32F_S8)return"depth32float-stencil8";if(e===Xe.BC1)return"bc1-rgba-unorm";if(e===Xe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Xe.BC2)return"bc2-rgba-unorm";if(e===Xe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Xe.BC3)return"bc3-rgba-unorm";if(e===Xe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Xe.BC4_SNORM)return"bc4-r-snorm";if(e===Xe.BC4_UNORM)return"bc4-r-unorm";if(e===Xe.BC5_SNORM)return"bc5-rg-snorm";if(e===Xe.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function zr(e){if(e===xe.TEXTURE_2D)return"2d";if(e===xe.TEXTURE_CUBE_MAP)return"cube";if(e===xe.TEXTURE_2D_ARRAY)return"2d-array";if(e===xe.TEXTURE_3D)return"3d";throw Error("whoops")}function Kr(e){if(e===Se.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===Se.REPEAT)return"repeat";if(e===Se.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function jr(e){if(e===ye.BILINEAR)return"linear";if(e===ye.POINT)return"nearest";throw Error("whoops")}function Zr(e){if(e===Ce.LINEAR)return"linear";if(e===Ce.NEAREST)return"nearest";if(e===Ce.NO_MIP)return"nearest";throw Error("whoops")}function qr(e){return e.gpuBuffer}function Qr(e){return e.gpuSampler}function Jr(e){if(e===ke.OcclusionConservative)return"occlusion";throw Error("whoops")}function $r(e){switch(e){case Pe.TRIANGLES:return"triangle-list";case Pe.POINTS:return"point-list";case Pe.TRIANGLE_STRIP:return"triangle-strip";case Pe.LINES:return"line-list";case Pe.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function en(e){if(e===Ae.NONE)return"none";if(e===Ae.FRONT)return"front";if(e===Ae.BACK)return"back";throw Error("whoops")}function tn(e){if(e===Te.CCW)return"ccw";if(e===Te.CW)return"cw";throw Error("whoops")}function rn(e){if(e===me.ZERO)return"zero";if(e===me.ONE)return"one";if(e===me.SRC)return"src";if(e===me.ONE_MINUS_SRC)return"one-minus-src";if(e===me.DST)return"dst";if(e===me.ONE_MINUS_DST)return"one-minus-dst";if(e===me.SRC_ALPHA)return"src-alpha";if(e===me.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===me.DST_ALPHA)return"dst-alpha";if(e===me.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===me.CONST)return"constant";if(e===me.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===me.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function nn(e){if(e===ge.ADD)return"add";if(e===ge.SUBSTRACT)return"subtract";if(e===ge.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===ge.MIN)return"min";if(e===ge.MAX)return"max";throw Error("whoops")}function an(e){return{operation:nn(e.blendMode),srcFactor:rn(e.blendSrcFactor),dstFactor:rn(e.blendDstFactor)}}function on(e){return e.blendMode===ge.ADD&&e.blendSrcFactor===me.ONE&&e.blendDstFactor===me.ZERO}function sn(e){return on(e.rgbBlendState)&&on(e.alphaBlendState)?void 0:{color:an(e.rgbBlendState),alpha:an(e.alphaBlendState)}}function un(e,t){return t.attachmentsState.map(function(t,r){return function(e,t){return{format:Yr(t),blend:sn(e),writeMask:e.channelWriteMask}}(t,e[r])})}function ln(e){if(e===Re.NEVER)return"never";if(e===Re.LESS)return"less";if(e===Re.EQUAL)return"equal";if(e===Re.LEQUAL)return"less-equal";if(e===Re.GREATER)return"greater";if(e===Re.NOTEQUAL)return"not-equal";if(e===Re.GEQUAL)return"greater-equal";if(e===Re.ALWAYS)return"always";throw Error("whoops")}function cn(e){if(e===be.KEEP)return"keep";if(e===be.REPLACE)return"replace";if(e===be.ZERO)return"zero";if(e===be.DECREMENT_CLAMP)return"decrement-clamp";if(e===be.DECREMENT_WRAP)return"decrement-wrap";if(e===be.INCREMENT_CLAMP)return"increment-clamp";if(e===be.INCREMENT_WRAP)return"increment-wrap";if(e===be.INVERT)return"invert";throw Error("whoops")}function fn(e){if(e===Oe.VERTEX)return"vertex";if(e===Oe.INSTANCE)return"instance";throw Error("whoops")}function dn(e){if(e===Xe.U8_R)return"uint8x2";if(e===Xe.U8_RG)return"uint8x2";if(e===Xe.U8_RGB)return"uint8x4";if(e===Xe.U8_RGBA)return"uint8x4";if(e===Xe.U8_RG_NORM)return"unorm8x2";if(e===Xe.U8_RGBA_NORM)return"unorm8x4";if(e===Xe.S8_RGB_NORM)return"snorm8x4";if(e===Xe.S8_RGBA_NORM)return"snorm8x4";if(e===Xe.U16_RG_NORM)return"unorm16x2";if(e===Xe.U16_RGBA_NORM)return"unorm16x4";if(e===Xe.S16_RG_NORM)return"snorm16x2";if(e===Xe.S16_RGBA_NORM)return"snorm16x4";if(e===Xe.S16_RG)return"uint16x2";if(e===Xe.F16_RG)return"float16x2";if(e===Xe.F16_RGBA)return"float16x4";if(e===Xe.F32_R)return"float32";if(e===Xe.F32_RG)return"float32x2";if(e===Xe.F32_RGB)return"float32x3";if(e===Xe.F32_RGBA)return"float32x4";throw"whoops"}function _n(e,t,r,n){switch(void 0===r&&(r=!1),e){case Xe.S8_R:case Xe.S8_R_NORM:case Xe.S8_RG_NORM:case Xe.S8_RGB_NORM:case Xe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case Xe.U8_R:case Xe.U8_R_NORM:case Xe.U8_RG:case Xe.U8_RG_NORM:case Xe.U8_RGB:case Xe.U8_RGB_NORM:case Xe.U8_RGB_SRGB:case Xe.U8_RGBA:case Xe.U8_RGBA_NORM:case Xe.U8_RGBA_SRGB:var a=(ArrayBuffer,new Uint8Array(t));return n&&a.set(new Uint8Array(n)),a;case Xe.S16_R:case Xe.S16_RG:case Xe.S16_RG_NORM:case Xe.S16_RGB_NORM:case Xe.S16_RGBA:case Xe.S16_RGBA_NORM:var o=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&o.set(new Int16Array(n)),o;case Xe.U16_R:case Xe.U16_RGB:case Xe.U16_RGBA_5551:case Xe.U16_RGBA_NORM:case Xe.U16_RG_NORM:case Xe.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case Xe.S32_R:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&u.set(new Int32Array(n)),u;case Xe.U32_R:case Xe.U32_RG:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&l.set(new Uint32Array(n)),l;case Xe.F32_R:case Xe.F32_RG:case Xe.F32_RGB:case Xe.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}function hn(e){var t=(32768&e)>>15,r=(31744&e)>>10,n=1023&e;return 0===r?(t?-1:1)*Math.pow(2,-14)*(n/1024):31==r?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,r-15)*(1+n/1024)}function pn(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(Wr||(Wr={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Hr||(Hr={}));var En=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return se(t,e),t.prototype.destroy=function(){},t}(We),vn=function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Bindings;var o=i.pipeline;Je(!!o);var s=i.uniformBufferBindings,u=i.storageBufferBindings,l=i.samplerBindings,c=i.storageTextureBindings;a.numUniformBuffers=(null==s?void 0:s.length)||0;var f=[[],[],[],[]],d=0;if(s&&s.length)for(var _=0;s.length>_;_++){var h=i.uniformBufferBindings[_],p=h.binding,E=h.size,v=h.offset,R={buffer:qr(h.buffer),offset:null!=v?v:0,size:E};f[0].push({binding:null!=p?p:d++,resource:R})}if(l&&l.length){d=0;for(_=0;l.length>_;_++){var T=ue(ue({},l[_]),yt),A=null!==(p=i.samplerBindings[_]).texture?p.texture:a.device.getFallbackTexture(T);if(T.dimension=A.dimension,T.formatKind=Qe(A.format),f[1].push({binding:null!==(r=p.textureBinding)&&void 0!==r?r:d++,resource:A.gpuTextureView}),-1!==p.samplerBinding){var m=Qr(null!==p.sampler?p.sampler:a.device.getFallbackSampler(T));f[1].push({binding:null!==(n=p.samplerBinding)&&void 0!==n?n:d++,resource:m})}}}if(u&&u.length){d=0;for(_=0;u.length>_;_++){var g=i.storageBufferBindings[_];p=g.binding,E=g.size,v=g.offset,R={buffer:qr(g.buffer),offset:null!=v?v:0,size:E};f[2].push({binding:null!=p?p:d++,resource:R})}}if(c&&c.length){d=0;for(_=0;c.length>_;_++){var S=i.storageTextureBindings[_];f[3].push({binding:null!=(p=S.binding)?p:d++,resource:(A=S.texture).gpuTextureView})}}var y=f.findLastIndex(function(e){return!!e.length});return a.gpuBindGroup=f.map(function(e,t){return y>=t&&a.device.device.createBindGroup({layout:o.getBindGroupLayout(t),entries:e})}),a}return se(t,e),t}(En),Rn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.Buffer;var i=r.usage,a=r.viewOrSize,o=!!(i&Ne.MAP_READ);n.usage=function(e){var t=0;return e&Ne.INDEX&&(t|=GPUBufferUsage.INDEX),e&Ne.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&Ne.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&Ne.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&Ne.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),e&Ne.INDIRECT&&(t|=GPUBufferUsage.INDIRECT),t|GPUBufferUsage.COPY_DST}(i),o&&(n.usage=Ne.MAP_READ|Ne.COPY_DST);var s=!G(a);(n.view=G(a)?null:a,n.size=G(a)?lt(a,4):lt(a.byteLength,4),G(a))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!o&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(a&&a.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(a),n.gpuBuffer.unmap());return n}return se(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,a=t.byteOffset+r,o=a+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(a,o));(t=new Uint8Array(s)).set(u),r=0,a=0,o=s,n=s}for(var l=15728640,c=0;o-(a+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,a+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,a+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(En),Tn=function(){function e(){this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null},e.prototype.beginComputePass=function(e){Je(null===this.gpuComputePassEncoder),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=$e(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){var t=this,r=e;r.gpuBindGroup.forEach(function(e,n){e&&t.gpuComputePassEncoder.setBindGroup(n,r.gpuBindGroup[n])})},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),An=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var i=r.program.computeStage;if(null===i)return n;var a={layout:"auto",compute:ue({},i)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return se(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(En),mn=function(e){function t(t){var r,n,i,a,o=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=ve.InputLayout;var u=[];try{for(var l=fe(o.vertexBufferDescriptors),c=l.next();!c.done;c=l.next()){var f=c.value,d=f.attributes;u.push({arrayStride:f.arrayStride,stepMode:fn(f.stepMode),attributes:[]});try{for(var _=(i=void 0,fe(d)),h=_.next();!h.done;h=_.next()){var p=h.value,E=p.offset;u[u.length-1].attributes.push({shaderLocation:p.shaderLocation,format:dn(p.format),offset:E})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=_.return)&&a.call(_)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===Xe.U16_R)return"uint16";if(e===Xe.U32_R)return"uint32";throw Error("whoops")}}(o.indexBufferFormat),s.buffers=u,s}return se(t,e),t}(En),gn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return se(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,a=e.entryPoint,o=e.postprocess,s=e.wgsl;if(!s)try{s=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var u=function(e){if(!s.includes(e))return"continue";s=(s=s.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")})};try{for(var l=fe(["u_TextureFramebufferDepth"]),c=l.next();!c.done;c=l.next()){u(c.value)}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return o&&(s=o(s)),{module:this.device.device.createShaderModule({code:s}),entryPoint:a||"main"}},t}(En),Sn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=ve.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:Jr(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return se(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(En),yn=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.Readback,r}return se(t,e),t.prototype.readTexture=function(e,t,r,n,i,a,o,s){return void 0===o&&(o=0),le(this,void 0,void 0,function(){var s,u,l,c,f,d,_;return ce(this,function(h){return u=pn((s=e).gpuTextureformat),d=this.device.createBuffer({usage:Ne.STORAGE|Ne.MAP_READ|Ne.COPY_DST,hint:Me.STATIC,viewOrSize:f=(c=256*Math.ceil((l=Math.ceil(n/u.width)*u.length)/256))*i}),(_=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:s.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),[2,this.readBuffer(d,0,a.byteLength===f?a:null,o,f,s.format,!0,!1,l,c,i)]})})},t.prototype.readTextureSync=function(e,t,r,n,i,a,o,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,a,o,s,u,l,c){var f=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===a&&(a=Xe.U8_RGB),void 0===o&&(o=!1),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=0);var d=e,_=i||d.size,h=r||d.view,p=h&&h.constructor&&h.constructor.BYTES_PER_ELEMENT||qe(a),E=d;if(!(d.usage&Ne.MAP_READ&&d.usage&Ne.COPY_DST)){var v=this.device.device.createCommandEncoder();E=this.device.createBuffer({usage:Ne.STORAGE|Ne.MAP_READ|Ne.COPY_DST,hint:Me.STATIC,viewOrSize:_}),v.copyBufferToBuffer(d.gpuBuffer,t,E.gpuBuffer,0,_),this.device.device.queue.submit([v.finish()])}return new Promise(function(e,r){E.gpuBuffer.mapAsync(Hr.READ,t,_).then(function(){var r=E.gpuBuffer.getMappedRange(t,_),n=h;if(o)n=null===n?_n(a,_,!0,r):_n(a,n.buffer,void 0,r);else if(null===n)switch(p){case 1:(n=new Uint8Array(_)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(_/2,r);break;case 4:(n=new Float32Array(_/4)).set(new Float32Array(r))}else switch(p){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(_/2,r,h);break;case 4:var i=h&&h.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}if(u!==l){1!==p||o||(u*=2,l*=2);for(var s=new Uint8Array(n.buffer),d=u,v=0,R=1;c>R;++R){v=R*l;for(var T=0;u>T;++T)s[d++]=s[v++]}n=0===p||o?new Uint8Array(s.buffer,0,d):new Float32Array(s.buffer,0,d/4)}E.gpuBuffer.unmap(),e(n)},function(e){return r(e)})})},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n=new Uint16Array(t);e--;)r[e]=hn(n[e]);return r},t}(En),Cn=function(){function e(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getEncoder=function(){var e;return(null===(e=this.renderBundle)||void 0===e?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder},e.prototype.getTextureView=function(e,t){return Je(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,a,o;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var u=0;e.colorAttachment.length>u;u++){var l=e.colorAttachment[u],c=e.colorResolveTo[u];if(null===l&&null!==c&&(l=c,c=null),this.gfxColorAttachment[u]=l,this.gfxColorResolveTo[u]=c,this.gfxColorAttachmentLevel[u]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[u])||0,this.gfxColorResolveToLevel[u]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[u])||0,null===l){this.gpuColorAttachments.length=u,this.gfxColorAttachment.length=u,this.gfxColorResolveTo.length=u;break}void 0===this.gpuColorAttachments[u]&&(this.gpuColorAttachments[u]={}),(d=this.gpuColorAttachments[u]).view=this.getTextureView(l,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[u])||0);var f=null!==(a=null===(i=e.colorClearColor)||void 0===i?void 0:i[u])&&void 0!==a?a:"load";"load"===f?d.loadOp="load":(d.loadOp="clear",d.clearValue=f),d.storeOp=(null===(o=e.colorStore)||void 0===o?void 0:o[u])?"store":"discard",d.resolveTarget=void 0,null!==c&&(l.sampleCount>1?d.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[u]):d.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var d,_=e.depthStencilAttachment;(d=this.gpuDepthStencilAttachment).view=_.gpuTextureView,!!(je(_.format)&Ve.Depth)?("load"===e.depthClearValue?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),d.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0),!!(je(_.format)&Ve.Stencil)?("load"===e.stencilClearValue?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),d.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=U(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e,t){Je(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(t),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,a){void 0===i&&(i=0),void 0===a&&(a=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,a)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=$e(e.gpuRenderPipeline);this.getEncoder().setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=this.getEncoder(),i=e;null!==r&&n.setIndexBuffer(qr(r.buffer),$e(i.indexFormat),r.offset);for(var a=0;t.length>a;a++){var o=t[a];null!==o&&n.setVertexBuffer(a,qr(o.buffer),o.offset)}}},e.prototype.setBindings=function(e){var t=e,r=this.getEncoder();t.gpuBindGroup.forEach(function(e,n){e&&r.setBindGroup(n,t.gpuBindGroup[n])})},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.getEncoder().draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.getEncoder().drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.getEncoder().drawIndirect(qr(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.getEncoder().drawIndexedIndirect(qr(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.beginBundle=function(e){this.renderBundle=e},e.prototype.endBundle=function(){this.renderBundle.finish()},e.prototype.executeBundles=function(e){this.gpuRenderPassEncoder.executeBundles(e.map(function(e){return e.renderBundle}))},e.prototype.finish=function(){var e;null===(e=this.gpuRenderPassEncoder)||void 0===e||e.end(),this.gpuRenderPassEncoder=null;for(var t=0;this.gfxColorAttachment.length>t;t++){var r=this.gfxColorAttachment[t],n=this.gfxColorResolveTo[t];null!==r&&null!==n&&1===r.sampleCount&&this.copyAttachment(n,this.gfxColorAttachmentLevel[t],r,this.gfxColorResolveToLevel[t])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null},e.prototype.copyAttachment=function(e,t,r,n){Je(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},a={texture:e.gpuTexture,mipLevel:t};Je(r.width>>>n===e.width>>>t),Je(r.height>>>n===e.height>>>t),Je(!!(r.usage&Wr.COPY_SRC)),Je(!!(e.usage&Wr.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(i,a,[e.width,e.height,1])},e}(),Pn=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=ve.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return se(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(En),Nn=function(e){function t(t){var r,n,i=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Sampler;var o=i.lodMinClamp,s=i.mipmapFilter===Ce.NO_MIP?i.lodMinClamp:i.lodMaxClamp,u=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return u>1&&Je(i.minFilter===ye.BILINEAR&&i.magFilter===ye.BILINEAR&&i.mipmapFilter===Ce.LINEAR),a.gpuSampler=a.device.device.createSampler({addressModeU:Kr(i.addressModeU),addressModeV:Kr(i.addressModeV),addressModeW:Kr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:o,lodMaxClamp:s,minFilter:jr(i.minFilter),magFilter:jr(i.magFilter),mipmapFilter:Zr(i.mipmapFilter),compare:void 0!==i.compareFunction?ln(i.compareFunction):void 0,maxAnisotropy:u}),a}return se(t,e),t}(En),Mn=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,a=e.call(this,{id:t.id,device:t.device})||this;a.type=ve.Texture,a.flipY=!1;var o=r.format,s=r.dimension,u=r.width,l=r.height,c=r.depthOrArrayLayers,f=r.mipLevelCount,d=r.usage,_=r.pixelStore;return a.flipY=!!(null==_?void 0:_.unpackFlipY),a.device.createTextureShared({format:o,dimension:null!=s?s:xe.TEXTURE_2D,width:u,height:l,depthOrArrayLayers:null!=c?c:1,mipLevelCount:null!=f?f:1,usage:d,sampleCount:null!=i?i:1},a,n),a}return se(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,a={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},o=e.createTexture(a),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s],flipY:this.flipY},{texture:o,origin:[0,0,s]},[n,i]);return[o,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,a,o=this,s=this.device.device;if(this.isImageBitmapOrCanvases(e))n=(r=de(this.textureFromImageBitmapOrCanvas(s,e,this.depthOrArrayLayers),3))[0],i=r[1],a=r[2];else if(this.isVideo(e))n=s.importExternalTexture({source:e[0]});else{var u=pn(this.gpuTextureformat),l=Math.ceil(this.width/u.width)*u.length;e.forEach(function(e){s.queue.writeTexture({texture:o.gpuTexture},e,{bytesPerRow:l},{width:o.width,height:o.height})})}this.width=i,this.height=a,n&&(this.gpuTexture=n),this.gpuTextureView=this.gpuTexture.createView({dimension:zr(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(En),On=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=ve.RenderBundle,r.renderBundleEncoder=r.device.device.createRenderBundleEncoder({colorFormats:[r.device.swapChainFormat]}),r}return se(t,e),t.prototype.finish=function(){this.renderBundle=this.renderBundleEncoder.finish()},t}(En),In=function(){function e(e,t,r,n,i,a){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Wr.RENDER_ATTACHMENT|Wr.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Fe.UPPER_LEFT,this.clipSpaceNearZ=Ue.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.WGSLComposer=a,this.fallbackTexture2D=this.createFallbackTexture(xe.TEXTURE_2D,Le.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(xe.TEXTURE_2D,Le.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(xe.TEXTURE_2D_ARRAY,Le.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(xe.TEXTURE_3D,Le.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(xe.TEXTURE_CUBE_MAP,Le.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:Se.REPEAT,addressModeV:Se.REPEAT,minFilter:ye.POINT,magFilter:ye.POINT,mipmapFilter:Ce.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:Se.REPEAT,addressModeV:Se.REPEAT,minFilter:ye.POINT,magFilter:ye.POINT,mipmapFilter:Ce.NEAREST,compareFunction:Re.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Mn({id:0,device:this,descriptor:{format:Xe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:xe.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){Je(0===this.frameCommandEncoderPool.length)},e.prototype.endFrame=function(){Je(this.frameCommandEncoderPool.every(function(e){return null!==e})),this.device.queue.submit(this.frameCommandEncoderPool.map(function(e){return e.finish()})),this.frameCommandEncoderPool=[]},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new Rn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Mn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new Nn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Mn({id:this.getNextUniqueId(),device:this,descriptor:ue(ue({},e),{dimension:xe.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:Be.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=ve.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,a=e.sampleCount,o=e.mipLevelCount,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;Je(!!(l&Wr.RENDER_ATTACHMENT));var c=new Mn({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:xe.TEXTURE_2D,mipLevelCount:o,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=a,c.gpuTexture=s,c.gpuTextureView=u,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=dr(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=dr(this.queryVendorInfo(),"frag",e.fragment.glsl)),new gn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createProgramSimple=function(e){return new gn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,a=Yr(e.format),o=function(e){if(e===xe.TEXTURE_2D)return"2d";if(e===xe.TEXTURE_CUBE_MAP)return"2d";if(e===xe.TEXTURE_2D_ARRAY)return"2d";if(e===xe.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Be.SAMPLED&&(t|=Wr.TEXTURE_BINDING|Wr.COPY_DST|Wr.COPY_SRC),e&Be.STORAGE&&(t|=Wr.TEXTURE_BINDING|Wr.STORAGE_BINDING|Wr.COPY_SRC|Wr.COPY_DST),e&Be.RENDER_TARGET&&(t|=Wr.RENDER_ATTACHMENT|Wr.TEXTURE_BINDING|Wr.COPY_SRC|Wr.COPY_DST),t}(e.usage);if(t.gpuTextureformat=a,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:a,dimension:o,sampleCount:e.sampleCount,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},e.prototype.getFallbackSampler=function(e){return e.formatKind===Le.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===xe.TEXTURE_2D)return e.formatKind===Le.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===xe.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===xe.TEXTURE_3D)return this.fallbackTexture3D;if(t===xe.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===Le.Float?Xe.U8_RGBA_NORM:Xe.D24,usage:Be.SAMPLED,width:1,height:1,depthOrArrayLayers:e===xe.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new vn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new mn({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new An({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Pn({id:this.getNextUniqueId(),device:this,descriptor:ue({},e)})},e.prototype.createQueryPool=function(e,t){return new Sn({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,i=n.program,a=i.vertexStage,o=i.fragmentStage;if(null!==a&&null!==o){var s=n.megaStateDescriptor||{},u=s.stencilBack,l=s.stencilFront,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(s,["stencilBack","stencilFront"]),f=Rt(At);n.megaStateDescriptor=ue(ue(ue({},f),{stencilBack:ue(ue({},f.stencilBack),u),stencilFront:ue(ue({},f.stencilFront),l)}),c);var d=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach(function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=pt(void 0,d))});var _,h,p=(_=null!==(r=n.topology)&&void 0!==r?r:Pe.TRIANGLES,h=n.megaStateDescriptor,{topology:$r(_),cullMode:en(h.cullMode),frontFace:tn(h.frontFace)}),E=un(n.colorAttachmentFormats,n.megaStateDescriptor),v=function(e,t){if(!U(e))return{format:Yr(e),depthWriteEnabled:!!t.depthWrite,depthCompare:ln(t.depthCompare),depthBias:t.polygonOffset?t.polygonOffsetUnits:0,depthBiasSlopeScale:t.polygonOffset?t.polygonOffsetFactor:0,stencilFront:{compare:ln(t.stencilFront.compare),passOp:cn(t.stencilFront.passOp),failOp:cn(t.stencilFront.failOp),depthFailOp:cn(t.stencilFront.depthFailOp)},stencilBack:{compare:ln(t.stencilBack.compare),passOp:cn(t.stencilBack.passOp),failOp:cn(t.stencilBack.failOp),depthFailOp:cn(t.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),R=void 0;null!==n.inputLayout&&(R=n.inputLayout.buffers);var T=n.sampleCount,A={layout:"auto",vertex:ue(ue({},a),{buffers:R}),primitive:p,depthStencil:v,multisample:{count:T},fragment:ue(ue({},o),{targets:E})};e.gpuRenderPipeline=this.device.createRenderPipeline(A)}}},e.prototype.createReadback=function(){return new yn({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderBundle=function(){return new On({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();void 0===t&&(t=new Cn(this));var r=this.frameCommandEncoderPool.pop();return void 0===r&&(r=this.device.createCommandEncoder()),t.beginRenderPass(r,e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();void 0===e&&(e=new Tn);var t=this.frameCommandEncoderPool.pop();return void 0===t&&(t=this.device.createCommandEncoder()),e.beginComputePass(t),e},e.prototype.submitPass=function(e){var t=e;t instanceof Cn?(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.renderPassPool.push(t)):t instanceof Tn&&(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.computePassPool.push(t))},e.prototype.copySubTexture2D=function(e,t,r,n,i,a,o){var s=this.device.createCommandEncoder(),u=e,l=n,c={texture:l.gpuTexture,origin:[i,a,0],mipLevel:0,aspect:"all"},f={texture:u.gpuTexture,origin:[t,r,0],mipLevel:0,aspect:"all"};Je(!!(l.usage&Wr.COPY_SRC)),Je(!!(u.usage&Wr.COPY_DST)),s.copyTextureToTexture(c,f,[l.width,l.height,o||1]),this.device.queue.submit([s.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_SNORM:case we.BC4_UNORM:case we.BC5_SNORM:case we.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ke(e)){case we.BC1:case we.BC2:case we.BC3:case we.BC4_SNORM:case we.BC4_UNORM:case we.BC5_SNORM:case we.BC5_UNORM:return 4;default:return 1}}(e);return t%n===0&&r%n===0&&this.featureTextureCompressionBC}switch(e){case Xe.U16_RGBA_NORM:case Xe.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===ve.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===ve.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ve.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ve.Sampler){(r=e).gpuSampler.label=t}else if(e.type===ve.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),xn=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return le(this,void 0,void 0,function(){var t,r,n,i,a,o;return ce(this,function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc","float32-filterable"].filter(function(e){return t.features.has(e)}),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(a=this.pluginOptions.onContextLost,i.lost.then(function(){a&&a()})),null===i)return[2,null];if(!(o=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,Xr(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new In(t,i,e,o,wr,Gr&&new Gr)]}})})},e}();function Bn(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=R(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}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(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}var Dn={exports:{}};function bn(e,t,r){r=r||2;var n,i,a,o,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,d=Ln(e,0,f,r,!0),_=[];if(!d||d.next===d.prev)return _;if(c&&(d=function(e,t,r,n){var i,a,o,s=[];for(i=0,a=t.length;a>i;i++)(o=Ln(e,t[i]*n,a-1>i?t[i+1]*n:e.length,n,!1))===o.next&&(o.steiner=!0),s.push(zn(o));for(s.sort(Xn),i=0;s.length>i;i++)r=Wn(s[i],r);return r}(e,t,d,r)),e.length>80*r){n=a=e[0],i=o=e[1];for(var h=r;f>h;h+=r)n>(s=e[h])&&(n=s),i>(u=e[h+1])&&(i=u),s>a&&(a=s),u>o&&(o=u);l=0!==(l=Math.max(a-n,o-i))?32767/l:0}return Un(d,_,r,n,i,l,0),_}function Ln(e,t,r,n,i){var a,o;if(i===ai(e,t,r,n)>0)for(a=t;r>a;a+=n)o=ri(a,e[a],e[a+1],o);else for(a=r-n;a>=t;a-=n)o=ri(a,e[a],e[a+1],o);return o&&qn(o,o.next)&&(ni(o),o=o.next),o}function Fn(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!qn(n,n.next)&&0!==Zn(n.prev,n,n.next))n=n.next;else{if(ni(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function Un(e,t,r,n,i,a,o){if(e){!o&&a&&function(e,t,r,n){var i=e;do{0===i.z&&(i.z=Yn(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,a,o,s,u,l=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,n=r,s=0,t=0;l>t&&(s++,n=n.nextZ);t++);for(u=l;s>0||u>0&&n;)0===s||0!==u&&n&&r.z>n.z?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,s--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=n}a.nextZ=null,l*=2}while(o>1)}(i)}(e,n,i,a);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,a?wn(e,n,i,a):kn(e))t.push(s.i/r|0),t.push(e.i/r|0),t.push(u.i/r|0),ni(e),e=u.next,l=u.next;else if((e=u)===l){o?1===o?Un(e=Gn(Fn(e),t,r),t,r,n,i,a,2):2===o&&Vn(e,t,r,n,i,a):Un(Fn(e),t,r,n,i,a,1);break}}}function kn(e){var t=e.prev,r=e,n=e.next;if(Zn(t,r,n)>=0)return!1;for(var i=t.x,a=r.x,o=n.x,s=t.y,u=r.y,l=n.y,c=a>i?o>i?i:o:o>a?a:o,f=u>s?l>s?s:l:l>u?u:l,d=i>a?i>o?i:o:a>o?a:o,_=s>u?s>l?s:l:u>l?u:l,h=n.next;h!==t;){if(h.x>=c&&d>=h.x&&h.y>=f&&_>=h.y&&Kn(i,s,a,u,o,l,h.x,h.y)&&Zn(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function wn(e,t,r,n){var i=e.prev,a=e,o=e.next;if(Zn(i,a,o)>=0)return!1;for(var s=i.x,u=a.x,l=o.x,c=i.y,f=a.y,d=o.y,_=u>s?l>s?s:l:l>u?u:l,h=f>c?d>c?c:d:d>f?f:d,p=s>u?s>l?s:l:u>l?u:l,E=c>f?c>d?c:d:f>d?f:d,v=Yn(_,h,t,r,n),R=Yn(p,E,t,r,n),T=e.prevZ,A=e.nextZ;T&&T.z>=v&&A&&R>=A.z;){if(T.x>=_&&p>=T.x&&T.y>=h&&E>=T.y&&T!==i&&T!==o&&Kn(s,c,u,f,l,d,T.x,T.y)&&Zn(T.prev,T,T.next)>=0)return!1;if(T=T.prevZ,A.x>=_&&p>=A.x&&A.y>=h&&E>=A.y&&A!==i&&A!==o&&Kn(s,c,u,f,l,d,A.x,A.y)&&Zn(A.prev,A,A.next)>=0)return!1;A=A.nextZ}for(;T&&T.z>=v;){if(T.x>=_&&p>=T.x&&T.y>=h&&E>=T.y&&T!==i&&T!==o&&Kn(s,c,u,f,l,d,T.x,T.y)&&Zn(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;A&&R>=A.z;){if(A.x>=_&&p>=A.x&&A.y>=h&&E>=A.y&&A!==i&&A!==o&&Kn(s,c,u,f,l,d,A.x,A.y)&&Zn(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function Gn(e,t,r){var n=e;do{var i=n.prev,a=n.next.next;!qn(i,a)&&Qn(i,n,n.next,a)&&ei(i,a)&&ei(a,i)&&(t.push(i.i/r|0),t.push(n.i/r|0),t.push(a.i/r|0),ni(n),ni(n.next),n=e=a),n=n.next}while(n!==e);return Fn(n)}function Vn(e,t,r,n,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&jn(o,s)){var u=ti(o,s);return o=Fn(o,o.next),u=Fn(u,u.next),Un(o,t,r,n,i,a,0),void Un(u,t,r,n,i,a,0)}s=s.next}o=o.next}while(o!==e)}function Xn(e,t){return e.x-t.x}function Wn(e,t){var r=function(e,t){var r,n=t,i=e.x,a=e.y,o=-1/0;do{if(n.y>=a&&a>=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>o&&(o=s,r=n.next.x>n.x?n:n.next,s===i))return r}n=n.next}while(n!==t);if(!r)return null;var u,l=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!Kn(f>a?i:o,a,c,f,f>a?o:i,a,n.x,n.y)||(u=Math.abs(a-n.y)/(i-n.x),ei(n,e)&&(d>u||u===d&&(n.x>r.x||n.x===r.x&&Hn(r,n)))&&(r=n,d=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=ti(r,e);return Fn(n,n.next),Fn(r,r.next)}function Hn(e,t){return 0>Zn(e.prev,e,t.prev)&&0>Zn(t.next,e,e.next)}function Yn(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zn(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function Kn(e,t,r,n,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(n-s)>=(r-o)*(t-s)&&(r-o)*(a-s)>=(i-o)*(n-s)}function jn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Qn(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ei(e,t)&&ei(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(Zn(e.prev,e,t.prev)||Zn(e,t.prev,t))||qn(e,t)&&Zn(e.prev,e,e.next)>0&&Zn(t.prev,t,t.next)>0)}function Zn(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function qn(e,t){return e.x===t.x&&e.y===t.y}function Qn(e,t,r,n){var i=$n(Zn(e,t,r)),a=$n(Zn(e,t,n)),o=$n(Zn(r,n,e)),s=$n(Zn(r,n,t));return i!==a&&o!==s||(!(0!==i||!Jn(e,r,t))||(!(0!==a||!Jn(e,n,t))||(!(0!==o||!Jn(r,e,n))||!(0!==s||!Jn(r,t,n)))))}function Jn(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function $n(e){return e>0?1:0>e?-1:0}function ei(e,t){return 0>Zn(e.prev,e,e.next)?Zn(e,t,e.next)>=0&&Zn(e,e.prev,t)>=0:0>Zn(e,t,e.prev)||0>Zn(e,e.next,t)}function ti(e,t){var r=new ii(e.i,e.x,e.y),n=new ii(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function ri(e,t,r,n){var i=new ii(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ni(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 ii(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ai(e,t,r,n){for(var i=0,a=t,o=r-n;r>a;a+=n)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}Dn.exports=bn,Dn.exports.default=bn,bn.deviation=function(e,t,r,n){var i=t&&t.length,a=Math.abs(ai(e,0,i?t[0]*r:e.length,r));if(i)for(var o=0,s=t.length;s>o;o++){a-=Math.abs(ai(e,t[o]*r,s-1>o?t[o+1]*r:e.length,r))}var u=0;for(o=0;n.length>o;o+=3){var l=n[o]*r,c=n[o+1]*r,f=n[o+2]*r;u+=Math.abs((e[l]-e[f])*(e[c+1]-e[l+1])-(e[l]-e[c])*(e[f+1]-e[l+1]))}return 0===a&&0===u?0:Math.abs((u-a)/a)},bn.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var a=0;e[i].length>a;a++)for(var o=0;t>o;o++)r.vertices.push(e[i][a][o]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var oi=Dn.exports;
|
|
12
12
|
/*!
|
|
13
13
|
* @antv/g-math
|
|
14
14
|
* @description Geometry util
|
|
15
|
-
* @version 3.0
|
|
16
|
-
* @date 12/
|
|
15
|
+
* @version 3.1.0
|
|
16
|
+
* @date 12/24/2025, 11:55:15 AM
|
|
17
17
|
* @author AntVis
|
|
18
18
|
* @docs https://g.antv.antgroup.com/
|
|
19
|
-
*/function si(e,t,r,n){var i=e-r,a=t-n;return Math.sqrt(i*i+a*a)}function ui(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function li(e,t,r,n,i){var a=1-i;return a*a*a*e+3*t*i*a*a+3*r*i*i*a+n*i*i*i}function ci(e,t,r,n,i,a,o,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=si(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,o],[t,n,a,s]);var l=function(e,t,r,n,i,a,o,s,u){var l=li(e,r,i,o,u),c=li(t,n,a,s,u),f=ui(e,t,r,n,u),d=ui(r,n,i,a,u),
|
|
19
|
+
*/function si(e,t,r,n){var i=e-r,a=t-n;return Math.sqrt(i*i+a*a)}function ui(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function li(e,t,r,n,i){var a=1-i;return a*a*a*e+3*t*i*a*a+3*r*i*i*a+n*i*i*i}function ci(e,t,r,n,i,a,o,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=si(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,o],[t,n,a,s]);var l=function(e,t,r,n,i,a,o,s,u){var l=li(e,r,i,o,u),c=li(t,n,a,s,u),f=ui(e,t,r,n,u),d=ui(r,n,i,a,u),_=ui(i,a,o,s,u),h=ui(f.x,f.y,d.x,d.y,u),p=ui(d.x,d.y,_.x,_.y,u);return[[e,t,f.x,f.y,h.x,h.y,l,c],[l,c,p.x,p.y,_.x,_.y,o,s]]}(e,t,r,n,i,a,o,s,.5),c=[].concat(T(l[0]),[u-1]),f=[].concat(T(l[1]),[u-1]);return ci.apply(void 0,T(c))+ci.apply(void 0,T(f))}function fi(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function di(e,t,r,n,i,a,o){if(0===o)return(si(e,t,r,n)+si(r,n,i,a)+si(e,t,i,a))/2;var s=function(e,t,r,n,i,a,o){var s=fi(e,r,i,o),u=fi(t,n,a,o),l=ui(e,t,r,n,o),c=ui(r,n,i,a,o);return[[e,t,l.x,l.y,s,u],[s,u,c.x,c.y,i,a]]}(e,t,r,n,i,a,.5),u=s[0],l=s[1];return u.push(o-1),l.push(o-1),di.apply(void 0,T(u))+di.apply(void 0,T(l))}
|
|
20
20
|
/*!
|
|
21
21
|
* @antv/g-plugin-device-renderer
|
|
22
22
|
* @description A G plugin of renderer implementation with GPUDevice
|
|
23
|
-
* @version 2.
|
|
24
|
-
* @date 12/
|
|
23
|
+
* @version 2.6.1
|
|
24
|
+
* @date 12/24/2025, 11:56:30 AM
|
|
25
25
|
* @author AntVis
|
|
26
26
|
* @docs https://g.antv.antgroup.com/
|
|
27
27
|
*/
|
|
28
|
-
var hi=u(function e(){l(this,e),this.drawcalls=[]});hi.tag="c-renderable-3d";var _i=function(){return u(function e(){l(this,e),this.lights=[]},[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value:function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach(function(t){e[t.define]||(e[t.define]=0),e[t.define]++}),e}},{key:"sortLights",value:function(){this.lights.sort(function(e,t){return e.order-t.order})}}])}(),pi=["style"],Ei=function(e){function r(e){var n,i=e.style,a=T(e,pi);return l(this,r),(n=h(this,r,[o({type:t.Shape.MESH,style:o({x:"",y:"",z:"",lineWidth:0},i)},a)])).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return p(r,e),u(r,[{key:"destroy",value:function(){A(r,"destroy",this,3)([]);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}])}(t.DisplayObject);Ei.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["x","y","z","geometry","material"]));var vi=function(){return u(function e(){l(this,e)},[{key:"update",value:function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,a=e.z,o=void 0===a?0:a,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:o,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}}}])}(),Ri=function(){return u(function e(){l(this,e),this.counter=0,this.id2DisplayObjectMap={}},[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"deleteById",value:function(e){delete this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=C(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}])}(),mi=function(){return u(function e(){l(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}},[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(U(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return void 0===(t=this.defines[e])?null:t;var t}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&$e("1"===t),null!==t}}])}(),Ti=function(){return u(function e(t){l(this,e),this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize},[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){e=ct(e,this.uniformBufferWordAlignment),$e(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=ct(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){$e(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=ct(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return Je(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=Je(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:Ne.UNIFORM,hint:Me.DYNAMIC}));var t=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())Je(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}])}();function gi(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Ai(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function yi(e){return 0}var Si=u(function e(){l(this,e),this.keys=[],this.values=[]}),Ci=function(){return u(function e(t,r){l(this,e),this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r},[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Si);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=Bn(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:b().mark(function e(){var t,r,n,i,a;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=Bn(this.buckets.values()),e.prev=1,t.s();case 2:if((r=t.n()).done){e.next=6;break}i=(n=r.value).values.length-1;case 3:if(i<0){e.next=5;break}return e.next=4,n.values[i];case 4:i--,e.next=3;break;case 5:e.next=2;break;case 6:e.next=8;break;case 7:e.prev=7,a=e.catch(1),t.e(a);case 8:return e.prev=8,t.f(),e.finish(8);case 9:case"end":return e.stop()}},e,this,[[1,7,8,9]])})}])}();function Pi(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:dr(e,"vert",t,n),preprocessedFrag:dr(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function Ni(e,t){return $e(""!==e.preprocessedVert&&""!==t.preprocessedVert),$e(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Mi(e,t){return e=gi(e,t.blendMode),e=gi(e,t.blendSrcFactor),e=gi(e,t.blendDstFactor)}function Oi(e,t){return e=Mi(e,t.rgbBlendState),e=gi(e=Mi(e,t.alphaBlendState),t.channelWriteMask)}function Ii(e,t){for(var r,n,i,a,o,s,u,l,c=0;t.attachmentsState.length>c;c++)e=Oi(e,t.attachmentsState[c]);return e=function(e,t){return gi(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=gi(e,t.depthCompare),e=gi(e,t.depthWrite?1:0),e=gi(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=gi(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=gi(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=gi(e,null===(a=t.stencilFront)||void 0===a?void 0:a.depthFailOp),e=gi(e,null===(o=t.stencilBack)||void 0===o?void 0:o.compare),e=gi(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=gi(e,null===(u=t.stencilBack)||void 0===u?void 0:u.failOp),e=gi(e,null===(l=t.stencilBack)||void 0===l?void 0:l.depthFailOp),e=gi(e,t.stencilWrite?1:0),e=gi(e,t.cullMode),e=gi(e,t.frontFace?1:0),e=gi(e,t.polygonOffset?1:0)}function xi(e){var t=0;t=gi(t,e.program.id),null!==e.inputLayout&&(t=gi(t,e.inputLayout.id)),t=Ii(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=gi(t,e.colorAttachmentFormats[r]||0);return Ai(t=gi(t,e.depthStencilAttachmentFormat||0))}function Bi(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=gi(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var a=e.uniformBufferBindings[i];null!==a&&null!==a.buffer&&(t=gi(t,a.buffer.id),t=gi(t,a.binding),t=gi(t,a.offset),t=gi(t,a.size))}return Ai(t)}var Di=function(){return u(function e(t){l(this,e),this.bindingsCache=new Ci(It,Bi),this.renderPipelinesCache=new Ci(Ft,xi),this.inputLayoutsCache=new Ci(wt,yi),this.programCache=new Ci(Ni,yi),this.samplerCache=new Ci(Gt,yi),this.device=t},[{key:"createBindings",value:function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Pt(t.samplerBindings,Vt),uniformBufferBindings:t.uniformBufferBindings&&Pt(t.uniformBufferBindings,Xt),storageBufferBindings:t.storageBufferBindings&&Pt(t.storageBufferBindings,Xt),storageTextureBindings:t.storageTextureBindings&&Pt(t.storageTextureBindings,Wt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter(function(e){return e.size>0}),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r}},{key:"createRenderPipeline",value:function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var a=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&Rt(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o(o({},a),{},{colorAttachmentFormats:e.colorAttachmentFormats.filter(function(e){return e})})),this.renderPipelinesCache.add(a,i)}return i}},{key:"createInputLayout",value:function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter(function(e){return!!e});var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Pt((t=e).vertexBufferDescriptors,zt),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r}},{key:"createProgramSimple",value:function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,a=null;if(i&&n&&(a=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===a){var o=Pi(this.device,e),s=o.preprocessedVert,u=o.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=u;var l={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};a=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:u}},r),this.programCache.add(l,a)}return a}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=Bn(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=Bn(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,a=Bn(this.inputLayoutsCache.values());try{for(a.s();!(i=a.n()).done;){i.value.destroy()}}catch(e){a.e(e)}finally{a.f()}var o,s=Bn(this.programCache.values());try{for(s.s();!(o=s.n()).done;){o.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=Bn(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}])}(),bi=function(e){return e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping",e}({}),Li=function(e){return e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil",e}({}),Fi=function(){return u(function e(){l(this,e),this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]},[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n}},{key:"attachRenderTargetID",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;$e(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"exec",value:function(e){$e(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){$e(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}])}(),Ui=function(){return u(function e(t,r){l(this,e),this.dimension=xe.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Be.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,$e(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))},[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){$e(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.attachment.destroy()}}])}(),ki=function(){return u(function e(t,r){l(this,e),this.dimension=xe.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Be.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)},[{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){$e(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}])}(),wi=u(function e(){l(this,e),this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]}),Gi=function(){return u(function e(t){l(this,e),this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t},[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Ui(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new ki(this.device,e)}},{key:"beginGraphBuilder",value:function(){$e(null===this.currentGraph),this.currentGraph=new wi}},{key:"pushPass",value:function(e){var t=new Fi;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=Je(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return $e(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);$e(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r}},{key:"getRenderTargetDescription",value:function(e){return Je(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var a=t.resolveTextureInputIDs[i];if(void 0!==a)this.resolveTextureUseCount[a]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[a]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if($e(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=Je(this.renderTargetAliveForID[e]);return t?($e(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):($e(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,this.renderTargetAliveForID[e]=void 0,this.renderTargetDeadPool.push(r)),r}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];$e(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=Je(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return Je(n.texture)}},{key:"determineResolveParam",value:function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],a=t.resolveTextureOutputExternalTextures[r],o=void 0!==i,s=void 0!==a;$e(!(o&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),o){$e(e.resolveTextureRenderTargetIDs[i]===n),$e(this.resolveTextureUseCount[i]>0),$e(this.renderTargetOutputCount[n]>0);var f=Je(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=Je(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,"".concat(f.debugName," (Resolve ").concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=a,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}}},{key:"schedulePass",value:function(e,t){for(var r=t.renderTargetIDs[Li.DepthStencil],n=Li.Color0;Li.ColorMax>=n;n++){var i=t.renderTargetIDs[n],a=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=a,t.descriptor.colorAttachment[n]=null!==a?a.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var o=this.determineResolveParam(e,t,n),s=o.store,u=o.level;t.descriptor.colorResolveTo[n]=o.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==a&&a.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Li.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Li.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,h=0,_=0,p=0;t.renderTargets.length>p;p++){var E=t.renderTargets[p];if(E){var v=E.width>>>t.renderTargetLevels[p],R=E.height>>>t.renderTargetLevels[p];0===d&&(d=v,h=R,_=E.sampleCount),$e(v===d),$e(R===h),$e(E.sampleCount===_),E.needsClear=!1}}d>0&&h>0&&(t.viewportX*=d,t.viewportY*=h,t.viewportW*=d,t.viewportH*=h);for(var m=0;t.resolveTextureInputIDs.length>m;m++){t.resolveTextureInputTextures[m]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[m])}for(var T=0;t.renderTargetIDs.length>T;T++)this.releaseRenderTargetForID(t.renderTargetIDs[T],!0);for(var g=0;t.renderTargetExtraRefs.length>g;g++)t.renderTargetExtraRefs[g]&&this.releaseRenderTargetForID(t.renderTargetIDs[g],!0)}},{key:"scheduleGraph",value:function(e){$e(0===this.renderTargetOutputCount.length),$e(0===this.renderTargetResolveCount.length),$e(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;ut(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),ut(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),ut(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var a=0;this.renderTargetOutputCount.length>a;a++)$e(0===this.renderTargetOutputCount[a]);for(var o=0;this.renderTargetResolveCount.length>o;o++)$e(0===this.renderTargetResolveCount[o]);for(var s=0;this.resolveTextureUseCount.length>s;s++)$e(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)$e(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){$e(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach(function(e){t.execPass(e)}),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=Je(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return $e(r>=0),Je(t.resolveTextureInputTextures[r])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)$e(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)$e(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()}}])}(),Vi=function(e){return e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT",e}({});function Xi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,n=w(e,0,r)/r;return t&&(n=1-n),65535&65535*n}function Wi(e,t){return(16777215&e|(255&t)<<24)>>>0}function Hi(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function zi(e,t){return Wi(Hi(0,t),e)}function Yi(e,t){return $e(t>=0),(4294967040&e|t>>>8&255)>>>0}function Ki(e){return Wi(0,e)}function ji(e,t){return $e(t>=0),(4278190335&e|t<<8)>>>0}var Zi=z(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var qi=z(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Qi(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=a,4}var $i=function(e){return e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags",e}({}),Ji=function(){return u(function e(){l(this,e),this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=dt(1,function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}}),this.dynamicUniformBufferByteOffsets=dt(4,function(){return 0}),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:Rt(Tt),program:null,topology:Pe.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()},[{key:"reset",value:function(){this.sortKey=0,this.flags=$i.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){var t,r;vt(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=m(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~$i.InheritedFlags|e.flags&$i.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],a=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=a.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=a.uniformBufferBindings)||void 0===r?void 0:r.length});for(var o=0;Math.min(i.uniformBufferBindings.length,a.uniformBufferBindings.length)>o;o++)i.uniformBufferBindings[o].size=e.bindingDescriptors[0].uniformBufferBindings[o].size;this.setSamplerBindingsFromTextureMappings(a.samplerBindings);for(var s=0;e.dynamicUniformBufferByteOffsets.length>s;s++)this.dynamicUniformBufferByteOffsets[s]=e.dynamicUniformBufferByteOffsets[s]}},{key:"validate",value:function(){for(var e=0;this.bindingDescriptors.length>e;e++)for(var t=this.bindingDescriptors[e],r=0;r<(null===(n=t.uniformBufferBindings)||void 0===n?void 0:n.length);r++){var n;$e(t.uniformBufferBindings[r].size>0)}$e(this.drawCount>0)}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return vt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setVertexInput",value:function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){$e(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ft(this.flags,$i.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=ft(this.flags,$i.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ft(this.flags,$i.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach(function(e){var t=e.value;if(G(t)||Array.isArray(t)||t instanceof Float32Array){var i=G(t)?[t]:t,a=4-r%4;if(4!==a)if(a<(i.length>4?4:i.length)){r+=a;for(var o=0;a>o;o++)n.push(0)}else;r+=i.length,n.push.apply(n,m(i))}});var i=4-n.length%4;if(4!==i)for(var a=0;i>a;a++)n.push(0);for(var o=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)o+=Qi(s,o,n[u],n[u+1],n[u+2],n[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){var r;return $e((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter(function(e){return e});for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=ft(this.flags,$i.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var a=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:$e(n===a.sampleCount))}var o=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:$e(n===o.sampleCount)),$e(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&$i.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=Je(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach(function(e){var t={};e.forEach(function(e){t[e.name]=e.value}),r.renderPipelineDescriptor.program.setUniformsLegacy(t)});var s=e.createBindings(o(o({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(s),this.flags&$i.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0}}])}();function ea(e,t){return e.sortKey-t.sortKey}var ta=function(e){return e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e}({}),ra=function(){return u(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ea,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ta.Forwards;l(this,e),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r},[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var a=n+(i-n>>>1);0>r(t,e[a])?i=a:n=a+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=$i.Draw,this.insertSorted(e)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){if(this.ensureSorted(),this.executionOrder===ta.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(var n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}])}(),na=function(){return u(function e(){l(this,e),this.pool=[],this.allocCount=0},[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Ji),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}])}(),ia=function(){return u(function e(t){l(this,e),this.instPool=new na,this.templatePool=new na,this.simpleRenderInstList=new ra,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t},[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{key:"submitRenderInst",value:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList).submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){$e(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=$i.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),$e(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){Je(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){Je(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}])}(),aa=function(){return u(function e(t){l(this,e),this.parameters=t},[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new Di(e),this.renderGraph=new Gi(this.device),this.renderInstManager=new ia(this.renderCache),this.uniformBuffer=new Ti(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}},{key:"getDefines",value:function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==bi.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}}}])}(),oa=function(){return u(function e(t){l(this,e),this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.format=t},[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}])}();function sa(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var ua=sa(tt(.88,.88,.88,1)),la=sa(nt),ca=sa(at),fa=function(e){return e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4",e}({});function da(e,t){var r=function(e){return e.antialiasingMode===fa.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function ha(e,t,r){var n=function(e){if(e===Li.Color0)return Xe.U8_RGBA_RT;if(e===Li.DepthStencil)return Xe.D24_S8;throw Error("whoops")}(e),i=new oa(n);return da(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}var _a=function(){return u(function e(){l(this,e),this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}])}(),pa=function(){return u(function e(){l(this,e),this.inputTexture=null,this.outputTexture=null},[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),$e(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new ki(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}])}(),Ea=["style"],va=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=T(e,Ea);return l(this,t),h(this,t,[o({type:t.tag,style:o({intensity:Math.PI},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);va.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["intensity"])),va.tag="light";var Ra=["style"],ma=function(e){return e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR",e}({}),Ta=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=T(e,Ra);return l(this,t),h(this,t,[o({type:t.tag,style:o({type:ma.NONE,fill:"black",start:1,end:1e3,density:0},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);function ga(e,t,r){var n=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:arguments.length>3&&void 0!==arguments[3]?arguments[3]:Me.STATIC});return n.setSubData(0,new Uint8Array(r)),n}Ta.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["type","density","start","end"])),Ta.tag="fog";var Aa,ya,Sa=function(e){return e.CHANGED="changed",e}({}),Ca=function(e){function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(this,r),(t=h(this,r)).drawMode=Pe.TRIANGLES,t.vertexBuffers=[],t.vertices=[],t.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=n,t}return p(r,e),u(r,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ga(this.device,Ne.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=Xe.U32_R,this}},{key:"setVertexBuffer",value:function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach(function(e){var n=e.format,i=e.bufferByteOffset,a=e.location,o=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find(function(e){return e.shaderLocation===a});s?(s.format=n,s.offset=i,s.divisor=o):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:a,divisor:o})}),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var a=ga(this.device,Ne.VERTEX,i.buffer,Me.DYNAMIC);return this.vertexBuffers[r]=a,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var a=i.arrayStride,o=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find(function(e){return e.shaderLocation===t});if(o)this.getVertexBuffer(e).setSubData(o.offset+r*a,n);this.emit(Sa.CHANGED)}}},{key:"updateIndices",value:function(e){return this.indexBuffer&&this.indexBuffer.setSubData(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach(function(e){e&&e.destroy()}),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}])}(We),Pa=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",e.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",e}return p(t,e),u(t)}(mi),Na=dt(1,function(){return new _a});function Ma(e,t,r,n){e.pushPass(function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Li.Color0,n);var a=e.resolveRenderTarget(n);i.attachResolveTexture(a);var o=t.renderInstManager.newRenderInst();o.setUniformBuffer(t.uniformBuffer),o.setAllowSkippingIfPipelineNotReady(!1),o.setMegaStateFlags(gt),o.setBindingLayout({numUniformBuffers:1,numSamplers:1}),o.drawPrimitives(3);var s=o.allocateUniformBuffer(0,4);Qi(o.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Pa,l=t.renderCache.createProgramSimple(u);o.setProgram(l),Aa||((Aa=new Ca(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),Aa.vertexCount=3,ya=t.getCache().createInputLayout(Aa.inputLayoutDescriptor)),i.exec(function(e,r){Na[0].texture=r.getResolveTextureForID(a),o.setSamplerBindingsFromTextureMappings(Na),o.setVertexInput(ya,Aa.vertexBuffers.map(function(e){return{buffer:e,byteOffset:0}}),null),o.drawOnPass(t.renderCache,e)})})}var Oa=function(e){return e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking",e}({}),Ia=function(){function e(t,r,n,i,a){l(this,e),this.renderLists={leftEye:new ra,rightEye:new ra,picking:new ra},this.cameras=[],this.renderHelper=t,this.lightPool=r,this.texturePool=n,this.batchManager=i,this.options=a}return u(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.config,s=r.renderingContext.root.ownerDocument.defaultView;a.disableRenderHooks=!0;var u=function(e){var t=e.target;t.nodeName!==va.tag?t.nodeName!==Ta.tag?(t.renderable3D||(t.renderable3D=new hi),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},l=function(e){var r=e.target;if(r.nodeName!==va.tag)if(r.nodeName!==Ta.tag){if(r.nodeName===t.Shape.MESH){var i,a;if(null!==(i=r.style.geometry)&&void 0!==i&&i.meshes){var o=r.style.geometry.meshes.indexOf(r);o>-1&&r.style.geometry.meshes.splice(o,1)}if(null!==(a=r.style.material)&&void 0!==a&&a.meshes){var s=r.style.material.meshes.indexOf(r);s>-1&&r.style.material.meshes.splice(s,1)}}n.swapChain&&n.batchManager.remove(r),delete r.renderable3D}else n.lightPool.removeFog(r);else n.lightPool.removeLight(r)},c=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach(function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)}):n.batchManager.updateAttribute(t,r,i)}},f=function(e){if(n.swapChain)for(var r=e.detail,i=0;r.length>i;i++){var a=r[i].target;(a.nodeName===t.Shape.FRAGMENT?a.childNodes:[a]).forEach(function(e){n.batchManager.updateAttribute(e,"modelMatrix",null)})}};i.hooks.initAsync.tapPromise(e.tag,F(b().mark(function e(){var i,a;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s.addEventListener(t.ElementEvent.MOUNTED,u),s.addEventListener(t.ElementEvent.UNMOUNTED,l),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((a=n.context.config).width,a.height),e.next=1,n.context.deviceContribution.createSwapChain(i);case 1:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),s.addEventListener(t.CanvasEvent.RESIZE,function(){n.swapChain.configureSwapChain(i.width,i.height)}),n.batchManager.attach(o({device:n.device},r));case 2:case"end":return e.stop()}},e)}))),i.hooks.destroy.tap(e.tag,function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),s.removeEventListener(t.ElementEvent.MOUNTED,u),s.removeEventListener(t.ElementEvent.UNMOUNTED,l),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.device.destroy(),n.device.checkForLeaks(),a.disableRenderHooks=!1}),i.hooks.beginFrame.tap(e.tag,function(e){var r,i=null==e?void 0:e.session,a=n.context.config,o=a.width,s=a.height;if(i){var u=i.renderState.baseLayer;u||(u=i.renderState.layers[0]),n.swapChain.configureSwapChain(u.framebufferWidth,u.framebufferHeight,u.framebuffer);var l=e.getViewerPose(i.referenceSpace);l&&l.views.forEach(function(e,t){var r=i.renderState.baseLayer.getViewport(e),a=z.apply(ie,m(e.transform.matrix));a[12]*=o,a[13]*=s,a[14]*=500,a[12]+=o/2,a[13]-=s/2,a[14]+=250;var l=z.apply(ie,m(e.projectionMatrix)),c=K(W(),a);Z(c,c,ae(1,-1,1));var f=e.transform.position;n.cameras[t]={viewport:{x:r.x/u.framebufferWidth,y:r.y/u.framebufferHeight,width:r.width/u.framebufferWidth,height:r.height/u.framebufferHeight},projectionMatrix:l,viewMatrix:c,cameraPosition:[f.x,f.y,f.z],isOrtho:!1}})}else{var c=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:c.getPerspective(),viewMatrix:c.getViewTransform(),cameraPosition:c.getPosition(),isOrtho:c.isOrtho()}]}var f,d=n.swapChain.getCanvas(),h=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)f=rt;else{var _=t.parseColor(n.context.config.background);f=n.context.config.background?tt(Number(_.r)/255*Number(_.alpha),Number(_.g)/255*Number(_.alpha),Number(_.b)/255*Number(_.alpha),Number(_.alpha)):it}var p={backbufferWidth:d.width,backbufferHeight:d.height,antialiasingMode:fa.None},E=ha(Li.Color0,p,sa(f)),v=ha(Li.DepthStencil,p,ca),R=n.builder.createRenderTargetID(E,"Main Color"),T=n.builder.createRenderTargetID(v,"Main Depth");n.builder.pushPass(function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Li.Color0,R),e.attachRenderTargetID(Li.DepthStencil,T),e.exec(function(e,t){n.cameras.forEach(function(r,i){var a=r.viewport,o=t.currentPass,s=o.viewportW,u=o.viewportH;e.setViewport(a.x*s,a.y*u,a.width*s,a.height*u),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(h.renderCache,e)})})}),null!==(r=n.options)&&void 0!==r&&r.enableFXAA&&Ma(n.builder,n.renderHelper,p,R),n.builder.resolveRenderTargetToExternalTexture(R,n.swapChain.getOnscreenTexture())}),i.hooks.endFrame.tap(e.tag,function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,a=r.height;if(n.cameras.forEach(function(e,r){var o=e.viewport,s=e.cameraPosition,u=e.viewMatrix,l=e.projectionMatrix,c=e.isOrtho,f=o.width,d=o.height,h=n.renderHelper.pushTemplateRenderInst();h.setBindingLayout({numUniformBuffers:2,numSamplers:0}),h.setMegaStateFlags(At({depthWrite:!0,blendConstant:rt},{rgbBlendMode:Ae.ADD,alphaBlendMode:Ae.ADD,rgbBlendSrcFactor:ge.SRC_ALPHA,alphaBlendSrcFactor:ge.ONE,rgbBlendDstFactor:ge.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:ge.ONE_MINUS_SRC_ALPHA})),h.setUniforms(0,[{name:Oa.PROJECTION_MATRIX,value:l},{name:Oa.VIEW_MATRIX,value:u},{name:Oa.CAMERA_POSITION,value:s},{name:Oa.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Oa.VIEWPORT,value:[i*f,a*d]},{name:Oa.IS_ORTHO,value:c?1:0},{name:Oa.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()}),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var o=n.captureOptions,s=o.type,u=o.encoderOptions,l=n.context.contextService.getDomElement().toDataURL(s,u);n.resolveCapturePromise(l),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}})}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,function(e){r&&r(e)})}},{key:"toDataURL",value:(r=F(b().mark(function e(t){var r=this;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise(function(e){r.resolveCapturePromise=function(t){e(t)}}),e.abrupt("return",this.capturePromise);case 1:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})}]);var r}();Ia.tag="RenderGraph";var xa=function(){function e(t,r,n,i){l(this,e),this.renderHelper=t,this.renderGraphPlugin=r,this.pickingIdGenerator=n,this.batchManager=i}return u(e,[{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new hi);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},s=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,function(){a.addEventListener(t.ElementEvent.MOUNTED,o),a.addEventListener(t.ElementEvent.UNMOUNTED,s)}),i.hooks.destroy.tap(e.tag,function(){a.removeEventListener(t.ElementEvent.MOUNTED,o),a.removeEventListener(t.ElementEvent.UNMOUNTED,s),n.pickingIdGenerator.reset()}),i.hooks.pickSync.tap(e.tag,function(e){return n.pick(e)}),i.hooks.pick.tapPromise(e.tag,function(){var e=F(b().mark(function e(t){return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.pick(t));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}},{key:"pick",value:function(e){var r=e.topmost,n=e.position,i=n.viewportX,a=n.viewportY,o=this.context.contextService.getDPR(),s=this.context.config.width*o,u=this.context.config.height*o,l=i*o,c=a*o;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(w(Math.round(l),0,s-1),w(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e}},{key:"pickByRectangleInDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i}},{key:"restorePickingColor",value:function(e){var t=this;e.forEach(function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)})}},{key:"pickByRectangle",value:function(e,t){var r,n=this,i=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,u=this.renderHelper.renderGraph.newGraphBuilder(),l=this.context.camera,c=e.x,f=e.y,d=e.width,h=e.height,_={backbufferWidth:d,backbufferHeight:h,antialiasingMode:fa.None},p=ha(Li.Color0,_,sa(rt)),E=u.createRenderTargetID(p,"Picking Color"),v=ha(Li.DepthStencil,_,ca),R=u.createRenderTargetID(v,"Picking Depth"),m=o({},l.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach(function(e){e.age=-1}),u.pushPass(function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Li.Color0,E),e.attachRenderTargetID(Li.DepthStencil,R),e.exec(function(e){a.picking.drawOnPassRenderer(s.renderCache,e)}),e.post(function(e){var t,a=e.getRenderTargetTexture(Li.Color0),o=i.createReadback();m&&m.enabled?l.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):l.clearViewOffset(),l.setEnableUpdate(!0);try{t=o.readTextureSync(a,0,0,d,h,new Uint8Array(d*h*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var u=n.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(r=u)}o.destroy()})});var T=this.renderHelper.pushTemplateRenderInst();T.setBindingLayout({numUniformBuffers:2,numSamplers:0}),T.setMegaStateFlags(At({depthWrite:!0},{rgbBlendMode:Ae.ADD,rgbBlendSrcFactor:ge.ONE,rgbBlendDstFactor:ge.ZERO,alphaBlendMode:Ae.ADD,alphaBlendSrcFactor:ge.ONE,alphaBlendDstFactor:ge.ZERO}));var g=this.context.config,A=g.width,y=g.height,S=this.context.contextService.getDPR();return l.setEnableUpdate(!1),l.setViewOffset(A*S,y*S,c,y*S-f,d,h),T.setUniforms(0,[{name:Oa.PROJECTION_MATRIX,value:l.getPerspective()},{name:Oa.VIEW_MATRIX,value:l.getViewTransform()},{name:Oa.CAMERA_POSITION,value:l.getPosition()},{name:Oa.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Oa.VIEWPORT,value:[d,h]},{name:Oa.IS_ORTHO,value:l.isOrtho()?1:0},{name:Oa.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r}}])}();xa.tag="WebGLPicker";var Ba=5e-4,Da=function(){return u(function e(){l(this,e),this.clipPathMeshCreated=!1},[{key:"beforeUploadUBO",value:function(e,t){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}])}();var ba=function(e){return e.CHANGED="changed",e}({}),La=function(e){function t(e,r){var n;l(this,t),(n=h(this,t)).props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=Rt(Tt),a=i.cullMode,s=i.depthCompare,u=i.depthWrite,c=i.stencilFront,f=i.stencilBack,d=i.stencilWrite,_=i.frontFace,p=i.polygonOffset,E=i.attachmentsState;return n.device=e,n.props=o({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilFront:c,stencilBack:f,stencilWrite:d,frontFace:_,polygonOffset:p,attachmentsState:E,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return p(t,e),u(t,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilFront",get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e}},{key:"stencilBack",get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,function(t,r){return e.samplers.push(r),""}),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach(function(e){var t=de(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})}),r.push({type:t.trim(),uniforms:i}),""}),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach(function(e){var n=e.trim().split(" "),i=n[0]||"",a=n[1]||"",o=a.indexOf("[")>-1;if(a=a.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find(function(e){return i===e.type});if(s)if(o)for(var u=function(e){s.uniforms.forEach(function(r){t.push("".concat(a,"[").concat(e,"].").concat(r.name))})},l=0;5>l;l++)u(l);else s.uniforms.forEach(function(e){t.push("".concat(a,".").concat(e.name))})}a&&t.push(a)}}),""}),t}(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,r=!1;Object.keys(e).forEach(function(n){var i,a=e[n],o=t.textures[n];o&&o!==a&&(t.textureDirty=!0),(i=a)&&i.type?(t.textures[n]=a,t.textureDirty=!0,a.on(Ie.LOADED,function(){t.dispatchMutationEvent()})):(t.uniforms[n]=a,r=!0),U(e[n])&&(delete t.textures[n],delete t.uniforms[n])}),r&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(ba.CHANGED)}}])}(We),Fa=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t,[e,o({},r)])).defines=o(o({},n.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return p(t,e),u(t)}(La);function Ua(e){var t={};return Object.keys(e).forEach(function(r){"number"==typeof e[r]&&(t[r]=e[r])}),t}function ka(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(function(r){return e[r]===t[r]})}var wa=function(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=C(e,2);return void 0!==t[1]}))};function Ga(e,t){return 256*(e=w(Math.floor(e),0,255))+(t=w(Math.floor(t),0,255))}var Va=1,Xa="FillTextureMapping",Wa=function(e){return e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX",e}({}),Ha=function(e){return e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX",e}({}),za=function(){return u(function e(t,r,n,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:-1,s=arguments.length>6?arguments[6]:void 0;l(this,e),this.id=Va++,this.gradientAttributeName="fill",this.objects=[],this.program=new mi,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1,this.renderHelper=t,this.texturePool=r,this.lightPool=n,this.drawcallCtors=a,this.index=o,this.context=s},[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Fa(this.context.device),this.material.defines=o(o({},Ua(Ha)),this.material.defines),this.geometry=new Ca(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(Sa.CHANGED,function(){e.geometry.meshes.forEach(function(e){e.renderable.dirty=!0}),e.context.renderingService.dirty()})}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(ba.CHANGED,function(){e.material.meshes.forEach(function(e){e.renderable.dirty=!0}),e.context.renderingService.dirty()})}},{key:"shouldMergeColor",value:function(e,r,n){var i=e.parsedStyle[n],a=r.parsedStyle[n];return!i&&!a||(!(!t.isCSSRGB(i)||!t.isCSSRGB(a))||(!(!t.isPattern(i)||!t.isPattern(a)||i.image!==a.image)||!(!Array.isArray(i)||!Array.isArray(a)||e.style[n]!==r.style[n])))}},{key:"shouldMerge",value:function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))}},{key:"createGeometry",value:function(e){var r,n,i=this,a=W(),o=W(),s=[],u=[],l=[],c=[],f=this.divisor,d=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach(function(e){var r,n=e.parsedStyle,f=n.fill,h=n.stroke,_=n.opacity,p=void 0===_?1:_,E=n.fillOpacity,v=void 0===E?1:E,R=n.strokeOpacity,T=void 0===R?1:R,g=n.lineWidth,A=void 0===g?1:g,y=n.visibility,S=n.increasedLineWidthForHitTesting,C=void 0===S?0:S,P=[0,0,0,0];t.isCSSRGB(f)&&(P=[Number(f.r),Number(f.g),Number(f.b),255*Number(f.alpha)]);var N=[0,0,0,0];t.isCSSRGB(h)&&(N=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),ne(o,i.context.camera.getViewTransform(),a);var M=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var O=e.parsedStyle,I=O.x,x=O.y,B=O.z;ne(a,e.getWorldTransform(),q(a,ae(I,x,B)))}else H(a,e.getWorldTransform());s.push.apply(s,m(a)),u.push(Ga(P[0],P[1]),Ga(P[2],P[3]),Ga(N[0],N[1]),Ga(N[2],N[3])),l.push(p,v,T,A,"hidden"!==y?1:0,d,d,C),c.push.apply(c,m(M).concat([e.sortable.renderOrder*Ba]))}),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Wa.MODEL_MATRIX,byteStride:64,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.MODEL_MATRIX0,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.MODEL_MATRIX1,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:32,location:Ha.MODEL_MATRIX2,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:48,location:Ha.MODEL_MATRIX3,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PACKED_COLOR,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PACKED_COLOR,divisor:f}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PACKED_STYLE,byteStride:32,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PACKED_STYLE1,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.PACKED_STYLE2,divisor:f}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PICKING_COLOR,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PICKING_COLOR,divisor:f}],data:new Float32Array(c)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:Re.ALWAYS,passOp:be.REPLACE},this.material.stencilBack={compare:Re.ALWAYS,passOp:be.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:Re.EQUAL,passOp:be.KEEP},this.material.stencilBack={compare:Re.EQUAL,passOp:be.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var i=o({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=o(o(o({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort(function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)}).forEach(function(e){var t=new _a;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture ".concat(e)),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:ye.CLAMP_TO_EDGE,addressModeV:ye.CLAMP_TO_EDGE,minFilter:Se.POINT,magFilter:Se.BILINEAR,mipmapFilter:Ce.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)}),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ka(i,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=o(o({},this.material.defines),Ua(Ha)),Object.keys(this.material.defines).forEach(function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))}),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),u=this.renderHelper.getCache().createInputLayout(o(o({},this.geometry.inputLayoutDescriptor),{},{program:s})),l=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(u,this.geometry.vertexBuffers.filter(function(e){return!!e}).map(function(e){return{buffer:e,byteOffset:0}}),l?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=zi(Vi.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,r,n,i){var a=this;if(0!==e.length){if("fill"===n||"stroke"===n){var o=[];e.forEach(function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];t.isCSSRGB(n)&&(a=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),o.push(Ga(a[0],a[1]),Ga(a[2],a[3]),Ga(s[0],s[1]),Ga(s[2],s[3]))}),this.geometry.updateVertexBuffer(Wa.PACKED_COLOR,Ha.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var s=this.instance.parsedStyle.fill,u=this.textureMappings.findIndex(function(e){return e.name===Xa});if(t.isCSSRGB(s))0>u||(this.textureMappings.splice(u,-1),this.material.textureDirty=!0);else{var l=this.createFillGradientTextureMapping([this.instance]);0>u||this.textureMappings.splice(u,1,l),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var c,f,d=[],h=(null===(c=e[0])||void 0===c?void 0:c.nodeName)===t.Shape.CIRCLE||(null===(f=e[0])||void 0===f?void 0:f.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach(function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,a=t.lineWidth,o=t.increasedLineWidthForHitTesting;d.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===a?1:a,"hidden"!==t.visibility?1:0,h,h,void 0===o?0:o)}),this.geometry.updateVertexBuffer(Wa.PACKED_STYLE,Ha.PACKED_STYLE1,r,new Uint8Array(new Float32Array(d).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var _=[],p=W();e.forEach(function(e){if(a.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;ne(p,e.getWorldTransform(),q(p,ae(r,n,i)))}else H(p,e.getWorldTransform());_.push.apply(_,m(p))}),this.geometry.updateVertexBuffer(Wa.MODEL_MATRIX,Ha.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(_).buffer))}else if("pointerEvents"===n){var E=[];e.forEach(function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];E.push.apply(E,m(r).concat([e.sortable.renderOrder*Ba]))}),this.geometry.updateVertexBuffer(Wa.PICKING_COLOR,Ha.PICKING_COLOR,r,new Uint8Array(new Float32Array(E).buffer))}}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Wa.PICKING_COLOR,Ha.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(m(i),[t*Ba])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map(function(e){return e.slice()}),i=Wa.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride/4*r)}for(var a=0,o=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].arrayStride/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];o[s]=a,a++}for(var d=Wa.PICKING_COLOR+1;e.vertexBuffers.length>d;d++){var h=e.inputLayoutDescriptor.vertexBufferDescriptors[d],_=e.inputLayoutDescriptor.vertexBufferDescriptors[d].attributes[0];if(_)e.setVertexBuffer({bufferIndex:d,byteStride:h.arrayStride,stepMode:h.stepMode,attributes:[{format:_.format,bufferByteOffset:_.offset,location:_.shaderLocation,divisor:_.divisor}],data:e.vertices[d]})}for(var p=new Float32Array(3*r),E=0;r>E;)for(var v=0;3>v;v++){p[3*o[E++]+v]=1}e.setVertexBuffer({bufferIndex:Wa.BARYCENTRIC,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Number(Ha.BARYCENTRIC)}],data:p}),e.setIndexBuffer(o)}},{key:"beforeUploadUBO",value:function(e,t){}},{key:"uploadUBO",value:function(e){var r,n=this,i=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),u=!!s,l=null!==(r=i.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(i.defines.USE_WIREFRAME){var f=t.parseColor(i.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:i.wireframeLineWidth})}if(u&&this.uploadFog(c,s),this.uploadMaterial(c,i),l){var d={};a.forEach(function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])})}c.sort(function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)}),e.setUniforms(1,c);var h=i.blendEquation,_=i.blendEquationAlpha,p=i.blendSrc,E=i.blendDst,v=i.blendSrcAlpha,R=i.blendDstAlpha,m=wa({blendConstant:i.blendConstant,depthCompare:i.depthCompare,depthWrite:i.depthWrite,stencilFront:i.stencilFront,stencilBack:i.stencilBack,stencilWrite:i.stencilWrite,stencilRef:i.stencilRef,cullMode:i.cullMode,frontFace:i.frontFace,polygonOffset:i.polygonOffset}),T=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(o({attachmentsState:[{channelWriteMask:this.material.stencilWrite?De.NONE:De.ALL,rgbBlendState:o(o({},T.rgbBlendState),wa({blendMode:h,blendSrcFactor:p,blendDstFactor:E})),alphaBlendState:o(o({},T.alphaBlendState),wa({blendMode:_,blendSrcFactor:v,blendDstFactor:R}))}]},m)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,a=n.fill,o=n.start,s=n.end,u=n.density;if(t.isCSSRGB(a)){var l=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)];e.push({name:"u_FogInfos",value:[i,o,s,u]}),e.push({name:"u_FogColor",value:l})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map(function(e){return{name:e,value:t.uniforms[e]}});e.push.apply(e,m(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r,n=this,i=e[0],a=i.parsedStyle[this.gradientAttributeName];if(a&&(t.isPattern(a)||Array.isArray(a))){Array.isArray(a)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:a,width:128,height:128,instance:i})):t.isPattern(a)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(a,i,function(){e.forEach(function(e){e.renderable.dirty=!0}),n.material.textureDirty=!0})),r=this.texturePool.getOrCreateCanvas();var o=this.texturePool.getOrCreateTexture(this.context.device,r,He(Xe.U8_RGBA_NORM,1,1,1));if(o){var s=new _a;return s.name=Xa,s.texture=o,s.texture.on("loaded",function(){e.forEach(function(e){e.renderable.dirty=!0}),n.material.textureDirty=!0}),this.context.device.setResourceName(s.texture,"Fill Texture".concat(this.id)),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:ye.CLAMP_TO_EDGE,addressModeV:ye.CLAMP_TO_EDGE,minFilter:Se.POINT,magFilter:Se.BILINEAR,mipmapFilter:Ce.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null}}])}(),Ya=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e}(Ya||{}),Ka=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e[e.EXTRUDE=1+e.PACKED_STYLE3]="EXTRUDE",e[e.SIZE=1+e.EXTRUDE]="SIZE",e}(Ka||{}),ja=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],Za=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(Ka))}},{key:"createGeometry",value:function(e){var t=this;A(r,"createGeometry",this,3)([e]);var n=[],i=[];e.forEach(function(e,r){var a=e,o=a.parsedStyle.radius,s=t.shouldOmitStroke(a.parsedStyle),u=t.getSize(e.parsedStyle,a.nodeName),l=t.getPosition(e.parsedStyle,a.nodeName);n.push.apply(n,m(u).concat([a.parsedStyle.isBillboard?1:0,a.parsedStyle.isSizeAttenuation?1:0,ja.indexOf(a.nodeName),o&&o[0]||0,s?1:0])),i.push.apply(i,m(l))}),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:16,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ka.EXTRUDE},{format:Xe.F32_RG,bufferByteOffset:8,location:Ha.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Ya.PACKED_STYLE,byteStride:28,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ka.SIZE,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:16,location:Ka.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var o=[];e.forEach(function(e){var t=e,r=a.shouldOmitStroke(t.parsedStyle),n=C(a.getSize(e.parsedStyle,e.nodeName),2);o.push.apply(o,[n[0],n[1]].concat([t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,ja.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0]))}),this.geometry.updateVertexBuffer(Ya.PACKED_STYLE,Ka.SIZE,t,new Uint8Array(new Float32Array(o).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];e.forEach(function(e){var t=C(a.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])}),this.geometry.updateVertexBuffer(Wa.POSITION,Ha.POSITION,t,new Uint8Array(new Float32Array(s).buffer))}}},{key:"getPosition",value:function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,a=e.cy,o=e.cz;n=[void 0===i?0:i,void 0===a?0:a,void 0===o?0:o]}else if(r===t.Shape.RECT){var s=e.x,u=e.y,l=e.z;n=[void 0===s?0:s,void 0===u?0:u,void 0===l?0:l]}return n}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,a=t&&t.length&&t.every(function(e){return 0!==e});return!i||i&&(a||1>n)}}])}(za);function qa(e,t,r,n,i,a){for(var o=i[i.length-3],s=i[i.length-2],u=null!=a?a:w(di(o,s,e,t,r,n,3)/10,8,100),l=0,c=0,f=1;u>=f;++f){var d=f/u;i.push((l=o+(e-o)*d)+(e+(r-e)*d-l)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function Qa(e,t,r,n,i,a,o,s){var u=o[o.length-3],l=o[o.length-2];o.length-=3;var c=null!=s?s:w(ci(u,l,e,t,r,n,i,a,3)/10,8,100),f=0,d=0,h=0,_=0,p=0;o.push(u,l,0);for(var E=1,v=0;c>=E;++E)o.push((h=(d=(f=1-(v=E/c))*f)*f)*u+3*d*v*e+3*f*(_=v*v)*r+(p=_*v)*i,h*l+3*d*v*t+3*f*_*n+p*a,0)}var $a=1e20,Ja=function(){return u(function e(t,r){l(this,e);var n=t.fontSize,i=void 0===n?24:n,a=t.buffer,o=void 0===a?3:a,s=t.radius,u=void 0===s?8:s,c=t.cutoff,f=void 0===c?.25:c,d=t.fontFamily,h=void 0===d?"sans-serif":d,_=t.fontWeight,p=void 0===_?"normal":_,E=t.fontStyle,v=void 0===E?"normal":E,R=t.canvas;this.buffer=o,this.cutoff=f,this.radius=u;var m=this.size=i+4*o,T=r.offscreenCanvasCreator.getOrCreateCanvas(R);T.width=m,T.height=m;var g=r.offscreenCanvasCreator.getOrCreateContext(R,{willReadFrequently:!0});this.ctx=g,g.font="".concat(v," ").concat(p," ").concat(i,"px ").concat(h),g.textBaseline="alphabetic",g.textAlign="left",g.fillStyle="black",this.gridOuter=new Float64Array(m*m),this.gridInner=new Float64Array(m*m),this.f=new Float64Array(m),this.z=new Float64Array(m+1),this.v=new Uint16Array(m)},[{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,a=t.actualBoundingBoxRight,o=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),u=Math.min(this.size-this.buffer,o+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),h={data:d,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:o,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return h;var _=this.ctx,p=this.buffer,E=this.gridInner,v=this.gridOuter;_.clearRect(p,p,s,u),_.fillText(e,p,p+o);var R=_.getImageData(p,p,s,u);v.fill($a,0,f),E.fill(0,0,f);for(var m=0;u>m;m++)for(var T=0;s>T;T++){var g=R.data[4*(m*s+T)+3]/255;if(0!==g){var A=(m+p)*l+T+p;if(1===g)v[A]=0,E[A]=$a;else{var y=.5-g;v[A]=y>0?y*y:0,E[A]=0>y?y*y:0}}}eo(v,0,0,l,c,l,this.f,this.v,this.z),eo(E,p,p,s,u,l,this.f,this.v,this.z);for(var S=0;f>S;S++){d[S]=Math.round(255-255*((Math.sqrt(v[S])-Math.sqrt(E[S]))/this.radius+this.cutoff))}return h}}])}();function eo(e,t,r,n,i,a,o,s,u){for(var l=t;t+n>l;l++)to(e,r*a+l,a,i,o,s,u);for(var c=r;r+i>c;c++)to(e,c*a+t,1,n,o,s,u)}function to(e,t,r,n,i,a,o){a[0]=0,o[0]=-$a,o[1]=$a,i[0]=e[t];for(var s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{var f=a[u];l=(i[s]-i[f]+c-f*f)/(s-f)/2}while(o[u]>=l&&--u>-1);a[++u]=s,o[u]=l,o[u+1]=$a}for(var d=0,h=0;n>d;d++){for(;d>o[h+1];)h++;var _=a[h],p=d-_;e[t+d*r]=i[_]+p*p}}var ro=function(e){return e[e.PACKED=Wa.POSITION+1]="PACKED",e[e.VERTEX_NUM=1+e.PACKED]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(ro||{}),no=function(e){return e[e.PREV=Ha.POSITION]="PREV",e[e.POINT1=1+e.PREV]="POINT1",e[e.POINT2=1+e.POINT1]="POINT2",e[e.NEXT=1+e.POINT2]="NEXT",e[e.VERTEX_JOINT=1+e.NEXT]="VERTEX_JOINT",e[e.VERTEX_NUM=1+e.VERTEX_JOINT]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(no||{});function io(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function ao(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!U(r[0][2])}var oo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).segmentNum=-1,u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.segmentNum=u.calcSegmentNum(i),u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){return co(e,!1,12,this.calcSubpathIndex(e)).instancedCount}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter(function(e){return e===po}).length;return this.index-r}return 0}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.segmentNum===i}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(no))}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=[],s=0,u=0;e.forEach(function(e){var r=co(e,!1,12,t.calcSubpathIndex(e)),l=r.pointsBuffer,c=r.travelBuffer,f=r.instancedCount,d=e.parsedStyle,h=d.lineDash;o.push(h&&h[0]||0,h&&h[1]||0,d.lineDashOffset||0,io(d.isBillboard,d.isSizeAttenuation,ao(e))),s+=f;for(var _=0;l.length-12>_;_+=4)i.push(l[_],l[_+1],l[_+2],l[_+3],l[_+4],l[_+5],l[_+6],l[_+7],l[_+8],l[_+9],l[_+10],l[_+11],l[_+12],l[_+13],l[_+14],l[_+15]);a.push.apply(a,m(c)),n.push(0+u,2+u,1+u,0+u,3+u,2+u,4+u,6+u,5+u,4+u,7+u,6+u,4+u,7+u,8+u),u+=9}),i.length&&(this.geometry.setVertexBuffer({bufferIndex:ro.PACKED,byteStride:64,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:no.PREV,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:16,location:no.POINT1,divisor:1},{format:Xe.F32_R,bufferByteOffset:28,location:no.VERTEX_JOINT,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:32,location:no.POINT2,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:48,location:no.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ro.VERTEX_NUM,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,byteStride:4,location:no.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:ro.TRAVEL,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,byteStride:4,location:no.TRAVEL,divisor:1}],data:new Float32Array(a)}),this.divisor=s/e.length,this.geometry.setVertexBuffer({bufferIndex:ro.DASH,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:no.DASH,divisor:this.divisor}],data:new Float32Array(o)}),A(r,"createGeometry",this,3)([e]),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var o=[],s=[],u=0;e.forEach(function(e){var t=co(e,!1,12,a.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;u=t.instancedCount;for(var i=0;r.length-12>i;i+=4)o.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,m(n))}),this.geometry.updateVertexBuffer(ro.PACKED,no.PREV,t*u,new Uint8Array(new Float32Array(o).buffer)),this.geometry.updateVertexBuffer(ro.TRAVEL,no.TRAVEL,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var l=[];e.forEach(function(e){var t=e.parsedStyle,r=t.lineDash;l.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,io(t.isBillboard,t.isSizeAttenuation,ao(e)))}),this.geometry.updateVertexBuffer(ro.DASH,no.DASH,t,new Uint8Array(new Float32Array(l).buffer))}}}],[{key:"calcSubpathNum",value:function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter(function(e){return"M"===e[0]}).length:1}}])}(za),so=function(e){return e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2",e}({}),uo=3,lo=4;function co(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.parsedStyle,o=a.lineCap,s=a.lineJoin,u=e.sortable.renderOrder*Ba,l=0,c=0,f=e.parsedStyle,d=f.markerStart,h=f.markerEnd,_=f.markerStartOffset,p=f.markerEndOffset,T=[],g=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var A=e.parsedStyle.points.points,P=A.length,N=0,M=0,O=0,I=0,x=0;d&&t.isDisplayObject(d)&&_&&(N=Math.cos(x=Math.atan2(A[1][1]-A[0][1],A[1][0]-A[0][0]))*(_||0),M=Math.sin(x)*(_||0)),h&&t.isDisplayObject(h)&&p&&(O=Math.cos(x=Math.atan2(A[P-2][1]-A[P-1][1],A[P-2][0]-A[P-1][0]))*(p||0),I=Math.sin(x)*(p||0));var B=e.nodeName===t.Shape.POLYLINE;if(T[0]=A.reduce(function(e,t,r){var n=0,i=0;return 0===r?(n=N,i=M):r===P-1&&(n=O,i=I),e.push(t[0]+n,t[1]+i,B?t[2]||0:u),e},[]),e.nodeName===t.Shape.POLYGON){var D;if(r)return g=oi(T[0],[],3),{pointsBuffer:T[0],travelBuffer:[],triangles:g,instancedCount:Math.round(T[0].length/uo)};T[0].push(T[0][0],T[0][1],T[0][2]||u),(D=T[0]).push.apply(D,m(fo(T[0][0],T[0][1],T[0][2]||u,T[0][3],T[0][4],T[0][5]||u)))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var b;if(e.nodeName!==t.Shape.PATH){if(b=t.parsePath(t.convertToPath(e,Y(W()))),e.nodeName===t.Shape.RECT){var L=e.parsedStyle;0>L.width&&(l+=b.rect.width),0>L.height&&(c+=b.rect.height)}}else b=e.parsedStyle.d;var F=b.absolutePath,U=b.segments,k=0,w=0,G=0,V=0,X=0;if(d&&d.parentNode&&t.isDisplayObject(d)&&_){var H=C(d.parentNode.getStartTangent(),2),z=H[0],K=H[1];k=Math.cos(X=Math.atan2(z[1]-K[1],z[0]-K[0]))*(_||0),w=Math.sin(X)*(_||0)}if(h&&h.parentNode&&t.isDisplayObject(h)&&p){var j=C(h.parentNode.getEndTangent(),2),Z=j[0],q=j[1];G=Math.cos(X=Math.atan2(Z[1]-q[1],Z[0]-q[0]))*(p||0),V=Math.sin(X)*(p||0)}var Q=-1,$=-1;if(F.forEach(function(r,i){var a,o=y(a=r)||v(a)||R(a)||S(),s=o[0],f=E(o).slice(1),d=F[i+1],h=0===i&&(0!==k||0!==w),_=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==G&&0!==V;if("M"===s)$++,T[$]=[],Q=T[$].length,h?T[$].push(f[0]-l+k,f[1]-c+w,u,f[0]-l,f[1]-c,u):T[$].push(f[0]-l,f[1]-c,u);else if("L"===s)_?T[$].push(f[0]-l+G,f[1]-c+V,u):T[$].push(f[0]-l,f[1]-c,u);else if("Q"===s)qa(f[0]-l,f[1]-c,f[2]-l,f[3]-c,T[$],n),_&&T[$].push(f[2]-l+G,f[3]-c+V,u);else if("A"===s){for(var p=C(U[i].prePoint,2),g=_e(p[0],p[1],f[0],f[1],f[2],f[3],f[4],f[5],f[6],void 0),A=0;g.length>A;A+=6)Qa(g[A]-l,g[A+1]-c,g[A+2]-l,g[A+3]-c,g[A+4]-l,g[A+5]-c,T[$],n);_&&T[$].push(f[5]-l+G,f[6]-c+V,u)}else if("C"===s)Qa(f[0]-l,f[1]-c,f[2]-l,f[3]-c,f[4]-l,f[5]-c,T[$],n),_&&T[$].push(f[4]-l+G,f[5]-c+V,u);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var P,N=1e-4;(Math.abs(T[$][T[$].length-2]-T[$][Q])>N||Math.abs(T[$][T[$].length-1]-T[$][Q+1])>N)&&T[$].push(T[$][Q],T[$][Q+1],u),(P=T[$]).push.apply(P,m(fo(T[$][Q],T[$][Q+1],T[$][Q+2],T[$][Q+3],T[$][Q+4],T[$][Q+5])))}}),r){var J=T[i];return{pointsBuffer:J,travelBuffer:[],triangles:g=oi(J,[],3),instancedCount:Math.round(J.length/uo)}}}var ee=function(e){var t;switch(e){case"bevel":t=so.JOINT_BEVEL;break;case"round":t=so.JOINT_ROUND;break;default:t=so.JOINT_MITER}return t}(s),te=function(e){var t;switch(e){case"square":t=so.CAP_SQUARE;break;case"round":t=so.CAP_ROUND;break;default:t=so.CAP_BUTT}return t}(o),re=te;te===so.CAP_ROUND&&(re=so.JOINT_CAP_ROUND),te===so.CAP_BUTT&&(re=so.JOINT_CAP_BUTT),te===so.CAP_SQUARE&&(re=so.JOINT_CAP_SQUARE);for(var ne=T[i],ie=(Math.round(0/uo)+2)*lo,ae=0,oe=[],se=[],ue=0;ne.length>ue;ue+=uo)ue>1&&(ae+=Math.sqrt(Math.pow(ne[ue]-ne[ue-uo],2)+Math.pow(ne[ue+1]-ne[ue+1-uo],2)+Math.pow(ne[ue+2]-ne[ue+2-uo],2))),se.push(ae),oe[ie++]=ne[ue],oe[ie++]=ne[ue+1],oe[ie++]=ne[ue+2]||0,oe[ie]=ee,0===ue&&te!==so.CAP_ROUND&&(oe[ie]+=te),ne.length>ue+2*uo?ne.length>ue+uo||(oe[ie]=0):oe[ie]+=re-ee,ie++;return oe[ie++]=ne[ne.length-6],oe[ie++]=ne[ne.length-5],oe[ie++]=ne[ne.length-4]||u,oe[ie++]=0,oe[0]=ne[0],oe[1]=ne[1],oe[2]=ne[2]||u,oe[3]=0,oe[4]=ne[3],oe[5]=ne[4],oe[6]=ne[5]||u,oe[7]=te===so.CAP_ROUND?te:0,{pointsBuffer:oe,travelBuffer:se,triangles:g,instancedCount:Math.round(ne.length/uo)}}function fo(e,t,r){var n=[(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e)-e,(arguments.length>4&&void 0!==arguments[4]?arguments[4]:t)-t,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:r)-r],i=.01;return[e+n[0]*i,t+n[1]*i,r+n[2]*i]}var ho=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e}(ho||{}),_o=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e}(_o||{}),po=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).trianglesHash=[[],[]],u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.trianglesHash=u.calcSegmentNum(i),u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){var t=co(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]}},{key:"calcSubpathIndex",value:function(e){return e.nodeName===t.Shape.PATH?this.index:0}},{key:"compareTrianglesHash",value:function(e){var t=C(this.trianglesHash,2),r=t[0],n=t[1],i=C(e,2),a=i[0],o=i[1];return r.length===a.length&&n.length===o.length&&(!r.some(function(e,t){return e!==a[t]})&&!n.some(function(e,t){return e!==o[t]}))}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.compareTrianglesHash(i)}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=0;if(e.forEach(function(e,r){var s=co(e,!0,12,t.calcSubpathIndex(e)),u=s.triangles,l=s.pointsBuffer;if(u.length){var c=e.getGeometryBounds().halfExtents,f=[];l.forEach(function(e,t){t%3!=2&&f.push(e/c[t%3]/2)}),o+=i.length/3,i.push.apply(i,m(l)),a.push.apply(a,f),n.push.apply(n,m(u.map(function(e){return e+o})))}}),i.length){A(r,"createGeometry",this,3)([e]);var s=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ho.PACKED_STYLE,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:_o.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ha.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length/e.length,this.geometry.setIndexBuffer(new Uint32Array(n))}}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=o(o(o({},this.material.defines),Ua(_o)),{},{INSTANCED:!0})}},{key:"updateAttribute",value:function(e,t,n,i){if(0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var a=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.updateVertexBuffer(ho.PACKED_STYLE,_o.PACKED_STYLE3,t,new Uint8Array(new Float32Array(a).buffer))}}}])}(za),Eo=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1],vo=function(e){return e[e.POINT=Wa.POSITION+1]="POINT",e[e.CAP=1+e.POINT]="CAP",e[e.DASH=1+e.CAP]="DASH",e}(vo||{}),Ro=function(e){return e[e.POSITION=Ha.POSITION]="POSITION",e[e.UV=Ha.UV]="UV",e[e.POINTA=Ha.NORMAL]="POINTA",e[e.POINTB=Ha.BARYCENTRIC]="POINTB",e[e.CAP=Ha.MAX]="CAP",e[e.DASH=Ha.MAX+1]="DASH",e}(Ro||{}),mo={butt:1,round:2,square:3},To=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).renderHelper=e,u.texturePool=t,u.lightPool=n,u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(Ro))}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter(function(e){return e===po}).length;return this.index-r}return 0}},{key:"createGeometry",value:function(e){var n=this;A(r,"createGeometry",this,3)([e]);var i=[],a=[],o=[],s=[],u=0;e.forEach(function(e){var r,l;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,l=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,h=d.d.absolutePath,_=d.lineCap,p=d.lineDash,E=d.lineDashOffset,v=d.markerStart,R=d.markerEnd,m=d.markerStartOffset,T=d.markerEndOffset,g=d.isBillboard,A=d.isSizeAttenuation,y=0,S=0,C=n.calcSubpathIndex(e),P=0;h.length>P;P++){if("M"===h[P][0]){if(y===C){S=P;break}y++}}r={x1:h[S][1],y1:h[S][2],x2:h[S+1][1],y2:h[S+1][2],z1:0,z2:0,lineCap:_,lineDash:p,lineDashOffset:E,isBillboard:g,isSizeAttenuation:A,markerStart:v,markerEnd:R,markerStartOffset:m,markerEndOffset:T},l=e.getTotalLength()}var N=r.x1,M=r.y1,O=r.x2,I=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,k=F.startOffsetY,w=F.endOffsetX,G=F.endOffsetY,V=n.calcDash(r,l),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;a.push(mo[D]),o.push(X,W,H,b||L?1:0),i.push(N+U,M+k,x,O+w,I+G,B),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4}),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:20,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ro.POSITION,divisor:0},{format:Xe.F32_RG,bufferByteOffset:12,location:Ro.UV,divisor:0}],data:new Float32Array(Eo)}),this.geometry.setVertexBuffer({bufferIndex:vo.POINT,byteStride:24,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ro.POINTA,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:12,location:Ro.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:vo.CAP,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,location:Ro.CAP,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:vo.DASH,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ro.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),this.updateBatchedAttribute(e,n,i,a),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];e.forEach(function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var a=e.parsedStyle,u=a.d.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,lineCap:a.lineCap,isBillboard:a.isBillboard,isSizeAttenuation:a.isSizeAttenuation,markerStart:a.markerStart,markerEnd:a.markerEnd,markerStartOffset:a.markerStartOffset,markerEndOffset:a.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,d=r.y2,h=r.z1,_=r.z2,p=o.calcOffset(r);s.push(l+p.startOffsetX,c+p.startOffsetY,h,f+p.endOffsetX,d+p.endOffsetY,_)}),this.geometry.updateVertexBuffer(vo.POINT,Ro.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var u=[];e.forEach(function(e){var t=e.getTotalLength(),r=o.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)}),this.geometry.updateVertexBuffer(vo.DASH,Ro.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];e.forEach(function(e){l.push(mo[e.parsedStyle.lineCap])}),this.geometry.updateVertexBuffer(vo.CAP,Ro.CAP,n,new Uint8Array(new Float32Array(l).buffer))}}},{key:"calcOffset",value:function(e){var r=e.x1,n=e.y1,i=e.x2,a=e.y2,o=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,d=0,h=0,_=0;return o&&t.isDisplayObject(o)&&u&&(c=Math.cos(_=Math.atan2(a-n,i-r))*(u||0),f=Math.sin(_)*(u||0)),s&&t.isDisplayObject(s)&&l&&(d=Math.cos(_=Math.atan2(n-a,r-i))*(l||0),h=Math.sin(_)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:h}}},{key:"calcDash",value:function(e,t){var r=e.lineDash,n=0,i=1,a=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var o=r.reduce(function(e,t){return e+t},0);0===o?(i=1,a=0):(i=o/t,a=r[1]/o)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:a}}}],[{key:"isLine",value:function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,a=0,o=0;n.length>o;o++){if("M"===n[o][0]){if(i===r){a=o;break}i++}}if("M"===n[a][0]&&"L"===n[a+1][0]&&(void 0===n[a+2]||"M"===n[a+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var s=e.parsedStyle.points.points,u=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]),l=1;s.length-1>l;l++)if((s[l+1][0]-s[l+1][1])/(s[l][0]-s[l][1])!==u)return!1;return!0}return!1}}])}(za),go=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e[e.SIZE=Wa.MAX]="SIZE",e}(go||{}),Ao=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e[e.SIZE=1+e.PACKED_STYLE3]="SIZE",e}(Ao||{}),yo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"shouldMerge",value:function(e,r){var n=A(t,"shouldMerge",this,3)([e,r]);return!!n&&this.instance.parsedStyle.src===e.parsedStyle.src}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.src;this.material.defines=o(o({},this.material.defines),Ua(Ao)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){A(t,"createGeometry",this,3)([e]);var r=[],n=[],i=[];e.forEach(function(e,t){var a=e.parsedStyle,o=a.x,s=a.y,u=a.z,l=a.width,c=a.height,f=a.isBillboard,d=a.billboardRotation,h=a.isSizeAttenuation;r.push(void 0===o?0:o,void 0===s?0:s,void 0===u?0:u),n.push(l,c),i.push(f?1:0,null!=d?d:0,h?1:0,0)}),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:go.SIZE,byteStride:8,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ao.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:go.PACKED_STYLE,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ao.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ha.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})}},{key:"updateAttribute",value:function(e,r,n,i){if(0!==e.length)if(A(t,"updateAttribute",this,3)([e,r,n,i]),this.updateBatchedAttribute(e,r,n,i),"x"===n||"y"===n||"z"===n){var a=[];e.forEach(function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;a.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)}),this.geometry.updateVertexBuffer(Wa.POSITION,Ha.POSITION,r,new Uint8Array(new Float32Array(a).buffer))}else if("width"===n||"height"===n){var o=[];e.forEach(function(e){var t=e.parsedStyle;o.push(t.width,t.height)}),this.geometry.updateVertexBuffer(go.SIZE,Ao.SIZE,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.updateVertexBuffer(go.PACKED_STYLE,Ao.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var u=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:u})}}}])}(za);function So(e,t,r,n){var i=t.width,a=t.height;if(n){if(n.length!==i*a*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*a*r);return e.width=i,e.height=a,e.data=n,e}function Co(e,t,r,n,i,a){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*a,c=((n.y+u)*t.width+n.x)*a,f=0;i.width*a>f;f++)s[c+f]=o[l+f];return t}var Po=function(){function e(t,r){l(this,e),So(this,t,1,r)}return u(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var a=So({},{width:n,height:i},r);Co(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=a.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){Co(e,t,r,n,i,1)}}])}();var No=u(function e(t){l(this,e);var r={},n=[];for(var i in t){var a=t[i],o=r[i]={};for(var s in a){var u=a[+s];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c={x:0,y:0,w:u.bitmap.width+2,h:u.bitmap.height+2};n.push(c),o[s]={rect:c,metrics:u.metrics}}}}var f=function(e){var t,r=0,n=0,i=Bn(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;r+=a.w*a.h,n=Math.max(n,a.w)}}catch(e){i.e(e)}finally{i.f()}e.sort(function(e,t){return t.h-e.h});var o,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=Bn(e);try{for(c.s();!(o=c.n()).done;)for(var f=o.value,d=s.length-1;d>=0;d--){var h=s[d];if(h.w>=f.w&&h.h>=f.h){if(f.x=h.x,f.y=h.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===h.w&&f.h===h.h){var _=s.pop();s.length>d&&(s[d]=_)}else f.h===h.h?(h.x+=f.w,h.w-=f.w):f.w===h.w?(h.y+=f.h,h.h-=f.h):(s.push({x:h.x+f.w,y:h.y,w:h.w-f.w,h:f.h}),h.y+=f.h,h.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),d=new Po({width:f.w||1,height:f.h||1});for(var h in t){var _=t[h];for(var p in _){var E=_[+p];if(E&&0!==E.bitmap.width&&0!==E.bitmap.height){var v=r[h][p].rect;Po.copy(E.bitmap,d,{x:0,y:0},{x:v.x+1,y:v.y+1},E.bitmap)}}}this.image=d,this.positions=r});var Mo=function(){return u(function e(t){l(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={},this.runtime=t},[{key:"destroy",value:function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}},{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,r,n,i,a,o){var s=this,u=[],l=a,c=o,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach(function(e){var n=u.length;Array.from(e).forEach(function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),a=r&&r[n];a&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=a.metrics.advance+i)});for(var a=l-i,o=n;u.length>o;o++)u[o].x-=f*a;l=0,c+=r}),u}},{key:"generateAtlas",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=[];this.glyphMap[r]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[r]||{});if(Array.from(new Set(s.split(""))).forEach(function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)}),l.length){var f=l.map(function(o){return t.generateSDF(e,r,n,i,a,o)}).reduce(function(e,t){return e[t.id]=t,e},{});this.glyphMap[r]=o(o({},this.glyphMap[r]),f),this.glyphAtlas=new No(this.glyphMap);var d=this.glyphAtlas.image,h=d.width,_=d.height,p=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=u.createTexture(o(o({},He(Xe.ALPHA,h,_,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([p])}}},{key:"generateSDF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=a.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new Ja({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][a]||(this.textMetricsCache[t][a]=s.ctx.measureText(a).width);var u=s.draw(a),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,d=u.glyphTop,h=u.glyphAdvance;return{id:o,bitmap:new Po({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:d-24+3,advance:h}}}}])}();var Oo=function(e){return e[e.INSTANCED=Wa.POSITION+1]="INSTANCED",e[e.TEX=1+e.INSTANCED]="TEX",e}(Oo||{}),Io=function(e){return e[e.TEX=Ha.MAX]="TEX",e[e.OFFSET=1+e.TEX]="OFFSET",e}(Io||{}),xo=function(e){return e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke",e}({}),Bo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).packedBufferObjectMap=new WeakMap,u.tmpMat4=W(),u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.fontHash=u.calcFontHash(i),u.glyphManager=new Mo(u.context),u}return p(r,e),u(r,[{key:"calcFontHash",value:function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce(function(t,r){return t+e.parsedStyle[r]},"")}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n&&(this.index===t&&this.fontHash===this.calcFontHash(e))}},{key:"createGeometry",value:function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,a=n.letterSpacing,o=void 0===a?0:a,s=r.parsedStyle.textBaseline,u=void 0===s?"alphabetic":s,l=24/(void 0===i?16:i),c=[],f=[],d=[],h=[],_=0;e.forEach(function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,a=r.dy,s=n.font,p=n.lines,E=n.height,v=n.lineHeight,R=void 0===i?0:i,T=void 0===a?0:a;"alphabetic"===u&&(u="bottom");var g=0;"middle"===u?g+=-E/2:"bottom"===u?g+=-E:"top"===u||"hanging"===u?g+=0:"ideographic"===u&&(g+=-E);var A=t.glyphManager.getAtlas(),y=t.buildTextBuffers({object:e,lines:p,fontStack:s,lineHeight:l*v,offsetX:l*R,offsetY:l*(g+T),letterSpacing:l*o,glyphAtlas:A,indicesOffset:_}),S=y.indexBuffer,C=y.charUVOffsetBuffer,P=y.charPositionsBuffer;_=y.indicesOffset;var N=h.length;h.push.apply(h,m(y.charPackedBuffer)),t.packedBufferObjectMap.set(e,[N,h.length]),d.push.apply(d,m(C)),f.push.apply(f,m(P)),c.push.apply(c,m(S))}),this.geometry.vertexCount=c.length,this.geometry.setIndexBuffer(new Uint32Array(c)),this.geometry.setVertexBuffer({bufferIndex:Oo.INSTANCED,byteStride:128,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.MODEL_MATRIX0},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.MODEL_MATRIX1},{format:Xe.F32_RGBA,bufferByteOffset:32,location:Ha.MODEL_MATRIX2},{format:Xe.F32_RGBA,bufferByteOffset:48,location:Ha.MODEL_MATRIX3},{format:Xe.F32_RGBA,bufferByteOffset:64,location:Ha.PACKED_COLOR},{format:Xe.F32_RGBA,bufferByteOffset:80,location:Ha.PACKED_STYLE1},{format:Xe.F32_RGBA,bufferByteOffset:96,location:Ha.PACKED_STYLE2},{format:Xe.F32_RGBA,bufferByteOffset:112,location:Ha.PICKING_COLOR}],data:new Float32Array(h)}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:Oo.TEX,byteStride:16,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Io.TEX},{format:Xe.F32_RG,bufferByteOffset:8,location:Io.OFFSET}],data:new Float32Array(d)})}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=Te.BACK,this.material.defines=o(o({},this.material.defines),Ua(Io));var t=this.instance.parsedStyle,r=t.fontSize,n=void 0===r?16:r,a=t.fontFamily,s=void 0===a?"sans-serif":a,u=t.fontWeight,l=void 0===u?"normal":u,c=t.fontStyle,f=void 0===c?"normal":c,d=t.metrics.font,h=e.map(function(e){return e.parsedStyle.text}).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+l,f,h,this.context.device);var _=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(_,"TextSDF Texture");var E=p.image,v=E.width,R=E.height;this.material.setUniforms(i(i(i(i(i(i({},xo.SDF_MAP,_),xo.SDF_MAP_SIZE,[v,R]),xo.FONT_SIZE,n),xo.GAMMA_SCALE,1),xo.STROKE_BLUR,.2),xo.HAS_STROKE,this.index))}},{key:"changeRenderOrder",value:function(e,t){for(var r=this.geometry.vertices[Oo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oo.INSTANCED].arrayStride/4,i=C(this.packedBufferObjectMap.get(e),2),a=i[0],o=i[1],s=r.slice(a,o),u=0;o-a>u;u+=n)s[u+n-1]=t*Ba;this.geometry.updateVertexBuffer(Oo.INSTANCED,Ha.MODEL_MATRIX0,a/n,new Uint8Array(s.buffer))}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[Oo.INSTANCED],u=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oo.INSTANCED].arrayStride/4;e.forEach(function(e){var r,n=e.parsedStyle,i=n.fill,a=n.stroke,l=n.opacity,c=void 0===l?1:l,f=n.fillOpacity,d=void 0===f?1:f,h=n.strokeOpacity,_=void 0===h?1:h,p=n.lineWidth,E=void 0===p?1:p,v=n.visibility,R=n.isBillboard,m=n.billboardRotation,T=n.isSizeAttenuation,g=[0,0,0,0];t.isCSSRGB(i)&&(g=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var A=[0,0,0,0];t.isCSSRGB(a)&&(A=[Number(a.r),Number(a.g),Number(a.b),255*Number(a.alpha)]);for(var y=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=H(o.tmpMat4,e.getWorldTransform()),P=C(o.packedBufferObjectMap.get(e),2),N=P[0],M=P[1],O=s.slice(N,M),I=0;M-N>I;I+=u)O[I+0]=S[0],O[I+1]=S[1],O[I+2]=S[2],O[I+3]=S[3],O[I+4]=S[4],O[I+5]=S[5],O[I+6]=S[6],O[I+7]=S[7],O[I+8]=S[8],O[I+9]=S[9],O[I+10]=S[10],O[I+11]=S[11],O[I+12]=S[12],O[I+13]=S[13],O[I+14]=S[14],O[I+15]=S[15],O[I+16]=Ga(g[0],g[1]),O[I+17]=Ga(g[2],g[3]),O[I+18]=Ga(A[0],A[1]),O[I+19]=Ga(A[2],A[3]),O[I+20]=c,O[I+21]=d,O[I+22]=_,O[I+23]=E,O[I+24]="hidden"!==v?1:0,O[I+25]=R?1:0,O[I+26]=T?1:0,O[I+27]=null!=m?m:0,O[I+28]=y[0],O[I+29]=y[1],O[I+30]=y[2];o.geometry.updateVertexBuffer(Oo.INSTANCED,Ha.MODEL_MATRIX0,N/u,new Uint8Array(O.buffer))})}}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,a=e.fontStack,o=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,d=n.parsedStyle,h=d.textAlign,_=void 0===h?"start":h,p=d.fill,E=d.stroke,v=d.opacity,R=void 0===v?1:v,T=d.fillOpacity,g=void 0===T?1:T,A=d.strokeOpacity,y=void 0===A?1:A,S=d.lineWidth,C=void 0===S?1:S,P=d.visibility,N=d.isBillboard,M=d.billboardRotation,O=d.isSizeAttenuation,I=d.x,x=void 0===I?0:I,B=d.y,D=void 0===B?0:B,b=d.z,L=void 0===b?0:b,F=[0,0,0,0];t.isCSSRGB(p)&&(F=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var U=[0,0,0,0];t.isCSSRGB(E)&&(U=[Number(E.r),Number(E.g),Number(E.b),255*Number(E.alpha)]);var k=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],w=H(this.tmpMat4,n.getWorldTransform()),G=[],V=[],X=[],W=[],z=f,Y=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],a=t[i.fontStack],o=a&&a[i.glyph];if(o){var s=o.rect;if(s){var u=o.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(o.metrics.left-4)*i.scale-u+l[0],f=(-o.metrics.top-4)*i.scale+l[1],d=c+s.w*i.scale,h=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:h},br:{x:d,y:h},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,a,o,_,s,u,l),c.positions);return Y.forEach(function(e){var t=[];t.push.apply(t,m(w));var r=[].concat(t,[Ga(F[0],F[1]),Ga(F[2],F[3]),Ga(U[0],U[1]),Ga(U[2],U[3]),R,g,y,C,"hidden"!==P?1:0,N?1:0,O?1:0,null!=M?M:0],m(k),[n.sortable.renderOrder*Ba]);G.push.apply(G,m(r).concat(m(r),m(r),m(r))),V.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),V.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),V.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),V.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),X.push(x,D,L,x,D,L,x,D,L,x,D,L),W.push(0+z,2+z,1+z),W.push(2+z,0+z,3+z),z+=4}),{indexBuffer:W,charUVOffsetBuffer:V,charPositionsBuffer:X,charPackedBuffer:G,indicesOffset:z}}},{key:"destroy",value:function(){A(r,"destroy",this,3)([]),this.glyphManager.destroy()}}])}(za),Do=function(e){function r(){var e;l(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=h(this,r,[].concat(n))).mergeXYZIntoModelMatrix=!1,e}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,n){var i=A(r,"shouldMerge",this,3)([e,n]);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,n,i){0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i))}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,A(r,"createGeometry",this,3)([e]),this.geometry.build(e),this.observeGeometryChanged()}}])}(za),bo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(Za),this.needDrawStrokeSeparately(e)&&t.push(oo),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every(function(e){return 0!==e});return!s||u&&a>0&&(1>o||l)}}])}(Da),Lo=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"getDrawcallCtors",value:function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=r.opacity,o=r.strokeOpacity,s=r.lineWidth,u=i&&!i.isNone,l=oo.calcSubpathNum(e),c=[];if(!(e.nodeName===t.Shape.POLYLINE||null!=n&&n.isNone))for(var f=0;l>f;f++)c.push(po);for(var d=0;l>d;d++)if(0!==o&&0!==a&&0!==s&&u){var h=To.isLine(e,d);c.push(h?To:oo)}return c}}])}(Da),Fo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[yo]}}])}(Da),Uo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Bo),t.push(Bo),t}},{key:"beforeUploadUBO",value:function(e,t){t.material.setUniforms(i({},xo.HAS_STROKE,1===t.instance.renderable3D.drawcalls.length?0:1-t.index))}}])}(Da),ko=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[To]}}])}(Da),wo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[Do]}}])}(Da),Go=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,a=i&&i.length&&i.some(function(e){return e!==i[0]});return null!=n&&n.isNone||a||t.push(Za),a&&t.push(po),(a||this.needDrawStrokeSeparately(e))&&t.push(oo),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every(function(e){return 0!==e});return!s||u&&a>0&&(1>o||l)}}])}(Da),Vo=1,Xo=function(){return u(function e(t,r,n,i){l(this,e),this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=t,this.rendererFactory=r,this.texturePool=n,this.lightPool=i},[{key:"destroy",value:function(){this.drawcalls.forEach(function(e){e.destroy()}),this.drawcalls=[],this.pendingUpdatePatches={}}},{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.drawcalls.forEach(function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var a=t.renderHelper.renderInstManager.newRenderInst();a.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(a,i),t.renderHelper.renderInstManager.submitRenderInst(a,e),r||n.objects.forEach(function(e){e.renderable.dirty=!1})})}},{key:"attach",value:function(e){this.context=e}},{key:"add",value:function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach(function(i,a,o){var s=t.drawcalls.find(function(t){return i===t.constructor&&t.index===a&&t.maxInstances>t.objects.length&&t.shouldMerge(e,a)});s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,o,a,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[a]=s,s.geometryDirty=!0)})}}},{key:"remove",value:function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach(function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach(function(e){e.destroy()})}}),r.drawcalls=[])}},{key:"updateAttribute",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.renderable3D,o=this.rendererFactory[e.nodeName];if(o){var s=o.getDrawcallCtors(e);if(s.forEach(function(s,u,l){var c=a.drawcalls.find(function(e){return e&&e.index===u&&e.constructor===s});if(c||((c=a.drawcalls[u])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&n.drawcalls.splice(n.drawcalls.indexOf(c),1),a.drawcalls[a.drawcalls.indexOf(c)]=void 0),(c=n.drawcalls.find(function(t){return s===t.constructor&&t.index===u&&t.maxInstances>t.objects.length&&t.shouldMerge(e,u)}))?c.geometryDirty=!0:((c=new s(n.renderHelper,n.texturePool,n.lightPool,e,l,u,n.context)).renderer=o,c.init(),n.drawcalls.push(c)),c.objects.push(e),a.drawcalls[u]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,u)){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;n.pendingUpdatePatches[d]||(n.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[d].objectIndices.indexOf(f)&&n.pendingUpdatePatches[d].objectIndices.push(f)}}else n.remove(e),n.add(e);else n.remove(e),n.add(e)}),a.drawcalls.length>s.length)for(var u=a.drawcalls.length-1;u>=s.length;u--){var l=a.drawcalls[u];l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(l),1),a.drawcalls.pop()}}}},{key:"changeRenderOrder",value:function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach(function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)})}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=Vo++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach(function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,a=r.name,o=r.value;i.sort(function(e,t){return e-t});var s=[];i.forEach(function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])}),s.forEach(function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],a,o)})}),this.pendingUpdatePatches={}}}])}(),Wo=function(){return u(function e(t,r){l(this,e),this.textureCache={},this.context=t,this.runtime=r},[{key:"getOrCreateTexture",value:function(e,t,r,n){var i,a=this,s="string"==typeof t?t:t.src||"";if(s&&this.textureCache[s])(i=this.textureCache[s]).emit(Ie.LOADED);else if(i=e.createTexture(o({format:Xe.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:xe.TEXTURE_2D,usage:Be.SAMPLED,pixelStore:{unpackFlipY:!1}},r)),s&&(this.textureCache[s]=i),k(t)){var u=this.context.config.createImage();u&&(u.onload=function(){var e=function(e){a.textureCache[s].setImageData([e]),a.textureCache[s].emit(Ie.LOADED),a.context.renderingService.dirty(),n&&n(a.textureCache[s],e)};a.runtime.globalThis.createImageBitmap?a.runtime.globalThis.createImageBitmap(u).then(function(t){return e(t)}).catch(function(){e(u)}):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=t)}else i.setImageData([t]),i.emit(Ie.LOADED),this.context.renderingService.dirty();return i}},{key:"getOrCreateCanvas",value:function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,i=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),u=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=i;var l=this.context.imagePool;t.forEach(function(e){var t=l.getOrCreateGradient(o(o({type:e.type},e.value),{},{width:n,height:i,min:[0,0]}),u);u.fillStyle=t,u.fillRect(0,0,n,i)})}},{key:"getOrCreatePattern",value:function(e,r,n){var i,a=e.image,o=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),h=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);if(d.width=l,d.height=c,k(a)){var _=this.context.imagePool.getImageSync(a,r,n);i=null==_?void 0:_.img}else i=a;var p=i&&h.createPattern(i,o);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));p.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}h.fillStyle=p,h.fillRect(0,0,l,c)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}])}(),Ho=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l(this,r),(e=h(this,r)).name="device-renderer",e.parameters={toneMapping:bi.NONE,toneMappingExposure:1},e.options=t,e}return p(r,e),u(r,[{key:"init",value:function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new vi;var n=new aa(this.parameters),a=new _i,o=new Wo(this.context,e),s=new Ri,u=new bo,l=new Lo,c=(i(i(i(i(i(i(i(i(i(i(r={},t.Shape.CIRCLE,u),t.Shape.ELLIPSE,u),t.Shape.POLYLINE,l),t.Shape.PATH,l),t.Shape.POLYGON,l),t.Shape.RECT,new Go),t.Shape.IMAGE,new Fo),t.Shape.LINE,new ko),t.Shape.TEXT,new Uo),t.Shape.MESH,new wo),i(i(r,t.Shape.GROUP,void 0),t.Shape.HTML,void 0)),f=new Xo(n,c,o,a),d=new Ia(n,a,o,f,this.options);this.addRenderingPlugin(d),this.addRenderingPlugin(new xa(n,d,s,f))}},{key:"destroy",value:function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]}},{key:"getRenderGraphPlugin",value:function(){return this.plugins[0]}},{key:"getDevice",value:function(){return this.getRenderGraphPlugin().getDevice()}},{key:"getSwapChain",value:function(){return this.getRenderGraphPlugin().getSwapChain()}},{key:"loadTexture",value:function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)}},{key:"toDataURL",value:function(e){return this.getRenderGraphPlugin().toDataURL(e)}},{key:"setParameters",value:function(e){this.parameters=o(o({},this.parameters),e)}}])}(t.AbstractRendererPlugin),zo=Object.freeze({__proto__:null,AntialiasingMode:fa,Batch:Da,BufferGeometry:Ca,DeviceProgram:mi,DynamicUniformBuffer:Ti,FILL_TEXTURE_MAPPING:Xa,Fog:Ta,FogType:ma,GeometryEvent:Sa,HashMap:Ci,ImageDrawcall:yo,Instanced:za,InstancedFillDrawcall:po,InstancedLineDrawcall:To,InstancedPathDrawcall:oo,JOINT_TYPE:so,Light:va,Material:La,MaterialEvent:ba,Mesh:Ei,MeshDrawcall:Do,Plugin:Ho,RGAttachmentSlot:Li,RenderCache:Di,RenderGraphPlugin:Ia,RenderHelper:aa,RenderInst:Ji,RenderInstExecutionOrder:ta,RenderInstFlags:$i,RenderInstList:ra,RenderInstManager:ia,Renderable3D:hi,RendererLayer:Vi,SDFDrawcall:Za,ShaderMaterial:Fa,SingleSampledTexture:ki,TemporalTexture:pa,TextDrawcall:Bo,TextUniform:xo,TextureMapping:_a,TexturePool:Wo,TinySDF:Ja,ToneMapping:bi,VertexAttributeBufferIndex:Wa,VertexAttributeLocation:Ha,bezierCurveTo:Qa,compareDefines:ka,definedProps:wa,enumToObject:Ua,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Qi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:Ai,hashCodeNumberUpdate:gi,makeAttachmentClearDescriptor:sa,makeBackbufferDescSimple:ha,makeDataBuffer:ga,makeDepthKey:Xi,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&Vi.TRANSLUCENT?Ki(e):zi(e,t)},makeSortKeyOpaque:zi,makeSortKeyTranslucent:Ki,nullHashFunc:yi,opaqueBlackFullClearRenderPassDescriptor:la,opaqueWhiteFullClearRenderPassDescriptor:ca,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Ue.NEGATIVE_ONE?function(e){ne(e,Zi,e)}(e):t===Ue.ZERO&&function(e){ne(e,qi,e)}(e))},pushFXAAPass:Ma,quadCurveTo:qa,renderInstCompareNone:null,renderInstCompareSortKey:ea,segmentInstanceGeometry:Eo,setBackbufferDescSimple:da,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=!!(e>>>31&1),n=Xi(t,r,arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536);return r?ji(e,n):Yi(e,n)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?ji(e,t):Yi(e,t)},setSortKeyLayer:Wi,setSortKeyOpaqueDepth:Yi,setSortKeyProgramKey:Hi,setSortKeyTranslucentDepth:ji,standardFullClearRenderPassDescriptor:ua,updateBuffer:co}),Yo=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(t,r){var n=this,i=t.renderingService,a=t.renderingContext,o=t.config;this.context=t;var s=a.root.ownerDocument.defaultView,u=function(e){i.hooks.pointerMove.call(e)},l=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},h=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},p=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",u,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",l,!0),r.globalThis.addEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",u,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",l,!0),e.addEventListener("touchmove",u,!0),e.addEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.addEventListener("click",p,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})}),i.hooks.destroy.tap(e.tag,function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",u,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",l,!0),r.globalThis.removeEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",u,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",l,!0),e.removeEventListener("touchmove",u,!0),e.removeEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.removeEventListener("click",p,!0),e.removeEventListener("wheel",_,!0)})}}])}();Yo.tag="DOMInteraction";var Ko=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="dom-interaction",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new Yo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),jo=Object.freeze({__proto__:null,Plugin:Ko}),Zo=function(){function e(){l(this,e),this.displayObjectHTMLElementMap=new WeakMap}return u(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(r,n){var i=this,a=r.camera,o=r.renderingContext,s=r.renderingService;this.context=r;var u=o.root.ownerDocument.defaultView,l=u.context.eventService.nativeHTMLMap,c=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(a));var n=i.getOrCreateEl(r);i.$camera.appendChild(n),Object.keys(r.attributes).forEach(function(e){i.updateAttribute(e,r)}),c(r,n),l.set(n,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),l.delete(n))}},h=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},_=function(e){for(var r=e.detail,n=0;r.length>n;n++){var a=r[n].target;(a.nodeName===t.Shape.FRAGMENT?a.childNodes:[a]).forEach(function(e){if(e.nodeName===t.Shape.HTML){var r=i.getOrCreateEl(e);c(e,r)}})}},p=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.parentElement.style.width="".concat(e.width||0,"px"),i.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,function(){u.addEventListener(t.CanvasEvent.RESIZE,p),u.addEventListener(t.ElementEvent.MOUNTED,f),u.addEventListener(t.ElementEvent.UNMOUNTED,d),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,_)}),s.hooks.endFrame.tap(e.tag,function(){i.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(a.getOrthoMatrix()))}),s.hooks.destroy.tap(e.tag,function(){i.$camera&&i.$camera.remove(),u.removeEventListener(t.CanvasEvent.RESIZE,p),u.removeEventListener(t.ElementEvent.MOUNTED,f),u.removeEventListener(t.ElementEvent.UNMOUNTED,d),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,_)})}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,a=this.context.contextService.getDomElement(),o=a.parentNode;if(o){var s="g-canvas-camera",u=o.querySelector("#".concat(s));if(!u){var l=(r||document).createElement("div");l.style.overflow="hidden",l.style.pointerEvents="none",l.style.position="absolute",l.style.left="0px",l.style.top="0px",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px");var c=(r||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(a.offsetLeft||0,"px"),c.style.top="".concat(a.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.pointerEvents="none",c.style.width="100%",c.style.height="100%",l.appendChild(c),o.appendChild(l)}return u}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;k(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var a=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(a[0].buildCSSText(null,null,"")," ").concat(a[1].buildCSSText(null,null,""));break;case"width":var o=r.parsedStyle.width;n.style.width=G(o)?"".concat(o,"px"):""+o;break;case"height":var s=r.parsedStyle.height;n.style.height=G(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var u=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===u?"auto":u;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var l=r.parsedStyle.fill,c="";t.isCSSRGB(l)?c=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?c=r.getAttribute("fill"):t.isPattern(l),n.style.background=c;break;case"stroke":var f=r.parsedStyle.stroke,d="";t.isCSSRGB(f)?d=f.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(f)?d=r.getAttribute("stroke"):t.isPattern(f),n.style["border-color"]=d,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:U(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}}}])}();Zo.tag="HTMLRendering";var qo=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="html-renderer",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new Zo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Qo=Object.freeze({__proto__:null,Plugin:qo}),$o=function(){return u(function e(){l(this,e),this.cacheStore=new Map},[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,r){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([r.entity])}),this.onRefAdded(r),!0)}},{key:"get",value:function(e,t){var r=this.cacheStore.get(e);return r?(r.counter.has(t.entity)||(r.counter.add(t.entity),this.onRefAdded(t)),r.value):null}},{key:"update",value:function(e,t,r){var n=this.cacheStore.get(e);return!!n&&(n.value=o(o({},n.value),t),n.counter.has(r.entity)||(n.counter.add(r.entity),this.onRefAdded(r)),!0)}},{key:"release",value:function(e,t){var r=this.cacheStore.get(e);return!!r&&(r.counter.delete(t.entity),r.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach(function(r){t.release(r,e)})}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Jo=[],es=[],ts=function(){function e(){l(this,e)}return u(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Jo.length>0||es.length>0)&&(es.forEach(function(e){return e()}),es=Jo.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame(function(){e.executeTask(t)}))}},{key:"sliceImage",value:function(t,r,n,i){for(var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,s=t.naturalWidth||t.width,u=t.naturalHeight||t.height,l=r-a,c=n-a,f=Math.ceil(s/l),d=Math.ceil(u/c),h={tileSize:[r,n],gridSize:[d,f],tiles:Array(d).fill(null).map(function(){return Array(f).fill(null)})},_=function(e){for(var a=function(a){Jo.push(function(){var f=a*l,d=e*c,_=[Math.min(r,s-f),Math.min(n,u-d)],p=_[0],E=_[1],v=o.createCanvas();v.width=r,v.height=n,v.getContext("2d").drawImage(t,f,d,p,E,0,0,p,E),h.tiles[e][a]={x:f,y:d,tileX:a,tileY:e,data:v},i()})},d=0;f>d;d++)a(d)},p=0;d>p;p++)_(p);return e.stop(),e.executeTask(),h}}])}();ts.TASK_NUM_PER_FRAME=10;var rs=new $o;rs.onRefAdded=function(e){var r=this;e.addEventListener(t.ElementEvent.DESTROY,function(){r.releaseRef(e)},{once:!0})};var ns=function(){return u(function e(t,r){l(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=r},[{key:"getImageSync",value:function(e,t,r){var n=k(e)?e:e.src;if(rs.has(n)){var i=rs.get(n,t);if(i.img.complete)return null==r||r(i),i}return this.getOrCreateImage(e,t).then(function(e){null==r||r(e)}).catch(function(e){console.error(e)}),null}},{key:"getOrCreateImage",value:function(e,t){var r=this,n=k(e)?e:e.src;if(!k(e)&&!rs.has(n)){var i={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:is(e)};rs.put(n,i,t)}if(rs.has(n)){var a=rs.get(n,t);return a.img.complete?Promise.resolve(a):new Promise(function(e,t){a.img.addEventListener("load",function(){a.size=[a.img.naturalWidth||a.img.width,a.img.naturalHeight||a.img.height],a.tileSize=is(a.img),e(a)}),a.img.addEventListener("error",function(e){t(e)})})}return new Promise(function(e,i){var a=r.context.config.createImage();if(a){var o={img:a,size:[0,0],tileSize:is(a)};rs.put(n,o,t),a.onload=function(){o.size=[a.naturalWidth||a.width,a.naturalHeight||a.height],o.tileSize=is(o.img),e(o)},a.onerror=function(e){i(e)},a.crossOrigin="Anonymous",a.src=n}})}},{key:"createDownSampledImage",value:(r=F(b().mark(function e(t,r){var n,i,a,s,u,l,c,f,d,h,_,p,E,v;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(t,r);case 1:if(void 0===(n=e.sent).downSamplingRate){e.next=2;break}return e.abrupt("return",n);case 2:if(u=void 0===(s=(a="boolean"==typeof(i=this.context.config.enableLargeImageOptimization)?{}:i).maxDownSampledImageSize)?2048:s,c=void 0===(l=a.downSamplingRateThreshold)?.5:l,f=this.runtime.globalThis.createImageBitmap,d=C(n.size,2),p=n.img,E=Math.min((u+u)/((h=d[0])+(_=d[1])),Math.max(.01,Math.min(c,.5))),v=o(o({},n),{},{downSamplingRate:E}),rs.update(n.img.src,v,r),!f){e.next=7;break}return e.prev=3,e.next=4,f(n.img,{resizeWidth:h*E,resizeHeight:_*E});case 4:p=e.sent,e.next=6;break;case 5:e.prev=5,e.catch(3),E=1;case 6:e.next=8;break;case 7:E=1;case 8:return v=o(o({},this.getImageSync(t,r)),{},{downSampled:p,downSamplingRate:E}),rs.update(n.img.src,v,r),e.abrupt("return",v);case 9:case"end":return e.stop()}},e,this,[[3,5]])})),function(e,t){return r.apply(this,arguments)})},{key:"createImageTiles",value:(e=F(b().mark(function e(r,n,i,a){var s,u,l;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(r,a);case 1:return s=e.sent,ts.api={requestAnimationFrame:(u=a.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:u.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},l=o(o({},s),ts.sliceImage(s.img,s.tileSize[0],s.tileSize[0],i)),rs.update(s.img.src,l,a),e.abrupt("return",l);case 2:case"end":return e.stop()}},e,this)})),function(t,r,n,i){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){rs.release(k(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){rs.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,r,n,i,a,o,s){var u=this.generatePatternKey(r);if(u&&this.patternCache[u])return this.patternCache[u];var l,c=r.image,f=r.repetition,d=r.transform,h=!1;if(k(c)){var _=this.getImageSync(c,e,s);l=null==_?void 0:_.img}else i?(l=i,h=!0):l=c;var p,E=l&&n.createPattern(l,f);E&&(p=d?t.parsedTransformToMat4(t.parseTransform(d),new t.DisplayObject({})):Y(W()),h&&Z(p,p,[1/a,1/a,1]),E.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return u&&E&&(this.patternCache[u]=E),E}},{key:"getOrCreateGradient",value:function(e,r){var n=this.generateGradientKey(e),i=e.type,a=e.steps,o=e.min,s=e.width,u=e.height,l=e.cx,c=e.cy,f=e.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(o,s,u,e.angle);d=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var _=t.computeRadialGradient(o,s,u,l,c,f),p=_.x,E=_.y;d=r.createRadialGradient(p,E,0,p,E,_.r)}return d&&(a.forEach(function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=d)||void 0===r||r.addColorStop(n.value/100,""+e.color))}),this.gradientCache[n]=d),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,a=e.angle,o=e.cx,s=e.cy,u=e.size;return"gradient-".concat(e.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==u?void 0:""+u)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map(function(e){var t=e.color;return"".concat(e.offset).concat(t)}).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,r=e.repetition;return k(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0}}]);var e,r}();function is(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,r=e.naturalHeight||e.height,n=256;return[256,512].forEach(function(e){1e3>Math.ceil(r/e)*Math.ceil(t/e)&&(n=e)}),[n,n]}ns.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var as=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(r){var n=r.renderingService,i=r.imagePool,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e,t,r){var n=e.parsedStyle,i=n.width,a=n.height;i&&!a?e.setAttribute("height",r/t*i):!i&&a&&e.setAttribute("width",t/r*a)},s=function(e){var r=e.target,a=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=a.keepAspectRatio;i.getImageSync(a.src,r,function(e){var t=e.img;s&&o(r,t.width,t.height),r.dirty(),n.dirty()})}},u=function(e){var r=e.target,a=e.prevValue,s=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(a!==s&&i.releaseImage(a,r),k(s)&&i.getOrCreateImage(s,r).then(function(e){var t=e.img;r.attributes.keepAspectRatio&&o(r,t.width,t.height),r.dirty(),n.dirty()}).catch(function(){}))};n.hooks.init.tap(e.tag,function(){a.addEventListener(t.ElementEvent.MOUNTED,s),a.addEventListener(t.ElementEvent.ATTR_MODIFIED,u)}),n.hooks.destroy.tap(e.tag,function(){a.removeEventListener(t.ElementEvent.MOUNTED,s),a.removeEventListener(t.ElementEvent.ATTR_MODIFIED,u)})}}])}();as.tag="LoadImage";var os=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="image-loader",e}return p(t,e),u(t,[{key:"init",value:function(e){this.context.imagePool=new ns(this.context,e),this.addRenderingPlugin(new as)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),ss=function(){return u(function e(t){l(this,e),this.canvasConfig=t.config,this.deviceRendererPlugin=t.deviceRendererPlugin},[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=k(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.deviceRendererPlugin.getDevice().canvasContext}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){if(this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=F(b().mark(function e(t){return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}},e)})),function(t){return e.apply(this,arguments)})}]);var e}(),us=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t)).name="webgpu-context-register",n.rendererPlugin=e,n.config=r,n}return p(t,e),u(t,[{key:"init",value:function(){this.context.ContextService=ss,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new xn({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),ls=function(e){function r(e){var n;l(this,r),(n=h(this,r,[o({enableSizeAttenuation:!1},e)])).clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new Ho;return n.registerPlugin(new us(i,e)),n.registerPlugin(new os),n.registerPlugin(i),n.registerPlugin(new Ko),n.registerPlugin(new qo),n}return p(r,e),u(r)}(t.AbstractRenderer);e.DeviceRenderer=zo,e.DomInteraction=jo,e.HTMLRenderer=Qo,e.Renderer=ls});
|
|
28
|
+
var _i=u(function e(){l(this,e),this.drawcalls=[]});_i.tag="c-renderable-3d";var hi=function(){return u(function e(){l(this,e),this.lights=[]},[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value:function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach(function(t){e[t.define]||(e[t.define]=0),e[t.define]++}),e}},{key:"sortLights",value:function(){this.lights.sort(function(e,t){return e.order-t.order})}}])}(),pi=["style"],Ei=function(e){function r(e){var n,i=e.style,a=A(e,pi);return l(this,r),(n=_(this,r,[o({type:t.Shape.MESH,style:o({x:"",y:"",z:"",lineWidth:0},i)},a)])).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return p(r,e),u(r,[{key:"destroy",value:function(){g(r,"destroy",this,3)([]);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}])}(t.DisplayObject);Ei.PARSED_STYLE_LIST=new Set([].concat(T(t.DisplayObject.PARSED_STYLE_LIST),["x","y","z","geometry","material"]));var vi=function(){return u(function e(){l(this,e)},[{key:"update",value:function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,a=e.z,o=void 0===a?0:a,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:o,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}}}])}(),Ri=function(){return u(function e(){l(this,e),this.counter=0,this.id2DisplayObjectMap={}},[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"deleteById",value:function(e){delete this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=C(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}])}(),Ti=function(){return u(function e(){l(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}},[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(U(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return void 0===(t=this.defines[e])?null:t;var t}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&Je("1"===t),null!==t}}])}(),Ai=function(){return u(function e(t){l(this,e),this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize},[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){e=ct(e,this.uniformBufferWordAlignment),Je(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=ct(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Je(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=ct(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return $e(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=$e(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:Ne.UNIFORM,hint:Me.DYNAMIC}));var t=ct(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())$e(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}])}();function mi(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function gi(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Si(e){return 0}var yi=u(function e(){l(this,e),this.keys=[],this.values=[]}),Ci=function(){return u(function e(t,r){l(this,e),this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r},[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new yi);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=Bn(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:b().mark(function e(){var t,r,n,i,a;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=Bn(this.buckets.values()),e.prev=1,t.s();case 2:if((r=t.n()).done){e.next=6;break}i=(n=r.value).values.length-1;case 3:if(i<0){e.next=5;break}return e.next=4,n.values[i];case 4:i--,e.next=3;break;case 5:e.next=2;break;case 6:e.next=8;break;case 7:e.prev=7,a=e.catch(1),t.e(a);case 8:return e.prev=8,t.f(),e.finish(8);case 9:case"end":return e.stop()}},e,this,[[1,7,8,9]])})}])}();function Pi(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:dr(e,"vert",t,n),preprocessedFrag:dr(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function Ni(e,t){return Je(""!==e.preprocessedVert&&""!==t.preprocessedVert),Je(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Mi(e,t){return e=mi(e,t.blendMode),e=mi(e,t.blendSrcFactor),e=mi(e,t.blendDstFactor)}function Oi(e,t){return e=Mi(e,t.rgbBlendState),e=mi(e=Mi(e,t.alphaBlendState),t.channelWriteMask)}function Ii(e,t){for(var r,n,i,a,o,s,u,l,c=0;t.attachmentsState.length>c;c++)e=Oi(e,t.attachmentsState[c]);return e=function(e,t){return mi(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=mi(e,t.depthCompare),e=mi(e,t.depthWrite?1:0),e=mi(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=mi(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=mi(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=mi(e,null===(a=t.stencilFront)||void 0===a?void 0:a.depthFailOp),e=mi(e,null===(o=t.stencilBack)||void 0===o?void 0:o.compare),e=mi(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=mi(e,null===(u=t.stencilBack)||void 0===u?void 0:u.failOp),e=mi(e,null===(l=t.stencilBack)||void 0===l?void 0:l.depthFailOp),e=mi(e,t.stencilWrite?1:0),e=mi(e,t.cullMode),e=mi(e,t.frontFace?1:0),e=mi(e,t.polygonOffset?1:0)}function xi(e){var t=0;t=mi(t,e.program.id),null!==e.inputLayout&&(t=mi(t,e.inputLayout.id)),t=Ii(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=mi(t,e.colorAttachmentFormats[r]||0);return gi(t=mi(t,e.depthStencilAttachmentFormat||0))}function Bi(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=mi(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var a=e.uniformBufferBindings[i];null!==a&&null!==a.buffer&&(t=mi(t,a.buffer.id),t=mi(t,a.binding),t=mi(t,a.offset),t=mi(t,a.size))}return gi(t)}var Di=function(){return u(function e(t){l(this,e),this.bindingsCache=new Ci(It,Bi),this.renderPipelinesCache=new Ci(Ft,xi),this.inputLayoutsCache=new Ci(wt,Si),this.programCache=new Ci(Ni,Si),this.samplerCache=new Ci(Gt,Si),this.device=t},[{key:"createBindings",value:function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Pt(t.samplerBindings,Vt),uniformBufferBindings:t.uniformBufferBindings&&Pt(t.uniformBufferBindings,Xt),storageBufferBindings:t.storageBufferBindings&&Pt(t.storageBufferBindings,Xt),storageTextureBindings:t.storageTextureBindings&&Pt(t.storageTextureBindings,Wt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter(function(e){return e.size>0}),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r}},{key:"createRenderPipeline",value:function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var a=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&Rt(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o(o({},a),{},{colorAttachmentFormats:e.colorAttachmentFormats.filter(function(e){return e})})),this.renderPipelinesCache.add(a,i)}return i}},{key:"createInputLayout",value:function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter(function(e){return!!e});var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Pt((t=e).vertexBufferDescriptors,Yt),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r}},{key:"createProgramSimple",value:function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,a=null;if(i&&n&&(a=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===a){var o=Pi(this.device,e),s=o.preprocessedVert,u=o.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=u;var l={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};a=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:u}},r),this.programCache.add(l,a)}return a}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=Bn(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=Bn(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,a=Bn(this.inputLayoutsCache.values());try{for(a.s();!(i=a.n()).done;){i.value.destroy()}}catch(e){a.e(e)}finally{a.f()}var o,s=Bn(this.programCache.values());try{for(s.s();!(o=s.n()).done;){o.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=Bn(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}])}(),bi=function(e){return e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping",e}({}),Li=function(e){return e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil",e}({}),Fi=function(){return u(function e(){l(this,e),this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]},[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n}},{key:"attachRenderTargetID",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;Je(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"exec",value:function(e){Je(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){Je(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}])}(),Ui=function(){return u(function e(t,r){l(this,e),this.dimension=xe.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Be.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,Je(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))},[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){Je(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.attachment.destroy()}}])}(),ki=function(){return u(function e(t,r){l(this,e),this.dimension=xe.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Be.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)},[{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){Je(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}])}(),wi=u(function e(){l(this,e),this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]}),Gi=function(){return u(function e(t){l(this,e),this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t},[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Ui(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new ki(this.device,e)}},{key:"beginGraphBuilder",value:function(){Je(null===this.currentGraph),this.currentGraph=new wi}},{key:"pushPass",value:function(e){var t=new Fi;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=$e(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Je(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);Je(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r}},{key:"getRenderTargetDescription",value:function(e){return $e(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var a=t.resolveTextureInputIDs[i];if(void 0!==a)this.resolveTextureUseCount[a]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[a]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(Je(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=$e(this.renderTargetAliveForID[e]);return t?(Je(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Je(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,this.renderTargetAliveForID[e]=void 0,this.renderTargetDeadPool.push(r)),r}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Je(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=$e(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return $e(n.texture)}},{key:"determineResolveParam",value:function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],a=t.resolveTextureOutputExternalTextures[r],o=void 0!==i,s=void 0!==a;Je(!(o&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),o){Je(e.resolveTextureRenderTargetIDs[i]===n),Je(this.resolveTextureUseCount[i]>0),Je(this.renderTargetOutputCount[n]>0);var f=$e(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=$e(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,"".concat(f.debugName," (Resolve ").concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=a,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}}},{key:"schedulePass",value:function(e,t){for(var r=t.renderTargetIDs[Li.DepthStencil],n=Li.Color0;Li.ColorMax>=n;n++){var i=t.renderTargetIDs[n],a=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=a,t.descriptor.colorAttachment[n]=null!==a?a.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var o=this.determineResolveParam(e,t,n),s=o.store,u=o.level;t.descriptor.colorResolveTo[n]=o.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==a&&a.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Li.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Li.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,_=0,h=0,p=0;t.renderTargets.length>p;p++){var E=t.renderTargets[p];if(E){var v=E.width>>>t.renderTargetLevels[p],R=E.height>>>t.renderTargetLevels[p];0===d&&(d=v,_=R,h=E.sampleCount),Je(v===d),Je(R===_),Je(E.sampleCount===h),E.needsClear=!1}}d>0&&_>0&&(t.viewportX*=d,t.viewportY*=_,t.viewportW*=d,t.viewportH*=_);for(var T=0;t.resolveTextureInputIDs.length>T;T++){t.resolveTextureInputTextures[T]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[T])}for(var A=0;t.renderTargetIDs.length>A;A++)this.releaseRenderTargetForID(t.renderTargetIDs[A],!0);for(var m=0;t.renderTargetExtraRefs.length>m;m++)t.renderTargetExtraRefs[m]&&this.releaseRenderTargetForID(t.renderTargetIDs[m],!0)}},{key:"scheduleGraph",value:function(e){Je(0===this.renderTargetOutputCount.length),Je(0===this.renderTargetResolveCount.length),Je(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;ut(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),ut(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),ut(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var a=0;this.renderTargetOutputCount.length>a;a++)Je(0===this.renderTargetOutputCount[a]);for(var o=0;this.renderTargetResolveCount.length>o;o++)Je(0===this.renderTargetResolveCount[o]);for(var s=0;this.resolveTextureUseCount.length>s;s++)Je(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)Je(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){Je(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach(function(e){t.execPass(e)}),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=$e(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Je(r>=0),$e(t.resolveTextureInputTextures[r])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Je(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)Je(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()}}])}(),Vi=function(e){return e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT",e}({});function Xi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,n=w(e,0,r)/r;return t&&(n=1-n),65535&65535*n}function Wi(e,t){return(16777215&e|(255&t)<<24)>>>0}function Hi(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Yi(e,t){return Wi(Hi(0,t),e)}function zi(e,t){return Je(t>=0),(4294967040&e|t>>>8&255)>>>0}function Ki(e){return Wi(0,e)}function ji(e,t){return Je(t>=0),(4278190335&e|t<<8)>>>0}var Zi=Y(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var qi=Y(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Qi(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=a,4}var Ji=function(e){return e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags",e}({}),$i=function(){return u(function e(){l(this,e),this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=dt(1,function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}}),this.dynamicUniformBufferByteOffsets=dt(4,function(){return 0}),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:Rt(At),program:null,topology:Pe.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()},[{key:"reset",value:function(){this.sortKey=0,this.flags=Ji.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){var t,r;vt(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=T(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~Ji.InheritedFlags|e.flags&Ji.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],a=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=a.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=a.uniformBufferBindings)||void 0===r?void 0:r.length});for(var o=0;Math.min(i.uniformBufferBindings.length,a.uniformBufferBindings.length)>o;o++)i.uniformBufferBindings[o].size=e.bindingDescriptors[0].uniformBufferBindings[o].size;this.setSamplerBindingsFromTextureMappings(a.samplerBindings);for(var s=0;e.dynamicUniformBufferByteOffsets.length>s;s++)this.dynamicUniformBufferByteOffsets[s]=e.dynamicUniformBufferByteOffsets[s]}},{key:"validate",value:function(){for(var e=0;this.bindingDescriptors.length>e;e++)for(var t=this.bindingDescriptors[e],r=0;r<(null===(n=t.uniformBufferBindings)||void 0===n?void 0:n.length);r++){var n;Je(t.uniformBufferBindings[r].size>0)}Je(this.drawCount>0)}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return vt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setVertexInput",value:function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){Je(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ft(this.flags,Ji.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=ft(this.flags,Ji.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=ft(this.flags,Ji.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach(function(e){var t=e.value;if(G(t)||Array.isArray(t)||t instanceof Float32Array){var i=G(t)?[t]:t,a=4-r%4;if(4!==a)if(a<(i.length>4?4:i.length)){r+=a;for(var o=0;a>o;o++)n.push(0)}else;r+=i.length,n.push.apply(n,T(i))}});var i=4-n.length%4;if(4!==i)for(var a=0;i>a;a++)n.push(0);for(var o=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)o+=Qi(s,o,n[u],n[u+1],n[u+2],n[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){var r;return Je((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter(function(e){return e});for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=ft(this.flags,Ji.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var a=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:Je(n===a.sampleCount))}var o=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:Je(n===o.sampleCount)),Je(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&Ji.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=$e(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach(function(e){var t={};e.forEach(function(e){t[e.name]=e.value}),r.renderPipelineDescriptor.program.setUniformsLegacy(t)});var s=e.createBindings(o(o({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(s),this.flags&Ji.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0}}])}();function ea(e,t){return e.sortKey-t.sortKey}var ta=function(e){return e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e}({}),ra=function(){return u(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ea,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ta.Forwards;l(this,e),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r},[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var a=n+(i-n>>>1);0>r(t,e[a])?i=a:n=a+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Ji.Draw,this.insertSorted(e)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){if(this.ensureSorted(),this.executionOrder===ta.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(var n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}])}(),na=function(){return u(function e(){l(this,e),this.pool=[],this.allocCount=0},[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new $i),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}])}(),ia=function(){return u(function e(t){l(this,e),this.instPool=new na,this.templatePool=new na,this.simpleRenderInstList=new ra,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t},[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{key:"submitRenderInst",value:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList).submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){Je(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Ji.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Je(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){$e(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){$e(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}])}(),aa=function(){return u(function e(t){l(this,e),this.parameters=t},[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new Di(e),this.renderGraph=new Gi(this.device),this.renderInstManager=new ia(this.renderCache),this.uniformBuffer=new Ai(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}},{key:"getDefines",value:function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==bi.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}}}])}(),oa=function(){return u(function e(t){l(this,e),this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.format=t},[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}])}();function sa(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var ua=sa(tt(.88,.88,.88,1)),la=sa(nt),ca=sa(at),fa=function(e){return e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4",e}({});function da(e,t){var r=function(e){return e.antialiasingMode===fa.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function _a(e,t,r){var n=function(e){if(e===Li.Color0)return Xe.U8_RGBA_RT;if(e===Li.DepthStencil)return Xe.D24_S8;throw Error("whoops")}(e),i=new oa(n);return da(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}var ha=function(){return u(function e(){l(this,e),this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}])}(),pa=function(){return u(function e(){l(this,e),this.inputTexture=null,this.outputTexture=null},[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Je(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new ki(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}])}(),Ea=["style"],va=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=A(e,Ea);return l(this,t),_(this,t,[o({type:t.tag,style:o({intensity:Math.PI},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);va.PARSED_STYLE_LIST=new Set([].concat(T(t.DisplayObject.PARSED_STYLE_LIST),["intensity"])),va.tag="light";var Ra=["style"],Ta=function(e){return e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR",e}({}),Aa=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=A(e,Ra);return l(this,t),_(this,t,[o({type:t.tag,style:o({type:Ta.NONE,fill:"black",start:1,end:1e3,density:0},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);function ma(e,t,r){var n=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:arguments.length>3&&void 0!==arguments[3]?arguments[3]:Me.STATIC});return n.setSubData(0,new Uint8Array(r)),n}Aa.PARSED_STYLE_LIST=new Set([].concat(T(t.DisplayObject.PARSED_STYLE_LIST),["type","density","start","end"])),Aa.tag="fog";var ga,Sa,ya=function(e){return e.CHANGED="changed",e}({}),Ca=function(e){function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(this,r),(t=_(this,r)).drawMode=Pe.TRIANGLES,t.vertexBuffers=[],t.vertices=[],t.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=n,t}return p(r,e),u(r,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ma(this.device,Ne.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=Xe.U32_R,this}},{key:"setVertexBuffer",value:function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach(function(e){var n=e.format,i=e.bufferByteOffset,a=e.location,o=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find(function(e){return e.shaderLocation===a});s?(s.format=n,s.offset=i,s.divisor=o):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:a,divisor:o})}),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var a=ma(this.device,Ne.VERTEX,i.buffer,Me.DYNAMIC);return this.vertexBuffers[r]=a,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var a=i.arrayStride,o=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find(function(e){return e.shaderLocation===t});if(o)this.getVertexBuffer(e).setSubData(o.offset+r*a,n);this.emit(ya.CHANGED)}}},{key:"updateIndices",value:function(e){return this.indexBuffer&&this.indexBuffer.setSubData(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach(function(e){e&&e.destroy()}),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}])}(We),Pa=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=_(this,t,[].concat(n))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",e.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",e}return p(t,e),u(t)}(Ti),Na=dt(1,function(){return new ha});function Ma(e,t,r,n){e.pushPass(function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Li.Color0,n);var a=e.resolveRenderTarget(n);i.attachResolveTexture(a);var o=t.renderInstManager.newRenderInst();o.setUniformBuffer(t.uniformBuffer),o.setAllowSkippingIfPipelineNotReady(!1),o.setMegaStateFlags(mt),o.setBindingLayout({numUniformBuffers:1,numSamplers:1}),o.drawPrimitives(3);var s=o.allocateUniformBuffer(0,4);Qi(o.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Pa,l=t.renderCache.createProgramSimple(u);o.setProgram(l),ga||((ga=new Ca(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),ga.vertexCount=3,Sa=t.getCache().createInputLayout(ga.inputLayoutDescriptor)),i.exec(function(e,r){Na[0].texture=r.getResolveTextureForID(a),o.setSamplerBindingsFromTextureMappings(Na),o.setVertexInput(Sa,ga.vertexBuffers.map(function(e){return{buffer:e,byteOffset:0}}),null),o.drawOnPass(t.renderCache,e)})})}var Oa=function(e){return e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking",e}({}),Ia=function(){function e(t,r,n,i,a){l(this,e),this.renderLists={leftEye:new ra,rightEye:new ra,picking:new ra},this.cameras=[],this.renderHelper=t,this.lightPool=r,this.texturePool=n,this.batchManager=i,this.options=a}return u(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.config,s=r.renderingContext.root.ownerDocument.defaultView;a.disableRenderHooks=!0;var u=function(e){var t=e.target;t.nodeName!==va.tag?t.nodeName!==Aa.tag?(t.renderable3D||(t.renderable3D=new _i),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},l=function(e){var r=e.target;if(r.nodeName!==va.tag)if(r.nodeName!==Aa.tag){if(r.nodeName===t.Shape.MESH){var i,a;if(null!==(i=r.style.geometry)&&void 0!==i&&i.meshes){var o=r.style.geometry.meshes.indexOf(r);o>-1&&r.style.geometry.meshes.splice(o,1)}if(null!==(a=r.style.material)&&void 0!==a&&a.meshes){var s=r.style.material.meshes.indexOf(r);s>-1&&r.style.material.meshes.splice(s,1)}}n.swapChain&&n.batchManager.remove(r),delete r.renderable3D}else n.lightPool.removeFog(r);else n.lightPool.removeLight(r)},c=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach(function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)}):n.batchManager.updateAttribute(t,r,i)}},f=function(e){if(n.swapChain)for(var r=e.detail,i=0;r.length>i;i++){var a=r[i].target;(a.nodeName===t.Shape.FRAGMENT?a.childNodes:[a]).forEach(function(e){n.batchManager.updateAttribute(e,"modelMatrix",null)})}};i.hooks.initAsync.tapPromise(e.tag,F(b().mark(function e(){var i,a;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s.addEventListener(t.ElementEvent.MOUNTED,u),s.addEventListener(t.ElementEvent.UNMOUNTED,l),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((a=n.context.config).width,a.height),e.next=1,n.context.deviceContribution.createSwapChain(i);case 1:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),s.addEventListener(t.CanvasEvent.RESIZE,function(){n.swapChain.configureSwapChain(i.width,i.height)}),n.batchManager.attach(o({device:n.device},r));case 2:case"end":return e.stop()}},e)}))),i.hooks.destroy.tap(e.tag,function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),s.removeEventListener(t.ElementEvent.MOUNTED,u),s.removeEventListener(t.ElementEvent.UNMOUNTED,l),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.device.destroy(),n.device.checkForLeaks(),a.disableRenderHooks=!1}),i.hooks.beginFrame.tap(e.tag,function(e){var r,i=null==e?void 0:e.session,a=n.context.config,o=a.width,s=a.height;if(i){var u=i.renderState.baseLayer;u||(u=i.renderState.layers[0]),n.swapChain.configureSwapChain(u.framebufferWidth,u.framebufferHeight,u.framebuffer);var l=e.getViewerPose(i.referenceSpace);l&&l.views.forEach(function(e,t){var r=i.renderState.baseLayer.getViewport(e),a=Y.apply(ie,T(e.transform.matrix));a[12]*=o,a[13]*=s,a[14]*=500,a[12]+=o/2,a[13]-=s/2,a[14]+=250;var l=Y.apply(ie,T(e.projectionMatrix)),c=K(W(),a);Z(c,c,ae(1,-1,1));var f=e.transform.position;n.cameras[t]={viewport:{x:r.x/u.framebufferWidth,y:r.y/u.framebufferHeight,width:r.width/u.framebufferWidth,height:r.height/u.framebufferHeight},projectionMatrix:l,viewMatrix:c,cameraPosition:[f.x,f.y,f.z],isOrtho:!1}})}else{var c=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:c.getPerspective(),viewMatrix:c.getViewTransform(),cameraPosition:c.getPosition(),isOrtho:c.isOrtho()}]}var f,d=n.swapChain.getCanvas(),_=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)f=rt;else{var h=t.parseColor(n.context.config.background);f=n.context.config.background?tt(Number(h.r)/255*Number(h.alpha),Number(h.g)/255*Number(h.alpha),Number(h.b)/255*Number(h.alpha),Number(h.alpha)):it}var p={backbufferWidth:d.width,backbufferHeight:d.height,antialiasingMode:fa.None},E=_a(Li.Color0,p,sa(f)),v=_a(Li.DepthStencil,p,ca),R=n.builder.createRenderTargetID(E,"Main Color"),A=n.builder.createRenderTargetID(v,"Main Depth");n.builder.pushPass(function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Li.Color0,R),e.attachRenderTargetID(Li.DepthStencil,A),e.exec(function(e,t){n.cameras.forEach(function(r,i){var a=r.viewport,o=t.currentPass,s=o.viewportW,u=o.viewportH;e.setViewport(a.x*s,a.y*u,a.width*s,a.height*u),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(_.renderCache,e)})})}),null!==(r=n.options)&&void 0!==r&&r.enableFXAA&&Ma(n.builder,n.renderHelper,p,R),n.builder.resolveRenderTargetToExternalTexture(R,n.swapChain.getOnscreenTexture())}),i.hooks.endFrame.tap(e.tag,function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,a=r.height;if(n.cameras.forEach(function(e,r){var o=e.viewport,s=e.cameraPosition,u=e.viewMatrix,l=e.projectionMatrix,c=e.isOrtho,f=o.width,d=o.height,_=n.renderHelper.pushTemplateRenderInst();_.setBindingLayout({numUniformBuffers:2,numSamplers:0}),_.setMegaStateFlags(gt({depthWrite:!0,blendConstant:rt},{rgbBlendMode:ge.ADD,alphaBlendMode:ge.ADD,rgbBlendSrcFactor:me.SRC_ALPHA,alphaBlendSrcFactor:me.ONE,rgbBlendDstFactor:me.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:me.ONE_MINUS_SRC_ALPHA})),_.setUniforms(0,[{name:Oa.PROJECTION_MATRIX,value:l},{name:Oa.VIEW_MATRIX,value:u},{name:Oa.CAMERA_POSITION,value:s},{name:Oa.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Oa.VIEWPORT,value:[i*f,a*d]},{name:Oa.IS_ORTHO,value:c?1:0},{name:Oa.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()}),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var o=n.captureOptions,s=o.type,u=o.encoderOptions,l=n.context.contextService.getDomElement().toDataURL(s,u);n.resolveCapturePromise(l),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}})}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,function(e){r&&r(e)})}},{key:"toDataURL",value:(r=F(b().mark(function e(t){var r=this;return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise(function(e){r.resolveCapturePromise=function(t){e(t)}}),e.abrupt("return",this.capturePromise);case 1:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})}]);var r}();Ia.tag="RenderGraph";var xa=function(){function e(t,r,n,i){l(this,e),this.renderHelper=t,this.renderGraphPlugin=r,this.pickingIdGenerator=n,this.batchManager=i}return u(e,[{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new _i);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},s=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,function(){a.addEventListener(t.ElementEvent.MOUNTED,o),a.addEventListener(t.ElementEvent.UNMOUNTED,s)}),i.hooks.destroy.tap(e.tag,function(){a.removeEventListener(t.ElementEvent.MOUNTED,o),a.removeEventListener(t.ElementEvent.UNMOUNTED,s),n.pickingIdGenerator.reset()}),i.hooks.pickSync.tap(e.tag,function(e){return n.pick(e)}),i.hooks.pick.tapPromise(e.tag,function(){var e=F(b().mark(function e(t){return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.pick(t));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}},{key:"pick",value:function(e){var r=e.topmost,n=e.position,i=n.viewportX,a=n.viewportY,o=this.context.contextService.getDPR(),s=this.context.config.width*o,u=this.context.config.height*o,l=i*o,c=a*o;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(w(Math.round(l),0,s-1),w(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e}},{key:"pickByRectangleInDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i}},{key:"restorePickingColor",value:function(e){var t=this;e.forEach(function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)})}},{key:"pickByRectangle",value:function(e,t){var r,n=this,i=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,u=this.renderHelper.renderGraph.newGraphBuilder(),l=this.context.camera,c=e.x,f=e.y,d=e.width,_=e.height,h={backbufferWidth:d,backbufferHeight:_,antialiasingMode:fa.None},p=_a(Li.Color0,h,sa(rt)),E=u.createRenderTargetID(p,"Picking Color"),v=_a(Li.DepthStencil,h,ca),R=u.createRenderTargetID(v,"Picking Depth"),T=o({},l.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach(function(e){e.age=-1}),u.pushPass(function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Li.Color0,E),e.attachRenderTargetID(Li.DepthStencil,R),e.exec(function(e){a.picking.drawOnPassRenderer(s.renderCache,e)}),e.post(function(e){var t,a=e.getRenderTargetTexture(Li.Color0),o=i.createReadback();T&&T.enabled?l.setViewOffset(T.fullWidth,T.fullHeight,T.offsetX,T.offsetY,T.width,T.height):l.clearViewOffset(),l.setEnableUpdate(!0);try{t=o.readTextureSync(a,0,0,d,_,new Uint8Array(d*_*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var u=n.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(r=u)}o.destroy()})});var A=this.renderHelper.pushTemplateRenderInst();A.setBindingLayout({numUniformBuffers:2,numSamplers:0}),A.setMegaStateFlags(gt({depthWrite:!0},{rgbBlendMode:ge.ADD,rgbBlendSrcFactor:me.ONE,rgbBlendDstFactor:me.ZERO,alphaBlendMode:ge.ADD,alphaBlendSrcFactor:me.ONE,alphaBlendDstFactor:me.ZERO}));var m=this.context.config,g=m.width,S=m.height,y=this.context.contextService.getDPR();return l.setEnableUpdate(!1),l.setViewOffset(g*y,S*y,c,S*y-f,d,_),A.setUniforms(0,[{name:Oa.PROJECTION_MATRIX,value:l.getPerspective()},{name:Oa.VIEW_MATRIX,value:l.getViewTransform()},{name:Oa.CAMERA_POSITION,value:l.getPosition()},{name:Oa.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Oa.VIEWPORT,value:[d,_]},{name:Oa.IS_ORTHO,value:l.isOrtho()?1:0},{name:Oa.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r}}])}();xa.tag="WebGLPicker";var Ba=5e-4,Da=function(){return u(function e(){l(this,e),this.clipPathMeshCreated=!1},[{key:"beforeUploadUBO",value:function(e,t){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}])}();var ba=function(e){return e.CHANGED="changed",e}({}),La=function(e){function t(e,r){var n;l(this,t),(n=_(this,t)).props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=Rt(At),a=i.cullMode,s=i.depthCompare,u=i.depthWrite,c=i.stencilFront,f=i.stencilBack,d=i.stencilWrite,h=i.frontFace,p=i.polygonOffset,E=i.attachmentsState;return n.device=e,n.props=o({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilFront:c,stencilBack:f,stencilWrite:d,frontFace:h,polygonOffset:p,attachmentsState:E,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return p(t,e),u(t,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilFront",get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e}},{key:"stencilBack",get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,function(t,r){return e.samplers.push(r),""}),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach(function(e){var t=de(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})}),r.push({type:t.trim(),uniforms:i}),""}),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach(function(e){var n=e.trim().split(" "),i=n[0]||"",a=n[1]||"",o=a.indexOf("[")>-1;if(a=a.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find(function(e){return i===e.type});if(s)if(o)for(var u=function(e){s.uniforms.forEach(function(r){t.push("".concat(a,"[").concat(e,"].").concat(r.name))})},l=0;5>l;l++)u(l);else s.uniforms.forEach(function(e){t.push("".concat(a,".").concat(e.name))})}a&&t.push(a)}}),""}),t}(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,r=!1;Object.keys(e).forEach(function(n){var i,a=e[n],o=t.textures[n];o&&o!==a&&(t.textureDirty=!0),(i=a)&&i.type?(t.textures[n]=a,t.textureDirty=!0,a.on(Ie.LOADED,function(){t.dispatchMutationEvent()})):(t.uniforms[n]=a,r=!0),U(e[n])&&(delete t.textures[n],delete t.uniforms[n])}),r&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(ba.CHANGED)}}])}(We),Fa=function(e){function t(e,r){var n;return l(this,t),(n=_(this,t,[e,o({},r)])).defines=o(o({},n.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return p(t,e),u(t)}(La);function Ua(e){var t={};return Object.keys(e).forEach(function(r){"number"==typeof e[r]&&(t[r]=e[r])}),t}function ka(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(function(r){return e[r]===t[r]})}var wa=function(e){return Object.fromEntries(Object.entries(e).filter(function(e){var t=C(e,2);return void 0!==t[1]}))};function Ga(e,t){return 256*(e=w(Math.floor(e),0,255))+(t=w(Math.floor(t),0,255))}var Va=1,Xa="FillTextureMapping",Wa=function(e){return e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX",e}({}),Ha=function(e){return e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX",e}({}),Ya=function(){return u(function e(t,r,n,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:-1,s=arguments.length>6?arguments[6]:void 0;l(this,e),this.id=Va++,this.gradientAttributeName="fill",this.objects=[],this.program=new Ti,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1,this.renderHelper=t,this.texturePool=r,this.lightPool=n,this.drawcallCtors=a,this.index=o,this.context=s},[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Fa(this.context.device),this.material.defines=o(o({},Ua(Ha)),this.material.defines),this.geometry=new Ca(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(ya.CHANGED,function(){e.geometry.meshes.forEach(function(e){e.renderable.dirty=!0}),e.context.renderingService.dirty()})}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(ba.CHANGED,function(){e.material.meshes.forEach(function(e){e.renderable.dirty=!0}),e.context.renderingService.dirty()})}},{key:"shouldMergeColor",value:function(e,r,n){var i=e.parsedStyle[n],a=r.parsedStyle[n];return!i&&!a||(!(!t.isCSSRGB(i)||!t.isCSSRGB(a))||(!(!t.isPattern(i)||!t.isPattern(a)||i.image!==a.image)||!(!Array.isArray(i)||!Array.isArray(a)||e.style[n]!==r.style[n])))}},{key:"shouldMerge",value:function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))}},{key:"createGeometry",value:function(e){var r,n,i=this,a=W(),o=W(),s=[],u=[],l=[],c=[],f=this.divisor,d=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach(function(e){var r,n=e.parsedStyle,f=n.fill,_=n.stroke,h=n.opacity,p=void 0===h?1:h,E=n.fillOpacity,v=void 0===E?1:E,R=n.strokeOpacity,A=void 0===R?1:R,m=n.lineWidth,g=void 0===m?1:m,S=n.visibility,y=n.increasedLineWidthForHitTesting,C=void 0===y?0:y,P=[0,0,0,0];t.isCSSRGB(f)&&(P=[Number(f.r),Number(f.g),Number(f.b),255*Number(f.alpha)]);var N=[0,0,0,0];t.isCSSRGB(_)&&(N=[Number(_.r),Number(_.g),Number(_.b),255*Number(_.alpha)]),ne(o,i.context.camera.getViewTransform(),a);var M=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var O=e.parsedStyle,I=O.x,x=O.y,B=O.z;ne(a,e.getWorldTransform(),q(a,ae(I,x,B)))}else H(a,e.getWorldTransform());s.push.apply(s,T(a)),u.push(Ga(P[0],P[1]),Ga(P[2],P[3]),Ga(N[0],N[1]),Ga(N[2],N[3])),l.push(p,v,A,g,"hidden"!==S?1:0,d,d,C),c.push.apply(c,T(M).concat([e.sortable.renderOrder*Ba]))}),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Wa.MODEL_MATRIX,byteStride:64,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.MODEL_MATRIX0,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.MODEL_MATRIX1,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:32,location:Ha.MODEL_MATRIX2,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:48,location:Ha.MODEL_MATRIX3,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PACKED_COLOR,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PACKED_COLOR,divisor:f}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PACKED_STYLE,byteStride:32,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PACKED_STYLE1,divisor:f},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.PACKED_STYLE2,divisor:f}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:Wa.PICKING_COLOR,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.PICKING_COLOR,divisor:f}],data:new Float32Array(c)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:Re.ALWAYS,passOp:be.REPLACE},this.material.stencilBack={compare:Re.ALWAYS,passOp:be.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:Re.EQUAL,passOp:be.KEEP},this.material.stencilBack={compare:Re.EQUAL,passOp:be.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var i=o({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=o(o(o({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort(function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)}).forEach(function(e){var t=new ha;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture ".concat(e)),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:Se.CLAMP_TO_EDGE,addressModeV:Se.CLAMP_TO_EDGE,minFilter:ye.POINT,magFilter:ye.BILINEAR,mipmapFilter:Ce.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)}),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ka(i,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=o(o({},this.material.defines),Ua(Ha)),Object.keys(this.material.defines).forEach(function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))}),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),u=this.renderHelper.getCache().createInputLayout(o(o({},this.geometry.inputLayoutDescriptor),{},{program:s})),l=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(u,this.geometry.vertexBuffers.filter(function(e){return!!e}).map(function(e){return{buffer:e,byteOffset:0}}),l?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=Yi(Vi.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,r,n,i){var a=this;if(0!==e.length){if("fill"===n||"stroke"===n){var o=[];e.forEach(function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];t.isCSSRGB(n)&&(a=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),o.push(Ga(a[0],a[1]),Ga(a[2],a[3]),Ga(s[0],s[1]),Ga(s[2],s[3]))}),this.geometry.updateVertexBuffer(Wa.PACKED_COLOR,Ha.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var s=this.instance.parsedStyle.fill,u=this.textureMappings.findIndex(function(e){return e.name===Xa});if(t.isCSSRGB(s))0>u||(this.textureMappings.splice(u,-1),this.material.textureDirty=!0);else{var l=this.createFillGradientTextureMapping([this.instance]);0>u||this.textureMappings.splice(u,1,l),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var c,f,d=[],_=(null===(c=e[0])||void 0===c?void 0:c.nodeName)===t.Shape.CIRCLE||(null===(f=e[0])||void 0===f?void 0:f.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach(function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,a=t.lineWidth,o=t.increasedLineWidthForHitTesting;d.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===a?1:a,"hidden"!==t.visibility?1:0,_,_,void 0===o?0:o)}),this.geometry.updateVertexBuffer(Wa.PACKED_STYLE,Ha.PACKED_STYLE1,r,new Uint8Array(new Float32Array(d).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var h=[],p=W();e.forEach(function(e){if(a.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;ne(p,e.getWorldTransform(),q(p,ae(r,n,i)))}else H(p,e.getWorldTransform());h.push.apply(h,T(p))}),this.geometry.updateVertexBuffer(Wa.MODEL_MATRIX,Ha.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(h).buffer))}else if("pointerEvents"===n){var E=[];e.forEach(function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];E.push.apply(E,T(r).concat([e.sortable.renderOrder*Ba]))}),this.geometry.updateVertexBuffer(Wa.PICKING_COLOR,Ha.PICKING_COLOR,r,new Uint8Array(new Float32Array(E).buffer))}}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Wa.PICKING_COLOR,Ha.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(T(i),[t*Ba])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map(function(e){return e.slice()}),i=Wa.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride/4*r)}for(var a=0,o=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].arrayStride/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];o[s]=a,a++}for(var d=Wa.PICKING_COLOR+1;e.vertexBuffers.length>d;d++){var _=e.inputLayoutDescriptor.vertexBufferDescriptors[d],h=e.inputLayoutDescriptor.vertexBufferDescriptors[d].attributes[0];if(h)e.setVertexBuffer({bufferIndex:d,byteStride:_.arrayStride,stepMode:_.stepMode,attributes:[{format:h.format,bufferByteOffset:h.offset,location:h.shaderLocation,divisor:h.divisor}],data:e.vertices[d]})}for(var p=new Float32Array(3*r),E=0;r>E;)for(var v=0;3>v;v++){p[3*o[E++]+v]=1}e.setVertexBuffer({bufferIndex:Wa.BARYCENTRIC,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Number(Ha.BARYCENTRIC)}],data:p}),e.setIndexBuffer(o)}},{key:"beforeUploadUBO",value:function(e,t){}},{key:"uploadUBO",value:function(e){var r,n=this,i=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),u=!!s,l=null!==(r=i.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(i.defines.USE_WIREFRAME){var f=t.parseColor(i.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:i.wireframeLineWidth})}if(u&&this.uploadFog(c,s),this.uploadMaterial(c,i),l){var d={};a.forEach(function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])})}c.sort(function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)}),e.setUniforms(1,c);var _=i.blendEquation,h=i.blendEquationAlpha,p=i.blendSrc,E=i.blendDst,v=i.blendSrcAlpha,R=i.blendDstAlpha,T=wa({blendConstant:i.blendConstant,depthCompare:i.depthCompare,depthWrite:i.depthWrite,stencilFront:i.stencilFront,stencilBack:i.stencilBack,stencilWrite:i.stencilWrite,stencilRef:i.stencilRef,cullMode:i.cullMode,frontFace:i.frontFace,polygonOffset:i.polygonOffset}),A=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(o({attachmentsState:[{channelWriteMask:this.material.stencilWrite?De.NONE:De.ALL,rgbBlendState:o(o({},A.rgbBlendState),wa({blendMode:_,blendSrcFactor:p,blendDstFactor:E})),alphaBlendState:o(o({},A.alphaBlendState),wa({blendMode:h,blendSrcFactor:v,blendDstFactor:R}))}]},T)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,a=n.fill,o=n.start,s=n.end,u=n.density;if(t.isCSSRGB(a)){var l=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)];e.push({name:"u_FogInfos",value:[i,o,s,u]}),e.push({name:"u_FogColor",value:l})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map(function(e){return{name:e,value:t.uniforms[e]}});e.push.apply(e,T(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r,n=this,i=e[0],a=i.parsedStyle[this.gradientAttributeName];if(a&&(t.isPattern(a)||Array.isArray(a))){Array.isArray(a)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:a,width:128,height:128,instance:i})):t.isPattern(a)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(a,i,function(){e.forEach(function(e){e.renderable.dirty=!0}),n.material.textureDirty=!0})),r=this.texturePool.getOrCreateCanvas();var o=this.texturePool.getOrCreateTexture(this.context.device,r,He(Xe.U8_RGBA_NORM,1,1,1));if(o){var s=new ha;return s.name=Xa,s.texture=o,s.texture.on("loaded",function(){e.forEach(function(e){e.renderable.dirty=!0}),n.material.textureDirty=!0}),this.context.device.setResourceName(s.texture,"Fill Texture".concat(this.id)),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:Se.CLAMP_TO_EDGE,addressModeV:Se.CLAMP_TO_EDGE,minFilter:ye.POINT,magFilter:ye.BILINEAR,mipmapFilter:Ce.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null}}])}(),za=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e}(za||{}),Ka=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e[e.EXTRUDE=1+e.PACKED_STYLE3]="EXTRUDE",e[e.SIZE=1+e.EXTRUDE]="SIZE",e}(Ka||{}),ja=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],Za=function(e){function r(){return l(this,r),_(this,r,arguments)}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=g(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(Ka))}},{key:"createGeometry",value:function(e){var t=this;g(r,"createGeometry",this,3)([e]);var n=[],i=[];e.forEach(function(e,r){var a=e,o=a.parsedStyle.radius,s=t.shouldOmitStroke(a.parsedStyle),u=t.getSize(e.parsedStyle,a.nodeName),l=t.getPosition(e.parsedStyle,a.nodeName);n.push.apply(n,T(u).concat([a.parsedStyle.isBillboard?1:0,a.parsedStyle.isSizeAttenuation?1:0,ja.indexOf(a.nodeName),o&&o[0]||0,s?1:0])),i.push.apply(i,T(l))}),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:16,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ka.EXTRUDE},{format:Xe.F32_RG,bufferByteOffset:8,location:Ha.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:za.PACKED_STYLE,byteStride:28,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ka.SIZE,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:16,location:Ka.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(g(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var o=[];e.forEach(function(e){var t=e,r=a.shouldOmitStroke(t.parsedStyle),n=C(a.getSize(e.parsedStyle,e.nodeName),2);o.push.apply(o,[n[0],n[1]].concat([t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,ja.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0]))}),this.geometry.updateVertexBuffer(za.PACKED_STYLE,Ka.SIZE,t,new Uint8Array(new Float32Array(o).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];e.forEach(function(e){var t=C(a.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])}),this.geometry.updateVertexBuffer(Wa.POSITION,Ha.POSITION,t,new Uint8Array(new Float32Array(s).buffer))}}},{key:"getPosition",value:function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,a=e.cy,o=e.cz;n=[void 0===i?0:i,void 0===a?0:a,void 0===o?0:o]}else if(r===t.Shape.RECT){var s=e.x,u=e.y,l=e.z;n=[void 0===s?0:s,void 0===u?0:u,void 0===l?0:l]}return n}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,a=t&&t.length&&t.every(function(e){return 0!==e});return!i||i&&(a||1>n)}}])}(Ya);function qa(e,t,r,n,i,a){for(var o=i[i.length-3],s=i[i.length-2],u=null!=a?a:w(di(o,s,e,t,r,n,3)/10,8,100),l=0,c=0,f=1;u>=f;++f){var d=f/u;i.push((l=o+(e-o)*d)+(e+(r-e)*d-l)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function Qa(e,t,r,n,i,a,o,s){var u=o[o.length-3],l=o[o.length-2];o.length-=3;var c=null!=s?s:w(ci(u,l,e,t,r,n,i,a,3)/10,8,100),f=0,d=0,_=0,h=0,p=0;o.push(u,l,0);for(var E=1,v=0;c>=E;++E)o.push((_=(d=(f=1-(v=E/c))*f)*f)*u+3*d*v*e+3*f*(h=v*v)*r+(p=h*v)*i,_*l+3*d*v*t+3*f*h*n+p*a,0)}var Ja=1e20,$a=function(){return u(function e(t,r){l(this,e);var n=t.fontSize,i=void 0===n?24:n,a=t.buffer,o=void 0===a?3:a,s=t.radius,u=void 0===s?8:s,c=t.cutoff,f=void 0===c?.25:c,d=t.fontFamily,_=void 0===d?"sans-serif":d,h=t.fontWeight,p=void 0===h?"normal":h,E=t.fontStyle,v=void 0===E?"normal":E,R=t.canvas;this.buffer=o,this.cutoff=f,this.radius=u;var T=this.size=i+4*o,A=r.offscreenCanvasCreator.getOrCreateCanvas(R);A.width=T,A.height=T;var m=r.offscreenCanvasCreator.getOrCreateContext(R,{willReadFrequently:!0});this.ctx=m,m.font="".concat(v," ").concat(p," ").concat(i,"px ").concat(_),m.textBaseline="alphabetic",m.textAlign="left",m.fillStyle="black",this.gridOuter=new Float64Array(T*T),this.gridInner=new Float64Array(T*T),this.f=new Float64Array(T),this.z=new Float64Array(T+1),this.v=new Uint16Array(T)},[{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,a=t.actualBoundingBoxRight,o=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),u=Math.min(this.size-this.buffer,o+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),_={data:d,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:o,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return _;var h=this.ctx,p=this.buffer,E=this.gridInner,v=this.gridOuter;h.clearRect(p,p,s,u),h.fillText(e,p,p+o);var R=h.getImageData(p,p,s,u);v.fill(Ja,0,f),E.fill(0,0,f);for(var T=0;u>T;T++)for(var A=0;s>A;A++){var m=R.data[4*(T*s+A)+3]/255;if(0!==m){var g=(T+p)*l+A+p;if(1===m)v[g]=0,E[g]=Ja;else{var S=.5-m;v[g]=S>0?S*S:0,E[g]=0>S?S*S:0}}}eo(v,0,0,l,c,l,this.f,this.v,this.z),eo(E,p,p,s,u,l,this.f,this.v,this.z);for(var y=0;f>y;y++){d[y]=Math.round(255-255*((Math.sqrt(v[y])-Math.sqrt(E[y]))/this.radius+this.cutoff))}return _}}])}();function eo(e,t,r,n,i,a,o,s,u){for(var l=t;t+n>l;l++)to(e,r*a+l,a,i,o,s,u);for(var c=r;r+i>c;c++)to(e,c*a+t,1,n,o,s,u)}function to(e,t,r,n,i,a,o){a[0]=0,o[0]=-Ja,o[1]=Ja,i[0]=e[t];for(var s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{var f=a[u];l=(i[s]-i[f]+c-f*f)/(s-f)/2}while(o[u]>=l&&--u>-1);a[++u]=s,o[u]=l,o[u+1]=Ja}for(var d=0,_=0;n>d;d++){for(;d>o[_+1];)_++;var h=a[_],p=d-h;e[t+d*r]=i[h]+p*p}}var ro=function(e){return e[e.PACKED=Wa.POSITION+1]="PACKED",e[e.VERTEX_NUM=1+e.PACKED]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(ro||{}),no=function(e){return e[e.PREV=Ha.POSITION]="PREV",e[e.POINT1=1+e.PREV]="POINT1",e[e.POINT2=1+e.POINT1]="POINT2",e[e.NEXT=1+e.POINT2]="NEXT",e[e.VERTEX_JOINT=1+e.NEXT]="VERTEX_JOINT",e[e.VERTEX_NUM=1+e.VERTEX_JOINT]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(no||{});function io(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function ao(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!U(r[0][2])}var oo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=_(this,r,[e,t,n,i,a,o,s])).segmentNum=-1,u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.segmentNum=u.calcSegmentNum(i),u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){return co(e,!1,12,this.calcSubpathIndex(e)).instancedCount}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter(function(e){return e===po}).length;return this.index-r}return 0}},{key:"shouldMerge",value:function(e,t){var n=g(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.segmentNum===i}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(no))}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=[],s=0,u=0;e.forEach(function(e){var r=co(e,!1,12,t.calcSubpathIndex(e)),l=r.pointsBuffer,c=r.travelBuffer,f=r.instancedCount,d=e.parsedStyle,_=d.lineDash;o.push(_&&_[0]||0,_&&_[1]||0,d.lineDashOffset||0,io(d.isBillboard,d.isSizeAttenuation,ao(e))),s+=f;for(var h=0;l.length-12>h;h+=4)i.push(l[h],l[h+1],l[h+2],l[h+3],l[h+4],l[h+5],l[h+6],l[h+7],l[h+8],l[h+9],l[h+10],l[h+11],l[h+12],l[h+13],l[h+14],l[h+15]);a.push.apply(a,T(c)),n.push(0+u,2+u,1+u,0+u,3+u,2+u,4+u,6+u,5+u,4+u,7+u,6+u,4+u,7+u,8+u),u+=9}),i.length&&(this.geometry.setVertexBuffer({bufferIndex:ro.PACKED,byteStride:64,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:no.PREV,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:16,location:no.POINT1,divisor:1},{format:Xe.F32_R,bufferByteOffset:28,location:no.VERTEX_JOINT,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:32,location:no.POINT2,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:48,location:no.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ro.VERTEX_NUM,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,byteStride:4,location:no.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:ro.TRAVEL,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,byteStride:4,location:no.TRAVEL,divisor:1}],data:new Float32Array(a)}),this.divisor=s/e.length,this.geometry.setVertexBuffer({bufferIndex:ro.DASH,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:no.DASH,divisor:this.divisor}],data:new Float32Array(o)}),g(r,"createGeometry",this,3)([e]),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(g(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var o=[],s=[],u=0;e.forEach(function(e){var t=co(e,!1,12,a.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;u=t.instancedCount;for(var i=0;r.length-12>i;i+=4)o.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,T(n))}),this.geometry.updateVertexBuffer(ro.PACKED,no.PREV,t*u,new Uint8Array(new Float32Array(o).buffer)),this.geometry.updateVertexBuffer(ro.TRAVEL,no.TRAVEL,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var l=[];e.forEach(function(e){var t=e.parsedStyle,r=t.lineDash;l.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,io(t.isBillboard,t.isSizeAttenuation,ao(e)))}),this.geometry.updateVertexBuffer(ro.DASH,no.DASH,t,new Uint8Array(new Float32Array(l).buffer))}}}],[{key:"calcSubpathNum",value:function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter(function(e){return"M"===e[0]}).length:1}}])}(Ya),so=function(e){return e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2",e}({}),uo=3,lo=4;function co(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.parsedStyle,o=a.lineCap,s=a.lineJoin,u=e.sortable.renderOrder*Ba,l=0,c=0,f=e.parsedStyle,d=f.markerStart,_=f.markerEnd,h=f.markerStartOffset,p=f.markerEndOffset,A=[],m=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var g=e.parsedStyle.points.points,P=g.length,N=0,M=0,O=0,I=0,x=0;d&&t.isDisplayObject(d)&&h&&(N=Math.cos(x=Math.atan2(g[1][1]-g[0][1],g[1][0]-g[0][0]))*(h||0),M=Math.sin(x)*(h||0)),_&&t.isDisplayObject(_)&&p&&(O=Math.cos(x=Math.atan2(g[P-2][1]-g[P-1][1],g[P-2][0]-g[P-1][0]))*(p||0),I=Math.sin(x)*(p||0));var B=e.nodeName===t.Shape.POLYLINE;if(A[0]=g.reduce(function(e,t,r){var n=0,i=0;return 0===r?(n=N,i=M):r===P-1&&(n=O,i=I),e.push(t[0]+n,t[1]+i,B?t[2]||0:u),e},[]),e.nodeName===t.Shape.POLYGON){var D;if(r)return m=oi(A[0],[],3),{pointsBuffer:A[0],travelBuffer:[],triangles:m,instancedCount:Math.round(A[0].length/uo)};A[0].push(A[0][0],A[0][1],A[0][2]||u),(D=A[0]).push.apply(D,T(fo(A[0][0],A[0][1],A[0][2]||u,A[0][3],A[0][4],A[0][5]||u)))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var b;if(e.nodeName!==t.Shape.PATH){if(b=t.parsePath(t.convertToPath(e,z(W()))),e.nodeName===t.Shape.RECT){var L=e.parsedStyle;0>L.width&&(l+=b.rect.width),0>L.height&&(c+=b.rect.height)}}else b=e.parsedStyle.d;var F=b.absolutePath,U=b.segments,k=0,w=0,G=0,V=0,X=0;if(d&&d.parentNode&&t.isDisplayObject(d)&&h){var H=C(d.parentNode.getStartTangent(),2),Y=H[0],K=H[1];k=Math.cos(X=Math.atan2(Y[1]-K[1],Y[0]-K[0]))*(h||0),w=Math.sin(X)*(h||0)}if(_&&_.parentNode&&t.isDisplayObject(_)&&p){var j=C(_.parentNode.getEndTangent(),2),Z=j[0],q=j[1];G=Math.cos(X=Math.atan2(Z[1]-q[1],Z[0]-q[0]))*(p||0),V=Math.sin(X)*(p||0)}var Q=-1,J=-1;if(F.forEach(function(r,i){var a,o=S(a=r)||v(a)||R(a)||y(),s=o[0],f=E(o).slice(1),d=F[i+1],_=0===i&&(0!==k||0!==w),h=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==G&&0!==V;if("M"===s)J++,A[J]=[],Q=A[J].length,_?A[J].push(f[0]-l+k,f[1]-c+w,u,f[0]-l,f[1]-c,u):A[J].push(f[0]-l,f[1]-c,u);else if("L"===s)h?A[J].push(f[0]-l+G,f[1]-c+V,u):A[J].push(f[0]-l,f[1]-c,u);else if("Q"===s)qa(f[0]-l,f[1]-c,f[2]-l,f[3]-c,A[J],n),h&&A[J].push(f[2]-l+G,f[3]-c+V,u);else if("A"===s){for(var p=C(U[i].prePoint,2),m=he(p[0],p[1],f[0],f[1],f[2],f[3],f[4],f[5],f[6],void 0),g=0;m.length>g;g+=6)Qa(m[g]-l,m[g+1]-c,m[g+2]-l,m[g+3]-c,m[g+4]-l,m[g+5]-c,A[J],n);h&&A[J].push(f[5]-l+G,f[6]-c+V,u)}else if("C"===s)Qa(f[0]-l,f[1]-c,f[2]-l,f[3]-c,f[4]-l,f[5]-c,A[J],n),h&&A[J].push(f[4]-l+G,f[5]-c+V,u);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var P,N=1e-4;(Math.abs(A[J][A[J].length-2]-A[J][Q])>N||Math.abs(A[J][A[J].length-1]-A[J][Q+1])>N)&&A[J].push(A[J][Q],A[J][Q+1],u),(P=A[J]).push.apply(P,T(fo(A[J][Q],A[J][Q+1],A[J][Q+2],A[J][Q+3],A[J][Q+4],A[J][Q+5])))}}),r){var $=A[i];return{pointsBuffer:$,travelBuffer:[],triangles:m=oi($,[],3),instancedCount:Math.round($.length/uo)}}}var ee=function(e){var t;switch(e){case"bevel":t=so.JOINT_BEVEL;break;case"round":t=so.JOINT_ROUND;break;default:t=so.JOINT_MITER}return t}(s),te=function(e){var t;switch(e){case"square":t=so.CAP_SQUARE;break;case"round":t=so.CAP_ROUND;break;default:t=so.CAP_BUTT}return t}(o),re=te;te===so.CAP_ROUND&&(re=so.JOINT_CAP_ROUND),te===so.CAP_BUTT&&(re=so.JOINT_CAP_BUTT),te===so.CAP_SQUARE&&(re=so.JOINT_CAP_SQUARE);for(var ne=A[i],ie=(Math.round(0/uo)+2)*lo,ae=0,oe=[],se=[],ue=0;ne.length>ue;ue+=uo)ue>1&&(ae+=Math.sqrt(Math.pow(ne[ue]-ne[ue-uo],2)+Math.pow(ne[ue+1]-ne[ue+1-uo],2)+Math.pow(ne[ue+2]-ne[ue+2-uo],2))),se.push(ae),oe[ie++]=ne[ue],oe[ie++]=ne[ue+1],oe[ie++]=ne[ue+2]||0,oe[ie]=ee,0===ue&&te!==so.CAP_ROUND&&(oe[ie]+=te),ne.length>ue+2*uo?ne.length>ue+uo||(oe[ie]=0):oe[ie]+=re-ee,ie++;return oe[ie++]=ne[ne.length-6],oe[ie++]=ne[ne.length-5],oe[ie++]=ne[ne.length-4]||u,oe[ie++]=0,oe[0]=ne[0],oe[1]=ne[1],oe[2]=ne[2]||u,oe[3]=0,oe[4]=ne[3],oe[5]=ne[4],oe[6]=ne[5]||u,oe[7]=te===so.CAP_ROUND?te:0,{pointsBuffer:oe,travelBuffer:se,triangles:m,instancedCount:Math.round(ne.length/uo)}}function fo(e,t,r){var n=[(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e)-e,(arguments.length>4&&void 0!==arguments[4]?arguments[4]:t)-t,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:r)-r],i=.01;return[e+n[0]*i,t+n[1]*i,r+n[2]*i]}var _o=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e}(_o||{}),ho=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e}(ho||{}),po=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=_(this,r,[e,t,n,i,a,o,s])).trianglesHash=[[],[]],u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.trianglesHash=u.calcSegmentNum(i),u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){var t=co(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]}},{key:"calcSubpathIndex",value:function(e){return e.nodeName===t.Shape.PATH?this.index:0}},{key:"compareTrianglesHash",value:function(e){var t=C(this.trianglesHash,2),r=t[0],n=t[1],i=C(e,2),a=i[0],o=i[1];return r.length===a.length&&n.length===o.length&&(!r.some(function(e,t){return e!==a[t]})&&!n.some(function(e,t){return e!==o[t]}))}},{key:"shouldMerge",value:function(e,t){var n=g(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.compareTrianglesHash(i)}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=0;if(e.forEach(function(e,r){var s=co(e,!0,12,t.calcSubpathIndex(e)),u=s.triangles,l=s.pointsBuffer;if(u.length){var c=e.getGeometryBounds().halfExtents,f=[];l.forEach(function(e,t){t%3!=2&&f.push(e/c[t%3]/2)}),o+=i.length/3,i.push.apply(i,T(l)),a.push.apply(a,f),n.push.apply(n,T(u.map(function(e){return e+o})))}}),i.length){g(r,"createGeometry",this,3)([e]);var s=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:_o.PACKED_STYLE,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:ho.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ha.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length/e.length,this.geometry.setIndexBuffer(new Uint32Array(n))}}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=o(o(o({},this.material.defines),Ua(ho)),{},{INSTANCED:!0})}},{key:"updateAttribute",value:function(e,t,n,i){if(0!==e.length&&(g(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var a=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.updateVertexBuffer(_o.PACKED_STYLE,ho.PACKED_STYLE3,t,new Uint8Array(new Float32Array(a).buffer))}}}])}(Ya),Eo=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1],vo=function(e){return e[e.POINT=Wa.POSITION+1]="POINT",e[e.CAP=1+e.POINT]="CAP",e[e.DASH=1+e.CAP]="DASH",e}(vo||{}),Ro=function(e){return e[e.POSITION=Ha.POSITION]="POSITION",e[e.UV=Ha.UV]="UV",e[e.POINTA=Ha.NORMAL]="POINTA",e[e.POINTB=Ha.BARYCENTRIC]="POINTB",e[e.CAP=Ha.MAX]="CAP",e[e.DASH=Ha.MAX+1]="DASH",e}(Ro||{}),To={butt:1,round:2,square:3},Ao=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=_(this,r,[e,t,n,i,a,o,s])).renderHelper=e,u.texturePool=t,u.lightPool=n,u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=g(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Ua(Ro))}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter(function(e){return e===po}).length;return this.index-r}return 0}},{key:"createGeometry",value:function(e){var n=this;g(r,"createGeometry",this,3)([e]);var i=[],a=[],o=[],s=[],u=0;e.forEach(function(e){var r,l;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,l=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,_=d.d.absolutePath,h=d.lineCap,p=d.lineDash,E=d.lineDashOffset,v=d.markerStart,R=d.markerEnd,T=d.markerStartOffset,A=d.markerEndOffset,m=d.isBillboard,g=d.isSizeAttenuation,S=0,y=0,C=n.calcSubpathIndex(e),P=0;_.length>P;P++){if("M"===_[P][0]){if(S===C){y=P;break}S++}}r={x1:_[y][1],y1:_[y][2],x2:_[y+1][1],y2:_[y+1][2],z1:0,z2:0,lineCap:h,lineDash:p,lineDashOffset:E,isBillboard:m,isSizeAttenuation:g,markerStart:v,markerEnd:R,markerStartOffset:T,markerEndOffset:A},l=e.getTotalLength()}var N=r.x1,M=r.y1,O=r.x2,I=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,k=F.startOffsetY,w=F.endOffsetX,G=F.endOffsetY,V=n.calcDash(r,l),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;a.push(To[D]),o.push(X,W,H,b||L?1:0),i.push(N+U,M+k,x,O+w,I+G,B),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4}),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:20,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ro.POSITION,divisor:0},{format:Xe.F32_RG,bufferByteOffset:12,location:Ro.UV,divisor:0}],data:new Float32Array(Eo)}),this.geometry.setVertexBuffer({bufferIndex:vo.POINT,byteStride:24,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ro.POINTA,divisor:1},{format:Xe.F32_RGB,bufferByteOffset:12,location:Ro.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:vo.CAP,byteStride:4,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_R,bufferByteOffset:0,location:Ro.CAP,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:vo.DASH,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ro.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(g(r,"updateAttribute",this,3)([e,n,i,a]),this.updateBatchedAttribute(e,n,i,a),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];e.forEach(function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var a=e.parsedStyle,u=a.d.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,lineCap:a.lineCap,isBillboard:a.isBillboard,isSizeAttenuation:a.isSizeAttenuation,markerStart:a.markerStart,markerEnd:a.markerEnd,markerStartOffset:a.markerStartOffset,markerEndOffset:a.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,d=r.y2,_=r.z1,h=r.z2,p=o.calcOffset(r);s.push(l+p.startOffsetX,c+p.startOffsetY,_,f+p.endOffsetX,d+p.endOffsetY,h)}),this.geometry.updateVertexBuffer(vo.POINT,Ro.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var u=[];e.forEach(function(e){var t=e.getTotalLength(),r=o.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)}),this.geometry.updateVertexBuffer(vo.DASH,Ro.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];e.forEach(function(e){l.push(To[e.parsedStyle.lineCap])}),this.geometry.updateVertexBuffer(vo.CAP,Ro.CAP,n,new Uint8Array(new Float32Array(l).buffer))}}},{key:"calcOffset",value:function(e){var r=e.x1,n=e.y1,i=e.x2,a=e.y2,o=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,d=0,_=0,h=0;return o&&t.isDisplayObject(o)&&u&&(c=Math.cos(h=Math.atan2(a-n,i-r))*(u||0),f=Math.sin(h)*(u||0)),s&&t.isDisplayObject(s)&&l&&(d=Math.cos(h=Math.atan2(n-a,r-i))*(l||0),_=Math.sin(h)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:_}}},{key:"calcDash",value:function(e,t){var r=e.lineDash,n=0,i=1,a=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var o=r.reduce(function(e,t){return e+t},0);0===o?(i=1,a=0):(i=o/t,a=r[1]/o)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:a}}}],[{key:"isLine",value:function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,a=0,o=0;n.length>o;o++){if("M"===n[o][0]){if(i===r){a=o;break}i++}}if("M"===n[a][0]&&"L"===n[a+1][0]&&(void 0===n[a+2]||"M"===n[a+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var s=e.parsedStyle.points.points,u=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]),l=1;s.length-1>l;l++)if((s[l+1][0]-s[l+1][1])/(s[l][0]-s[l][1])!==u)return!1;return!0}return!1}}])}(Ya),mo=function(e){return e[e.PACKED_STYLE=Wa.POSITION+1]="PACKED_STYLE",e[e.SIZE=Wa.MAX]="SIZE",e}(mo||{}),go=function(e){return e[e.PACKED_STYLE3=Ha.MAX]="PACKED_STYLE3",e[e.SIZE=1+e.PACKED_STYLE3]="SIZE",e}(go||{}),So=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"shouldMerge",value:function(e,r){var n=g(t,"shouldMerge",this,3)([e,r]);return!!n&&this.instance.parsedStyle.src===e.parsedStyle.src}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.src;this.material.defines=o(o({},this.material.defines),Ua(go)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){g(t,"createGeometry",this,3)([e]);var r=[],n=[],i=[];e.forEach(function(e,t){var a=e.parsedStyle,o=a.x,s=a.y,u=a.z,l=a.width,c=a.height,f=a.isBillboard,d=a.billboardRotation,_=a.isSizeAttenuation;r.push(void 0===o?0:o,void 0===s?0:s,void 0===u?0:u),n.push(l,c),i.push(f?1:0,null!=d?d:0,_?1:0,0)}),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:mo.SIZE,byteStride:8,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:go.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:mo.PACKED_STYLE,byteStride:16,stepMode:Oe.INSTANCE,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:go.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Wa.UV,byteStride:8,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Ha.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})}},{key:"updateAttribute",value:function(e,r,n,i){if(0!==e.length)if(g(t,"updateAttribute",this,3)([e,r,n,i]),this.updateBatchedAttribute(e,r,n,i),"x"===n||"y"===n||"z"===n){var a=[];e.forEach(function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;a.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)}),this.geometry.updateVertexBuffer(Wa.POSITION,Ha.POSITION,r,new Uint8Array(new Float32Array(a).buffer))}else if("width"===n||"height"===n){var o=[];e.forEach(function(e){var t=e.parsedStyle;o.push(t.width,t.height)}),this.geometry.updateVertexBuffer(mo.SIZE,go.SIZE,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];e.forEach(function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)}),this.geometry.updateVertexBuffer(mo.PACKED_STYLE,go.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var u=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:u})}}}])}(Ya);function yo(e,t,r,n){var i=t.width,a=t.height;if(n){if(n.length!==i*a*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*a*r);return e.width=i,e.height=a,e.data=n,e}function Co(e,t,r,n,i,a){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*a,c=((n.y+u)*t.width+n.x)*a,f=0;i.width*a>f;f++)s[c+f]=o[l+f];return t}var Po=function(){function e(t,r){l(this,e),yo(this,t,1,r)}return u(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var a=yo({},{width:n,height:i},r);Co(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=a.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){Co(e,t,r,n,i,1)}}])}();var No=u(function e(t){l(this,e);var r={},n=[];for(var i in t){var a=t[i],o=r[i]={};for(var s in a){var u=a[+s];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c={x:0,y:0,w:u.bitmap.width+2,h:u.bitmap.height+2};n.push(c),o[s]={rect:c,metrics:u.metrics}}}}var f=function(e){var t,r=0,n=0,i=Bn(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;r+=a.w*a.h,n=Math.max(n,a.w)}}catch(e){i.e(e)}finally{i.f()}e.sort(function(e,t){return t.h-e.h});var o,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=Bn(e);try{for(c.s();!(o=c.n()).done;)for(var f=o.value,d=s.length-1;d>=0;d--){var _=s[d];if(_.w>=f.w&&_.h>=f.h){if(f.x=_.x,f.y=_.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===_.w&&f.h===_.h){var h=s.pop();s.length>d&&(s[d]=h)}else f.h===_.h?(_.x+=f.w,_.w-=f.w):f.w===_.w?(_.y+=f.h,_.h-=f.h):(s.push({x:_.x+f.w,y:_.y,w:_.w-f.w,h:f.h}),_.y+=f.h,_.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),d=new Po({width:f.w||1,height:f.h||1});for(var _ in t){var h=t[_];for(var p in h){var E=h[+p];if(E&&0!==E.bitmap.width&&0!==E.bitmap.height){var v=r[_][p].rect;Po.copy(E.bitmap,d,{x:0,y:0},{x:v.x+1,y:v.y+1},E.bitmap)}}}this.image=d,this.positions=r});var Mo=function(){return u(function e(t){l(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={},this.runtime=t},[{key:"destroy",value:function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}},{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,r,n,i,a,o){var s=this,u=[],l=a,c=o,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach(function(e){var n=u.length;Array.from(e).forEach(function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),a=r&&r[n];a&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=a.metrics.advance+i)});for(var a=l-i,o=n;u.length>o;o++)u[o].x-=f*a;l=0,c+=r}),u}},{key:"generateAtlas",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=[];this.glyphMap[r]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[r]||{});if(Array.from(new Set(s.split(""))).forEach(function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)}),l.length){var f=l.map(function(o){return t.generateSDF(e,r,n,i,a,o)}).reduce(function(e,t){return e[t.id]=t,e},{});this.glyphMap[r]=o(o({},this.glyphMap[r]),f),this.glyphAtlas=new No(this.glyphMap);var d=this.glyphAtlas.image,_=d.width,h=d.height,p=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=u.createTexture(o(o({},He(Xe.ALPHA,_,h,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([p])}}},{key:"generateSDF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=a.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new $a({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][a]||(this.textMetricsCache[t][a]=s.ctx.measureText(a).width);var u=s.draw(a),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,d=u.glyphTop,_=u.glyphAdvance;return{id:o,bitmap:new Po({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:d-24+3,advance:_}}}}])}();var Oo=function(e){return e[e.INSTANCED=Wa.POSITION+1]="INSTANCED",e[e.TEX=1+e.INSTANCED]="TEX",e}(Oo||{}),Io=function(e){return e[e.TEX=Ha.MAX]="TEX",e[e.OFFSET=1+e.TEX]="OFFSET",e}(Io||{}),xo=function(e){return e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke",e}({}),Bo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=_(this,r,[e,t,n,i,a,o,s])).packedBufferObjectMap=new WeakMap,u.tmpMat4=W(),u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.fontHash=u.calcFontHash(i),u.glyphManager=new Mo(u.context),u}return p(r,e),u(r,[{key:"calcFontHash",value:function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce(function(t,r){return t+e.parsedStyle[r]},"")}},{key:"shouldMerge",value:function(e,t){var n=g(r,"shouldMerge",this,3)([e,t]);return!!n&&(this.index===t&&this.fontHash===this.calcFontHash(e))}},{key:"createGeometry",value:function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,a=n.letterSpacing,o=void 0===a?0:a,s=r.parsedStyle.textBaseline,u=void 0===s?"alphabetic":s,l=24/(void 0===i?16:i),c=[],f=[],d=[],_=[],h=0;e.forEach(function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,a=r.dy,s=n.font,p=n.lines,E=n.height,v=n.lineHeight,R=void 0===i?0:i,A=void 0===a?0:a;"alphabetic"===u&&(u="bottom");var m=0;"middle"===u?m+=-E/2:"bottom"===u?m+=-E:"top"===u||"hanging"===u?m+=0:"ideographic"===u&&(m+=-E);var g=t.glyphManager.getAtlas(),S=t.buildTextBuffers({object:e,lines:p,fontStack:s,lineHeight:l*v,offsetX:l*R,offsetY:l*(m+A),letterSpacing:l*o,glyphAtlas:g,indicesOffset:h}),y=S.indexBuffer,C=S.charUVOffsetBuffer,P=S.charPositionsBuffer;h=S.indicesOffset;var N=_.length;_.push.apply(_,T(S.charPackedBuffer)),t.packedBufferObjectMap.set(e,[N,_.length]),d.push.apply(d,T(C)),f.push.apply(f,T(P)),c.push.apply(c,T(y))}),this.geometry.vertexCount=c.length,this.geometry.setIndexBuffer(new Uint32Array(c)),this.geometry.setVertexBuffer({bufferIndex:Oo.INSTANCED,byteStride:128,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGBA,bufferByteOffset:0,location:Ha.MODEL_MATRIX0},{format:Xe.F32_RGBA,bufferByteOffset:16,location:Ha.MODEL_MATRIX1},{format:Xe.F32_RGBA,bufferByteOffset:32,location:Ha.MODEL_MATRIX2},{format:Xe.F32_RGBA,bufferByteOffset:48,location:Ha.MODEL_MATRIX3},{format:Xe.F32_RGBA,bufferByteOffset:64,location:Ha.PACKED_COLOR},{format:Xe.F32_RGBA,bufferByteOffset:80,location:Ha.PACKED_STYLE1},{format:Xe.F32_RGBA,bufferByteOffset:96,location:Ha.PACKED_STYLE2},{format:Xe.F32_RGBA,bufferByteOffset:112,location:Ha.PICKING_COLOR}],data:new Float32Array(_)}),this.geometry.setVertexBuffer({bufferIndex:Wa.POSITION,byteStride:12,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RGB,bufferByteOffset:0,location:Ha.POSITION}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:Oo.TEX,byteStride:16,stepMode:Oe.VERTEX,attributes:[{format:Xe.F32_RG,bufferByteOffset:0,location:Io.TEX},{format:Xe.F32_RG,bufferByteOffset:8,location:Io.OFFSET}],data:new Float32Array(d)})}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=Ae.BACK,this.material.defines=o(o({},this.material.defines),Ua(Io));var t=this.instance.parsedStyle,r=t.fontSize,n=void 0===r?16:r,a=t.fontFamily,s=void 0===a?"sans-serif":a,u=t.fontWeight,l=void 0===u?"normal":u,c=t.fontStyle,f=void 0===c?"normal":c,d=t.metrics.font,_=e.map(function(e){return e.parsedStyle.text}).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+l,f,_,this.context.device);var h=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(h,"TextSDF Texture");var E=p.image,v=E.width,R=E.height;this.material.setUniforms(i(i(i(i(i(i({},xo.SDF_MAP,h),xo.SDF_MAP_SIZE,[v,R]),xo.FONT_SIZE,n),xo.GAMMA_SCALE,1),xo.STROKE_BLUR,.2),xo.HAS_STROKE,this.index))}},{key:"changeRenderOrder",value:function(e,t){for(var r=this.geometry.vertices[Oo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oo.INSTANCED].arrayStride/4,i=C(this.packedBufferObjectMap.get(e),2),a=i[0],o=i[1],s=r.slice(a,o),u=0;o-a>u;u+=n)s[u+n-1]=t*Ba;this.geometry.updateVertexBuffer(Oo.INSTANCED,Ha.MODEL_MATRIX0,a/n,new Uint8Array(s.buffer))}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(g(r,"updateAttribute",this,3)([e,n,i,a]),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[Oo.INSTANCED],u=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oo.INSTANCED].arrayStride/4;e.forEach(function(e){var r,n=e.parsedStyle,i=n.fill,a=n.stroke,l=n.opacity,c=void 0===l?1:l,f=n.fillOpacity,d=void 0===f?1:f,_=n.strokeOpacity,h=void 0===_?1:_,p=n.lineWidth,E=void 0===p?1:p,v=n.visibility,R=n.isBillboard,T=n.billboardRotation,A=n.isSizeAttenuation,m=[0,0,0,0];t.isCSSRGB(i)&&(m=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var g=[0,0,0,0];t.isCSSRGB(a)&&(g=[Number(a.r),Number(a.g),Number(a.b),255*Number(a.alpha)]);for(var S=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],y=H(o.tmpMat4,e.getWorldTransform()),P=C(o.packedBufferObjectMap.get(e),2),N=P[0],M=P[1],O=s.slice(N,M),I=0;M-N>I;I+=u)O[I+0]=y[0],O[I+1]=y[1],O[I+2]=y[2],O[I+3]=y[3],O[I+4]=y[4],O[I+5]=y[5],O[I+6]=y[6],O[I+7]=y[7],O[I+8]=y[8],O[I+9]=y[9],O[I+10]=y[10],O[I+11]=y[11],O[I+12]=y[12],O[I+13]=y[13],O[I+14]=y[14],O[I+15]=y[15],O[I+16]=Ga(m[0],m[1]),O[I+17]=Ga(m[2],m[3]),O[I+18]=Ga(g[0],g[1]),O[I+19]=Ga(g[2],g[3]),O[I+20]=c,O[I+21]=d,O[I+22]=h,O[I+23]=E,O[I+24]="hidden"!==v?1:0,O[I+25]=R?1:0,O[I+26]=A?1:0,O[I+27]=null!=T?T:0,O[I+28]=S[0],O[I+29]=S[1],O[I+30]=S[2];o.geometry.updateVertexBuffer(Oo.INSTANCED,Ha.MODEL_MATRIX0,N/u,new Uint8Array(O.buffer))})}}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,a=e.fontStack,o=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,d=n.parsedStyle,_=d.textAlign,h=void 0===_?"start":_,p=d.fill,E=d.stroke,v=d.opacity,R=void 0===v?1:v,A=d.fillOpacity,m=void 0===A?1:A,g=d.strokeOpacity,S=void 0===g?1:g,y=d.lineWidth,C=void 0===y?1:y,P=d.visibility,N=d.isBillboard,M=d.billboardRotation,O=d.isSizeAttenuation,I=d.x,x=void 0===I?0:I,B=d.y,D=void 0===B?0:B,b=d.z,L=void 0===b?0:b,F=[0,0,0,0];t.isCSSRGB(p)&&(F=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var U=[0,0,0,0];t.isCSSRGB(E)&&(U=[Number(E.r),Number(E.g),Number(E.b),255*Number(E.alpha)]);var k=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],w=H(this.tmpMat4,n.getWorldTransform()),G=[],V=[],X=[],W=[],Y=f,z=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],a=t[i.fontStack],o=a&&a[i.glyph];if(o){var s=o.rect;if(s){var u=o.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(o.metrics.left-4)*i.scale-u+l[0],f=(-o.metrics.top-4)*i.scale+l[1],d=c+s.w*i.scale,_=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:_},br:{x:d,y:_},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,a,o,h,s,u,l),c.positions);return z.forEach(function(e){var t=[];t.push.apply(t,T(w));var r=[].concat(t,[Ga(F[0],F[1]),Ga(F[2],F[3]),Ga(U[0],U[1]),Ga(U[2],U[3]),R,m,S,C,"hidden"!==P?1:0,N?1:0,O?1:0,null!=M?M:0],T(k),[n.sortable.renderOrder*Ba]);G.push.apply(G,T(r).concat(T(r),T(r),T(r))),V.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),V.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),V.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),V.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),X.push(x,D,L,x,D,L,x,D,L,x,D,L),W.push(0+Y,2+Y,1+Y),W.push(2+Y,0+Y,3+Y),Y+=4}),{indexBuffer:W,charUVOffsetBuffer:V,charPositionsBuffer:X,charPackedBuffer:G,indicesOffset:Y}}},{key:"destroy",value:function(){g(r,"destroy",this,3)([]),this.glyphManager.destroy()}}])}(Ya),Do=function(e){function r(){var e;l(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=_(this,r,[].concat(n))).mergeXYZIntoModelMatrix=!1,e}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,n){var i=g(r,"shouldMerge",this,3)([e,n]);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,n,i){0!==e.length&&(g(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i))}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,g(r,"createGeometry",this,3)([e]),this.geometry.build(e),this.observeGeometryChanged()}}])}(Ya),bo=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(Za),this.needDrawStrokeSeparately(e)&&t.push(oo),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every(function(e){return 0!==e});return!s||u&&a>0&&(1>o||l)}}])}(Da),Lo=function(e){function r(){return l(this,r),_(this,r,arguments)}return p(r,e),u(r,[{key:"getDrawcallCtors",value:function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=r.opacity,o=r.strokeOpacity,s=r.lineWidth,u=i&&!i.isNone,l=oo.calcSubpathNum(e),c=[];if(!(e.nodeName===t.Shape.POLYLINE||null!=n&&n.isNone))for(var f=0;l>f;f++)c.push(po);for(var d=0;l>d;d++)if(0!==o&&0!==a&&0!==s&&u){var _=Ao.isLine(e,d);c.push(_?Ao:oo)}return c}}])}(Da),Fo=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[So]}}])}(Da),Uo=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Bo),t.push(Bo),t}},{key:"beforeUploadUBO",value:function(e,t){t.material.setUniforms(i({},xo.HAS_STROKE,1===t.instance.renderable3D.drawcalls.length?0:1-t.index))}}])}(Da),ko=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[Ao]}}])}(Da),wo=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[Do]}}])}(Da),Go=function(e){function t(){return l(this,t),_(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,a=i&&i.length&&i.some(function(e){return e!==i[0]});return null!=n&&n.isNone||a||t.push(Za),a&&t.push(po),(a||this.needDrawStrokeSeparately(e))&&t.push(oo),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every(function(e){return 0!==e});return!s||u&&a>0&&(1>o||l)}}])}(Da),Vo=1,Xo=function(){return u(function e(t,r,n,i){l(this,e),this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=t,this.rendererFactory=r,this.texturePool=n,this.lightPool=i},[{key:"destroy",value:function(){this.drawcalls.forEach(function(e){e.destroy()}),this.drawcalls=[],this.pendingUpdatePatches={}}},{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.drawcalls.forEach(function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var a=t.renderHelper.renderInstManager.newRenderInst();a.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(a,i),t.renderHelper.renderInstManager.submitRenderInst(a,e),r||n.objects.forEach(function(e){e.renderable.dirty=!1})})}},{key:"attach",value:function(e){this.context=e}},{key:"add",value:function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach(function(i,a,o){var s=t.drawcalls.find(function(t){return i===t.constructor&&t.index===a&&t.maxInstances>t.objects.length&&t.shouldMerge(e,a)});s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,o,a,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[a]=s,s.geometryDirty=!0)})}}},{key:"remove",value:function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach(function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach(function(e){e.destroy()})}}),r.drawcalls=[])}},{key:"updateAttribute",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.renderable3D,o=this.rendererFactory[e.nodeName];if(o){var s=o.getDrawcallCtors(e);if(s.forEach(function(s,u,l){var c=a.drawcalls.find(function(e){return e&&e.index===u&&e.constructor===s});if(c||((c=a.drawcalls[u])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&n.drawcalls.splice(n.drawcalls.indexOf(c),1),a.drawcalls[a.drawcalls.indexOf(c)]=void 0),(c=n.drawcalls.find(function(t){return s===t.constructor&&t.index===u&&t.maxInstances>t.objects.length&&t.shouldMerge(e,u)}))?c.geometryDirty=!0:((c=new s(n.renderHelper,n.texturePool,n.lightPool,e,l,u,n.context)).renderer=o,c.init(),n.drawcalls.push(c)),c.objects.push(e),a.drawcalls[u]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,u)){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;n.pendingUpdatePatches[d]||(n.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[d].objectIndices.indexOf(f)&&n.pendingUpdatePatches[d].objectIndices.push(f)}}else n.remove(e),n.add(e);else n.remove(e),n.add(e)}),a.drawcalls.length>s.length)for(var u=a.drawcalls.length-1;u>=s.length;u--){var l=a.drawcalls[u];l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(l),1),a.drawcalls.pop()}}}},{key:"changeRenderOrder",value:function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach(function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)})}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=Vo++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach(function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,a=r.name,o=r.value;i.sort(function(e,t){return e-t});var s=[];i.forEach(function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])}),s.forEach(function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],a,o)})}),this.pendingUpdatePatches={}}}])}(),Wo=function(){return u(function e(t,r){l(this,e),this.textureCache={},this.context=t,this.runtime=r},[{key:"getOrCreateTexture",value:function(e,t,r,n){var i,a=this,s="string"==typeof t?t:t.src||"";if(s&&this.textureCache[s])(i=this.textureCache[s]).emit(Ie.LOADED);else if(i=e.createTexture(o({format:Xe.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:xe.TEXTURE_2D,usage:Be.SAMPLED,pixelStore:{unpackFlipY:!1}},r)),s&&(this.textureCache[s]=i),k(t)){var u=this.context.config.createImage();u&&(u.onload=function(){var e=function(e){a.textureCache[s].setImageData([e]),a.textureCache[s].emit(Ie.LOADED),a.context.renderingService.dirty(),n&&n(a.textureCache[s],e)};a.runtime.globalThis.createImageBitmap?a.runtime.globalThis.createImageBitmap(u).then(function(t){return e(t)}).catch(function(){e(u)}):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=t)}else i.setImageData([t]),i.emit(Ie.LOADED),this.context.renderingService.dirty();return i}},{key:"getOrCreateCanvas",value:function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,i=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),u=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=i;var l=this.context.imagePool;t.forEach(function(e){var t=l.getOrCreateGradient(o(o({type:e.type},e.value),{},{width:n,height:i,min:[0,0]}),u);u.fillStyle=t,u.fillRect(0,0,n,i)})}},{key:"getOrCreatePattern",value:function(e,r,n){var i,a=e.image,o=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),_=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);if(d.width=l,d.height=c,k(a)){var h=this.context.imagePool.getImageSync(a,r,n);i=null==h?void 0:h.img}else i=a;var p=i&&_.createPattern(i,o);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));p.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}_.fillStyle=p,_.fillRect(0,0,l,c)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}])}(),Ho=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l(this,r),(e=_(this,r)).name="device-renderer",e.parameters={toneMapping:bi.NONE,toneMappingExposure:1},e.options=t,e}return p(r,e),u(r,[{key:"init",value:function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new vi;var n=new aa(this.parameters),a=new hi,o=new Wo(this.context,e),s=new Ri,u=new bo,l=new Lo,c=(i(i(i(i(i(i(i(i(i(i(r={},t.Shape.CIRCLE,u),t.Shape.ELLIPSE,u),t.Shape.POLYLINE,l),t.Shape.PATH,l),t.Shape.POLYGON,l),t.Shape.RECT,new Go),t.Shape.IMAGE,new Fo),t.Shape.LINE,new ko),t.Shape.TEXT,new Uo),t.Shape.MESH,new wo),i(i(r,t.Shape.GROUP,void 0),t.Shape.HTML,void 0)),f=new Xo(n,c,o,a),d=new Ia(n,a,o,f,this.options);this.addRenderingPlugin(d),this.addRenderingPlugin(new xa(n,d,s,f))}},{key:"destroy",value:function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]}},{key:"getRenderGraphPlugin",value:function(){return this.plugins[0]}},{key:"getDevice",value:function(){return this.getRenderGraphPlugin().getDevice()}},{key:"getSwapChain",value:function(){return this.getRenderGraphPlugin().getSwapChain()}},{key:"loadTexture",value:function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)}},{key:"toDataURL",value:function(e){return this.getRenderGraphPlugin().toDataURL(e)}},{key:"setParameters",value:function(e){this.parameters=o(o({},this.parameters),e)}}])}(t.AbstractRendererPlugin),Yo=Object.freeze({__proto__:null,AntialiasingMode:fa,Batch:Da,BufferGeometry:Ca,DeviceProgram:Ti,DynamicUniformBuffer:Ai,FILL_TEXTURE_MAPPING:Xa,Fog:Aa,FogType:Ta,GeometryEvent:ya,HashMap:Ci,ImageDrawcall:So,Instanced:Ya,InstancedFillDrawcall:po,InstancedLineDrawcall:Ao,InstancedPathDrawcall:oo,JOINT_TYPE:so,Light:va,Material:La,MaterialEvent:ba,Mesh:Ei,MeshDrawcall:Do,Plugin:Ho,RGAttachmentSlot:Li,RenderCache:Di,RenderGraphPlugin:Ia,RenderHelper:aa,RenderInst:$i,RenderInstExecutionOrder:ta,RenderInstFlags:Ji,RenderInstList:ra,RenderInstManager:ia,Renderable3D:_i,RendererLayer:Vi,SDFDrawcall:Za,ShaderMaterial:Fa,SingleSampledTexture:ki,TemporalTexture:pa,TextDrawcall:Bo,TextUniform:xo,TextureMapping:ha,TexturePool:Wo,TinySDF:$a,ToneMapping:bi,VertexAttributeBufferIndex:Wa,VertexAttributeLocation:Ha,bezierCurveTo:Qa,compareDefines:ka,definedProps:wa,enumToObject:Ua,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Qi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:gi,hashCodeNumberUpdate:mi,makeAttachmentClearDescriptor:sa,makeBackbufferDescSimple:_a,makeDataBuffer:ma,makeDepthKey:Xi,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&Vi.TRANSLUCENT?Ki(e):Yi(e,t)},makeSortKeyOpaque:Yi,makeSortKeyTranslucent:Ki,nullHashFunc:Si,opaqueBlackFullClearRenderPassDescriptor:la,opaqueWhiteFullClearRenderPassDescriptor:ca,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Ue.NEGATIVE_ONE?function(e){ne(e,Zi,e)}(e):t===Ue.ZERO&&function(e){ne(e,qi,e)}(e))},pushFXAAPass:Ma,quadCurveTo:qa,renderInstCompareNone:null,renderInstCompareSortKey:ea,segmentInstanceGeometry:Eo,setBackbufferDescSimple:da,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=!!(e>>>31&1),n=Xi(t,r,arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536);return r?ji(e,n):zi(e,n)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?ji(e,t):zi(e,t)},setSortKeyLayer:Wi,setSortKeyOpaqueDepth:zi,setSortKeyProgramKey:Hi,setSortKeyTranslucentDepth:ji,standardFullClearRenderPassDescriptor:ua,updateBuffer:co}),zo=function(){return u(function e(t){l(this,e),this.canvasConfig=t.config,this.deviceRendererPlugin=t.deviceRendererPlugin},[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=k(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.deviceRendererPlugin.getDevice().canvasContext}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){if(this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=F(b().mark(function e(t){return b().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}},e)})),function(t){return e.apply(this,arguments)})}]);var e}(),Ko=function(e){function t(e,r){var n;return l(this,t),(n=_(this,t)).name="webgpu-context-register",n.rendererPlugin=e,n.config=r,n}return p(t,e),u(t,[{key:"init",value:function(){this.context.ContextService=zo,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new xn({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),jo=function(e){function r(e){var n;l(this,r),(n=_(this,r,[o({enableSizeAttenuation:!1},e)])).clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new Ho;return n.registerPlugin(new Ko(i,e)),n.registerPlugin(new t.ImageLoader.Plugin),n.registerPlugin(i),n.registerPlugin(new t.DomInteraction.Plugin),n.registerPlugin(new t.HTMLRenderer.Plugin),n}return p(r,e),u(r)}(t.AbstractRenderer);Object.defineProperty(e,"DomInteraction",{enumerable:!0,get:function(){return t.DomInteraction}}),Object.defineProperty(e,"HTMLRenderer",{enumerable:!0,get:function(){return t.HTMLRenderer}}),e.DeviceRenderer=Yo,e.Renderer=jo});
|
|
29
29
|
//# sourceMappingURL=index.umd.min.js.map
|