@antv/g-webgpu 1.9.1 → 1.9.3

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.
@@ -1,2 +1,2 @@
1
- !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";var r=function(e,t){return r=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])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=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},i.apply(this,arguments)};function o(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}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(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(a,s)}u((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),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 u(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 l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var f="undefined"!=typeof Float32Array?Float32Array:Array;function p(){var e=new f(16);return f!=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 d(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 h(e,t,r,n,i,o,a,s,u,l,c,p,d,h,_,E){var R=new f(16);return R[0]=e,R[1]=t,R[2]=r,R[3]=n,R[4]=i,R[5]=o,R[6]=a,R[7]=s,R[8]=u,R[9]=l,R[10]=c,R[11]=p,R[12]=d,R[13]=h,R[14]=_,R[15]=E,R}function _(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 E(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}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var R,m=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],p=t[9],d=t[10],h=t[11],_=t[12],E=t[13],R=t[14],m=t[15],T=r[0],v=r[1],g=r[2],A=r[3];return e[0]=T*n+v*s+g*f+A*_,e[1]=T*i+v*u+g*p+A*E,e[2]=T*o+v*l+g*d+A*R,e[3]=T*a+v*c+g*h+A*m,e[4]=(T=r[4])*n+(v=r[5])*s+(g=r[6])*f+(A=r[7])*_,e[5]=T*i+v*u+g*p+A*E,e[6]=T*o+v*l+g*d+A*R,e[7]=T*a+v*c+g*h+A*m,e[8]=(T=r[8])*n+(v=r[9])*s+(g=r[10])*f+(A=r[11])*_,e[9]=T*i+v*u+g*p+A*E,e[10]=T*o+v*l+g*d+A*R,e[11]=T*a+v*c+g*h+A*m,e[12]=(T=r[12])*n+(v=r[13])*s+(g=r[14])*f+(A=r[15])*_,e[13]=T*i+v*u+g*p+A*E,e[14]=T*o+v*l+g*d+A*R,e[15]=T*a+v*c+g*h+A*m,e};function T(e,t,r){var n=new f(3);return n[0]=e,n[1]=t,n[2]=r,n}function v(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function g(e,t,r,n,i,o,a,s,u,l){var c,f,p,d,h,_=e,E=t,R=r,m=n,T=s,A=u,y=120*Math.PI/180,S=Math.PI/180*(+i||0),C=[];if(l)f=l[0],p=l[1],d=l[2],h=l[3];else{E=(c=v(_,E,-S)).y;var O=((_=c.x)-(T=(c=v(T,A,-S)).x))/2,I=(E-(A=c.y))/2,P=O*O/(R*R)+I*I/(m*m);P>1&&(R*=P=Math.sqrt(P),m*=P);var N=R*R,M=m*m,x=(o===a?-1:1)*Math.sqrt(Math.abs((N*M-N*I*I-M*O*O)/(N*I*I+M*O*O)));d=x*R*I/m+(_+T)/2,f=Math.asin(((E-(h=x*-m*O/R+(E+A)/2))/m*1e9>>0)/1e9),p=Math.asin(((A-h)/m*1e9>>0)/1e9),0>(f=d>_?Math.PI-f:f)&&(f=2*Math.PI+f),0>(p=d>T?Math.PI-p:p)&&(p=2*Math.PI+p),a&&f>p&&(f-=2*Math.PI),!a&&p>f&&(p-=2*Math.PI)}var D=p-f;if(Math.abs(D)>y){var B=p,L=T,F=A;C=g(T=d+R*Math.cos(p=f+y*(a&&p>f?1:-1)),A=h+m*Math.sin(p),R,m,i,0,a,L,F,[p,B,d,h])}D=p-f;var b=Math.cos(f),U=Math.sin(f),G=Math.cos(p),w=Math.sin(p),k=Math.tan(D/4),V=4/3*R*k,W=4/3*m*k,X=[_,E],H=[_+V*U,E-W*b],Y=[T+V*w,A-W*G],K=[T,A];if(H[0]=2*X[0]-H[0],H[1]=2*X[1]-H[1],l)return H.concat(Y,K,C);for(var z=[],j=0,q=(C=H.concat(Y,K,C)).length;q>j;j+=1)z[j]=j%2?v(C[j-1],C[j],S).y:v(C[j],C[j+1],S).x;return z}R=new f(3),f!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0);var A=function(e){return null==e},y={}.toString,S=function(e,t){return y.call(e)==="[object "+t+"]"},C=function(e){return S(e,"String")},O=function(e,t,r){return t>e?t:e>r?r:e},I=function(e){return S(e,"Number")},P={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 o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),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 a(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,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},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,o,a){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,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var p,d=c.length;for(l=0;d>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(p=1,u=Array(f-1);f>p;p++)u[p-1]=arguments[p];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);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[o]=1===l.length?l[0]:l:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(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}(P);var N=P.exports,M={exports:{}};function x(e,t,r){r=r||2;var n,i,o,a,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,p=D(e,0,f,r,!0),d=[];if(!p||p.next===p.prev)return d;if(c&&(p=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=D(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(X(a));for(s.sort(w),i=0;s.length>i;i++)r=B(r=k(s[i],r),r.next);return r}(e,t,p,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var h=r;f>h;h+=r)n>(s=e[h])&&(n=s),i>(u=e[h+1])&&(i=u),s>o&&(o=s),u>a&&(a=u);l=0!==(l=Math.max(o-n,a-i))?1/l:0}return L(p,d,r,n,i,l),d}function D(e,t,r,n,i){var o,a;if(i===re(e,t,r,n)>0)for(o=t;r>o;o+=n)a=$(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=$(o,e[o],e[o+1],a);return a&&z(a,a.next)&&(ee(a),a=a.next),a}function B(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!z(n,n.next)&&0!==K(n.prev,n,n.next))n=n.next;else{if(ee(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function L(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=W(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,o,a,s,u,l=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,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--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,l*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?b(e,n,i,o):F(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),ee(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?L(e=U(B(e),t,r),t,r,n,i,o,2):2===a&&G(e,t,r,n,i,o):L(B(e),t,r,n,i,o,1);break}}}function F(e){var t=e.prev,r=e,n=e.next;if(K(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(H(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&K(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function b(e,t,r,n){var i=e.prev,o=e,a=e.next;if(K(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,u=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,l=W(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=W(s,u,t,r,n),f=e.prevZ,p=e.nextZ;f&&f.z>=l&&p&&c>=p.z;){if(f!==e.prev&&f!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&K(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&K(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=l;){if(f!==e.prev&&f!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&K(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&c>=p.z;){if(p!==e.prev&&p!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&K(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function U(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!z(i,o)&&j(i,n,n.next,o)&&Q(i,o)&&Q(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),ee(n),ee(n.next),n=e=o),n=n.next}while(n!==e);return B(n)}function G(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Y(a,s)){var u=J(a,s);return a=B(a,a.next),u=B(u,u.next),L(a,t,r,n,i,o),void L(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function w(e,t){return e.x-t.x}function k(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var u,l=r,c=r.x,f=r.y,p=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!H(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),Q(n,e)&&(p>u||u===p&&(n.x>r.x||n.x===r.x&&V(r,n)))&&(r=n,p=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=J(r,e),i=B(r,r.next);return B(n,n.next),t===r?i:t}function V(e,t){return 0>K(e.prev,e,t.prev)&&0>K(t.next,e,e.next)}function W(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function X(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 H(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function Y(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&&j(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Q(e,t)&&Q(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(K(e.prev,e,t.prev)||K(e,t.prev,t))||z(e,t)&&K(e.prev,e,e.next)>0&&K(t.prev,t,t.next)>0)}function K(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function z(e,t){return e.x===t.x&&e.y===t.y}function j(e,t,r,n){var i=Z(K(e,t,r)),o=Z(K(e,t,n)),a=Z(K(r,n,e)),s=Z(K(r,n,t));return i!==o&&a!==s||(!(0!==i||!q(e,r,t))||(!(0!==o||!q(e,n,t))||(!(0!==a||!q(r,e,n))||!(0!==s||!q(r,t,n)))))}function q(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 Z(e){return e>0?1:0>e?-1:0}function Q(e,t){return 0>K(e.prev,e,e.next)?K(e,t,e.next)>=0&&K(e,e.prev,t)>=0:0>K(e,t,e.prev)||0>K(e,e.next,t)}function J(e,t){var r=new te(e.i,e.x,e.y),n=new te(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function $(e,t,r,n){var i=new te(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 ee(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 te(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function re(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}M.exports=x,M.exports.default=x,x.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(re(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(re(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var u=0;for(a=0;n.length>a;a+=3){var l=n[a]*r,c=n[a+1]*r,f=n[a+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===o&&0===u?0:Math.abs((u-o)/o)},x.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 o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var ne=M.exports;function ie(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function oe(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function ae(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function se(e,t,r,n,i,o,a,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=ie(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,u){var l=ae(e,r,i,a,u),c=ae(t,n,o,s,u),f=oe(e,t,r,n,u),p=oe(r,n,i,o,u),d=oe(i,o,a,s,u),h=oe(f.x,f.y,p.x,p.y,u),_=oe(p.x,p.y,d.x,d.y,u);return[[e,t,f.x,f.y,h.x,h.y,l,c],[l,c,_.x,_.y,d.x,d.y,a,s]]}(e,t,r,n,i,o,a,s,.5),p=c(c([],l(f[0]),!1),[u-1],!1),d=c(c([],l(f[1]),!1),[u-1],!1);return se.apply(void 0,c([],l(p),!1))+se.apply(void 0,c([],l(d),!1))}function ue(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function le(e,t,r,n,i,o,a){if(0===a)return(ie(e,t,r,n)+ie(r,n,i,o)+ie(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=ue(e,r,i,a),u=ue(t,n,o,a),l=oe(e,t,r,n,a),c=oe(r,n,i,o,a);return[[e,t,l.x,l.y,s,u],[s,u,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),u=s[0],f=s[1];return u.push(a-1),f.push(a-1),le.apply(void 0,c([],l(u),!1))+le.apply(void 0,c([],l(f),!1))}var ce,fe,pe,de,he,_e,Ee,Re,me,Te,ve,ge,Ae,ye,Se,Ce,Oe,Ie,Pe,Ne,Me,xe,De,Be,Le,Fe,be,Ue=function(){function e(){this.meshes=[]}return e.tag="c-renderable-3d",e}(),Ge=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=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},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),we=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0,anchor:[.5,.5,.5]},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),ke=function(){function e(){}return e.prototype.update=function(e){var t=e.geometry.computeBoundingBox(),r=t.getMax(),n=t.getMin();return{width:r[0]-n[0],height:r[1]-n[1],depth:r[2]-n[2]}},e}(),Ve=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=l(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}();function We(e,t,r,n){return{dimension:Ce.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:Oe.Sampled}}function Xe(e){return e}function He(e,t,r){return e<<16|t<<8|r}function Ye(e){return e>>>8&255}function Ke(e){return e>>>16&255}function ze(e){return 255&e}function je(e){switch(e){case Be.F32:case Be.U32:case Be.S32:return 4;case Be.U16:case Be.S16:case Be.F16:return 2;case Be.U8:case Be.S8:return 1;default:throw Error("whoops")}}function qe(e){return je(Ke(e))}function Ze(e){var t=ze(e);if(t&Fe.Depth)return Ne.Depth;if(t&Fe.Normalized)return Ne.Float;var r=Ke(e);if(r===Be.F16||r===Be.F32)return Ne.Float;if(r===Be.U8||r===Be.U16||r===Be.U32)return Ne.Uint;if(r===Be.S8||r===Be.S16||r===Be.S32)return Ne.Sint;throw Error("whoops")}function Qe(e,t){if(void 0===t&&(t=""),!e)throw console.error(Error().stack),Error("Assert fail: ".concat(t))}function Je(e){if(null!=e)return e;throw Error("Missing object")}function $e(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function et(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function tt(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function rt(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"}(ce||(ce={})),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.InputState=7]="InputState",e[e.RenderPipeline=8]="RenderPipeline",e[e.ComputePipeline=9]="ComputePipeline",e[e.Readback=10]="Readback",e[e.QueryPool=11]="QueryPool"}(fe||(fe={})),function(e){e[e.Never=512]="Never",e[e.Less=513]="Less",e[e.Equal=514]="Equal",e[e.LessEqual=515]="LessEqual",e[e.Greater=516]="Greater",e[e.NotEqual=517]="NotEqual",e[e.GreaterEqual=518]="GreaterEqual",e[e.Always=519]="Always"}(pe||(pe={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(de||(de={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(he||(he={})),function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.Src=768]="Src",e[e.OneMinusSrc=769]="OneMinusSrc",e[e.Dst=774]="Dst",e[e.OneMinusDst=775]="OneMinusDst",e[e.SrcAlpha=770]="SrcAlpha",e[e.OneMinusSrcAlpha=771]="OneMinusSrcAlpha",e[e.DstAlpha=772]="DstAlpha",e[e.OneMinusDstAlpha=773]="OneMinusDstAlpha"}(_e||(_e={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(Ee||(Ee={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(Re||(Re={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(me||(me={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(Te||(Te={})),function(e){e[e.Points=0]="Points",e[e.Triangles=1]="Triangles",e[e.TriangleStrip=2]="TriangleStrip",e[e.Lines=3]="Lines",e[e.LineStrip=4]="LineStrip"}(ve||(ve={})),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"}(ge||(ge={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(Ae||(Ae={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(ye||(ye={})),function(e){e.LOADED="loaded"}(Se||(Se={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(Ce||(Ce={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(Oe||(Oe={})),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.AllChannels=15]="AllChannels"}(Ie||(Ie={})),function(e){e[e.Keep=7680]="Keep",e[e.Zero=0]="Zero",e[e.Replace=7681]="Replace",e[e.Invert=5386]="Invert",e[e.IncrementClamp=7682]="IncrementClamp",e[e.DecrementClamp=7683]="DecrementClamp",e[e.IncrementWrap=34055]="IncrementWrap",e[e.DecrementWrap=34056]="DecrementWrap"}(Pe||(Pe={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Ne||(Ne={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(Me||(Me={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(xe||(xe={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(De||(De={})),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.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(Be||(Be={})),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"}(Le||(Le={})),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"}(Fe||(Fe={})),function(e){e[e.ALPHA=He(Be.U8,Le.A,Fe.None)]="ALPHA",e[e.F16_R=He(Be.F16,Le.R,Fe.None)]="F16_R",e[e.F16_RG=He(Be.F16,Le.RG,Fe.None)]="F16_RG",e[e.F16_RGB=He(Be.F16,Le.RGB,Fe.None)]="F16_RGB",e[e.F16_RGBA=He(Be.F16,Le.RGBA,Fe.None)]="F16_RGBA",e[e.F32_R=He(Be.F32,Le.R,Fe.None)]="F32_R",e[e.F32_RG=He(Be.F32,Le.RG,Fe.None)]="F32_RG",e[e.F32_RGB=He(Be.F32,Le.RGB,Fe.None)]="F32_RGB",e[e.F32_RGBA=He(Be.F32,Le.RGBA,Fe.None)]="F32_RGBA",e[e.U8_R=He(Be.U8,Le.R,Fe.None)]="U8_R",e[e.U8_R_NORM=He(Be.U8,Le.R,Fe.Normalized)]="U8_R_NORM",e[e.U8_RG=He(Be.U8,Le.RG,Fe.None)]="U8_RG",e[e.U8_RG_NORM=He(Be.U8,Le.RG,Fe.Normalized)]="U8_RG_NORM",e[e.U8_RGB=He(Be.U8,Le.RGB,Fe.None)]="U8_RGB",e[e.U8_RGB_NORM=He(Be.U8,Le.RGB,Fe.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=He(Be.U8,Le.RGB,Fe.sRGB|Fe.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=He(Be.U8,Le.RGBA,Fe.None)]="U8_RGBA",e[e.U8_RGBA_NORM=He(Be.U8,Le.RGBA,Fe.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=He(Be.U8,Le.RGBA,Fe.sRGB|Fe.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=He(Be.U16,Le.R,Fe.None)]="U16_R",e[e.U16_R_NORM=He(Be.U16,Le.R,Fe.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=He(Be.U16,Le.RG,Fe.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=He(Be.U16,Le.RGBA,Fe.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=He(Be.U16,Le.RGB,Fe.None)]="U16_RGB",e[e.U32_R=He(Be.U32,Le.R,Fe.None)]="U32_R",e[e.U32_RG=He(Be.U32,Le.RG,Fe.None)]="U32_RG",e[e.S8_R=He(Be.S8,Le.R,Fe.None)]="S8_R",e[e.S8_R_NORM=He(Be.S8,Le.R,Fe.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=He(Be.S8,Le.RG,Fe.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=He(Be.S8,Le.RGB,Fe.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=He(Be.S8,Le.RGBA,Fe.Normalized)]="S8_RGBA_NORM",e[e.S16_R=He(Be.S16,Le.R,Fe.None)]="S16_R",e[e.S16_RG=He(Be.S16,Le.RG,Fe.None)]="S16_RG",e[e.S16_RG_NORM=He(Be.S16,Le.RG,Fe.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=He(Be.S16,Le.RGB,Fe.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=He(Be.S16,Le.RGBA,Fe.None)]="S16_RGBA",e[e.S16_RGBA_NORM=He(Be.S16,Le.RGBA,Fe.Normalized)]="S16_RGBA_NORM",e[e.S32_R=He(Be.S32,Le.R,Fe.None)]="S32_R",e[e.U16_RGBA_5551=He(Be.U16_PACKED_5551,Le.RGBA,Fe.Normalized)]="U16_RGBA_5551",e[e.BC1=He(Be.BC1,Le.RGBA,Fe.Normalized)]="BC1",e[e.BC1_SRGB=He(Be.BC1,Le.RGBA,Fe.Normalized|Fe.sRGB)]="BC1_SRGB",e[e.BC2=He(Be.BC2,Le.RGBA,Fe.Normalized)]="BC2",e[e.BC2_SRGB=He(Be.BC2,Le.RGBA,Fe.Normalized|Fe.sRGB)]="BC2_SRGB",e[e.BC3=He(Be.BC3,Le.RGBA,Fe.Normalized)]="BC3",e[e.BC3_SRGB=He(Be.BC3,Le.RGBA,Fe.Normalized|Fe.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=He(Be.BC4_UNORM,Le.R,Fe.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=He(Be.BC4_SNORM,Le.R,Fe.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=He(Be.BC5_UNORM,Le.RG,Fe.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=He(Be.BC5_SNORM,Le.RG,Fe.Normalized)]="BC5_SNORM",e[e.D24=He(Be.D24,Le.R,Fe.Depth)]="D24",e[e.D24_S8=He(Be.D24S8,Le.RG,Fe.Depth|Fe.Stencil)]="D24_S8",e[e.D32F=He(Be.D32F,Le.R,Fe.Depth)]="D32F",e[e.D32F_S8=He(Be.D32FS8,Le.RG,Fe.Depth|Fe.Stencil)]="D32F_S8",e[e.U8_RGB_RT=He(Be.U8,Le.RGB,Fe.RenderTarget|Fe.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=He(Be.U8,Le.RGBA,Fe.RenderTarget|Fe.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=He(Be.U8,Le.RGBA,Fe.RenderTarget|Fe.Normalized|Fe.sRGB)]="U8_RGBA_RT_SRGB"}(be||(be={}));var nt=rt(0,0,0,0),it=rt(0,0,0,1),ot=rt(1,1,1,0),at=rt(1,1,1,1),st=!0;function ut(e,t){if(void 0===t&&(t=st),!t)return e;switch(e){case pe.Less:return pe.Greater;case pe.LessEqual:return pe.GreaterEqual;case pe.GreaterEqual:return pe.LessEqual;case pe.Greater:return pe.Less;default:return e}}function lt(e,t){return null!=e?e:t}function ct(e){return void 0===e?null:e}function ft(e,t,r){e.length=t,e.fill(r)}function pt(e,t){var r=t-1;return e+r&~r}function dt(e,t){return((e+t-1)/t|0)*t}function ht(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}function _t(e,t,r){var n=ht(e,t,r);e.splice(n,0,t)}function Et(e,t,r){return r?e|=t:e&=~t,e}function Rt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function mt(e,t,r){for(void 0===r&&(r="0");t>e.length;)e="".concat(r).concat(e);return e}function Tt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function vt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Tt(e.rgbBlendState,t.rgbBlendState),Tt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function gt(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=vt(e[r],t[r])}function At(e,t){void 0!==t.attachmentsState&&gt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&et(e.blendConstant,t.blendConstant),e.depthCompare=lt(t.depthCompare,e.depthCompare),e.depthWrite=lt(t.depthWrite,e.depthWrite),e.stencilCompare=lt(t.stencilCompare,e.stencilCompare),e.stencilWrite=lt(t.stencilWrite,e.stencilWrite),e.stencilPassOp=lt(t.stencilPassOp,e.stencilPassOp),e.stencilRef=lt(t.stencilRef,e.stencilRef),e.cullMode=lt(t.cullMode,e.cullMode),e.frontFace=lt(t.frontFace,e.frontFace),e.polygonOffset=lt(t.polygonOffset,e.polygonOffset)}function yt(e){var t=Object.assign({},e);return t.attachmentsState=[],gt(t.attachmentsState,e.attachmentsState),t.blendConstant=tt(t.blendConstant),t}function St(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)}var Ct={blendMode:Ee.Add,blendSrcFactor:_e.One,blendDstFactor:_e.Zero},Ot={attachmentsState:[{channelWriteMask:Ie.RGB,rgbBlendState:Ct,alphaBlendState:Ct}],blendConstant:tt(ot),depthWrite:!0,depthCompare:pe.LessEqual,stencilCompare:pe.Always,stencilWrite:!1,stencilPassOp:Pe.Keep,stencilRef:0,cullMode:he.None,frontFace:de.CCW,polygonOffset:!1};function It(e,t){void 0===e&&(e=null),void 0===t&&(t=Ot);var r=yt(t);return null!==e&&At(r,e),r}var Pt=It({depthCompare:pe.Always,depthWrite:!1},Ot);function Nt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],gt(e.attachmentsState,Ot.attachmentsState)),St(e.attachmentsState[0],t),e}var Mt,xt={formatKind:Ne.Float,dimension:Ce.n2D};function Dt(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 Bt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function Lt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Ft(e,t){return e.dimension===t.dimension&&e.formatKind===t.formatKind}function bt(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Ut(e,t){return e.numSamplers===t.numSamplers&&(e.numUniformBuffers===t.numUniformBuffers&&(void 0===e.samplerEntries==(void 0===t.samplerEntries)&&!(void 0!==e.samplerEntries&&!Dt(e.samplerEntries,t.samplerEntries,Ft))))}function Gt(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!Dt(e.samplerBindings,t.samplerBindings,bt)&&(!!Dt(e.uniformBufferBindings,t.uniformBufferBindings,Lt)&&!!Vt(e.bindingLayout,t.bindingLayout)))}function wt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function kt(e,t){return!!wt(e.rgbBlendState,t.rgbBlendState)&&(!!wt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Vt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Wt(e,t){return e===t}function Xt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!Dt(e.attachmentsState,t.attachmentsState,kt)&&!!$e(e.blendConstant,t.blendConstant)&&e.depthCompare===t.depthCompare&&e.depthWrite===t.depthWrite&&e.stencilCompare===t.stencilCompare&&e.stencilWrite===t.stencilWrite&&e.stencilPassOp===t.stencilPassOp&&e.stencilRef===t.stencilRef&&e.cullMode===t.cullMode&&e.frontFace===t.frontFace&&e.polygonOffset===t.polygonOffset}(e.megaStateDescriptor,t.megaStateDescriptor)&&(!!function(e,t){return e.id===t.id}(e.program,t.program)&&(!!Dt(e.bindingLayouts,t.bindingLayouts,Vt)&&(!!Dt(e.colorAttachmentFormats,t.colorAttachmentFormats,Wt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Ht(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Yt(e,t){return A(e)?A(t):!A(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function Kt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Dt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Yt)&&!!Dt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Ht))}function zt(e,t){return e.wrapS===t.wrapS&&e.wrapT===t.wrapT&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipFilter===t.mipFilter&&e.minLOD===t.minLOD&&e.maxLOD===t.maxLOD&&e.maxAnisotropy===t.maxAnisotropy&&e.compareMode===t.compareMode}function jt(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function qt(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Zt(e){return{bindingLayout:e.bindingLayout,samplerBindings:Bt(e.samplerBindings,jt),uniformBufferBindings:Bt(e.uniformBufferBindings,qt),pipeline:e.pipeline}}function Qt(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Jt(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Bt(e.samplerEntries,Qt):void 0}}function $t(e){var t=Bt(e.bindingLayouts,Jt),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:yt(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function er(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function tr(e){return A(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function rr(e){return{vertexAttributeDescriptors:Bt(e.vertexAttributeDescriptors,er),vertexBufferDescriptors:Bt(e.vertexBufferDescriptors,tr),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Mt||(Mt={}));var nr,ir=new Uint16Array([65279]),or=255==new DataView(ir.buffer).getUint8(0)?Mt.LITTLE_ENDIAN:Mt.BIG_ENDIAN;var ar=/([^[]*)(\[[0-9]+\])?/;function sr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function ur(e,t,r,n){var i=null,o=null;return function(a,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Qe(o===c,"Uniform length cannot change.");for(var p=0;c>p;++p)if(l[p]!==i[p]){f=!0;break}}return f&&(n(a,e,s,l),i.set(l)),f}}function lr(e,t,r,n){e[t](r,n)}function cr(e,t,r,n){e[t](r,!1,n)}var fr={},pr={},dr={},hr=[0];function _r(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(hr[0]=e,e=hr);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function Er(e,t){return _r(e,t,Float32Array,fr)}function Rr(e,t){return _r(e,t,Int32Array,pr)}function mr(e,t){return _r(e,t,Uint32Array,dr)}var Tr=((nr={})[ce.FLOAT]=ur.bind(null,"uniform1fv",Er,1,lr),nr[ce.FLOAT_VEC2]=ur.bind(null,"uniform2fv",Er,2,lr),nr[ce.FLOAT_VEC3]=ur.bind(null,"uniform3fv",Er,3,lr),nr[ce.FLOAT_VEC4]=ur.bind(null,"uniform4fv",Er,4,lr),nr[ce.INT]=ur.bind(null,"uniform1iv",Rr,1,lr),nr[ce.INT_VEC2]=ur.bind(null,"uniform2iv",Rr,2,lr),nr[ce.INT_VEC3]=ur.bind(null,"uniform3iv",Rr,3,lr),nr[ce.INT_VEC4]=ur.bind(null,"uniform4iv",Rr,4,lr),nr[ce.BOOL]=ur.bind(null,"uniform1iv",Rr,1,lr),nr[ce.BOOL_VEC2]=ur.bind(null,"uniform2iv",Rr,2,lr),nr[ce.BOOL_VEC3]=ur.bind(null,"uniform3iv",Rr,3,lr),nr[ce.BOOL_VEC4]=ur.bind(null,"uniform4iv",Rr,4,lr),nr[ce.FLOAT_MAT2]=ur.bind(null,"uniformMatrix2fv",Er,4,cr),nr[ce.FLOAT_MAT3]=ur.bind(null,"uniformMatrix3fv",Er,9,cr),nr[ce.FLOAT_MAT4]=ur.bind(null,"uniformMatrix4fv",Er,16,cr),nr[ce.UNSIGNED_INT]=ur.bind(null,"uniform1uiv",mr,1,lr),nr[ce.UNSIGNED_INT_VEC2]=ur.bind(null,"uniform2uiv",mr,2,lr),nr[ce.UNSIGNED_INT_VEC3]=ur.bind(null,"uniform3uiv",mr,3,lr),nr[ce.UNSIGNED_INT_VEC4]=ur.bind(null,"uniform4uiv",mr,4,lr),nr[ce.FLOAT_MAT2x3]=ur.bind(null,"uniformMatrix2x3fv",Er,6,cr),nr[ce.FLOAT_MAT2x4]=ur.bind(null,"uniformMatrix2x4fv",Er,8,cr),nr[ce.FLOAT_MAT3x2]=ur.bind(null,"uniformMatrix3x2fv",Er,6,cr),nr[ce.FLOAT_MAT3x4]=ur.bind(null,"uniformMatrix3x4fv",Er,12,cr),nr[ce.FLOAT_MAT4x2]=ur.bind(null,"uniformMatrix4x2fv",Er,8,cr),nr[ce.FLOAT_MAT4x3]=ur.bind(null,"uniformMatrix4x3fv",Er,12,cr),nr[ce.SAMPLER_2D]=sr,nr[ce.SAMPLER_CUBE]=sr,nr[ce.SAMPLER_3D]=sr,nr[ce.SAMPLER_2D_SHADOW]=sr,nr[ce.SAMPLER_2D_ARRAY]=sr,nr[ce.SAMPLER_2D_ARRAY_SHADOW]=sr,nr[ce.SAMPLER_CUBE_SHADOW]=sr,nr[ce.INT_SAMPLER_2D]=sr,nr[ce.INT_SAMPLER_3D]=sr,nr[ce.INT_SAMPLER_CUBE]=sr,nr[ce.INT_SAMPLER_2D_ARRAY]=sr,nr[ce.UNSIGNED_INT_SAMPLER_2D]=sr,nr[ce.UNSIGNED_INT_SAMPLER_3D]=sr,nr[ce.UNSIGNED_INT_SAMPLER_CUBE]=sr,nr[ce.UNSIGNED_INT_SAMPLER_2D_ARRAY]=sr,nr);var vr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function gr(e,t){return"#define ".concat(e," ").concat(t)}function Ar(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=l(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*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var u=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}function yr(e,t,r,n,i){var o,a;void 0===n&&(n=null);var s="#version 100"===e.glslVersion,c=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),f="";null!==n&&(f=Object.keys(n).map((function(e){return gr(e,n[e])})).join("\n"));var p=c.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=c.filter((function(e){return!e.startsWith("precision")})).join("\n"),h="";if(e.viewportOrigin===Me.UpperLeft&&(h+="".concat(gr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===xe.Zero&&(h+="".concat(gr("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,E=0,R=0;d=d.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(E++,") uniform ").concat(n)})),_++,E=0,Qe(e.separateSamplerTextures),d=(d=d.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(E++,") uniform texture2D T_").concat(r,";\nlayout(set = ").concat(_,", binding = ").concat(E++,") uniform sampler S_").concat(r,";\n"):""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(R++,") ").concat(t)})),h+="".concat(gr("gl_VertexID","gl_VertexIndex"),"\n")}d=e.separateSamplerTextures?(d=(d=(d=d.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_".concat(t,", sampler S_P_").concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_".concat(t,", S_").concat(t)}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_".concat(t,", S_").concat(t,")")})):(d=(d=(d=d.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_".concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var m="".concat(s?"":e.glslVersion,"\n").concat("","\n").concat(s&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"","\n").concat(p,"\n").concat(h,"\n").concat(f,"\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(m=m.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),s){if("frag"===t&&(m=m.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(m=(m=m.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")}))),m=m.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){var T,v=(m=m.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return T=r,"".concat(t," ").concat(r,";\n")}))).lastIndexOf("}");m=m.substring(0,v)+"\n gl_FragColor = vec4(".concat(T,");\n")+m.substring(v)}m=m.replace(/^\s*layout\((.*)\)/gm,"");try{for(var g=u(vr),A=g.next();!A.done;A=g.next()){var y=l(A.value,2);m=m.replace(y[0],y[1])}}catch(e){o={error:e}}finally{try{A&&!A.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}}return m}function Sr(e,t,r,n,i){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:yr(e,"vert",t,n),preprocessedFrag:yr(e,"frag",r,n)}}function Cr(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 Sr(e.queryVendorInfo(),n,i,r)}var Or=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(A(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return ct(this.defines[e])},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&Qe("1"===t),null!==t},e.prototype.ensurePreprocessed=function(e){""===this.preprocessedVert&&(this.preprocessedVert=yr(e,"vert",this.both+this.vert,this.defines),this.preprocessedFrag=yr(e,"frag",this.both+this.frag,this.defines))},e}(),Ir=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=dt(e,this.uniformBufferWordAlignment),Qe(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=dt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=dt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Qe(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=dt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return Je(this.shadowBufferF32)},e.prototype.prepareToRender=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:this.currentBufferWordSize,usage:ge.UNIFORM,hint:Ae.Dynamic}));var t=dt(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}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Pr(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Nr(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Mr(e){return 0}var xr=function(){this.keys=[],this.values=[]},Dr=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=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]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new xr);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=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))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=u(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=u(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function Br(e,t){return Qe(""!==e.preprocessedVert&&""!==t.preprocessedVert),Qe(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Lr(e,t){return e=Pr(e,t.numUniformBuffers),e=Pr(e,t.numSamplers)}function Fr(e,t){return e=Pr(e,t.blendMode),e=Pr(e,t.blendSrcFactor),e=Pr(e,t.blendDstFactor)}function br(e,t){return e=Fr(e,t.rgbBlendState),e=Pr(e=Fr(e,t.alphaBlendState),t.channelWriteMask)}function Ur(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=br(e,t.attachmentsState[r]);return e=function(e,t){return Pr(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Pr(e,t.depthCompare),e=Pr(e,t.depthWrite?1:0),e=Pr(e,t.stencilCompare),e=Pr(e,t.stencilPassOp),e=Pr(e,t.stencilWrite?1:0),e=Pr(e,t.cullMode),e=Pr(e,t.frontFace?1:0),e=Pr(e,t.polygonOffset?1:0)}function Gr(e){var t=0;t=Pr(t,e.program.id),null!==e.inputLayout&&(t=Pr(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=Lr(t,e.bindingLayouts[r]);t=Ur(t,e.megaStateDescriptor);for(r=0;e.colorAttachmentFormats.length>r;r++)t=Pr(t,e.colorAttachmentFormats[r]||0);return Nr(t=Pr(t,e.depthStencilAttachmentFormat||0))}function wr(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Pr(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Pr(t,n.buffer.id),t=Pr(t,n.wordCount))}return Nr(t)}var kr,Vr,Wr=function(){function e(e){this.bindingsCache=new Dr(Gt,wr),this.renderPipelinesCache=new Dr(Xt,Gr),this.inputLayoutsCache=new Dr(Kt,Mr),this.programCache=new Dr(Br,Mr),this.samplerCache=new Dr(zt,Mr),this.device=e}return e.prototype.createBindings=function(e){var t=this.bindingsCache.get(e);if(null===t){var r=Zt(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t},e.prototype.createRenderPipeline=function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=$t(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t},e.prototype.createInputLayout=function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=rr(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t},e.prototype.createProgramSimple=function(e){var t,r=this.programCache.get(e);if(null===r){var n={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};r=this.device.createProgramSimple(n),this.programCache.add(n,r)}return r},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,l,c;try{for(var f=u(this.bindingsCache.values()),p=f.next();!p.done;p=f.next()){p.value.destroy()}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var d=u(this.renderPipelinesCache.values()),h=d.next();!h.done;h=d.next()){h.value.destroy()}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}try{for(var _=u(this.inputLayoutsCache.values()),E=_.next();!E.done;E=_.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}try{for(var R=u(this.programCache.values()),m=R.next();!m.done;m=R.next()){m.value.destroy()}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var T=u(this.samplerCache.values()),v=T.next();!v.done;v=T.next()){v.value.destroy()}}catch(e){l={error:e}}finally{try{v&&!v.done&&(c=T.return)&&c.call(T)}finally{if(l)throw l.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(kr||(kr={})),function(e){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"}(Vr||(Vr={}));var Xr,Hr=function(){function 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=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),Qe(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.resolveToExternalTexture=function(e,t){this.resolveTextureOutputExternalTextures[e]=t},e.prototype.exec=function(e){Qe(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){Qe(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),Yr=function(){function e(e,t){this.dimension=Ce.n2D,this.depth=1,this.numLevels=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Oe.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.age=0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,Qe(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){Qe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()},e}(),Kr=function(){function e(e,t){this.dimension=Ce.n2D,this.depth=1,this.numLevels=1,this.usage=Oe.RenderTarget,this.width=0,this.height=0,this.age=0,this.immutable=!0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){Qe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),zr=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},jr=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=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 Yr(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=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 Kr(this.device,e)},e.prototype.beginGraphBuilder=function(){Qe(null===this.currentGraph),this.currentGraph=new zr},e.prototype.pushPass=function(e){var t=new Hr;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=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},e.prototype.resolveRenderTargetPassAttachmentSlot=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]},e.prototype.findPassForResolveRenderTarget=function(e){var t=Je(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Qe(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);Qe(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return Je(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(Qe(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]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=Je(this.renderTargetAliveForID[e]);return t?(Qe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Qe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Qe(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)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;Qe(!(a&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){Qe(e.resolveTextureRenderTargetIDs[i]===n),Qe(this.resolveTextureUseCount[i]>0),Qe(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 p=Je(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(p),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=o,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[Vr.DepthStencil],n=Vr.Color0;Vr.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,u=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Vr.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Vr.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 p=0,d=0,h=0,_=0;t.renderTargets.length>_;_++){var E=t.renderTargets[_];if(E){var R=E.width>>>t.renderTargetLevels[_],m=E.height>>>t.renderTargetLevels[_];0===p&&(p=R,d=m,h=E.sampleCount),Qe(R===p),Qe(m===d),Qe(E.sampleCount===h),E.needsClear=!1}}p>0&&d>0&&(t.viewportX*=p,t.viewportY*=d,t.viewportW*=p,t.viewportH*=d);for(_=0;t.resolveTextureInputIDs.length>_;_++){t.resolveTextureInputTextures[_]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[_])}for(_=0;t.renderTargetIDs.length>_;_++)this.releaseRenderTargetForID(t.renderTargetIDs[_],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){Qe(0===this.renderTargetOutputCount.length),Qe(0===this.renderTargetResolveCount.length),Qe(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;ft(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),ft(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),ft(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)Qe(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)Qe(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)Qe(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)Qe(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){Qe(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.beginDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.endDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=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},e.prototype.execute=function(){var e=Je(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Qe(r>=0),Je(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Qe(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)Qe(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(Xr||(Xr={}));var qr=65536,Zr=16;function Qr(e,t,r){void 0===r&&(r=qr);var n=O(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<Zr)-1)}function Jr(e,t){return(16777215&e|(255&t)<<24)>>>0}function $r(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function en(e,t){return Jr($r(0,t),e)}function tn(e,t){return Qe(t>=0),(4294967040&e|t>>>8&255)>>>0}function rn(e){return Jr(0,e)}function nn(e,t){return Qe(t>=0),(4278190335&e|t<<8)>>>0}var on=h(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var an,sn=h(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function un(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){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"}(an||(an={}));var ln,cn=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Rt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Rt(4,(function(){return 0})),this.flags=0,this.inputState=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={bindingLayouts:[],inputLayout:null,megaStateDescriptor:yt(Ot),program:null,topology:ve.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=an.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){At(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 t=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>t;t++)this.renderPipelineDescriptor.colorAttachmentFormats[t]=e.renderPipelineDescriptor.colorAttachmentFormats[t];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.inputState=e.inputState,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],l(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~an.InheritedFlags|e.flags&an.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(t=0;Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length)>t;t++)r.uniformBufferBindings[t].wordCount=e.bindingDescriptors[0].uniformBufferBindings[t].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(t=0;e.dynamicUniformBufferByteOffsets.length>t;t++)this.dynamicUniformBufferByteOffsets[t]=e.dynamicUniformBufferByteOffsets[t]},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return At(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setInputLayoutAndState=function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){Qe(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})},e.prototype.setBindingLayouts=function(e){Qe(this.bindingDescriptors.length>=e.length),Qe(1===e.length),this.setBindingLayout(e[0])},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=Et(this.flags,an.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=Et(this.flags,an.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=Et(this.flags,an.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(I(t)||Array.isArray(t)||t instanceof Float32Array){var i=I(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],l(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)a+=un(s,a,n[u],n[u+1],n[u+2],n[u+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){return Qe(this.dynamicUniformBufferByteOffsets.length>this.bindingDescriptors[0].bindingLayout.numUniformBuffers),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=t,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.setUniformBufferOffset=function(e,t,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=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.lateBinding=n.lateBinding):(r.texture=null,r.sampler=null,r.lateBinding=null)}},e.prototype.hasLateSamplerBinding=function(e){for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1},e.prototype.resolveLateSamplerBinding=function(e,t){for(var r=0;this.bindingDescriptors[0].samplerBindings.length>r;r++){var n=this.bindingDescriptors[0].samplerBindings[r];n.lateBinding===e&&(null===t?(n.texture=null,n.sampler=null):(Qe(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=Et(this.flags,an.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===n?n=o.sampleCount:Qe(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===n?n=a.sampleCount:Qe(n==a.sampleCount)),Qe(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&an.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setInputState(this.inputState);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=Je(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniforms(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(0,s,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Qe(!!(this.flags&an.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&an.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0},e}();function fn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(ln||(ln={}));var pn=function(){function e(e,t){void 0===e&&(e=fn),void 0===t&&(t=ln.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):_t(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=an.Draw,this.insertSorted(e)},e.prototype.hasLateSamplerBinding=function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1},e.prototype.resolveLateSamplerBinding=function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].resolveLateSamplerBinding(e,t)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){this.ensureSorted();var r=0;if(this.executionOrder===ln.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)&&r++;return r},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),dn=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new cn),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),hn=function(){function e(e){this.renderCache=e,this.instPool=new dn,this.templatePool=new dn,this.simpleRenderInstList=new pn,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=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},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){Qe(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=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|=an.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Qe(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){Je(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){Je(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),_n=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Wr(e),this.renderGraph=new jr(this.device),this.renderInstManager=new hn(this.renderCache),this.uniformBuffer=new Ir(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=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)!==kr.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),En=function(){function e(e){this.pixelFormat=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function Rn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var mn,Tn=Rn(rt(.88,.88,.88,1)),vn=Rn(it),gn=Rn(at);function An(e,t){var r=function(e){return e.antialiasingMode===mn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function yn(e,t,r){var n=function(e){if(e===Vr.Color0)return be.U8_RGBA_RT;if(e===Vr.DepthStencil)return be.D24_S8;throw Error("whoops")}(e),i=new En(n);return An(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(mn||(mn={}));var Sn,Cn=function(){function e(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.lateBinding=e.lateBinding,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),On=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Qe(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Kr(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),In=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Sn||(Sn={}));var Pn,Nn=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:Sn.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);!function(e){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"}(Pn||(Pn={}));var Mn,xn=function(){function e(e,t,r,n){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.renderLists={world:new pn,picking:new pn}}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,u=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.nodeName!==In.tag?t.nodeName!==Nn.tag?(t.renderable3D||(t.renderable3D=new Ue),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},c=function(e){var t=e.target;t.nodeName!==In.tag?t.nodeName!==Nn.tag?(n.swapChain&&n.batchManager.remove(t),delete t.renderable3D):n.lightPool.removeFog(t):n.lightPool.removeLight(t)},f=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)}},p=function(e){n.swapChain&&n.batchManager.updateAttribute(e.target,"modelMatrix",null)};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return u.addEventListener(t.ElementEvent.MOUNTED,l),u.addEventListener(t.ElementEvent.UNMOUNTED,c),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((o=this.context.config).width,o.height),n=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return n.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),u.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),u.removeEventListener(t.ElementEvent.MOUNTED,l),u.removeEventListener(t.ElementEvent.UNMOUNTED,c),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),o.hooks.beginFrame.tap(e.tag,(function(){var e=n.swapChain.getCanvas(),r=n.renderHelper.renderInstManager;n.builder=n.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(n.context.config.background),o=n.context.config.background?rt(Number(i.r)/255*Number(i.alpha),Number(i.g)/255*Number(i.alpha),Number(i.b)/255*Number(i.alpha),Number(i.alpha)):ot,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:mn.None},s=yn(Vr.Color0,a,Rn(o)),u=yn(Vr.DepthStencil,a,gn),l=n.builder.createRenderTargetID(s,"Main Color"),c=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Vr.Color0,l),e.attachRenderTargetID(Vr.DepthStencil,c),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(r.renderCache,e)}))})),n.builder.resolveRenderTargetToExternalTexture(l,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(){var e,t,r=n.renderHelper.renderInstManager,i=n.renderHelper.pushTemplateRenderInst();i.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),i.setMegaStateFlags(Nt({depthWrite:!0,blendConstant:ot},{rgbBlendMode:Ee.Add,alphaBlendMode:Ee.Add,rgbBlendSrcFactor:_e.SrcAlpha,alphaBlendSrcFactor:_e.One,rgbBlendDstFactor:_e.OneMinusSrcAlpha,alphaBlendDstFactor:_e.OneMinusSrcAlpha}));var o=(e=n.context.config).width,a=e.height,s=n.context.camera;if(i.setUniforms(0,[{name:Pn.PROJECTION_MATRIX,value:s.getPerspective()},{name:Pn.VIEW_MATRIX,value:s.getViewTransform()},{name:Pn.CAMERA_POSITION,value:s.getPosition()},{name:Pn.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Pn.VIEWPORT,value:[o,a]},{name:Pn.IS_ORTHO,value:s.isOrtho()?1:0},{name:Pn.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),r.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),r.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var u=(t=n.captureOptions).type,l=t.encoderOptions,c=n.context.contextService.getDomElement().toDataURL(u,l);n.resolveCapturePromise(c),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),Dn=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,u=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new Ue);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,u)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,u)})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){return a(n,void 0,void 0,(function(){return s(this,(function(t){return[2,this.pick(e)]}))}))}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,u=this.context.config.height*a,l=i*a,c=o*a;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(O(Math.round(l),0,s-1),O(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var 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},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n,o=this,a=this.renderGraphPlugin.getDevice(),s=this.renderGraphPlugin.getRenderLists(),u=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),c=this.context.camera,f=e.x,p=e.y,d=e.width,h=e.height,_={backbufferWidth:d,backbufferHeight:h,antialiasingMode:mn.None},E=yn(Vr.Color0,_,Rn(nt)),R=l.createRenderTargetID(E,"Picking Color"),m=yn(Vr.DepthStencil,_,gn),T=l.createRenderTargetID(m,"Picking Depth"),v=i({},c.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Vr.Color0,R),e.attachRenderTargetID(Vr.DepthStencil,T),e.exec((function(e){s.picking.drawOnPassRenderer(u.renderCache,e)})),e.post((function(e){var t=e.getRenderTargetTexture(Vr.Color0),r=a.createReadback();v&&v.enabled?c.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):c.clearViewOffset(),c.setEnableUpdate(!0);var i=r.readTexture(t,0,0,d,h,new Uint8Array(d*h*4)),s=-1;if(!i||0===i[0]&&0===i[1]&&0===i[2]||(s=o.pickingIdGenerator.decodePickingColor(i)),s>-1){var u=o.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(n=u)}r.destroy()}))}));var g=this.renderHelper.pushTemplateRenderInst();g.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),g.setMegaStateFlags(Nt({depthWrite:!0},{rgbBlendMode:Ee.Add,rgbBlendSrcFactor:_e.One,rgbBlendDstFactor:_e.Zero,alphaBlendMode:Ee.Add,alphaBlendSrcFactor:_e.One,alphaBlendDstFactor:_e.Zero}));var A=(r=this.context.config).width,y=r.height,S=this.context.contextService.getDPR();return c.setEnableUpdate(!1),c.setViewOffset(A*S,y*S,f,p,d,h),g.setUniforms(0,[{name:Pn.PROJECTION_MATRIX,value:c.getPerspective()},{name:Pn.VIEW_MATRIX,value:c.getViewTransform()},{name:Pn.CAMERA_POSITION,value:c.getPosition()},{name:Pn.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Pn.VIEWPORT,value:[A,y]},{name:Pn.IS_ORTHO,value:c.isOrtho()?1:0},{name:Pn.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(s.picking,!0),u.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),u.resetRenderInsts(),n},e.tag="WebGLPicker",e}(),Bn=.005,Ln=function(){function e(){this.meshes=[],this.clipPathMeshCreated=!1}return e.prototype.shouldSubmitRenderInst=function(e,t){return!0},e.prototype.beforeUploadUBO=function(e,t,r){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();function Fn(e,t,r){var n=e.createBuffer({viewOrSize:pt(r.byteLength,4)/4,usage:t,hint:Ae.Static});return n.setSubData(0,new Uint8Array(r)),n}!function(e){e.CHANGED="changed"}(Mn||(Mn={}));var bn,Un=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=ve.Triangles,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:be.U32_R},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=Fn(this.device,ge.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={byteStride:e.byteStride,frequency:e.frequency},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=e.byteStride,u=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===r&&e.location===o}));u?(u.format=n,u.bufferByteOffset=i,u.byteStride=s,u.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:n,bufferIndex:r,bufferByteOffset:i,location:o,byteStride:s,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=Fn(this.device,ge.VERTEX,i.buffer);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));o&&this.getVertexBuffer(e).setSubData(o.bufferByteOffset+r*i,n);this.emit(Mn.CHANGED)},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexAttributeDescriptors=[],this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(N);!function(e){e.CHANGED="changed"}(bn||(bn={}));var Gn=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=yt(Ot),a=o.cullMode,s=o.depthCompare,u=o.depthWrite,l=o.stencilCompare,c=o.stencilWrite,f=o.stencilPassOp,p=o.frontFace,d=o.polygonOffset,h=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:p,polygonOffset:d,attachmentsState:h,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilCompare",{get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilPassOp",{get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"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},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=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=Ar(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(Se.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),A(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(bn.CHANGED)},t}(N),wn=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Gn);function kn(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Vn(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Wn=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=l(e,2);return void 0!==t[1]})))};function Xn(e,t){return 256*(e=O(Math.floor(e),0,255))+(t=O(Math.floor(t),0,255))}var Hn,Yn,Kn=1,zn="FillTextureMapping";!function(e){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"}(Hn||(Hn={})),function(e){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"}(Yn||(Yn={}));var jn,qn,Zn=function(){function e(e,t,r){this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.id=Kn++,this.index=-1,this.objects=[],this.program=new Or,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.lightReceived=!1,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(e){this.inited||(this.renderer.beforeInitMesh(this),this.context=e,this.material=new wn(this.context.device),this.material.defines=i(i({},kn(Yn)),this.material.defines),this.geometry=new Un(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(Mn.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(bn.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))},e.prototype.shouldMerge=function(e,t){return!this.instance||(this.instance.nodeName===e.nodeName||this.instance.nodeName===e.renderable.proxyNodeName||this.instance.renderable.proxyNodeName===e.nodeName||this.instance.renderable.proxyNodeName===e.renderable.proxyNodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r=this,n=p(),i=p(),o=[],a=[],s=[],u=[];e.forEach((function(e){var f,p=e.parsedStyle,h=p.fill,_=p.stroke,E=p.opacity,R=p.fillOpacity,T=p.strokeOpacity,v=p.lineWidth,g=p.anchor,A=p.visibility,y=p.increasedLineWidthForHitTesting,S=[0,0,0,0];t.isCSSRGB(h)&&(S=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]);var C=[0,0,0,0];t.isCSSRGB(_)&&(C=[Number(_.r),Number(_.g),Number(_.b),255*Number(_.alpha)]),r.clipPathTarget?(d(n,e.getLocalTransform()),S=[255,255,255,255],m(n,r.clipPathTarget.getWorldTransform(),n)):d(n,e.getWorldTransform()),m(i,r.context.camera.getViewTransform(),n);var O=e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];o.push.apply(o,c([],l(n),!1)),a.push(Xn(S[0],S[1]),Xn(S[2],S[3]),Xn(C[0],C[1]),Xn(C[2],C[3])),s.push(E,R,T,v,"visible"===A?1:0,g[0],g[1],y||0),u.push.apply(u,c(c([],l(O),!1),[e.sortable.renderOrder*Bn],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Hn.MODEL_MATRIX,byteStride:64,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.MODEL_MATRIX0,divisor:1},{format:be.F32_RGBA,bufferByteOffset:16,location:Yn.MODEL_MATRIX1,divisor:1},{format:be.F32_RGBA,bufferByteOffset:32,location:Yn.MODEL_MATRIX2,divisor:1},{format:be.F32_RGBA,bufferByteOffset:48,location:Yn.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PACKED_COLOR,byteStride:16,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.PACKED_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PACKED_STYLE,byteStride:32,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.PACKED_STYLE1,divisor:1},{format:be.F32_RGBA,bufferByteOffset:16,location:Yn.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PICKING_COLOR,byteStride:16,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.PICKING_COLOR,divisor:1}],data:new Float32Array(u)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=this.lightPool.getAllLights(),o=!!this.lightPool.getFog(),a=!!n.length;this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=pe.Always,this.material.stencilPassOp=Pe.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=pe.Equal,this.material.stencilPassOp=Pe.Keep):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var s=i({},this.material.defines);if(this.material.defines.USE_FOG=o,this.material.defines.USE_LIGHT=a,this.material.defines=i(i(i({},this.material.defines),this.lightPool.getDefines()),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var u=this.createFillGradientTextureMapping(t);u&&this.textureMappings.push(u),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 Cn;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:Re.Clamp,wrapT:Re.Clamp,minFilter:me.Point,magFilter:me.Bilinear,mipFilter:Te.Linear,minLOD:0,maxLOD: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}(!Vn(s,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),kn(Yn)),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.programDescriptorSimpleWithOrig=Cr(this.context.device,this.program),this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.inputStateDirty=!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,this.inputStateDirty=!0);var l=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),c=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),f=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.context.device.createInputState(l,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),f?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,c),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(c),e.setInputLayoutAndState(l,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),f?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=en(Xr.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){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(Xn(a[0],a[1]),Xn(a[2],a[3]),Xn(s[0],s[1]),Xn(s[2],s[3]))})),this.geometry.updateVertexBuffer(Hn.PACKED_COLOR,Yn.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===zn}));if(t.isCSSRGB(a))0>s||(this.textureMappings.splice(s,-1),this.material.textureDirty=!0);else{var u=this.createFillGradientTextureMapping([this.instance]);0>s||this.textureMappings.splice(s,1,u),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var f=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor;f.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(Hn.PACKED_STYLE,Yn.PACKED_STYLE1,r,new Uint8Array(new Float32Array(f).buffer))}else if("modelMatrix"===n){var h=[];e.forEach((function(e){var t=d(p(),e.getWorldTransform());h.push.apply(h,c([],l(t),!1))})),this.geometry.updateVertexBuffer(Hn.MODEL_MATRIX,Yn.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(h).buffer))}else if("pointerEvents"===n){var _=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];_.push.apply(_,c(c([],l(r),!1),[e.sortable.renderOrder*Bn],!1))})),this.geometry.updateVertexBuffer(Hn.PICKING_COLOR,Yn.PICKING_COLOR,r,new Uint8Array(new Float32Array(_).buffer))}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},e.prototype.changeRenderOrder=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(Hn.PICKING_COLOR,Yn.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],l(i),!1),[t*Bn],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Hn.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var u=t[i],l=1;e.vertices.length>l;l++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[l].byteStride)/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];s[i]=a,a++}var p=function(t){var r=e.inputLayoutDescriptor.vertexBufferDescriptors[t],n=r.frequency,i=r.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));o&&e.setVertexBuffer({bufferIndex:o.bufferIndex,byteStride:i,frequency:n,attributes:[{format:o.format,bufferByteOffset:o.bufferByteOffset,location:o.location,divisor:o.divisor}],data:e.vertices[t]})};for(i=Hn.PICKING_COLOR+1;e.vertexBuffers.length>i;i++)p(i);var d=new Float32Array(3*r);for(i=0;r>i;)for(l=0;3>l;l++){d[3*(u=s[i++])+l]=1}e.setVertexBuffer({bufferIndex:Hn.BARYCENTRIC,byteStride:12,frequency:ye.PerVertex,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Number(Yn.BARYCENTRIC)}],data:d}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t,r){},e.prototype.uploadUBO=function(e){var r=this,n=this.material,o=this.lightPool.getAllLights(),a=this.lightPool.getFog(),s=!!a,u=this.lightReceived&&!!o.length,l=[];if(n.defines.USE_WIREFRAME){var c=t.parseColor(n.wireframeColor);l.push({name:"u_WireframeLineColor",value:[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255]}),l.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(s&&this.uploadFog(l,a),this.uploadMaterial(l,n),u){var f={};o.forEach((function(e){f[e.define]||(f[e.define]=-1),f[e.define]++,e.uploadUBO(l,f[e.define])}))}l.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,l);var p=n.blendEquation,d=n.blendEquationAlpha,h=n.blendSrc,_=n.blendDst,E=n.blendSrcAlpha,R=n.blendDstAlpha,m=Wn({blendConstant:n.blendConstant,depthCompare:n.depthCompare,depthWrite:n.depthWrite,stencilCompare:n.stencilCompare,stencilWrite:n.stencilWrite,stencilPassOp:n.stencilPassOp,stencilRef:n.stencilRef,cullMode:n.cullMode,frontFace:n.frontFace,polygonOffset:n.polygonOffset}),T=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Ie.None:Ie.AllChannels,rgbBlendState:i(i({},T.rgbBlendState),Wn({blendMode:p,blendSrcFactor:h,blendDstFactor:_})),alphaBlendState:i(i({},T.alphaBlendState),Wn({blendMode:d,blendSrcFactor:E,blendDstFactor:R}))}]},m)),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(t.isCSSRGB(o)){var l=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,u]}),e.push({name:"u_FogColor",value:l})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],l(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.nodeName===t.Shape.LINE?i.parsedStyle.stroke:i.parsedStyle.fill;if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,We(be.U8_RGBA_NORM,1,1,1));if(a){var s=new Cn;return s.name=zn,s.texture=a,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"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Bilinear,mipFilter:Te.Linear,minLOD:0,maxLOD:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(jn||(jn={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(qn||(qn={}));var Qn,Jn,$n=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],ei=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(!this.needDrawStrokeSeparately(t.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&this.instance.parsedStyle.fill.isNone===t.parsedStyle.fill.isNone)},r.prototype.createMaterial=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 vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec3 v_Data;\nout vec2 v_Radius;\nout vec4 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 #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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 + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n float antialiasblur = 1.0 / radius.y;\n\n bool isBillboard = a_StylePacked3.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec3(a_Extrude * radius / radius.y, antialiasblur);\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 vec3 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\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 float epsilon = 0.000001;\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 float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\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 outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data.xy, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data.xy, 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=i(i({},this.material.defines),kn(qn))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[],o=[];t.forEach((function(e,t){var a=e,s=4*t,u=a.parsedStyle.radius,f=r.shouldOmitStroke(a.parsedStyle),p=r.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,c(c([],l(p),!1),[$n.indexOf(a.nodeName),u&&u[0]||0,f?1:0,a.parsedStyle.isBillboard?1:0],!1)),n.push(-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1),o.push(0+s,2+s,1+s,0+s,3+s,2+s)})),this.geometry.setIndexBuffer(new Uint32Array(o)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:16,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Yn.POSITION},{format:be.F32_RG,bufferByteOffset:8,location:Yn.UV}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:jn.PACKED_STYLE,byteStride:24,frequency:ye.PerInstance,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:qn.SIZE,divisor:1},{format:be.F32_RGBA,bufferByteOffset:8,location:qn.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=l(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],l([n[0],n[1]]),!1),[$n.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0,t.parsedStyle.isBillboard?1:0],!1))})),this.geometry.updateVertexBuffer(jn.PACKED_STYLE,qn.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},r.prototype.getSize=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},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r.prototype.needDrawStrokeSeparately=function(e){var t=e.stroke,r=e.lineDash,n=e.lineWidth,i=e.strokeOpacity,o=t&&!t.isNone,a=r&&r.length&&r.every((function(e){return 0!==e}));return o&&n>0&&(a||1>i)},r}(Zn),ti=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Qn||(Qn={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(Jn||(Jn={}));var ri={butt:1,round:2,square:3},ni=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=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\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\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 #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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 float isBillboard = a_Dash.w;\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n if (isBillboard > 0.5 && isPerspective) {\n // clip space\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 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (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 * strokeWidth * 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(strokeWidth / 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;\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 = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\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 * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}",this.material.defines=i(i({},this.material.defines),kn(Jn))},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],u=0;r.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,defX:c.defX,defY:c.defY,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:!0,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){var p=e.parsedStyle,d=p.path.absolutePath;r={x1:d[0][1],y1:d[0][2],x2:d[1][1],y2:d[1][2],z1:0,z2:0,defX:p.defX,defY:p.defY,lineCap:p.lineCap,lineDash:p.lineDash,lineDashOffset:p.lineDashOffset,isBillboard:!1,markerStart:p.markerStart,markerEnd:p.markerEnd,markerStartOffset:p.markerStartOffset,markerEndOffset:p.markerEndOffset},l=e.getTotalLength()}var h=r.x1,_=r.y1,E=r.x2,R=r.y2,m=r.z1,T=r.z2,v=r.defX,g=r.defY,A=r.lineCap,y=r.isBillboard,S=n.calcOffset(r),C=S.startOffsetX,O=S.startOffsetY,I=S.endOffsetX,P=S.endOffsetY,N=n.calcDash(r,l),M=N.dashOffset,x=N.dashSegmentPercent,D=N.dashRatioInEachSegment;o.push(ri[A]),a.push(M,x,D,y?1:0),i.push(h-v+C,_-g+O,m,E-v+I,R-g+P,T),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:Hn.POSITION,byteStride:20,frequency:ye.PerInstance,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Jn.POSITION,divisor:0},{format:be.F32_RG,bufferByteOffset:12,location:Jn.UV,divisor:0}],data:new Float32Array(ti)}),this.geometry.setVertexBuffer({bufferIndex:Qn.POINT,byteStride:24,frequency:ye.PerInstance,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Jn.POINTA,divisor:1},{format:be.F32_RGB,bufferByteOffset:12,location:Jn.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Qn.CAP,byteStride:4,frequency:ye.PerInstance,attributes:[{format:be.F32_R,bufferByteOffset:0,location:Jn.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Qn.DASH,byteStride:16,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Jn.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE&&e.renderable.proxyNodeName===t.Shape.LINE){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,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isBillboard:!0,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH&&e.renderable.proxyNodeName===t.Shape.LINE){var o=e.parsedStyle,u=o.path.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:!0,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,p=r.y2,d=r.z1,h=r.z2,_=r.defX,E=r.defY,R=a.calcOffset(r);s.push(l-_+R.startOffsetX,c-E+R.startOffsetY,d,f-_+R.endOffsetX,p-E+R.endOffsetY,h)})),this.geometry.updateVertexBuffer(Qn.POINT,Jn.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isBillboard"===i){var u=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Qn.DASH,Jn.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];r.forEach((function(e){l.push(ri[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Qn.CAP,Jn.CAP,n,new Uint8Array(new Float32Array(l).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,p=0,d=0,h=0;return a&&t.isDisplayObject(a)&&u&&(c=Math.cos(h=Math.atan2(o-n,i-r))*(u||0),f=Math.sin(h)*(u||0)),s&&t.isDisplayObject(s)&&l&&(p=Math.cos(h=Math.atan2(n-o,r-i))*(l||0),d=Math.sin(h)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:p,endOffsetY:d}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(Zn),ii=10,oi=8,ai=100;function si(e,t,r,n,i){for(var o=i[i.length-2],a=i[i.length-1],s=le(o,a,e,t,r,n,3),u=O(s/ii,oi,ai),l=0,c=0,f=1;u>=f;++f){var p=f/u;i.push((l=o+(e-o)*p)+(e+(r-e)*p-l)*p,(c=a+(t-a)*p)+(t+(n-t)*p-c)*p)}}function ui(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var l=se(s,u,e,t,r,n,i,o,3),c=O(l/ii,oi,ai),f=0,p=0,d=0,h=0,_=0;a.push(s,u);for(var E=1,R=0;c>=E;++E)a.push((d=(p=(f=1-(R=E/c))*f)*f)*s+3*p*R*e+3*f*(h=R*R)*r+(_=h*R)*i,d*u+3*p*R*t+3*f*h*n+_*o)}var li,ci=1e20,fi=function(){function e(e){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,u=e.cutoff,l=void 0===u?.25:u,c=e.fontFamily,f=void 0===c?"sans-serif":c,p=e.fontWeight,d=void 0===p?"normal":p,h=e.fontStyle,_=void 0===h?"normal":h,E=e.canvas;this.buffer=o,this.cutoff=l,this.radius=s;var R=this.size=n+4*o,m=t.runtime.offscreenCanvas.getOrCreateCanvas(E);m.width=R,m.height=R;var T=t.runtime.offscreenCanvas.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=T,T.font="".concat(_," ").concat(d," ").concat(n,"px ").concat(f),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),p=new Uint8ClampedArray(f),d={data:p,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return d;var h=this,_=h.ctx,E=h.buffer,R=h.gridInner,m=h.gridOuter;_.clearRect(E,E,s,u),_.fillText(e,E,E+a);var T=_.getImageData(E,E,s,u);m.fill(ci,0,f),R.fill(0,0,f);for(var v=0;u>v;v++)for(var g=0;s>g;g++){var A=T.data[4*(v*s+g)+3]/255;if(0!==A){var y=(v+E)*l+g+E;if(1===A)m[y]=0,R[y]=ci;else m[y]=(C=.5-A)>0?C*C:0,R[y]=0>C?C*C:0}}pi(m,0,0,l,c,l,this.f,this.v,this.z),pi(R,E,E,s,u,l,this.f,this.v,this.z);for(var S=0;f>S;S++){var C;p[S]=Math.round(255-255*((C=Math.sqrt(m[S])-Math.sqrt(R[S]))/this.radius+this.cutoff))}return d},e}();function pi(e,t,r,n,i,o,a,s,u){for(var l=t;t+n>l;l++)di(e,r*o+l,o,i,a,s,u);for(var c=r;r+i>c;c++)di(e,c*o+t,1,n,a,s,u)}function di(e,t,r,n,i,o,a){o[0]=0,a[0]=-ci,a[1]=ci,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{l=(i[s]-i[f=o[u]]+c-f*f)/(s-f)/2}while(a[u]>=l&&--u>-1);o[++u]=s,a[u]=l,a[u+1]=ci}for(s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;var f,p=s-(f=o[u]);e[t+s*r]=i[f]+p*p}}!function(e){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"}(li||(li={}));var hi,_i,Ei;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(hi||(hi={})),function(e){e[e.PREV=0]="PREV",e[e.POINT1=1]="POINT1",e[e.POINT2=2]="POINT2",e[e.NEXT=3]="NEXT",e[e.VERTEX_JOINT=4]="VERTEX_JOINT",e[e.VERTEX_NUM=5]="VERTEX_NUM",e[e.TRAVEL=6]="TRAVEL"}(_i||(_i={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.FILL_COLOR="u_FillColor",e.STROKE_COLOR="u_StrokeColor",e.STROKE_WIDTH="u_StrokeWidth",e.INCREASED_LINE_WIDTH_FOR_HIT_TESTING="u_IncreasedLineWidthForHitTesting",e.OPACITY="u_Opacity",e.FILL_OPACITY="u_FillOpacity",e.STROKE_OPACITY="u_StrokeOpacity",e.EXPAND="u_Expand",e.MITER_LIMIT="u_MiterLimit",e.SCALE_MODE="u_ScaleMode",e.ALIGNMENT="u_Alignment",e.PICKING_COLOR="u_PickingColor",e.DASH="u_Dash",e.GAP="u_Gap",e.DASH_OFFSET="u_DashOffset",e.VISIBLE="u_Visible",e.Z_INDEX="u_ZIndex"}(Ei||(Ei={}));var Ri=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(e,t){return!1},r.prototype.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r,n,s,u,l,c,f,d,h,_,R,v,g=e.parsedStyle,A=g.stroke,y=g.opacity,S=g.fillOpacity,C=g.strokeOpacity,O=g.lineWidth,I=g.increasedLineWidthForHitTesting,P=g.anchor,N=g.lineDash,M=g.lineDashOffset,x=g.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===i||e.nodeName===t.Shape.CIRCLE&&"r"===i||e.nodeName===t.Shape.ELLIPSE&&("rx"===i||"ry"===i)||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("stroke"===i){var D=[0,0,0,0];t.isCSSRGB(A)&&(D=[Number(A.r)/255,Number(A.g)/255,Number(A.b)/255,Number(A.alpha)]),a.material.setUniforms(((r={})[Ei.STROKE_COLOR]=D,r))}else if("opacity"===i)a.material.setUniforms(((n={})[Ei.OPACITY]=y,n));else if("fillOpacity"===i)a.material.setUniforms(((s={})[Ei.FILL_OPACITY]=S,s));else if("strokeOpacity"===i)a.material.setUniforms(((u={})[Ei.STROKE_OPACITY]=C,u));else if("lineWidth"===i)a.material.setUniforms(((l={})[Ei.STROKE_WIDTH]=O,l));else if("increasedLineWidthForHitTesting"===i)a.material.setUniforms(((c={})[Ei.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=I||0,c));else if("anchor"===i||"modelMatrix"===i){var B=0,L=0,F=e.getGeometryBounds();if(F){var b=F.halfExtents;B=-b[0]*P[0]*2,L=-b[1]*P[1]*2}var U=p();m(U,e.getWorldTransform(),E(U,T(B,L,0))),a.material.setUniforms(((f={})[Ei.MODEL_MATRIX]=U,f))}else if("visibility"===i)a.material.setUniforms(((d={})[Ei.VISIBLE]="visible"===x?1:0,d));else if("lineDash"===i)a.material.setUniforms(((h={})[Ei.DASH]=N[0]||0,h[Ei.GAP]=N[1]||0,h));else if("lineDashOffset"===i)a.material.setUniforms(((_={})[Ei.DASH_OFFSET]=M||0,_));else if("pointerEvents"===i){var G=o&&e.isInteractive()&&(null===(v=e.renderable3D)||void 0===v?void 0:v.encodedPickingColor)||[0,0,0];a.material.setUniforms(((R={})[Ei.PICKING_COLOR]=G,R))}}))},r.prototype.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ei.Z_INDEX]=t*Bn,r))},r.prototype.createMaterial=function(e){var r,n;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 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\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\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\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\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\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 next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\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 gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\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 if (u_Dash + u_Gap > 1.0) {\n float 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 float travel = mod(v_Travel + u_Gap * scalingFactor * 0.5 + u_DashOffset, u_Dash * scalingFactor + u_Gap * scalingFactor) - (u_Gap * scalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * scalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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 outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}",this.material.defines=i(i({},this.material.defines),kn(_i));var o=e[0],a=o.parsedStyle,s=a.fill,u=a.stroke,l=a.opacity,c=a.fillOpacity,f=a.strokeOpacity,d=a.lineWidth,h=a.increasedLineWidthForHitTesting,_=a.anchor,R=a.lineDash,v=a.lineDashOffset,g=a.visibility,A=[0,0,0,0];t.isCSSRGB(s)&&(A=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var y=[0,0,0,0];t.isCSSRGB(u)&&(y=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var S=o.isInteractive()&&(null===(n=o.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0],C=0,O=0,I=o.getGeometryBounds();if(I){var P=I.halfExtents;C=-P[0]*_[0]*2,O=-P[1]*_[1]*2}var N=p();m(N,o.getWorldTransform(),E(N,T(C,O,0))),this.material.setUniforms(((r={})[Ei.MODEL_MATRIX]=N,r[Ei.FILL_COLOR]=A,r[Ei.STROKE_COLOR]=y,r[Ei.STROKE_WIDTH]=d,r[Ei.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=h||0,r[Ei.OPACITY]=l,r[Ei.FILL_OPACITY]=c,r[Ei.STROKE_OPACITY]=f,r[Ei.EXPAND]=1,r[Ei.MITER_LIMIT]=5,r[Ei.SCALE_MODE]=1,r[Ei.ALIGNMENT]=.5,r[Ei.PICKING_COLOR]=S,r[Ei.DASH]=R&&R[0]||0,r[Ei.GAP]=R&&R[1]||0,r[Ei.DASH_OFFSET]=v||0,r[Ei.VISIBLE]="visible"===g?1:0,r[Ei.Z_INDEX]=o.sortable.renderOrder*Bn,r)),this.material.cullMode=he.None},r.prototype.createGeometry=function(e){var t=mi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:hi.PACKED,byteStride:48,frequency:ye.PerInstance,attributes:[{format:be.F32_RG,bufferByteOffset:0,byteStride:12,location:_i.PREV,divisor:1},{format:be.F32_RG,bufferByteOffset:12,byteStride:12,location:_i.POINT1,divisor:1},{format:be.F32_R,bufferByteOffset:20,byteStride:12,location:_i.VERTEX_JOINT,divisor:1},{format:be.F32_RG,bufferByteOffset:24,byteStride:12,location:_i.POINT2,divisor:1},{format:be.F32_RG,bufferByteOffset:36,byteStride:12,location:_i.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:hi.VERTEX_NUM,byteStride:4,frequency:ye.PerInstance,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:_i.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:hi.TRAVEL,byteStride:4,frequency:ye.PerInstance,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:_i.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=n,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))},r}(Zn);function mi(e,r){var n;void 0===r&&(r=!1);var i=e.parsedStyle,o=i.lineCap,a=i.lineJoin,s=e.parsedStyle,u=s.defX,f=s.defY,d=e.parsedStyle,h=d.markerStart,E=d.markerEnd,R=d.markerStartOffset,m=d.markerEndOffset,T=[],v=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var A=e.parsedStyle.points.points,y=A.length,S=0,C=0,O=0,I=0,P=0;if(h&&t.isDisplayObject(h)&&R&&(S=Math.cos(P=Math.atan2(A[1][1]-A[0][1],A[1][0]-A[0][0]))*(R||0),C=Math.sin(P)*(R||0)),E&&t.isDisplayObject(E)&&m&&(O=Math.cos(P=Math.atan2(A[y-2][1]-A[y-1][1],A[y-2][0]-A[y-1][0]))*(m||0),I=Math.sin(P)*(m||0)),T[0]=A.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=S,i=C):r===y-1&&(n=O,i=I),e.push(t[0]-u+n,t[1]-f+i),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return v=ne(T[0],[],2),{pointsBuffer:T[0],travelBuffer:[],triangles:v,instancedCount:Math.round(T[0].length/2)};T[0].push(T[0][0],T[0][1]),(n=T[0]).push.apply(n,c([],l(Ti(T[0][0],T[0][1],T[0][2],T[0][3])),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var N=void 0;if(e.nodeName!==t.Shape.PATH){if(N=t.parsePath(t.convertToPath(e,_(p())),e),u=N.rect.x,f=N.rect.y,e.nodeName===t.Shape.RECT){var M=e.parsedStyle;0>M.width&&(u+=N.rect.width),0>M.height&&(f+=N.rect.height)}}else N=e.parsedStyle.path;var x=N.absolutePath,D=N.segments,B=0,L=0,F=0,b=0;P=0;if(h&&t.isDisplayObject(h)&&R){var U=l(h.parentNode.getStartTangent(),2);B=Math.cos(P=Math.atan2((G=U[0])[1]-(w=U[1])[1],G[0]-w[0]))*(R||0),L=Math.sin(P)*(R||0)}if(E&&t.isDisplayObject(E)&&m){var G,w,k=l(E.parentNode.getEndTangent(),2);F=Math.cos(P=Math.atan2((G=k[0])[1]-(w=k[1])[1],G[0]-w[0]))*(m||0),b=Math.sin(P)*(m||0)}var V=-1,W=-1;if(x.forEach((function(r,n){var i,o=l(r),a=o[0],s=o.slice(1),p=x[n+1],d=0===n&&(0!==B||0!==L),h=(n===x.length-1||p&&("M"===p[0]||"Z"===p[0]))&&0!==F&&0!==b;if("M"===a)W++,T[W]=[],V=T[W].length,d?T[W].push(s[0]-u+B,s[1]-f+L,s[0]-u,s[1]-f):T[W].push(s[0]-u,s[1]-f);else if("L"===a)h?T[W].push(s[0]-u+F,s[1]-f+b):T[W].push(s[0]-u,s[1]-f);else if("Q"===a)si(s[0]-u,s[1]-f,s[2]-u,s[3]-f,T[W]),h&&T[W].push(s[2]-u+F,s[3]-f+b);else if("A"===a){for(var _=l(D[n].prePoint,2),E=g(_[0],_[1],s[0],s[1],s[2],s[3],s[4],s[5],s[6],void 0),R=0;E.length>R;R+=6)ui(E[R]-u,E[R+1]-f,E[R+2]-u,E[R+3]-f,E[R+4]-u,E[R+5]-f,T[W]);h&&T[W].push(s[5]-u+F,s[6]-f+b)}else if("C"===a)ui(s[0]-u,s[1]-f,s[2]-u,s[3]-f,s[4]-u,s[5]-f,T[W]),h&&T[W].push(s[4]-u+F,s[5]-f+b);else if("Z"===a&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var m=1e-4;(Math.abs(T[W][T[W].length-2]-T[W][V])>m||Math.abs(T[W][T[W].length-1]-T[W][V+1])>m)&&T[W].push(T[W][V],T[W][V+1]),(i=T[W]).push.apply(i,c([],l(Ti(T[W][V],T[W][V+1],T[W][V+2],T[W][V+3])),!1))}})),r){var X=T.reduce((function(e,t){return e.push.apply(e,c([],l(t),!1)),e}),[]);return{pointsBuffer:X,travelBuffer:[],triangles:v=ne(X,[],2),instancedCount:Math.round(X.length/2)}}}var H=function(e){var t;switch(e){case"bevel":t=li.JOINT_BEVEL;break;case"round":t=li.JOINT_ROUND;break;default:t=li.JOINT_MITER}return t}(a),Y=function(e){var t;switch(e){case"square":t=li.CAP_SQUARE;break;case"round":t=li.CAP_ROUND;break;default:t=li.CAP_BUTT}return t}(o),K=Y;return Y===li.CAP_ROUND&&(K=li.JOINT_CAP_ROUND),Y===li.CAP_BUTT&&(K=li.JOINT_CAP_BUTT),Y===li.CAP_SQUARE&&(K=li.JOINT_CAP_SQUARE),T.map((function(e){for(var t=6,r=0,n=[],i=[],o=0;e.length>o;o+=2)o>1&&(r+=Math.sqrt(Math.pow(e[o]-e[o-2],2)+Math.pow(e[o+1]-e[o+1-2],2))),i.push(r),n[t++]=e[o],n[t++]=e[o+1],n[t]=H,0==o&&Y!==li.CAP_ROUND&&(n[t]+=Y),e.length>o+4?e.length>o+2||(n[t]=0):n[t]+=K-H,t++;return n[t++]=e[e.length-4],n[t++]=e[e.length-3],n[t++]=0,n[0]=e[0],n[1]=e[1],n[2]=0,n[3]=e[2],n[4]=e[3],n[5]=Y===li.CAP_ROUND?Y:0,{pointsBuffer:n,travelBuffer:i,triangles:v,instancedCount:Math.round(e.length/2)}})).reduce((function(e,t){var r,n;return(r=e.pointsBuffer).push.apply(r,c([],l(t.pointsBuffer),!1)),(n=e.travelBuffer).push.apply(n,c([],l(t.travelBuffer),!1)),e.instancedCount+=t.instancedCount,e}),{pointsBuffer:[],travelBuffer:[],triangles:v,instancedCount:0})}function Ti(e,t,r,n){void 0===r&&(r=e),void 0===n&&(n=t);var i=[r-e,n-t];return[e+.01*i[0],t+.01*i[1]]}var vi=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(e,t){return!1},r.prototype.createGeometry=function(e){var t=e[0],r=mi(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:8,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Yn.POSITION}],data:new Float32Array(i)});var o=t.getGeometryBounds().halfExtents,a=i.map((function(e,t){return e/o[t%2]/2}));this.geometry.setVertexBuffer({bufferIndex:Hn.UV,byteStride:8,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Yn.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))},r.prototype.createMaterial=function(e){var r,n;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nlayout(location = POSITION) in vec2 a_Position;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * vec4(a_Position, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\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\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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\n vec4 u_Color = u_FillColor;\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 outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}";var i=e[0],o=i.parsedStyle,a=o.fill,s=o.opacity,u=o.fillOpacity,l=o.anchor,c=o.visibility,f=[0,0,0,0];t.isCSSRGB(a)&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var d=i.isInteractive()&&(null===(n=i.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0],h=0,_=0,R=i.getGeometryBounds();if(R){var v=R.halfExtents;h=-v[0]*l[0]*2,_=-v[1]*l[1]*2}var g=p();m(g,i.getWorldTransform(),E(g,T(h,_,0))),this.material.setUniforms(((r={})[Ei.MODEL_MATRIX]=g,r[Ei.FILL_COLOR]=f,r[Ei.PICKING_COLOR]=d,r[Ei.OPACITY]=s,r[Ei.FILL_OPACITY]=u,r[Ei.VISIBLE]="visible"===c?1:0,r[Ei.Z_INDEX]=i.sortable.renderOrder*Bn,r))},r.prototype.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r,n,s,u,l,c,f,d=e.parsedStyle,h=d.fill,_=d.opacity,R=d.fillOpacity,v=d.anchor,g=d.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===i||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("fill"===i)if(t.isCSSRGB(h)){a.material.setUniforms(((r={})[Ei.FILL_COLOR]=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)],r))}else{var A=a.textureMappings.findIndex((function(e){return e.name===zn})),y=a.createFillGradientTextureMapping([a.instance]);0>A||a.textureMappings.splice(A,1,y),a.material.textureDirty=!0}else if("opacity"===i)a.material.setUniforms(((n={})[Ei.OPACITY]=_,n));else if("fillOpacity"===i)a.material.setUniforms(((s={})[Ei.FILL_OPACITY]=R,s));else if("anchor"===i||"modelMatrix"===i){var S=0,C=0,O=e.getGeometryBounds();if(O){var I=O.halfExtents;S=-I[0]*v[0]*2,C=-I[1]*v[1]*2}var P=p();m(P,e.getWorldTransform(),E(P,T(S,C,0))),a.material.setUniforms(((u={})[Ei.MODEL_MATRIX]=P,u))}else if("visibility"===i)a.material.setUniforms(((l={})[Ei.VISIBLE]="visible"===g?1:0,l));else if("pointerEvents"===i){var N=o&&e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];a.material.setUniforms(((c={})[Ei.PICKING_COLOR]=N,c))}}))},r.prototype.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ei.Z_INDEX]=t*Bn,r))},r}(Zn),gi=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.img===t.parsedStyle.img},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=i({},this.material.defines),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\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\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\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n bool isBillboard = a_Size.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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\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}";var r=this.texturePool.getOrCreateTexture(this.context.device,t);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[],i=[];t.forEach((function(e,t){var o=4*t,a=e.parsedStyle;r.push(a.width,a.height,a.z,a.isBillboard?1:0),n.push(0,0,1,0,1,1,0,1),i.push(0+o,2+o,1+o,0+o,3+o,2+o)})),this.geometry.setIndexBuffer(new Uint32Array(i)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:16,frequency:ye.PerInstance,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Hn.UV,byteStride:8,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Yn.UV}],data:new Float32Array(n)})},t.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"width"===n||"height"===n||"z"===n||"isBillboard"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height,t.z,t.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Hn.POSITION,Yn.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:a})}},t}(Zn);function Ai(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function yi(e,t,r,n,i,o){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 a=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*o,c=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[l+f];return t}var Si=function(){function e(e,t){Ai(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Ai({},{width:n,height:i},r);yi(e,o,{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=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){yi(e,t,r,n,i,1)},e}();var Ci=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=u(e),l=s.next();!l.done;l=s.next())o+=(_=l.value).w*_.h,a=Math.max(a,_.w)}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,p=0;try{for(var d=u(e),h=d.next();!h.done;h=d.next())for(var _=h.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=_.w&&R.h>=_.h){if(_.x=R.x,_.y=R.y,p=Math.max(p,_.y+_.h),f=Math.max(f,_.x+_.w),_.w===R.w&&_.h===R.h){var m=c.pop();c.length>E&&(c[E]=m)}else _.h===R.h?(R.x+=_.w,R.w-=_.w):_.w===R.w?(R.y+=_.h,R.h-=_.h):(c.push({x:R.x+_.w,y:R.y,w:R.w-_.w,h:_.h}),R.y+=_.h,R.h-=_.h);break}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}return{w:f,h:p,fill:o/(f*p)||0}}(r),l=new Si({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&Si.copy(c.bitmap,l,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=l,this.positions=t};var Oi,Ii,Pi,Ni=function(){function e(){this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,u=[],l=o,c=a,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),o=r&&r[n];o&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;l=0,c+=r})),u},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var u=this;void 0===t&&(t=""),void 0===o&&(o="");var l=[];this.glyphMap[t]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)})),l.length){var f=l.map((function(i){return u.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new Ci(this.glyphMap);var p=this.glyphAtlas.image,d=p.width,h=p.height,_=p.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},We(be.ALPHA,d,h,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([_],0)}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new fi({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var u=s.draw(o),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,p=u.glyphTop,d=u.glyphAdvance;return{id:a,bitmap:new Si({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:p-24+3,advance:d}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(Oi||(Oi={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(Ii||(Ii={})),function(e){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"}(Pi||(Pi={}));var Mi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.glyphManager=new Ni,t.packedBufferObjectMap=new WeakMap,t.tmpMat4=p(),t}return n(r,e),r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.instance;return n.parsedStyle.metrics.font===t.parsedStyle.metrics.font&&!["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(e){return n.parsedStyle[e]!==t.parsedStyle[e]}))},r.prototype.createGeometry=function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],u=[],f=0;e.forEach((function(e){var r=e.parsedStyle,p=r.metrics,d=p.font,h=p.lines,_=p.height,E=p.lineHeight,R=r.dx||0,m=r.dy||0,T=0;"middle"===n?T=-_/2:"bottom"===n?T=-_:"top"===n||"hanging"===n?T=0:"alphabetic"===n?T=.25*E-_:"ideographic"===n&&(T=-_);var v=t.glyphManager.getAtlas(),g=t.buildTextBuffers({object:e,lines:h,fontStack:d,lineHeight:o*E,offsetX:o*R,offsetY:o*(T+m),letterSpacing:o*i,glyphAtlas:v,indicesOffset:f}),A=g.indexBuffer,y=g.charUVOffsetBuffer;f=g.indicesOffset;var S=u.length;u.push.apply(u,c([],l(g.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[S,u.length]),s.push.apply(s,c([],l(y),!1)),a.push.apply(a,c([],l(A),!1))})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:Oi.INSTANCED,byteStride:128,frequency:ye.PerVertex,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Yn.MODEL_MATRIX0},{format:be.F32_RGBA,bufferByteOffset:16,location:Yn.MODEL_MATRIX1},{format:be.F32_RGBA,bufferByteOffset:32,location:Yn.MODEL_MATRIX2},{format:be.F32_RGBA,bufferByteOffset:48,location:Yn.MODEL_MATRIX3},{format:be.F32_RGBA,bufferByteOffset:64,location:Yn.PACKED_COLOR},{format:be.F32_RGBA,bufferByteOffset:80,location:Yn.PACKED_STYLE1},{format:be.F32_RGBA,bufferByteOffset:96,location:Yn.PACKED_STYLE2},{format:be.F32_RGBA,bufferByteOffset:112,location:Yn.PICKING_COLOR}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:Oi.TEX,byteStride:16,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Ii.TEX},{format:be.F32_RG,bufferByteOffset:8,location:Ii.OFFSET}],data:new Float32Array(s)})},r.prototype.createMaterial=function(e){var t;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\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\nout float v_GammaScale;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\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\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n float sizeAttenuation = a_StylePacked2.z;\n vec2 offset = a_Offset * fontScale;\n\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n v_GammaScale = 1.0;\n } else {\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\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\nin float v_GammaScale;\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\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\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 gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\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 < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=he.Back,this.material.defines=i(i({},this.material.defines),kn(Ii));var r=this.instance.parsedStyle,n=r.fontSize,o=r.fontFamily,a=void 0===o?"":o,s=r.fontWeight,u=void 0===s?"":s,l=r.fontStyle,c=r.metrics.font,f=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,c,a,""+u,l,f,this.context.device);var p=this.glyphManager.getAtlasTexture(),d=this.glyphManager.getAtlas();this.context.device.setResourceName(p,"TextSDF Texture");var h=d.image,_=h.width,E=h.height;this.material.setUniforms(((t={})[Pi.SDF_MAP]=p,t[Pi.SDF_MAP_SIZE]=[_,E],t[Pi.FONT_SIZE]=n,t[Pi.GAMMA_SCALE]=1,t[Pi.STROKE_BLUR]=.2,t[Pi.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[Oi.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oi.INSTANCED].byteStride/4,i=l(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),u=0;a-o>u;u+=n)s[u+n-1]=t*Bn;this.geometry.updateVertexBuffer(Oi.INSTANCED,Yn.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(e,r,n,i){var o=this;if("text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"visibility"===n||"dx"===n||"dy"===n)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===n||"fill"===n||"fillOpacity"===n||"stroke"===n||"strokeOpacity"===n||"opacity"===n||"lineWidth"===n||"pointerEvents"===n){var a=this.geometry.vertices[Oi.INSTANCED],s=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Oi.INSTANCED].byteStride/4;e.forEach((function(e){var r,i=e.parsedStyle,u=i.fill,c=i.stroke,f=i.opacity,p=i.fillOpacity,h=i.strokeOpacity,_=i.lineWidth,E=i.visibility,R=i.isBillboard,m=i.sizeAttenuation,T=[0,0,0,0];t.isCSSRGB(u)&&(T=[Number(u.r),Number(u.g),Number(u.b),255*Number(u.alpha)]);var v=[0,0,0,0];t.isCSSRGB(c)&&(v=[Number(c.r),Number(c.g),Number(c.b),255*Number(c.alpha)]);for(var g=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],A="modelMatrix"===n?d(o.tmpMat4,e.getWorldTransform()):null,y=l(o.packedBufferObjectMap.get(e),2),S=y[0],C=y[1],O=a.slice(S,C),I=0;C-S>I;I+=s)"modelMatrix"===n?(O[I+0]=A[0],O[I+1]=A[1],O[I+2]=A[2],O[I+3]=A[3],O[I+4]=A[4],O[I+5]=A[5],O[I+6]=A[6],O[I+7]=A[7],O[I+8]=A[8],O[I+9]=A[9],O[I+10]=A[10],O[I+11]=A[11],O[I+12]=A[12],O[I+13]=A[13],O[I+14]=A[14],O[I+15]=A[15]):"fill"===n?(O[I+16]=Xn(T[0],T[1]),O[I+17]=Xn(T[2],T[3])):"stroke"===n&&(O[I+18]=Xn(v[0],v[1]),O[I+19]=Xn(v[2],v[3])),O[I+20]=f,O[I+21]=p,O[I+22]=h,O[I+23]=_,O[I+24]="visible"===E?1:0,O[I+25]=R?1:0,O[I+26]=m?1:0,O[I+27]=0,O[I+28]=g[0],O[I+29]=g[1],O[I+30]=g[2];o.geometry.updateVertexBuffer(Oi.INSTANCED,Yn.MODEL_MATRIX0,S/s,new Uint8Array(O.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,f=e.offsetY,p=e.glyphAtlas,h=e.indicesOffset,_=n.parsedStyle,E=_.textAlign,R=_.fill,m=_.stroke,T=_.opacity,v=_.fillOpacity,g=_.strokeOpacity,A=_.lineWidth,y=_.visibility,S=_.isBillboard,C=_.sizeAttenuation,O=[0,0,0,0];t.isCSSRGB(R)&&(O=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var I=[0,0,0,0];t.isCSSRGB(m)&&(I=[Number(m.r),Number(m.g),Number(m.b),255*Number(m.alpha)]);var P=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],N=d(this.tmpMat4,n.getWorldTransform()),M=[],x=[],D=[],B=h,L=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var u=a.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(a.metrics.left-4)*i.scale-u+l[0],f=(-a.metrics.top-4)*i.scale+l[1],p=c+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:p,y:f},bl:{x:c,y:d},br:{x:p,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,u,f),p.positions);return L.forEach((function(e){var t=[];t.push.apply(t,c([],l(N),!1));var r=c(c(c(c([],l(t),!1),[Xn(O[0],O[1]),Xn(O[2],O[3]),Xn(I[0],I[1]),Xn(I[2],I[3]),T,v,g,A,"visible"===y?1:0,S?1:0,C?1:0,0],!1),l(P),!1),[n.sortable.renderOrder*Bn],!1);M.push.apply(M,c(c(c(c([],l(r),!1),l(r),!1),l(r),!1),l(r),!1)),x.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),x.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),x.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),x.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),D.push(0+B,2+B,1+B),D.push(2+B,0+B,3+B),B+=4})),{indexBuffer:D,charUVOffsetBuffer:x,charPackedBuffer:M,indicesOffset:B}},r}(Zn),xi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.lightReceived=!0,t}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Zn),Di=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ei,Ri],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&o>0&&(1>a||l)},t}(Ln),Bi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[vi,Ri,ni],t}return n(r,e),r.prototype.shouldSubmitRenderInst=function(e,r){var n=e.parsedStyle,i=n.fill,o=n.stroke,a=n.opacity,s=n.strokeOpacity,u=n.lineDash,l=n.lineWidth,c=e.nodeName,f=o&&!o.isNone,p=u&&u.length&&u.every((function(e){return 0!==e})),d=this.isLine(e);if(e.renderable.proxyNodeName=d?t.Shape.LINE:null,0===r&&(e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(d||0===s||0===a||0===l||!f)return!1;if(c===t.Shape.CIRCLE||c===t.Shape.ELLIPSE)return p}return 2!==r||d},r.prototype.isLine=function(e){if(e.nodeName===t.Shape.PATH){var r=e.parsedStyle.path.absolutePath;if(2===r.length&&"M"===r[0][0]&&"L"===r[1][0])return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var n=e.parsedStyle.points.points,i=(n[1][0]-n[1][1])/(n[0][0]-n[0][1]),o=1;n.length-1>o;o++)if((n[o+1][0]-n[o+1][1])/(n[o][0]-n[o][1])!==i)return!1;return!0}return!1},r}(Ln);!function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[],t}n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0}}(Ln);var Li,Fi,bi,Ui=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[gi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Ln),Gi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[Mi,Mi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle,n=r.stroke;return!((!n||n.isNone||!r.lineWidth)&&0===t)},t.prototype.beforeUploadUBO=function(e,t,r){var n;t.material.setUniforms(((n={})[Pi.HAS_STROKE]=1-t.index,n))},t}(Ln),wi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ni],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Ln),ki=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[xi],t}return n(t,e),t}(Ln),Vi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ei,vi,Ri],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle.radius,n=r&&r.length&&r.some((function(e){return e!==r[0]}));if(0===t&&(e.parsedStyle.fill.isNone||n))return!1;return 1===t?n:2!==t||(n||this.needDrawStrokeSeparately(e))},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&o>0&&(1>a||l)},t}(Ln),Wi=1,Xi=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(r.context);var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.meshes.length){var n=this.rendererFactory[e.nodeName];n&&n.meshes.forEach((function(i,o){if(r.meshes[o]=void 0,n.shouldSubmitRenderInst(e,o)){var a=t.meshes.find((function(t){return i===t.constructor&&t.index===o&&t.shouldMerge(e,o)}));a&&a.key===e.parsedStyle.batchKey||((a=new i(t.renderHelper,t.texturePool,t.lightPool)).renderer=n,a.index=o,t.meshes.push(a),e.parsedStyle.batchKey&&(a.key=e.parsedStyle.batchKey)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.meshes.forEach((function(r){if(r){var n=r.objects.indexOf(e);n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length&&t.meshes.splice(t.meshes.indexOf(r),1)}})),r.meshes=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];a&&a.meshes.forEach((function(s,u){var l=a.shouldSubmitRenderInst(e,u),c=o.meshes.find((function(e){return e&&e.index===u&&e.constructor===s}));if(l!==!!c&&(c&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.meshes.splice(i.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=i.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((c=new s(i.renderHelper,i.texturePool,i.lightPool)).renderer=a,c.index=u,c.init(i.context),i.meshes.push(c)),c&&(c.objects.push(e),o.meshes[u]=c))),l&&c&&c.inited&&!c.geometryDirty){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var p=c.id+t;i.pendingUpdatePatches[p]||(i.pendingUpdatePatches[p]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[p].objectIndices.indexOf(f)&&i.pendingUpdatePatches[p].objectIndices.push(f)}}}))},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.meshes.length&&r.meshes.forEach((function(r){r&&r.inited&&!r.geometryDirty&&(r.renderer.shouldSubmitRenderInst(e,r.index)&&r.inited&&r.changeRenderOrder(e,t))}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=Wi++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=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],o,a)}))})),this.pendingUpdatePatches={}},e}(),Hi=function(){function e(e){this.context=e,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,u="string"==typeof r?r:r.src||"";if(u&&this.textureCache[u])(a=this.textureCache[u]).emit(Se.LOADED);else if(a=e.createTexture(i({pixelFormat:be.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:Ce.n2D,usage:Oe.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),u&&(this.textureCache[u]=a),C(r)){var l,c=this.context.config.createImage;c?l=c(r):t.isBrowser&&(l=new window.Image),l&&(l.onload=function(){s.textureCache[u].setImageData(l),s.textureCache[u].emit(Se.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[u])},l.onerror=function(){},l.crossOrigin="Anonymous",l.src=r)}else a.setImageData(r),a.emit(Se.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return t.runtime.offscreenCanvas.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,o=2*n[0]||1,a=2*n[1]||1,s=this.context.config.offscreenCanvas,u=t.runtime.offscreenCanvas.getOrCreateCanvas(s),l=t.runtime.offscreenCanvas.getOrCreateContext(s);u.width=o,u.height=a;var c=this.context.imagePool;r.forEach((function(e){var t=c.getOrCreateGradient(i(i({type:e.type},e.value),{width:o,height:a}),l);l.fillStyle=t,l.fillRect(0,0,o,a)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,p=t.runtime.offscreenCanvas.getOrCreateCanvas(f),d=t.runtime.offscreenCanvas.getOrCreateContext(f);p.width=l,p.height=c;var h=(i=C(o)?this.context.imagePool.getImageSync(o,n):o)&&d.createPattern(i,a);if(s){var _=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));h.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}d.fillStyle=h,d.fillRect(0,0,l,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),Yi="#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}",Ki=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.vert=Yi,t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord);\n}",t.features={},t}return n(t,e),t}(Or),zi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert=Yi,t.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}",t}return n(t,e),t}(Or),ji=Rt(1,(function(){return new Cn}));var qi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="device-renderer",t.parameters={toneMapping:kr.NONE,toneMappingExposure:1},t}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new ke;var n=new _n(this.parameters),i=new Ge,o=new Hi(this.context),a=new Ve,s=new Di,u=new Bi,l=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=u,r[t.Shape.PATH]=u,r[t.Shape.POLYGON]=u,r[t.Shape.RECT]=new Vi,r[t.Shape.IMAGE]=new Ui,r[t.Shape.LINE]=new wi,r[t.Shape.TEXT]=new Gi,r[t.Shape.MESH]=new ki,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new Xi(n,l,o,i),f=new xn(n,i,o,c);this.addRenderingPlugin(f),this.addRenderingPlugin(new Dn(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),Zi=Object.freeze({__proto__:null,get AntialiasingMode(){return mn},Batch:Ln,get BlendFactor(){return _e},get BlendMode(){return Ee},get BufferFrequencyHint(){return Ae},BufferGeometry:Un,get BufferUsage(){return ge},get ChannelWriteMask(){return Ie},get ClipSpaceNearZ(){return xe},get CompareMode(){return pe},CopyProgram:Ki,get CullMode(){return he},DeviceProgram:Or,DynamicUniformBuffer:Ir,get Endianness(){return Mt},FILL_TEXTURE_MAPPING:zn,FillMesh:vi,Fog:Nn,get FogType(){return Sn},get Format(){return be},get FormatCompFlags(){return Le},get FormatFlags(){return Fe},get FormatTypeFlags(){return Be},get FrontFaceMode(){return de},get GL(){return ce},get GeometryEvent(){return Mn},HashMap:Dr,ImageMesh:gi,Instanced:Zn,InstancedLineMesh:ni,IsDepthReversed:st,get JOINT_TYPE(){return li},Light:In,LineMesh:Ri,Material:Gn,get MaterialEvent(){return bn},Mesh:we,MeshMesh:xi,get MipFilterMode(){return Te},OpaqueBlack:it,OpaqueWhite:at,Plugin:qi,get PrimitiveTopology(){return ve},get QueryPoolType(){return De},get RGAttachmentSlot(){return Vr},RenderCache:Wr,RenderGraphPlugin:xn,RenderHelper:_n,RenderInst:cn,get RenderInstExecutionOrder(){return ln},get RenderInstFlags(){return an},RenderInstList:pn,RenderInstManager:hn,Renderable3D:Ue,get RendererLayer(){return Xr},get ResourceType(){return fe},SDFMesh:ei,get SamplerFormatKind(){return Ne},ShaderMaterial:wn,SingleSampledTexture:Kr,get StencilOp(){return Pe},TemporalTexture:On,get TexFilterMode(){return me},TextMesh:Mi,get TextUniform(){return Pi},get TextureDimension(){return Ce},get TextureEvent(){return Se},TextureMapping:Cn,TexturePool:Hi,get TextureUsage(){return Oe},TinySDF:fi,get ToneMapping(){return kr},TransparentBlack:nt,TransparentWhite:ot,UNIFORM_SETTERS:Tr,get Uniform(){return Ei},get VertexAttributeBufferIndex(){return Hn},get VertexAttributeLocation(){return Yn},get VertexBufferFrequency(){return ye},get ViewportOrigin(){return Me},get WrapMode(){return Re},align:pt,alignNonPowerOfTwo:dt,arrayCopy:Bt,arrayEqual:Dt,assert:Qe,assertExists:Je,bezierCurveTo:ui,bindingLayoutDescriptorCopy:Jt,bindingLayoutDescriptorEqual:Ut,bindingLayoutSamplerDescriptorCopy:Qt,bindingsDescriptorCopy:Zt,bindingsDescriptorEquals:Gt,bisectRight:ht,bufferBindingCopy:qt,colorCopy:et,colorEqual:$e,colorNewCopy:tt,colorNewFromRGBA:rt,compareDefines:Vn,compareDepthValues:function(e,t,r,n){if(void 0===n&&(n=st),(r=ut(r,n))===pe.Less)return t>e;if(r===pe.LessEqual)return t>=e;if(r===pe.Greater)return e>t;if(r===pe.GreaterEqual)return e>=t;throw Error("whoops")},copyAttachmentState:vt,copyAttachmentStateFromSimple:St,copyMegaState:yt,defaultBindingLayoutSamplerDescriptor:xt,defaultMegaState:Ot,definedProps:Wn,enumToObject:kn,fallbackUndefined:lt,fillArray:ft,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),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,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:un,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},fullscreenMegaState:Pt,getAttributeLocations: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 o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r},getDefines: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},getFormatByteSize:function(e){return je(Ke(e))*Ye(e)},getFormatCompByteSize:qe,getFormatCompFlags:Ye,getFormatCompFlagsComponentCount:Xe,getFormatComponentCount:function(e){return Ye(e)},getFormatFlags:ze,getFormatSamplerKind:Ze,getFormatTypeFlags:Ke,getFormatTypeFlagsByteSize:je,getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},getSystemEndianness:function(){return or},getUniformSetter:function(e,t,r){var n=Tr[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)},getUniforms:Ar,hashCodeNumberFinish:Nr,hashCodeNumberUpdate:Pr,inputLayoutBufferDescriptorCopy:tr,inputLayoutBufferDescriptorEquals:Yt,inputLayoutDescriptorCopy:rr,inputLayoutDescriptorEquals:Kt,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:mt,makeAttachmentClearDescriptor:Rn,makeBackbufferDescSimple:yn,makeDepthKey:Qr,makeFormat:He,makeMegaState:It,makeSortKey:function(e,t){return void 0===t&&(t=0),e&Xr.TRANSLUCENT?rn(e):en(e,t)},makeSortKeyOpaque:en,makeSortKeyTranslucent:rn,makeStaticDataBuffer:Fn,makeTextureDescriptor2D:We,nArray:Rt,nullHashFunc:Mr,nullify:ct,opaqueBlackFullClearRenderPassDescriptor:vn,opaqueWhiteFullClearRenderPassDescriptor:gn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(ar);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]}},prependLineNo:function(e,t){return void 0===t&&(t=1),e.split("\n").map((function(e,r){return"".concat(mt(""+(t+r),4," ")," ").concat(e)})).join("\n")},preprocessProgramObj_GLSL:Cr,preprocessProgram_GLSL:Sr,preprocessShader_GLSL:yr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===xe.NegativeOne?function(e){m(e,on,e)}(e):t===xe.Zero&&function(e){m(e,sn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Vr.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Pt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);un(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new zi,l=t.renderCache.createProgram(u);a.setProgram(l),Li||((Li=new Un(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:ye.PerVertex,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-1,-3,-1,1,3,-1])}),Li.vertexCount=3,bi=t.getCache().createInputLayout(Li.inputLayoutDescriptor),Fi=t.getDevice().createInputState(bi,Li.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){ji[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(ji),a.setInputLayoutAndState(bi,Fi),a.drawOnPass(t.renderCache,e)}))}))},quadCurveTo:si,range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:fn,renderPipelineDescriptorCopy:$t,renderPipelineDescriptorEquals:Xt,reverseDepthForClearValue:function(e,t){return void 0===t&&(t=st),t?1-e:e},reverseDepthForCompareMode:ut,reverseDepthForDepthOffset:function(e,t){return void 0===t&&(t=st),t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e,t){void 0===t&&(t=st),t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e,t){void 0===t&&(t=st),t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:jt,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:zt,segmentInstanceGeometry:ti,setAttachmentStateSimple:Nt,setBackbufferDescSimple:An,setBitFlagEnabled:Et,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:At,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=qr);var n=!!(e>>>31&1),i=Qr(t,n,r);return n?nn(e,i):tn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?nn(e,t):tn(e,t)},setSortKeyLayer:Jr,setSortKeyOpaqueDepth:tn,setSortKeyProgramKey:$r,setSortKeyTranslucentDepth:nn,spliceBisectRight:_t,standardFullClearRenderPassDescriptor:Tn,updateBuffer:mi,vertexAttributeDescriptorCopy:er,vertexAttributeDescriptorEquals:Ht}),Qi=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.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)},p=function(e){i.hooks.pointerOut.call(e)},d=function(e){i.hooks.pointerCancel.call(e)},h=function(e){i.hooks.pointerWheel.call(e)},_=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",p,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",l,!0),r.globalThis.addEventListener("pointercancel",d,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",u,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",p,!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",d,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",_,!0),e.addEventListener("wheel",h,{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",p,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",l,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",u,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",p,!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",d,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",_,!0),e.removeEventListener("wheel",h,!0)}))},e.tag="DOMInteraction",e}(),Ji=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new Qi)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),$i=Object.freeze({__proto__:null,Plugin:Ji}),eo=function(){function e(){}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(r){var n=this,i=r.camera,o=r.renderingContext,a=r.renderingService;this.context=r;var s=o.root.ownerDocument.defaultView,u=function(e,t){t.style.transform=n.joinTransformMatrix(e.getWorldTransform())},l=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){n.$camera||(n.$camera=n.createCamera(i));var o=n.getOrCreateEl(r);n.$camera.appendChild(o);var a=r.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(e){o.style[e]=a[e]})),Object.keys(r.attributes).forEach((function(e){n.updateAttribute(e,r)})),u(r,o),t.runtime.nativeHTMLMap.set(o,r)}},c=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&n.$camera){var i=n.getOrCreateEl(r);i&&(i.remove(),t.runtime.nativeHTMLMap.delete(i))}},f=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&n.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var i=n.getOrCreateEl(r);u(r,i)}},d=function(){if(n.$camera){var e=n.context.config,t=e.height;n.$camera.style.width="".concat(e.width||0,"px"),n.$camera.style.height="".concat(t||0,"px")}};a.hooks.init.tap(e.tag,(function(){s.addEventListener(t.CanvasEvent.RESIZE,d),s.addEventListener(t.ElementEvent.MOUNTED,l),s.addEventListener(t.ElementEvent.UNMOUNTED,c),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),a.hooks.endFrame.tap(e.tag,(function(){n.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(n.$camera.style.transform=n.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(e.tag,(function(){n.$camera&&n.$camera.remove(),s.removeEventListener(t.CanvasEvent.RESIZE,d),s.removeEventListener(t.ElementEvent.MOUNTED,l),s.removeEventListener(t.ElementEvent.UNMOUNTED,c),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))},e.prototype.getId=function(e){return e.id||"g-html-"+e.entity},e.prototype.createCamera=function(e){var t,r=(t=this.context.config).document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var l=(r||document).createElement("div");u=l,l.id=s,l.style.position="absolute",l.style.left="".concat(o.offsetLeft||0,"px"),l.style.top="".concat(o.offsetTop||0,"px"),l.style.transformOrigin="left top",l.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),l.style.overflow="hidden",l.style.pointerEvents="none",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px"),a.appendChild(l)}return u}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.getId(e),n=this.$camera.querySelector("#"+r);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,n.id=r,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform())),n},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;C(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);break;case"width":if(t.runtime.enableCSSParsing){var a=r.computedStyleMap().get("width");n.style.width=""+a}else{n.style.width=I(a=r.parsedStyle.width)?"".concat(a,"px"):""+a}break;case"height":if(t.runtime.enableCSSParsing){var s=r.computedStyleMap().get("height");n.style.height=""+s}else{n.style.height=I(s=r.parsedStyle.height)?"".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":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var u=r.parsedStyle.fill,l="";t.isCSSRGB(u)?l=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?l=r.getAttribute("fill"):t.isPattern(u),n.style.background=l;break;case"stroke":var c=r.parsedStyle.stroke,f="";t.isCSSRGB(c)?f=c.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(c)?f=r.getAttribute("stroke"):t.isPattern(c),n.style["border-color"]=f,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}},e.tag="HTMLRendering",e}(),to=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new eo)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ro=Object.freeze({__proto__:null,Plugin:to}),no=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t():this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,u=e.image,l=e.repetition,c=e.transform,f=!1;C(u)?s=this.getImageSync(u,o):n?(s=n,f=!0):s=u;var d=s&&r.createPattern(s,l);if(d){var h=void 0;h=c?t.parsedTransformToMat4(t.parseTransform(c),new t.DisplayObject({})):_(p()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];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]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(h,h,[1/i,1/i,1]),d.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]})}return a&&d&&(this.patternCache[a]=d),d},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,u=e.cx,l=e.cy,c=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var p=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(p.x1,p.y1,p.x2,p.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,s,u,l,c),h=d.x,_=d.y;f=r.createRadialGradient(h,_,0,h,_,d.r)}return f&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==f||f.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return C(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),io=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var r=e.target;if(r.nodeName===t.Shape.IMAGE){var o=r.attributes.img;C(o)&&i.getImageSync(o,(function(){r.renderable.dirty=!0,n.dirtify()}))}},s=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&C(o)&&i.getOrCreateImage(o).then((function(){r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,s)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)}))},e.tag="LoadImage",e}(),oo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new no(this.context.config),this.addRenderingPlugin(new io)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin);let ao,so=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});so.decode();let uo=null;function lo(){return null!==uo&&uo.buffer===ao.memory.buffer||(uo=new Uint8Array(ao.memory.buffer)),uo}function co(e,t){return so.decode(lo().subarray(e,e+t))}const fo=Array(32).fill(void 0);fo.push(void 0,null,!0,!1);let po=fo.length;function ho(e){return fo[e]}function _o(e){const t=ho(e);return function(e){36>e||(fo[e]=po,po=e)}(e),t}let Eo=0,Ro=new TextEncoder("utf-8");const mo="function"==typeof Ro.encodeInto?function(e,t){return Ro.encodeInto(e,t)}:function(e,t){const r=Ro.encode(e);return t.set(r),{read:e.length,written:r.length}};function To(e,t,r){if(void 0===r){const r=Ro.encode(e),n=t(r.length);return lo().subarray(n,n+r.length).set(r),Eo=r.length,n}let n=e.length,i=t(n);const o=lo();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length);const t=lo().subarray(i+a,i+n);a+=mo(e,t).written}return Eo=a,i}let vo=null;function go(){return null!==vo&&vo.buffer===ao.memory.buffer||(vo=new Int32Array(ao.memory.buffer)),vo}function Ao(e,t,r){try{const u=ao.__wbindgen_add_to_stack_pointer(-16);var n=To(e,ao.__wbindgen_malloc,ao.__wbindgen_realloc),i=Eo,o=To(t,ao.__wbindgen_malloc,ao.__wbindgen_realloc);ao.glsl_compile(u,n,i,o,Eo,r);var a=go()[u/4+0],s=go()[u/4+1];return co(a,s)}finally{ao.__wbindgen_add_to_stack_pointer(16),ao.__wbindgen_free(a,s)}}async function yo(e){const t={wbg:{}};t.wbg.__wbindgen_string_new=function(e,t){return function(e){po===fo.length&&fo.push(fo.length+1);const t=po;return po=fo[t],fo[t]=e,t}(co(e,t))},t.wbg.__wbindgen_object_drop_ref=function(e){_o(e)},t.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(ho(e))},t.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(ho(e),ho(t))},t.wbg.__wbindgen_throw=function(e,t){throw Error(co(e,t))},("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 ao=r.exports,yo.__wbindgen_wasm_module=n,ao}var So,Co;function Oo(e){if(e===be.U8_R_NORM)return"r8unorm";if(e===be.U8_RG_NORM)return"rg8unorm";if(e===be.U8_RGBA_RT)return"bgra8unorm";if(e===be.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===be.U8_RGBA_NORM)return"rgba8unorm";if(e===be.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===be.S8_R_NORM)return"r8snorm";if(e===be.S8_RG_NORM)return"rg8snorm";if(e===be.S8_RGBA_NORM)return"rgba8snorm";if(e===be.U32_R)return"r32uint";if(e===be.F16_RGBA)return"rgba16float";if(e===be.F32_RGBA)return"rgba32float";if(e===be.D24)return"depth24plus";if(e===be.D24_S8)return"depth24plus-stencil8";if(e===be.D32F)return"depth32float";if(e===be.D32F_S8)return"depth32float-stencil8";if(e===be.BC1)return"bc1-rgba-unorm";if(e===be.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===be.BC2)return"bc2-rgba-unorm";if(e===be.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===be.BC3)return"bc3-rgba-unorm";if(e===be.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===be.BC4_SNORM)return"bc4-r-snorm";if(e===be.BC4_UNORM)return"bc4-r-unorm";if(e===be.BC5_SNORM)return"bc5-rg-snorm";if(e===be.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function Io(e){if(e===Re.Clamp)return"clamp-to-edge";if(e===Re.Repeat)return"repeat";if(e===Re.Mirror)return"mirror-repeat";throw Error("whoops")}function Po(e){if(e===me.Bilinear)return"linear";if(e===me.Point)return"nearest";throw Error("whoops")}function No(e){if(e===Te.Linear)return"linear";if(e===Te.Nearest)return"nearest";if(e===Te.NoMip)return"nearest";throw Error("whoops")}function Mo(e){if(e===Ne.Float)return"float";if(e===Ne.Depth)return"depth";throw Error("whoops")}function xo(e){return e.formatKind===Ne.Depth&&e.comparison?{type:"comparison"}:e.formatKind===Ne.Float?{type:"filtering"}:{type:"non-filtering"}}function Do(e){if(e===Ce.n2D)return"2d";if(e===Ce.n2DArray)return"2d-array";if(e===Ce.n3D)return"3d";if(e===Ce.Cube)return"cube";throw Error("whoops")}function Bo(e){return e.gpuBuffer}function Lo(e){if(e===De.OcclusionConservative)return"occlusion";throw Error("whoops")}function Fo(e){switch(e){case ve.Triangles:return"triangle-list";case ve.Points:return"point-list";case ve.TriangleStrip:return"triangle-strip";case ve.Lines:return"line-list";case ve.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function bo(e){if(e===he.None)return"none";if(e===he.Front)return"front";if(e===he.Back)return"back";throw Error("whoops")}function Uo(e){if(e===de.CCW)return"ccw";if(e===de.CW)return"cw";throw Error("whoops")}function Go(e){if(e===_e.Zero)return"zero";if(e===_e.One)return"one";if(e===_e.Src)return"src";if(e===_e.OneMinusSrc)return"one-minus-src";if(e===_e.Dst)return"dst";if(e===_e.OneMinusDst)return"one-minus-dst";if(e===_e.SrcAlpha)return"src-alpha";if(e===_e.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===_e.DstAlpha)return"dst-alpha";if(e===_e.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function wo(e){if(e===Ee.Add)return"add";if(e===Ee.Subtract)return"subtract";if(e===Ee.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function ko(e){return{operation:wo(e.blendMode),srcFactor:Go(e.blendSrcFactor),dstFactor:Go(e.blendDstFactor)}}function Vo(e){return e.blendMode===Ee.Add&&e.blendSrcFactor===_e.One&&e.blendDstFactor===_e.Zero}function Wo(e){return Vo(e.rgbBlendState)&&Vo(e.alphaBlendState)?void 0:{color:ko(e.rgbBlendState),alpha:ko(e.alphaBlendState)}}function Xo(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:Oo(t),blend:Wo(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function Ho(e){if(e===pe.Never)return"never";if(e===pe.Less)return"less";if(e===pe.Equal)return"equal";if(e===pe.LessEqual)return"less-equal";if(e===pe.Greater)return"greater";if(e===pe.NotEqual)return"not-equal";if(e===pe.GreaterEqual)return"greater-equal";if(e===pe.Always)return"always";throw Error("whoops")}function Yo(e){if(e===ye.PerVertex)return"vertex";if(e===ye.PerInstance)return"instance";throw Error("whoops")}function Ko(e){if(e===be.U8_R)return"uint8x2";if(e===be.U8_RG)return"uint8x2";if(e===be.U8_RGB)return"uint8x4";if(e===be.U8_RGBA)return"uint8x4";if(e===be.U8_RG_NORM)return"unorm8x2";if(e===be.U8_RGBA_NORM)return"unorm8x4";if(e===be.S8_RGB_NORM)return"snorm8x4";if(e===be.S8_RGBA_NORM)return"snorm8x4";if(e===be.U16_RG_NORM)return"unorm16x2";if(e===be.U16_RGBA_NORM)return"unorm16x4";if(e===be.S16_RG_NORM)return"snorm16x2";if(e===be.S16_RGBA_NORM)return"snorm16x4";if(e===be.S16_RG)return"uint16x2";if(e===be.F16_RG)return"float16x2";if(e===be.F16_RGBA)return"float16x4";if(e===be.F32_R)return"float32";if(e===be.F32_RG)return"float32x2";if(e===be.F32_RGB)return"float32x3";if(e===be.F32_RGBA)return"float32x4";throw"whoops"}function zo(e,t,r,n){switch(void 0===r&&(r=!1),e){case be.S8_R:case be.S8_R_NORM:case be.S8_RG_NORM:case be.S8_RGB_NORM:case be.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case be.U8_R:case be.U8_R_NORM:case be.U8_RG:case be.U8_RG_NORM:case be.U8_RGB:case be.U8_RGB_NORM:case be.U8_RGB_SRGB:case be.U8_RGBA:case be.U8_RGBA_NORM:case be.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case be.S16_R:case be.S16_RG:case be.S16_RG_NORM:case be.S16_RGB_NORM:case be.S16_RGBA:case be.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case be.U16_R:case be.U16_RGB:case be.U16_RGBA_5551:case be.U16_RGBA_NORM:case be.U16_RG_NORM:case be.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 be.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 be.U32_R:case be.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 be.F32_R:case be.F32_RG:case be.F32_RGB:case be.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(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"}(So||(So={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Co||(Co={}));var jo=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 n(t,e),t.prototype.destroy=function(){},t}(N),qo=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.Bindings;var i=r.pipeline,o=r.bindingLayout;Qe(!!i);var a=n.device._createBindGroupLayout(o),s=[[],[]],u=0;if(o.storageEntries)for(var l=0;o.storageEntries.length>l;l++){Qe((f=r.storageBufferBindings[l]).wordCount>0);var c={buffer:Bo(f.buffer),offset:0,size:f.wordCount<<2};s[0].push({binding:u++,resource:c})}for(l=0;o.numUniformBuffers>l;l++){Qe((f=r.uniformBufferBindings[l]).wordCount>0);c={buffer:Bo(f.buffer),offset:0,size:f.wordCount<<2};s[0].push({binding:u++,resource:c})}u=0;for(l=0;o.numSamplers>l;l++){var f,p=void 0!==o.samplerEntries?o.samplerEntries[l]:xt,d=null!==(f=r.samplerBindings[l]).texture?f.texture:n.device.getFallbackTexture(p);Qe(p.dimension===d.dimension),Qe(p.formatKind===Ze(d.pixelFormat)),s[1].push({binding:u++,resource:d.gpuTextureView});var h=null!==f.sampler?f.sampler:n.device.getFallbackSampler(p),_=h.gpuSampler;s[1].push({binding:u++,resource:_})}return n.gpuBindGroup=s.filter((function(e){return e.length>0})).map((function(e,t){return n.device.device.createBindGroup({layout:i.getBindGroupLayout(t),entries:e})})),n.bindingLayout=r.bindingLayout,n.bindGroupLayout=a,n}return n(t,e),t}(jo);function Zo(e){return void 0!==e.byteLength}var Qo=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&ge.MAP_READ);n.usage=function(e){var t=0;return e&ge.INDEX&&(t|=GPUBufferUsage.INDEX),e&ge.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&ge.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&ge.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&ge.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=ge.MAP_READ|ge.COPY_DST);var s=Zo(o);return n.size=Zo(o)?o.byteLength:4*o,n.view=Zo(o)?o:null,Zo(o)?(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new Uint8Array(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap()):n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}),n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(u),r=0,o=0,a=s,n=s}for(var l=15728640,c=0;a-(o+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(jo),Jo=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatch=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(){Qe(null===this.gpuComputePassEncoder),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=Je(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e,t,r){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0],r)},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuComputePassEncoder.pushDebugGroup&&this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuComputePassEncoder.popDebugGroup&&this.gpuComputePassEncoder.popDebugGroup()},e}(),$o=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(jo),ea=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.InputLayout;for(var i=[],o=0;r.vertexAttributeDescriptors.length>o;o++){var a=r.vertexAttributeDescriptors[o],s={shaderLocation:a.location,format:Ko(a.format),offset:a.bufferByteOffset};if(void 0!==i[a.bufferIndex])i[a.bufferIndex].attributes.push(s);else{var u=Je(r.vertexBufferDescriptors[a.bufferIndex]),l=u.byteStride,c=Yo(u.frequency);i[a.bufferIndex]={arrayStride:l,stepMode:c,attributes:[s]}}}return n.indexFormat=function(e){if(null!==e){if(e===be.U16_R)return"uint16";if(e===be.U32_R)return"uint32";throw Error("whoops")}}(r.indexBufferFormat),n.buffers=i,n}return n(t,e),t}(jo),ta=function(e){function t(t){var r=t.inputLayout,n=t.vertexBuffers,i=t.indexBuffer,o=e.call(this,{id:t.id,device:t.device})||this;return o.type=fe.InputState,o.inputLayout=r,o.vertexBuffers=n,o.indexBuffer=i,o}return n(t,e),t}(jo),ra=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=fe.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.preprocessedVert&&(n.vertexStage=n.createShaderStage(r.preprocessedVert,"vertex")),r.preprocessedFrag&&(n.fragmentStage=n.createShaderStage(r.preprocessedFrag,"fragment")),r.preprocessedCompute&&(n.computeStage=n.createShaderStage(r.preprocessedCompute,"compute")),n}return n(t,e),t.prototype.createShaderStage=function(e,t){var r,n,i=e;if("compute"!==t)try{i=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),Error("whoops")}var o=function(e){if(!i.includes(e))return"continue";i=(i=i.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 a=u(["u_TextureFramebufferDepth"]),s=a.next();!s.done;s=a.next()){o(s.value)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return{module:this.device.device.createShaderModule({code:i}),entryPoint:"main"}},t}(jo),na=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:Lo(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 n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(jo),ia=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=fe.Readback,r}return n(t,e),t.prototype.readTexture=function(e,t,r,n,i,o,a,s){var u=e,l=this.getBlockInformationFromFormat(u.format),c=256*Math.ceil(Math.ceil(n/l.width)*l.length/256),f=this.device.createBuffer({usage:ge.STORAGE|ge.MAP_READ|ge.COPY_DST,hint:Ae.Static,viewOrSize:c*i}),p=this.device.device.createCommandEncoder();return p.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:f.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([p.finish()]),null},t.prototype.readBuffer=function(e,t,r,n,i,o,a,s){var u=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=be.U8_RGB),void 0===a&&(a=!1);var l=e,c=i||l.size,f=r||l.view,p=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||qe(o),d=l;if(!(l.usage&ge.MAP_READ&&l.usage&ge.COPY_DST)){var h=this.device.device.createCommandEncoder();d=this.device.createBuffer({usage:ge.STORAGE|ge.MAP_READ|ge.COPY_DST,hint:Ae.Static,viewOrSize:c}),h.copyBufferToBuffer(l.gpuBuffer,t,d.gpuBuffer,0,c),this.device.device.queue.submit([h.finish()])}return new Promise((function(e,r){d.gpuBuffer.mapAsync(Co.READ,t,c).then((function(){var r=d.gpuBuffer.getMappedRange(t,c),n=f;if(a)n=null===n?zo(o,c,!0,r):zo(o,n.buffer,void 0,r);else if(null===n)switch(p){case 1:(n=new Uint8Array(c)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r);break;case 4:(n=new Float32Array(c/4)).set(new Float32Array(r))}else switch(p){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}d.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},t.prototype.getBlockInformationFromFormat=function(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}}},t}(jo),oa=function(){function e(){this.commandEncoder=null,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.getTextureView=function(e,t){return Qe(e.numLevels>t),1===e.numLevels?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var t=e.colorAttachment.length;this.gfxColorAttachment.length=t,this.gfxColorResolveTo.length=t;for(var r=0;e.colorAttachment.length>r;r++){var n=e.colorAttachment[r],i=e.colorResolveTo[r];if(null===n&&null!==i&&(n=i,i=null),this.gfxColorAttachment[r]=n,this.gfxColorResolveTo[r]=i,this.gfxColorAttachmentLevel[r]=e.colorAttachmentLevel[r],this.gfxColorResolveToLevel[r]=e.colorResolveToLevel[r],null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={}),(a=this.gpuColorAttachments[r]).view=this.getTextureView(n,this.gfxColorAttachmentLevel[r]);var o=e.colorClearColor[r];"load"===o?a.loadOp="load":(a.loadOp="clear",console.log(o,ot),a.clearValue=o),a.storeOp=e.colorStore[r]?"store":"discard",a.resolveTarget=void 0,null!==i&&(n.sampleCount>1?a.resolveTarget=this.getTextureView(i,this.gfxColorResolveToLevel[r]):a.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var a,s=e.depthStencilAttachment;(a=this.gpuDepthStencilAttachment).view=s.gpuTextureView,!!(ze(s.pixelFormat)&Fe.Depth)?("load"===e.depthClearValue?a.depthLoadOp="load":(a.depthLoadOp="clear",a.depthClearValue=e.depthClearValue),a.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(a.depthLoadOp=void 0,a.depthStoreOp=void 0),!!(ze(s.pixelFormat)&Fe.Stencil)?("load"===e.stencilClearValue?a.stencilLoadOp="load":(a.stencilLoadOp="clear",a.stencilClearValue=e.stencilClearValue),a.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(a.stencilLoadOp=void 0,a.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},e.prototype.beginRenderPass=function(e){Qe(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.setViewport=function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)},e.prototype.setScissor=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)},e.prototype.setPipeline=function(e){var t=Je(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setInputState=function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var r=t.inputLayout,n=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Bo(n.buffer),Je(r.indexFormat),n.byteOffset)}for(var i=0;t.vertexBuffers.length>i;i++){var o=t.vertexBuffers[i];A(o)||this.gpuRenderPassEncoder.setVertexBuffer(i,Bo(o.buffer),o.byteOffset)}}},e.prototype.setBindings=function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),n.gpuBindGroup[1]&&this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])},e.prototype.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},e.prototype.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},e.prototype.drawIndexedInstanced=function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,this.gfxColorAttachmentLevel[e],t,this.gfxColorResolveToLevel[e])}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t,r,n){Qe(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};Qe(r.width>>>n==e.width>>>t),Qe(r.height>>>n==e.height>>>t),Qe(!!(r.usage&So.COPY_SRC)),Qe(!!(e.usage&So.COPY_DST)),this.commandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),aa=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=fe.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device._createRenderPipeline(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(jo),sa=function(e){function t(t){var r,n,i=t.descriptor,o=this;(o=e.call(this,{id:t.id,device:t.device})||this).type=fe.Sampler;var a=i.minLOD,s=i.mipFilter===Te.NoMip?i.minLOD:i.maxLOD,u=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return u>1&&Qe(i.minFilter===me.Bilinear&&i.magFilter===me.Bilinear&&i.mipFilter===Te.Linear),o.gpuSampler=o.device.device.createSampler({addressModeU:Io(i.wrapS),addressModeV:Io(i.wrapT),addressModeW:Io(null!==(n=i.wrapQ)&&void 0!==n?n:i.wrapS),lodMinClamp:a,lodMaxClamp:s,minFilter:Po(i.minFilter),magFilter:Po(i.magFilter),mipmapFilter:No(i.mipFilter),compare:void 0!==i.compareMode?Ho(i.compareMode):void 0,maxAnisotropy:u}),o}return n(t,e),t}(jo),ua=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=e.call(this,{id:t.id,device:t.device})||this;return i.type=fe.Texture,i.device.createTextureShared({pixelFormat:r.pixelFormat,dimension:r.dimension,width:r.width,height:r.height,depthOrArrayLayers:r.depth,numLevels:r.numLevels,usage:r.usage,sampleCount:1},i,n),i}return n(t,e),t.prototype.setImageData=function(e,t){},t.prototype.destroy=function(){this.gpuTexture.destroy()},t}(jo),la=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=So.RENDER_ATTACHMENT|So.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Dr(Ut,Mr),this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Me.UpperLeft,this.clipSpaceNearZ=xe.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(Ce.n2D,Ne.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Ce.n2D,Ne.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(Ce.n2DArray,Ne.Float),this.fallbackTexture3D=this.createFallbackTexture(Ce.n3D,Ne.Float),this.fallbackTextureCube=this.createFallbackTexture(Ce.Cube,Ne.Float),this.fallbackSamplerFiltering=this.createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Point,mipFilter:Te.Nearest}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Point,mipFilter:Te.Nearest,compareMode:pe.Always}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler 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:"opaque"})}return 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 ua({id:0,device:this,descriptor:{pixelFormat:be.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:Ce.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new Qo({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new ua({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new sa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new ua({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:Ce.n2D,numLevels:1,depth:1,usage:Oe.RenderTarget})});return t.depthOrArrayLayers=1,t.type=fe.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.pixelFormat,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.numLevels,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;Qe(!!(l&So.RENDER_ATTACHMENT));var c=new ua({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:Ce.n2D,numLevels:a,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=u,c},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},e.prototype.createProgramSimple=function(e){return new ra({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.numLevels,o=Oo(e.pixelFormat),a=function(e){if(e===Ce.n2D)return"2d";if(e===Ce.Cube)return"2d";if(e===Ce.n2DArray)return"2d";if(e===Ce.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Oe.Sampled&&(t|=So.TEXTURE_BINDING|So.COPY_DST),e&Oe.RenderTarget&&(t|=So.RENDER_ATTACHMENT|So.TEXTURE_BINDING|So.COPY_SRC|So.COPY_DST),t}(e.usage);if(t.format=o,t.dimension=e.dimension,t.pixelFormat=e.pixelFormat,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.numLevels=i,t.usage=s,t.sampleCount=1,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},e.prototype.getFallbackSampler=function(e){return e.formatKind===Ne.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===Ce.n2D)return e.formatKind===Ne.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===Ce.n2DArray)return this.fallbackTexture2DArray;if(t===Ce.n3D)return this.fallbackTexture3D;if(t===Ce.Cube)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,pixelFormat:t===Ne.Float?be.U8_RGBA_NORM:be.D24,usage:Oe.Sampled,width:1,height:1,depth:e===Ce.Cube?6:1,numLevels:1})},e.prototype.createBindings=function(e){return new qo({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new ea({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputState=function(e,t,r){return new ta({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})},e.prototype.createComputePipeline=function(e){return new $o({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new aa({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new na({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype._createBindGroupLayout=function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t},e.prototype._createBindGroupLayoutInternal=function(e){var t,r=this,n=[[],[]];if(e.storageEntries)for(var i=0;e.storageEntries.length>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.COMPUTE,buffer:{type:e.storageEntries[i].type}});for(i=0;e.numUniformBuffers>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(i=0;e.numSamplers>i;i++){var o=void 0!==e.samplerEntries?e.samplerEntries[i]:xt;n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=o,{sampleType:Mo(t.formatKind),viewDimension:Do(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:xo(o)})}return{gpuBindGroupLayout:n.map((function(e){return e.length?r.device.createBindGroupLayout({entries:e}):null})).filter((function(e){return!!e}))}},e.prototype._createPipelineLayout=function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})},e.prototype._createRenderPipeline=function(e,t){if(null===e.gpuRenderPipeline){var r=e.descriptor,n=r.program,o=n.vertexStage,a=n.fragmentStage;if(null!==o&&null!==a){var s,u=this._createPipelineLayout(r.bindingLayouts),l=(s=r.megaStateDescriptor,{topology:Fo(r.topology),cullMode:bo(s.cullMode),frontFace:Uo(s.frontFace)}),c=Xo(r.colorAttachmentFormats,r.megaStateDescriptor),f=function(e,t){if(null!==e)return{format:Oo(e),depthWriteEnabled:t.depthWrite,depthCompare:Ho(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(r.depthStencilAttachmentFormat,r.megaStateDescriptor),p=void 0;null!==r.inputLayout&&(p=r.inputLayout.buffers);var d=r.sampleCount,h={layout:u,vertex:i(i({},o),{buffers:p}),primitive:l,depthStencil:f,multisample:{count:d},fragment:i(i({},a),{targets:c})};e.gpuRenderPipeline=this.device.createRenderPipeline(h)}}},e.prototype.createReadback=function(){return new ia({id:this.getNextUniqueId(),device:this})},e.prototype.destroyRenderTarget=function(e){e.gpuTexture.destroy()},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new oa),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();return void 0===e&&(e=new Jo),e.commandEncoder=this.device.createCommandEncoder(),e.beginComputePass(),e},e.prototype.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null},e.prototype.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,u=n,l={texture:u.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};Qe(!!(u.usage&So.COPY_SRC)),Qe(!!(s.usage&So.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ke(e)){case Be.BC1:case Be.BC2:case Be.BC3:case Be.BC4_SNORM:case Be.BC4_UNORM:case Be.BC5_SNORM:case Be.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ke(e)){case Be.BC1:case Be.BC2:case Be.BC3:case Be.BC4_SNORM:case Be.BC4_UNORM:case Be.BC5_SNORM:case Be.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case be.U16_RGBA_NORM:case be.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===fe.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===fe.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===fe.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===fe.Sampler){(r=e).gpuSampler.label=t}else if(e.type===fe.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.pushDebugGroup=function(e){},e.prototype.popDebugGroup=function(){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this._createRenderPipeline(e,!1)},e}(),ca=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var r,n,i,o,a,u;return s(this,(function(s){switch(s.label){case 0:if(void 0===t.runtime.globalThis.navigator.gpu)return[2,null];r=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,t.runtime.globalThis.navigator.gpu.requestAdapter()];case 2:return r=s.sent(),[3,4];case 3:return n=s.sent(),console.log(n),[3,4];case 4:return null===r?[2,null]:(i=["depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),[4,r.requestDevice({requiredFeatures:i})]);case 5:if((o=s.sent())&&(a=this.pluginOptions.onContextLost,o.lost.then((function(){a&&a()}))),null===o)return[2,null];if(!(u=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,yo(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new la(r,o,e,u,Ao)]}}))}))},e}(),fa=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="webgpu-device",r}return n(t,e),t.prototype.init=function(){this.context.deviceContribution=new ca(i({shaderCompilerPath:"/glsl_wgsl_compiler_bg.wasm"},this.options))},t.prototype.destroy=function(){delete this.context.deviceContribution},t}(t.AbstractRendererPlugin),pa=Object.freeze({__proto__:null,Plugin:fa}),da=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=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=C(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)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),ha=function(e){function t(t){var r=e.call(this)||this;return r.rendererPlugin=t,r.name="webgpu-context-register",r}return n(t,e),t.prototype.init=function(){this.context.ContextService=da,this.context.deviceRendererPlugin=this.rendererPlugin},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),_a=function(e){function t(t){var r=e.call(this,t)||this,n=new qi;return r.registerPlugin(new ha(n)),r.registerPlugin(new oo),r.registerPlugin(new fa({shaderCompilerPath:null==t?void 0:t.shaderCompilerPath,onContextLost:null==t?void 0:t.onContextLost})),r.registerPlugin(n),r.registerPlugin(new Ji),r.registerPlugin(new to),r}return n(t,e),t}(t.AbstractRenderer);e.DeviceRenderer=Zi,e.DomInteraction=$i,e.HTMLRenderer=ro,e.Renderer=_a,e.WebGPUDevice=pa}));
1
+ !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";var r=function(e,t){return r=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])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=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},i.apply(this,arguments)};function o(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}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(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(a,s)}u((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),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 u(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 l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var f="undefined"!=typeof Float32Array?Float32Array:Array;function p(){var e=new f(16);return f!=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 d(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 _(e,t,r,n,i,o,a,s,u,l,c,p,d,_,h,E){var R=new f(16);return R[0]=e,R[1]=t,R[2]=r,R[3]=n,R[4]=i,R[5]=o,R[6]=a,R[7]=s,R[8]=u,R[9]=l,R[10]=c,R[11]=p,R[12]=d,R[13]=_,R[14]=h,R[15]=E,R}function h(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 E(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}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var R,m=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],p=t[9],d=t[10],_=t[11],h=t[12],E=t[13],R=t[14],m=t[15],v=r[0],T=r[1],g=r[2],y=r[3];return e[0]=v*n+T*s+g*f+y*h,e[1]=v*i+T*u+g*p+y*E,e[2]=v*o+T*l+g*d+y*R,e[3]=v*a+T*c+g*_+y*m,e[4]=(v=r[4])*n+(T=r[5])*s+(g=r[6])*f+(y=r[7])*h,e[5]=v*i+T*u+g*p+y*E,e[6]=v*o+T*l+g*d+y*R,e[7]=v*a+T*c+g*_+y*m,e[8]=(v=r[8])*n+(T=r[9])*s+(g=r[10])*f+(y=r[11])*h,e[9]=v*i+T*u+g*p+y*E,e[10]=v*o+T*l+g*d+y*R,e[11]=v*a+T*c+g*_+y*m,e[12]=(v=r[12])*n+(T=r[13])*s+(g=r[14])*f+(y=r[15])*h,e[13]=v*i+T*u+g*p+y*E,e[14]=v*o+T*l+g*d+y*R,e[15]=v*a+T*c+g*_+y*m,e};function v(e,t,r){var n=new f(3);return n[0]=e,n[1]=t,n[2]=r,n}function T(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function g(e,t,r,n,i,o,a,s,u,l){var c,f,p,d,_,h=e,E=t,R=r,m=n,v=s,y=u,A=120*Math.PI/180,S=Math.PI/180*(+i||0),C=[];if(l)f=l[0],p=l[1],d=l[2],_=l[3];else{E=(c=T(h,E,-S)).y;var O=((h=c.x)-(v=(c=T(v,y,-S)).x))/2,I=(E-(y=c.y))/2,P=O*O/(R*R)+I*I/(m*m);P>1&&(R*=P=Math.sqrt(P),m*=P);var N=R*R,M=m*m,x=(o===a?-1:1)*Math.sqrt(Math.abs((N*M-N*I*I-M*O*O)/(N*I*I+M*O*O)));d=x*R*I/m+(h+v)/2,f=Math.asin(((E-(_=x*-m*O/R+(E+y)/2))/m*1e9>>0)/1e9),p=Math.asin(((y-_)/m*1e9>>0)/1e9),0>(f=d>h?Math.PI-f:f)&&(f=2*Math.PI+f),0>(p=d>v?Math.PI-p:p)&&(p=2*Math.PI+p),a&&f>p&&(f-=2*Math.PI),!a&&p>f&&(p-=2*Math.PI)}var D=p-f;if(Math.abs(D)>A){var B=p,L=v,b=y;C=g(v=d+R*Math.cos(p=f+A*(a&&p>f?1:-1)),y=_+m*Math.sin(p),R,m,i,0,a,L,b,[p,B,d,_])}D=p-f;var F=Math.cos(f),U=Math.sin(f),G=Math.cos(p),w=Math.sin(p),k=Math.tan(D/4),V=4/3*R*k,W=4/3*m*k,X=[h,E],H=[h+V*U,E-W*F],Y=[v+V*w,y-W*G],K=[v,y];if(H[0]=2*X[0]-H[0],H[1]=2*X[1]-H[1],l)return H.concat(Y,K,C);for(var z=[],j=0,q=(C=H.concat(Y,K,C)).length;q>j;j+=1)z[j]=j%2?T(C[j-1],C[j],S).y:T(C[j],C[j+1],S).x;return z}R=new f(3),f!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0);var y=function(e){return null==e},A={}.toString,S=function(e,t){return A.call(e)==="[object "+t+"]"},C=function(e){return S(e,"String")},O=function(e,t,r){return t>e?t:e>r?r:e},I=function(e){return S(e,"Number")},P={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 o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),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 a(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,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},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,o,a){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,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(l=1,u=Array(f-1);f>l;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var p,d=c.length;for(l=0;d>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(p=1,u=Array(f-1);f>p;p++)u[p-1]=arguments[p];c[l].fn.apply(c[l].context,u)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);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[o]=1===l.length?l[0]:l:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(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}(P);var N=P.exports,M={exports:{}};function x(e,t,r){r=r||2;var n,i,o,a,s,u,l,c=t&&t.length,f=c?t[0]*r:e.length,p=D(e,0,f,r,!0),d=[];if(!p||p.next===p.prev)return d;if(c&&(p=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=D(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(X(a));for(s.sort(w),i=0;s.length>i;i++)r=B(r=k(s[i],r),r.next);return r}(e,t,p,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(u=e[_+1])&&(i=u),s>o&&(o=s),u>a&&(a=u);l=0!==(l=Math.max(o-n,a-i))?1/l:0}return L(p,d,r,n,i,l),d}function D(e,t,r,n,i){var o,a;if(i===re(e,t,r,n)>0)for(o=t;r>o;o+=n)a=$(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=$(o,e[o],e[o+1],a);return a&&z(a,a.next)&&(ee(a),a=a.next),a}function B(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!z(n,n.next)&&0!==K(n.prev,n,n.next))n=n.next;else{if(ee(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function L(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=W(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,o,a,s,u,l=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,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--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,l*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?F(e,n,i,o):b(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),ee(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?L(e=U(B(e),t,r),t,r,n,i,o,2):2===a&&G(e,t,r,n,i,o):L(B(e),t,r,n,i,o,1);break}}}function b(e){var t=e.prev,r=e,n=e.next;if(K(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(H(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&K(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function F(e,t,r,n){var i=e.prev,o=e,a=e.next;if(K(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,u=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,l=W(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=W(s,u,t,r,n),f=e.prevZ,p=e.nextZ;f&&f.z>=l&&p&&c>=p.z;){if(f!==e.prev&&f!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&K(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&K(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=l;){if(f!==e.prev&&f!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&K(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&c>=p.z;){if(p!==e.prev&&p!==e.next&&H(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&K(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function U(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!z(i,o)&&j(i,n,n.next,o)&&Q(i,o)&&Q(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),ee(n),ee(n.next),n=e=o),n=n.next}while(n!==e);return B(n)}function G(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Y(a,s)){var u=J(a,s);return a=B(a,a.next),u=B(u,u.next),L(a,t,r,n,i,o),void L(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function w(e,t){return e.x-t.x}function k(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var u,l=r,c=r.x,f=r.y,p=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!H(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),Q(n,e)&&(p>u||u===p&&(n.x>r.x||n.x===r.x&&V(r,n)))&&(r=n,p=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=J(r,e),i=B(r,r.next);return B(n,n.next),t===r?i:t}function V(e,t){return 0>K(e.prev,e,t.prev)&&0>K(t.next,e,e.next)}function W(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function X(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 H(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function Y(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&&j(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Q(e,t)&&Q(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(K(e.prev,e,t.prev)||K(e,t.prev,t))||z(e,t)&&K(e.prev,e,e.next)>0&&K(t.prev,t,t.next)>0)}function K(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function z(e,t){return e.x===t.x&&e.y===t.y}function j(e,t,r,n){var i=Z(K(e,t,r)),o=Z(K(e,t,n)),a=Z(K(r,n,e)),s=Z(K(r,n,t));return i!==o&&a!==s||(!(0!==i||!q(e,r,t))||(!(0!==o||!q(e,n,t))||(!(0!==a||!q(r,e,n))||!(0!==s||!q(r,t,n)))))}function q(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 Z(e){return e>0?1:0>e?-1:0}function Q(e,t){return 0>K(e.prev,e,e.next)?K(e,t,e.next)>=0&&K(e,e.prev,t)>=0:0>K(e,t,e.prev)||0>K(e,e.next,t)}function J(e,t){var r=new te(e.i,e.x,e.y),n=new te(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function $(e,t,r,n){var i=new te(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 ee(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 te(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function re(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}M.exports=x,M.exports.default=x,x.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(re(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(re(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var u=0;for(a=0;n.length>a;a+=3){var l=n[a]*r,c=n[a+1]*r,f=n[a+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===o&&0===u?0:Math.abs((u-o)/o)},x.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 o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var ne=M.exports;function ie(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function oe(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function ae(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function se(e,t,r,n,i,o,a,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=ie(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,u){var l=ae(e,r,i,a,u),c=ae(t,n,o,s,u),f=oe(e,t,r,n,u),p=oe(r,n,i,o,u),d=oe(i,o,a,s,u),_=oe(f.x,f.y,p.x,p.y,u),h=oe(p.x,p.y,d.x,d.y,u);return[[e,t,f.x,f.y,_.x,_.y,l,c],[l,c,h.x,h.y,d.x,d.y,a,s]]}(e,t,r,n,i,o,a,s,.5),p=c(c([],l(f[0]),!1),[u-1],!1),d=c(c([],l(f[1]),!1),[u-1],!1);return se.apply(void 0,c([],l(p),!1))+se.apply(void 0,c([],l(d),!1))}function ue(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function le(e,t,r,n,i,o,a){if(0===a)return(ie(e,t,r,n)+ie(r,n,i,o)+ie(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=ue(e,r,i,a),u=ue(t,n,o,a),l=oe(e,t,r,n,a),c=oe(r,n,i,o,a);return[[e,t,l.x,l.y,s,u],[s,u,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),u=s[0],f=s[1];return u.push(a-1),f.push(a-1),le.apply(void 0,c([],l(u),!1))+le.apply(void 0,c([],l(f),!1))}var ce,fe,pe,de,_e,he,Ee,Re,me,ve,Te,ge,ye,Ae,Se,Ce,Oe,Ie,Pe,Ne,Me,xe,De,Be,Le,be,Fe,Ue=function(){function e(){this.meshes=[]}return e.tag="c-renderable-3d",e}(),Ge=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=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},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),we=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0,anchor:[.5,.5,.5]},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),ke=function(){function e(){}return e.prototype.update=function(e){var t=e.geometry.computeBoundingBox(),r=t.getMax(),n=t.getMin();return{width:r[0]-n[0],height:r[1]-n[1],depth:r[2]-n[2]}},e}(),Ve=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=l(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}();function We(e,t,r,n){return{dimension:Ce.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:Oe.Sampled}}function Xe(e){return e}function He(e,t,r){return e<<16|t<<8|r}function Ye(e){return e>>>8&255}function Ke(e){return e>>>16&255}function ze(e){return 255&e}function je(e){switch(e){case Be.F32:case Be.U32:case Be.S32:return 4;case Be.U16:case Be.S16:case Be.F16:return 2;case Be.U8:case Be.S8:return 1;default:throw Error("whoops")}}function qe(e){return je(Ke(e))}function Ze(e){var t=ze(e);if(t&be.Depth)return Ne.Depth;if(t&be.Normalized)return Ne.Float;var r=Ke(e);if(r===Be.F16||r===Be.F32)return Ne.Float;if(r===Be.U8||r===Be.U16||r===Be.U32)return Ne.Uint;if(r===Be.S8||r===Be.S16||r===Be.S32)return Ne.Sint;throw Error("whoops")}function Qe(e,t){if(void 0===t&&(t=""),!e)throw console.error(Error().stack),Error("Assert fail: ".concat(t))}function Je(e){if(null!=e)return e;throw Error("Missing object")}function $e(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function et(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function tt(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function rt(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"}(ce||(ce={})),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.InputState=7]="InputState",e[e.RenderPipeline=8]="RenderPipeline",e[e.ComputePipeline=9]="ComputePipeline",e[e.Readback=10]="Readback",e[e.QueryPool=11]="QueryPool"}(fe||(fe={})),function(e){e[e.Never=512]="Never",e[e.Less=513]="Less",e[e.Equal=514]="Equal",e[e.LessEqual=515]="LessEqual",e[e.Greater=516]="Greater",e[e.NotEqual=517]="NotEqual",e[e.GreaterEqual=518]="GreaterEqual",e[e.Always=519]="Always"}(pe||(pe={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(de||(de={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(_e||(_e={})),function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.Src=768]="Src",e[e.OneMinusSrc=769]="OneMinusSrc",e[e.Dst=774]="Dst",e[e.OneMinusDst=775]="OneMinusDst",e[e.SrcAlpha=770]="SrcAlpha",e[e.OneMinusSrcAlpha=771]="OneMinusSrcAlpha",e[e.DstAlpha=772]="DstAlpha",e[e.OneMinusDstAlpha=773]="OneMinusDstAlpha"}(he||(he={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(Ee||(Ee={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(Re||(Re={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(me||(me={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(ve||(ve={})),function(e){e[e.Points=0]="Points",e[e.Triangles=1]="Triangles",e[e.TriangleStrip=2]="TriangleStrip",e[e.Lines=3]="Lines",e[e.LineStrip=4]="LineStrip"}(Te||(Te={})),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"}(ge||(ge={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(ye||(ye={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(Ae||(Ae={})),function(e){e.LOADED="loaded"}(Se||(Se={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(Ce||(Ce={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(Oe||(Oe={})),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.AllChannels=15]="AllChannels"}(Ie||(Ie={})),function(e){e[e.Keep=7680]="Keep",e[e.Zero=0]="Zero",e[e.Replace=7681]="Replace",e[e.Invert=5386]="Invert",e[e.IncrementClamp=7682]="IncrementClamp",e[e.DecrementClamp=7683]="DecrementClamp",e[e.IncrementWrap=34055]="IncrementWrap",e[e.DecrementWrap=34056]="DecrementWrap"}(Pe||(Pe={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Ne||(Ne={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(Me||(Me={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(xe||(xe={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(De||(De={})),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.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(Be||(Be={})),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"}(Le||(Le={})),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"}(be||(be={})),function(e){e[e.ALPHA=He(Be.U8,Le.A,be.None)]="ALPHA",e[e.F16_R=He(Be.F16,Le.R,be.None)]="F16_R",e[e.F16_RG=He(Be.F16,Le.RG,be.None)]="F16_RG",e[e.F16_RGB=He(Be.F16,Le.RGB,be.None)]="F16_RGB",e[e.F16_RGBA=He(Be.F16,Le.RGBA,be.None)]="F16_RGBA",e[e.F32_R=He(Be.F32,Le.R,be.None)]="F32_R",e[e.F32_RG=He(Be.F32,Le.RG,be.None)]="F32_RG",e[e.F32_RGB=He(Be.F32,Le.RGB,be.None)]="F32_RGB",e[e.F32_RGBA=He(Be.F32,Le.RGBA,be.None)]="F32_RGBA",e[e.U8_R=He(Be.U8,Le.R,be.None)]="U8_R",e[e.U8_R_NORM=He(Be.U8,Le.R,be.Normalized)]="U8_R_NORM",e[e.U8_RG=He(Be.U8,Le.RG,be.None)]="U8_RG",e[e.U8_RG_NORM=He(Be.U8,Le.RG,be.Normalized)]="U8_RG_NORM",e[e.U8_RGB=He(Be.U8,Le.RGB,be.None)]="U8_RGB",e[e.U8_RGB_NORM=He(Be.U8,Le.RGB,be.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=He(Be.U8,Le.RGB,be.sRGB|be.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=He(Be.U8,Le.RGBA,be.None)]="U8_RGBA",e[e.U8_RGBA_NORM=He(Be.U8,Le.RGBA,be.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=He(Be.U8,Le.RGBA,be.sRGB|be.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=He(Be.U16,Le.R,be.None)]="U16_R",e[e.U16_R_NORM=He(Be.U16,Le.R,be.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=He(Be.U16,Le.RG,be.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=He(Be.U16,Le.RGBA,be.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=He(Be.U16,Le.RGB,be.None)]="U16_RGB",e[e.U32_R=He(Be.U32,Le.R,be.None)]="U32_R",e[e.U32_RG=He(Be.U32,Le.RG,be.None)]="U32_RG",e[e.S8_R=He(Be.S8,Le.R,be.None)]="S8_R",e[e.S8_R_NORM=He(Be.S8,Le.R,be.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=He(Be.S8,Le.RG,be.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=He(Be.S8,Le.RGB,be.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=He(Be.S8,Le.RGBA,be.Normalized)]="S8_RGBA_NORM",e[e.S16_R=He(Be.S16,Le.R,be.None)]="S16_R",e[e.S16_RG=He(Be.S16,Le.RG,be.None)]="S16_RG",e[e.S16_RG_NORM=He(Be.S16,Le.RG,be.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=He(Be.S16,Le.RGB,be.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=He(Be.S16,Le.RGBA,be.None)]="S16_RGBA",e[e.S16_RGBA_NORM=He(Be.S16,Le.RGBA,be.Normalized)]="S16_RGBA_NORM",e[e.S32_R=He(Be.S32,Le.R,be.None)]="S32_R",e[e.U16_RGBA_5551=He(Be.U16_PACKED_5551,Le.RGBA,be.Normalized)]="U16_RGBA_5551",e[e.BC1=He(Be.BC1,Le.RGBA,be.Normalized)]="BC1",e[e.BC1_SRGB=He(Be.BC1,Le.RGBA,be.Normalized|be.sRGB)]="BC1_SRGB",e[e.BC2=He(Be.BC2,Le.RGBA,be.Normalized)]="BC2",e[e.BC2_SRGB=He(Be.BC2,Le.RGBA,be.Normalized|be.sRGB)]="BC2_SRGB",e[e.BC3=He(Be.BC3,Le.RGBA,be.Normalized)]="BC3",e[e.BC3_SRGB=He(Be.BC3,Le.RGBA,be.Normalized|be.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=He(Be.BC4_UNORM,Le.R,be.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=He(Be.BC4_SNORM,Le.R,be.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=He(Be.BC5_UNORM,Le.RG,be.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=He(Be.BC5_SNORM,Le.RG,be.Normalized)]="BC5_SNORM",e[e.D24=He(Be.D24,Le.R,be.Depth)]="D24",e[e.D24_S8=He(Be.D24S8,Le.RG,be.Depth|be.Stencil)]="D24_S8",e[e.D32F=He(Be.D32F,Le.R,be.Depth)]="D32F",e[e.D32F_S8=He(Be.D32FS8,Le.RG,be.Depth|be.Stencil)]="D32F_S8",e[e.U8_RGB_RT=He(Be.U8,Le.RGB,be.RenderTarget|be.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=He(Be.U8,Le.RGBA,be.RenderTarget|be.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=He(Be.U8,Le.RGBA,be.RenderTarget|be.Normalized|be.sRGB)]="U8_RGBA_RT_SRGB"}(Fe||(Fe={}));var nt=rt(0,0,0,0),it=rt(0,0,0,1),ot=rt(1,1,1,0),at=rt(1,1,1,1),st=!0;function ut(e,t){if(void 0===t&&(t=st),!t)return e;switch(e){case pe.Less:return pe.Greater;case pe.LessEqual:return pe.GreaterEqual;case pe.GreaterEqual:return pe.LessEqual;case pe.Greater:return pe.Less;default:return e}}function lt(e,t){return null!=e?e:t}function ct(e){return void 0===e?null:e}function ft(e,t,r){e.length=t,e.fill(r)}function pt(e,t){var r=t-1;return e+r&~r}function dt(e,t){return((e+t-1)/t|0)*t}function _t(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}function ht(e,t,r){var n=_t(e,t,r);e.splice(n,0,t)}function Et(e,t,r){return r?e|=t:e&=~t,e}function Rt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function mt(e,t,r){for(void 0===r&&(r="0");t>e.length;)e="".concat(r).concat(e);return e}function vt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Tt(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),vt(e.rgbBlendState,t.rgbBlendState),vt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function gt(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=Tt(e[r],t[r])}function yt(e,t){void 0!==t.attachmentsState&&gt(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&et(e.blendConstant,t.blendConstant),e.depthCompare=lt(t.depthCompare,e.depthCompare),e.depthWrite=lt(t.depthWrite,e.depthWrite),e.stencilCompare=lt(t.stencilCompare,e.stencilCompare),e.stencilWrite=lt(t.stencilWrite,e.stencilWrite),e.stencilPassOp=lt(t.stencilPassOp,e.stencilPassOp),e.stencilRef=lt(t.stencilRef,e.stencilRef),e.cullMode=lt(t.cullMode,e.cullMode),e.frontFace=lt(t.frontFace,e.frontFace),e.polygonOffset=lt(t.polygonOffset,e.polygonOffset)}function At(e){var t=Object.assign({},e);return t.attachmentsState=[],gt(t.attachmentsState,e.attachmentsState),t.blendConstant=tt(t.blendConstant),t}function St(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)}var Ct={blendMode:Ee.Add,blendSrcFactor:he.One,blendDstFactor:he.Zero},Ot={attachmentsState:[{channelWriteMask:Ie.RGB,rgbBlendState:Ct,alphaBlendState:Ct}],blendConstant:tt(nt),depthWrite:!0,depthCompare:pe.LessEqual,stencilCompare:pe.Always,stencilWrite:!1,stencilPassOp:Pe.Keep,stencilRef:0,cullMode:_e.None,frontFace:de.CCW,polygonOffset:!1};function It(e,t){void 0===e&&(e=null),void 0===t&&(t=Ot);var r=At(t);return null!==e&&yt(r,e),r}var Pt=It({depthCompare:pe.Always,depthWrite:!1},Ot);function Nt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],gt(e.attachmentsState,Ot.attachmentsState)),St(e.attachmentsState[0],t),e}var Mt,xt={formatKind:Ne.Float,dimension:Ce.n2D};function Dt(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 Bt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function Lt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function bt(e,t){return e.dimension===t.dimension&&e.formatKind===t.formatKind}function Ft(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Ut(e,t){return e.numSamplers===t.numSamplers&&(e.numUniformBuffers===t.numUniformBuffers&&(void 0===e.samplerEntries==(void 0===t.samplerEntries)&&!(void 0!==e.samplerEntries&&!Dt(e.samplerEntries,t.samplerEntries,bt))))}function Gt(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!Dt(e.samplerBindings,t.samplerBindings,Ft)&&(!!Dt(e.uniformBufferBindings,t.uniformBufferBindings,Lt)&&!!Vt(e.bindingLayout,t.bindingLayout)))}function wt(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function kt(e,t){return!!wt(e.rgbBlendState,t.rgbBlendState)&&(!!wt(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Vt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Wt(e,t){return e===t}function Xt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!Dt(e.attachmentsState,t.attachmentsState,kt)&&!!$e(e.blendConstant,t.blendConstant)&&e.depthCompare===t.depthCompare&&e.depthWrite===t.depthWrite&&e.stencilCompare===t.stencilCompare&&e.stencilWrite===t.stencilWrite&&e.stencilPassOp===t.stencilPassOp&&e.stencilRef===t.stencilRef&&e.cullMode===t.cullMode&&e.frontFace===t.frontFace&&e.polygonOffset===t.polygonOffset}(e.megaStateDescriptor,t.megaStateDescriptor)&&(!!function(e,t){return e.id===t.id}(e.program,t.program)&&(!!Dt(e.bindingLayouts,t.bindingLayouts,Vt)&&(!!Dt(e.colorAttachmentFormats,t.colorAttachmentFormats,Wt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Ht(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Yt(e,t){return y(e)?y(t):!y(t)&&(e.byteStride===t.byteStride&&e.frequency===t.frequency)}function Kt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!Dt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Yt)&&!!Dt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Ht))}function zt(e,t){return e.wrapS===t.wrapS&&e.wrapT===t.wrapT&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipFilter===t.mipFilter&&e.minLOD===t.minLOD&&e.maxLOD===t.maxLOD&&e.maxAnisotropy===t.maxAnisotropy&&e.compareMode===t.compareMode}function jt(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function qt(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Zt(e){return{bindingLayout:e.bindingLayout,samplerBindings:Bt(e.samplerBindings,jt),uniformBufferBindings:Bt(e.uniformBufferBindings,qt),pipeline:e.pipeline}}function Qt(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Jt(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Bt(e.samplerEntries,Qt):void 0}}function $t(e){var t=Bt(e.bindingLayouts,Jt),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:At(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function er(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function tr(e){return y(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function rr(e){return{vertexAttributeDescriptors:Bt(e.vertexAttributeDescriptors,er),vertexBufferDescriptors:Bt(e.vertexBufferDescriptors,tr),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Mt||(Mt={}));var nr,ir=new Uint16Array([65279]),or=255==new DataView(ir.buffer).getUint8(0)?Mt.LITTLE_ENDIAN:Mt.BIG_ENDIAN;var ar=/([^[]*)(\[[0-9]+\])?/;function sr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function ur(e,t,r,n){var i=null,o=null;return function(a,s,u){var l=t(u,r),c=l.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Qe(o===c,"Uniform length cannot change.");for(var p=0;c>p;++p)if(l[p]!==i[p]){f=!0;break}}return f&&(n(a,e,s,l),i.set(l)),f}}function lr(e,t,r,n){e[t](r,n)}function cr(e,t,r,n){e[t](r,!1,n)}var fr={},pr={},dr={},_r=[0];function hr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(_r[0]=e,e=_r);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function Er(e,t){return hr(e,t,Float32Array,fr)}function Rr(e,t){return hr(e,t,Int32Array,pr)}function mr(e,t){return hr(e,t,Uint32Array,dr)}var vr=((nr={})[ce.FLOAT]=ur.bind(null,"uniform1fv",Er,1,lr),nr[ce.FLOAT_VEC2]=ur.bind(null,"uniform2fv",Er,2,lr),nr[ce.FLOAT_VEC3]=ur.bind(null,"uniform3fv",Er,3,lr),nr[ce.FLOAT_VEC4]=ur.bind(null,"uniform4fv",Er,4,lr),nr[ce.INT]=ur.bind(null,"uniform1iv",Rr,1,lr),nr[ce.INT_VEC2]=ur.bind(null,"uniform2iv",Rr,2,lr),nr[ce.INT_VEC3]=ur.bind(null,"uniform3iv",Rr,3,lr),nr[ce.INT_VEC4]=ur.bind(null,"uniform4iv",Rr,4,lr),nr[ce.BOOL]=ur.bind(null,"uniform1iv",Rr,1,lr),nr[ce.BOOL_VEC2]=ur.bind(null,"uniform2iv",Rr,2,lr),nr[ce.BOOL_VEC3]=ur.bind(null,"uniform3iv",Rr,3,lr),nr[ce.BOOL_VEC4]=ur.bind(null,"uniform4iv",Rr,4,lr),nr[ce.FLOAT_MAT2]=ur.bind(null,"uniformMatrix2fv",Er,4,cr),nr[ce.FLOAT_MAT3]=ur.bind(null,"uniformMatrix3fv",Er,9,cr),nr[ce.FLOAT_MAT4]=ur.bind(null,"uniformMatrix4fv",Er,16,cr),nr[ce.UNSIGNED_INT]=ur.bind(null,"uniform1uiv",mr,1,lr),nr[ce.UNSIGNED_INT_VEC2]=ur.bind(null,"uniform2uiv",mr,2,lr),nr[ce.UNSIGNED_INT_VEC3]=ur.bind(null,"uniform3uiv",mr,3,lr),nr[ce.UNSIGNED_INT_VEC4]=ur.bind(null,"uniform4uiv",mr,4,lr),nr[ce.FLOAT_MAT2x3]=ur.bind(null,"uniformMatrix2x3fv",Er,6,cr),nr[ce.FLOAT_MAT2x4]=ur.bind(null,"uniformMatrix2x4fv",Er,8,cr),nr[ce.FLOAT_MAT3x2]=ur.bind(null,"uniformMatrix3x2fv",Er,6,cr),nr[ce.FLOAT_MAT3x4]=ur.bind(null,"uniformMatrix3x4fv",Er,12,cr),nr[ce.FLOAT_MAT4x2]=ur.bind(null,"uniformMatrix4x2fv",Er,8,cr),nr[ce.FLOAT_MAT4x3]=ur.bind(null,"uniformMatrix4x3fv",Er,12,cr),nr[ce.SAMPLER_2D]=sr,nr[ce.SAMPLER_CUBE]=sr,nr[ce.SAMPLER_3D]=sr,nr[ce.SAMPLER_2D_SHADOW]=sr,nr[ce.SAMPLER_2D_ARRAY]=sr,nr[ce.SAMPLER_2D_ARRAY_SHADOW]=sr,nr[ce.SAMPLER_CUBE_SHADOW]=sr,nr[ce.INT_SAMPLER_2D]=sr,nr[ce.INT_SAMPLER_3D]=sr,nr[ce.INT_SAMPLER_CUBE]=sr,nr[ce.INT_SAMPLER_2D_ARRAY]=sr,nr[ce.UNSIGNED_INT_SAMPLER_2D]=sr,nr[ce.UNSIGNED_INT_SAMPLER_3D]=sr,nr[ce.UNSIGNED_INT_SAMPLER_CUBE]=sr,nr[ce.UNSIGNED_INT_SAMPLER_2D_ARRAY]=sr,nr);var Tr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function gr(e,t){return"#define ".concat(e," ").concat(t)}function yr(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().split("\n").forEach((function(e){var t=l(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*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,n){return n.trim().split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var u=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}function Ar(e,t,r,n,i){var o,a;void 0===n&&(n=null);var s="#version 100"===e.glslVersion,c=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),f="";null!==n&&(f=Object.keys(n).map((function(e){return gr(e,n[e])})).join("\n"));var p=c.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=c.filter((function(e){return!e.startsWith("precision")})).join("\n"),_="";if(e.viewportOrigin===Me.UpperLeft&&(_+="".concat(gr("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===xe.Zero&&(_+="".concat(gr("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var h=0,E=0,R=0;d=d.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(h,", binding = ").concat(E++,") uniform ").concat(n)})),h++,E=0,Qe(e.separateSamplerTextures),d=(d=d.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = ".concat(h,", binding = ").concat(E++,") uniform texture2D T_").concat(r,";\nlayout(set = ").concat(h,", binding = ").concat(E++,") uniform sampler S_").concat(r,";\n"):""}))).replace("frag"===t?/^\s*\b\s*(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(R++,") ").concat(t)})),_+="".concat(gr("gl_VertexID","gl_VertexIndex"),"\n")}d=e.separateSamplerTextures?(d=(d=(d=d.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_".concat(t,", sampler S_P_").concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_".concat(t,", S_").concat(t)}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_".concat(t,", S_").concat(t,")")})):(d=(d=(d=d.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_".concat(t)}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_".concat(t,")")}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var m="".concat(s?"":e.glslVersion,"\n").concat("","\n").concat(s&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"","\n").concat(p,"\n").concat(_,"\n").concat(f,"\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(m=m.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),s){if("frag"===t&&(m=m.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(m=(m=m.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")}))),m=m.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){var v,T=(m=m.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return v=r,"".concat(t," ").concat(r,";\n")}))).lastIndexOf("}");m=m.substring(0,T)+"\n gl_FragColor = vec4(".concat(v,");\n")+m.substring(T)}m=m.replace(/^\s*layout\((.*)\)/gm,"");try{for(var g=u(Tr),y=g.next();!y.done;y=g.next()){var A=l(y.value,2);m=m.replace(A[0],A[1])}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}}return m}function Sr(e,t,r,n,i){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:Ar(e,"vert",t,n),preprocessedFrag:Ar(e,"frag",r,n)}}function Cr(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 Sr(e.queryVendorInfo(),n,i,r)}var Or=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(y(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return ct(this.defines[e])},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&Qe("1"===t),null!==t},e.prototype.ensurePreprocessed=function(e){""===this.preprocessedVert&&(this.preprocessedVert=Ar(e,"vert",this.both+this.vert,this.defines),this.preprocessedFrag=Ar(e,"frag",this.both+this.frag,this.defines))},e}(),Ir=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=dt(e,this.uniformBufferWordAlignment),Qe(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=dt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=dt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Qe(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=dt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return Je(this.shadowBufferF32)},e.prototype.prepareToRender=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:ge.UNIFORM,hint:ye.Dynamic}));var t=dt(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}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Pr(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function Nr(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Mr(e){return 0}var xr=function(){this.keys=[],this.values=[]},Dr=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=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]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new xr);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=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))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=u(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=u(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function Br(e,t){return Qe(""!==e.preprocessedVert&&""!==t.preprocessedVert),Qe(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Lr(e,t){return e=Pr(e,t.numUniformBuffers),e=Pr(e,t.numSamplers)}function br(e,t){return e=Pr(e,t.blendMode),e=Pr(e,t.blendSrcFactor),e=Pr(e,t.blendDstFactor)}function Fr(e,t){return e=br(e,t.rgbBlendState),e=Pr(e=br(e,t.alphaBlendState),t.channelWriteMask)}function Ur(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=Fr(e,t.attachmentsState[r]);return e=function(e,t){return Pr(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Pr(e,t.depthCompare),e=Pr(e,t.depthWrite?1:0),e=Pr(e,t.stencilCompare),e=Pr(e,t.stencilPassOp),e=Pr(e,t.stencilWrite?1:0),e=Pr(e,t.cullMode),e=Pr(e,t.frontFace?1:0),e=Pr(e,t.polygonOffset?1:0)}function Gr(e){var t=0;t=Pr(t,e.program.id),null!==e.inputLayout&&(t=Pr(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=Lr(t,e.bindingLayouts[r]);t=Ur(t,e.megaStateDescriptor);for(r=0;e.colorAttachmentFormats.length>r;r++)t=Pr(t,e.colorAttachmentFormats[r]||0);return Nr(t=Pr(t,e.depthStencilAttachmentFormat||0))}function wr(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Pr(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Pr(t,n.buffer.id),t=Pr(t,n.wordCount))}return Nr(t)}var kr,Vr,Wr=function(){function e(e){this.bindingsCache=new Dr(Gt,wr),this.renderPipelinesCache=new Dr(Xt,Gr),this.inputLayoutsCache=new Dr(Kt,Mr),this.programCache=new Dr(Br,Mr),this.samplerCache=new Dr(zt,Mr),this.device=e}return e.prototype.createBindings=function(e){var t=this.bindingsCache.get(e);if(null===t){var r=Zt(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t},e.prototype.createRenderPipeline=function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=$t(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t},e.prototype.createInputLayout=function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=rr(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t},e.prototype.createProgramSimple=function(e){var t,r=this.programCache.get(e);if(null===r){var n={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};r=this.device.createProgramSimple(n),this.programCache.add(n,r)}return r},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,l,c;try{for(var f=u(this.bindingsCache.values()),p=f.next();!p.done;p=f.next()){p.value.destroy()}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var d=u(this.renderPipelinesCache.values()),_=d.next();!_.done;_=d.next()){_.value.destroy()}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}try{for(var h=u(this.inputLayoutsCache.values()),E=h.next();!E.done;E=h.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}try{for(var R=u(this.programCache.values()),m=R.next();!m.done;m=R.next()){m.value.destroy()}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var v=u(this.samplerCache.values()),T=v.next();!T.done;T=v.next()){T.value.destroy()}}catch(e){l={error:e}}finally{try{T&&!T.done&&(c=v.return)&&c.call(v)}finally{if(l)throw l.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(kr||(kr={})),function(e){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"}(Vr||(Vr={}));var Xr,Hr=function(){function 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=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),Qe(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.resolveToExternalTexture=function(e,t){this.resolveTextureOutputExternalTextures[e]=t},e.prototype.exec=function(e){Qe(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){Qe(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),Yr=function(){function e(e,t){this.dimension=Ce.n2D,this.depth=1,this.numLevels=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Oe.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.age=0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,Qe(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){Qe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()},e}(),Kr=function(){function e(e,t){this.dimension=Ce.n2D,this.depth=1,this.numLevels=1,this.usage=Oe.RenderTarget,this.width=0,this.height=0,this.age=0,this.immutable=!0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){Qe(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),zr=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},jr=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=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 Yr(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=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 Kr(this.device,e)},e.prototype.beginGraphBuilder=function(){Qe(null===this.currentGraph),this.currentGraph=new zr},e.prototype.pushPass=function(e){var t=new Hr;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=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},e.prototype.resolveRenderTargetPassAttachmentSlot=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]},e.prototype.findPassForResolveRenderTarget=function(e){var t=Je(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Qe(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);Qe(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return Je(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(Qe(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]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=Je(this.renderTargetAliveForID[e]);return t?(Qe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Qe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Qe(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)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;Qe(!(a&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){Qe(e.resolveTextureRenderTargetIDs[i]===n),Qe(this.resolveTextureUseCount[i]>0),Qe(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 p=Je(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(p),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=o,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[Vr.DepthStencil],n=Vr.Color0;Vr.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,u=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Vr.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Vr.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 p=0,d=0,_=0,h=0;t.renderTargets.length>h;h++){var E=t.renderTargets[h];if(E){var R=E.width>>>t.renderTargetLevels[h],m=E.height>>>t.renderTargetLevels[h];0===p&&(p=R,d=m,_=E.sampleCount),Qe(R===p),Qe(m===d),Qe(E.sampleCount===_),E.needsClear=!1}}p>0&&d>0&&(t.viewportX*=p,t.viewportY*=d,t.viewportW*=p,t.viewportH*=d);for(h=0;t.resolveTextureInputIDs.length>h;h++){t.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[h])}for(h=0;t.renderTargetIDs.length>h;h++)this.releaseRenderTargetForID(t.renderTargetIDs[h],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){Qe(0===this.renderTargetOutputCount.length),Qe(0===this.renderTargetResolveCount.length),Qe(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;ft(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),ft(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),ft(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)Qe(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)Qe(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)Qe(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)Qe(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){Qe(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.beginDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.endDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=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},e.prototype.execute=function(){var e=Je(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Qe(r>=0),Je(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Qe(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)Qe(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(Xr||(Xr={}));var qr=65536,Zr=16;function Qr(e,t,r){void 0===r&&(r=qr);var n=O(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<Zr)-1)}function Jr(e,t){return(16777215&e|(255&t)<<24)>>>0}function $r(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function en(e,t){return Jr($r(0,t),e)}function tn(e,t){return Qe(t>=0),(4294967040&e|t>>>8&255)>>>0}function rn(e){return Jr(0,e)}function nn(e,t){return Qe(t>=0),(4278190335&e|t<<8)>>>0}var on=_(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var an,sn=_(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function un(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){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"}(an||(an={}));var ln,cn=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Rt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Rt(4,(function(){return 0})),this.flags=0,this.inputState=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={bindingLayouts:[],inputLayout:null,megaStateDescriptor:At(Ot),program:null,topology:Te.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=an.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){yt(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 t=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>t;t++)this.renderPipelineDescriptor.colorAttachmentFormats[t]=e.renderPipelineDescriptor.colorAttachmentFormats[t];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.inputState=e.inputState,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],l(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~an.InheritedFlags|e.flags&an.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(t=0;Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length)>t;t++)r.uniformBufferBindings[t].wordCount=e.bindingDescriptors[0].uniformBufferBindings[t].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(t=0;e.dynamicUniformBufferByteOffsets.length>t;t++)this.dynamicUniformBufferByteOffsets[t]=e.dynamicUniformBufferByteOffsets[t]},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return yt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setInputLayoutAndState=function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){Qe(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers),this.renderPipelineDescriptor.bindingLayouts[0]=e,this.bindingDescriptors[0].bindingLayout=e;for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({buffer:null,wordCount:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})},e.prototype.setBindingLayouts=function(e){Qe(this.bindingDescriptors.length>=e.length),Qe(1===e.length),this.setBindingLayout(e[0])},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=Et(this.flags,an.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=Et(this.flags,an.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=Et(this.flags,an.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(I(t)||Array.isArray(t)||t instanceof Float32Array){var i=I(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],l(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)a+=un(s,a,n[u],n[u+1],n[u+2],n[u+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){return Qe(this.dynamicUniformBufferByteOffsets.length>this.bindingDescriptors[0].bindingLayout.numUniformBuffers),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=t,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.setUniformBufferOffset=function(e,t,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=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.lateBinding=n.lateBinding):(r.texture=null,r.sampler=null,r.lateBinding=null)}},e.prototype.hasLateSamplerBinding=function(e){for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){if(this.bindingDescriptors[0].samplerBindings[t].lateBinding===e)return!0}return!1},e.prototype.resolveLateSamplerBinding=function(e,t){for(var r=0;this.bindingDescriptors[0].samplerBindings.length>r;r++){var n=this.bindingDescriptors[0].samplerBindings[r];n.lateBinding===e&&(null===t?(n.texture=null,n.sampler=null):(Qe(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=Et(this.flags,an.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.pixelFormat:null,null!==o&&(-1===n?n=o.sampleCount:Qe(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.pixelFormat:null,null!==a&&(-1===n?n=a.sampleCount:Qe(n==a.sampleCount)),Qe(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&an.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setInputState(this.inputState);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=Je(this.uniformBuffer.buffer);this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniforms(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(0,s,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Qe(!!(this.flags&an.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&an.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0},e}();function fn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(ln||(ln={}));var pn=function(){function e(e,t){void 0===e&&(e=fn),void 0===t&&(t=ln.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):ht(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=an.Draw,this.insertSorted(e)},e.prototype.hasLateSamplerBinding=function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1},e.prototype.resolveLateSamplerBinding=function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].resolveLateSamplerBinding(e,t)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){this.ensureSorted();var r=0;if(this.executionOrder===ln.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)&&r++;return r},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),dn=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new cn),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),_n=function(){function e(e){this.renderCache=e,this.instPool=new dn,this.templatePool=new dn,this.simpleRenderInstList=new pn,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=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},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){Qe(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=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|=an.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Qe(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){Je(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){Je(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),hn=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Wr(e),this.renderGraph=new jr(this.device),this.renderInstManager=new _n(this.renderCache),this.uniformBuffer=new Ir(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=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)!==kr.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),En=function(){function e(e){this.pixelFormat=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function Rn(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var mn,vn=Rn(rt(.88,.88,.88,1)),Tn=Rn(it),gn=Rn(at);function yn(e,t){var r=function(e){return e.antialiasingMode===mn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function An(e,t,r){var n=function(e){if(e===Vr.Color0)return Fe.U8_RGBA_RT;if(e===Vr.DepthStencil)return Fe.D24_S8;throw Error("whoops")}(e),i=new En(n);return yn(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(mn||(mn={}));var Sn,Cn=function(){function e(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.lateBinding=e.lateBinding,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),On=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Qe(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Kr(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),In=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Sn||(Sn={}));var Pn,Nn=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:Sn.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);!function(e){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"}(Pn||(Pn={}));var Mn,xn=function(){function e(e,t,r,n){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.renderLists={world:new pn,picking:new pn}}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,u=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.nodeName!==In.tag?t.nodeName!==Nn.tag?(t.renderable3D||(t.renderable3D=new Ue),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},c=function(e){var t=e.target;t.nodeName!==In.tag?t.nodeName!==Nn.tag?(n.swapChain&&n.batchManager.remove(t),delete t.renderable3D):n.lightPool.removeFog(t):n.lightPool.removeLight(t)},f=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)}},p=function(e){n.swapChain&&n.batchManager.updateAttribute(e.target,"modelMatrix",null)};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return u.addEventListener(t.ElementEvent.MOUNTED,l),u.addEventListener(t.ElementEvent.UNMOUNTED,c),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((o=this.context.config).width,o.height),n=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return n.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),u.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),u.removeEventListener(t.ElementEvent.MOUNTED,l),u.removeEventListener(t.ElementEvent.UNMOUNTED,c),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),o.hooks.beginFrame.tap(e.tag,(function(){var e,r=n.swapChain.getCanvas(),i=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)e=nt;else{var o=t.parseColor(n.context.config.background);e=n.context.config.background?rt(Number(o.r)/255*Number(o.alpha),Number(o.g)/255*Number(o.alpha),Number(o.b)/255*Number(o.alpha),Number(o.alpha)):ot}var a={backbufferWidth:r.width,backbufferHeight:r.height,antialiasingMode:mn.None},s=An(Vr.Color0,a,Rn(e)),u=An(Vr.DepthStencil,a,gn),l=n.builder.createRenderTargetID(s,"Main Color"),c=n.builder.createRenderTargetID(u,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Vr.Color0,l),e.attachRenderTargetID(Vr.DepthStencil,c),e.exec((function(e){n.renderLists.world.drawOnPassRenderer(i.renderCache,e)}))})),n.builder.resolveRenderTargetToExternalTexture(l,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(){var e,t,r=n.renderHelper.renderInstManager,i=n.renderHelper.pushTemplateRenderInst();i.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),i.setMegaStateFlags(Nt({depthWrite:!0,blendConstant:nt},{rgbBlendMode:Ee.Add,alphaBlendMode:Ee.Add,rgbBlendSrcFactor:he.SrcAlpha,alphaBlendSrcFactor:he.One,rgbBlendDstFactor:he.OneMinusSrcAlpha,alphaBlendDstFactor:he.OneMinusSrcAlpha}));var o=(e=n.context.config).width,a=e.height,s=n.context.camera;if(i.setUniforms(0,[{name:Pn.PROJECTION_MATRIX,value:s.getPerspective()},{name:Pn.VIEW_MATRIX,value:s.getViewTransform()},{name:Pn.CAMERA_POSITION,value:s.getPosition()},{name:Pn.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Pn.VIEWPORT,value:[o,a]},{name:Pn.IS_ORTHO,value:s.isOrtho()?1:0},{name:Pn.IS_PICKING,value:0}]),n.batchManager.render(n.renderLists.world),r.popTemplateRenderInst(),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),r.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var u=(t=n.captureOptions).type,l=t.encoderOptions,c=n.context.contextService.getDomElement().toDataURL(u,l);n.resolveCapturePromise(c),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),Dn=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new Ue);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,a)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a)})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){throw Error("Async version is not implemented.")}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,u=this.context.config.height*a,l=i*a,c=o*a;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(O(Math.round(l),0,s-1),O(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var 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},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n,o=this,a=this.renderGraphPlugin.getDevice(),s=this.renderGraphPlugin.getRenderLists(),u=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),c=this.context.camera,f=e.x,p=e.y,d=e.width,_=e.height,h={backbufferWidth:d,backbufferHeight:_,antialiasingMode:mn.None},E=An(Vr.Color0,h,Rn(nt)),R=l.createRenderTargetID(E,"Picking Color"),m=An(Vr.DepthStencil,h,gn),v=l.createRenderTargetID(m,"Picking Depth"),T=i({},c.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Vr.Color0,R),e.attachRenderTargetID(Vr.DepthStencil,v),e.exec((function(e){s.picking.drawOnPassRenderer(u.renderCache,e)})),e.post((function(e){var t=e.getRenderTargetTexture(Vr.Color0),r=a.createReadback();T&&T.enabled?c.setViewOffset(T.fullWidth,T.fullHeight,T.offsetX,T.offsetY,T.width,T.height):c.clearViewOffset(),c.setEnableUpdate(!0);var i=r.readTextureSync(t,0,0,d,_,new Uint8Array(d*_*4)),s=-1;if(!i||0===i[0]&&0===i[1]&&0===i[2]||(s=o.pickingIdGenerator.decodePickingColor(i)),s>-1){var u=o.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(n=u)}r.destroy()}))}));var g=this.renderHelper.pushTemplateRenderInst();g.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),g.setMegaStateFlags(Nt({depthWrite:!0},{rgbBlendMode:Ee.Add,rgbBlendSrcFactor:he.One,rgbBlendDstFactor:he.Zero,alphaBlendMode:Ee.Add,alphaBlendSrcFactor:he.One,alphaBlendDstFactor:he.Zero}));var y=(r=this.context.config).width,A=r.height,S=this.context.contextService.getDPR();return c.setEnableUpdate(!1),c.setViewOffset(y*S,A*S,f,p,d,_),g.setUniforms(0,[{name:Pn.PROJECTION_MATRIX,value:c.getPerspective()},{name:Pn.VIEW_MATRIX,value:c.getViewTransform()},{name:Pn.CAMERA_POSITION,value:c.getPosition()},{name:Pn.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Pn.VIEWPORT,value:[y,A]},{name:Pn.IS_ORTHO,value:c.isOrtho()?1:0},{name:Pn.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(s.picking,!0),u.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),u.resetRenderInsts(),n},e.tag="WebGLPicker",e}(),Bn=.005,Ln=function(){function e(){this.meshes=[],this.clipPathMeshCreated=!1}return e.prototype.shouldSubmitRenderInst=function(e,t){return!0},e.prototype.beforeUploadUBO=function(e,t,r){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();function bn(e,t,r,n){void 0===n&&(n=ye.Static);var i=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:n});return i.setSubData(0,new Uint8Array(r)),i}!function(e){e.CHANGED="changed"}(Mn||(Mn={}));var Fn,Un=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=Te.Triangles,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:Fe.U32_R},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=bn(this.device,ge.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={byteStride:e.byteStride,frequency:e.frequency},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=e.byteStride,u=t.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===r&&e.location===o}));u?(u.format=n,u.bufferByteOffset=i,u.byteStride=s,u.divisor=a):t.inputLayoutDescriptor.vertexAttributeDescriptors.push({format:n,bufferIndex:r,bufferByteOffset:i,location:o,byteStride:s,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=bn(this.device,ge.VERTEX,i.buffer,ye.Dynamic);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e].byteStride,o=this.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.location===t}));o&&this.getVertexBuffer(e).setSubData(o.bufferByteOffset+r*i,n);this.emit(Mn.CHANGED)},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexAttributeDescriptors=[],this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(N);!function(e){e.CHANGED="changed"}(Fn||(Fn={}));var Gn=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=At(Ot),a=o.cullMode,s=o.depthCompare,u=o.depthWrite,l=o.stencilCompare,c=o.stencilWrite,f=o.stencilPassOp,p=o.frontFace,d=o.polygonOffset,_=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:p,polygonOffset:d,attachmentsState:_,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilCompare",{get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilPassOp",{get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"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},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=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=yr(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(Se.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),y(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(Fn.CHANGED)},t}(N),wn=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Gn);function kn(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Vn(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Wn=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=l(e,2);return void 0!==t[1]})))};function Xn(e,t){return 256*(e=O(Math.floor(e),0,255))+(t=O(Math.floor(t),0,255))}var Hn,Yn,Kn=1,zn="FillTextureMapping";!function(e){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"}(Hn||(Hn={})),function(e){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"}(Yn||(Yn={}));var jn,qn,Zn=function(){function e(e,t,r){this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.id=Kn++,this.index=-1,this.objects=[],this.program=new Or,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.lightReceived=!1,this.divisor=1,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(e){this.inited||(this.renderer.beforeInitMesh(this),this.context=e,this.material=new wn(this.context.device),this.material.defines=i(i({},kn(Yn)),this.material.defines),this.geometry=new Un(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(Mn.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(Fn.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n]))},e.prototype.shouldMerge=function(e,t){return!this.instance||(this.instance.nodeName===e.nodeName||this.instance.nodeName===e.renderable.proxyNodeName||this.instance.renderable.proxyNodeName===e.nodeName||this.instance.renderable.proxyNodeName===e.renderable.proxyNodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r=this,n=p(),i=p(),o=[],a=[],s=[],u=[],f=this.divisor;e.forEach((function(e){var f,p=e.parsedStyle,_=p.fill,h=p.stroke,E=p.opacity,R=p.fillOpacity,v=p.strokeOpacity,T=p.lineWidth,g=p.anchor,y=p.visibility,A=p.increasedLineWidthForHitTesting,S=[0,0,0,0];t.isCSSRGB(_)&&(S=[Number(_.r),Number(_.g),Number(_.b),255*Number(_.alpha)]);var C=[0,0,0,0];t.isCSSRGB(h)&&(C=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),r.clipPathTarget?(d(n,e.getLocalTransform()),S=[255,255,255,255],m(n,r.clipPathTarget.getWorldTransform(),n)):d(n,e.getWorldTransform()),m(i,r.context.camera.getViewTransform(),n);var O=e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];o.push.apply(o,c([],l(n),!1)),a.push(Xn(S[0],S[1]),Xn(S[2],S[3]),Xn(C[0],C[1]),Xn(C[2],C[3])),s.push(E,R,v,T,"visible"===y?1:0,g[0],g[1],A||0),u.push.apply(u,c(c([],l(O),!1),[e.sortable.renderOrder*Bn],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Hn.MODEL_MATRIX,byteStride:64,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.MODEL_MATRIX0,divisor:f},{format:Fe.F32_RGBA,bufferByteOffset:16,location:Yn.MODEL_MATRIX1,divisor:f},{format:Fe.F32_RGBA,bufferByteOffset:32,location:Yn.MODEL_MATRIX2,divisor:f},{format:Fe.F32_RGBA,bufferByteOffset:48,location:Yn.MODEL_MATRIX3,divisor:f}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PACKED_COLOR,byteStride:16,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.PACKED_COLOR,divisor:f}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PACKED_STYLE,byteStride:32,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.PACKED_STYLE1,divisor:f},{format:Fe.F32_RGBA,bufferByteOffset:16,location:Yn.PACKED_STYLE2,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Hn.PICKING_COLOR,byteStride:16,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.PICKING_COLOR,divisor:f}],data:new Float32Array(u)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=this.lightPool.getAllLights(),o=!!this.lightPool.getFog(),a=!!n.length;this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=pe.Always,this.material.stencilPassOp=Pe.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=pe.Equal,this.material.stencilPassOp=Pe.Keep):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var s=i({},this.material.defines);if(this.material.defines.USE_FOG=o,this.material.defines.USE_LIGHT=a,this.material.defines=i(i(i({},this.material.defines),this.lightPool.getDefines()),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var u=this.createFillGradientTextureMapping(t);u&&this.textureMappings.push(u),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 Cn;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:Re.Clamp,wrapT:Re.Clamp,minFilter:me.Point,magFilter:me.Bilinear,mipFilter:ve.Linear,minLOD:0,maxLOD: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}(!Vn(s,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),kn(Yn)),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.programDescriptorSimpleWithOrig=Cr(this.context.device,this.program),this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.inputStateDirty=!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,this.inputStateDirty=!0);var l=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),c=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),f=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.context.device.createInputState(l,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),f?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,c),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(c),e.setInputLayoutAndState(l,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),f?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=en(Xr.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){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(Xn(a[0],a[1]),Xn(a[2],a[3]),Xn(s[0],s[1]),Xn(s[2],s[3]))})),this.geometry.updateVertexBuffer(Hn.PACKED_COLOR,Yn.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===zn}));if(t.isCSSRGB(a))0>s||(this.textureMappings.splice(s,-1),this.material.textureDirty=!0);else{var u=this.createFillGradientTextureMapping([this.instance]);0>s||this.textureMappings.splice(s,1,u),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var f=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor;f.push(t.opacity,t.fillOpacity,t.strokeOpacity,t.lineWidth,"visible"===t.visibility?1:0,r[0],r[1],t.increasedLineWidthForHitTesting||0)})),this.geometry.updateVertexBuffer(Hn.PACKED_STYLE,Yn.PACKED_STYLE1,r,new Uint8Array(new Float32Array(f).buffer))}else if("modelMatrix"===n){var _=[];e.forEach((function(e){var t=d(p(),e.getWorldTransform());_.push.apply(_,c([],l(t),!1))})),this.geometry.updateVertexBuffer(Hn.MODEL_MATRIX,Yn.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(_).buffer))}else if("pointerEvents"===n){var h=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];h.push.apply(h,c(c([],l(r),!1),[e.sortable.renderOrder*Bn],!1))})),this.geometry.updateVertexBuffer(Hn.PICKING_COLOR,Yn.PICKING_COLOR,r,new Uint8Array(new Float32Array(h).buffer))}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},e.prototype.changeRenderOrder=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(Hn.PICKING_COLOR,Yn.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],l(i),!1),[t*Bn],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Hn.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var u=t[i],l=1;e.vertices.length>l;l++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[l].byteStride)/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];s[i]=a,a++}var p=function(t){var r=e.inputLayoutDescriptor.vertexBufferDescriptors[t],n=r.frequency,i=r.byteStride,o=e.inputLayoutDescriptor.vertexAttributeDescriptors.find((function(e){return e.bufferIndex===t}));o&&e.setVertexBuffer({bufferIndex:o.bufferIndex,byteStride:i,frequency:n,attributes:[{format:o.format,bufferByteOffset:o.bufferByteOffset,location:o.location,divisor:o.divisor}],data:e.vertices[t]})};for(i=Hn.PICKING_COLOR+1;e.vertexBuffers.length>i;i++)p(i);var d=new Float32Array(3*r);for(i=0;r>i;)for(l=0;3>l;l++){d[3*(u=s[i++])+l]=1}e.setVertexBuffer({bufferIndex:Hn.BARYCENTRIC,byteStride:12,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RGB,bufferByteOffset:0,location:Number(Yn.BARYCENTRIC)}],data:d}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t,r){},e.prototype.uploadUBO=function(e){var r=this,n=this.material,o=this.lightPool.getAllLights(),a=this.lightPool.getFog(),s=!!a,u=this.lightReceived&&!!o.length,l=[];if(n.defines.USE_WIREFRAME){var c=t.parseColor(n.wireframeColor);l.push({name:"u_WireframeLineColor",value:[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255]}),l.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(s&&this.uploadFog(l,a),this.uploadMaterial(l,n),u){var f={};o.forEach((function(e){f[e.define]||(f[e.define]=-1),f[e.define]++,e.uploadUBO(l,f[e.define])}))}l.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,l);var p=n.blendEquation,d=n.blendEquationAlpha,_=n.blendSrc,h=n.blendDst,E=n.blendSrcAlpha,R=n.blendDstAlpha,m=Wn({blendConstant:n.blendConstant,depthCompare:n.depthCompare,depthWrite:n.depthWrite,stencilCompare:n.stencilCompare,stencilWrite:n.stencilWrite,stencilPassOp:n.stencilPassOp,stencilRef:n.stencilRef,cullMode:n.cullMode,frontFace:n.frontFace,polygonOffset:n.polygonOffset}),v=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Ie.None:Ie.AllChannels,rgbBlendState:i(i({},v.rgbBlendState),Wn({blendMode:p,blendSrcFactor:_,blendDstFactor:h})),alphaBlendState:i(i({},v.alphaBlendState),Wn({blendMode:d,blendSrcFactor:E,blendDstFactor:R}))}]},m)),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(t.isCSSRGB(o)){var l=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,u]}),e.push({name:"u_FogColor",value:l})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],l(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.nodeName===t.Shape.LINE?i.parsedStyle.stroke:i.parsedStyle.fill;if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,We(Fe.U8_RGBA_NORM,1,1,1));if(a){var s=new Cn;return s.name=zn,s.texture=a,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"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Bilinear,mipFilter:ve.Linear,minLOD:0,maxLOD:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(jn||(jn={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(qn||(qn={}));var Qn,Jn,$n=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],ei=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(!this.needDrawStrokeSeparately(t.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&this.instance.parsedStyle.fill.isNone===t.parsedStyle.fill.isNone)},r.prototype.createMaterial=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 vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\nlayout(location = SIZE) in vec2 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec3 v_Data;\nout vec2 v_Radius;\nout vec4 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 #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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 + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n float antialiasblur = 1.0 / radius.y;\n\n bool isBillboard = a_StylePacked3.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec3(a_Extrude * radius / radius.y, antialiasblur);\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 vec3 v_Data;\nin vec2 v_Radius;\nin vec4 v_StylePacked3;\n\nout vec4 outputColor;\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 float epsilon = 0.000001;\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 float antialiasblur = v_Data.z;\n float antialiased_blur = -max(0.0, antialiasblur);\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 outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data.xy, 1.0);\n inner_df = sdCircle(v_Data.xy, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data.xy, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data.xy, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data.xy, 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=i(i({},this.material.defines),kn(qn))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[],o=[];t.forEach((function(e,t){var a=e,s=4*t,u=a.parsedStyle.radius,f=r.shouldOmitStroke(a.parsedStyle),p=r.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,c(c([],l(p),!1),[$n.indexOf(a.nodeName),u&&u[0]||0,f?1:0,a.parsedStyle.isBillboard?1:0],!1)),n.push(-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1),o.push(0+s,2+s,1+s,0+s,3+s,2+s)})),this.geometry.setIndexBuffer(new Uint32Array(o)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:16,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Yn.POSITION},{format:Fe.F32_RG,bufferByteOffset:8,location:Yn.UV}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:jn.PACKED_STYLE,byteStride:24,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:qn.SIZE,divisor:1},{format:Fe.F32_RGBA,bufferByteOffset:8,location:qn.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=l(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],l([n[0],n[1]]),!1),[$n.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0,t.parsedStyle.isBillboard?1:0],!1))})),this.geometry.updateVertexBuffer(jn.PACKED_STYLE,qn.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},r.prototype.getSize=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},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r.prototype.needDrawStrokeSeparately=function(e){var t=e.stroke,r=e.lineDash,n=e.lineWidth,i=e.strokeOpacity,o=t&&!t.isNone,a=r&&r.length&&r.every((function(e){return 0!==e}));return o&&n>0&&(a||1>i)},r}(Zn),ti=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Qn||(Qn={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(Jn||(Jn={}));var ri={butt:1,round:2,square:3},ni=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.isLine=function(e){if(e.nodeName===t.Shape.PATH){var r=e.parsedStyle.path.absolutePath;if(2===r.length&&"M"===r[0][0]&&"L"===r[1][0])return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var n=e.parsedStyle.points.points,i=(n[1][0]-n[1][1])/(n[0][0]-n[0][1]),o=1;n.length-1>o;o++)if((n[o+1][0]-n[o+1][1])/(n[o][0]-n[o][1])!==i)return!1;return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=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\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\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 #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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 float isBillboard = a_Dash.w;\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n if (isBillboard > 0.5 && isPerspective) {\n // clip space\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 + strokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + strokeWidth * (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 * strokeWidth * 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(strokeWidth / 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;\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 = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\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 * blur\n * u_Opacity * u_StrokeOpacity\n * ceil(mod(v_Dash.x + u_dash_offset, u_dash_array) - (u_dash_array * u_dash_ratio));\n }\n}",this.material.defines=i(i({},this.material.defines),kn(Jn))},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],u=0;r.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,defX:c.defX,defY:c.defY,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:!0,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){var p=e.parsedStyle,d=p.path.absolutePath;r={x1:d[0][1],y1:d[0][2],x2:d[1][1],y2:d[1][2],z1:0,z2:0,defX:p.defX,defY:p.defY,lineCap:p.lineCap,lineDash:p.lineDash,lineDashOffset:p.lineDashOffset,isBillboard:!1,markerStart:p.markerStart,markerEnd:p.markerEnd,markerStartOffset:p.markerStartOffset,markerEndOffset:p.markerEndOffset},l=e.getTotalLength()}var _=r.x1,h=r.y1,E=r.x2,R=r.y2,m=r.z1,v=r.z2,T=r.defX,g=r.defY,y=r.lineCap,A=r.isBillboard,S=n.calcOffset(r),C=S.startOffsetX,O=S.startOffsetY,I=S.endOffsetX,P=S.endOffsetY,N=n.calcDash(r,l),M=N.dashOffset,x=N.dashSegmentPercent,D=N.dashRatioInEachSegment;o.push(ri[y]),a.push(M,x,D,A?1:0),i.push(_-T+C,h-g+O,m,E-T+I,R-g+P,v),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:Hn.POSITION,byteStride:20,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGB,bufferByteOffset:0,location:Jn.POSITION,divisor:0},{format:Fe.F32_RG,bufferByteOffset:12,location:Jn.UV,divisor:0}],data:new Float32Array(ti)}),this.geometry.setVertexBuffer({bufferIndex:Qn.POINT,byteStride:24,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGB,bufferByteOffset:0,location:Jn.POINTA,divisor:1},{format:Fe.F32_RGB,bufferByteOffset:12,location:Jn.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Qn.CAP,byteStride:4,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_R,bufferByteOffset:0,location:Jn.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Qn.DASH,byteStride:16,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Jn.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"path"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE&&e.renderable.proxyNodeName===t.Shape.LINE){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,defX:n.defX,defY:n.defY,lineCap:n.lineCap,isBillboard:!0,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH&&e.renderable.proxyNodeName===t.Shape.LINE){var o=e.parsedStyle,u=o.path.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,defX:o.defX,defY:o.defY,lineCap:o.lineCap,isBillboard:!0,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,p=r.y2,d=r.z1,_=r.z2,h=r.defX,E=r.defY,R=a.calcOffset(r);s.push(l-h+R.startOffsetX,c-E+R.startOffsetY,d,f-h+R.endOffsetX,p-E+R.endOffsetY,_)})),this.geometry.updateVertexBuffer(Qn.POINT,Jn.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isBillboard"===i){var u=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Qn.DASH,Jn.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];r.forEach((function(e){l.push(ri[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Qn.CAP,Jn.CAP,n,new Uint8Array(new Float32Array(l).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,p=0,d=0,_=0;return a&&t.isDisplayObject(a)&&u&&(c=Math.cos(_=Math.atan2(o-n,i-r))*(u||0),f=Math.sin(_)*(u||0)),s&&t.isDisplayObject(s)&&l&&(p=Math.cos(_=Math.atan2(n-o,r-i))*(l||0),d=Math.sin(_)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:p,endOffsetY:d}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(Zn),ii="#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\n#ifdef INSTANCED\n in vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n in vec4 v_Dash;\n#else\n layout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n#endif\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;\n\nvoid main(){\n #ifdef INSTANCED\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 #else\n if (u_Visible < 0.5) {\n discard;\n }\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 #ifdef INSTANCED\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n #endif\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 #ifdef INSTANCED\n vec3 pickingColor = u_PickingColor;\n #else\n vec3 pickingColor = u_PickingColor / 255.0;\n #endif\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 outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}",oi="#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\n#ifdef INSTANCED\n layout(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#else\n layout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n#endif\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 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\n#ifdef INSTANCED\n layout(location = DASH) in vec4 a_Dash;\n out vec4 v_Dash;\n#endif\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\n#ifdef INSTANCED\n const float u_Expand = 1.0;\n const float u_MiterLimit = 5.0;\n const float u_ScaleMode = 1.0;\n const float u_Alignment = 0.5;\n#endif\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\nvoid main() {\n #ifdef INSTANCED\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 v_Dash = a_Dash;\n #endif\n\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\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 next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\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 gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n}",ai=10,si=8,ui=100;function li(e,t,r,n,i,o){for(var a=i[i.length-2],s=i[i.length-1],u=null!=o?o:O(le(a,s,e,t,r,n,3)/ai,si,ui),l=0,c=0,f=1;u>=f;++f){var p=f/u;i.push((l=a+(e-a)*p)+(e+(r-e)*p-l)*p,(c=s+(t-s)*p)+(t+(n-t)*p-c)*p)}}function ci(e,t,r,n,i,o,a,s){var u=a[a.length-2],l=a[a.length-1];a.length-=2;var c=null!=s?s:O(se(u,l,e,t,r,n,i,o,3)/ai,si,ui),f=0,p=0,d=0,_=0,h=0;a.push(u,l);for(var E=1,R=0;c>=E;++E)a.push((d=(p=(f=1-(R=E/c))*f)*f)*u+3*p*R*e+3*f*(_=R*R)*r+(h=_*R)*i,d*l+3*p*R*t+3*f*_*n+h*o)}var fi,pi=1e20,di=function(){function e(e){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,u=e.cutoff,l=void 0===u?.25:u,c=e.fontFamily,f=void 0===c?"sans-serif":c,p=e.fontWeight,d=void 0===p?"normal":p,_=e.fontStyle,h=void 0===_?"normal":_,E=e.canvas;this.buffer=o,this.cutoff=l,this.radius=s;var R=this.size=n+4*o,m=t.runtime.offscreenCanvas.getOrCreateCanvas(E);m.width=R,m.height=R;var v=t.runtime.offscreenCanvas.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=v,v.font="".concat(h," ").concat(d," ").concat(n,"px ").concat(f),v.textBaseline="alphabetic",v.textAlign="left",v.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),p=new Uint8ClampedArray(f),d={data:p,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return d;var _=this,h=_.ctx,E=_.buffer,R=_.gridInner,m=_.gridOuter;h.clearRect(E,E,s,u),h.fillText(e,E,E+a);var v=h.getImageData(E,E,s,u);m.fill(pi,0,f),R.fill(0,0,f);for(var T=0;u>T;T++)for(var g=0;s>g;g++){var y=v.data[4*(T*s+g)+3]/255;if(0!==y){var A=(T+E)*l+g+E;if(1===y)m[A]=0,R[A]=pi;else m[A]=(C=.5-y)>0?C*C:0,R[A]=0>C?C*C:0}}_i(m,0,0,l,c,l,this.f,this.v,this.z),_i(R,E,E,s,u,l,this.f,this.v,this.z);for(var S=0;f>S;S++){var C;p[S]=Math.round(255-255*((C=Math.sqrt(m[S])-Math.sqrt(R[S]))/this.radius+this.cutoff))}return d},e}();function _i(e,t,r,n,i,o,a,s,u){for(var l=t;t+n>l;l++)hi(e,r*o+l,o,i,a,s,u);for(var c=r;r+i>c;c++)hi(e,c*o+t,1,n,a,s,u)}function hi(e,t,r,n,i,o,a){o[0]=0,a[0]=-pi,a[1]=pi,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{l=(i[s]-i[f=o[u]]+c-f*f)/(s-f)/2}while(a[u]>=l&&--u>-1);o[++u]=s,a[u]=l,a[u+1]=pi}for(s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;var f,p=s-(f=o[u]);e[t+s*r]=i[f]+p*p}}!function(e){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"}(fi||(fi={}));var Ei,Ri,mi;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(Ei||(Ei={})),function(e){e[e.PREV=0]="PREV",e[e.POINT1=1]="POINT1",e[e.POINT2=2]="POINT2",e[e.NEXT=3]="NEXT",e[e.VERTEX_JOINT=4]="VERTEX_JOINT",e[e.VERTEX_NUM=5]="VERTEX_NUM",e[e.TRAVEL=6]="TRAVEL"}(Ri||(Ri={})),function(e){e.MODEL_MATRIX="u_ModelMatrix",e.FILL_COLOR="u_FillColor",e.STROKE_COLOR="u_StrokeColor",e.STROKE_WIDTH="u_StrokeWidth",e.INCREASED_LINE_WIDTH_FOR_HIT_TESTING="u_IncreasedLineWidthForHitTesting",e.OPACITY="u_Opacity",e.FILL_OPACITY="u_FillOpacity",e.STROKE_OPACITY="u_StrokeOpacity",e.EXPAND="u_Expand",e.MITER_LIMIT="u_MiterLimit",e.SCALE_MODE="u_ScaleMode",e.ALIGNMENT="u_Alignment",e.PICKING_COLOR="u_PickingColor",e.DASH="u_Dash",e.GAP="u_Gap",e.DASH_OFFSET="u_DashOffset",e.VISIBLE="u_Visible",e.Z_INDEX="u_ZIndex"}(mi||(mi={}));var vi,Ti,gi=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(e,t){return!1},r.prototype.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r,n,s,u,l,c,f,d,_,h,R,T,g=e.parsedStyle,y=g.stroke,A=g.opacity,S=g.fillOpacity,C=g.strokeOpacity,O=g.lineWidth,I=g.increasedLineWidthForHitTesting,P=g.anchor,N=g.lineDash,M=g.lineDashOffset,x=g.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===i||e.nodeName===t.Shape.CIRCLE&&"r"===i||e.nodeName===t.Shape.ELLIPSE&&("rx"===i||"ry"===i)||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("stroke"===i){var D=[0,0,0,0];t.isCSSRGB(y)&&(D=[Number(y.r)/255,Number(y.g)/255,Number(y.b)/255,Number(y.alpha)]),a.material.setUniforms(((r={})[mi.STROKE_COLOR]=D,r))}else if("opacity"===i)a.material.setUniforms(((n={})[mi.OPACITY]=A,n));else if("fillOpacity"===i)a.material.setUniforms(((s={})[mi.FILL_OPACITY]=S,s));else if("strokeOpacity"===i)a.material.setUniforms(((u={})[mi.STROKE_OPACITY]=C,u));else if("lineWidth"===i)a.material.setUniforms(((l={})[mi.STROKE_WIDTH]=O,l));else if("increasedLineWidthForHitTesting"===i)a.material.setUniforms(((c={})[mi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=I||0,c));else if("anchor"===i||"modelMatrix"===i){var B=0,L=0,b=e.getGeometryBounds();if(b){var F=b.halfExtents;B=-F[0]*P[0]*2,L=-F[1]*P[1]*2}var U=p();m(U,e.getWorldTransform(),E(U,v(B,L,0))),a.material.setUniforms(((f={})[mi.MODEL_MATRIX]=U,f))}else if("visibility"===i)a.material.setUniforms(((d={})[mi.VISIBLE]="visible"===x?1:0,d));else if("lineDash"===i)a.material.setUniforms(((_={})[mi.DASH]=N[0]||0,_[mi.GAP]=N[1]||0,_));else if("lineDashOffset"===i)a.material.setUniforms(((h={})[mi.DASH_OFFSET]=M||0,h));else if("pointerEvents"===i){var G=o&&e.isInteractive()&&(null===(T=e.renderable3D)||void 0===T?void 0:T.encodedPickingColor)||[0,0,0];a.material.setUniforms(((R={})[mi.PICKING_COLOR]=G,R))}}))},r.prototype.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[mi.Z_INDEX]=t*Bn,r))},r.prototype.createMaterial=function(e){var r,n;this.material.vertexShader=oi,this.material.fragmentShader=ii,this.material.defines=i(i({},this.material.defines),kn(Ri));var o=e[0],a=o.parsedStyle,s=a.fill,u=a.stroke,l=a.opacity,c=a.fillOpacity,f=a.strokeOpacity,d=a.lineWidth,_=a.increasedLineWidthForHitTesting,h=a.anchor,R=a.lineDash,T=a.lineDashOffset,g=a.visibility,y=[0,0,0,0];t.isCSSRGB(s)&&(y=[Number(s.r)/255,Number(s.g)/255,Number(s.b)/255,Number(s.alpha)]);var A=[0,0,0,0];t.isCSSRGB(u)&&(A=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var S=o.isInteractive()&&(null===(n=o.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0],C=0,O=0,I=o.getGeometryBounds();if(I){var P=I.halfExtents;C=-P[0]*h[0]*2,O=-P[1]*h[1]*2}var N=p();m(N,o.getWorldTransform(),E(N,v(C,O,0))),this.material.setUniforms(((r={})[mi.MODEL_MATRIX]=N,r[mi.FILL_COLOR]=y,r[mi.STROKE_COLOR]=A,r[mi.STROKE_WIDTH]=d,r[mi.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=_||0,r[mi.OPACITY]=l,r[mi.FILL_OPACITY]=c,r[mi.STROKE_OPACITY]=f,r[mi.EXPAND]=1,r[mi.MITER_LIMIT]=5,r[mi.SCALE_MODE]=1,r[mi.ALIGNMENT]=.5,r[mi.PICKING_COLOR]=S,r[mi.DASH]=R&&R[0]||0,r[mi.GAP]=R&&R[1]||0,r[mi.DASH_OFFSET]=T||0,r[mi.VISIBLE]="visible"===g?1:0,r[mi.Z_INDEX]=o.sortable.renderOrder*Bn,r)),this.material.cullMode=_e.None},r.prototype.createGeometry=function(e){var t=yi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:Ei.PACKED,byteStride:48,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,byteStride:12,location:Ri.PREV,divisor:1},{format:Fe.F32_RG,bufferByteOffset:12,byteStride:12,location:Ri.POINT1,divisor:1},{format:Fe.F32_R,bufferByteOffset:20,byteStride:12,location:Ri.VERTEX_JOINT,divisor:1},{format:Fe.F32_RG,bufferByteOffset:24,byteStride:12,location:Ri.POINT2,divisor:1},{format:Fe.F32_RG,bufferByteOffset:36,byteStride:12,location:Ri.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:Ei.VERTEX_NUM,byteStride:4,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ri.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Ei.TRAVEL,byteStride:4,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ri.TRAVEL,divisor:1}],data:new Float32Array(r)}),this.geometry.vertexCount=15,this.geometry.instancedCount=n,this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2,4,6,5,4,7,6,4,7,8]))},r}(Zn);function yi(e,r,n){var i;void 0===r&&(r=!1);var o=e.parsedStyle,a=o.lineCap,s=o.lineJoin,u=e.parsedStyle,f=u.defX,d=u.defY,_=e.parsedStyle,E=_.markerStart,R=_.markerEnd,m=_.markerStartOffset,v=_.markerEndOffset,T=[],y=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var A=e.parsedStyle.points.points,S=A.length,C=0,O=0,I=0,P=0,N=0;if(E&&t.isDisplayObject(E)&&m&&(C=Math.cos(N=Math.atan2(A[1][1]-A[0][1],A[1][0]-A[0][0]))*(m||0),O=Math.sin(N)*(m||0)),R&&t.isDisplayObject(R)&&v&&(I=Math.cos(N=Math.atan2(A[S-2][1]-A[S-1][1],A[S-2][0]-A[S-1][0]))*(v||0),P=Math.sin(N)*(v||0)),T[0]=A.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=C,i=O):r===S-1&&(n=I,i=P),e.push(t[0]-f+n,t[1]-d+i),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return y=ne(T[0],[],2),{pointsBuffer:T[0],travelBuffer:[],triangles:y,instancedCount:Math.round(T[0].length/2)};T[0].push(T[0][0],T[0][1]),(i=T[0]).push.apply(i,c([],l(Ai(T[0][0],T[0][1],T[0][2],T[0][3])),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var M=void 0;if(e.nodeName!==t.Shape.PATH){if(M=t.parsePath(t.convertToPath(e,h(p()))),f=M.rect.x,d=M.rect.y,e.nodeName===t.Shape.RECT){var x=e.parsedStyle;0>x.width&&(f+=M.rect.width),0>x.height&&(d+=M.rect.height)}}else M=e.parsedStyle.path;var D=M.absolutePath,B=M.segments,L=0,b=0,F=0,U=0;N=0;if(E&&t.isDisplayObject(E)&&m){var G=l(E.parentNode.getStartTangent(),2);L=Math.cos(N=Math.atan2((w=G[0])[1]-(k=G[1])[1],w[0]-k[0]))*(m||0),b=Math.sin(N)*(m||0)}if(R&&t.isDisplayObject(R)&&v){var w,k,V=l(R.parentNode.getEndTangent(),2);F=Math.cos(N=Math.atan2((w=V[0])[1]-(k=V[1])[1],w[0]-k[0]))*(v||0),U=Math.sin(N)*(v||0)}var W=-1,X=-1;if(D.forEach((function(r,i){var o,a=l(r),s=a[0],u=a.slice(1),p=D[i+1],_=0===i&&(0!==L||0!==b),h=(i===D.length-1||p&&("M"===p[0]||"Z"===p[0]))&&0!==F&&0!==U;if("M"===s)X++,T[X]=[],W=T[X].length,_?T[X].push(u[0]-f+L,u[1]-d+b,u[0]-f,u[1]-d):T[X].push(u[0]-f,u[1]-d);else if("L"===s)h?T[X].push(u[0]-f+F,u[1]-d+U):T[X].push(u[0]-f,u[1]-d);else if("Q"===s)li(u[0]-f,u[1]-d,u[2]-f,u[3]-d,T[X],n),h&&T[X].push(u[2]-f+F,u[3]-d+U);else if("A"===s){for(var E=l(B[i].prePoint,2),R=g(E[0],E[1],u[0],u[1],u[2],u[3],u[4],u[5],u[6],void 0),m=0;R.length>m;m+=6)ci(R[m]-f,R[m+1]-d,R[m+2]-f,R[m+3]-d,R[m+4]-f,R[m+5]-d,T[X],n);h&&T[X].push(u[5]-f+F,u[6]-d+U)}else if("C"===s)ci(u[0]-f,u[1]-d,u[2]-f,u[3]-d,u[4]-f,u[5]-d,T[X],n),h&&T[X].push(u[4]-f+F,u[5]-d+U);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var v=1e-4;(Math.abs(T[X][T[X].length-2]-T[X][W])>v||Math.abs(T[X][T[X].length-1]-T[X][W+1])>v)&&T[X].push(T[X][W],T[X][W+1]),(o=T[X]).push.apply(o,c([],l(Ai(T[X][W],T[X][W+1],T[X][W+2],T[X][W+3])),!1))}})),r){var H=T.reduce((function(e,t){return e.push.apply(e,c([],l(t),!1)),e}),[]);return{pointsBuffer:H,travelBuffer:[],triangles:y=ne(H,[],2),instancedCount:Math.round(H.length/2)}}}var Y=function(e){var t;switch(e){case"bevel":t=fi.JOINT_BEVEL;break;case"round":t=fi.JOINT_ROUND;break;default:t=fi.JOINT_MITER}return t}(s),K=function(e){var t;switch(e){case"square":t=fi.CAP_SQUARE;break;case"round":t=fi.CAP_ROUND;break;default:t=fi.CAP_BUTT}return t}(a),z=K;K===fi.CAP_ROUND&&(z=fi.JOINT_CAP_ROUND),K===fi.CAP_BUTT&&(z=fi.JOINT_CAP_BUTT),K===fi.CAP_SQUARE&&(z=fi.JOINT_CAP_SQUARE);var j=6;return T.map((function(e){for(var t=0,r=[],n=[],i=0;e.length>i;i+=2)i>1&&(t+=Math.sqrt(Math.pow(e[i]-e[i-2],2)+Math.pow(e[i+1]-e[i+1-2],2))),n.push(t),r[j++]=e[i],r[j++]=e[i+1],r[j]=Y,0==i&&K!==fi.CAP_ROUND&&(r[j]+=K),e.length>i+4?e.length>i+2||(r[j]=0):r[j]+=z-Y,j++;return r[j++]=e[e.length-4],r[j++]=e[e.length-3],r[j++]=0,r[0]=e[0],r[1]=e[1],r[2]=0,r[3]=e[2],r[4]=e[3],r[5]=K===fi.CAP_ROUND?K:0,{pointsBuffer:r,travelBuffer:n,triangles:y,instancedCount:Math.round(e.length/2)}})).reduce((function(e,t){var r,n;return(r=e.pointsBuffer).push.apply(r,c([],l(t.pointsBuffer),!1)),(n=e.travelBuffer).push.apply(n,c([],l(t.travelBuffer),!1)),e.instancedCount+=t.instancedCount,e}),{pointsBuffer:[],travelBuffer:[],triangles:y,instancedCount:0})}function Ai(e,t,r,n){void 0===r&&(r=e),void 0===n&&(n=t);var i=[r-e,n-t];return[e+.01*i[0],t+.01*i[1]]}!function(e){e[e.PACKED=5]="PACKED",e[e.VERTEX_NUM=6]="VERTEX_NUM",e[e.TRAVEL=7]="TRAVEL",e[e.DASH=8]="DASH"}(vi||(vi={})),function(e){e[e.PREV=8]="PREV",e[e.POINT1=9]="POINT1",e[e.POINT2=10]="POINT2",e[e.NEXT=11]="NEXT",e[e.VERTEX_JOINT=12]="VERTEX_JOINT",e[e.VERTEX_NUM=13]="VERTEX_NUM",e[e.TRAVEL=14]="TRAVEL",e[e.DASH=15]="DASH"}(Ti||(Ti={}));var Si=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.isOneCommandCurve=function(e){if(e.nodeName===t.Shape.PATH){var r=e.parsedStyle.path.absolutePath;if(2===r.length&&"M"===r[0][0]&&("C"===r[1][0]||"A"===r[1][0]||"Q"===r[1][0]))return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader=oi,this.material.fragmentShader=ii,this.material.defines=i(i(i({},this.material.defines),kn(Ti)),{INSTANCED:!0})},r.prototype.createGeometry=function(t){var r=[],n=[],i=[],o=[],a=0,s=0;t.forEach((function(e){var t=yi(e,!1,12),u=t.pointsBuffer,f=t.travelBuffer,p=t.instancedCount,d=e.parsedStyle,_=d.lineDash;o.push(_&&_[0]||0,_&&_[1]||0,d.lineDashOffset||0,d.isBillboard?1:0),a+=p;for(var h=0;u.length-9>h;h+=3)n.push(u[h],u[h+1],u[h+2],u[h+3],u[h+4],u[h+5],u[h+6],u[h+7],u[h+8],u[h+9],u[h+10],u[h+11]);i.push.apply(i,c([],l(f),!1)),r.push(0+s,2+s,1+s,0+s,3+s,2+s,4+s,6+s,5+s,4+s,7+s,6+s,4+s,7+s,8+s),s+=9})),this.geometry.setVertexBuffer({bufferIndex:vi.PACKED,byteStride:48,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Ti.PREV,divisor:1},{format:Fe.F32_RG,bufferByteOffset:12,location:Ti.POINT1,divisor:1},{format:Fe.F32_R,bufferByteOffset:20,location:Ti.VERTEX_JOINT,divisor:1},{format:Fe.F32_RG,bufferByteOffset:24,location:Ti.POINT2,divisor:1},{format:Fe.F32_RG,bufferByteOffset:36,location:Ti.NEXT,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:vi.VERTEX_NUM,byteStride:4,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ti.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:vi.TRAVEL,byteStride:4,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ti.TRAVEL,divisor:1}],data:new Float32Array(i)}),this.divisor=a/t.length,this.geometry.setVertexBuffer({bufferIndex:vi.DASH,byteStride:16,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Ti.DASH,divisor:this.divisor}],data:new Float32Array(o)}),e.prototype.createGeometry.call(this,t),this.geometry.vertexCount=15,this.geometry.instancedCount=a,this.geometry.setIndexBuffer(new Uint32Array(r))},r.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"path"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var o=[],a=[],s=0;t.forEach((function(e){var t=yi(e,!1,12),r=t.pointsBuffer,n=t.travelBuffer;s=t.instancedCount;for(var i=0;r.length-9>i;i+=3)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]);a.push.apply(a,c([],l(n),!1))})),this.geometry.updateVertexBuffer(vi.PACKED,Ti.PREV,r*s,new Uint8Array(new Float32Array(o).buffer)),this.geometry.updateVertexBuffer(vi.TRAVEL,Ti.TRAVEL,r,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n){var u=[];t.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;u.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,t.isBillboard?1:0)})),this.geometry.updateVertexBuffer(vi.DASH,vi.DASH,r,new Uint8Array(new Float32Array(u).buffer))}},r}(Zn),Ci=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(e,t){return!1},r.prototype.createGeometry=function(e){var t=e[0],r=yi(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:8,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Yn.POSITION}],data:new Float32Array(i)});var o=t.getGeometryBounds().halfExtents,a=i.map((function(e,t){return e/o[t%2]/2}));this.geometry.setVertexBuffer({bufferIndex:Hn.UV,byteStride:8,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Yn.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))},r.prototype.createMaterial=function(e){var r,n;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(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nlayout(location = POSITION) in vec2 a_Position;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * vec4(a_Position, u_ZIndex, 1.0);\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};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\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\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * 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\n vec4 u_Color = u_FillColor;\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 outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}";var i=e[0],o=i.parsedStyle,a=o.fill,s=o.opacity,u=o.fillOpacity,l=o.anchor,c=o.visibility,f=[0,0,0,0];t.isCSSRGB(a)&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var d=i.isInteractive()&&(null===(n=i.renderable3D)||void 0===n?void 0:n.encodedPickingColor)||[0,0,0],_=0,h=0,R=i.getGeometryBounds();if(R){var T=R.halfExtents;_=-T[0]*l[0]*2,h=-T[1]*l[1]*2}var g=p();m(g,i.getWorldTransform(),E(g,v(_,h,0))),this.material.setUniforms(((r={})[mi.MODEL_MATRIX]=g,r[mi.FILL_COLOR]=f,r[mi.PICKING_COLOR]=d,r[mi.OPACITY]=s,r[mi.FILL_OPACITY]=u,r[mi.VISIBLE]="visible"===c?1:0,r[mi.Z_INDEX]=i.sortable.renderOrder*Bn,r))},r.prototype.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r,n,s,u,l,c,f,d=e.parsedStyle,_=d.fill,h=d.opacity,R=d.fillOpacity,T=d.anchor,g=d.visibility;if("lineJoin"===i||"lineCap"===i||"markerStart"===i||"markerEnd"===i||"markerStartOffset"===i||"markerEndOffset"===i||e.nodeName===t.Shape.RECT&&("width"===i||"height"===i||"radius"===i)||e.nodeName===t.Shape.LINE&&("x1"===i||"y1"===i||"x2"===i||"y2"===i)||e.nodeName===t.Shape.POLYLINE&&"points"===i||e.nodeName===t.Shape.POLYGON&&"points"===i||e.nodeName===t.Shape.PATH&&"path"===i)a.material.geometryDirty=!0,a.material.programDirty=!0;else if("fill"===i)if(t.isCSSRGB(_)){a.material.setUniforms(((r={})[mi.FILL_COLOR]=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)],r))}else{var y=a.textureMappings.findIndex((function(e){return e.name===zn})),A=a.createFillGradientTextureMapping([a.instance]);0>y||a.textureMappings.splice(y,1,A),a.material.textureDirty=!0}else if("opacity"===i)a.material.setUniforms(((n={})[mi.OPACITY]=h,n));else if("fillOpacity"===i)a.material.setUniforms(((s={})[mi.FILL_OPACITY]=R,s));else if("anchor"===i||"modelMatrix"===i){var S=0,C=0,O=e.getGeometryBounds();if(O){var I=O.halfExtents;S=-I[0]*T[0]*2,C=-I[1]*T[1]*2}var P=p();m(P,e.getWorldTransform(),E(P,v(S,C,0))),a.material.setUniforms(((u={})[mi.MODEL_MATRIX]=P,u))}else if("visibility"===i)a.material.setUniforms(((l={})[mi.VISIBLE]="visible"===g?1:0,l));else if("pointerEvents"===i){var N=o&&e.isInteractive()&&(null===(f=e.renderable3D)||void 0===f?void 0:f.encodedPickingColor)||[0,0,0];a.material.setUniforms(((c={})[mi.PICKING_COLOR]=N,c))}}))},r.prototype.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[mi.Z_INDEX]=t*Bn,r))},r}(Zn),Oi=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.img===t.parsedStyle.img},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=i({},this.material.defines),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\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\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\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n bool isBillboard = a_Size.w > 0.5;\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n } else {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\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\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}";var r=this.texturePool.getOrCreateTexture(this.context.device,t);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[],i=[];t.forEach((function(e,t){var o=4*t,a=e.parsedStyle;r.push(a.width,a.height,a.z,a.isBillboard?1:0),n.push(0,0,1,0,1,1,0,1),i.push(0+o,2+o,1+o,0+o,3+o,2+o)})),this.geometry.setIndexBuffer(new Uint32Array(i)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Hn.POSITION,byteStride:16,frequency:Ae.PerInstance,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Hn.UV,byteStride:8,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Yn.UV}],data:new Float32Array(n)})},t.prototype.updateAttribute=function(t,r,n,i){if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"width"===n||"height"===n||"z"===n||"isBillboard"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height,t.z,t.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Hn.POSITION,Yn.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:a})}},t}(Zn);function Ii(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function Pi(e,t,r,n,i,o){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 a=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*o,c=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[l+f];return t}var Ni=function(){function e(e,t){Ii(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Ii({},{width:n,height:i},r);Pi(e,o,{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=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){Pi(e,t,r,n,i,1)},e}();var Mi=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=u(e),l=s.next();!l.done;l=s.next())o+=(h=l.value).w*h.h,a=Math.max(a,h.w)}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,p=0;try{for(var d=u(e),_=d.next();!_.done;_=d.next())for(var h=_.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=h.w&&R.h>=h.h){if(h.x=R.x,h.y=R.y,p=Math.max(p,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===R.w&&h.h===R.h){var m=c.pop();c.length>E&&(c[E]=m)}else h.h===R.h?(R.x+=h.w,R.w-=h.w):h.w===R.w?(R.y+=h.h,R.h-=h.h):(c.push({x:R.x+h.w,y:R.y,w:R.w-h.w,h:h.h}),R.y+=h.h,R.h-=h.h);break}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}return{w:f,h:p,fill:o/(f*p)||0}}(r),l=new Ni({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&Ni.copy(c.bitmap,l,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=l,this.positions=t};var xi,Di,Bi,Li=function(){function e(){this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,u=[],l=o,c=a,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),o=r&&r[n];o&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=o.metrics.advance+i)}));for(var o=l-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;l=0,c+=r})),u},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var u=this;void 0===t&&(t=""),void 0===o&&(o="");var l=[];this.glyphMap[t]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)})),l.length){var f=l.map((function(i){return u.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new Mi(this.glyphMap);var p=this.glyphAtlas.image,d=p.width,_=p.height,h=p.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},We(Fe.ALPHA,d,_,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([h],0)}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new di({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var u=s.draw(o),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,p=u.glyphTop,d=u.glyphAdvance;return{id:a,bitmap:new Ni({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:p-24+3,advance:d}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(xi||(xi={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(Di||(Di={})),function(e){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"}(Bi||(Bi={}));var bi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.glyphManager=new Li,t.packedBufferObjectMap=new WeakMap,t.tmpMat4=p(),t}return n(r,e),r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.instance;return n.parsedStyle.metrics.font===t.parsedStyle.metrics.font&&!["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(e){return n.parsedStyle[e]!==t.parsedStyle[e]}))},r.prototype.createGeometry=function(e){var t=this,r=this.instance.parsedStyle,n=r.textBaseline,i=r.letterSpacing,o=24/r.fontSize,a=[],s=[],u=[],f=0;e.forEach((function(e){var r=e.parsedStyle,p=r.metrics,d=p.font,_=p.lines,h=p.height,E=p.lineHeight,R=r.dx||0,m=r.dy||0,v=0;"middle"===n?v=-h/2:"bottom"===n?v=-h:"top"===n||"hanging"===n?v=0:"alphabetic"===n?v=.25*E-h:"ideographic"===n&&(v=-h);var T=t.glyphManager.getAtlas(),g=t.buildTextBuffers({object:e,lines:_,fontStack:d,lineHeight:o*E,offsetX:o*R,offsetY:o*(v+m),letterSpacing:o*i,glyphAtlas:T,indicesOffset:f}),y=g.indexBuffer,A=g.charUVOffsetBuffer;f=g.indicesOffset;var S=u.length;u.push.apply(u,c([],l(g.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[S,u.length]),s.push.apply(s,c([],l(A),!1)),a.push.apply(a,c([],l(y),!1))})),this.geometry.vertexCount=a.length,this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.setVertexBuffer({bufferIndex:xi.INSTANCED,byteStride:128,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RGBA,bufferByteOffset:0,location:Yn.MODEL_MATRIX0},{format:Fe.F32_RGBA,bufferByteOffset:16,location:Yn.MODEL_MATRIX1},{format:Fe.F32_RGBA,bufferByteOffset:32,location:Yn.MODEL_MATRIX2},{format:Fe.F32_RGBA,bufferByteOffset:48,location:Yn.MODEL_MATRIX3},{format:Fe.F32_RGBA,bufferByteOffset:64,location:Yn.PACKED_COLOR},{format:Fe.F32_RGBA,bufferByteOffset:80,location:Yn.PACKED_STYLE1},{format:Fe.F32_RGBA,bufferByteOffset:96,location:Yn.PACKED_STYLE2},{format:Fe.F32_RGBA,bufferByteOffset:112,location:Yn.PICKING_COLOR}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:xi.TEX,byteStride:16,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:Di.TEX},{format:Fe.F32_RG,bufferByteOffset:8,location:Di.OFFSET}],data:new Float32Array(s)})},r.prototype.createMaterial=function(e){var t;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\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\nout float v_GammaScale;\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[ 2 ][ 3 ] == - 1.0;\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\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n float sizeAttenuation = a_StylePacked2.z;\n vec2 offset = a_Offset * fontScale;\n\n if (isBillboard) {\n vec4 mvPosition = u_ViewMatrix * u_ModelMatrix * vec4(0.0, 0.0, u_ZIndex, 1.0);\nvec2 scale;\nscale.x = length(vec3(u_ModelMatrix[0][0], u_ModelMatrix[0][1], u_ModelMatrix[0][2]));\nscale.y = length(vec3(u_ModelMatrix[1][0], u_ModelMatrix[1][1], u_ModelMatrix[1][2]));\n\n// if (sizeAttenuation < 0.5) {\n// bool isPerspective = isPerspectiveMatrix( u_ProjectionMatrix );\n// if ( isPerspective ) scale *= - mvPosition.z;\n// }\n\nvec2 alignedPosition = offset * scale;\n\nfloat rotation = 0.0;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\nmvPosition.xy += rotatedPosition;\n\ngl_Position = u_ProjectionMatrix * mvPosition;\n v_GammaScale = 1.0;\n } else {\n gl_Position = project(vec4(a_Offset * fontScale, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n v_GammaScale = gl_Position.w;\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\nin float v_GammaScale;\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\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float EDGE_GAMMA = 0.105 / u_DevicePixelRatio;\n float fontScale = u_FontSize / 24.0;\n highp float gamma = EDGE_GAMMA / (fontScale * u_GammaScale);\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 gamma = (u_StrokeBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_GammaScale);\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = gamma * v_GammaScale;\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 < 0.001) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=_e.Back,this.material.defines=i(i({},this.material.defines),kn(Di));var r=this.instance.parsedStyle,n=r.fontSize,o=r.fontFamily,a=void 0===o?"":o,s=r.fontWeight,u=void 0===s?"":s,l=r.fontStyle,c=r.metrics.font,f=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,c,a,""+u,l,f,this.context.device);var p=this.glyphManager.getAtlasTexture(),d=this.glyphManager.getAtlas();this.context.device.setResourceName(p,"TextSDF Texture");var _=d.image,h=_.width,E=_.height;this.material.setUniforms(((t={})[Bi.SDF_MAP]=p,t[Bi.SDF_MAP_SIZE]=[h,E],t[Bi.FONT_SIZE]=n,t[Bi.GAMMA_SCALE]=1,t[Bi.STROKE_BLUR]=.2,t[Bi.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[xi.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[xi.INSTANCED].byteStride/4,i=l(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),u=0;a-o>u;u+=n)s[u+n-1]=t*Bn;this.geometry.updateVertexBuffer(xi.INSTANCED,Yn.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(e,r,n,i){var o=this;if("text"===n||"fontFamily"===n||"fontSize"===n||"fontWeight"===n||"fontStyle"===n||"fontVariant"===n||"textBaseline"===n||"letterSpacing"===n||"wordWrapWidth"===n||"lineHeight"===n||"wordWrap"===n||"textAlign"===n||"visibility"===n||"dx"===n||"dy"===n)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===n||"fill"===n||"fillOpacity"===n||"stroke"===n||"strokeOpacity"===n||"opacity"===n||"lineWidth"===n||"pointerEvents"===n){var a=this.geometry.vertices[xi.INSTANCED],s=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[xi.INSTANCED].byteStride/4;e.forEach((function(e){var r,i=e.parsedStyle,u=i.fill,c=i.stroke,f=i.opacity,p=i.fillOpacity,_=i.strokeOpacity,h=i.lineWidth,E=i.visibility,R=i.isBillboard,m=i.sizeAttenuation,v=[0,0,0,0];t.isCSSRGB(u)&&(v=[Number(u.r),Number(u.g),Number(u.b),255*Number(u.alpha)]);var T=[0,0,0,0];t.isCSSRGB(c)&&(T=[Number(c.r),Number(c.g),Number(c.b),255*Number(c.alpha)]);for(var g=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],y="modelMatrix"===n?d(o.tmpMat4,e.getWorldTransform()):null,A=l(o.packedBufferObjectMap.get(e),2),S=A[0],C=A[1],O=a.slice(S,C),I=0;C-S>I;I+=s)"modelMatrix"===n?(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]):"fill"===n?(O[I+16]=Xn(v[0],v[1]),O[I+17]=Xn(v[2],v[3])):"stroke"===n&&(O[I+18]=Xn(T[0],T[1]),O[I+19]=Xn(T[2],T[3])),O[I+20]=f,O[I+21]=p,O[I+22]=_,O[I+23]=h,O[I+24]="visible"===E?1:0,O[I+25]=R?1:0,O[I+26]=m?1:0,O[I+27]=0,O[I+28]=g[0],O[I+29]=g[1],O[I+30]=g[2];o.geometry.updateVertexBuffer(xi.INSTANCED,Yn.MODEL_MATRIX0,S/s,new Uint8Array(O.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,f=e.offsetY,p=e.glyphAtlas,_=e.indicesOffset,h=n.parsedStyle,E=h.textAlign,R=h.fill,m=h.stroke,v=h.opacity,T=h.fillOpacity,g=h.strokeOpacity,y=h.lineWidth,A=h.visibility,S=h.isBillboard,C=h.sizeAttenuation,O=[0,0,0,0];t.isCSSRGB(R)&&(O=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var I=[0,0,0,0];t.isCSSRGB(m)&&(I=[Number(m.r),Number(m.g),Number(m.b),255*Number(m.alpha)]);var P=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],N=d(this.tmpMat4,n.getWorldTransform()),M=[],x=[],D=[],B=_,L=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var u=a.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(a.metrics.left-4)*i.scale-u+l[0],f=(-a.metrics.top-4)*i.scale+l[1],p=c+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:p,y:f},bl:{x:c,y:d},br:{x:p,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,u,f),p.positions);return L.forEach((function(e){var t=[];t.push.apply(t,c([],l(N),!1));var r=c(c(c(c([],l(t),!1),[Xn(O[0],O[1]),Xn(O[2],O[3]),Xn(I[0],I[1]),Xn(I[2],I[3]),v,T,g,y,"visible"===A?1:0,S?1:0,C?1:0,0],!1),l(P),!1),[n.sortable.renderOrder*Bn],!1);M.push.apply(M,c(c(c(c([],l(r),!1),l(r),!1),l(r),!1),l(r),!1)),x.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),x.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),x.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),x.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),D.push(0+B,2+B,1+B),D.push(2+B,0+B,3+B),B+=4})),{indexBuffer:D,charUVOffsetBuffer:x,charPackedBuffer:M,indicesOffset:B}},r}(Zn),Fi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.lightReceived=!0,t}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Zn),Ui=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ei,gi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&o>0&&(1>a||l)},t}(Ln),Gi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[Ci,gi,ni,Si],t}return n(r,e),r.prototype.shouldSubmitRenderInst=function(e,r){var n=e.parsedStyle,i=n.fill,o=n.stroke,a=n.opacity,s=n.strokeOpacity,u=n.lineDash,l=n.lineWidth,c=e.nodeName,f=o&&!o.isNone,p=u&&u.length&&u.every((function(e){return 0!==e})),d=ni.isLine(e),_=Si.isOneCommandCurve(e);if(e.renderable.proxyNodeName=d?t.Shape.LINE:null,0===r&&(_||e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(d||_||0===s||0===a||0===l||!f)return!1;if(c===t.Shape.CIRCLE||c===t.Shape.ELLIPSE)return p}return 2===r?d:3!==r||_},r}(Ln);!function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[],t}n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0}}(Ln);var wi,ki,Vi,Wi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[Oi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Ln),Xi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[bi,bi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle,n=r.stroke;return!((!n||n.isNone||!r.lineWidth)&&0===t)},t.prototype.beforeUploadUBO=function(e,t,r){var n;t.material.setUniforms(((n={})[Bi.HAS_STROKE]=1-t.index,n))},t}(Ln),Hi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ni],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Ln),Yi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[Fi],t}return n(t,e),t}(Ln),Ki=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[ei,Ci,gi],t}return n(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle.radius,n=r&&r.length&&r.some((function(e){return e!==r[0]}));if(0===t&&(e.parsedStyle.fill.isNone||n))return!1;return 1===t?n:2!==t||(n||this.needDrawStrokeSeparately(e))},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&o>0&&(1>a||l)},t}(Ln),zi=1,ji=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(r.context);var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.meshes.length){var n=this.rendererFactory[e.nodeName];n&&n.meshes.forEach((function(i,o){if(r.meshes[o]=void 0,n.shouldSubmitRenderInst(e,o)){var a=t.meshes.find((function(t){return i===t.constructor&&t.index===o&&t.shouldMerge(e,o)}));a&&a.key===e.parsedStyle.batchKey||((a=new i(t.renderHelper,t.texturePool,t.lightPool)).renderer=n,a.index=o,t.meshes.push(a),e.parsedStyle.batchKey&&(a.key=e.parsedStyle.batchKey)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.meshes.forEach((function(r){if(r){var n=r.objects.indexOf(e);n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length&&t.meshes.splice(t.meshes.indexOf(r),1)}})),r.meshes=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];a&&a.meshes.forEach((function(s,u){var l=a.shouldSubmitRenderInst(e,u),c=o.meshes.find((function(e){return e&&e.index===u&&e.constructor===s}));if(l!==!!c&&(c&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.meshes.splice(i.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=i.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))?c.geometryDirty=!0:((c=new s(i.renderHelper,i.texturePool,i.lightPool)).renderer=a,c.index=u,c.init(i.context),i.meshes.push(c)),c&&(c.objects.push(e),o.meshes[u]=c))),l&&c&&c.inited&&!c.geometryDirty){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var p=c.id+t;i.pendingUpdatePatches[p]||(i.pendingUpdatePatches[p]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[p].objectIndices.indexOf(f)&&i.pendingUpdatePatches[p].objectIndices.push(f)}}}))},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.meshes.length&&r.meshes.forEach((function(r){r&&r.inited&&!r.geometryDirty&&(r.renderer.shouldSubmitRenderInst(e,r.index)&&r.inited&&r.changeRenderOrder(e,t))}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=zi++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=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],o,a)}))})),this.pendingUpdatePatches={}},e}(),qi=function(){function e(e){this.context=e,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,u="string"==typeof r?r:r.src||"";if(u&&this.textureCache[u])(a=this.textureCache[u]).emit(Se.LOADED);else if(a=e.createTexture(i({pixelFormat:Fe.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:Ce.n2D,usage:Oe.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),u&&(this.textureCache[u]=a),C(r)){var l,c=this.context.config.createImage;c?l=c(r):t.isBrowser&&(l=new window.Image),l&&(l.onload=function(){var e=function(e){s.textureCache[u].setImageData(e),s.textureCache[u].emit(Se.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[u])};t.runtime.globalThis.createImageBitmap?t.runtime.globalThis.createImageBitmap(l).then((function(t){return e(t)})).catch((function(){e(l)})):e(l)},l.onerror=function(){},l.crossOrigin="Anonymous",l.src=r)}else a.setImageData(r),a.emit(Se.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return t.runtime.offscreenCanvas.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,o=2*n[0]||1,a=2*n[1]||1,s=this.context.config.offscreenCanvas,u=t.runtime.offscreenCanvas.getOrCreateCanvas(s),l=t.runtime.offscreenCanvas.getOrCreateContext(s);u.width=o,u.height=a;var c=this.context.imagePool;r.forEach((function(e){var t=c.getOrCreateGradient(i(i({type:e.type},e.value),{width:o,height:a}),l);l.fillStyle=t,l.fillRect(0,0,o,a)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,p=t.runtime.offscreenCanvas.getOrCreateCanvas(f),d=t.runtime.offscreenCanvas.getOrCreateContext(f);p.width=l,p.height=c;var _=(i=C(o)?this.context.imagePool.getImageSync(o,n):o)&&d.createPattern(i,a);if(s){var h=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));_.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12],f:h[13]})}d.fillStyle=_,d.fillRect(0,0,l,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),Zi="#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}",Qi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.vert=Zi,t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord);\n}",t.features={},t}return n(t,e),t}(Or),Ji=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert=Zi,t.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}",t}return n(t,e),t}(Or),$i=Rt(1,(function(){return new Cn}));var eo=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="device-renderer",t.parameters={toneMapping:kr.NONE,toneMappingExposure:1},t}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new ke;var n=new hn(this.parameters),i=new Ge,o=new qi(this.context),a=new Ve,s=new Ui,u=new Gi,l=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=u,r[t.Shape.PATH]=u,r[t.Shape.POLYGON]=u,r[t.Shape.RECT]=new Ki,r[t.Shape.IMAGE]=new Wi,r[t.Shape.LINE]=new Hi,r[t.Shape.TEXT]=new Xi,r[t.Shape.MESH]=new Yi,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new ji(n,l,o,i),f=new xn(n,i,o,c);this.addRenderingPlugin(f),this.addRenderingPlugin(new Dn(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),to=Object.freeze({__proto__:null,get AntialiasingMode(){return mn},Batch:Ln,get BlendFactor(){return he},get BlendMode(){return Ee},get BufferFrequencyHint(){return ye},BufferGeometry:Un,get BufferUsage(){return ge},get ChannelWriteMask(){return Ie},get ClipSpaceNearZ(){return xe},get CompareMode(){return pe},CopyProgram:Qi,get CullMode(){return _e},DeviceProgram:Or,DynamicUniformBuffer:Ir,get Endianness(){return Mt},FILL_TEXTURE_MAPPING:zn,FillMesh:Ci,Fog:Nn,get FogType(){return Sn},get Format(){return Fe},get FormatCompFlags(){return Le},get FormatFlags(){return be},get FormatTypeFlags(){return Be},get FrontFaceMode(){return de},get GL(){return ce},get GeometryEvent(){return Mn},HashMap:Dr,ImageMesh:Oi,Instanced:Zn,InstancedLineMesh:ni,InstancedPathMesh:Si,IsDepthReversed:st,get JOINT_TYPE(){return fi},Light:In,LineMesh:gi,Material:Gn,get MaterialEvent(){return Fn},Mesh:we,MeshMesh:Fi,get MipFilterMode(){return ve},OpaqueBlack:it,OpaqueWhite:at,Plugin:eo,get PrimitiveTopology(){return Te},get QueryPoolType(){return De},get RGAttachmentSlot(){return Vr},RenderCache:Wr,RenderGraphPlugin:xn,RenderHelper:hn,RenderInst:cn,get RenderInstExecutionOrder(){return ln},get RenderInstFlags(){return an},RenderInstList:pn,RenderInstManager:_n,Renderable3D:Ue,get RendererLayer(){return Xr},get ResourceType(){return fe},SDFMesh:ei,get SamplerFormatKind(){return Ne},ShaderMaterial:wn,SingleSampledTexture:Kr,get StencilOp(){return Pe},TemporalTexture:On,get TexFilterMode(){return me},TextMesh:bi,get TextUniform(){return Bi},get TextureDimension(){return Ce},get TextureEvent(){return Se},TextureMapping:Cn,TexturePool:qi,get TextureUsage(){return Oe},TinySDF:di,get ToneMapping(){return kr},TransparentBlack:nt,TransparentWhite:ot,UNIFORM_SETTERS:vr,get Uniform(){return mi},get VertexAttributeBufferIndex(){return Hn},get VertexAttributeLocation(){return Yn},get VertexBufferFrequency(){return Ae},get ViewportOrigin(){return Me},get WrapMode(){return Re},align:pt,alignNonPowerOfTwo:dt,arrayCopy:Bt,arrayEqual:Dt,assert:Qe,assertExists:Je,bezierCurveTo:ci,bindingLayoutDescriptorCopy:Jt,bindingLayoutDescriptorEqual:Ut,bindingLayoutSamplerDescriptorCopy:Qt,bindingsDescriptorCopy:Zt,bindingsDescriptorEquals:Gt,bisectRight:_t,bufferBindingCopy:qt,colorCopy:et,colorEqual:$e,colorNewCopy:tt,colorNewFromRGBA:rt,compareDefines:Vn,compareDepthValues:function(e,t,r,n){if(void 0===n&&(n=st),(r=ut(r,n))===pe.Less)return t>e;if(r===pe.LessEqual)return t>=e;if(r===pe.Greater)return e>t;if(r===pe.GreaterEqual)return e>=t;throw Error("whoops")},copyAttachmentState:Tt,copyAttachmentStateFromSimple:St,copyMegaState:At,defaultBindingLayoutSamplerDescriptor:xt,defaultMegaState:Ot,definedProps:Wn,enumToObject:kn,fallbackUndefined:lt,fillArray:ft,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),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,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:un,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},fullscreenMegaState:Pt,getAttributeLocations: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 o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r},getDefines: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},getFormatByteSize:function(e){return je(Ke(e))*Ye(e)},getFormatCompByteSize:qe,getFormatCompFlags:Ye,getFormatCompFlagsComponentCount:Xe,getFormatComponentCount:function(e){return Ye(e)},getFormatFlags:ze,getFormatSamplerKind:Ze,getFormatTypeFlags:Ke,getFormatTypeFlagsByteSize:je,getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},getSystemEndianness:function(){return or},getUniformSetter:function(e,t,r){var n=vr[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)},getUniforms:yr,hashCodeNumberFinish:Nr,hashCodeNumberUpdate:Pr,inputLayoutBufferDescriptorCopy:tr,inputLayoutBufferDescriptorEquals:Yt,inputLayoutDescriptorCopy:rr,inputLayoutDescriptorEquals:Kt,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:mt,makeAttachmentClearDescriptor:Rn,makeBackbufferDescSimple:An,makeDataBuffer:bn,makeDepthKey:Qr,makeFormat:He,makeMegaState:It,makeSortKey:function(e,t){return void 0===t&&(t=0),e&Xr.TRANSLUCENT?rn(e):en(e,t)},makeSortKeyOpaque:en,makeSortKeyTranslucent:rn,makeTextureDescriptor2D:We,nArray:Rt,nullHashFunc:Mr,nullify:ct,opaqueBlackFullClearRenderPassDescriptor:Tn,opaqueWhiteFullClearRenderPassDescriptor:gn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(ar);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]}},prependLineNo:function(e,t){return void 0===t&&(t=1),e.split("\n").map((function(e,r){return"".concat(mt(""+(t+r),4," ")," ").concat(e)})).join("\n")},preprocessProgramObj_GLSL:Cr,preprocessProgram_GLSL:Sr,preprocessShader_GLSL:Ar,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===xe.NegativeOne?function(e){m(e,on,e)}(e):t===xe.Zero&&function(e){m(e,sn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Vr.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Pt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);un(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Ji,l=t.renderCache.createProgram(u);a.setProgram(l),wi||((wi=new Un(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:Ae.PerVertex,attributes:[{format:Fe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-1,-3,-1,1,3,-1])}),wi.vertexCount=3,Vi=t.getCache().createInputLayout(wi.inputLayoutDescriptor),ki=t.getDevice().createInputState(Vi,wi.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){$i[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings($i),a.setInputLayoutAndState(Vi,ki),a.drawOnPass(t.renderCache,e)}))}))},quadCurveTo:li,range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:fn,renderPipelineDescriptorCopy:$t,renderPipelineDescriptorEquals:Xt,reverseDepthForClearValue:function(e,t){return void 0===t&&(t=st),t?1-e:e},reverseDepthForCompareMode:ut,reverseDepthForDepthOffset:function(e,t){return void 0===t&&(t=st),t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e,t){void 0===t&&(t=st),t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e,t){void 0===t&&(t=st),t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:jt,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:zt,segmentInstanceGeometry:ti,setAttachmentStateSimple:Nt,setBackbufferDescSimple:yn,setBitFlagEnabled:Et,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:yt,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=qr);var n=!!(e>>>31&1),i=Qr(t,n,r);return n?nn(e,i):tn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?nn(e,t):tn(e,t)},setSortKeyLayer:Jr,setSortKeyOpaqueDepth:tn,setSortKeyProgramKey:$r,setSortKeyTranslucentDepth:nn,spliceBisectRight:ht,standardFullClearRenderPassDescriptor:vn,updateBuffer:yi,vertexAttributeDescriptorCopy:er,vertexAttributeDescriptorEquals:Ht}),ro=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.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)},p=function(e){i.hooks.pointerOut.call(e)},d=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},h=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",p,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",l,!0),r.globalThis.addEventListener("pointercancel",d,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",u,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",p,!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",d,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",h,!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",p,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",l,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",u,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",p,!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",d,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",h,!0),e.removeEventListener("wheel",_,!0)}))},e.tag="DOMInteraction",e}(),no=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new ro)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),io=Object.freeze({__proto__:null,Plugin:no}),oo=function(){function e(){}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(r){var n=this,i=r.camera,o=r.renderingContext,a=r.renderingService;this.context=r;var s=o.root.ownerDocument.defaultView,u=function(e,t){t.style.transform=n.joinTransformMatrix(e.getWorldTransform())},l=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){n.$camera||(n.$camera=n.createCamera(i));var o=n.getOrCreateEl(r);n.$camera.appendChild(o);var a=r.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(e){o.style[e]=a[e]})),Object.keys(r.attributes).forEach((function(e){n.updateAttribute(e,r)})),u(r,o),t.runtime.nativeHTMLMap.set(o,r)}},c=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&n.$camera){var i=n.getOrCreateEl(r);i&&(i.remove(),t.runtime.nativeHTMLMap.delete(i))}},f=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&n.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var i=n.getOrCreateEl(r);u(r,i)}},d=function(){if(n.$camera){var e=n.context.config,t=e.height;n.$camera.style.width="".concat(e.width||0,"px"),n.$camera.style.height="".concat(t||0,"px")}};a.hooks.init.tap(e.tag,(function(){s.addEventListener(t.CanvasEvent.RESIZE,d),s.addEventListener(t.ElementEvent.MOUNTED,l),s.addEventListener(t.ElementEvent.UNMOUNTED,c),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),a.hooks.endFrame.tap(e.tag,(function(){n.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(n.$camera.style.transform=n.joinTransformMatrix(i.getOrthoMatrix()))})),a.hooks.destroy.tap(e.tag,(function(){n.$camera&&n.$camera.remove(),s.removeEventListener(t.CanvasEvent.RESIZE,d),s.removeEventListener(t.ElementEvent.MOUNTED,l),s.removeEventListener(t.ElementEvent.UNMOUNTED,c),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))},e.prototype.getId=function(e){return e.id||"g-html-"+e.entity},e.prototype.createCamera=function(e){var t,r=(t=this.context.config).document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",u=a.querySelector("#"+s);if(!u){var l=(r||document).createElement("div");u=l,l.id=s,l.style.position="absolute",l.style.left="".concat(o.offsetLeft||0,"px"),l.style.top="".concat(o.offsetTop||0,"px"),l.style.transformOrigin="left top",l.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),l.style.overflow="hidden",l.style.pointerEvents="none",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px"),a.appendChild(l)}return u}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.getId(e),n=this.$camera.querySelector("#"+r);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,n.id=r,e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform())),n},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;C(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);break;case"width":if(t.runtime.enableCSSParsing){var a=r.computedStyleMap().get("width");n.style.width=""+a}else{n.style.width=I(a=r.parsedStyle.width)?"".concat(a,"px"):""+a}break;case"height":if(t.runtime.enableCSSParsing){var s=r.computedStyleMap().get("height");n.style.height=""+s}else{n.style.height=I(s=r.parsedStyle.height)?"".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":n.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var u=r.parsedStyle.fill,l="";t.isCSSRGB(u)?l=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?l=r.getAttribute("fill"):t.isPattern(u),n.style.background=l;break;case"stroke":var c=r.parsedStyle.stroke,f="";t.isCSSRGB(c)?f=c.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(c)?f=r.getAttribute("stroke"):t.isPattern(c),n.style["border-color"]=f,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}},e.tag="HTMLRendering",e}(),ao=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new oo)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),so=Object.freeze({__proto__:null,Plugin:ao}),uo=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t():this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o){var a=this.generatePatternKey(e);if(a&&this.patternCache[a])return this.patternCache[a];var s,u=e.image,l=e.repetition,c=e.transform,f=!1;C(u)?s=this.getImageSync(u,o):n?(s=n,f=!0):s=u;var d=s&&r.createPattern(s,l);if(d){var _=void 0;_=c?t.parsedTransformToMat4(t.parseTransform(c),new t.DisplayObject({})):h(p()),f&&function(e,t,r){var n=r[0],i=r[1],o=r[2];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]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(_,_,[1/i,1/i,1]),d.setTransform({a:_[0],b:_[1],c:_[4],d:_[5],e:_[12],f:_[13]})}return a&&d&&(this.patternCache[a]=d),d},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,u=e.cx,l=e.cy,c=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var p=t.computeLinearGradient(a,s,e.angle);f=r.createLinearGradient(p.x1,p.y1,p.x2,p.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,s,u,l,c),_=d.x,h=d.y;f=r.createRadialGradient(_,h,0,_,h,d.r)}return f&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==f||f.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return C(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),lo=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e){var r=e.target;if(r.nodeName===t.Shape.IMAGE){var o=r.attributes.img;C(o)&&i.getImageSync(o,(function(){r.renderable.dirty=!0,n.dirtify()}))}},s=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"img"===e.attrName&&C(o)&&i.getOrCreateImage(o).then((function(){r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,a),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,s)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,a),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)}))},e.tag="LoadImage",e}(),co=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new uo(this.context.config),this.addRenderingPlugin(new lo)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin);let fo,po=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});po.decode();let _o=null;function ho(){return null!==_o&&_o.buffer===fo.memory.buffer||(_o=new Uint8Array(fo.memory.buffer)),_o}function Eo(e,t){return po.decode(ho().subarray(e,e+t))}const Ro=Array(32).fill(void 0);Ro.push(void 0,null,!0,!1);let mo=Ro.length;function vo(e){return Ro[e]}function To(e){const t=vo(e);return function(e){36>e||(Ro[e]=mo,mo=e)}(e),t}let go=0,yo=new TextEncoder("utf-8");const Ao="function"==typeof yo.encodeInto?function(e,t){return yo.encodeInto(e,t)}:function(e,t){const r=yo.encode(e);return t.set(r),{read:e.length,written:r.length}};function So(e,t,r){if(void 0===r){const r=yo.encode(e),n=t(r.length);return ho().subarray(n,n+r.length).set(r),go=r.length,n}let n=e.length,i=t(n);const o=ho();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length);const t=ho().subarray(i+a,i+n);a+=Ao(e,t).written}return go=a,i}let Co=null;function Oo(){return null!==Co&&Co.buffer===fo.memory.buffer||(Co=new Int32Array(fo.memory.buffer)),Co}function Io(e,t,r){try{const u=fo.__wbindgen_add_to_stack_pointer(-16);var n=So(e,fo.__wbindgen_malloc,fo.__wbindgen_realloc),i=go,o=So(t,fo.__wbindgen_malloc,fo.__wbindgen_realloc);fo.glsl_compile(u,n,i,o,go,r);var a=Oo()[u/4+0],s=Oo()[u/4+1];return Eo(a,s)}finally{fo.__wbindgen_add_to_stack_pointer(16),fo.__wbindgen_free(a,s)}}async function Po(e){const t={wbg:{}};t.wbg.__wbindgen_string_new=function(e,t){return function(e){mo===Ro.length&&Ro.push(Ro.length+1);const t=mo;return mo=Ro[t],Ro[t]=e,t}(Eo(e,t))},t.wbg.__wbindgen_object_drop_ref=function(e){To(e)},t.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(vo(e))},t.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(vo(e),vo(t))},t.wbg.__wbindgen_throw=function(e,t){throw Error(Eo(e,t))},("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 fo=r.exports,Po.__wbindgen_wasm_module=n,fo}var No,Mo;function xo(e){if(e===Fe.U8_R_NORM)return"r8unorm";if(e===Fe.U8_RG_NORM)return"rg8unorm";if(e===Fe.U8_RGBA_RT)return"bgra8unorm";if(e===Fe.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===Fe.U8_RGBA_NORM)return"rgba8unorm";if(e===Fe.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===Fe.S8_R_NORM)return"r8snorm";if(e===Fe.S8_RG_NORM)return"rg8snorm";if(e===Fe.S8_RGBA_NORM)return"rgba8snorm";if(e===Fe.U32_R)return"r32uint";if(e===Fe.F16_RGBA)return"rgba16float";if(e===Fe.F32_RGBA)return"rgba32float";if(e===Fe.D24)return"depth24plus";if(e===Fe.D24_S8)return"depth24plus-stencil8";if(e===Fe.D32F)return"depth32float";if(e===Fe.D32F_S8)return"depth32float-stencil8";if(e===Fe.BC1)return"bc1-rgba-unorm";if(e===Fe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Fe.BC2)return"bc2-rgba-unorm";if(e===Fe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Fe.BC3)return"bc3-rgba-unorm";if(e===Fe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Fe.BC4_SNORM)return"bc4-r-snorm";if(e===Fe.BC4_UNORM)return"bc4-r-unorm";if(e===Fe.BC5_SNORM)return"bc5-rg-snorm";if(e===Fe.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function Do(e){if(e===Re.Clamp)return"clamp-to-edge";if(e===Re.Repeat)return"repeat";if(e===Re.Mirror)return"mirror-repeat";throw Error("whoops")}function Bo(e){if(e===me.Bilinear)return"linear";if(e===me.Point)return"nearest";throw Error("whoops")}function Lo(e){if(e===ve.Linear)return"linear";if(e===ve.Nearest)return"nearest";if(e===ve.NoMip)return"nearest";throw Error("whoops")}function bo(e){if(e===Ne.Float)return"float";if(e===Ne.Depth)return"depth";throw Error("whoops")}function Fo(e){return e.formatKind===Ne.Depth&&e.comparison?{type:"comparison"}:e.formatKind===Ne.Float?{type:"filtering"}:{type:"non-filtering"}}function Uo(e){if(e===Ce.n2D)return"2d";if(e===Ce.n2DArray)return"2d-array";if(e===Ce.n3D)return"3d";if(e===Ce.Cube)return"cube";throw Error("whoops")}function Go(e){return e.gpuBuffer}function wo(e){if(e===De.OcclusionConservative)return"occlusion";throw Error("whoops")}function ko(e){switch(e){case Te.Triangles:return"triangle-list";case Te.Points:return"point-list";case Te.TriangleStrip:return"triangle-strip";case Te.Lines:return"line-list";case Te.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function Vo(e){if(e===_e.None)return"none";if(e===_e.Front)return"front";if(e===_e.Back)return"back";throw Error("whoops")}function Wo(e){if(e===de.CCW)return"ccw";if(e===de.CW)return"cw";throw Error("whoops")}function Xo(e){if(e===he.Zero)return"zero";if(e===he.One)return"one";if(e===he.Src)return"src";if(e===he.OneMinusSrc)return"one-minus-src";if(e===he.Dst)return"dst";if(e===he.OneMinusDst)return"one-minus-dst";if(e===he.SrcAlpha)return"src-alpha";if(e===he.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===he.DstAlpha)return"dst-alpha";if(e===he.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function Ho(e){if(e===Ee.Add)return"add";if(e===Ee.Subtract)return"subtract";if(e===Ee.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function Yo(e){return{operation:Ho(e.blendMode),srcFactor:Xo(e.blendSrcFactor),dstFactor:Xo(e.blendDstFactor)}}function Ko(e){return e.blendMode===Ee.Add&&e.blendSrcFactor===he.One&&e.blendDstFactor===he.Zero}function zo(e){return Ko(e.rgbBlendState)&&Ko(e.alphaBlendState)?void 0:{color:Yo(e.rgbBlendState),alpha:Yo(e.alphaBlendState)}}function jo(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:xo(t),blend:zo(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function qo(e){if(e===pe.Never)return"never";if(e===pe.Less)return"less";if(e===pe.Equal)return"equal";if(e===pe.LessEqual)return"less-equal";if(e===pe.Greater)return"greater";if(e===pe.NotEqual)return"not-equal";if(e===pe.GreaterEqual)return"greater-equal";if(e===pe.Always)return"always";throw Error("whoops")}function Zo(e){if(e===Ae.PerVertex)return"vertex";if(e===Ae.PerInstance)return"instance";throw Error("whoops")}function Qo(e){if(e===Fe.U8_R)return"uint8x2";if(e===Fe.U8_RG)return"uint8x2";if(e===Fe.U8_RGB)return"uint8x4";if(e===Fe.U8_RGBA)return"uint8x4";if(e===Fe.U8_RG_NORM)return"unorm8x2";if(e===Fe.U8_RGBA_NORM)return"unorm8x4";if(e===Fe.S8_RGB_NORM)return"snorm8x4";if(e===Fe.S8_RGBA_NORM)return"snorm8x4";if(e===Fe.U16_RG_NORM)return"unorm16x2";if(e===Fe.U16_RGBA_NORM)return"unorm16x4";if(e===Fe.S16_RG_NORM)return"snorm16x2";if(e===Fe.S16_RGBA_NORM)return"snorm16x4";if(e===Fe.S16_RG)return"uint16x2";if(e===Fe.F16_RG)return"float16x2";if(e===Fe.F16_RGBA)return"float16x4";if(e===Fe.F32_R)return"float32";if(e===Fe.F32_RG)return"float32x2";if(e===Fe.F32_RGB)return"float32x3";if(e===Fe.F32_RGBA)return"float32x4";throw"whoops"}function Jo(e,t,r,n){switch(void 0===r&&(r=!1),e){case Fe.S8_R:case Fe.S8_R_NORM:case Fe.S8_RG_NORM:case Fe.S8_RGB_NORM:case Fe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case Fe.U8_R:case Fe.U8_R_NORM:case Fe.U8_RG:case Fe.U8_RG_NORM:case Fe.U8_RGB:case Fe.U8_RGB_NORM:case Fe.U8_RGB_SRGB:case Fe.U8_RGBA:case Fe.U8_RGBA_NORM:case Fe.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case Fe.S16_R:case Fe.S16_RG:case Fe.S16_RG_NORM:case Fe.S16_RGB_NORM:case Fe.S16_RGBA:case Fe.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case Fe.U16_R:case Fe.U16_RGB:case Fe.U16_RGBA_5551:case Fe.U16_RGBA_NORM:case Fe.U16_RG_NORM:case Fe.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 Fe.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 Fe.U32_R:case Fe.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 Fe.F32_R:case Fe.F32_RG:case Fe.F32_RGB:case Fe.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(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"}(No||(No={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Mo||(Mo={}));var $o=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 n(t,e),t.prototype.destroy=function(){},t}(N),ea=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.Bindings;var i=r.pipeline,o=r.bindingLayout;Qe(!!i);var a=n.device._createBindGroupLayout(o),s=[[],[]],u=0;if(o.storageEntries)for(var l=0;o.storageEntries.length>l;l++){Qe((f=r.storageBufferBindings[l]).wordCount>0);var c={buffer:Go(f.buffer),offset:0,size:f.wordCount<<2};s[0].push({binding:u++,resource:c})}for(l=0;o.numUniformBuffers>l;l++){Qe((f=r.uniformBufferBindings[l]).wordCount>0);c={buffer:Go(f.buffer),offset:0,size:f.wordCount<<2};s[0].push({binding:u++,resource:c})}u=0;for(l=0;o.numSamplers>l;l++){var f,p=void 0!==o.samplerEntries?o.samplerEntries[l]:xt,d=null!==(f=r.samplerBindings[l]).texture?f.texture:n.device.getFallbackTexture(p);Qe(p.dimension===d.dimension),Qe(p.formatKind===Ze(d.pixelFormat)),s[1].push({binding:u++,resource:d.gpuTextureView});var _=null!==f.sampler?f.sampler:n.device.getFallbackSampler(p),h=_.gpuSampler;s[1].push({binding:u++,resource:h})}return n.gpuBindGroup=s.filter((function(e){return e.length>0})).map((function(e,t){return n.device.device.createBindGroup({layout:i.getBindGroupLayout(t),entries:e})})),n.bindingLayout=r.bindingLayout,n.bindGroupLayout=a,n}return n(t,e),t}($o),ta=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&ge.MAP_READ);n.usage=function(e){var t=0;return e&ge.INDEX&&(t|=GPUBufferUsage.INDEX),e&ge.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&ge.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&ge.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&ge.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=ge.MAP_READ|ge.COPY_DST);var s=!I(o);(n.view=I(o)?null:o,n.size=I(o)?pt(o,4):pt(o.byteLength,4),I(o))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(o&&o.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap());return n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var u=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(u),r=0,o=0,a=s,n=s}for(var l=15728640,c=0;a-(o+c)>l;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,l),c+=l;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}($o),ra=function(){function e(){this.commandEncoder=null,this.gpuComputePassEncoder=null}return e.prototype.dispatch=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},e.prototype.beginComputePass=function(){Qe(null===this.gpuComputePassEncoder),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=Je(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e,t,r){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0],r)},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuComputePassEncoder.pushDebugGroup&&this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuComputePassEncoder.popDebugGroup&&this.gpuComputePassEncoder.popDebugGroup()},e}(),na=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}($o),ia=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.InputLayout;for(var i=[],o=0;r.vertexAttributeDescriptors.length>o;o++){var a=r.vertexAttributeDescriptors[o],s={shaderLocation:a.location,format:Qo(a.format),offset:a.bufferByteOffset};if(void 0!==i[a.bufferIndex])i[a.bufferIndex].attributes.push(s);else{var u=Je(r.vertexBufferDescriptors[a.bufferIndex]),l=u.byteStride,c=Zo(u.frequency);i[a.bufferIndex]={arrayStride:l,stepMode:c,attributes:[s]}}}return n.indexFormat=function(e){if(null!==e){if(e===Fe.U16_R)return"uint16";if(e===Fe.U32_R)return"uint32";throw Error("whoops")}}(r.indexBufferFormat),n.buffers=i,n}return n(t,e),t}($o),oa=function(e){function t(t){var r=t.inputLayout,n=t.vertexBuffers,i=t.indexBuffer,o=e.call(this,{id:t.id,device:t.device})||this;return o.type=fe.InputState,o.inputLayout=r,o.vertexBuffers=n,o.indexBuffer=i,o}return n(t,e),t}($o),aa=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=fe.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.preprocessedVert&&(n.vertexStage=n.createShaderStage(r.preprocessedVert,"vertex")),r.preprocessedFrag&&(n.fragmentStage=n.createShaderStage(r.preprocessedFrag,"fragment")),r.preprocessedCompute&&(n.computeStage=n.createShaderStage(r.preprocessedCompute,"compute")),n}return n(t,e),t.prototype.createShaderStage=function(e,t){var r,n,i=e;if("compute"!==t)try{i=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),Error("whoops")}var o=function(e){if(!i.includes(e))return"continue";i=(i=i.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 a=u(["u_TextureFramebufferDepth"]),s=a.next();!s.done;s=a.next()){o(s.value)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return{module:this.device.device.createShaderModule({code:i}),entryPoint:"main"}},t}($o),sa=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=fe.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:wo(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 n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}($o),ua=function(e){function r(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=fe.Readback,r}return n(r,e),r.prototype.readTexture=function(e,t,r,n,i,o,u,l){return void 0===u&&(u=0),a(this,void 0,void 0,(function(){var a,l,c,f,p,d;return s(this,(function(s){return 0,l=this.getBlockInformationFromFormat((a=e).format),p=this.device.createBuffer({usage:ge.STORAGE|ge.MAP_READ|ge.COPY_DST,hint:ye.Static,viewOrSize:f=(c=256*Math.ceil(Math.ceil(n/l.width)*l.length/256))*i}),(d=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:a.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:p.gpuBuffer,offset:0,bytesPerRow:c},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([d.finish()]),[2,this.readBuffer(p,0,o.byteLength===f?o:null,u,f,a.pixelFormat)]}))}))},r.prototype.readTextureSync=function(e,r,n,i,o,a,s,u){throw Error(t.ERROR_MSG_METHOD_NOT_IMPLEMENTED)},r.prototype.readBuffer=function(e,t,r,n,i,o,a,s){var u=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=Fe.U8_RGB),void 0===a&&(a=!1);var l=e,c=i||l.size,f=r||l.view,p=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||qe(o),d=l;if(!(l.usage&ge.MAP_READ&&l.usage&ge.COPY_DST)){var _=this.device.device.createCommandEncoder();d=this.device.createBuffer({usage:ge.STORAGE|ge.MAP_READ|ge.COPY_DST,hint:ye.Static,viewOrSize:c}),_.copyBufferToBuffer(l.gpuBuffer,t,d.gpuBuffer,0,c),this.device.device.queue.submit([_.finish()])}return new Promise((function(e,r){d.gpuBuffer.mapAsync(Mo.READ,t,c).then((function(){var r=d.gpuBuffer.getMappedRange(t,c),n=f;if(a)n=null===n?Jo(o,c,!0,r):Jo(o,n.buffer,void 0,r);else if(null===n)switch(p){case 1:(n=new Uint8Array(c)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r);break;case 4:(n=new Float32Array(c/4)).set(new Float32Array(r))}else switch(p){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(c/2,r,f);break;case 4:var i=f&&f.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}d.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},r.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},r.prototype.getBlockInformationFromFormat=function(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}}},r}($o),la=function(){function e(){this.commandEncoder=null,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.getTextureView=function(e,t){return Qe(e.numLevels>t),1===e.numLevels?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var t=e.colorAttachment.length;this.gfxColorAttachment.length=t,this.gfxColorResolveTo.length=t;for(var r=0;e.colorAttachment.length>r;r++){var n=e.colorAttachment[r],i=e.colorResolveTo[r];if(null===n&&null!==i&&(n=i,i=null),this.gfxColorAttachment[r]=n,this.gfxColorResolveTo[r]=i,this.gfxColorAttachmentLevel[r]=e.colorAttachmentLevel[r],this.gfxColorResolveToLevel[r]=e.colorResolveToLevel[r],null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={}),(a=this.gpuColorAttachments[r]).view=this.getTextureView(n,this.gfxColorAttachmentLevel[r]);var o=e.colorClearColor[r];"load"===o?a.loadOp="load":(a.loadOp="clear",a.clearValue=o),a.storeOp=e.colorStore[r]?"store":"discard",a.resolveTarget=void 0,null!==i&&(n.sampleCount>1?a.resolveTarget=this.getTextureView(i,this.gfxColorResolveToLevel[r]):a.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var a,s=e.depthStencilAttachment;(a=this.gpuDepthStencilAttachment).view=s.gpuTextureView,!!(ze(s.pixelFormat)&be.Depth)?("load"===e.depthClearValue?a.depthLoadOp="load":(a.depthLoadOp="clear",a.depthClearValue=e.depthClearValue),a.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(a.depthLoadOp=void 0,a.depthStoreOp=void 0),!!(ze(s.pixelFormat)&be.Stencil)?("load"===e.stencilClearValue?a.stencilLoadOp="load":(a.stencilLoadOp="clear",a.stencilClearValue=e.stencilClearValue),a.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(a.stencilLoadOp=void 0,a.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},e.prototype.beginRenderPass=function(e){Qe(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.setViewport=function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)},e.prototype.setScissor=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)},e.prototype.setPipeline=function(e){var t=Je(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},e.prototype.setInputState=function(e){if(null!==e){var t=e;if(null!==t.indexBuffer){var r=t.inputLayout,n=t.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Go(n.buffer),Je(r.indexFormat),n.byteOffset)}for(var i=0;t.vertexBuffers.length>i;i++){var o=t.vertexBuffers[i];y(o)||this.gpuRenderPassEncoder.setVertexBuffer(i,Go(o.buffer),o.byteOffset)}}},e.prototype.setBindings=function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),n.gpuBindGroup[1]&&this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])},e.prototype.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},e.prototype.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},e.prototype.drawIndexedInstanced=function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.finish=function(){this.gpuRenderPassEncoder.end(),this.gpuRenderPassEncoder=null;for(var e=0;this.gfxColorAttachment.length>e;e++){var t=this.gfxColorAttachment[e],r=this.gfxColorResolveTo[e];null!==t&&null!==r&&1===t.sampleCount&&this.copyAttachment(r,this.gfxColorAttachmentLevel[e],t,this.gfxColorResolveToLevel[e])}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.commandEncoder.finish()},e.prototype.copyAttachment=function(e,t,r,n){Qe(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};Qe(r.width>>>n==e.width>>>t),Qe(r.height>>>n==e.height>>>t),Qe(!!(r.usage&No.COPY_SRC)),Qe(!!(e.usage&No.COPY_DST)),this.commandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),ca=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=fe.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device._createRenderPipeline(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}($o),fa=function(e){function t(t){var r,n,i=t.descriptor,o=this;(o=e.call(this,{id:t.id,device:t.device})||this).type=fe.Sampler;var a=i.minLOD,s=i.mipFilter===ve.NoMip?i.minLOD:i.maxLOD,u=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return u>1&&Qe(i.minFilter===me.Bilinear&&i.magFilter===me.Bilinear&&i.mipFilter===ve.Linear),o.gpuSampler=o.device.device.createSampler({addressModeU:Do(i.wrapS),addressModeV:Do(i.wrapT),addressModeW:Do(null!==(n=i.wrapQ)&&void 0!==n?n:i.wrapS),lodMinClamp:a,lodMaxClamp:s,minFilter:Bo(i.minFilter),magFilter:Bo(i.magFilter),mipmapFilter:Lo(i.mipFilter),compare:void 0!==i.compareMode?qo(i.compareMode):void 0,maxAnisotropy:u}),o}return n(t,e),t}($o),pa=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=e.call(this,{id:t.id,device:t.device})||this;return i.type=fe.Texture,i.device.createTextureShared({pixelFormat:r.pixelFormat,dimension:r.dimension,width:r.width,height:r.height,depthOrArrayLayers:r.depth,numLevels:r.numLevels,usage:r.usage,sampleCount:1},i,n),i}return n(t,e),t.prototype.setImageData=function(e,t){},t.prototype.destroy=function(){this.gpuTexture.destroy()},t}($o),da=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=No.RENDER_ATTACHMENT|No.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Dr(Ut,Mr),this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=Me.UpperLeft,this.clipSpaceNearZ=xe.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(Ce.n2D,Ne.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Ce.n2D,Ne.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(Ce.n2DArray,Ne.Float),this.fallbackTexture3D=this.createFallbackTexture(Ce.n3D,Ne.Float),this.fallbackTextureCube=this.createFallbackTexture(Ce.Cube,Ne.Float),this.fallbackSamplerFiltering=this.createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Point,mipFilter:ve.Nearest}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({wrapS:Re.Repeat,wrapT:Re.Repeat,minFilter:me.Point,magFilter:me.Point,mipFilter:ve.Nearest,compareMode:pe.Always}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler 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.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 pa({id:0,device:this,descriptor:{pixelFormat:Fe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:Ce.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new ta({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new pa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new fa({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new pa({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:Ce.n2D,numLevels:1,depth:1,usage:Oe.RenderTarget})});return t.depthOrArrayLayers=1,t.type=fe.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.pixelFormat,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.numLevels,s=e.gpuTexture,u=e.gpuTextureView,l=e.usage;Qe(!!(l&No.RENDER_ATTACHMENT));var c=new pa({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:Ce.n2D,numLevels:a,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=u,c},e.prototype.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},e.prototype.createProgramSimple=function(e){return new aa({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.numLevels,o=xo(e.pixelFormat),a=function(e){if(e===Ce.n2D)return"2d";if(e===Ce.Cube)return"2d";if(e===Ce.n2DArray)return"2d";if(e===Ce.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Oe.Sampled&&(t|=No.TEXTURE_BINDING|No.COPY_DST),e&Oe.RenderTarget&&(t|=No.RENDER_ATTACHMENT|No.TEXTURE_BINDING|No.COPY_SRC|No.COPY_DST),t}(e.usage);if(t.format=o,t.dimension=e.dimension,t.pixelFormat=e.pixelFormat,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.numLevels=i,t.usage=s,t.sampleCount=1,!r){var u=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,usage:s}),l=u.createView();t.gpuTexture=u,t.gpuTextureView=l}},e.prototype.getFallbackSampler=function(e){return e.formatKind===Ne.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===Ce.n2D)return e.formatKind===Ne.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===Ce.n2DArray)return this.fallbackTexture2DArray;if(t===Ce.n3D)return this.fallbackTexture3D;if(t===Ce.Cube)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,pixelFormat:t===Ne.Float?Fe.U8_RGBA_NORM:Fe.D24,usage:Oe.Sampled,width:1,height:1,depth:e===Ce.Cube?6:1,numLevels:1})},e.prototype.createBindings=function(e){return new ea({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new ia({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputState=function(e,t,r){return new oa({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})},e.prototype.createComputePipeline=function(e){return new na({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new ca({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new sa({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype._createBindGroupLayout=function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t},e.prototype._createBindGroupLayoutInternal=function(e){var t,r=this,n=[[],[]];if(e.storageEntries)for(var i=0;e.storageEntries.length>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.COMPUTE,buffer:{type:e.storageEntries[i].type}});for(i=0;e.numUniformBuffers>i;i++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(i=0;e.numSamplers>i;i++){var o=void 0!==e.samplerEntries?e.samplerEntries[i]:xt;n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=o,{sampleType:bo(t.formatKind),viewDimension:Uo(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:Fo(o)})}return{gpuBindGroupLayout:n.map((function(e){return e.length?r.device.createBindGroupLayout({entries:e}):null})).filter((function(e){return!!e}))}},e.prototype._createPipelineLayout=function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})},e.prototype._createRenderPipeline=function(e,t){if(null===e.gpuRenderPipeline){var r=e.descriptor,n=r.program,o=n.vertexStage,a=n.fragmentStage;if(null!==o&&null!==a){var s,u=this._createPipelineLayout(r.bindingLayouts),l=(s=r.megaStateDescriptor,{topology:ko(r.topology),cullMode:Vo(s.cullMode),frontFace:Wo(s.frontFace)}),c=jo(r.colorAttachmentFormats,r.megaStateDescriptor),f=function(e,t){if(null!==e)return{format:xo(e),depthWriteEnabled:t.depthWrite,depthCompare:qo(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(r.depthStencilAttachmentFormat,r.megaStateDescriptor),p=void 0;null!==r.inputLayout&&(p=r.inputLayout.buffers);var d=r.sampleCount,_={layout:u,vertex:i(i({},o),{buffers:p}),primitive:l,depthStencil:f,multisample:{count:d},fragment:i(i({},a),{targets:c})};e.gpuRenderPipeline=this.device.createRenderPipeline(_)}}},e.prototype.createReadback=function(){return new ua({id:this.getNextUniqueId(),device:this})},e.prototype.destroyRenderTarget=function(e){e.gpuTexture.destroy()},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new la),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();return void 0===e&&(e=new ra),e.commandEncoder=this.device.createCommandEncoder(),e.beginComputePass(),e},e.prototype.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null},e.prototype.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,u=n,l={texture:u.gpuTexture,origin:[i,o,0]},c={texture:s.gpuTexture,origin:[t,r,0]};Qe(!!(u.usage&No.COPY_SRC)),Qe(!!(s.usage&No.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ke(e)){case Be.BC1:case Be.BC2:case Be.BC3:case Be.BC4_SNORM:case Be.BC4_UNORM:case Be.BC5_SNORM:case Be.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ke(e)){case Be.BC1:case Be.BC2:case Be.BC3:case Be.BC4_SNORM:case Be.BC4_UNORM:case Be.BC5_SNORM:case Be.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case Fe.U16_RGBA_NORM:case Fe.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===fe.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===fe.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===fe.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===fe.Sampler){(r=e).gpuSampler.label=t}else if(e.type===fe.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.pushDebugGroup=function(e){},e.prototype.popDebugGroup=function(){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this._createRenderPipeline(e,!1)},e}(),_a=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var r,n,i,o,a,u;return s(this,(function(s){switch(s.label){case 0:if(void 0===t.runtime.globalThis.navigator.gpu)return[2,null];r=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,t.runtime.globalThis.navigator.gpu.requestAdapter()];case 2:return r=s.sent(),[3,4];case 3:return n=s.sent(),console.log(n),[3,4];case 4:return null===r?[2,null]:(i=["depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),[4,r.requestDevice({requiredFeatures:i})]);case 5:if((o=s.sent())&&(a=this.pluginOptions.onContextLost,o.lost.then((function(){a&&a()}))),null===o)return[2,null];if(!(u=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,Po(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new da(r,o,e,u,Io)]}}))}))},e}(),ha=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="webgpu-device",r}return n(t,e),t.prototype.init=function(){this.context.deviceContribution=new _a(i({shaderCompilerPath:"/glsl_wgsl_compiler_bg.wasm"},this.options))},t.prototype.destroy=function(){delete this.context.deviceContribution},t}(t.AbstractRendererPlugin),Ea=Object.freeze({__proto__:null,Plugin:ha}),Ra=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=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=C(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)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),ma=function(e){function t(t){var r=e.call(this)||this;return r.rendererPlugin=t,r.name="webgpu-context-register",r}return n(t,e),t.prototype.init=function(){this.context.ContextService=Ra,this.context.deviceRendererPlugin=this.rendererPlugin},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),va=function(e){function r(r){var n=e.call(this,r)||this;n.clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new eo;return n.registerPlugin(new ma(i)),n.registerPlugin(new co),n.registerPlugin(new ha({shaderCompilerPath:null==r?void 0:r.shaderCompilerPath,onContextLost:null==r?void 0:r.onContextLost})),n.registerPlugin(i),n.registerPlugin(new no),n.registerPlugin(new ao),n}return n(r,e),r}(t.AbstractRenderer);e.DeviceRenderer=to,e.DomInteraction=io,e.HTMLRenderer=so,e.Renderer=va,e.WebGPUDevice=Ea}));
2
2
  //# sourceMappingURL=index.umd.min.js.map