@antv/g-webgpu 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";function r(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
- r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=y(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&n.call(E,o)&&(_=E);var g=p.prototype=h.prototype=Object.create(_);function m(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(i,o,a,s){var u=l(e[i],e,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function y(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(g,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(R.prototype),u(R.prototype,a,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),u(g,s,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function o(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}o((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof v?t:v).prototype),o=new N(n||[]);return i._invoke=function(e,t,r){var n=f;return function(i,o){if(n===d)throw new Error("Generator is already running");if(n===p){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=C(a,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=l(e,t,r);if("normal"===u.type){if(n=r.done?p:h,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var f="suspendedStart",h="suspendedYield",d="executing",p="completed",_={};function v(){}function E(){}function g(){}var m={};u(m,o,(function(){return this}));var R=Object.getPrototypeOf,y=R&&R(R(x([])));y&&y!==r&&n.call(y,o)&&(m=y);var T=g.prototype=v.prototype=Object.create(m);function A(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=l(e[i],e,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function C(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method))return _;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var i=l(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,_;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function x(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:t,done:!0}}return E.prototype=g,u(T,"constructor",g),u(g,"constructor",E),E.displayName=u(g,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,u(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},A(S.prototype),u(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),u(T,s,"Generator"),u(T,o,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(this.prev>=a.tryLoc){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(a.catchLoc>this.prev)return i(a.catchLoc,!0);if(a.finallyLoc>this.prev)return i(a.finallyLoc)}else if(u){if(a.catchLoc>this.prev)return i(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}!o||"break"!==e&&"continue"!==e||o.tryLoc>t||t>o.finallyLoc||(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:x(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),_}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function a(e,t,r,n){var i,o=arguments.length,a=3>o?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(3>o?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var u,c,l=o((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=new 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,c,l=this._events[s],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(c=1,u=new Array(f-1);f>c;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,d=l.length;for(c=0;d>c;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(f-1);f>h;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].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,c=[],l=s.length;l>u;u++)(s[u].fn!==t||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c: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})),f=function(){function e(){this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}var r=e.prototype;return r.getImageSync=function(e,t){return this.imageCache[e]||this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},r.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(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))},r.getOrCreatePatternSync=function(e,r,n){var i=this.generatePatternKey(e);if(i&&this.patternCache[i])return this.patternCache[i];var o,a=e.image,s=e.repetition,u=(o=t.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(o,s);return i&&u&&(this.patternCache[i]=u),u},r.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,s=e.height,u=e.cx,c=e.cy;if(this.gradientCache[n])return this.gradientCache[n];var l=null;if(i===t.GradientType.LinearGradient){var f=t.computeLinearGradient(a,s,e.angle);l=r.createLinearGradient(f.x1,f.y1,f.x2,f.y2)}else if(i===t.GradientType.RadialGradient){var h=t.computeRadialGradient(a,s,u,c),d=h.x,p=h.y;l=r.createRadialGradient(d,p,0,d,p,h.r)}return l&&(o.forEach((function(e){var t;null===(t=l)||void 0===t||t.addColorStop(e[0],e[1])})),this.gradientCache[n]=l),this.gradientCache[n]},r.generateGradientKey=function(e){return"gradient-"+e.type+"-"+(e.angle||0)+"-"+(e.cx||0)+"-"+(e.cy||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},r.generatePatternKey=function(e){var r=e.image,n=e.repetition;if(t.isString(r))return"pattern-"+r+"-"+n},e}();function h(){
3
+ r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&n.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function r(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=u(e);if(t){var i=u(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}function h(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}h((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof v?t:v).prototype),o=new N(n||[]);return i._invoke=function(e,t,r){var n=f;return function(i,o){if(n===d)throw Error("Generator is already running");if(n===p){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=C(a,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=c(e,t,r);if("normal"===u.type){if(n=r.done?p:h,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f="suspendedStart",h="suspendedYield",d="executing",p="completed",_={};function v(){}function E(){}function y(){}var g={};u(g,o,(function(){return this}));var m=Object.getPrototypeOf,R=m&&m(m(x([])));R&&R!==r&&n.call(R,o)&&(g=R);var T=y.prototype=v.prototype=Object.create(g);function A(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function C(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method))return _;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var i=c(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,_;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function x(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:t,done:!0}}return E.prototype=y,u(T,"constructor",y),u(y,"constructor",E),E.displayName=u(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===E||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,u(e,s,"GeneratorFunction")),e.prototype=Object.create(T),e},e.awrap=function(e){return{__await:e}},A(S.prototype),u(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),u(T,s,"Generator"),u(T,o,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(this.prev>=a.tryLoc){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(a.catchLoc>this.prev)return i(a.catchLoc,!0);if(a.finallyLoc>this.prev)return i(a.finallyLoc)}else if(u){if(a.catchLoc>this.prev)return i(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(this.prev>=i.tryLoc&&n.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}!o||"break"!==e&&"continue"!==e||o.tryLoc>t||t>o.finallyLoc||(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:x(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),_}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function d(e,t,r,n){var i,o=arguments.length,a=3>o?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(3>o?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var _=h((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 h,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(h=1,u=Array(f-1);f>h;h++)u[h-1]=arguments[h];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}));function v(){
4
4
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
5
- h=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=y(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function d(){}function p(){}var _={};s(_,i,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,i)&&(_=E);var g=p.prototype=f.prototype=Object.create(_);function m(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function y(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,s(g,"constructor",p),s(p,"constructor",d),d.displayName=s(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(R.prototype),s(R.prototype,o,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),s(g,a,"Generator"),s(g,i,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function d(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){d(o,n,i,a,s,"next",e)}function s(e){d(o,n,i,a,s,"throw",e)}a(void 0)}))}}a([t.inject(t.CanvasConfig),s("design:type",Object)],f.prototype,"canvasConfig",void 0),f=a([t.singleton()],f);var _=(u=function(){function e(){this.imagePool=void 0,this.renderingContext=void 0}return e.prototype.apply=function(e){var r=this,n=function(n){var i=n.target;if(i.nodeName===t.Shape.IMAGE){var o=i.attributes.img;t.isString(o)&&r.imagePool.getImageSync(o,(function(){i.renderable.dirty=!0,e.dirtify()}))}},i=function(n){var i=n.target,o=n.newValue;i.nodeName===t.Shape.IMAGE&&"img"===n.attrName&&t.isString(o)&&r.imagePool.getOrCreateImage(o).then((function(){i.renderable.dirty=!0,e.dirtify()}))};e.hooks.init.tapPromise(c.tag,p(h().mark((function e(){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,i);case 2:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(c.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,i)}))},e}(),u.tag="LoadImage",c=u);a([t.inject(f),s("design:type",f)],_.prototype,"imagePool",void 0),a([t.inject(t.RenderingContext),s("design:type",Object)],_.prototype,"renderingContext",void 0),_=c=a([t.singleton({contrib:t.RenderingPluginContribution})],_);var v=t.Module((function(e){e(f),e(_)})),E=function(){function e(){this.name="image-loader"}var t=e.prototype;return t.init=function(e){e.load(v,!0)},t.destroy=function(e){e.unload(v)},e}(),g=R,m=R;function R(e,t,r){r=r||2;var n,i,o,a,s,u,c,l=t&&t.length,f=l?t[0]*r:e.length,h=y(e,0,f,r,!0),d=[];if(!h||h.next===h.prev)return d;if(l&&(h=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=y(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(M(a));for(s.sort(N),i=0;s.length>i;i++)r=T(r=x(s[i],r),r.next);return r}(e,t,h,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var p=r;f>p;p+=r)n>(s=e[p])&&(n=s),i>(u=e[p+1])&&(i=u),s>o&&(o=s),u>a&&(a=u);c=0!==(c=Math.max(o-n,a-i))?1/c:0}return A(h,d,r,n,i,c),d}function y(e,t,r,n,i){var o,a;if(i===j(e,t,r,n)>0)for(o=t;r>o;o+=n)a=W(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=W(o,e[o],e[o+1],a);return a&&F(a,a.next)&&(X(a),a=a.next),a}function T(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!F(n,n.next)&&0!==b(n.prev,n,n.next))n=n.next;else{if(X(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function A(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=D(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,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;c>t&&(s++,n=n.nextZ);t++);for(u=c;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,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,c=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?C(e,n,i,o):S(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),X(e),e=u.next,c=u.next;else if((e=u)===c){a?1===a?A(e=O(T(e),t,r),t,r,n,i,o,2):2===a&&I(e,t,r,n,i,o):A(T(e),t,r,n,i,o,1);break}}}function S(e){var t=e.prev,r=e,n=e.next;if(b(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(B(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&b(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function C(e,t,r,n){var i=e.prev,o=e,a=e.next;if(b(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,c=D(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),l=D(s,u,t,r,n),f=e.prevZ,h=e.nextZ;f&&f.z>=c&&h&&l>=h.z;){if(f!==e.prev&&f!==e.next&&B(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&b(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,h!==e.prev&&h!==e.next&&B(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&b(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(;f&&f.z>=c;){if(f!==e.prev&&f!==e.next&&B(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&b(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;h&&l>=h.z;){if(h!==e.prev&&h!==e.next&&B(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&b(h.prev,h,h.next)>=0)return!1;h=h.nextZ}return!0}function O(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!F(i,o)&&U(i,n,n.next,o)&&k(i,o)&&k(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),X(n),X(n.next),n=e=o),n=n.next}while(n!==e);return T(n)}function I(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&L(a,s)){var u=V(a,s);return a=T(a,a.next),u=T(u,u.next),A(a,t,r,n,i,o),void A(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function N(e,t){return e.x-t.x}function x(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,c=r,l=r.x,f=r.y,h=1/0;n=r;do{n.x>i||l>n.x||i===n.x||!B(f>o?i:a,o,l,f,f>o?a:i,o,n.x,n.y)||(u=Math.abs(o-n.y)/(i-n.x),k(n,e)&&(h>u||u===h&&(n.x>r.x||n.x===r.x&&P(r,n)))&&(r=n,h=u)),n=n.next}while(n!==c);return r}(e,t);if(!r)return t;var n=V(r,e),i=T(r,r.next);return T(n,n.next),t===r?i:t}function P(e,t){return 0>b(e.prev,e,t.prev)&&0>b(t.next,e,e.next)}function D(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 M(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 B(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 L(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&&U(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(k(e,t)&&k(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)&&(b(e.prev,e,t.prev)||b(e,t.prev,t))||F(e,t)&&b(e.prev,e,e.next)>0&&b(t.prev,t,t.next)>0)}function b(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function F(e,t){return e.x===t.x&&e.y===t.y}function U(e,t,r,n){var i=G(b(e,t,r)),o=G(b(e,t,n)),a=G(b(r,n,e)),s=G(b(r,n,t));return i!==o&&a!==s||(!(0!==i||!w(e,r,t))||(!(0!==o||!w(e,n,t))||(!(0!==a||!w(r,e,n))||!(0!==s||!w(r,t,n)))))}function w(e,t,r){return!(t.x>Math.max(e.x,r.x)||t.x<Math.min(e.x,r.x)||t.y>Math.max(e.y,r.y)||t.y<Math.min(e.y,r.y))}function G(e){return e>0?1:0>e?-1:0}function k(e,t){return 0>b(e.prev,e,e.next)?b(e,t,e.next)>=0&&b(e,e.prev,t)>=0:0>b(e,t,e.prev)||0>b(e,e.next,t)}function V(e,t){var r=new H(e.i,e.x,e.y),n=new H(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 W(e,t,r,n){var i=new H(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 X(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 H(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 j(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}R.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(j(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(j(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 c=n[a]*r,l=n[a+1]*r,f=n[a+2]*r;u+=Math.abs((e[c]-e[f])*(e[l+1]-e[c+1])-(e[c]-e[l])*(e[f+1]-e[c+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},R.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},g.default=m;const Y=1e20;class K{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=r;const s=this.size=e+4*t,u=this._createCanvas(s),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(r),s=Math.min(this.size-this.buffer,Math.ceil(o-i)),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),c=s+2*this.buffer,l=u+2*this.buffer,f=Math.max(c*l,0),h=new Uint8ClampedArray(f),d={data:h,width:c,height:l,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===u)return d;const{ctx:p,buffer:_,gridInner:v,gridOuter:E}=this;p.clearRect(_,_,s,u),p.fillText(e,_,_+a);const g=p.getImageData(_,_,s,u);E.fill(Y,0,f),v.fill(0,0,f);for(let e=0;u>e;e++)for(let t=0;s>t;t++){const r=g.data[4*(e*s+t)+3]/255;if(0===r)continue;const n=(e+_)*c+t+_;if(1===r)E[n]=0,v[n]=Y;else{const e=.5-r;E[n]=e>0?e*e:0,v[n]=0>e?e*e:0}}z(E,0,0,c,l,c,this.f,this.v,this.z),z(v,_,_,s,u,c,this.f,this.v,this.z);for(let e=0;f>e;e++){const t=Math.sqrt(E[e])-Math.sqrt(v[e]);h[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}}function z(e,t,r,n,i,o,a,s,u){for(let c=t;t+n>c;c++)q(e,r*o+c,o,i,a,s,u);for(let c=r;r+i>c;c++)q(e,c*o+t,1,n,a,s,u)}function q(e,t,r,n,i,o,a){o[0]=0,a[0]=-Y,a[1]=Y,i[0]=e[t];for(let s=1,u=0,c=0;n>s;s++){i[s]=e[t+s*r];const n=s*s;do{const e=o[u];c=(i[s]-i[e]+n-e*e)/(s-e)/2}while(a[u]>=c&&--u>-1);u++,o[u]=s,a[u]=c,a[u+1]=Y}for(let s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;const n=o[u],c=s-n;e[t+s*r]=i[n]+c*c}}var Z=function(){this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]};Z.tag="c-renderable-3d";var Q=function(){function e(){this.lights=[],this.fog=void 0}var t=e.prototype;return t.addLight=function(e){this.lights.push(e),this.sortLights()},t.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},t.addFog=function(e){this.fog=e},t.removeFog=function(e){this.fog=null},t.getFog=function(){return this.fog},t.getAllLights=function(){return this.lights},t.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},t.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}();function J(){
5
+ v=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new C(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return I()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(O([])));y&&y!==t&&r.call(y,o)&&(_=y);var g=p.prototype=h.prototype=Object.create(_);function m(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return d.prototype=p,u(g,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(R.prototype),u(R.prototype,a,(function(){return this})),e.AsyncIterator=R,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new R(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),u(g,s,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function E(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function y(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){E(o,n,i,a,s,"next",e)}function s(e){E(o,n,i,a,s,"throw",e)}a(void 0)}))}}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function R(e,t,r){return t&&m(e.prototype,t),r&&m(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}var S,C,O=function(){function e(){g(this,e),this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}return R(e,[{key:"getImageSync",value:function(e,t){return this.imageCache[e]||this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]}},{key:"getOrCreateImage",value: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(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))}},{key:"getOrCreatePatternSync",value:function(e,r,n){var i=this.generatePatternKey(e);if(i&&this.patternCache[i])return this.patternCache[i];var o,a=e.image,s=e.repetition,u=(o=t.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(o,s);return i&&u&&(this.patternCache[i]=u),u}},{key:"getOrCreateGradient",value: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;if(this.gradientCache[n])return this.gradientCache[n];var c=null;if(i===t.GradientType.LinearGradient){var f=t.computeLinearGradient(a,s,e.angle);c=r.createLinearGradient(f.x1,f.y1,f.x2,f.y2)}else if(i===t.GradientType.RadialGradient){var h=t.computeRadialGradient(a,s,u,l),d=h.x,p=h.y;c=r.createRadialGradient(d,p,0,d,p,h.r)}return c&&(o.forEach((function(e){var t,r=T(e,2);null===(t=c)||void 0===t||t.addColorStop(r[0],r[1])})),this.gradientCache[n]=c),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.width,r=e.height,n=e.steps,i=e.angle,o=e.cx,a=e.cy;return"gradient-".concat(e.type,"-").concat(i||0,"-").concat(o||0,"-").concat(a||0,"-").concat(t,"-").concat(r,"-").concat(n.map((function(e){return e.join("")})).join("-"))}},{key:"generatePatternKey",value:function(e){var r=e.image,n=e.repetition;if(t.isString(r))return"pattern-".concat(r,"-").concat(n)}}]),e}();d([t.inject(t.CanvasConfig),p("design:type",Object)],O.prototype,"canvasConfig",void 0),O=d([t.singleton()],O);var I=(S=function(){function e(){g(this,e),this.imagePool=void 0,this.renderingContext=void 0}return R(e,[{key:"apply",value:function(e){var r=this,n=function(n){var i=n.target;if(i.nodeName===t.Shape.IMAGE){var o=i.attributes.img;t.isString(o)&&r.imagePool.getImageSync(o,(function(){i.renderable.dirty=!0,e.dirtify()}))}},i=function(n){var i=n.target,o=n.newValue;i.nodeName===t.Shape.IMAGE&&"img"===n.attrName&&t.isString(o)&&r.imagePool.getOrCreateImage(o).then((function(){i.renderable.dirty=!0,e.dirtify()}))};e.hooks.init.tapPromise(C.tag,y(v().mark((function e(){return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,i);case 2:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(C.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,i)}))}}]),e}(),S.tag="LoadImage",C=S);d([t.inject(O),p("design:type",O)],I.prototype,"imagePool",void 0),d([t.inject(t.RenderingContext),p("design:type",Object)],I.prototype,"renderingContext",void 0),I=C=d([t.singleton({contrib:t.RenderingPluginContribution})],I);var N=t.Module((function(e){e(O),e(I)})),x=function(){function e(){g(this,e),this.name="image-loader"}return R(e,[{key:"init",value:function(e){e.load(N,!0)}},{key:"destroy",value:function(e){e.unload(N)}}]),e}(),P=b,D=b;function b(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,h=M(e,0,f,r,!0),d=[];if(!h||h.next===h.prev)return d;if(c&&(h=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=M(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(H(a));for(s.sort(G),i=0;s.length>i;i++)r=B(r=V(s[i],r),r.next);return r}(e,t,h,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var p=r;f>p;p+=r)n>(s=e[p])&&(n=s),i>(u=e[p+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(h,d,r,n,i,l),d}function M(e,t,r,n,i){var o,a;if(i===ne(e,t,r,n)>0)for(o=t;r>o;o+=n)a=ee(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=ee(o,e[o],e[o+1],a);return a&&z(a,a.next)&&(te(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(te(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=X(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?U(e,n,i,o):F(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),te(e),e=u.next,l=u.next;else if((e=u)===l){a?1===a?L(e=w(B(e),t,r),t,r,n,i,o,2):2===a&&k(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(j(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 U(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=X(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=X(s,u,t,r,n),f=e.prevZ,h=e.nextZ;f&&f.z>=l&&h&&c>=h.z;){if(f!==e.prev&&f!==e.next&&j(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,h!==e.prev&&h!==e.next&&j(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&K(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(;f&&f.z>=l;){if(f!==e.prev&&f!==e.next&&j(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(;h&&c>=h.z;){if(h!==e.prev&&h!==e.next&&j(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&K(h.prev,h,h.next)>=0)return!1;h=h.nextZ}return!0}function w(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!z(i,o)&&q(i,n,n.next,o)&&J(i,o)&&J(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),te(n),te(n.next),n=e=o),n=n.next}while(n!==e);return B(n)}function k(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=$(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 G(e,t){return e.x-t.x}function V(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,h=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!j(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),J(n,e)&&(h>u||u===h&&(n.x>r.x||n.x===r.x&&W(r,n)))&&(r=n,h=u)),n=n.next}while(n!==l);return r}(e,t);if(!r)return t;var n=$(r,e),i=B(r,r.next);return B(n,n.next),t===r?i:t}function W(e,t){return 0>K(e.prev,e,t.prev)&&0>K(t.next,e,e.next)}function X(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 H(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 j(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&&q(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(J(e,t)&&J(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 q(e,t,r,n){var i=Q(K(e,t,r)),o=Q(K(e,t,n)),a=Q(K(r,n,e)),s=Q(K(r,n,t));return i!==o&&a!==s||(!(0!==i||!Z(e,r,t))||(!(0!==o||!Z(e,n,t))||(!(0!==a||!Z(r,e,n))||!(0!==s||!Z(r,t,n)))))}function Z(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 Q(e){return e>0?1:0>e?-1:0}function J(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 $(e,t){var r=new re(e.i,e.x,e.y),n=new re(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 ee(e,t,r,n){var i=new re(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 te(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 re(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 ne(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}b.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(ne(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(ne(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)},b.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},P.default=D;const ie=1e20;class oe{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=n,this.radius=r;const s=this.size=e+4*t,u=this._createCanvas(s),l=this.ctx=u.getContext("2d",{willReadFrequently:!0});l.font=`${a} ${o} ${e}px ${i}`,l.textBaseline="alphabetic",l.textAlign="left",l.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(r),s=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),h=new Uint8ClampedArray(f),d={data:h,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===u)return d;const{ctx:p,buffer:_,gridInner:v,gridOuter:E}=this;p.clearRect(_,_,s,u),p.fillText(e,_,_+a);const y=p.getImageData(_,_,s,u);E.fill(ie,0,f),v.fill(0,0,f);for(let e=0;u>e;e++)for(let t=0;s>t;t++){const r=y.data[4*(e*s+t)+3]/255;if(0===r)continue;const n=(e+_)*l+t+_;if(1===r)E[n]=0,v[n]=ie;else{const e=.5-r;E[n]=e>0?e*e:0,v[n]=0>e?e*e:0}}ae(E,0,0,l,c,l,this.f,this.v,this.z),ae(v,_,_,s,u,l,this.f,this.v,this.z);for(let e=0;f>e;e++){h[e]=Math.round(255-255*((Math.sqrt(E[e])-Math.sqrt(v[e]))/this.radius+this.cutoff))}return d}}function ae(e,t,r,n,i,o,a,s,u){for(let l=t;t+n>l;l++)se(e,r*o+l,o,i,a,s,u);for(let l=r;r+i>l;l++)se(e,l*o+t,1,n,a,s,u)}function se(e,t,r,n,i,o,a){o[0]=0,a[0]=-ie,a[1]=ie,i[0]=e[t];for(let s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];const n=s*s;do{const e=o[u];l=(i[s]-i[e]+n-e*e)/(s-e)/2}while(a[u]>=l&&--u>-1);u++,o[u]=s,a[u]=l,a[u+1]=ie}for(let s=0,u=0;n>s;s++){for(;s>a[u+1];)u++;const n=o[u],l=s-n;e[t+s*r]=i[n]+l*l}}function ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function le(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ue(Object(r),!0).forEach((function(t){ve(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ce(){
6
6
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
7
- J=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,v=_&&_(_(S([])));v&&v!==t&&r.call(v,i)&&(p=v);var E=d.prototype=f.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=d,s(E,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),s(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),s(E,a,"Generator"),s(E,i,(function(){return this})),s(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function $(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){$(o,n,i,a,s,"next",e)}function s(e){$(o,n,i,a,s,"throw",e)}a(void 0)}))}}function te(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function re(e,t,r){return t&&te(e.prototype,t),r&&te(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ne(){return ne=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ne.apply(this,arguments)}function ie(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,oe(e,t)}function oe(e,t){return oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},oe(e,t)}function ae(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&(i[r]=e[r]);return i}function se(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);t>r;r++)n[r]=e[r];return n}function ce(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return ue(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}Q=a([t.singleton()],Q);var le=["style"],fe=function(e){function r(r){var n,i=r.style,o=ae(r,le);return(n=e.call(this,ne({type:t.Shape.MESH,style:ne({x:"",y:"",z:"",lineWidth:0},i)},o))||this).cullable.enable=!1,n.style.geometry.meshes.push(se(n)),n.style.material.meshes.push(se(n)),n}return ie(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),he="undefined"!=typeof Float32Array?Float32Array:Array;function de(){var e=new he(16);return he!=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 pe(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(e,t,r,n,i,o,a,s,u,c,l,f,h,d,p,_){var v=new he(16);return v[0]=e,v[1]=t,v[2]=r,v[3]=n,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=u,v[9]=c,v[10]=l,v[11]=f,v[12]=h,v[13]=d,v[14]=p,v[15]=_,v}function ve(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 Ee=function(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],u=t[5],c=t[6],l=t[7],f=t[8],h=t[9],d=t[10],p=t[11],_=t[12],v=t[13],E=t[14],g=t[15],m=r[0],R=r[1],y=r[2],T=r[3];return e[0]=m*n+R*s+y*f+T*_,e[1]=m*i+R*u+y*h+T*v,e[2]=m*o+R*c+y*d+T*E,e[3]=m*a+R*l+y*p+T*g,e[4]=(m=r[4])*n+(R=r[5])*s+(y=r[6])*f+(T=r[7])*_,e[5]=m*i+R*u+y*h+T*v,e[6]=m*o+R*c+y*d+T*E,e[7]=m*a+R*l+y*p+T*g,e[8]=(m=r[8])*n+(R=r[9])*s+(y=r[10])*f+(T=r[11])*_,e[9]=m*i+R*u+y*h+T*v,e[10]=m*o+R*c+y*d+T*E,e[11]=m*a+R*l+y*p+T*g,e[12]=(m=r[12])*n+(R=r[13])*s+(y=r[14])*f+(T=r[15])*_,e[13]=m*i+R*u+y*h+T*v,e[14]=m*o+R*c+y*d+T*E,e[15]=m*a+R*l+y*p+T*g,e};function ge(e,t,r){var n=new he(3);return n[0]=e,n[1]=t,n[2]=r,n}var me,Re;me=new he(3),he!=Float32Array&&(me[0]=0,me[1]=0,me[2]=0),Re=me;var ye,Te,Ae,Se,Ce,Oe,Ie,Ne,xe,Pe,De,Me,Be,Le,be,Fe,Ue,we,Ge,ke,Ve,We,Xe,He,je,Ye,Ke;!function(){var e=function(){var e=new he(2);return he!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function ze(e,t,r,n){return{dimension:be.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:Fe.Sampled}}function qe(e){return e}function Ze(e,t,r){return e<<16|t<<8|r}function Qe(e){return e>>>8&255}function Je(e){return e>>>16&255}function $e(e){return 255&e}function et(e){switch(e){case Xe.F32:case Xe.U32:case Xe.S32:return 4;case Xe.U16:case Xe.S16:case Xe.F16:return 2;case Xe.U8:case Xe.S8:return 1;default:throw new Error("whoops")}}function tt(e){return et(Je(e))}function rt(e){var t=$e(e);if(t&je.Depth)return Ge.Depth;if(t&je.Normalized)return Ge.Float;var r=Je(e);if(r===Xe.F16||r===Xe.F32)return Ge.Float;if(r===Xe.U8||r===Xe.U16||r===Xe.U32)return Ge.Uint;if(r===Xe.S8||r===Xe.S16||r===Xe.S32)return Ge.Sint;throw new Error("whoops")}function nt(e,t){if(void 0===t&&(t=""),!e)throw console.error((new Error).stack),new Error("Assert fail: "+t)}function it(e){if(null!=e)return e;throw new Error("Missing object")}function ot(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function at(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function st(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function ut(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!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"}(ye||(ye={})),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"}(Te||(Te={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(Ae||(Ae={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(Se||(Se={})),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"}(Ce||(Ce={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}(Oe||(Oe={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(Ie||(Ie={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(Ne||(Ne={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(xe||(xe={})),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"}(Pe||(Pe={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(De||(De={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(Me||(Me={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(Be||(Be={})),function(e){e.LOADED="loaded"}(Le||(Le={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(be||(be={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(Fe||(Fe={})),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"}(Ue||(Ue={})),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"}(we||(we={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(Ge||(Ge={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(ke||(ke={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(Ve||(Ve={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(We||(We={})),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"}(Xe||(Xe={})),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"}(He||(He={})),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"}(je||(je={})),function(e){e[e.ALPHA=Ze(Xe.U8,He.A,je.None)]="ALPHA",e[e.F16_R=Ze(Xe.F16,He.R,je.None)]="F16_R",e[e.F16_RG=Ze(Xe.F16,He.RG,je.None)]="F16_RG",e[e.F16_RGB=Ze(Xe.F16,He.RGB,je.None)]="F16_RGB",e[e.F16_RGBA=Ze(Xe.F16,He.RGBA,je.None)]="F16_RGBA",e[e.F32_R=Ze(Xe.F32,He.R,je.None)]="F32_R",e[e.F32_RG=Ze(Xe.F32,He.RG,je.None)]="F32_RG",e[e.F32_RGB=Ze(Xe.F32,He.RGB,je.None)]="F32_RGB",e[e.F32_RGBA=Ze(Xe.F32,He.RGBA,je.None)]="F32_RGBA",e[e.U8_R=Ze(Xe.U8,He.R,je.None)]="U8_R",e[e.U8_R_NORM=Ze(Xe.U8,He.R,je.Normalized)]="U8_R_NORM",e[e.U8_RG=Ze(Xe.U8,He.RG,je.None)]="U8_RG",e[e.U8_RG_NORM=Ze(Xe.U8,He.RG,je.Normalized)]="U8_RG_NORM",e[e.U8_RGB=Ze(Xe.U8,He.RGB,je.None)]="U8_RGB",e[e.U8_RGB_NORM=Ze(Xe.U8,He.RGB,je.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=Ze(Xe.U8,He.RGB,je.sRGB|je.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=Ze(Xe.U8,He.RGBA,je.None)]="U8_RGBA",e[e.U8_RGBA_NORM=Ze(Xe.U8,He.RGBA,je.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=Ze(Xe.U8,He.RGBA,je.sRGB|je.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=Ze(Xe.U16,He.R,je.None)]="U16_R",e[e.U16_R_NORM=Ze(Xe.U16,He.R,je.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=Ze(Xe.U16,He.RG,je.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=Ze(Xe.U16,He.RGBA,je.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=Ze(Xe.U16,He.RGB,je.None)]="U16_RGB",e[e.U32_R=Ze(Xe.U32,He.R,je.None)]="U32_R",e[e.U32_RG=Ze(Xe.U32,He.RG,je.None)]="U32_RG",e[e.S8_R=Ze(Xe.S8,He.R,je.None)]="S8_R",e[e.S8_R_NORM=Ze(Xe.S8,He.R,je.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=Ze(Xe.S8,He.RG,je.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=Ze(Xe.S8,He.RGB,je.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=Ze(Xe.S8,He.RGBA,je.Normalized)]="S8_RGBA_NORM",e[e.S16_R=Ze(Xe.S16,He.R,je.None)]="S16_R",e[e.S16_RG=Ze(Xe.S16,He.RG,je.None)]="S16_RG",e[e.S16_RG_NORM=Ze(Xe.S16,He.RG,je.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=Ze(Xe.S16,He.RGB,je.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=Ze(Xe.S16,He.RGBA,je.None)]="S16_RGBA",e[e.S16_RGBA_NORM=Ze(Xe.S16,He.RGBA,je.Normalized)]="S16_RGBA_NORM",e[e.S32_R=Ze(Xe.S32,He.R,je.None)]="S32_R",e[e.U16_RGBA_5551=Ze(Xe.U16_PACKED_5551,He.RGBA,je.Normalized)]="U16_RGBA_5551",e[e.BC1=Ze(Xe.BC1,He.RGBA,je.Normalized)]="BC1",e[e.BC1_SRGB=Ze(Xe.BC1,He.RGBA,je.Normalized|je.sRGB)]="BC1_SRGB",e[e.BC2=Ze(Xe.BC2,He.RGBA,je.Normalized)]="BC2",e[e.BC2_SRGB=Ze(Xe.BC2,He.RGBA,je.Normalized|je.sRGB)]="BC2_SRGB",e[e.BC3=Ze(Xe.BC3,He.RGBA,je.Normalized)]="BC3",e[e.BC3_SRGB=Ze(Xe.BC3,He.RGBA,je.Normalized|je.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=Ze(Xe.BC4_UNORM,He.R,je.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=Ze(Xe.BC4_SNORM,He.R,je.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=Ze(Xe.BC5_UNORM,He.RG,je.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=Ze(Xe.BC5_SNORM,He.RG,je.Normalized)]="BC5_SNORM",e[e.D24=Ze(Xe.D24,He.R,je.Depth)]="D24",e[e.D24_S8=Ze(Xe.D24S8,He.RG,je.Depth|je.Stencil)]="D24_S8",e[e.D32F=Ze(Xe.D32F,He.R,je.Depth)]="D32F",e[e.D32F_S8=Ze(Xe.D32FS8,He.RG,je.Depth|je.Stencil)]="D32F_S8",e[e.U8_RGB_RT=Ze(Xe.U8,He.RGB,je.RenderTarget|je.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=Ze(Xe.U8,He.RGBA,je.RenderTarget|je.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=Ze(Xe.U8,He.RGBA,je.RenderTarget|je.Normalized|je.sRGB)]="U8_RGBA_RT_SRGB"}(Ye||(Ye={})),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"}(Ke||(Ke={}));var ct=ut(0,0,0,0),lt=ut(0,0,0,1),ft=ut(1,1,1,0),ht=ut(1,1,1,1),dt=!0;function pt(e,t){if(void 0===t&&(t=dt),!t)return e;switch(e){case Te.Less:return Te.Greater;case Te.LessEqual:return Te.GreaterEqual;case Te.GreaterEqual:return Te.LessEqual;case Te.Greater:return Te.Less;default:return e}}function _t(e,t){return null!=e?e:t}function vt(e){return void 0===e?null:e}function Et(e,t,r){e.length=t,e.fill(r)}function gt(e,t){var r=t-1;return e+r&~r}function mt(e,t){return((e+t-1)/t|0)*t}function Rt(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 yt(e,t,r){var n=Rt(e,t,r);e.splice(n,0,t)}function Tt(e,t,r){return r?e|=t:e&=~t,e}function At(e,t){for(var r=new Array(e),n=0;e>n;n++)r[n]=t();return r}function St(e,t,r){for(void 0===r&&(r="0");t>e.length;)e=""+r+e;return e}function Ct(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Ot(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Ct(e.rgbBlendState,t.rgbBlendState),Ct(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function It(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=Ot(e[r],t[r])}function Nt(e,t){void 0!==t.attachmentsState&&It(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&at(e.blendConstant,t.blendConstant),e.depthCompare=_t(t.depthCompare,e.depthCompare),e.depthWrite=_t(t.depthWrite,e.depthWrite),e.stencilCompare=_t(t.stencilCompare,e.stencilCompare),e.stencilWrite=_t(t.stencilWrite,e.stencilWrite),e.stencilPassOp=_t(t.stencilPassOp,e.stencilPassOp),e.stencilRef=_t(t.stencilRef,e.stencilRef),e.cullMode=_t(t.cullMode,e.cullMode),e.frontFace=_t(t.frontFace,e.frontFace),e.polygonOffset=_t(t.polygonOffset,e.polygonOffset)}function xt(e){var t=Object.assign({},e);return t.attachmentsState=[],It(t.attachmentsState,e.attachmentsState),t.blendConstant=st(t.blendConstant),t}function Pt(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 Dt={blendMode:Oe.Add,blendSrcFactor:Ce.One,blendDstFactor:Ce.Zero},Mt={attachmentsState:[{channelWriteMask:Ue.RGB,rgbBlendState:Dt,alphaBlendState:Dt}],blendConstant:st(ct),depthWrite:!0,depthCompare:Te.LessEqual,stencilCompare:Te.Always,stencilWrite:!1,stencilPassOp:we.Keep,stencilRef:0,cullMode:Se.None,frontFace:Ae.CCW,polygonOffset:!1};function Bt(e,t){void 0===e&&(e=null),void 0===t&&(t=Mt);var r=xt(t);return null!==e&&Nt(r,e),r}var Lt=Bt({depthCompare:Te.Always,depthWrite:!1},Mt);function bt(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],It(e.attachmentsState,Mt.attachmentsState)),Pt(e.attachmentsState[0],t),e}var Ft,Ut={formatKind:Ge.Float,dimension:be.n2D};function wt(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 Gt(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function kt(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function Vt(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function Wt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Xt(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!wt(e.samplerBindings,t.samplerBindings,Vt)&&(!!wt(e.uniformBufferBindings,t.uniformBufferBindings,kt)&&!!Yt(e.bindingLayout,t.bindingLayout)))}function Ht(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function jt(e,t){return!!Ht(e.rgbBlendState,t.rgbBlendState)&&(!!Ht(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function Yt(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function Kt(e,t){return e===t}function zt(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!wt(e.attachmentsState,t.attachmentsState,jt)&&!!ot(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)&&(!!wt(e.bindingLayouts,t.bindingLayouts,Yt)&&(!!wt(e.colorAttachmentFormats,t.colorAttachmentFormats,Kt)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function qt(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Zt(e,r){return t.isNil(e)?t.isNil(r):!t.isNil(r)&&(e.byteStride===r.byteStride&&e.frequency===r.frequency)}function Qt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!wt(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Zt)&&!!wt(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,qt))}function Jt(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 $t(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function er(e){return{buffer:e.buffer,wordCount:e.wordCount}}function tr(e){return{bindingLayout:e.bindingLayout,samplerBindings:Gt(e.samplerBindings,$t),uniformBufferBindings:Gt(e.uniformBufferBindings,er),pipeline:e.pipeline}}function rr(e){return{dimension:e.dimension,formatKind:e.formatKind}}function nr(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?Gt(e.samplerEntries,rr):void 0}}function ir(e){var t=Gt(e.bindingLayouts,nr),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:xt(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function or(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function ar(e){return t.isNil(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function sr(e){return{vertexAttributeDescriptors:Gt(e.vertexAttributeDescriptors,or),vertexBufferDescriptors:Gt(e.vertexBufferDescriptors,ar),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(Ft||(Ft={}));var ur,cr=new Uint16Array([65279]),lr=255==new DataView(cr.buffer).getUint8(0)?Ft.LITTLE_ENDIAN:Ft.BIG_ENDIAN;var fr=/([^[]*)(\[[0-9]+\])?/;function hr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function dr(e,t,r,n){var i=null,o=null;return function(a,s,u){var c=t(u,r),l=c.length,f=!1;if(null===i)i=new Float32Array(l),o=l,f=!0;else{nt(o===l,"Uniform length cannot change.");for(var h=0;l>h;++h)if(c[h]!==i[h]){f=!0;break}}return f&&(n(a,e,s,c),i.set(c)),f}}function pr(e,t,r,n){e[t](r,n)}function _r(e,t,r,n){e[t](r,!1,n)}var vr={},Er={},gr={},mr=[0];function Rr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(mr[0]=e,e=mr);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 yr(e,t){return Rr(e,t,Float32Array,vr)}function Tr(e,t){return Rr(e,t,Int32Array,Er)}function Ar(e,t){return Rr(e,t,Uint32Array,gr)}var Sr,Cr=((ur={})[Ke.FLOAT]=dr.bind(null,"uniform1fv",yr,1,pr),ur[Ke.FLOAT_VEC2]=dr.bind(null,"uniform2fv",yr,2,pr),ur[Ke.FLOAT_VEC3]=dr.bind(null,"uniform3fv",yr,3,pr),ur[Ke.FLOAT_VEC4]=dr.bind(null,"uniform4fv",yr,4,pr),ur[Ke.INT]=dr.bind(null,"uniform1iv",Tr,1,pr),ur[Ke.INT_VEC2]=dr.bind(null,"uniform2iv",Tr,2,pr),ur[Ke.INT_VEC3]=dr.bind(null,"uniform3iv",Tr,3,pr),ur[Ke.INT_VEC4]=dr.bind(null,"uniform4iv",Tr,4,pr),ur[Ke.BOOL]=dr.bind(null,"uniform1iv",Tr,1,pr),ur[Ke.BOOL_VEC2]=dr.bind(null,"uniform2iv",Tr,2,pr),ur[Ke.BOOL_VEC3]=dr.bind(null,"uniform3iv",Tr,3,pr),ur[Ke.BOOL_VEC4]=dr.bind(null,"uniform4iv",Tr,4,pr),ur[Ke.FLOAT_MAT2]=dr.bind(null,"uniformMatrix2fv",yr,4,_r),ur[Ke.FLOAT_MAT3]=dr.bind(null,"uniformMatrix3fv",yr,9,_r),ur[Ke.FLOAT_MAT4]=dr.bind(null,"uniformMatrix4fv",yr,16,_r),ur[Ke.SAMPLER_2D]=hr,ur[Ke.SAMPLER_CUBE]=hr,ur[Ke.UNSIGNED_INT]=dr.bind(null,"uniform1uiv",Ar,1,pr),ur[Ke.UNSIGNED_INT_VEC2]=dr.bind(null,"uniform2uiv",Ar,2,pr),ur[Ke.UNSIGNED_INT_VEC3]=dr.bind(null,"uniform3uiv",Ar,3,pr),ur[Ke.UNSIGNED_INT_VEC4]=dr.bind(null,"uniform4uiv",Ar,4,pr),ur[Ke.FLOAT_MAT2x3]=dr.bind(null,"uniformMatrix2x3fv",yr,6,_r),ur[Ke.FLOAT_MAT2x4]=dr.bind(null,"uniformMatrix2x4fv",yr,8,_r),ur[Ke.FLOAT_MAT3x2]=dr.bind(null,"uniformMatrix3x2fv",yr,6,_r),ur[Ke.FLOAT_MAT3x4]=dr.bind(null,"uniformMatrix3x4fv",yr,12,_r),ur[Ke.FLOAT_MAT4x2]=dr.bind(null,"uniformMatrix4x2fv",yr,8,_r),ur[Ke.FLOAT_MAT4x3]=dr.bind(null,"uniformMatrix4x3fv",yr,12,_r),ur[Ke.SAMPLER_2D]=hr,ur[Ke.SAMPLER_CUBE]=hr,ur[Ke.SAMPLER_3D]=hr,ur[Ke.SAMPLER_2D_SHADOW]=hr,ur[Ke.SAMPLER_2D_ARRAY]=hr,ur[Ke.SAMPLER_2D_ARRAY_SHADOW]=hr,ur[Ke.SAMPLER_CUBE_SHADOW]=hr,ur[Ke.INT_SAMPLER_2D]=hr,ur[Ke.INT_SAMPLER_3D]=hr,ur[Ke.INT_SAMPLER_CUBE]=hr,ur[Ke.INT_SAMPLER_2D_ARRAY]=hr,ur[Ke.UNSIGNED_INT_SAMPLER_2D]=hr,ur[Ke.UNSIGNED_INT_SAMPLER_3D]=hr,ur[Ke.UNSIGNED_INT_SAMPLER_CUBE]=hr,ur[Ke.UNSIGNED_INT_SAMPLER_2D_ARRAY]=hr,ur);function Or(e,t,r){var n=e.createBuffer({viewOrSize:gt(r.byteLength,4)/4,usage:t,hint:Me.Static});return n.setSubData(0,new Uint8Array(r)),n}!function(e){e.CHANGED="changed"}(Sr||(Sr={}));var Ir,Nr=function(e){function r(t,r){var n;return void 0===r&&(r={}),(n=e.call(this)||this).device=void 0,n.props=void 0,n.drawMode=Pe.Triangles,n.vertexBuffers=[],n.vertices=[],n.indexBuffer=void 0,n.indices=void 0,n.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:Ye.U32_R},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n.device=t,n.props=r,n}ie(r,e);var n=r.prototype;return n.validate=function(e){return!0},n.build=function(e){},n.computeBoundingBox=function(){return new t.AABB},n.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=Or(this.device,De.INDEX|De.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this},n.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=Or(this.device,De.VERTEX|De.COPY_DST,i.buffer);return this.vertexBuffers[r]=o,this},n.getVertexBuffer=function(e){return this.vertexBuffers[e]},n.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(Sr.CHANGED)},n.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,ArrayBuffer.isView(e)?e:new Uint32Array(e)),this},n.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}(l.EventEmitter),xr=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function Pr(e,t){return"#define "+e+" "+t}function Dr(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=e.trim().split(/\s+/),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(o+"["+e+"]."+r.name)}))},c=0;5>c;c++)u(c);else s.uniforms.forEach((function(e){t.push(o+"."+e.name)}))}o&&t.push(o)}})),""})),t}function Mr(e,t,r,n,i){void 0===n&&(n=null);var o="#version 100"===e.glslVersion,a=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),s="";null!==n&&(s=Object.keys(n).map((function(e){return Pr(e,n[e])})).join("\n"));var u=a.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",c=a.filter((function(e){return!e.startsWith("precision")})).join("\n"),l="";if(e.viewportOrigin===ke.UpperLeft&&(l+=Pr("VIEWPORT_ORIGIN_TL","1")+"\n"),e.clipSpaceNearZ===Ve.Zero&&(l+=Pr("CLIPSPACE_NEAR_ZERO","1")+"\n"),e.explicitBindingLocations){var f=0,h=0,d=0;c=c.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout("+(r?r+", ":"")+"set = "+f+", binding = "+h+++") uniform "+n})),f++,h=0,nt(e.separateSamplerTextures),c=(c=c.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = "+f+", binding = "+h+++") uniform texture2D T_"+r+";\nlayout(set = "+f+", binding = "+h+++") uniform sampler S_"+r+";\n":""}))).replace("frag"===t?/^\b(varying|in)\b/gm:/^\b(varying|out)\b/gm,(function(e,t){return"layout(location = "+d+++") "+t})),l+=Pr("gl_VertexID","gl_VertexIndex")+"\n"}c=e.separateSamplerTextures?(c=(c=(c=c.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"texture2D T_P_"+t+", sampler S_P_"+t}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_"+t+")"}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"T_"+t+", S_"+t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D(T_"+t+", S_"+t+")"})):(c=(c=(c=c.replace(/\bPD_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"sampler2D P_"+t}))).replace(/\bPU_SAMPLER_2D\((.*?)\)/g,(function(e,t){return"SAMPLER_2D(P_"+t+")"}))).replace(/\bPP_SAMPLER_2D\((.*?)\)/g,(function(e,t){return t}))).replace(/\bSAMPLER_2D\((.*?)\)/g,(function(e,t){return t}));var p=((o?"":e.glslVersion)+"\n\n"+(o&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"")+"\n"+u+"\n"+l+"\n"+s+"\n"+c+"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(p=p.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) "+t}))),o){if("frag"===t&&(p=p.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying "+t+" "+r+";\n"}))),"vert"===t&&(p=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying "+t+" "+r+";\n"}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute "+t+" "+r+";\n"}))),p=p.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 "+t:""}))})),"frag"===t){var _,v=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return _=r,t+" "+r+";\n"}))).lastIndexOf("}");p=p.substring(0,v)+"\n gl_FragColor = vec4("+_+");\n"+p.substring(v)}p=p.replace(/^\s*layout\((.*)\)/gm,"");for(var E,g=ce(xr);!(E=g()).done;){var m=E.value;p=p.replace(m[0],m[1])}}return p}function Br(e,t,r,n,i){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:Mr(e,"vert",t,n),preprocessedFrag:Mr(e,"frag",r,n)}}function Lr(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 Br(e.queryVendorInfo(),n,i,r)}!function(e){e.CHANGED="changed"}(Ir||(Ir={}));var br=function(e){function r(t,r){var n;(n=e.call(this)||this).device=void 0,n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uniformNames=void 0,n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=xt(Mt),o=i.cullMode,a=i.depthCompare,s=i.depthWrite,u=i.stencilCompare,c=i.stencilWrite,l=i.stencilPassOp,f=i.frontFace,h=i.polygonOffset,d=i.attachmentsState;return n.device=t,n.props=ne({cullMode:o,depthTest:!0,depthCompare:a,depthWrite:s,stencilCompare:u,stencilWrite:c,stencilPassOp:l,frontFace:f,polygonOffset:h,attachmentsState:d,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}ie(r,e);var n=r.prototype;return n.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=Dr(this.props.fragmentShader)},n.setUniforms=function(e){var r=this,n=!1;Object.keys(e).forEach((function(i){var o,a=e[i],s=r.textures[i];s&&s!==a&&(r.textureDirty=!0),(o=a)&&o.type?(r.textures[i]=a,r.textureDirty=!0,a.on(Le.LOADED,(function(){r.dispatchMutationEvent()}))):(r.uniforms[i]=a,n=!0),t.isNil(e[i])&&(delete r.textures[i],delete r.uniforms[i])})),n&&this.dispatchMutationEvent()},n.dispatchMutationEvent=function(){this.emit(Ir.CHANGED)},re(r,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilCompare",get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilPassOp",get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}}]),r}(l.EventEmitter),Fr=function(e){function t(t,r){var n;return(n=e.call(this,t,ne({},r))||this).defines=ne({},n.defines,{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return ie(t,e),t}(br),Ur=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}var r=e.prototype;return r.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},r.setDefineString=function(e,r){if(null!==r){if(this.defines[e]===r)return!1;this.defines[e]=r}else{if(t.isNil(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},r.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},r.getDefineString=function(e){return vt(this.defines[e])},r.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&nt("1"===t),null!==t},r.ensurePreprocessed=function(e){""===this.preprocessedVert&&(this.preprocessedVert=Mr(e,"vert",this.both+this.vert,this.defines),this.preprocessedFrag=Mr(e,"frag",this.both+this.frag,this.defines))},e}(),wr=function(){function e(e){this.device=void 0,this.uniformBufferWordAlignment=void 0,this.uniformBufferMaxPageWordSize=void 0,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}var t=e.prototype;return t.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},t.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},t.allocateChunk=function(e){e=mt(e,this.uniformBufferWordAlignment),nt(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=mt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},t.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=mt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){nt(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=mt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw new Error("Assert fail: this.currentWordOffset ["+this.currentWordOffset+"] <= newWordCount ["+n+"]")}},t.mapBufferF32=function(){return it(this.shadowBufferF32)},t.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=it(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:De.UNIFORM|De.COPY_DST,hint:Me.Dynamic}));var t=mt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw new Error("Assert fail: wordCount ["+t+"] ("+this.currentWordOffset+" aligned "+this.uniformBufferMaxPageWordSize+") <= this.currentBufferWordSize ["+this.currentBufferWordSize+"]");if(this.isSupportedUBO())it(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},t.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Gr(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function kr(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Vr(e){return 0}var Wr=function(){this.keys=[],this.values=[]},Xr=function(){function e(e,t){this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=e,this.keyHashFunc=t}var t=e.prototype;return t.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},t.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},t.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]},t.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Wr);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},t.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))}},t.clear=function(){this.buckets.clear()},t.size=function(){for(var e,t=0,r=ce(this.buckets.values());!(e=r()).done;){t+=e.value.values.length}return t},t.values=J().mark((function e(){var t,r,n,i;return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=ce(this.buckets.values());case 1:if((r=t()).done){e.next=12;break}i=(n=r.value).values.length-1;case 4:if(i<0){e.next=10;break}return e.next=7,n.values[i];case 7:i--,e.next=4;break;case 10:e.next=1;break;case 12:case"end":return e.stop()}}),e,this)})),e}();function Hr(e,t){return nt(""!==e.preprocessedVert&&""!==t.preprocessedVert),nt(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function jr(e,t){return e=Gr(e,t.numUniformBuffers),e=Gr(e,t.numSamplers)}function Yr(e,t){return e=Gr(e,t.blendMode),e=Gr(e,t.blendSrcFactor),e=Gr(e,t.blendDstFactor)}function Kr(e,t){return e=Yr(e,t.rgbBlendState),e=Gr(e=Yr(e,t.alphaBlendState),t.channelWriteMask)}function zr(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=Kr(e,t.attachmentsState[r]);return e=function(e,t){return Gr(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Gr(e,t.depthCompare),e=Gr(e,t.depthWrite?1:0),e=Gr(e,t.stencilCompare),e=Gr(e,t.stencilPassOp),e=Gr(e,t.stencilWrite?1:0),e=Gr(e,t.cullMode),e=Gr(e,t.frontFace?1:0),e=Gr(e,t.polygonOffset?1:0)}function qr(e){var t=0;t=Gr(t,e.program.id),null!==e.inputLayout&&(t=Gr(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=jr(t,e.bindingLayouts[r]);t=zr(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=Gr(t,e.colorAttachmentFormats[n]||0);return kr(t=Gr(t,e.depthStencilAttachmentFormat||0))}function Zr(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=Gr(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=Gr(t,o.buffer.id),t=Gr(t,o.wordCount))}return kr(t)}var Qr,Jr=function(){function e(e){this.device=void 0,this.bindingsCache=new Xr(Xt,Zr),this.renderPipelinesCache=new Xr(zt,qr),this.inputLayoutsCache=new Xr(Qt,Vr),this.programCache=new Xr(Hr,Vr),this.samplerCache=new Xr(Jt,Vr),this.device=e}var t=e.prototype;return t.createBindings=function(e){var t=this.bindingsCache.get(e);if(null===t){var r=tr(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t},t.createRenderPipeline=function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=ir(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t},t.createInputLayout=function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=sr(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t},t.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},t.createProgram=function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)},t.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},t.destroy=function(){for(var e,t=ce(this.bindingsCache.values());!(e=t()).done;){e.value.destroy()}for(var r,n=ce(this.renderPipelinesCache.values());!(r=n()).done;){r.value.destroy()}for(var i,o=ce(this.inputLayoutsCache.values());!(i=o()).done;){i.value.destroy()}for(var a,s=ce(this.programCache.values());!(a=s()).done;){a.value.destroy()}for(var u,c=ce(this.samplerCache.values());!(u=c()).done;){u.value.destroy()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!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"}(Qr||(Qr={}));var $r,en={x:0,y:0,w:1,h:1},tn=function(){function e(){this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=en,this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorResolveTo:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=0,this.viewportH=0,this.execFunc=null,this.postFunc=null,this.debugName=void 0,this.debugThumbnails=[]}var t=e.prototype;return t.setDebugName=function(e){this.debugName=e},t.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},t.setViewport=function(e){this.viewport=e},t.attachRenderTargetID=function(e,t){nt(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t},t.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},t.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},t.resolveToExternalTexture=function(e,t){this.resolveTextureOutputExternalTextures[e]=t},t.exec=function(e){nt(null===this.execFunc),this.execFunc=e},t.post=function(e){nt(null===this.postFunc),this.postFunc=e},t.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),rn=function(){function e(e,t){this.debugName=void 0,this.dimension=be.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=Fe.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,nt(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}var t=e.prototype;return t.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},t.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},t.reset=function(e){nt(this.matchesDescription(e)),this.age=0},t.destroy=function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()},e}(),nn=function(){function e(e,t){this.dimension=be.n2D,this.depth=1,this.numLevels=1,this.usage=Fe.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=t.pixelFormat,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}var t=e.prototype;return t.matchesDescription=function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height},t.reset=function(e){nt(this.matchesDescription(e)),this.age=0},t.destroy=function(){this.texture.destroy()},e}();$r=Symbol.species;var on,an=function(){this[$r]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},sn=function(){function e(e){this.device=void 0,this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}var t=e.prototype;return t.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 rn(this.device,e)},t.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 nn(this.device,e)},t.beginGraphBuilder=function(){nt(null===this.currentGraph),this.currentGraph=new an},t.pushPass=function(e){var t=new tn;e(t),this.currentGraph.passes.push(t)},t.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},t.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},t.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},t.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]},t.findPassForResolveRenderTarget=function(e){var t=it(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return nt(void 0===t.resolveTextureOutputExternalTextures[r]),t},t.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},t.resolveRenderTargetToExternalTexture=function(e,t){var r=this.findPassForResolveRenderTarget(e),n=r.renderTargetIDs.indexOf(e);nt(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t},t.getRenderTargetDescription=function(e){return it(this.currentGraph.renderTargetDescriptions[e])},t.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[o]]++}},t.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(nt(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]},t.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=it(this.renderTargetAliveForID[e]);return t?(nt(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(nt(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},t.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];nt(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=it(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 it(n.texture)},t.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;nt(!(a&&s));var u=null,c=!1;if(this.renderTargetOutputCount[n]>1&&(c=!0),a){nt(e.resolveTextureRenderTargetIDs[i]===n),nt(this.resolveTextureUseCount[i]>0),nt(this.renderTargetOutputCount[n]>0);var l=it(this.renderTargetAliveForID[n]);if(null!==l.texture&&1===this.renderTargetOutputCount[n])u=null,c=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=it(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,l.debugName+" (Resolve "+i+")")}u=this.singleSampledTextureForResolveTextureID[i].texture}}else u=s?o:null;return{resolveTo:u,store:c}},t.schedulePass=function(e,t){for(var r=t.renderTargetIDs[Qr.DepthStencil],n=Qr.Color0;Qr.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;var a=this.determineResolveParam(e,t,n),s=a.store;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[Qr.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,Qr.DepthStencil),l=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=l,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var f=0,h=0,d=0,p=0;t.renderTargets.length>p;p++){var _=t.renderTargets[p];_&&(0===f&&(f=_.width,h=_.height,d=_.sampleCount),nt(_.width===f),nt(_.height===h),nt(_.sampleCount===d),_.needsClear=!1)}if(f>0&&h>0){var v=h*t.viewport.y,E=f*t.viewport.w,g=h*t.viewport.h;t.viewportX=f*t.viewport.x,t.viewportY=v,t.viewportW=E,t.viewportH=g}for(var m=0;t.resolveTextureInputIDs.length>m;m++){t.resolveTextureInputTextures[m]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[m])}for(var R=0;t.renderTargetIDs.length>R;R++)this.releaseRenderTargetForID(t.renderTargetIDs[R],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},t.scheduleGraph=function(e){nt(0===this.renderTargetOutputCount.length),nt(0===this.renderTargetResolveCount.length),nt(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;Et(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),Et(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),Et(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var o=0;this.renderTargetOutputCount.length>o;o++)nt(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)nt(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)nt(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)nt(void 0===this.renderTargetAliveForID[u]);for(var c=0;this.renderTargetDeadPool.length>c;c++)1>this.renderTargetDeadPool[c].age||(this.renderTargetDeadPool[c].destroy(),this.renderTargetDeadPool.splice(c--,1));for(var l=0;this.singleSampledTextureDeadPool.length>l;l++)1>this.singleSampledTextureDeadPool[l].age||(this.singleSampledTextureDeadPool[l].destroy(),this.singleSampledTextureDeadPool.splice(l--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},t.execPass=function(e){nt(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},t.execGraph=function(e){var t=this;this.scheduleGraph(e),e.passes.forEach((function(e){t.execPass(e)})),this.singleSampledTextureForResolveTextureID.length=0},t.execute=function(){var e=it(this.currentGraph);this.execGraph(e),this.currentGraph=null},t.getDebug=function(){return this},t.getPasses=function(){return this.currentGraph.passes},t.getPassDebugThumbnails=function(e){return e.debugThumbnails},t.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},t.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},t.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return nt(r>=0),it(t.resolveTextureInputTextures[r])},t.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},t.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},t.newGraphBuilder=function(){return this.beginGraphBuilder(),this},t.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)nt(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)nt(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()},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"}(on||(on={}));function un(e,r,n){void 0===n&&(n=65536);var i=t.clamp(e,0,n)/n;return r&&(i=1-i),65535&65535*i}function cn(e,t){return(16777215&e|(255&t)<<24)>>>0}function ln(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function fn(e,t){return cn(ln(0,t),e)}function hn(e,t){return nt(t>=0),(4294967040&e|t>>>8&255)>>>0}function dn(e){return cn(0,e)}function pn(e,t){return nt(t>=0),(4278190335&e|t<<8)>>>0}var _n=_e(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var vn,En=_e(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function gn(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.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(vn||(vn={}));var mn,Rn=function(){function e(){this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=At(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=At(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:xt(Mt),program:null,topology:Pe.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}var r=e.prototype;return r.reset=function(){this.sortKey=0,this.flags=vn.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null},r.setFromTemplate=function(e){Nt(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=[].concat(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~vn.InheritedFlags|e.flags&vn.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(var i=0;i<Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length);i++)r.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(var o=0;e.dynamicUniformBufferByteOffsets.length>o;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]},r.setProgram=function(e){this.renderPipelineDescriptor.program=e},r.setMegaStateFlags=function(e){return Nt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},r.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},r.setInputLayoutAndState=function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e},r.setBindingLayout=function(e){nt(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(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})},r.setBindingLayouts=function(e){nt(this.bindingDescriptors.length>=e.length),nt(1===e.length),this.setBindingLayout(e[0])},r.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=Tt(this.flags,vn.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},r.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=Tt(this.flags,vn.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},r.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=Tt(this.flags,vn.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},r.setUniforms=function(e,r){if(0!==r.length){this.uniforms[e]=r;var n=0,i=[];r.forEach((function(e){var r=e.value;if(t.isNumber(r)||Array.isArray(r)||r instanceof Float32Array){var o=t.isNumber(r)?[r]:r,a=4-n%4;if(4!==a)if(a<(o.length>4?4:o.length)){n+=a;for(var s=0;a>s;s++)i.push(0)}else;n+=o.length,i.push.apply(i,o)}}));var o=4-i.length%4;if(4!==o)for(var a=0;o>a;a++)i.push(0);for(var s=this.allocateUniformBuffer(e,i.length),u=this.mapUniformBufferF32(e),c=0;i.length>c;c+=4)s+=gn(u,s,i[c],i[c+1],i[c+2],i[c+3])}},r.setUniformBuffer=function(e){this.uniformBuffer=e},r.allocateUniformBuffer=function(e,t){return nt(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)},r.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},r.setUniformBufferOffset=function(e,t,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r},r.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},r.getUniformBuffer=function(){return this.uniformBuffer},r.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)}},r.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},r.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):(nt(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}},r.setAllowSkippingIfPipelineNotReady=function(e){this.flags=Tt(this.flags,vn.AllowSkippingIfPipelineNotReady,e)},r.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:nt(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:nt(n==a.sampleCount)),nt(n>0),this.renderPipelineDescriptor.sampleCount=n},r.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&vn.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;this.bindingDescriptors[0].uniformBufferBindings.length>o;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=it(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 a=e.createBindings(ne({},this.bindingDescriptors[0],{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(nt(!!(this.flags&vn.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&vn.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0},e}();function yn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(mn||(mn={}));var Tn=function(){function e(e,t){void 0===e&&(e=yn),void 0===t&&(t=mn.Forwards),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}var t=e.prototype;return t.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},t.insertSorted=function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):yt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()},t.submitRenderInst=function(e){e.flags|=vn.Draw,this.insertSorted(e)},t.hasLateSamplerBinding=function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1},t.resolveLateSamplerBinding=function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].resolveLateSamplerBinding(e,t)},t.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},t.drawOnPassRendererNoReset=function(e,t){this.ensureSorted();var r=0;if(this.executionOrder===mn.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&r++;return r},t.reset=function(){this.renderInsts.length=0},t.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),An=function(){function e(){this.pool=[],this.allocCount=0}var t=e.prototype;return t.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Rn),this.allocCount-1},t.popRenderInst=function(){this.allocCount--},t.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},t.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),Sn=function(){function e(e){this.renderCache=void 0,this.instPool=new An,this.templatePool=new An,this.simpleRenderInstList=new Tn,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=e}var t=e.prototype;return t.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},t.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},t.setCurrentRenderInstList=function(e){nt(null===this.simpleRenderInstList),this.currentRenderInstList=e},t.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|=vn.Template,r},t.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},t.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},t.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),nt(0===this.templatePool.allocCount)},t.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},t.disableSimpleMode=function(){this.simpleRenderInstList=null},t.drawOnPassRenderer=function(e){it(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},t.drawOnPassRendererNoReset=function(e){it(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),Cn=function(){function e(){this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}var t=e.prototype;return t.getDevice=function(){return this.device},t.setDevice=function(e){this.device=e,this.renderCache=new Jr(e),this.renderGraph=new sn(this.device),this.renderInstManager=new Sn(this.renderCache),this.uniformBuffer=new wr(this.device)},t.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},t.prepareToRender=function(){this.uniformBuffer.prepareToRender()},t.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache.destroy(),this.renderGraph.destroy()},t.getCache=function(){return this.renderCache},e}();Cn=a([t.singleton()],Cn);var On=function(){function e(e){this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.pixelFormat=e}var t=e.prototype;return t.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},t.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function In(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Nn,xn=In(ut(.88,.88,.88,1)),Pn=In(lt),Dn=In(ht);function Mn(e,t){var r=function(e){return e.antialiasingMode===Nn.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Bn(e,t,r){var n=function(e){if(e===Qr.Color0)return Ye.U8_RGBA_RT;if(e===Qr.DepthStencil)return Ye.D24_S8;throw new Error("whoops")}(e),i=new On(n);return Mn(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"}(Nn||(Nn={}));var Ln=function(){function e(){this.name=void 0,this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}var t=e.prototype;return t.reset=function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0},t.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}(),bn=function(){function e(){this.inputTexture=null,this.outputTexture=null}var t=e.prototype;return t.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),nt(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new nn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},t.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},t.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},t.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}(),Fn=function(){function e(){this.imagePool=void 0,this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={}}var r=e.prototype;return r.getOrCreateTexture=function(e,r,n,i){var o,a=this,s="string"==typeof r?r:r.src||"";if(s&&this.textureCache[s])(o=this.textureCache[s]).emit(Le.LOADED);else if(o=e.createTexture(ne({pixelFormat:Ye.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:be.n2D,usage:Fe.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),s&&(this.textureCache[s]=o),t.isString(r)){var u,c=this.canvasConfig.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){a.textureCache[s].setImageData(u),a.textureCache[s].emit(Le.LOADED),a.renderingService.dirtify(),i&&i(a.textureCache[s])},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else o.setImageData(r),o.emit(Le.LOADED),this.renderingService.dirtify();return o},r.getOrCreateCanvas=function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)},r.getOrCreateGradient=function(e){var t=this,r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,i=2*n[0]||1,o=2*n[1]||1,a=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),s=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);a.width=i,a.height=o,r.forEach((function(e){var r=t.imagePool.getOrCreateGradient(ne({type:e.type},e.value,{width:i,height:o}),s);s.fillStyle=r,s.fillRect(0,0,i,o)}))},r.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=r.getGeometryBounds().halfExtents,u=2*s[0]||1,c=2*s[1]||1,l=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),f=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);l.width=u,l.height=c;var h=(i=t.isString(o)?this.imagePool.getImageSync(o,n):o)&&f.createPattern(i,a);f.fillStyle=h,f.fillRect(0,0,u,c)},r.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}();a([t.inject(f),s("design:type",f)],Fn.prototype,"imagePool",void 0),a([t.inject(t.OffscreenCanvasCreator),s("design:type",t.OffscreenCanvasCreator)],Fn.prototype,"offscreenCanvas",void 0),a([t.inject(t.RenderingService),s("design:type",t.RenderingService)],Fn.prototype,"renderingService",void 0),a([t.inject(t.CanvasConfig),s("design:type",Object)],Fn.prototype,"canvasConfig",void 0),Fn=a([t.singleton()],Fn);var Un=t.Syringe.defineToken("RendererFactory"),wn=t.Syringe.defineToken("ShapeRenderer"),Gn=t.Syringe.defineToken("MeshFactory"),kn=1,Vn=function(){function e(){this.renderHelper=void 0,this.rendererFactory=void 0,this.meshFactory=void 0,this.device=void 0,this.renderingService=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}var t=e.prototype;return t.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(r.device,r.renderingService);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}))}))},t.attach=function(e,t){this.device=e,this.renderingService=t},t.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=t.meshFactory(i)).renderer=n,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}},t.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=[])},t.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 c=a.shouldSubmitRenderInst(e,u),l=o.meshes.find((function(e){return e&&e.index===u&&e.constructor===s}));if(c!==!!l&&(l&&(l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&i.meshes.splice(i.meshes.indexOf(l),1),o.meshes[o.meshes.indexOf(l)]=void 0),c&&((l=i.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((l=i.meshFactory(s)).renderer=a,l.index=u,l.init(i.device,i.renderingService),i.meshes.push(l)),l&&(l.objects.push(e),o.meshes[u]=l))),c&&l&&l.inited&&!l.geometryDirty){var f=l.objects.indexOf(e);if(n)e.parsedStyle[t]=r,l.updateAttribute([e],f,t,r);else{var h=l.id+t;i.pendingUpdatePatches[h]||(i.pendingUpdatePatches[h]={instance:l,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[h].objectIndices.indexOf(f)&&i.pendingUpdatePatches[h].objectIndices.push(f)}}}))},t.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))}))},t.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=kn++),this.stencilRefCache[e.entity]},t.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}();a([t.inject(Cn),s("design:type",Cn)],Vn.prototype,"renderHelper",void 0),a([t.inject(Un),s("design:type",Function)],Vn.prototype,"rendererFactory",void 0),a([t.inject(Gn),s("design:type",Function)],Vn.prototype,"meshFactory",void 0),Vn=a([t.singleton()],Vn);var Wn=.005,Xn=1,Hn=function(){function e(){this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.batchManager=void 0,this.device=void 0,this.renderingService=void 0,this.id=Xn++,this.meshes=[],this.clipPathMeshCreated=!1}var t=e.prototype;return t.shouldSubmitRenderInst=function(e,t){return!0},t.beforeUploadUBO=function(e,t,r){},t.beforeInitMesh=function(e){},t.afterInitMesh=function(e){},e}();function jn(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Yn(e,t){var r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((function(r){return e[r]===t[r]}))}a([t.inject(Cn),s("design:type",Cn)],Hn.prototype,"renderHelper",void 0),a([t.inject(Fn),s("design:type",Fn)],Hn.prototype,"texturePool",void 0),a([t.inject(t.DefaultCamera),s("design:type",t.Camera)],Hn.prototype,"camera",void 0),a([t.inject(Q),s("design:type",Q)],Hn.prototype,"lightPool",void 0),a([t.inject(Vn),s("design:type",Vn)],Hn.prototype,"batchManager",void 0),Hn=a([t.injectable()],Hn);var Kn,zn,qn=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){return void 0!==e[1]})))},Zn=1,Qn="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.FILL_STROKE=1]="FILL_STROKE",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"}(Kn||(Kn={})),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.COLOR=4]="COLOR",e[e.STROKE_COLOR=5]="STROKE_COLOR",e[e.PACKED_STYLE1=6]="PACKED_STYLE1",e[e.PACKED_STYLE2=7]="PACKED_STYLE2",e[e.PICKING_COLOR=8]="PICKING_COLOR",e[e.POSITION=9]="POSITION",e[e.NORMAL=10]="NORMAL",e[e.UV=11]="UV",e[e.BARYCENTRIC=12]="BARYCENTRIC",e[e.MAX=13]="MAX"}(zn||(zn={}));var Jn=function(){function e(){this.id=Zn++,this.renderer=void 0,this.index=-1,this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.device=void 0,this.renderingService=void 0,this.objects=[],this.material=void 0,this.geometry=void 0,this.clipPath=void 0,this.clipPathTarget=void 0,this.inputState=void 0,this.program=new Ur,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}var r=e.prototype;return r.init=function(e,t){this.inited||(this.renderer.beforeInitMesh(this),this.device=e,this.renderingService=t,this.material=new Fr(this.device),this.material.defines=ne({},jn(zn),this.material.defines),this.geometry=new Nr(this.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},r.observeGeometryChanged=function(){var e=this;this.geometry.on(Sr.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))},r.observeMaterialChanged=function(){var e=this;this.material.on(Ir.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))},r.shouldMerge=function(e,t){return!this.instance||this.instance.nodeName===e.nodeName&&!e.parsedStyle.clipPath},r.createGeometry=function(e){var r=this,n=de(),i=de(),o=[],a=[],s=[],u=[];e.forEach((function(e){var c,l=e.parsedStyle,f=l.fill,h=l.stroke,d=l.opacity,p=l.fillOpacity,_=l.strokeOpacity,v=l.lineWidth,E=l.anchor,g=l.visibility,m=l.increasedLineWidthForHitTesting,R=[0,0,0,0];f instanceof t.CSSRGB&&(R=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]);var y=[0,0,0,0];h instanceof t.CSSRGB&&(y=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]),r.clipPathTarget?(pe(n,e.getLocalTransform()),R=[1,1,1,1],Ee(n,r.clipPathTarget.getWorldTransform(),n)):pe(n,e.getWorldTransform()),Ee(i,r.camera.getViewTransform(),n);var T=e.isInteractive()&&(null===(c=e.renderable3D)||void 0===c?void 0:c.encodedPickingColor)||[0,0,0];o.push.apply(o,n),a.push.apply(a,R.concat(y)),s.push(d.value,p.value,_.value,v.value,"visible"===g.value?1:0,E[0].value,E[1].value,(null==m?void 0:m.value)||0),u.push.apply(u,T.concat([e.sortable.renderOrder*Wn]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Kn.MODEL_MATRIX,byteStride:64,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:zn.MODEL_MATRIX0,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:16,location:zn.MODEL_MATRIX1,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:32,location:zn.MODEL_MATRIX2,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:48,location:zn.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Kn.FILL_STROKE,byteStride:32,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:zn.COLOR,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:16,location:zn.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Kn.PACKED_STYLE,byteStride:32,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:zn.PACKED_STYLE1,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:16,location:zn.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Kn.PICKING_COLOR,byteStride:16,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:zn.PICKING_COLOR,divisor:1}],data:new Float32Array(u)})},r.destroy=function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()},r.applyRenderInst=function(e,t){var r=this,n=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!n.length,a=ne({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=ne({},this.material.defines,this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=Te.Always,this.material.stencilPassOp=we.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=Te.Equal,this.material.stencilPassOp=we.Keep):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t),this.material.textureDirty){this.textureMappings=[];var s=this.createFillGradientTextureMapping(t);s&&this.textureMappings.push(s),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 Ln;t.name=e,t.texture=r.material.textures[e],r.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:Ie.Clamp,wrapT:Ie.Clamp,minFilter:Ne.Point,magFilter:Ne.Bilinear,mipFilter:xe.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}(Yn(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=ne({},this.material.defines,jn(zn)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"number"==typeof t?r.program.setDefineString(e,""+t):r.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=Lr(this.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 u=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),c=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),l=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.device.createInputState(u,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),l?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,c),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(c),e.setInputLayoutAndState(u,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=fn(on.OPAQUE,t[0].sortable.renderOrder)},r.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];n instanceof t.CSSRGB&&(a=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]);var s=[0,0,0,0];i instanceof t.CSSRGB&&(s=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)]),o.push.apply(o,a.concat(s))})),this.geometry.updateVertexBuffer(Kn.FILL_STROKE,zn.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===Qn}));if(a instanceof t.CSSRGB)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 c=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor,n=t.increasedLineWidthForHitTesting;c.push(t.opacity.value,t.fillOpacity.value,t.strokeOpacity.value,t.lineWidth.value,"visible"===t.visibility.value?1:0,r[0].value,r[1].value,(null==n?void 0:n.value)||0)})),this.geometry.updateVertexBuffer(Kn.PACKED_STYLE,zn.PACKED_STYLE1,r,new Uint8Array(new Float32Array(c).buffer))}else if("modelMatrix"===n){var l=[];e.forEach((function(e){var t=pe(de(),e.getWorldTransform());l.push.apply(l,t)})),this.geometry.updateVertexBuffer(Kn.MODEL_MATRIX,zn.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(l).buffer))}else if("pointerEvents"===n){var f=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];f.push.apply(f,r.concat([e.sortable.renderOrder*Wn]))})),this.geometry.updateVertexBuffer(Kn.PICKING_COLOR,zn.PICKING_COLOR,r,new Uint8Array(new Float32Array(f).buffer))}},r.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)},r.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(Kn.PICKING_COLOR,zn.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(i,[t*Wn])).buffer))},r.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Kn.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride/4*r)}for(var o=0,a=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],c=1;e.vertices.length>c;c++)for(var l=e.inputLayoutDescriptor.vertexBufferDescriptors[c].byteStride/4,f=0;l>f;f++)e.vertices[c][o*l+f]=n[c][u*l+f];a[s]=o,o++}for(var h=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]})},d=Kn.PICKING_COLOR+1;e.vertexBuffers.length>d;d++)h(d);for(var p=new Float32Array(3*r),_=0;r>_;)for(var v=0;3>v;v++){p[3*a[_++]+v]=1}e.setVertexBuffer({bufferIndex:Kn.BARYCENTRIC,byteStride:12,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RGB,bufferByteOffset:0,location:Number(zn.BARYCENTRIC)}],data:p}),e.setIndexBuffer(a)},r.beforeUploadUBO=function(e,t,r){},r.uploadUBO=function(e){var r=this,n=this.material,i=this.lightPool.getAllLights(),o=this.lightPool.getFog(),a=!!o,s=!!i.length,u=[];if(n.defines.USE_WIREFRAME){var c=t.parseColor(n.wireframeColor);u.push({name:"u_WireframeLineColor",value:[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255]}),u.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(a&&this.uploadFog(u,o),this.uploadMaterial(u,n),s){var l={};i.forEach((function(e){l[e.define]||(l[e.define]=-1),l[e.define]++,e.uploadUBO(u,l[e.define])}))}u.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,u);var f=n.blendEquation,h=n.blendEquationAlpha,d=n.blendSrc,p=n.blendDst,_=n.blendSrcAlpha,v=n.blendDstAlpha,E=qn({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}),g=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(ne({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Ue.None:Ue.AllChannels,rgbBlendState:ne({},g.rgbBlendState,qn({blendMode:f,blendSrcFactor:d,blendDstFactor:p})),alphaBlendState:ne({},g.alphaBlendState,qn({blendMode:h,blendSrcFactor:_,blendDstFactor:v}))}]},E)),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},r.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(o instanceof t.CSSRGB){var c=[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:c})}},r.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,r)},r.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.device,r,ze(Ye.U8_RGBA_NORM,1,1,1));if(a){var s=new Ln;return s.name=Qn,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:Ie.Repeat,wrapT:Ie.Repeat,minFilter:Ne.Point,magFilter:Ne.Bilinear,mipFilter:xe.Linear,minLOD:0,maxLOD:0}),s}}return null},re(e,[{key:"instance",get:function(){return this.objects[0]}}]),e}();a([t.inject(Cn),s("design:type",Cn)],Jn.prototype,"renderHelper",void 0),a([t.inject(Fn),s("design:type",Fn)],Jn.prototype,"texturePool",void 0),a([t.inject(t.DefaultCamera),s("design:type",t.Camera)],Jn.prototype,"camera",void 0),a([t.inject(Q),s("design:type",Q)],Jn.prototype,"lightPool",void 0),Jn=a([t.injectable()],Jn);var $n,ei;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}($n||($n={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(ei||(ei={}));var ti=[t.Shape.CIRCLE,t.Shape.ELLIPSE],ri=function(e){function r(){return e.apply(this,arguments)||this}ie(r,e);var n=r.prototype;return n.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);return!!n&&(!this.needDrawStrokeSeparately(t.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&this.instance.parsedStyle.fill.isNone===t.parsedStyle.fill.isNone)},n.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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\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 vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 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 * 0.5 + 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 antialiasblur = 1.0 / (a_Size.x + strokeWidth);\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) * radius;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\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 vec4 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\nvoid main() {\n int shape = int(floor(v_Data.w + 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;\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(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\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 // vec2 imagecoord = mod(v_Uv, 0.1);\n // vec4 texel = texture(SAMPLER_2D(u_Map), imagecoord);\n // u_Color = texel;\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=ne({},this.material.defines,jn(ei))},n.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,c=r.shouldOmitStroke(a.parsedStyle),l=r.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,l.concat([ti.indexOf(a.nodeName),u||0,c?1:0,0])),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:Kn.POSITION,byteStride:16,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:zn.POSITION},{format:Ye.F32_RG,bufferByteOffset:8,location:zn.UV}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:$n.PACKED_STYLE,byteStride:24,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:ei.SIZE,divisor:1},{format:Ye.F32_RGBA,bufferByteOffset:8,location:ei.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})},n.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||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n){var a=[];t.forEach((function(e){var t=o.shouldOmitStroke(e.parsedStyle),r=o.getSize(e.parsedStyle,e.nodeName);a.push.apply(a,[r[0],r[1]].concat([ti.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer($n.PACKED_STYLE,ei.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}},n.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i.value,i.value]}else if(r===t.Shape.ELLIPSE){n=[e.rx.value,e.ry.value]}return n},n.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.value}));return!i||i&&(o||1>n.value)},n.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.value}));return o&&n.value>0&&(a||1>i.value)},r}(Jn);ri=a([t.injectable()],ri);var ni,ii,oi=[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"}(ni||(ni={})),function(e){e[e.POSITION=9]="POSITION",e[e.UV=11]="UV",e[e.POINTA=10]="POINTA",e[e.POINTB=12]="POINTB",e[e.CAP=13]="CAP",e[e.DASH=14]="DASH"}(ii||(ii={}));var ai={butt:1,round:2,square:3},si=function(e){function r(){return e.apply(this,arguments)||this}ie(r,e);var n=r.prototype;return n.shouldMerge=function(r,n){var i=e.prototype.shouldMerge.call(this,r,n);if(!i)return!1;var o=this.instance;if(o.nodeName===t.Shape.LINE){var a=r.parsedStyle.stroke;if(o.parsedStyle.stroke.toString()!==a.toString())return!1}return!0},n.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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\n// out vec2 v_Normal;\n\nvoid main() {\n mat4 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 * 0.5 + 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 if (isBillboard < 0.5) {\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\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\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 }\n\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;\n// in vec2 v_Normal;\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 = 1. - smoothstep(0.98, 1., length(v_Normal));\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 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=ne({},this.material.defines,jn(ii))},n.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[],o=[],a=[],s=0;t.forEach((function(e){var t=e.parsedStyle,u=t.x1,c=t.y1,l=t.x2,f=t.y2,h=t.z1,d=t.z2,p=t.defX,_=t.defY,v=t.lineCap,E=t.isBillboard,g=r.calcDash(e),m=g.dashOffset,R=g.dashSegmentPercent,y=g.dashRatioInEachSegment;i.push(ai[v.value]),o.push(m,R,y,E?1:0),n.push(u.value-p,c.value-_,h.value,l.value-p,f.value-_,d.value),a.push(0+s,2+s,1+s,0+s,3+s,2+s),s+=4})),this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Kn.POSITION,byteStride:20,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGB,bufferByteOffset:0,location:ii.POSITION,divisor:0},{format:Ye.F32_RG,bufferByteOffset:12,location:ii.UV,divisor:0}],data:new Float32Array(oi)}),this.geometry.setVertexBuffer({bufferIndex:ni.POINT,byteStride:24,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGB,bufferByteOffset:0,location:ii.POINTA,divisor:1},{format:Ye.F32_RGB,bufferByteOffset:12,location:ii.POINTB,divisor:1}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:ni.CAP,byteStride:4,frequency:Be.PerInstance,attributes:[{format:Ye.F32_R,bufferByteOffset:0,location:ii.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ni.DASH,byteStride:16,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:ii.DASH,divisor:1}],data:new Float32Array(o)})},n.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),"x1"===n||"y1"===n||"x2"===n||"y2"===n||"z1"===n||"z2"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle,r=t.defX,n=t.defY;a.push(t.x1.value-r,t.y1.value-n,t.z1.value,t.x2.value-r,t.y2.value-n,t.z2.value)})),this.geometry.updateVertexBuffer(ni.POINT,ii.POINTA,r,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===n||"lineDash"===n){var s=[];t.forEach((function(e){var t=o.calcDash(e);s.push(t.dashOffset,t.dashSegmentPercent,t.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(ni.DASH,ii.DASH,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineCap"===n){var u=[];t.forEach((function(e){u.push(ai[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(ni.CAP,ii.CAP,r,new Uint8Array(new Float32Array(u).buffer))}},n.calcDash=function(e){var t=e.parsedStyle,r=t.lineDash,n=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,s=0;if(r&&r.length){o=(n&&n.value||0)/i;var u=r.reduce((function(e,t){return e+t.value}),0);a=u/i,s=r[1].value/u}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:s}},r}(Jn);function ui(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}si=a([t.injectable()],si);var ci=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function li(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function fi(e,t,r,n,i,o,a,s,u){var c=li(e,r,i,a,u),l=li(t,n,o,s,u),f=ci(e,t,r,n,u),h=ci(r,n,i,o,u),d=ci(i,o,a,s,u),p=ci(f.x,f.y,h.x,h.y,u),_=ci(h.x,h.y,d.x,d.y,u);return[[e,t,f.x,f.y,p.x,p.y,c,l],[c,l,_.x,_.y,d.x,d.y,a,s]]}function hi(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+=ui(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var c=fi(e,t,r,n,i,o,a,s,.5),l=[].concat(c[0],[u-1]),f=[].concat(c[1],[u-1]);return hi.apply(void 0,l)+hi.apply(void 0,f)}var di,pi=function(e,t,r,n,i,o,a,s){return hi(e,t,r,n,i,o,a,s,3)};!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"}(di||(di={}));var _i,vi,Ei;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(_i||(_i={})),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"}(vi||(vi={})),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 gi=function(e){function r(){return e.apply(this,arguments)||this}ie(r,e);var n=r.prototype;return n.shouldMerge=function(e,t){return!1},n.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r=e.parsedStyle,n=r.stroke,s=r.opacity,u=r.fillOpacity,c=r.strokeOpacity,l=r.lineWidth,f=r.increasedLineWidthForHitTesting,h=r.anchor,d=r.lineDash,p=r.lineDashOffset,_=r.visibility;if("lineJoin"===i||"lineCap"===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 v,E=[0,0,0,0];n instanceof t.CSSRGB&&(E=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(((v={})[Ei.STROKE_COLOR]=E,v))}else if("opacity"===i){var g;a.material.setUniforms(((g={})[Ei.OPACITY]=s.value,g))}else if("fillOpacity"===i){var m;a.material.setUniforms(((m={})[Ei.FILL_OPACITY]=u.value,m))}else if("strokeOpacity"===i){var R;a.material.setUniforms(((R={})[Ei.STROKE_OPACITY]=c.value,R))}else if("lineWidth"===i){var y;a.material.setUniforms(((y={})[Ei.STROKE_WIDTH]=l.value,y))}else if("increasedLineWidthForHitTesting"===i){var T;a.material.setUniforms(((T={})[Ei.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=f.value,T))}else if("anchor"===i||"modelMatrix"===i){var A,S=0,C=0,O=e.getGeometryBounds();if(O){var I=O.halfExtents;S=-I[0]*h[0].value*2,C=-I[1]*h[1].value*2}var N=de();Ee(N,e.getWorldTransform(),ve(N,ge(S,C,0))),a.material.setUniforms(((A={})[Ei.MODEL_MATRIX]=N,A))}else if("visibility"===i){var x;a.material.setUniforms(((x={})[Ei.VISIBLE]="visible"===_.value?1:0,x))}else if("lineDash"===i){var P;a.material.setUniforms(((P={})[Ei.DASH]=d[0].value||0,P[Ei.GAP]=d[1].value||0,P))}else if("lineDashOffset"===i){var D;a.material.setUniforms(((D={})[Ei.DASH_OFFSET]=p&&p.value||0,D))}else if("pointerEvents"===i){var M,B,L=o&&e.isInteractive()&&(null===(M=e.renderable3D)||void 0===M?void 0:M.encodedPickingColor)||[0,0,0];a.material.setUniforms(((B={})[Ei.PICKING_COLOR]=L,B))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ei.Z_INDEX]=t*Wn,r))},n.createMaterial=function(e){var r,n,i,o;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 travel = mod(v_Travel + u_Gap * 0.5 + u_DashOffset, u_Dash + u_Gap) - (u_Gap * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap + 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=ne({},this.material.defines,jn(vi));var a=e[0],s=a.parsedStyle,u=s.fill,c=s.stroke,l=s.opacity,f=s.fillOpacity,h=s.strokeOpacity,d=s.lineWidth,p=s.increasedLineWidthForHitTesting,_=s.anchor,v=s.lineDash,E=s.lineDashOffset,g=s.visibility,m=[0,0,0,0];u instanceof t.CSSRGB&&(m=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var R=[0,0,0,0];c instanceof t.CSSRGB&&(R=[Number(c.r)/255,Number(c.g)/255,Number(c.b)/255,Number(c.alpha)]);var y=a.isInteractive()&&(null===(r=a.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],T=0,A=0,S=a.getGeometryBounds();if(S){var C=S.halfExtents;T=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=de();Ee(O,a.getWorldTransform(),ve(O,ge(T,A,0))),this.material.setUniforms(((o={})[Ei.MODEL_MATRIX]=O,o[Ei.FILL_COLOR]=m,o[Ei.STROKE_COLOR]=R,o[Ei.STROKE_WIDTH]=d.value,o[Ei.INCREASED_LINE_WIDTH_FOR_HIT_TESTING]=p.value,o[Ei.OPACITY]=l.value,o[Ei.FILL_OPACITY]=f.value,o[Ei.STROKE_OPACITY]=h.value,o[Ei.EXPAND]=1,o[Ei.MITER_LIMIT]=5,o[Ei.SCALE_MODE]=1,o[Ei.ALIGNMENT]=.5,o[Ei.PICKING_COLOR]=y,o[Ei.DASH]=v&&(null===(n=v[0])||void 0===n?void 0:n.value)||0,o[Ei.GAP]=v&&(null===(i=v[1])||void 0===i?void 0:i.value)||0,o[Ei.DASH_OFFSET]=E&&E.value||0,o[Ei.VISIBLE]="visible"===g.value?1:0,o[Ei.Z_INDEX]=a.sortable.renderOrder*Wn,o)),this.material.cullMode=Se.None},n.createGeometry=function(e){var t=yi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:_i.PACKED,byteStride:48,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,byteStride:12,location:vi.PREV,divisor:1},{format:Ye.F32_RG,bufferByteOffset:12,byteStride:12,location:vi.POINT1,divisor:1},{format:Ye.F32_R,bufferByteOffset:20,byteStride:12,location:vi.VERTEX_JOINT,divisor:1},{format:Ye.F32_RG,bufferByteOffset:24,byteStride:12,location:vi.POINT2,divisor:1},{format:Ye.F32_RG,bufferByteOffset:36,byteStride:12,location:vi.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:_i.VERTEX_NUM,byteStride:4,frequency:Be.PerInstance,attributes:[{format:Ye.F32_R,bufferByteOffset:0,byteStride:4,location:vi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:_i.TRAVEL,byteStride:4,frequency:Be.PerInstance,attributes:[{format:Ye.F32_R,bufferByteOffset:0,byteStride:4,location:vi.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}(Jn);function mi(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var c=function(e,t){var r=Math.ceil(e/10);8>r?r=8:r>Ri&&(r=Ri);return r}(pi(s,u,e,t,r,n,i,o)),l=0,f=0,h=0,d=0,p=0;a.push(s,u);for(var _=1,v=0;c>=_;++_)a.push((h=(f=(l=1-(v=_/c))*l)*l)*s+3*f*v*e+3*l*(d=v*v)*r+(p=d*v)*i,h*u+3*f*v*t+3*l*d*n+p*o)}gi=a([t.injectable()],gi);var Ri=2048;function yi(e,r){void 0===r&&(r=!1);var n=e.parsedStyle,i=n.lineCap,o=n.lineJoin,a=e.parsedStyle,s=a.defX,u=a.defY,c=[],l=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){if(c=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-s,t[1]-u),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return l=g(c,[],2),{pointsBuffer:c,travelBuffer:[],triangles:l,instancedCount:Math.round(c.length/2)};var f;c.push(c[0],c[1]),(f=c).push.apply(f,Ti(c[0],c[1],c[2],c[3]))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var h;if(e.nodeName!==t.Shape.PATH){if(h=t.parsePath(t.convertToPath(e,!1),e),s=h.rect.x,u=h.rect.y,e.nodeName===t.Shape.RECT){var d=e.parsedStyle;0>d.width.value&&(s+=h.rect.width),0>d.height.value&&(u+=h.rect.height)}}else h=e.parsedStyle.path;var p=h.zCommandIndexes,_=[].concat(h.curve).map((function(e,t){return p.includes(t)?["Z"]:e})),v=-1;if(_.forEach((function(r){var n=r[0],i=r.slice(1);if("M"===n)v=c.length,c.push(i[0]-s,i[1]-u);else if("C"===n)mi(i[0]-s,i[1]-u,i[2]-s,i[3]-u,i[4]-s,i[5]-u,c);else if("Z"===n&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var o,a=1e-4;(Math.abs(c[c.length-2]-c[v])>a||Math.abs(c[c.length-1]-c[v+1])>a)&&c.push(c[v],c[v+1]),(o=c).push.apply(o,Ti(c[v],c[v+1],c[v+2],c[v+3]))}})),r)return l=g(c,[],2),{pointsBuffer:c,travelBuffer:[],triangles:l,instancedCount:Math.round(c.length/2)}}var E=function(e){var t;switch(e){case"bevel":t=di.JOINT_BEVEL;break;case"round":t=di.JOINT_ROUND;break;default:t=di.JOINT_MITER}return t}(o.value),m=function(e){var t;switch(e){case"square":t=di.CAP_SQUARE;break;case"round":t=di.CAP_ROUND;break;default:t=di.CAP_BUTT}return t}(i.value),R=m;m===di.CAP_ROUND&&(R=di.JOINT_CAP_ROUND),m===di.CAP_BUTT&&(R=di.JOINT_CAP_BUTT),m===di.CAP_SQUARE&&(R=di.JOINT_CAP_SQUARE);for(var y=3*(Math.round(0)+2),T=0,A=[],S=[],C=0;c.length>C;C+=2)C>1&&(T+=Math.sqrt(Math.pow(c[C]-c[C-2],2)+Math.pow(c[C+1]-c[C+1-2],2))),S.push(T),A[y++]=c[C],A[y++]=c[C+1],A[y]=E,0==C&&m!==di.CAP_ROUND&&(A[y]+=m),c.length>C+4?c.length>C+2||(A[y]=0):A[y]+=R-E,y++;return A[y++]=c[c.length-4],A[y++]=c[c.length-3],A[y++]=0,A[0]=c[0],A[1]=c[1],A[2]=0,A[3]=c[2],A[4]=c[3],A[5]=m===di.CAP_ROUND?m:0,{pointsBuffer:A,travelBuffer:S,triangles:l,instancedCount:Math.round(c.length/2)}}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 Ai=function(e){function r(){return e.apply(this,arguments)||this}ie(r,e);var n=r.prototype;return n.shouldMerge=function(e,t){return!1},n.createGeometry=function(e){var t=e[0],r=yi(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:Kn.POSITION,byteStride:8,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:zn.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:Kn.UV,byteStride:8,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:zn.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))},n.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,c=o.anchor,l=o.visibility,f=[0,0,0,0];a instanceof t.CSSRGB&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var h=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],d=0,p=0,_=i.getGeometryBounds();if(_){var v=_.halfExtents;d=-v[0]*c[0].value*2,p=-v[1]*c[1].value*2}var E=de();Ee(E,i.getWorldTransform(),ve(E,ge(d,p,0))),this.material.setUniforms(((n={})[Ei.MODEL_MATRIX]=E,n[Ei.FILL_COLOR]=f,n[Ei.PICKING_COLOR]=h,n[Ei.OPACITY]=s.value,n[Ei.FILL_OPACITY]=u.value,n[Ei.VISIBLE]="visible"===l.value?1:0,n[Ei.Z_INDEX]=i.sortable.renderOrder*Wn,n))},n.updateAttribute=function(r,n,i,o){var a=this;e.prototype.updateAttribute.call(this,r,n,i,o),r.forEach((function(e){var r=e.parsedStyle,n=r.fill,s=r.opacity,u=r.fillOpacity,c=r.anchor,l=r.visibility;if("lineJoin"===i||"lineCap"===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(n instanceof t.CSSRGB){var f,h=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)];a.material.setUniforms(((f={})[Ei.FILL_COLOR]=h,f))}else{var d=a.textureMappings.findIndex((function(e){return e.name===Qn})),p=a.createFillGradientTextureMapping([a.instance]);0>d||a.textureMappings.splice(d,1,p),a.material.textureDirty=!0}else if("opacity"===i){var _;a.material.setUniforms(((_={})[Ei.OPACITY]=s.value,_))}else if("fillOpacity"===i){var v;a.material.setUniforms(((v={})[Ei.FILL_OPACITY]=u.value,v))}else if("anchor"===i||"modelMatrix"===i){var E,g=0,m=0,R=e.getGeometryBounds();if(R){var y=R.halfExtents;g=-y[0]*c[0].value*2,m=-y[1]*c[1].value*2}var T=de();Ee(T,e.getWorldTransform(),ve(T,ge(g,m,0))),a.material.setUniforms(((E={})[Ei.MODEL_MATRIX]=T,E))}else if("visibility"===i){var A;a.material.setUniforms(((A={})[Ei.VISIBLE]="visible"===l.value?1:0,A))}else if("pointerEvents"===i){var S,C,O=o&&e.isInteractive()&&(null===(S=e.renderable3D)||void 0===S?void 0:S.encodedPickingColor)||[0,0,0];a.material.setUniforms(((C={})[Ei.PICKING_COLOR]=O,C))}}))},n.changeRenderOrder=function(e,t){var r;this.material&&this.material.setUniforms(((r={})[Ei.Z_INDEX]=t*Wn,r))},r}(Jn);Ai=a([t.injectable()],Ai);var Si=function(e){function t(){return e.apply(this,arguments)||this}ie(t,e);var r=t.prototype;return r.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);return!!n&&this.instance.parsedStyle.img===t.parsedStyle.img},r.createMaterial=function(e){var t=e[0].parsedStyle.img;this.material.defines=ne({},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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\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 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.device,t);this.material.setUniforms({u_Map:r})},r.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.value,a.height.value),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:Kn.POSITION,byteStride:8,frequency:Be.PerInstance,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:zn.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Kn.UV,byteStride:8,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:zn.UV}],data:new Float32Array(n)})},r.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){var o=[];t.forEach((function(e){var t=e.parsedStyle;o.push(t.width.value,t.height.value)})),this.geometry.updateVertexBuffer(Kn.POSITION,zn.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.device,i);this.material.setUniforms({u_Map:a})}},t}(Jn);Si=a([t.injectable()],Si);function Ci(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 Oi(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 c=((r.y+u)*e.width+r.x)*o,l=((n.y+u)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[l+f]=a[c+f];return t}var Ii=function(){function e(e,t){this.width=void 0,this.height=void 0,this.data=void 0,Ci(this,e,1,t)}var t=e.prototype;return t.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Ci({},{width:n,height:i},r);Oi(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)},t.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){Oi(e,t,r,n,i,1)},e}();var Ni=function(e){this.image=void 0,this.positions=void 0;var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i){if((c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height)r.push(l={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:l,metrics:c.metrics}}}var s=function(e){for(var t,r=0,n=0,i=ce(e);!(t=i()).done;){var o=t.value;r+=o.w*o.h,n=Math.max(n,o.w)}e.sort((function(e,t){return t.h-e.h}));for(var a,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,c=0,l=ce(e);!(a=l()).done;)for(var f=a.value,h=s.length-1;h>=0;h--){var d=s[h];if(d.w>=f.w&&d.h>=f.h){if(f.x=d.x,f.y=d.y,c=Math.max(c,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===d.w&&f.h===d.h){var p=s.pop();s.length>h&&(s[h]=p)}else f.h===d.h?(d.x+=f.w,d.w-=f.w):f.w===d.w?(d.y+=f.h,d.h-=f.h):(s.push({x:d.x+f.w,y:d.y,w:d.w-f.w,h:f.h}),d.y+=f.h,d.h-=f.h);break}}return{w:u,h:c,fill:r/(u*c)||0}}(r),u=new Ii({width:s.w||1,height:s.h||1});for(var n in e){i=e[n];for(var a in i){var c,l;if((c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height)Ii.copy(c.bitmap,u,{x:0,y:0},{x:(l=t[n][a].rect).x+1,y:l.y+1},c.bitmap)}}this.image=u,this.positions=t};var xi,Pi,Di,Mi=function(){function e(){this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}var t=e.prototype;return t.getMap=function(){return this.glyphMap},t.getAtlas=function(){return this.glyphAtlas},t.getAtlasTexture=function(){return this.glyphAtlasTexture},t.layout=function(e,t,r,n,i,o,a){var s=this,u=[],c=o,l=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:c,y:l,scale:1,fontStack:t}),c+=o.metrics.advance+i)}));for(var o=c-i,a=n;u.length>a;a++)u[a].x=u[a].x-f*o;c=0,l+=r})),u},t.generateAtlas=function(e,t,r,n,i,o){var a=this;void 0===e&&(e=""),void 0===n&&(n="");var s=[];this.glyphMap[e]||(s=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var u=Object.keys(this.glyphMap[e]||{});if(Array.from(new Set(i.split(""))).forEach((function(e){-1===u.indexOf(e.charCodeAt(0).toString())&&s.push(e)})),s.length){var c=s.map((function(i){return a.generateSDF(e,t,r,n,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[e]=ne({},this.glyphMap[e],c),this.glyphAtlas=new Ni(this.glyphMap);var l=this.glyphAtlas.image,f=l.width,h=l.height,d=l.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=o.createTexture(ne({},ze(Ye.ALPHA,f,h,1),{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([d],0)}},t.generateSDF=function(e,t,r,n,i){void 0===e&&(e="");var o=i.charCodeAt(0),a=this.sdfGeneratorCache[e];a||(a=this.sdfGeneratorCache[e]=new K({fontSize:24,fontFamily:t,fontWeight:r,fontStyle:n,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[e]||(this.textMetricsCache[e]={}),this.textMetricsCache[e][i]||(this.textMetricsCache[e][i]=a.ctx.measureText(i).width);var s=a.draw(i),u=s.glyphWidth,c=s.glyphHeight,l=s.glyphLeft,f=s.glyphTop,h=s.glyphAdvance;return{id:o,bitmap:new Ii({width:s.width,height:s.height},s.data),metrics:{width:u,height:c,left:l,top:f-24+3,advance:h}}},e}();Mi=a([t.injectable()],Mi),function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(xi||(xi={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(Pi||(Pi={})),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"}(Di||(Di={}));var Bi=function(e){function r(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).glyphManager=void 0,t}ie(r,e);var n=r.prototype;return n.shouldMerge=function(t,r){var n=e.prototype.shouldMerge.call(this,t,r);if(!n)return!1;if(this.index!==r)return!1;var i=this.instance;return i.parsedStyle.fontSize.value===t.parsedStyle.fontSize.value&&(i.parsedStyle.metrics.font===t.parsedStyle.metrics.font&&!["fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(e){return i.parsedStyle[e]!==t.parsedStyle[e]})))},n.createGeometry=function(e){var r=this,n=this.instance.parsedStyle,i=n.textBaseline,o=n.letterSpacing,a=void 0===o?0:o,s=24/n.fontSize.value,u=[],c=[],l=[],f=0;e.forEach((function(e){var n=e.parsedStyle,o=n.metrics,h=n.dx,d=n.dy,p=o.font,_=o.lines,v=o.height,E=o.lineHeight,g=0,m=0;h&&h.unit===t.UnitType.kPixels&&(g+=h.value),d&&d.unit===t.UnitType.kPixels&&(m+=d.value);var R=0;"middle"===i.value?R=-v/2:"bottom"===i.value?R=-v:"top"===i.value||"hanging"===i.value?R=0:"alphabetic"===i.value?R=.25*E-v:"ideographic"===i.value&&(R=-v);var y=r.glyphManager.getAtlas(),T=r.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:s*E,offsetX:s*g,offsetY:s*(R+m),letterSpacing:s*a,glyphAtlas:y,indicesOffset:f}),A=T.indexBuffer,S=T.charUVOffsetBuffer;f=T.indicesOffset,l.push.apply(l,T.charPackedBuffer),c.push.apply(c,S),u.push.apply(u,A)})),this.geometry.vertexCount=u.length,this.geometry.setIndexBuffer(new Uint32Array(u)),this.geometry.setVertexBuffer({bufferIndex:xi.INSTANCED,byteStride:144,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RGBA,bufferByteOffset:0,location:zn.MODEL_MATRIX0},{format:Ye.F32_RGBA,bufferByteOffset:16,location:zn.MODEL_MATRIX1},{format:Ye.F32_RGBA,bufferByteOffset:32,location:zn.MODEL_MATRIX2},{format:Ye.F32_RGBA,bufferByteOffset:48,location:zn.MODEL_MATRIX3},{format:Ye.F32_RGBA,bufferByteOffset:64,location:zn.COLOR},{format:Ye.F32_RGBA,bufferByteOffset:80,location:zn.STROKE_COLOR},{format:Ye.F32_RGBA,bufferByteOffset:96,location:zn.PACKED_STYLE1},{format:Ye.F32_RGBA,bufferByteOffset:112,location:zn.PACKED_STYLE2},{format:Ye.F32_RGBA,bufferByteOffset:128,location:zn.PICKING_COLOR}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:xi.TEX,byteStride:16,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:Pi.TEX},{format:Ye.F32_RG,bufferByteOffset:8,location:Pi.OFFSET}],data:new Float32Array(c)})},n.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(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\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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n v_UV = a_Tex / u_SDFMapSize;\n\n float fontScale = u_FontSize / 24.;\n\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}",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 vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin vec2 v_UV;\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=Se.Back,this.material.defines=ne({},this.material.defines,jn(Pi));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=r.fontStyle,u=r.metrics.font,c=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(u,o,a.toString(),s.toString(),c,this.device);var l=this.glyphManager.getAtlasTexture(),f=this.glyphManager.getAtlas();this.device.setResourceName(l,"TextSDF Texture");var h=f.image,d=h.width,p=h.height;this.material.setUniforms(((t={})[Di.SDF_MAP]=l,t[Di.SDF_MAP_SIZE]=[d,p],t[Di.FONT_SIZE]=n.value,t[Di.GAMMA_SCALE]=1,t[Di.STROKE_BLUR]=.2,t[Di.HAS_STROKE]=this.index,t))},n.changeRenderOrder=function(e,t){this.material&&(this.material.programDirty=!0,this.material.geometryDirty=!0)},n.updateAttribute=function(e,t,r,n){"text"===r||"fontFamily"===r||"fontSize"===r||"fontWeight"===r||"fontStyle"===r||"fontVariant"===r||"textBaseline"===r||"letterSpacing"===r||"wordWrapWidth"===r||"lineHeight"===r||"wordWrap"===r||"textAlign"===r||"modelMatrix"===r||"visibility"===r||"dx"===r||"dy"===r?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==r&&"fillOpacity"!==r&&"stroke"!==r&&"strokeOpacity"!==r&&"opacity"!==r&&"lineWidth"!==r&&"visibility"!==r&&"pointerEvents"!==r||(this.material.geometryDirty=!0)},n.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,c=e.offsetY,l=e.glyphAtlas,f=e.indicesOffset,h=n.parsedStyle,d=h.textAlign,p=h.fill,_=h.stroke,v=h.opacity,E=h.fillOpacity,g=h.strokeOpacity,m=h.lineWidth,R=h.visibility,y=[0,0,0,0];p instanceof t.CSSRGB&&(y=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]);var T=[0,0,0,0];_ instanceof t.CSSRGB&&(T=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=pe(de(),n.getWorldTransform()),C=[],O=[],I=[],N=f,x=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,c=[i.x+u,i.y],l=(a.metrics.left-4)*i.scale-u+c[0],f=(-a.metrics.top-4)*i.scale+c[1],h=l+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:l,y:f},tr:{x:h,y:f},bl:{x:l,y:d},br:{x:h,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,d.value,s,u,c),l.positions);return x.forEach((function(e){var t=[];t.push.apply(t,S);var r=[].concat(t,y,T,[v.value,E.value,g.value,m.value,"visible"===R.value?1:0,0,0,0],A,[n.sortable.renderOrder*Wn]);C.push.apply(C,r.concat(r,r,r)),O.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),O.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),O.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),O.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),I.push(0+N,2+N,1+N),I.push(2+N,0+N,3+N),N+=4})),{indexBuffer:I,charUVOffsetBuffer:O,charPackedBuffer:C,indicesOffset:N}},r}(Jn);a([t.inject(Mi),s("design:type",Mi)],Bi.prototype,"glyphManager",void 0),Bi=a([t.injectable()],Bi);var Li=function(e){function r(){return e.apply(this,arguments)||this}ie(r,e);var n=r.prototype;return n.shouldMerge=function(r,n){var i=e.prototype.shouldMerge.call(this,r,n);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},n.updateAttribute=function(t,r,n,i){e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i)},n.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},n.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(Jn);Li=a([t.injectable()],Li);var bi=function(){function e(){}return e.prototype.update=function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}},e}();bi=a([t.singleton({token:{token:t.GeometryAABBUpdater,named:t.Shape.MESH}})],bi);var Fi=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}var t=e.prototype;return t.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},t.getById=function(e){return this.id2DisplayObjectMap[e]},t.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},t.decodePickingColor=function(e){return e[0]+256*e[1]+65536*e[2]-1},t.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}();Fi=a([t.singleton()],Fi);var Ui=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[ri,gi],t}ie(t,e);var r=t.prototype;return r.shouldSubmitRenderInst=function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)},r.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,c=i&&i.length&&i.every((function(e){return 0!==e.value}));return!s||u&&o.value>0&&(1>a.value||c)},t}(Hn);Ui=a([t.injectable({token:[{token:wn,named:t.Shape.CIRCLE},{token:wn,named:t.Shape.ELLIPSE}]})],Ui);var wi=function(e){function r(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Ai,gi],t}return ie(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,c=n.lineWidth,l=e.nodeName,f=o&&!o.isNone,h=u&&u.length&&u.every((function(e){return 0!==e.value}));if(0===r&&(e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(0===s.value||0===a.value||0===c.value||!f)return!1;if(l===t.Shape.CIRCLE||l===t.Shape.ELLIPSE)return h}return!0},r}(Hn);wi=a([t.injectable({token:[{token:wn,named:t.Shape.POLYLINE},{token:wn,named:t.Shape.PATH},{token:wn,named:t.Shape.POLYGON},{token:wn,named:t.Shape.RECT}]})],wi);var Gi=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[],t}return ie(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Hn);Gi=a([t.injectable({token:[{token:wn,named:t.Shape.GROUP}]})],Gi);var ki=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Si],t}return ie(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Hn);ki=a([t.injectable({token:[{token:wn,named:t.Shape.IMAGE}]})],ki);var Vi=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Bi,Bi],t}ie(t,e);var r=t.prototype;return r.shouldSubmitRenderInst=function(e,t){var r=e.parsedStyle,n=r.lineWidth;return!(!(r.stroke&&n&&n.value)&&0===t)},r.beforeUploadUBO=function(e,t,r){var n;t.material.setUniforms(((n={})[Di.HAS_STROKE]=1-t.index,n))},t}(Hn);Vi=a([t.injectable({token:[{token:wn,named:t.Shape.TEXT}]})],Vi);var Wi=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[si],t}return ie(t,e),t.prototype.shouldSubmitRenderInst=function(e,t){return!0},t}(Hn);Wi=a([t.injectable({token:{token:wn,named:t.Shape.LINE}})],Wi);var Xi=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).meshes=[Li],t}return ie(t,e),t}(Hn);Xi=a([t.injectable({token:[{token:wn,named:t.Shape.MESH}]})],Xi);var Hi=t.Syringe.defineToken("DeviceContribution"),ji=["style"],Yi=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=ae(n,ji);return e.call(this,ne({type:t.tag,style:ne({intensity:Math.PI},i)},o))||this}return ie(t,e),t}(t.DisplayObject);Yi.tag="light";var Ki,zi=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Ki||(Ki={}));var qi,Zi,Qi=function(e){function t(r){var n=void 0===r?{}:r,i=n.style,o=ae(n,zi);return e.call(this,ne({type:t.tag,style:ne({type:Ki.NONE,fill:"black",start:1,end:1e3,density:0},i)},o))||this}return ie(t,e),t}(t.DisplayObject);Qi.tag="fog";var Ji;!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"}(Ji||(Ji={}));var $i,eo,to=(qi=function(){function e(){this.canvasConfig=void 0,this.contextService=void 0,this.renderingContext=void 0,this.camera=void 0,this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.deviceContribution=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new Tn,picking:new Tn},this.builder=void 0}var r=e.prototype;return r.getDevice=function(){return this.device},r.getSwapChain=function(){return this.swapChain},r.getRenderLists=function(){return this.renderLists},r.apply=function(e){var r=this,n=function(e){var t=e.target;if(t.nodeName!==Yi.tag)if(t.nodeName!==Qi.tag){var n=new Z;t.renderable3D=n,r.batchManager.add(t)}else r.lightPool.addFog(t);else r.lightPool.addLight(t)},i=function(e){var t=e.target;t.nodeName!==Yi.tag?t.nodeName!==Qi.tag?(r.batchManager.remove(t),delete t.renderable3D):r.lightPool.removeFog(t):r.lightPool.removeLight(t)},o=function(e){r.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},a=function(e){r.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};e.hooks.init.tapPromise(Zi.tag,ee(J().mark((function s(){var u,c;return J().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a),r.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,u=r.contextService.getDomElement(),r.contextService.resize((c=r.canvasConfig).width,c.height),s.next=10,r.deviceContribution.createSwapChain(u);case 10:r.swapChain=s.sent,r.device=r.swapChain.getDevice(),r.renderHelper.setDevice(r.device),r.renderHelper.renderInstManager.disableSimpleMode(),r.swapChain.configureSwapChain(u.width,u.height),r.renderingContext.root.ownerDocument.defaultView.addEventListener(t.CanvasEvent.RESIZE,(function(){r.swapChain.configureSwapChain(u.width,u.height)})),r.batchManager.attach(r.device,e);case 17:case"end":return s.stop()}}),s)})))),e.hooks.destroy.tap(Zi.tag,(function(){r.renderHelper.destroy(),r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a)})),e.hooks.beginFrame.tap(Zi.tag,(function(){var e=r.swapChain.getCanvas(),n=r.renderHelper.renderInstManager;r.builder=r.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(r.canvasConfig.background),o=r.canvasConfig.background?ut(Number(i.r)/255*Number(i.alpha),Number(i.g)/255*Number(i.alpha),Number(i.b)/255*Number(i.alpha),Number(i.alpha)):ct,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:Nn.None},s=Bn(Qr.Color0,a,In(o)),u=Bn(Qr.DepthStencil,a,Dn),c=r.builder.createRenderTargetID(s,"Main Color"),l=r.builder.createRenderTargetID(u,"Main Depth");r.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Qr.Color0,c),e.attachRenderTargetID(Qr.DepthStencil,l),e.exec((function(e){r.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),r.builder.resolveRenderTargetToExternalTexture(c,r.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(Zi.tag,(function(){var e=r.renderHelper.renderInstManager,t=r.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(bt({depthWrite:!0,blendConstant:ct},{rgbBlendMode:Oe.Add,alphaBlendMode:Oe.Add,rgbBlendSrcFactor:Ce.SrcAlpha,alphaBlendSrcFactor:Ce.One,rgbBlendDstFactor:Ce.OneMinusSrcAlpha,alphaBlendDstFactor:Ce.OneMinusSrcAlpha}));var n=r.canvasConfig,i=n.width,o=n.height;t.setUniforms(0,[{name:Ji.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:Ji.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:Ji.CAMERA_POSITION,value:r.camera.getPosition()},{name:Ji.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:Ji.VIEWPORT,value:[i,o]},{name:Ji.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:Ji.IS_PICKING,value:0}]),r.batchManager.render(r.renderLists.world),e.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),e.resetRenderInsts(),r.swapChain.present()}))},r.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e}(),qi.tag="RenderGraph",Zi=qi);a([t.inject(t.CanvasConfig),s("design:type",Object)],to.prototype,"canvasConfig",void 0),a([t.inject(t.ContextService),s("design:type",Object)],to.prototype,"contextService",void 0),a([t.inject(t.RenderingContext),s("design:type",Object)],to.prototype,"renderingContext",void 0),a([t.inject(t.DefaultCamera),s("design:type",t.Camera)],to.prototype,"camera",void 0),a([t.inject(Cn),s("design:type",Cn)],to.prototype,"renderHelper",void 0),a([t.inject(Q),s("design:type",Q)],to.prototype,"lightPool",void 0),a([t.inject(Fn),s("design:type",Fn)],to.prototype,"texturePool",void 0),a([t.inject(Vn),s("design:type",Vn)],to.prototype,"batchManager",void 0),a([t.inject(Hi),s("design:type",Object)],to.prototype,"deviceContribution",void 0),to=Zi=a([t.singleton({contrib:t.RenderingPluginContribution})],to);var ro=($i=function(){function e(){this.canvasConfig=void 0,this.sceneGraphService=void 0,this.contextService=void 0,this.renderingContext=void 0,this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.camera=void 0,this.batchManager=void 0}var r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var t=e.target,n=t.renderable3D;if(n){var i=r.pickingIdGenerator.getId(t);n.pickingId=i,n.encodedPickingColor=r.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(eo.tag,ee(J().mark((function e(){return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(eo.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(eo.tag,function(){var e=ee(J().mark((function e(n){var i,o,a,s,u,c,l,f,h;return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.topmost,a=(o=n.position).viewportX,s=o.viewportY,u=r.contextService.getDPR(),l=r.canvasConfig.height*u,h=s*u,!((f=a*u)>(c=r.canvasConfig.width*u)||0>f||h>l||0>h)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,r.pickByRectangleInDepth(new t.Rectangle(t.clamp(Math.round(f),0,c-1),t.clamp(Math.round(h),0,l-1),1,1),i?1:100);case 12:return n.picked=e.sent,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())},r.pickByRectangleInDepth=function(){var e=ee(J().mark((function e(t,r){var n,i,o;return J().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===r&&(r=100),n=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,n);case 6:if(!(n=e.sent)){e.next=12;break}i++,o.push(n),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(n&&r>=i){e.next=4;break}case 14:return r>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},r.pickByRectangle=function(e,t){var r=this,n=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),s=e.x,u=e.y,c=e.width,l=e.height,f={backbufferWidth:c,backbufferHeight:l,antialiasingMode:Nn.None},h=Bn(Qr.Color0,f,In(ct)),d=a.createRenderTargetID(h,"Picking Color"),p=Bn(Qr.DepthStencil,f,Dn),_=a.createRenderTargetID(p,"Picking Depth"),v=ne({},this.camera.getView());return new Promise((function(e){r.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),a.pushPass((function(t){t.setDebugName("Picking Pass"),t.attachRenderTargetID(Qr.Color0,d),t.attachRenderTargetID(Qr.DepthStencil,_),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(Qr.Color0),o=n.createReadback();v&&v.enabled?r.camera.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):r.camera.clearViewOffset(),r.camera.setEnableUpdate(!0),o.readTexture(i,0,0,c,l,new Uint8Array(c*l*4)).then((function(t){var n,i=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(i=r.pickingIdGenerator.decodePickingColor(t)),i>-1){var a=r.pickingIdGenerator.getById(i);a&&a.isVisible()&&a.isInteractive()&&(n=a)}o.destroy(),e(n)}))}))}));var f=r.renderHelper.pushTemplateRenderInst();f.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),f.setMegaStateFlags(bt({depthWrite:!0},{rgbBlendMode:Oe.Add,rgbBlendSrcFactor:Ce.One,rgbBlendDstFactor:Ce.Zero,alphaBlendMode:Oe.Add,alphaBlendSrcFactor:Ce.One,alphaBlendDstFactor:Ce.Zero}));var h=r.canvasConfig,p=h.width,E=h.height,g=r.contextService.getDPR();r.camera.setEnableUpdate(!1),r.camera.setViewOffset(p*g,E*g,s,u,c,l),f.setUniforms(0,[{name:Ji.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:Ji.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:Ji.CAMERA_POSITION,value:r.camera.getPosition()},{name:Ji.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:Ji.VIEWPORT,value:[p,E]},{name:Ji.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:Ji.IS_PICKING,value:1}]),t&&r.batchManager.updateAttribute(t,"pointerEvents",!1,!0),r.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),o.resetRenderInsts()}))},e}(),$i.tag="WebGLPicker",eo=$i);a([t.inject(t.CanvasConfig),s("design:type",Object)],ro.prototype,"canvasConfig",void 0),a([t.inject(t.SceneGraphService),s("design:type",Object)],ro.prototype,"sceneGraphService",void 0),a([t.inject(t.ContextService),s("design:type",Object)],ro.prototype,"contextService",void 0),a([t.inject(t.RenderingContext),s("design:type",Object)],ro.prototype,"renderingContext",void 0),a([t.inject(Cn),s("design:type",Cn)],ro.prototype,"renderHelper",void 0),a([t.inject(to),s("design:type",to)],ro.prototype,"renderGraphPlugin",void 0),a([t.inject(Fi),s("design:type",Fi)],ro.prototype,"pickingIdGenerator",void 0),a([t.inject(t.DefaultCamera),s("design:type",t.Camera)],ro.prototype,"camera",void 0),a([t.inject(Vn),s("design:type",Vn)],ro.prototype,"batchManager",void 0),ro=eo=a([t.singleton({contrib:t.RenderingPluginContribution})],ro);var no,io,oo,ao="#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}",so="#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}",uo=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).vert=ao,t.frag=so,t.features={},t}return ie(t,e),t}(Ur),co="#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}",lo=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).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=ao,t.frag=co,t}return ie(t,e),t}(Ur),fo=At(1,(function(){return new Ln}));var ho,po,_o=t.Module((function(e){e(Cn),e(Fn),e(Q),e(Mi),e(Fi),e(Vn),e(to),e(ro),e(ri),e(si),e(gi),e(Ai),e(Si),e(Bi),e(Li),e({token:Gn,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(Ui),e(wi),e(ki),e(Wi),e(Vi),e(Xi),e({token:Un,useFactory:function(e){var t={};return function(r){return t[r]||e.container.isBoundNamed(wn,r)&&(t[r]=e.container.getNamed(wn,r)),t[r]||null}}})})),vo=function(){function e(){this.name="device-renderer",this.container=void 0}var r=e.prototype;return r.init=function(e){t.GlobalContainer.isBound(bi)||t.GlobalContainer.register(bi),this.container=e,e.load(_o,!0)},r.destroy=function(e){t.GlobalContainer.isBound(bi)&&t.GlobalContainer.remove(bi),e.unload(_o)},r.getDevice=function(){return this.container.get(to).getDevice()},r.loadTexture=function(e,t,r){return this.container.get(to).loadTexture(e,t,r)},e}(),Eo=Object.freeze({__proto__:null,get AntialiasingMode(){return Nn},get Batch(){return Hn},get BlendFactor(){return Ce},get BlendMode(){return Oe},get BufferFrequencyHint(){return Me},BufferGeometry:Nr,get BufferUsage(){return De},get ChannelWriteMask(){return Ue},get ClipSpaceNearZ(){return Ve},get CompareMode(){return Te},CopyProgram:uo,get CullMode(){return Se},DeviceContribution:Hi,DeviceProgram:Ur,DynamicUniformBuffer:wr,get Endianness(){return Ft},FILL_TEXTURE_MAPPING:Qn,get FillMesh(){return Ai},Fog:Qi,get FogType(){return Ki},get Format(){return Ye},get FormatCompFlags(){return He},get FormatFlags(){return je},get FormatTypeFlags(){return Xe},get FrontFaceMode(){return Ae},get GL(){return Ke},get GeometryEvent(){return Sr},HashMap:Xr,IdentityViewportCoords:en,get ImageMesh(){return Si},get Instanced(){return Jn},get InstancedLineMesh(){return si},IsDepthReversed:dt,get JOINT_TYPE(){return di},Light:Yi,get LineMesh(){return gi},Material:br,get MaterialEvent(){return Ir},Mesh:fe,get MeshMesh(){return Li},get MipFilterMode(){return xe},OpaqueBlack:lt,OpaqueWhite:ht,Plugin:vo,get PrimitiveTopology(){return Pe},get QueryPoolType(){return We},get RGAttachmentSlot(){return Qr},RenderCache:Jr,get RenderGraphPlugin(){return to},get RenderHelper(){return Cn},RenderInst:Rn,get RenderInstExecutionOrder(){return mn},get RenderInstFlags(){return vn},RenderInstList:Tn,RenderInstManager:Sn,Renderable3D:Z,get RendererLayer(){return on},get ResourceType(){return ye},get SDFMesh(){return ri},get SamplerFormatKind(){return Ge},ShaderMaterial:Fr,SingleSampledTexture:nn,get StencilOp(){return we},TemporalTexture:bn,get TexFilterMode(){return Ne},get TextMesh(){return Bi},get TextUniform(){return Di},get TextureDimension(){return be},get TextureEvent(){return Le},TextureMapping:Ln,get TexturePool(){return Fn},get TextureUsage(){return Fe},TransparentBlack:ct,TransparentWhite:ft,UNIFORM_SETTERS:Cr,get Uniform(){return Ei},get VertexAttributeBufferIndex(){return Kn},get VertexAttributeLocation(){return zn},get VertexBufferFrequency(){return Be},get ViewportOrigin(){return ke},get WrapMode(){return Ie},align:gt,alignNonPowerOfTwo:mt,arrayCopy:Gt,arrayEqual:wt,assert:nt,assertExists:it,bindingLayoutDescriptorCopy:nr,bindingLayoutDescriptorEqual:Wt,bindingLayoutSamplerDescriptorCopy:rr,bindingsDescriptorCopy:tr,bindingsDescriptorEquals:Xt,bisectRight:Rt,bufferBindingCopy:er,colorCopy:at,colorEqual:ot,colorNewCopy:st,colorNewFromRGBA:ut,compareDefines:Yn,compareDepthValues:function(e,t,r,n){if(void 0===n&&(n=dt),(r=pt(r,n))===Te.Less)return t>e;if(r===Te.LessEqual)return t>=e;if(r===Te.Greater)return e>t;if(r===Te.GreaterEqual)return e>=t;throw new Error("whoops")},containerModule:_o,copyAttachmentState:Ot,copyAttachmentStateFromSimple:Pt,copyMegaState:xt,defaultBindingLayoutSamplerDescriptor:Ut,defaultMegaState:Mt,definedProps:qn,enumToObject:jn,fallbackUndefined:_t,fillArray:Et,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:gn,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:Lt,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 et(Je(e))*Qe(e)},getFormatCompByteSize:tt,getFormatCompFlags:Qe,getFormatCompFlagsComponentCount:qe,getFormatComponentCount:function(e){return Qe(e)},getFormatFlags:$e,getFormatSamplerKind:rt,getFormatTypeFlags:Je,getFormatTypeFlagsByteSize:et,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 lr},getUniformSetter:function(e,t,r){var n=Cr[r.type];if(!n)throw new Error("Unknown GLSL uniform type "+r.type);return n().bind(null,e,t)},getUniforms:Dr,hashCodeNumberFinish:kr,hashCodeNumberUpdate:Gr,inputLayoutBufferDescriptorCopy:ar,inputLayoutBufferDescriptorEquals:Zt,inputLayoutDescriptorCopy:sr,inputLayoutDescriptorEquals:Qt,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:St,makeAttachmentClearDescriptor:In,makeBackbufferDescSimple:Bn,makeDepthKey:un,makeFormat:Ze,makeMegaState:Bt,makeSortKey:function(e,t){return void 0===t&&(t=0),e&on.TRANSLUCENT?dn(e):fn(e,t)},makeSortKeyOpaque:fn,makeSortKeyTranslucent:dn,makeStaticDataBuffer:Or,makeTextureDescriptor2D:ze,nArray:At,nullHashFunc:Vr,nullify:vt,opaqueBlackFullClearRenderPassDescriptor:Pn,opaqueWhiteFullClearRenderPassDescriptor:Dn,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(fr);if(!t||2>t.length)throw new Error("Failed to parse GLSL uniform name "+e);return{name:t[1],length:Number(t[2])||1,isArray:Boolean(t[2])}},prependLineNo:function(e,t){return void 0===t&&(t=1),e.split("\n").map((function(e,r){return St(""+(t+r),4," ")+" "+e})).join("\n")},preprocessProgramObj_GLSL:Lr,preprocessProgram_GLSL:Br,preprocessShader_GLSL:Mr,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Ve.NegativeOne?function(e){Ee(e,_n,e)}(e):t===Ve.Zero&&function(e){Ee(e,En,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Qr.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(Lt),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);gn(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new lo,c=t.renderCache.createProgram(u);a.setProgram(c),no||((no=new Nr(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:Be.PerVertex,attributes:[{format:Ye.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),no.vertexCount=3,oo=t.getCache().createInputLayout(no.inputLayoutDescriptor),io=t.getDevice().createInputState(oo,no.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,c)),i.exec((function(e,r){fo[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(fo),a.setInputLayoutAndState(oo,io),a.drawOnPass(t.renderCache,e)}))}))},range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:yn,renderPipelineDescriptorCopy:ir,renderPipelineDescriptorEquals:zt,reverseDepthForClearValue:function(e,t){return void 0===t&&(t=dt),t?1-e:e},reverseDepthForCompareMode:pt,reverseDepthForDepthOffset:function(e,t){return void 0===t&&(t=dt),t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e,t){void 0===t&&(t=dt),t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e,t){void 0===t&&(t=dt),t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:$t,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:Jt,segmentInstanceGeometry:oi,setAttachmentStateSimple:bt,setBackbufferDescSimple:Mn,setBitFlagEnabled:Tt,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:Nt,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=65536);var n=!!(e>>>31&1),i=un(t,n,r);return n?pn(e,i):hn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?pn(e,t):hn(e,t)},setSortKeyLayer:cn,setSortKeyOpaqueDepth:hn,setSortKeyProgramKey:ln,setSortKeyTranslucentDepth:pn,spliceBisectRight:yt,standardFullClearRenderPassDescriptor:xn,updateBuffer:yi,vertexAttributeDescriptorCopy:or,vertexAttributeDescriptorEquals:qt});function go(){
7
+ ce=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function fe(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function he(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){fe(o,n,i,a,s,"next",e)}function s(e){fe(o,n,i,a,s,"throw",e)}a(void 0)}))}}function de(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pe(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _e(e,t,r){return t&&pe(e.prototype,t),r&&pe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function ve(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ee(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ge(e,t)}function ye(e){return ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ye(e)}function ge(e,t){return ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ge(e,t)}function me(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;o.length>n;n++)0>t.indexOf(r=o[n])&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Re(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Te(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Re(e)}function Ae(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ye(e);if(t){var i=ye(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return Te(this,r)}}function Se(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ye(e)););return e}function Ce(){return Ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=Se(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},Ce.apply(this,arguments)}function Oe(e,t){return xe(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||De(e,t)||Me()}function Ie(e){return xe(e)||Pe(e)||De(e)||Me()}function Ne(e){return function(e){if(Array.isArray(e))return be(e)}(e)||Pe(e)||De(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xe(e){if(Array.isArray(e))return e}function Pe(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function De(e,t){if(e){if("string"==typeof e)return be(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?be(e,t):void 0}}function be(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function Me(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Be(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=De(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var Le=_e((function e(){de(this,e),this.pickingId=void 0,this.encodedPickingColor=void 0,this.meshes=[]}));Le.tag="c-renderable-3d";var Fe=function(){function e(){de(this,e),this.lights=[],this.fog=void 0}return _e(e,[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value:function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e}},{key:"sortLights",value:function(){this.lights.sort((function(e,t){return e.order-t.order}))}}]),e}();Fe=d([t.singleton()],Fe);var Ue=["style"],we=function(e){Ee(n,e);var r=Ae(n);function n(e){var i,o=e.style,a=me(e,Ue);return de(this,n),(i=r.call(this,le({type:t.Shape.MESH,style:le({x:"",y:"",z:"",lineWidth:0},o)},a))).cullable.enable=!1,i.style.geometry.meshes.push(Re(i)),i.style.material.meshes.push(Re(i)),i}return _e(n,[{key:"destroy",value:function(){Ce(ye(n.prototype),"destroy",this).call(this);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}]),n}(t.DisplayObject),ke="undefined"!=typeof Float32Array?Float32Array:Array;function Ge(){var e=new ke(16);return ke!=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 Ve(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 We(e,t,r,n,i,o,a,s,u,l,c,f,h,d,p,_){var v=new ke(16);return v[0]=e,v[1]=t,v[2]=r,v[3]=n,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=u,v[9]=l,v[10]=c,v[11]=f,v[12]=h,v[13]=d,v[14]=p,v[15]=_,v}function Xe(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 He=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],h=t[9],d=t[10],p=t[11],_=t[12],v=t[13],E=t[14],y=t[15],g=r[0],m=r[1],R=r[2],T=r[3];return e[0]=g*n+m*s+R*f+T*_,e[1]=g*i+m*u+R*h+T*v,e[2]=g*o+m*l+R*d+T*E,e[3]=g*a+m*c+R*p+T*y,e[4]=(g=r[4])*n+(m=r[5])*s+(R=r[6])*f+(T=r[7])*_,e[5]=g*i+m*u+R*h+T*v,e[6]=g*o+m*l+R*d+T*E,e[7]=g*a+m*c+R*p+T*y,e[8]=(g=r[8])*n+(m=r[9])*s+(R=r[10])*f+(T=r[11])*_,e[9]=g*i+m*u+R*h+T*v,e[10]=g*o+m*l+R*d+T*E,e[11]=g*a+m*c+R*p+T*y,e[12]=(g=r[12])*n+(m=r[13])*s+(R=r[14])*f+(T=r[15])*_,e[13]=g*i+m*u+R*h+T*v,e[14]=g*o+m*l+R*d+T*E,e[15]=g*a+m*c+R*p+T*y,e};function je(e,t,r){var n=new ke(3);return n[0]=e,n[1]=t,n[2]=r,n}var Ye,Ke;Ye=new ke(3),ke!=Float32Array&&(Ye[0]=0,Ye[1]=0,Ye[2]=0),Ke=Ye;var ze,qe,Ze,Qe,Je,$e,et,tt,rt,nt,it,ot,at,st,ut,lt,ct,ft,ht,dt,pt,_t,vt,Et,yt,gt,mt;!function(){var e=function(){var e=new ke(2);return ke!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function Rt(e,t,r,n){return{dimension:ut.n2D,pixelFormat:e,width:t,height:r,depth:1,numLevels:n,usage:lt.Sampled}}function Tt(e){return e}function At(e,t,r){return e<<16|t<<8|r}function St(e){return e>>>8&255}function Ct(e){return e>>>16&255}function Ot(e){return 255&e}function It(e){switch(e){case vt.F32:case vt.U32:case vt.S32:return 4;case vt.U16:case vt.S16:case vt.F16:return 2;case vt.U8:case vt.S8:return 1;default:throw Error("whoops")}}function Nt(e){return It(Ct(e))}function xt(e){var t=Ot(e);if(t&yt.Depth)return ht.Depth;if(t&yt.Normalized)return ht.Float;var r=Ct(e);if(r===vt.F16||r===vt.F32)return ht.Float;if(r===vt.U8||r===vt.U16||r===vt.U32)return ht.Uint;if(r===vt.S8||r===vt.S16||r===vt.S32)return ht.Sint;throw Error("whoops")}function Pt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e)throw console.error(Error().stack),Error("Assert fail: ".concat(t))}function Dt(e){if(null!=e)return e;throw Error("Missing object")}function bt(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a}function Mt(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}function Bt(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Lt(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{r:e,g:t,b:r,a:n}}!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"}(ze||(ze={})),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"}(qe||(qe={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(Ze||(Ze={})),function(e){e[e.None=0]="None",e[e.Front=1]="Front",e[e.Back=2]="Back",e[e.FrontAndBack=3]="FrontAndBack"}(Qe||(Qe={})),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"}(Je||(Je={})),function(e){e[e.Add=32774]="Add",e[e.Subtract=32778]="Subtract",e[e.ReverseSubtract=32779]="ReverseSubtract"}($e||($e={})),function(e){e[e.Clamp=0]="Clamp",e[e.Repeat=1]="Repeat",e[e.Mirror=2]="Mirror"}(et||(et={})),function(e){e[e.Point=0]="Point",e[e.Bilinear=1]="Bilinear"}(tt||(tt={})),function(e){e[e.NoMip=0]="NoMip",e[e.Nearest=1]="Nearest",e[e.Linear=2]="Linear"}(rt||(rt={})),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"}(nt||(nt={})),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"}(it||(it={})),function(e){e[e.Static=1]="Static",e[e.Dynamic=2]="Dynamic"}(ot||(ot={})),function(e){e[e.PerVertex=1]="PerVertex",e[e.PerInstance=2]="PerInstance"}(at||(at={})),function(e){e.LOADED="loaded"}(st||(st={})),function(e){e[e.n2D=0]="n2D",e[e.n2DArray=1]="n2DArray",e[e.n3D=2]="n3D",e[e.Cube=3]="Cube"}(ut||(ut={})),function(e){e[e.Sampled=1]="Sampled",e[e.RenderTarget=2]="RenderTarget"}(lt||(lt={})),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"}(ct||(ct={})),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"}(ft||(ft={})),function(e){e[e.Float=0]="Float",e[e.Uint=1]="Uint",e[e.Sint=2]="Sint",e[e.Depth=3]="Depth"}(ht||(ht={})),function(e){e[e.LowerLeft=0]="LowerLeft",e[e.UpperLeft=1]="UpperLeft"}(dt||(dt={})),function(e){e[e.NegativeOne=0]="NegativeOne",e[e.Zero=1]="Zero"}(pt||(pt={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(_t||(_t={})),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"}(vt||(vt={})),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"}(Et||(Et={})),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"}(yt||(yt={})),function(e){e[e.ALPHA=At(vt.U8,Et.A,yt.None)]="ALPHA",e[e.F16_R=At(vt.F16,Et.R,yt.None)]="F16_R",e[e.F16_RG=At(vt.F16,Et.RG,yt.None)]="F16_RG",e[e.F16_RGB=At(vt.F16,Et.RGB,yt.None)]="F16_RGB",e[e.F16_RGBA=At(vt.F16,Et.RGBA,yt.None)]="F16_RGBA",e[e.F32_R=At(vt.F32,Et.R,yt.None)]="F32_R",e[e.F32_RG=At(vt.F32,Et.RG,yt.None)]="F32_RG",e[e.F32_RGB=At(vt.F32,Et.RGB,yt.None)]="F32_RGB",e[e.F32_RGBA=At(vt.F32,Et.RGBA,yt.None)]="F32_RGBA",e[e.U8_R=At(vt.U8,Et.R,yt.None)]="U8_R",e[e.U8_R_NORM=At(vt.U8,Et.R,yt.Normalized)]="U8_R_NORM",e[e.U8_RG=At(vt.U8,Et.RG,yt.None)]="U8_RG",e[e.U8_RG_NORM=At(vt.U8,Et.RG,yt.Normalized)]="U8_RG_NORM",e[e.U8_RGB=At(vt.U8,Et.RGB,yt.None)]="U8_RGB",e[e.U8_RGB_NORM=At(vt.U8,Et.RGB,yt.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=At(vt.U8,Et.RGB,yt.sRGB|yt.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=At(vt.U8,Et.RGBA,yt.None)]="U8_RGBA",e[e.U8_RGBA_NORM=At(vt.U8,Et.RGBA,yt.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=At(vt.U8,Et.RGBA,yt.sRGB|yt.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=At(vt.U16,Et.R,yt.None)]="U16_R",e[e.U16_R_NORM=At(vt.U16,Et.R,yt.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=At(vt.U16,Et.RG,yt.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=At(vt.U16,Et.RGBA,yt.Normalized)]="U16_RGBA_NORM",e[e.U16_RGB=At(vt.U16,Et.RGB,yt.None)]="U16_RGB",e[e.U32_R=At(vt.U32,Et.R,yt.None)]="U32_R",e[e.U32_RG=At(vt.U32,Et.RG,yt.None)]="U32_RG",e[e.S8_R=At(vt.S8,Et.R,yt.None)]="S8_R",e[e.S8_R_NORM=At(vt.S8,Et.R,yt.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=At(vt.S8,Et.RG,yt.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=At(vt.S8,Et.RGB,yt.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=At(vt.S8,Et.RGBA,yt.Normalized)]="S8_RGBA_NORM",e[e.S16_R=At(vt.S16,Et.R,yt.None)]="S16_R",e[e.S16_RG=At(vt.S16,Et.RG,yt.None)]="S16_RG",e[e.S16_RG_NORM=At(vt.S16,Et.RG,yt.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=At(vt.S16,Et.RGB,yt.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=At(vt.S16,Et.RGBA,yt.None)]="S16_RGBA",e[e.S16_RGBA_NORM=At(vt.S16,Et.RGBA,yt.Normalized)]="S16_RGBA_NORM",e[e.S32_R=At(vt.S32,Et.R,yt.None)]="S32_R",e[e.U16_RGBA_5551=At(vt.U16_PACKED_5551,Et.RGBA,yt.Normalized)]="U16_RGBA_5551",e[e.BC1=At(vt.BC1,Et.RGBA,yt.Normalized)]="BC1",e[e.BC1_SRGB=At(vt.BC1,Et.RGBA,yt.Normalized|yt.sRGB)]="BC1_SRGB",e[e.BC2=At(vt.BC2,Et.RGBA,yt.Normalized)]="BC2",e[e.BC2_SRGB=At(vt.BC2,Et.RGBA,yt.Normalized|yt.sRGB)]="BC2_SRGB",e[e.BC3=At(vt.BC3,Et.RGBA,yt.Normalized)]="BC3",e[e.BC3_SRGB=At(vt.BC3,Et.RGBA,yt.Normalized|yt.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=At(vt.BC4_UNORM,Et.R,yt.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=At(vt.BC4_SNORM,Et.R,yt.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=At(vt.BC5_UNORM,Et.RG,yt.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=At(vt.BC5_SNORM,Et.RG,yt.Normalized)]="BC5_SNORM",e[e.D24=At(vt.D24,Et.R,yt.Depth)]="D24",e[e.D24_S8=At(vt.D24S8,Et.RG,yt.Depth|yt.Stencil)]="D24_S8",e[e.D32F=At(vt.D32F,Et.R,yt.Depth)]="D32F",e[e.D32F_S8=At(vt.D32FS8,Et.RG,yt.Depth|yt.Stencil)]="D32F_S8",e[e.U8_RGB_RT=At(vt.U8,Et.RGB,yt.RenderTarget|yt.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=At(vt.U8,Et.RGBA,yt.RenderTarget|yt.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=At(vt.U8,Et.RGBA,yt.RenderTarget|yt.Normalized|yt.sRGB)]="U8_RGBA_RT_SRGB"}(gt||(gt={})),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"}(mt||(mt={}));var Ft=Lt(0,0,0,0),Ut=Lt(0,0,0,1),wt=Lt(1,1,1,0),kt=Lt(1,1,1,1),Gt=!0;function Vt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;if(!t)return e;switch(e){case qe.Less:return qe.Greater;case qe.LessEqual:return qe.GreaterEqual;case qe.GreaterEqual:return qe.LessEqual;case qe.Greater:return qe.Less;default:return e}}function Wt(e,t){return null!=e?e:t}function Xt(e){return void 0===e?null:e}function Ht(e,t,r){e.length=t,e.fill(r)}function jt(e,t){var r=t-1;return e+r&~r}function Yt(e,t){return((e+t-1)/t|0)*t}function Kt(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 zt(e,t,r){var n=Kt(e,t,r);e.splice(n,0,t)}function qt(e,t,r){return r?e|=t:e&=~t,e}function Zt(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Qt(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"0";t>e.length;)e="".concat(r).concat(e);return e}function Jt(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function $t(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Jt(e.rgbBlendState,t.rgbBlendState),Jt(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function er(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=$t(e[r],t[r])}function tr(e,t){void 0!==t.attachmentsState&&er(e.attachmentsState,t.attachmentsState),void 0!==t.blendConstant&&Mt(e.blendConstant,t.blendConstant),e.depthCompare=Wt(t.depthCompare,e.depthCompare),e.depthWrite=Wt(t.depthWrite,e.depthWrite),e.stencilCompare=Wt(t.stencilCompare,e.stencilCompare),e.stencilWrite=Wt(t.stencilWrite,e.stencilWrite),e.stencilPassOp=Wt(t.stencilPassOp,e.stencilPassOp),e.stencilRef=Wt(t.stencilRef,e.stencilRef),e.cullMode=Wt(t.cullMode,e.cullMode),e.frontFace=Wt(t.frontFace,e.frontFace),e.polygonOffset=Wt(t.polygonOffset,e.polygonOffset)}function rr(e){var t=Object.assign({},e);return t.attachmentsState=[],er(t.attachmentsState,e.attachmentsState),t.blendConstant=Bt(t.blendConstant),t}function nr(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 ir={blendMode:$e.Add,blendSrcFactor:Je.One,blendDstFactor:Je.Zero},or={attachmentsState:[{channelWriteMask:ct.RGB,rgbBlendState:ir,alphaBlendState:ir}],blendConstant:Bt(Ft),depthWrite:!0,depthCompare:qe.LessEqual,stencilCompare:qe.Always,stencilWrite:!1,stencilPassOp:ft.Keep,stencilRef:0,cullMode:Qe.None,frontFace:Ze.CCW,polygonOffset:!1};function ar(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:or,r=rr(t);return null!==e&&tr(r,e),r}var sr=ar({depthCompare:qe.Always,depthWrite:!1},or);function ur(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],er(e.attachmentsState,or.attachmentsState)),nr(e.attachmentsState[0],t),e}var lr,cr={formatKind:ht.Float,dimension:ut.n2D};function fr(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 hr(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function dr(e,t){return e.buffer===t.buffer&&e.wordCount===t.wordCount}function pr(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture)}function _r(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function vr(e,t){return e.samplerBindings.length===t.samplerBindings.length&&(!!fr(e.samplerBindings,t.samplerBindings,pr)&&(!!fr(e.uniformBufferBindings,t.uniformBufferBindings,dr)&&!!gr(e.bindingLayout,t.bindingLayout)))}function Er(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function yr(e,t){return!!Er(e.rgbBlendState,t.rgbBlendState)&&(!!Er(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function gr(e,t){return e.numSamplers===t.numSamplers&&e.numUniformBuffers===t.numUniformBuffers}function mr(e,t){return e===t}function Rr(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!!function(e,t){return!!fr(e.attachmentsState,t.attachmentsState,yr)&&!!bt(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)&&(!!fr(e.bindingLayouts,t.bindingLayouts,gr)&&(!!fr(e.colorAttachmentFormats,t.colorAttachmentFormats,mr)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat))))))}function Tr(e,t){return e.bufferIndex===t.bufferIndex&&e.bufferByteOffset===t.bufferByteOffset&&e.location===t.location&&e.format===t.format}function Ar(e,r){return t.isNil(e)?t.isNil(r):!t.isNil(r)&&(e.byteStride===r.byteStride&&e.frequency===r.frequency)}function Sr(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!fr(e.vertexBufferDescriptors,t.vertexBufferDescriptors,Ar)&&!!fr(e.vertexAttributeDescriptors,t.vertexAttributeDescriptors,Tr))}function Cr(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 Or(e){return{sampler:e.sampler,texture:e.texture,lateBinding:e.lateBinding}}function Ir(e){return{buffer:e.buffer,wordCount:e.wordCount}}function Nr(e){return{bindingLayout:e.bindingLayout,samplerBindings:hr(e.samplerBindings,Or),uniformBufferBindings:hr(e.uniformBufferBindings,Ir),pipeline:e.pipeline}}function xr(e){return{dimension:e.dimension,formatKind:e.formatKind}}function Pr(e){return{numSamplers:e.numSamplers,numUniformBuffers:e.numUniformBuffers,samplerEntries:void 0!==e.samplerEntries?hr(e.samplerEntries,xr):void 0}}function Dr(e){var t=hr(e.bindingLayouts,Pr),r=e.program,n=e.topology;return{bindingLayouts:t,inputLayout:e.inputLayout,megaStateDescriptor:rr(e.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:e.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:e.depthStencilAttachmentFormat,sampleCount:e.sampleCount}}function br(e){return{location:e.location,format:e.format,bufferIndex:e.bufferIndex,bufferByteOffset:e.bufferByteOffset,byteStride:e.byteStride,divisor:e.divisor}}function Mr(e){return t.isNil(e)?e:{byteStride:e.byteStride,frequency:e.frequency}}function Br(e){return{vertexAttributeDescriptors:hr(e.vertexAttributeDescriptors,br),vertexBufferDescriptors:hr(e.vertexBufferDescriptors,Mr),indexBufferFormat:e.indexBufferFormat}}!function(e){e[e.LITTLE_ENDIAN=0]="LITTLE_ENDIAN",e[e.BIG_ENDIAN=1]="BIG_ENDIAN"}(lr||(lr={}));var Lr,Fr=new Uint16Array([65279]),Ur=255==new DataView(Fr.buffer).getUint8(0)?lr.LITTLE_ENDIAN:lr.BIG_ENDIAN;var wr=/([^[]*)(\[[0-9]+\])?/;function kr(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function Gr(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{Pt(o===c,"Uniform length cannot change.");for(var h=0;c>h;++h)if(l[h]!==i[h]){f=!0;break}}return f&&(n(a,e,s,l),i.set(l)),f}}function Vr(e,t,r,n){e[t](r,n)}function Wr(e,t,r,n){e[t](r,!1,n)}var Xr={},Hr={},jr={},Yr=[0];function Kr(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(Yr[0]=e,e=Yr);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 zr(e,t){return Kr(e,t,Float32Array,Xr)}function qr(e,t){return Kr(e,t,Int32Array,Hr)}function Zr(e,t){return Kr(e,t,Uint32Array,jr)}var Qr,Jr=(ve(Lr={},mt.FLOAT,Gr.bind(null,"uniform1fv",zr,1,Vr)),ve(Lr,mt.FLOAT_VEC2,Gr.bind(null,"uniform2fv",zr,2,Vr)),ve(Lr,mt.FLOAT_VEC3,Gr.bind(null,"uniform3fv",zr,3,Vr)),ve(Lr,mt.FLOAT_VEC4,Gr.bind(null,"uniform4fv",zr,4,Vr)),ve(Lr,mt.INT,Gr.bind(null,"uniform1iv",qr,1,Vr)),ve(Lr,mt.INT_VEC2,Gr.bind(null,"uniform2iv",qr,2,Vr)),ve(Lr,mt.INT_VEC3,Gr.bind(null,"uniform3iv",qr,3,Vr)),ve(Lr,mt.INT_VEC4,Gr.bind(null,"uniform4iv",qr,4,Vr)),ve(Lr,mt.BOOL,Gr.bind(null,"uniform1iv",qr,1,Vr)),ve(Lr,mt.BOOL_VEC2,Gr.bind(null,"uniform2iv",qr,2,Vr)),ve(Lr,mt.BOOL_VEC3,Gr.bind(null,"uniform3iv",qr,3,Vr)),ve(Lr,mt.BOOL_VEC4,Gr.bind(null,"uniform4iv",qr,4,Vr)),ve(Lr,mt.FLOAT_MAT2,Gr.bind(null,"uniformMatrix2fv",zr,4,Wr)),ve(Lr,mt.FLOAT_MAT3,Gr.bind(null,"uniformMatrix3fv",zr,9,Wr)),ve(Lr,mt.FLOAT_MAT4,Gr.bind(null,"uniformMatrix4fv",zr,16,Wr)),ve(Lr,mt.SAMPLER_2D,kr),ve(Lr,mt.SAMPLER_CUBE,kr),ve(Lr,mt.UNSIGNED_INT,Gr.bind(null,"uniform1uiv",Zr,1,Vr)),ve(Lr,mt.UNSIGNED_INT_VEC2,Gr.bind(null,"uniform2uiv",Zr,2,Vr)),ve(Lr,mt.UNSIGNED_INT_VEC3,Gr.bind(null,"uniform3uiv",Zr,3,Vr)),ve(Lr,mt.UNSIGNED_INT_VEC4,Gr.bind(null,"uniform4uiv",Zr,4,Vr)),ve(Lr,mt.FLOAT_MAT2x3,Gr.bind(null,"uniformMatrix2x3fv",zr,6,Wr)),ve(Lr,mt.FLOAT_MAT2x4,Gr.bind(null,"uniformMatrix2x4fv",zr,8,Wr)),ve(Lr,mt.FLOAT_MAT3x2,Gr.bind(null,"uniformMatrix3x2fv",zr,6,Wr)),ve(Lr,mt.FLOAT_MAT3x4,Gr.bind(null,"uniformMatrix3x4fv",zr,12,Wr)),ve(Lr,mt.FLOAT_MAT4x2,Gr.bind(null,"uniformMatrix4x2fv",zr,8,Wr)),ve(Lr,mt.FLOAT_MAT4x3,Gr.bind(null,"uniformMatrix4x3fv",zr,12,Wr)),ve(Lr,mt.SAMPLER_2D,kr),ve(Lr,mt.SAMPLER_CUBE,kr),ve(Lr,mt.SAMPLER_3D,kr),ve(Lr,mt.SAMPLER_2D_SHADOW,kr),ve(Lr,mt.SAMPLER_2D_ARRAY,kr),ve(Lr,mt.SAMPLER_2D_ARRAY_SHADOW,kr),ve(Lr,mt.SAMPLER_CUBE_SHADOW,kr),ve(Lr,mt.INT_SAMPLER_2D,kr),ve(Lr,mt.INT_SAMPLER_3D,kr),ve(Lr,mt.INT_SAMPLER_CUBE,kr),ve(Lr,mt.INT_SAMPLER_2D_ARRAY,kr),ve(Lr,mt.UNSIGNED_INT_SAMPLER_2D,kr),ve(Lr,mt.UNSIGNED_INT_SAMPLER_3D,kr),ve(Lr,mt.UNSIGNED_INT_SAMPLER_CUBE,kr),ve(Lr,mt.UNSIGNED_INT_SAMPLER_2D_ARRAY,kr),Lr);function $r(e,t,r){var n=e.createBuffer({viewOrSize:jt(r.byteLength,4)/4,usage:t,hint:ot.Static});return n.setSubData(0,new Uint8Array(r)),n}!function(e){e.CHANGED="changed"}(Qr||(Qr={}));var en,tn=function(e){Ee(n,e);var r=Ae(n);function n(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return de(this,n),(t=r.call(this)).device=void 0,t.props=void 0,t.drawMode=nt.Triangles,t.vertexBuffers=[],t.vertices=[],t.indexBuffer=void 0,t.indices=void 0,t.inputLayoutDescriptor={vertexBufferDescriptors:[],vertexAttributeDescriptors:[],indexBufferFormat:gt.U32_R},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=i,t}return _e(n,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=$r(this.device,it.INDEX|it.COPY_DST,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this}},{key:"setVertexBuffer",value: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=$r(this.device,it.VERTEX|it.COPY_DST,i.buffer);return this.vertexBuffers[r]=o,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value: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(Qr.CHANGED)}},{key:"updateIndices",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.indexBuffer&&this.indexBuffer.setSubData(t,ArrayBuffer.isView(e)?e:new Uint32Array(e)),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexAttributeDescriptors=[],this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}]),n}(_.EventEmitter),rn=[[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]];function nn(e,t){return"#define ".concat(e," ").concat(t)}function on(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=Oe(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 an(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="#version 100"===e.glslVersion,o=!1,a=r.split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),s="";null!==n&&(s=Object.keys(n).map((function(e){return nn(e,n[e])})).join("\n"));var u=a.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",l=a.filter((function(e){return!e.startsWith("precision")})).join("\n"),c="";if(e.viewportOrigin===dt.UpperLeft&&(c+="".concat(nn("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===pt.Zero&&(c+="".concat(nn("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var f=0,h=0,d=0;l=l.replace(/^(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(f,", binding = ").concat(h++,") uniform ").concat(n)})),f++,h=0,Pt(e.separateSamplerTextures),l=(l=l.replace(/uniform sampler2D (.*);/g,(function(e,r){return"frag"===t?"\nlayout(set = ".concat(f,", binding = ").concat(h++,") uniform texture2D T_").concat(r,";\nlayout(set = ").concat(f,", binding = ").concat(h++,") 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(d++,") ").concat(t)})),c+="".concat(nn("gl_VertexID","gl_VertexIndex"),"\n")}l=e.separateSamplerTextures?(l=(l=(l=l.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,")")})):(l=(l=(l=l.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 p="".concat(i?"":e.glslVersion,"\n").concat(i&&o?"#extension GL_EXT_draw_buffers : require":"","\n").concat(i&&"frag"===t?"#extension GL_OES_standard_derivatives : enable":"","\n").concat(u,"\n").concat(c,"\n").concat(s,"\n").concat(l,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(p=p.replace(/^\b(out)\b/gm,(function(e,t){return"layout(location = 0) ".concat(t)}))),i){if("frag"===t&&(p=p.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(p=(p=p.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")}))),p=p.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=(p=p.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return _=r,"".concat(t," ").concat(r,";\n")}))).lastIndexOf("}");p=p.substring(0,v)+"\n gl_FragColor = vec4(".concat(_,");\n")+p.substring(v)}p=p.replace(/^\s*layout\((.*)\)/gm,"");var E,y=Be(rn);try{for(y.s();!(E=y.n()).done;){var g=Oe(E.value,2),m=g[0],R=g[1];p=p.replace(m,R)}}catch(e){y.e(e)}finally{y.f()}}return p}function sn(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=an(e,"vert",t,n,i),a=an(e,"frag",r,n,i);return{vert:t,frag:r,preprocessedVert:o,preprocessedFrag:a}}function un(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.features?t.features:null,i=void 0!==t.both?t.both+t.vert:t.vert,o=void 0!==t.both?t.both+t.frag:t.frag;return sn(e.queryVendorInfo(),i,o,r,n)}!function(e){e.CHANGED="changed"}(en||(en={}));var ln=function(e){Ee(n,e);var r=Ae(n);function n(e,t){var i;de(this,n),(i=r.call(this)).device=void 0,i.props={},i.meshes=[],i.defines={},i.uniforms={},i.uniformNames=void 0,i.uboBuffer=[],i.textures={},i.samplers=[],i.programDirty=!0,i.textureDirty=!0,i.geometryDirty=!0;var o=rr(or),a=o.cullMode,s=o.depthCompare,u=o.depthWrite,l=o.stencilCompare,c=o.stencilWrite,f=o.stencilPassOp,h=o.frontFace,d=o.polygonOffset,p=o.attachmentsState;return i.device=e,i.props=le({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilCompare:l,stencilWrite:c,stencilPassOp:f,frontFace:h,polygonOffset:d,attachmentsState:p,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},t),i.compile(),i}return _e(n,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilCompare",get:function(){return this.props.stencilCompare},set:function(e){this.props.stencilCompare=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilPassOp",get:function(){return this.props.stencilPassOp},set:function(e){this.props.stencilPassOp=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=on(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var r=this,n=!1;Object.keys(e).forEach((function(i){var o,a=e[i],s=r.textures[i];s&&s!==a&&(r.textureDirty=!0),(o=a)&&o.type?(r.textures[i]=a,r.textureDirty=!0,a.on(st.LOADED,(function(){r.dispatchMutationEvent()}))):(r.uniforms[i]=a,n=!0),t.isNil(e[i])&&(delete r.textures[i],delete r.uniforms[i])})),n&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(en.CHANGED)}}]),n}(_.EventEmitter),cn=function(e){Ee(r,e);var t=Ae(r);function r(e,n){var i;return de(this,r),(i=t.call(this,e,le({},n))).defines=le(le({},i.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),i}return _e(r)}(ln),fn=function(){function e(){de(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={},this.features={MRT:!0}}return _e(e,[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,r){if(null!==r){if(this.defines[e]===r)return!1;this.defines[e]=r}else{if(t.isNil(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return Xt(this.defines[e])}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&Pt("1"===t),null!==t}},{key:"ensurePreprocessed",value:function(e){""===this.preprocessedVert&&(this.preprocessedVert=an(e,"vert",this.both+this.vert,this.defines,this.features),this.preprocessedFrag=an(e,"frag",this.both+this.frag,this.defines,this.features))}}]),e}(),hn=function(){function e(t){de(this,e),this.device=void 0,this.uniformBufferWordAlignment=void 0,this.uniformBufferMaxPageWordSize=void 0,this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize}return _e(e,[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){e=Yt(e,this.uniformBufferWordAlignment),Pt(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=Yt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=Yt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Pt(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=Yt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return Dt(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=Dt(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:it.UNIFORM|it.COPY_DST,hint:ot.Dynamic}));var t=Yt(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())Dt(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}]),e}();function dn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function pn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function _n(e){return 0}var vn=_e((function e(){de(this,e),this.keys=[],this.values=[]})),En=function(){function e(t,r){de(this,e),this.keyEqualFunc=void 0,this.keyHashFunc=void 0,this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r}return _e(e,[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new vn);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=Be(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:ce().mark((function e(){var t,r,n,i;return ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Be(this.buckets.values()),e.prev=1,t.s();case 3:if((r=t.n()).done){e.next=14;break}i=(n=r.value).values.length-1;case 6:if(i<0){e.next=12;break}return e.next=9,n.values[i];case 9:i--,e.next=6;break;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))}]),e}();function yn(e,t){return Pt(""!==e.preprocessedVert&&""!==t.preprocessedVert),Pt(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function gn(e,t){return e=dn(e,t.numUniformBuffers),e=dn(e,t.numSamplers)}function mn(e,t){return e=dn(e,t.blendMode),e=dn(e,t.blendSrcFactor),e=dn(e,t.blendDstFactor)}function Rn(e,t){return e=mn(e,t.rgbBlendState),e=dn(e=mn(e,t.alphaBlendState),t.channelWriteMask)}function Tn(e,t){for(var r=0;t.attachmentsState.length>r;r++)e=Rn(e,t.attachmentsState[r]);return e=function(e,t){return dn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=dn(e,t.depthCompare),e=dn(e,t.depthWrite?1:0),e=dn(e,t.stencilCompare),e=dn(e,t.stencilPassOp),e=dn(e,t.stencilWrite?1:0),e=dn(e,t.cullMode),e=dn(e,t.frontFace?1:0),e=dn(e,t.polygonOffset?1:0)}function An(e){var t=0;t=dn(t,e.program.id),null!==e.inputLayout&&(t=dn(t,e.inputLayout.id));for(var r=0;e.bindingLayouts.length>r;r++)t=gn(t,e.bindingLayouts[r]);t=Tn(t,e.megaStateDescriptor);for(var n=0;e.colorAttachmentFormats.length>n;n++)t=dn(t,e.colorAttachmentFormats[n]||0);return pn(t=dn(t,e.depthStencilAttachmentFormat||0))}function Sn(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=dn(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var o=e.uniformBufferBindings[i];null!==o&&null!==o.buffer&&(t=dn(t,o.buffer.id),t=dn(t,o.wordCount))}return pn(t)}var Cn,On=function(){function e(t){de(this,e),this.device=void 0,this.bindingsCache=new En(vr,Sn),this.renderPipelinesCache=new En(Rr,An),this.inputLayoutsCache=new En(Sr,_n),this.programCache=new En(yn,_n),this.samplerCache=new En(Cr,_n),this.device=t}return _e(e,[{key:"createBindings",value:function(e){var t=this.bindingsCache.get(e);if(null===t){var r=Nr(e);t=this.device.createBindings(r),this.bindingsCache.add(r,t)}return t}},{key:"createRenderPipeline",value:function(e){var t=this.renderPipelinesCache.get(e);if(null===t){var r=Dr(e);t=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,t)}return t}},{key:"createInputLayout",value:function(e){var t=this.inputLayoutsCache.get(e);if(null===t){var r=Br(e);t=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,t)}return t}},{key:"createProgramSimple",value: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}},{key:"createProgram",value:function(e){return e.ensurePreprocessed(this.device.queryVendorInfo()),this.createProgramSimple(e)}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=Be(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=Be(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,o=Be(this.inputLayoutsCache.values());try{for(o.s();!(i=o.n()).done;){i.value.destroy()}}catch(e){o.e(e)}finally{o.f()}var a,s=Be(this.programCache.values());try{for(s.s();!(a=s.n()).done;){a.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=Be(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}]),e}();!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"}(Cn||(Cn={}));var In,Nn={x:0,y:0,w:1,h:1},xn=function(){function e(){de(this,e),this.renderTargetIDs=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.viewport=Nn,this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorResolveTo:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=0,this.viewportH=0,this.execFunc=null,this.postFunc=null,this.debugName=void 0,this.debugThumbnails=[]}return _e(e,[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e){this.viewport=e}},{key:"attachRenderTargetID",value:function(e,t){Pt(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"resolveToExternalTexture",value:function(e,t){this.resolveTextureOutputExternalTextures[e]=t}},{key:"exec",value:function(e){Pt(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){Pt(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}]),e}(),Pn=function(){function e(t,r){de(this,e),this.debugName=void 0,this.dimension=ut.n2D,this.depth=1,this.numLevels=1,this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.usage=lt.RenderTarget,this.immutable=!0,this.needsClear=!0,this.texture=null,this.attachment=void 0,this.age=0,this.pixelFormat=r.pixelFormat,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,Pt(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}return _e(e,[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){Pt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){null!==this.texture&&this.texture.destroy(),this.attachment.destroy()}}]),e}(),Dn=function(){function e(t,r){de(this,e),this.dimension=ut.n2D,this.depth=1,this.numLevels=1,this.usage=lt.RenderTarget,this.pixelFormat=void 0,this.width=0,this.height=0,this.texture=void 0,this.age=0,this.immutable=!0,this.pixelFormat=r.pixelFormat,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)}return _e(e,[{key:"matchesDescription",value:function(e){return this.pixelFormat===e.pixelFormat&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){Pt(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}]),e}();In=Symbol.species;var bn,Mn=_e((function e(){de(this,e),this[In]=void 0,this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),Bn=function(){function e(t){de(this,e),this.device=void 0,this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t}return _e(e,[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Pn(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new Dn(this.device,e)}},{key:"beginGraphBuilder",value:function(){Pt(null===this.currentGraph),this.currentGraph=new Mn}},{key:"pushPass",value:function(e){var t=new xn;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=Dt(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Pt(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=this.findPassForResolveRenderTarget(e),n=r.renderTargetIDs.indexOf(e);Pt(void 0===r.resolveTextureOutputIDs[n]),r.resolveTextureOutputExternalTextures[n]=t}},{key:"getRenderTargetDescription",value:function(e){return Dt(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var o=t.resolveTextureInputIDs[i];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[o]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(Pt(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=Dt(this.renderTargetAliveForID[e]);return t?(Pt(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Pt(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}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Pt(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=Dt(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 Dt(n.texture)}},{key:"determineResolveParam",value: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;Pt(!(a&&s));var u=null,l=!1;if(this.renderTargetOutputCount[n]>1&&(l=!0),a){Pt(e.resolveTextureRenderTargetIDs[i]===n),Pt(this.resolveTextureUseCount[i]>0),Pt(this.renderTargetOutputCount[n]>0);var c=Dt(this.renderTargetAliveForID[n]);if(null!==c.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var f=Dt(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,c.debugName+" (Resolve ".concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else u=s?o:null;return{resolveTo:u,store:l}}},{key:"schedulePass",value:function(e,t){for(var r=t.renderTargetIDs[Cn.DepthStencil],n=Cn.Color0;Cn.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;var a=this.determineResolveParam(e,t,n),s=a.store;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[Cn.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var l=this.determineResolveParam(e,t,Cn.DepthStencil),c=l.store;t.descriptor.depthStencilResolveTo=l.resolveTo,t.descriptor.depthStencilStore=c,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var f=0,h=0,d=0,p=0;t.renderTargets.length>p;p++){var _=t.renderTargets[p];_&&(0===f&&(f=_.width,h=_.height,d=_.sampleCount),Pt(_.width===f),Pt(_.height===h),Pt(_.sampleCount===d),_.needsClear=!1)}if(f>0&&h>0){var v=h*t.viewport.y,E=f*t.viewport.w,y=h*t.viewport.h;t.viewportX=f*t.viewport.x,t.viewportY=v,t.viewportW=E,t.viewportH=y}for(var g=0;t.resolveTextureInputIDs.length>g;g++){t.resolveTextureInputTextures[g]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[g])}for(var m=0;t.renderTargetIDs.length>m;m++)this.releaseRenderTargetForID(t.renderTargetIDs[m],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)}},{key:"scheduleGraph",value:function(e){Pt(0===this.renderTargetOutputCount.length),Pt(0===this.renderTargetResolveCount.length),Pt(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;Ht(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),Ht(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),Ht(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var o=0;this.renderTargetOutputCount.length>o;o++)Pt(0===this.renderTargetOutputCount[o]);for(var a=0;this.renderTargetResolveCount.length>a;a++)Pt(0===this.renderTargetResolveCount[a]);for(var s=0;this.resolveTextureUseCount.length>s;s++)Pt(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)Pt(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){Pt(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}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),e.passes.forEach((function(e){t.execPass(e)})),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=Dt(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Pt(r>=0),Dt(t.resolveTextureInputTextures[r])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Pt(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)Pt(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()}}]),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"}(bn||(bn={}));var Ln=65536;function Fn(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ln,i=t.clamp(e,0,n)/n;r&&(i=1-i);var o=65535*i;return 65535&o}function Un(e,t){return(16777215&e|(255&t)<<24)>>>0}function wn(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function kn(e,t){return Un(wn(0,t),e)}function Gn(e,t){return Pt(t>=0),(4294967040&e|t>>>8&255)>>>0}function Vn(e){return Un(0,e)}function Wn(e,t){return Pt(t>=0),(4278190335&e|t<<8)>>>0}var Xn=We(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Hn,jn=We(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Yn(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){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"}(Hn||(Hn={}));var Kn,zn=function(){function e(){de(this,e),this.sortKey=0,this.debug=null,this.renderPipelineDescriptor=void 0,this.uniformBuffer=void 0,this.uniforms=[],this.bindingDescriptors=Zt(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Zt(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:rr(or),program:null,topology:nt.Triangles,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return _e(e,[{key:"reset",value:function(){this.sortKey=0,this.flags=Hn.AllowSkippingIfPipelineNotReady,this.inputState=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){tr(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=Ne(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.flags=this.flags&~Hn.InheritedFlags|e.flags&Hn.InheritedFlags,this.sortKey=e.sortKey;var r=this.bindingDescriptors[0],n=e.bindingDescriptors[0];null!==n.bindingLayout&&this.setBindingLayout(n.bindingLayout);for(var i=0;Math.min(r.uniformBufferBindings.length,n.uniformBufferBindings.length)>i;i++)r.uniformBufferBindings[i].wordCount=e.bindingDescriptors[0].uniformBufferBindings[i].wordCount;this.setSamplerBindingsFromTextureMappings(n.samplerBindings);for(var o=0;e.dynamicUniformBufferByteOffsets.length>o;o++)this.dynamicUniformBufferByteOffsets[o]=e.dynamicUniformBufferByteOffsets[o]}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return tr(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setInputLayoutAndState",value:function(e,t){this.inputState=t,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){Pt(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(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null,lateBinding:null})}},{key:"setBindingLayouts",value:function(e){Pt(this.bindingDescriptors.length>=e.length),Pt(1===e.length),this.setBindingLayout(e[0])}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=qt(this.flags,Hn.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=qt(this.flags,Hn.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=qt(this.flags,Hn.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,r){if(0!==r.length){this.uniforms[e]=r;var n=0,i=[];r.forEach((function(e){var r=e.value;if(t.isNumber(r)||Array.isArray(r)||r instanceof Float32Array){var o=t.isNumber(r)?[r]:r,a=4-n%4;if(4!==a)if(a<(o.length>4?4:o.length)){n+=a;for(var s=0;a>s;s++)i.push(0)}else;n+=o.length,i.push.apply(i,Ne(o))}}));var o=4-i.length%4;if(4!==o)for(var a=0;o>a;a++)i.push(0);for(var s=this.allocateUniformBuffer(e,i.length),u=this.mapUniformBufferF32(e),l=0;i.length>l;l+=4)s+=Yn(u,s,i[l],i[l+1],i[l+2],i[l+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){return Pt(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)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"setUniformBufferOffset",value:function(e,t,r){this.dynamicUniformBufferByteOffsets[e]=t<<2,this.bindingDescriptors[0].uniformBufferBindings[e].wordCount=r}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler,r.lateBinding=n.lateBinding):(r.texture=null,r.sampler=null,r.lateBinding=null)}}},{key:"hasLateSamplerBinding",value: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}},{key:"resolveLateSamplerBinding",value: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):(Pt(null===t.lateBinding),n.texture=t.texture,null!==t.sampler&&(n.sampler=t.sampler)),n.lateBinding=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=qt(this.flags,Hn.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value: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:Pt(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:Pt(n==a.sampleCount)),Pt(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&Hn.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setInputState(this.inputState);for(var o=0;this.bindingDescriptors[0].uniformBufferBindings.length>o;o++)this.bindingDescriptors[0].uniformBufferBindings[o].buffer=Dt(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 a=e.createBindings(le(le({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(0,a,this.dynamicUniformBufferByteOffsets),this.drawInstanceCount>1?(Pt(!!(this.flags&Hn.Indexed)),t.drawIndexedInstanced(this.drawCount,this.drawStart,this.drawInstanceCount)):this.flags&Hn.Indexed?t.drawIndexed(this.drawCount,this.drawStart):t.draw(this.drawCount,this.drawStart),!0}}]),e}();function qn(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Kn||(Kn={}));var Zn=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:qn,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Kn.Forwards;de(this,e),this.renderInsts=[],this.compareFunction=void 0,this.executionOrder=void 0,this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r}return _e(e,[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):zt(this.renderInsts,e,this.compareFunction),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Hn.Draw,this.insertSorted(e)}},{key:"hasLateSamplerBinding",value:function(e){for(var t=0;this.renderInsts.length>t;t++)if(this.renderInsts[t].hasLateSamplerBinding(e))return!0;return!1}},{key:"resolveLateSamplerBinding",value:function(e,t){for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].resolveLateSamplerBinding(e,t)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){this.ensureSorted();var r=0;if(this.executionOrder===Kn.Forwards)for(var n=0;this.renderInsts.length>n;n++)this.renderInsts[n].drawOnPass(e,t)&&r++;else for(var i=this.renderInsts.length-1;i>=0;i--)this.renderInsts[i].drawOnPass(e,t)&&r++;return r}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}]),e}(),Qn=function(){function e(){de(this,e),this.pool=[],this.allocCount=0}return _e(e,[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new zn),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}]),e}(),Jn=function(){function e(t){de(this,e),this.renderCache=void 0,this.instPool=new Qn,this.templatePool=new Qn,this.simpleRenderInstList=new Zn,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}return _e(e,[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{key:"submitRenderInst",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList;t.submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){Pt(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Hn.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Pt(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){Dt(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){Dt(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}]),e}(),$n=function(){function e(){de(this,e),this.renderCache=void 0,this.renderGraph=void 0,this.renderInstManager=void 0,this.uniformBuffer=void 0,this.device=void 0}return _e(e,[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new On(e),this.renderGraph=new Bn(this.device),this.renderInstManager=new Jn(this.renderCache),this.uniformBuffer=new hn(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache.destroy(),this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}}]),e}();$n=d([t.singleton()],$n);var ei=function(){function e(t){de(this,e),this.pixelFormat=void 0,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.pixelFormat=t}return _e(e,[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}]),e}();function ti(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var ri,ni=ti(Lt(.88,.88,.88,1)),ii=ti(Ut),oi=ti(kt);function ai(e,t){var r=function(e){return e.antialiasingMode===ri.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function si(e,t,r){var n=function(e){if(e===Cn.Color0)return gt.U8_RGBA_RT;if(e===Cn.DepthStencil)return gt.D24_S8;throw Error("whoops")}(e),i=new ei(n);return ai(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"}(ri||(ri={}));var ui=function(){function e(){de(this,e),this.name=void 0,this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}return _e(e,[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.lateBinding=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value: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}(),li=function(){function e(){de(this,e),this.inputTexture=null,this.outputTexture=null}return _e(e,[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Pt(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Dn(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}]),e}(),ci=function(){function e(){de(this,e),this.imagePool=void 0,this.offscreenCanvas=void 0,this.renderingService=void 0,this.canvasConfig=void 0,this.textureCache={}}return _e(e,[{key:"getOrCreateTexture",value:function(e,r,n,i){var o,a=this,s="string"==typeof r?r:r.src||"";if(s&&this.textureCache[s])(o=this.textureCache[s]).emit(st.LOADED);else if(o=e.createTexture(le({pixelFormat:gt.U8_RGBA_NORM,width:1,height:1,depth:1,numLevels:1,dimension:ut.n2D,usage:lt.Sampled,pixelStore:{unpackFlipY:!1},immutable:!1},n)),s&&(this.textureCache[s]=o),t.isString(r)){var u,l=this.canvasConfig.createImage;l?u=l(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){a.textureCache[s].setImageData(u),a.textureCache[s].emit(st.LOADED),a.renderingService.dirtify(),i&&i(a.textureCache[s])},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else o.setImageData(r),o.emit(st.LOADED),this.renderingService.dirtify();return o}},{key:"getOrCreateCanvas",value:function(){return this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=this,r=e.gradients,n=e.instance.getGeometryBounds().halfExtents,i=2*n[0]||1,o=2*n[1]||1,a=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),s=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);a.width=i,a.height=o,r.forEach((function(e){var r=t.imagePool.getOrCreateGradient(le(le({type:e.type},e.value),{},{width:i,height:o}),s);s.fillStyle=r,s.fillRect(0,0,i,o)}))}},{key:"getOrCreatePattern",value:function(e,r,n){var i,o=e.image,a=e.repetition,s=r.getGeometryBounds().halfExtents,u=2*s[0]||1,l=2*s[1]||1,c=this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas),f=this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);c.width=u,c.height=l;var h=(i=t.isString(o)?this.imagePool.getImageSync(o,n):o)&&f.createPattern(i,a);f.fillStyle=h,f.fillRect(0,0,u,l)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}]),e}();d([t.inject(O),p("design:type",O)],ci.prototype,"imagePool",void 0),d([t.inject(t.OffscreenCanvasCreator),p("design:type",t.OffscreenCanvasCreator)],ci.prototype,"offscreenCanvas",void 0),d([t.inject(t.RenderingService),p("design:type",t.RenderingService)],ci.prototype,"renderingService",void 0),d([t.inject(t.CanvasConfig),p("design:type",Object)],ci.prototype,"canvasConfig",void 0),ci=d([t.singleton()],ci);var fi=t.Syringe.defineToken("RendererFactory"),hi=t.Syringe.defineToken("ShapeRenderer"),di=t.Syringe.defineToken("MeshFactory"),pi=1,_i=function(){function e(){de(this,e),this.renderHelper=void 0,this.rendererFactory=void 0,this.meshFactory=void 0,this.device=void 0,this.renderingService=void 0,this.meshes=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return _e(e,[{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.meshes.forEach((function(n){n.init(t.device,t.renderingService);var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=t.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),t.renderHelper.renderInstManager.submitRenderInst(o,e),r||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))}},{key:"attach",value:function(e,t){this.device=e,this.renderingService=t}},{key:"add",value: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=t.meshFactory(i)).renderer=n,a.index=o,t.meshes.push(a)),a&&(a.objects.push(e),r.meshes[o]=a,a.geometryDirty=!0)}}))}}},{key:"remove",value: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=[])}},{key:"updateAttribute",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],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&&n.meshes.splice(n.meshes.indexOf(c),1),o.meshes[o.meshes.indexOf(c)]=void 0),l&&((c=n.meshes.find((function(t){return s===t.constructor&&t.index===u&&t.shouldMerge(e,u)})))||((c=n.meshFactory(s)).renderer=a,c.index=u,c.init(n.device,n.renderingService),n.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(i)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var h=c.id+t;n.pendingUpdatePatches[h]||(n.pendingUpdatePatches[h]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[h].objectIndices.indexOf(f)&&n.pendingUpdatePatches[h].objectIndices.push(f)}}}))}},{key:"changeRenderOrder",value: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))}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=pi++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,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}();d([t.inject($n),p("design:type",$n)],_i.prototype,"renderHelper",void 0),d([t.inject(fi),p("design:type",Function)],_i.prototype,"rendererFactory",void 0),d([t.inject(di),p("design:type",Function)],_i.prototype,"meshFactory",void 0),_i=d([t.singleton()],_i);var vi=.005,Ei=1,yi=function(){function e(){de(this,e),this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.batchManager=void 0,this.device=void 0,this.renderingService=void 0,this.id=Ei++,this.meshes=[],this.clipPathMeshCreated=!1}return _e(e,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}},{key:"beforeUploadUBO",value:function(e,t,r){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}]),e}();function gi(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function mi(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}d([t.inject($n),p("design:type",$n)],yi.prototype,"renderHelper",void 0),d([t.inject(ci),p("design:type",ci)],yi.prototype,"texturePool",void 0),d([t.inject(t.DefaultCamera),p("design:type",t.Camera)],yi.prototype,"camera",void 0),d([t.inject(Fe),p("design:type",Fe)],yi.prototype,"lightPool",void 0),d([t.inject(_i),p("design:type",_i)],yi.prototype,"batchManager",void 0),yi=d([t.injectable()],yi);var Ri,Ti,Ai=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=Oe(e,2);return void 0!==t[1]})))},Si=1,Ci="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.FILL_STROKE=1]="FILL_STROKE",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"}(Ri||(Ri={})),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.COLOR=4]="COLOR",e[e.STROKE_COLOR=5]="STROKE_COLOR",e[e.PACKED_STYLE1=6]="PACKED_STYLE1",e[e.PACKED_STYLE2=7]="PACKED_STYLE2",e[e.PICKING_COLOR=8]="PICKING_COLOR",e[e.POSITION=9]="POSITION",e[e.NORMAL=10]="NORMAL",e[e.UV=11]="UV",e[e.BARYCENTRIC=12]="BARYCENTRIC",e[e.MAX=13]="MAX"}(Ti||(Ti={}));var Oi=function(){function e(){de(this,e),this.id=Si++,this.renderer=void 0,this.index=-1,this.renderHelper=void 0,this.texturePool=void 0,this.camera=void 0,this.lightPool=void 0,this.device=void 0,this.renderingService=void 0,this.objects=[],this.material=void 0,this.geometry=void 0,this.clipPath=void 0,this.clipPathTarget=void 0,this.inputState=void 0,this.program=new fn,this.programDescriptorSimpleWithOrig=void 0,this.geometryDirty=!0,this.materialDirty=!0,this.inputStateDirty=!0,this.textureMappings=[],this.samplerEntries=void 0,this.inited=!1}return _e(e,[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(e,t){this.inited||(this.renderer.beforeInitMesh(this),this.device=e,this.renderingService=t,this.material=new cn(this.device),this.material.defines=le(le({},gi(Ti)),this.material.defines),this.geometry=new tn(this.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(Qr.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(en.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.renderingService.dirtify()}))}},{key:"shouldMerge",value:function(e,t){return!this.instance||this.instance.nodeName===e.nodeName&&!e.parsedStyle.clipPath}},{key:"createGeometry",value:function(e){var r=this,n=Ge(),i=Ge(),o=[],a=[],s=[],u=[];e.forEach((function(e){var l,c=e.parsedStyle,f=c.fill,h=c.stroke,d=c.opacity,p=c.fillOpacity,_=c.strokeOpacity,v=c.lineWidth,E=c.anchor,y=c.visibility,g=c.increasedLineWidthForHitTesting,m=[0,0,0,0];f instanceof t.CSSRGB&&(m=[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255,Number(f.alpha)]);var R=[0,0,0,0];h instanceof t.CSSRGB&&(R=[Number(h.r)/255,Number(h.g)/255,Number(h.b)/255,Number(h.alpha)]),r.clipPathTarget?(Ve(n,e.getLocalTransform()),m=[1,1,1,1],He(n,r.clipPathTarget.getWorldTransform(),n)):Ve(n,e.getWorldTransform()),He(i,r.camera.getViewTransform(),n);var T=e.isInteractive()&&(null===(l=e.renderable3D)||void 0===l?void 0:l.encodedPickingColor)||[0,0,0];o.push.apply(o,Ne(n)),a.push.apply(a,Ne(m).concat(Ne(R))),s.push(d.value,p.value,_.value,v.value,"visible"===y.value?1:0,E[0].value,E[1].value,(null==g?void 0:g.value)||0),u.push.apply(u,Ne(T).concat([e.sortable.renderOrder*vi]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Ri.MODEL_MATRIX,byteStride:64,frequency:at.PerInstance,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:Ti.MODEL_MATRIX0,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:16,location:Ti.MODEL_MATRIX1,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:32,location:Ti.MODEL_MATRIX2,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:48,location:Ti.MODEL_MATRIX3,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Ri.FILL_STROKE,byteStride:32,frequency:at.PerInstance,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:Ti.COLOR,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:16,location:Ti.STROKE_COLOR,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:Ri.PACKED_STYLE,byteStride:32,frequency:at.PerInstance,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:Ti.PACKED_STYLE1,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:16,location:Ti.PACKED_STYLE2,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Ri.PICKING_COLOR,byteStride:16,frequency:at.PerInstance,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:Ti.PICKING_COLOR,divisor:1}],data:new Float32Array(u)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy(),this.inputState&&this.inputState.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=this.lightPool.getAllLights(),i=!!this.lightPool.getFog(),o=!!n.length,a=le({},this.material.defines);if(this.material.defines.USE_FOG=i,this.material.defines.USE_LIGHT=o,this.material.defines=le(le({},this.material.defines),this.lightPool.getDefines()),this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilCompare=qe.Always,this.material.stencilPassOp=ft.Replace):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilCompare=qe.Equal,this.material.stencilPassOp=ft.Keep):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t),this.material.textureDirty){this.textureMappings=[];var s=this.createFillGradientTextureMapping(t);s&&this.textureMappings.push(s),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 ui;t.name=e,t.texture=r.material.textures[e],r.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({wrapS:et.Clamp,wrapT:et.Clamp,minFilter:tt.Point,magFilter:tt.Bilinear,mipFilter:rt.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}(mi(a,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=le(le({},this.material.defines),gi(Ti)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"number"==typeof t?r.program.setDefineString(e,"".concat(t)):r.program.setDefineBool(e,t)})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.programDescriptorSimpleWithOrig=un(this.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 u=this.renderHelper.getCache().createInputLayout(this.geometry.inputLayoutDescriptor),l=this.renderHelper.getCache().createProgramSimple(this.programDescriptorSimpleWithOrig),c=!!this.geometry.indexBuffer;this.inputStateDirty&&(this.inputState&&this.inputState.destroy(),this.inputState=this.device.createInputState(u,this.geometry.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),c?{buffer:this.geometry.indexBuffer,byteOffset:0}:null,l),this.inputStateDirty=!1),e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(l),e.setInputLayoutAndState(u,this.inputState),this.renderer.beforeUploadUBO(e,this,this.index),this.uploadUBO(e),c?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=kn(bn.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value: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];n instanceof t.CSSRGB&&(a=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]);var s=[0,0,0,0];i instanceof t.CSSRGB&&(s=[Number(i.r)/255,Number(i.g)/255,Number(i.b)/255,Number(i.alpha)]),o.push.apply(o,Ne(a).concat(Ne(s)))})),this.geometry.updateVertexBuffer(Ri.FILL_STROKE,Ti.COLOR,r,new Uint8Array(new Float32Array(o).buffer));var a=this.instance.parsedStyle.fill,s=this.textureMappings.findIndex((function(e){return e.name===Ci}));if(a instanceof t.CSSRGB)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 l=[];e.forEach((function(e){var t=e.parsedStyle,r=t.anchor,n=t.increasedLineWidthForHitTesting;l.push(t.opacity.value,t.fillOpacity.value,t.strokeOpacity.value,t.lineWidth.value,"visible"===t.visibility.value?1:0,r[0].value,r[1].value,(null==n?void 0:n.value)||0)})),this.geometry.updateVertexBuffer(Ri.PACKED_STYLE,Ti.PACKED_STYLE1,r,new Uint8Array(new Float32Array(l).buffer))}else if("modelMatrix"===n){var c=[];e.forEach((function(e){var t=Ve(Ge(),e.getWorldTransform());c.push.apply(c,Ne(t))})),this.geometry.updateVertexBuffer(Ri.MODEL_MATRIX,Ti.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(c).buffer))}else if("pointerEvents"===n){var f=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];f.push.apply(f,Ne(r).concat([e.sortable.renderOrder*vi]))})),this.geometry.updateVertexBuffer(Ri.PICKING_COLOR,Ti.PICKING_COLOR,r,new Uint8Array(new Float32Array(f).buffer))}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Ri.PICKING_COLOR,Ti.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(Ne(i),[t*vi])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Ri.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].byteStride/4*r)}for(var o=0,a=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].byteStride/4,f=0;c>f;f++)e.vertices[l][o*c+f]=n[l][u*c+f];a[s]=o,o++}for(var h=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]})},d=Ri.PICKING_COLOR+1;e.vertexBuffers.length>d;d++)h(d);for(var p=new Float32Array(3*r),_=0;r>_;)for(var v=0;3>v;v++){p[3*a[_++]+v]=1}e.setVertexBuffer({bufferIndex:Ri.BARYCENTRIC,byteStride:12,frequency:at.PerVertex,attributes:[{format:gt.F32_RGB,bufferByteOffset:0,location:Number(Ti.BARYCENTRIC)}],data:p}),e.setIndexBuffer(a)}},{key:"beforeUploadUBO",value:function(e,t,r){}},{key:"uploadUBO",value:function(e){var r=this,n=this.material,i=this.lightPool.getAllLights(),o=this.lightPool.getFog(),a=!!o,s=!!i.length,u=[];if(n.defines.USE_WIREFRAME){var l=t.parseColor(n.wireframeColor);u.push({name:"u_WireframeLineColor",value:[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255]}),u.push({name:"u_WireframeLineWidth",value:n.wireframeLineWidth})}if(a&&this.uploadFog(u,o),this.uploadMaterial(u,n),s){var c={};i.forEach((function(e){c[e.define]||(c[e.define]=-1),c[e.define]++,e.uploadUBO(u,c[e.define])}))}u.sort((function(e,t){return r.material.uniformNames.indexOf(e.name)-r.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,u);var f=n.blendEquation,h=n.blendEquationAlpha,d=n.blendSrc,p=n.blendDst,_=n.blendSrcAlpha,v=n.blendDstAlpha,E=Ai({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}),y=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(le({attachmentsState:[{channelWriteMask:this.material.stencilWrite?ct.None:ct.AllChannels,rgbBlendState:le(le({},y.rgbBlendState),Ai({blendMode:f,blendSrcFactor:d,blendDstFactor:p})),alphaBlendState:le(le({},y.alphaBlendState),Ai({blendMode:h,blendSrcFactor:_,blendDstFactor:v}))}]},E)),e.setBindingLayouts([{numUniformBuffers:1,numSamplers:this.textureMappings.length,samplerEntries:this.samplerEntries}]),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,u=n.density;if(o instanceof t.CSSRGB){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})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,Ne(r))}},{key:"createFillGradientTextureMapping",value: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.device,r,Rt(gt.U8_RGBA_NORM,1,1,1));if(a){var s=new ui;return s.name=Ci,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({wrapS:et.Repeat,wrapT:et.Repeat,minFilter:tt.Point,magFilter:tt.Bilinear,mipFilter:rt.Linear,minLOD:0,maxLOD:0}),s}}return null}}]),e}();d([t.inject($n),p("design:type",$n)],Oi.prototype,"renderHelper",void 0),d([t.inject(ci),p("design:type",ci)],Oi.prototype,"texturePool",void 0),d([t.inject(t.DefaultCamera),p("design:type",t.Camera)],Oi.prototype,"camera",void 0),d([t.inject(Fe),p("design:type",Fe)],Oi.prototype,"lightPool",void 0),Oi=d([t.injectable()],Oi);var Ii,Ni;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(Ii||(Ii={})),function(e){e[e.PACKED_STYLE3=13]="PACKED_STYLE3",e[e.SIZE=14]="SIZE"}(Ni||(Ni={}));var xi=[t.Shape.CIRCLE,t.Shape.ELLIPSE],Pi=function(e){Ee(n,e);var r=Ae(n);function n(){return de(this,n),r.apply(this,arguments)}return _e(n,[{key:"shouldMerge",value:function(e,t){var r=Ce(ye(n.prototype),"shouldMerge",this).call(this,e,t);return!!r&&(!this.needDrawStrokeSeparately(e.parsedStyle)&&!this.needDrawStrokeSeparately(this.instance.parsedStyle)&&this.instance.parsedStyle.fill.isNone===e.parsedStyle.fill.isNone)}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\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 vec4 v_Data;\nout vec2 v_Radius;\nout vec4 v_StylePacked3;\n\nvoid main() {\n mat4 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 * 0.5 + 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 antialiasblur = 1.0 / (a_Size.x + strokeWidth);\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) * radius;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n \n v_Radius = radius;\n v_Data = vec4(a_Extrude, antialiasblur, a_StylePacked3.x);\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 vec4 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\nvoid main() {\n int shape = int(floor(v_Data.w + 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;\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(1.0));\n inner_df = sdEllipsoidApproximated(v_Data.xy, r);\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 // vec2 imagecoord = mod(v_Uv, 0.1);\n // vec4 texel = texture(SAMPLER_2D(u_Map), imagecoord);\n // u_Color = texel;\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=le(le({},this.material.defines),gi(Ni))}},{key:"createGeometry",value:function(e){var t=this;Ce(ye(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[];e.forEach((function(e,n){var a=e,s=4*n,u=a.parsedStyle.radius,l=t.shouldOmitStroke(a.parsedStyle),c=t.getSize(e.parsedStyle,a.nodeName);i.push.apply(i,Ne(c).concat([xi.indexOf(a.nodeName),u||0,l?1:0,0])),r.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:Ri.POSITION,byteStride:16,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ti.POSITION},{format:gt.F32_RG,bufferByteOffset:8,location:Ti.UV}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Ii.PACKED_STYLE,byteStride:24,frequency:at.PerInstance,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ni.SIZE,divisor:1},{format:gt.F32_RGBA,bufferByteOffset:8,location:Ni.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(Ce(ye(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"r"===r||"rx"===r||"ry"===r||"lineWidth"===r||"stroke"===r||"lineDash"===r||"strokeOpacity"===r){var a=[];e.forEach((function(e){var t=o.shouldOmitStroke(e.parsedStyle),r=Oe(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,[r[0],r[1]].concat([xi.indexOf(e.nodeName),e.parsedStyle.radius||0,t?1:0,0]))})),this.geometry.updateVertexBuffer(Ii.PACKED_STYLE,Ni.SIZE,t,new Uint8Array(new Float32Array(a).buffer))}}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i.value,i.value]}else if(r===t.Shape.ELLIPSE){n=[e.rx.value,e.ry.value]}return n}},{key:"shouldOmitStroke",value: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.value}));return!i||i&&(o||1>n.value)}},{key:"needDrawStrokeSeparately",value: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.value}));return o&&n.value>0&&(a||1>i.value)}}]),n}(Oi);Pi=d([t.injectable()],Pi);var Di,bi,Mi=[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"}(Di||(Di={})),function(e){e[e.POSITION=9]="POSITION",e[e.UV=11]="UV",e[e.POINTA=10]="POINTA",e[e.POINTB=12]="POINTB",e[e.CAP=13]="CAP",e[e.DASH=14]="DASH"}(bi||(bi={}));var Bi={butt:1,round:2,square:3},Li=function(e){Ee(n,e);var r=Ae(n);function n(){return de(this,n),r.apply(this,arguments)}return _e(n,[{key:"shouldMerge",value:function(e,r){var i=Ce(ye(n.prototype),"shouldMerge",this).call(this,e,r);if(!i)return!1;var o=this.instance;if(o.nodeName===t.Shape.LINE&&""+o.parsedStyle.stroke!=""+e.parsedStyle.stroke)return!1;return!0}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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;\n// out vec2 v_Normal;\n\nvoid main() {\n mat4 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 * 0.5 + 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 if (isBillboard < 0.5) {\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\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\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 }\n\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;\n// in vec2 v_Normal;\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 = 1. - smoothstep(0.98, 1., length(v_Normal));\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 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=le(le({},this.material.defines),gi(bi))}},{key:"createGeometry",value:function(e){var t=this;Ce(ye(n.prototype),"createGeometry",this).call(this,e);var r=[],i=[],o=[],a=[],s=0;e.forEach((function(e){var n=e.parsedStyle,u=n.x1,l=n.y1,c=n.x2,f=n.y2,h=n.z1,d=n.z2,p=n.defX,_=n.defY,v=n.lineCap,E=n.isBillboard,y=t.calcDash(e),g=y.dashOffset,m=y.dashSegmentPercent,R=y.dashRatioInEachSegment;i.push(Bi[v.value]),o.push(g,m,R,E?1:0),r.push(u.value-p,l.value-_,h.value,c.value-p,f.value-_,d.value),a.push(0+s,2+s,1+s,0+s,3+s,2+s),s+=4})),this.geometry.setIndexBuffer(new Uint32Array(a)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Ri.POSITION,byteStride:20,frequency:at.PerInstance,attributes:[{format:gt.F32_RGB,bufferByteOffset:0,location:bi.POSITION,divisor:0},{format:gt.F32_RG,bufferByteOffset:12,location:bi.UV,divisor:0}],data:new Float32Array(Mi)}),this.geometry.setVertexBuffer({bufferIndex:Di.POINT,byteStride:24,frequency:at.PerInstance,attributes:[{format:gt.F32_RGB,bufferByteOffset:0,location:bi.POINTA,divisor:1},{format:gt.F32_RGB,bufferByteOffset:12,location:bi.POINTB,divisor:1}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:Di.CAP,byteStride:4,frequency:at.PerInstance,attributes:[{format:gt.F32_R,bufferByteOffset:0,location:bi.CAP,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Di.DASH,byteStride:16,frequency:at.PerInstance,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:bi.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,t,r,i){var o=this;if(Ce(ye(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i),"x1"===r||"y1"===r||"x2"===r||"y2"===r||"z1"===r||"z2"===r){var a=[];e.forEach((function(e){var t=e.parsedStyle,r=t.defX,n=t.defY;a.push(t.x1.value-r,t.y1.value-n,t.z1.value,t.x2.value-r,t.y2.value-n,t.z2.value)})),this.geometry.updateVertexBuffer(Di.POINT,bi.POINTA,t,new Uint8Array(new Float32Array(a).buffer))}else if("lineDashOffset"===r||"lineDash"===r){var s=[];e.forEach((function(e){var t=o.calcDash(e);s.push(t.dashOffset,t.dashSegmentPercent,t.dashRatioInEachSegment,e.parsedStyle.isBillboard?1:0)})),this.geometry.updateVertexBuffer(Di.DASH,bi.DASH,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineCap"===r){var u=[];e.forEach((function(e){u.push(Bi[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Di.CAP,bi.CAP,t,new Uint8Array(new Float32Array(u).buffer))}}},{key:"calcDash",value:function(e){var t=e.parsedStyle,r=t.lineDash,n=t.lineDashOffset,i=e.getTotalLength(),o=0,a=1,s=0;if(r&&r.length){o=(n&&n.value||0)/i;var u=r.reduce((function(e,t){return e+t.value}),0);a=u/i,s=r[1].value/u}return{dashOffset:o,dashSegmentPercent:a,dashRatioInEachSegment:s}}}]),n}(Oi);function Fi(e){return function(e){if(Array.isArray(e))return Ui(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ui(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ui(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ui(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function wi(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}Li=d([t.injectable()],Li);var ki=function(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}};function Gi(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 Vi(e,t,r,n,i,o,a,s,u){var l=Gi(e,r,i,a,u),c=Gi(t,n,o,s,u),f=ki(e,t,r,n,u),h=ki(r,n,i,o,u),d=ki(i,o,a,s,u),p=ki(f.x,f.y,h.x,h.y,u),_=ki(h.x,h.y,d.x,d.y,u);return[[e,t,f.x,f.y,p.x,p.y,l,c],[l,c,_.x,_.y,d.x,d.y,a,s]]}function Wi(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+=wi(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var l=Vi(e,t,r,n,i,o,a,s,.5),c=[].concat(Fi(l[0]),[u-1]),f=[].concat(Fi(l[1]),[u-1]);return Wi.apply(void 0,Fi(c))+Wi.apply(void 0,Fi(f))}var Xi,Hi=function(e,t,r,n,i,o,a,s){return Wi(e,t,r,n,i,o,a,s,3)};!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"}(Xi||(Xi={}));var ji,Yi,Ki;!function(e){e[e.PACKED=0]="PACKED",e[e.VERTEX_NUM=1]="VERTEX_NUM",e[e.TRAVEL=2]="TRAVEL"}(ji||(ji={})),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"}(Yi||(Yi={})),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"}(Ki||(Ki={}));var zi=function(e){Ee(n,e);var r=Ae(n);function n(){return de(this,n),r.apply(this,arguments)}return _e(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;Ce(ye(n.prototype),"updateAttribute",this).call(this,e,r,i,o),e.forEach((function(e){var r=e.parsedStyle,n=r.stroke,s=r.opacity,u=r.fillOpacity,l=r.strokeOpacity,c=r.lineWidth,f=r.increasedLineWidthForHitTesting,h=r.anchor,d=r.lineDash,p=r.lineDashOffset,_=r.visibility;if("lineJoin"===i||"lineCap"===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 v=[0,0,0,0];n instanceof t.CSSRGB&&(v=[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]),a.material.setUniforms(ve({},Ki.STROKE_COLOR,v))}else if("opacity"===i)a.material.setUniforms(ve({},Ki.OPACITY,s.value));else if("fillOpacity"===i)a.material.setUniforms(ve({},Ki.FILL_OPACITY,u.value));else if("strokeOpacity"===i)a.material.setUniforms(ve({},Ki.STROKE_OPACITY,l.value));else if("lineWidth"===i)a.material.setUniforms(ve({},Ki.STROKE_WIDTH,c.value));else if("increasedLineWidthForHitTesting"===i)a.material.setUniforms(ve({},Ki.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,f.value));else if("anchor"===i||"modelMatrix"===i){var E=0,y=0,g=e.getGeometryBounds();if(g){var m=g.halfExtents;E=-m[0]*h[0].value*2,y=-m[1]*h[1].value*2}var R=Ge();He(R,e.getWorldTransform(),Xe(R,je(E,y,0))),a.material.setUniforms(ve({},Ki.MODEL_MATRIX,R))}else if("visibility"===i)a.material.setUniforms(ve({},Ki.VISIBLE,"visible"===_.value?1:0));else if("lineDash"===i){var T;a.material.setUniforms((ve(T={},Ki.DASH,d[0].value||0),ve(T,Ki.GAP,d[1].value||0),T))}else if("lineDashOffset"===i)a.material.setUniforms(ve({},Ki.DASH_OFFSET,p&&p.value||0));else if("pointerEvents"===i){var A,S=o&&e.isInteractive()&&(null===(A=e.renderable3D)||void 0===A?void 0:A.encodedPickingColor)||[0,0,0];a.material.setUniforms(ve({},Ki.PICKING_COLOR,S))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(ve({},Ki.Z_INDEX,t*vi))}},{key:"createMaterial",value:function(e){var r,n,i,o;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 travel = mod(v_Travel + u_Gap * 0.5 + u_DashOffset, u_Dash + u_Gap) - (u_Gap * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap + 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=le(le({},this.material.defines),gi(Yi));var a=e[0],s=a.parsedStyle,u=s.fill,l=s.stroke,c=s.opacity,f=s.fillOpacity,h=s.strokeOpacity,d=s.lineWidth,p=s.increasedLineWidthForHitTesting,_=s.anchor,v=s.lineDash,E=s.lineDashOffset,y=s.visibility,g=[0,0,0,0];u instanceof t.CSSRGB&&(g=[Number(u.r)/255,Number(u.g)/255,Number(u.b)/255,Number(u.alpha)]);var m=[0,0,0,0];l instanceof t.CSSRGB&&(m=[Number(l.r)/255,Number(l.g)/255,Number(l.b)/255,Number(l.alpha)]);var R=a.isInteractive()&&(null===(r=a.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],T=0,A=0,S=a.getGeometryBounds();if(S){var C=S.halfExtents;T=-C[0]*_[0].value*2,A=-C[1]*_[1].value*2}var O=Ge();He(O,a.getWorldTransform(),Xe(O,je(T,A,0))),this.material.setUniforms((ve(o={},Ki.MODEL_MATRIX,O),ve(o,Ki.FILL_COLOR,g),ve(o,Ki.STROKE_COLOR,m),ve(o,Ki.STROKE_WIDTH,d.value),ve(o,Ki.INCREASED_LINE_WIDTH_FOR_HIT_TESTING,p.value),ve(o,Ki.OPACITY,c.value),ve(o,Ki.FILL_OPACITY,f.value),ve(o,Ki.STROKE_OPACITY,h.value),ve(o,Ki.EXPAND,1),ve(o,Ki.MITER_LIMIT,5),ve(o,Ki.SCALE_MODE,1),ve(o,Ki.ALIGNMENT,.5),ve(o,Ki.PICKING_COLOR,R),ve(o,Ki.DASH,v&&(null===(n=v[0])||void 0===n?void 0:n.value)||0),ve(o,Ki.GAP,v&&(null===(i=v[1])||void 0===i?void 0:i.value)||0),ve(o,Ki.DASH_OFFSET,E&&E.value||0),ve(o,Ki.VISIBLE,"visible"===y.value?1:0),ve(o,Ki.Z_INDEX,a.sortable.renderOrder*vi),o)),this.material.cullMode=Qe.None}},{key:"createGeometry",value:function(e){var t=Qi(e[0]),r=t.travelBuffer,n=t.instancedCount;this.geometry.setVertexBuffer({bufferIndex:ji.PACKED,byteStride:48,frequency:at.PerInstance,attributes:[{format:gt.F32_RG,bufferByteOffset:0,byteStride:12,location:Yi.PREV,divisor:1},{format:gt.F32_RG,bufferByteOffset:12,byteStride:12,location:Yi.POINT1,divisor:1},{format:gt.F32_R,bufferByteOffset:20,byteStride:12,location:Yi.VERTEX_JOINT,divisor:1},{format:gt.F32_RG,bufferByteOffset:24,byteStride:12,location:Yi.POINT2,divisor:1},{format:gt.F32_RG,bufferByteOffset:36,byteStride:12,location:Yi.NEXT,divisor:1}],data:new Float32Array(t.pointsBuffer)}),this.geometry.setVertexBuffer({bufferIndex:ji.VERTEX_NUM,byteStride:4,frequency:at.PerInstance,attributes:[{format:gt.F32_R,bufferByteOffset:0,byteStride:4,location:Yi.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:ji.TRAVEL,byteStride:4,frequency:at.PerInstance,attributes:[{format:gt.F32_R,bufferByteOffset:0,byteStride:4,location:Yi.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]))}}]),n}(Oi);function qi(e,t,r,n,i,o,a){var s=a[a.length-2],u=a[a.length-1];a.length-=2;var l=function(e){var t=Math.ceil(e/10);8>t?t=8:t>Zi&&(t=Zi);return t}(Hi(s,u,e,t,r,n,i,o)),c=0,f=0,h=0,d=0,p=0;a.push(s,u);for(var _=1,v=0;l>=_;++_)a.push((h=(f=(c=1-(v=_/l))*c)*c)*s+3*f*v*e+3*c*(d=v*v)*r+(p=d*v)*i,h*u+3*f*v*t+3*c*d*n+p*o)}zi=d([t.injectable()],zi);var Zi=2048;function Qi(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.parsedStyle,i=n.lineCap,o=n.lineJoin,a=e.parsedStyle,s=a.defX,u=a.defY,l=[],c=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){if(l=e.parsedStyle.points.points.reduce((function(e,t){return e.push(t[0]-s,t[1]-u),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return c=P(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)};var f;l.push(l[0],l[1]),(f=l).push.apply(f,Ne(eo(l[0],l[1],l[2],l[3])))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var h;if(e.nodeName!==t.Shape.PATH){if(h=t.parsePath(t.convertToPath(e,!1),e),s=h.rect.x,u=h.rect.y,e.nodeName===t.Shape.RECT){var d=e.parsedStyle,p=d.width,_=d.height;0>p.value&&(s+=h.rect.width),0>_.value&&(u+=h.rect.height)}}else h=e.parsedStyle.path;var v=h,E=v.zCommandIndexes,y=Ne(h.curve).map((function(e,t){return E.includes(t)?["Z"]:e})),g=-1;if(y.forEach((function(r){var n=Ie(r),i=n[0],o=n.slice(1);if("M"===i)g=l.length,l.push(o[0]-s,o[1]-u);else if("C"===i)qi(o[0]-s,o[1]-u,o[2]-s,o[3]-u,o[4]-s,o[5]-u,l);else if("Z"===i&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var a,c=1e-4;(Math.abs(l[l.length-2]-l[g])>c||Math.abs(l[l.length-1]-l[g+1])>c)&&l.push(l[g],l[g+1]),(a=l).push.apply(a,Ne(eo(l[g],l[g+1],l[g+2],l[g+3])))}})),r)return c=P(l,[],2),{pointsBuffer:l,travelBuffer:[],triangles:c,instancedCount:Math.round(l.length/2)}}var m=Ji(o.value),R=$i(i.value),T=R;R===Xi.CAP_ROUND&&(T=Xi.JOINT_CAP_ROUND),R===Xi.CAP_BUTT&&(T=Xi.JOINT_CAP_BUTT),R===Xi.CAP_SQUARE&&(T=Xi.JOINT_CAP_SQUARE);for(var A=6,S=0,C=[],O=[],I=0;l.length>I;I+=2)I>1&&(S+=Math.sqrt(Math.pow(l[I]-l[I-2],2)+Math.pow(l[I+1]-l[I+1-2],2))),O.push(S),C[A++]=l[I],C[A++]=l[I+1],C[A]=m,0==I&&R!==Xi.CAP_ROUND&&(C[A]+=R),l.length>I+4?l.length>I+2||(C[A]=0):C[A]+=T-m,A++;C[A++]=l[l.length-4],C[A++]=l[l.length-3],C[A++]=0,C[0]=l[0],C[1]=l[1],C[2]=0,C[3]=l[2],C[4]=l[3],C[5]=R===Xi.CAP_ROUND?R:0;var N=Math.round(l.length/2);return{pointsBuffer:C,travelBuffer:O,triangles:c,instancedCount:N}}function Ji(e){var t;switch(e){case"bevel":t=Xi.JOINT_BEVEL;break;case"round":t=Xi.JOINT_ROUND;break;default:t=Xi.JOINT_MITER}return t}function $i(e){var t;switch(e){case"square":t=Xi.CAP_SQUARE;break;case"round":t=Xi.CAP_ROUND;break;default:t=Xi.CAP_BUTT}return t}function eo(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t,i=[r-e,n-t],o=.01;return[e+i[0]*o,t+i[1]*o]}var to=function(e){Ee(n,e);var r=Ae(n);function n(){return de(this,n),r.apply(this,arguments)}return _e(n,[{key:"shouldMerge",value:function(e,t){return!1}},{key:"createGeometry",value:function(e){var t=e[0],r=Qi(t,!0),n=r.triangles,i=r.pointsBuffer;this.geometry.setVertexBuffer({bufferIndex:Ri.POSITION,byteStride:8,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ti.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:Ri.UV,byteStride:8,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ti.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},{key:"createMaterial",value: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];a instanceof t.CSSRGB&&(f=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)]);var h=i.isInteractive()&&(null===(r=i.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],d=0,p=0,_=i.getGeometryBounds();if(_){var v=_.halfExtents;d=-v[0]*l[0].value*2,p=-v[1]*l[1].value*2}var E=Ge();He(E,i.getWorldTransform(),Xe(E,je(d,p,0))),this.material.setUniforms((ve(n={},Ki.MODEL_MATRIX,E),ve(n,Ki.FILL_COLOR,f),ve(n,Ki.PICKING_COLOR,h),ve(n,Ki.OPACITY,s.value),ve(n,Ki.FILL_OPACITY,u.value),ve(n,Ki.VISIBLE,"visible"===c.value?1:0),ve(n,Ki.Z_INDEX,i.sortable.renderOrder*vi),n))}},{key:"updateAttribute",value:function(e,r,i,o){var a=this;Ce(ye(n.prototype),"updateAttribute",this).call(this,e,r,i,o),e.forEach((function(e){var r=e.parsedStyle,n=r.fill,s=r.opacity,u=r.fillOpacity,l=r.anchor,c=r.visibility;if("lineJoin"===i||"lineCap"===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(n instanceof t.CSSRGB){a.material.setUniforms(ve({},Ki.FILL_COLOR,[Number(n.r)/255,Number(n.g)/255,Number(n.b)/255,Number(n.alpha)]))}else{var f=a.textureMappings.findIndex((function(e){return e.name===Ci})),h=a.createFillGradientTextureMapping([a.instance]);0>f||a.textureMappings.splice(f,1,h),a.material.textureDirty=!0}else if("opacity"===i)a.material.setUniforms(ve({},Ki.OPACITY,s.value));else if("fillOpacity"===i)a.material.setUniforms(ve({},Ki.FILL_OPACITY,u.value));else if("anchor"===i||"modelMatrix"===i){var d=0,p=0,_=e.getGeometryBounds();if(_){var v=_.halfExtents;d=-v[0]*l[0].value*2,p=-v[1]*l[1].value*2}var E=Ge();He(E,e.getWorldTransform(),Xe(E,je(d,p,0))),a.material.setUniforms(ve({},Ki.MODEL_MATRIX,E))}else if("visibility"===i)a.material.setUniforms(ve({},Ki.VISIBLE,"visible"===c.value?1:0));else if("pointerEvents"===i){var y,g=o&&e.isInteractive()&&(null===(y=e.renderable3D)||void 0===y?void 0:y.encodedPickingColor)||[0,0,0];a.material.setUniforms(ve({},Ki.PICKING_COLOR,g))}}))}},{key:"changeRenderOrder",value:function(e,t){this.material&&this.material.setUniforms(ve({},Ki.Z_INDEX,t*vi))}}]),n}(Oi);to=d([t.injectable()],to);var ro=function(e){Ee(r,e);var t=Ae(r);function r(){return de(this,r),t.apply(this,arguments)}return _e(r,[{key:"shouldMerge",value:function(e,t){var n=Ce(ye(r.prototype),"shouldMerge",this).call(this,e,t);return!!n&&this.instance.parsedStyle.img===e.parsedStyle.img}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.img;this.material.defines=le({},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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\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 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.device,t);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){Ce(ye(r.prototype),"createGeometry",this).call(this,e);var t=[],n=[],i=[];e.forEach((function(e,r){var o=4*r,a=e.parsedStyle;t.push(a.width.value,a.height.value),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:Ri.POSITION,byteStride:8,frequency:at.PerInstance,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ti.POSITION}],data:new Float32Array(t)}),this.geometry.setVertexBuffer({bufferIndex:Ri.UV,byteStride:8,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:Ti.UV}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){if(Ce(ye(r.prototype),"updateAttribute",this).call(this,e,t,n,i),this.updateBatchedAttribute(e,t,n,i),"width"===n||"height"===n){var o=[];e.forEach((function(e){var t=e.parsedStyle;o.push(t.width.value,t.height.value)})),this.geometry.updateVertexBuffer(Ri.POSITION,Ti.POSITION,t,new Uint8Array(new Float32Array(o).buffer))}else if("img"===n){var a=this.texturePool.getOrCreateTexture(this.device,i);this.material.setUniforms({u_Map:a})}}}]),r}(Oi);ro=d([t.injectable()],ro);function no(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 io(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 oo=function(){function e(t,r){de(this,e),this.width=void 0,this.height=void 0,this.data=void 0,no(this,t,1,r)}return _e(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=no({},{width:n,height:i},r);io(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)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){io(e,t,r,n,i,1)}}]),e}();var ao=_e((function e(t){de(this,e),this.image=void 0,this.positions=void 0;var r={},n=[];for(var i in t){var o=t[i],a=r[i]={};for(var s in o){if((c=o[+s])&&0!==c.bitmap.width&&0!==c.bitmap.height)n.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),a[s]={rect:f,metrics:c.metrics}}}var u=function(e){var t,r=0,n=0,i=Be(e);try{for(i.s();!(t=i.n()).done;){var o=t.value;r+=o.w*o.h,n=Math.max(n,o.w)}}catch(e){i.e(e)}finally{i.f()}e.sort((function(e,t){return t.h-e.h}));var a,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=Be(e);try{for(c.s();!(a=c.n()).done;)for(var f=a.value,h=s.length-1;h>=0;h--){var d=s[h];if(d.w>=f.w&&d.h>=f.h){if(f.x=d.x,f.y=d.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===d.w&&f.h===d.h){var p=s.pop();s.length>h&&(s[h]=p)}else f.h===d.h?(d.x+=f.w,d.w-=f.w):f.w===d.w?(d.y+=f.h,d.h-=f.h):(s.push({x:d.x+f.w,y:d.y,w:d.w-f.w,h:f.h}),d.y+=f.h,d.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),l=new oo({width:u.w||1,height:u.h||1});for(var i in t){o=t[i];for(var s in o){var c,f;if((c=o[+s])&&0!==c.bitmap.width&&0!==c.bitmap.height)oo.copy(c.bitmap,l,{x:0,y:0},{x:(f=r[i][s].rect).x+1,y:f.y+1},c.bitmap)}}this.image=l,this.positions=r}));function so(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}var uo,lo,co,fo=function(){function e(){de(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphAtlas=void 0,this.glyphMap={},this.glyphAtlasTexture=void 0}return _e(e,[{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,r,n,i,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}},{key:"generateAtlas",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,s=[];this.glyphMap[t]||(s=so());var u=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(o.split(""))).forEach((function(e){-1===u.indexOf(""+e.charCodeAt(0))&&s.push(e)})),s.length){var l=s.map((function(o){return e.generateSDF(t,r,n,i,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=le(le({},this.glyphMap[t]),l),this.glyphAtlas=new ao(this.glyphMap);var c=this.glyphAtlas.image,f=c.width,h=c.height,d=c.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=a.createTexture(le(le({},Rt(gt.ALPHA,f,h,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1},immutable:!1})),this.glyphAtlasTexture.setImageData([d],0)}}},{key:"generateSDF",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o=i.charCodeAt(0),a=this.sdfGeneratorCache[e];a||(a=this.sdfGeneratorCache[e]=new oe({fontSize:24,fontFamily:t,fontWeight:r,fontStyle:n,buffer:3,radius:8,cutoff:.25})),this.textMetricsCache[e]||(this.textMetricsCache[e]={}),this.textMetricsCache[e][i]||(this.textMetricsCache[e][i]=a.ctx.measureText(i).width);var s=a.draw(i),u=s.data,l=s.width,c=s.height,f=s.glyphWidth,h=s.glyphHeight,d=s.glyphLeft,p=s.glyphTop,_=s.glyphAdvance;return{id:o,bitmap:new oo({width:l,height:c},u),metrics:{width:f,height:h,left:d,top:p-24+3,advance:_}}}}]),e}();fo=d([t.injectable()],fo),function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(uo||(uo={})),function(e){e[e.TEX=13]="TEX",e[e.OFFSET=14]="OFFSET"}(lo||(lo={})),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"}(co||(co={}));var ho=function(e){Ee(n,e);var r=Ae(n);function n(){var e;de(this,n);for(var t=arguments.length,i=Array(t),o=0;t>o;o++)i[o]=arguments[o];return(e=r.call.apply(r,[this].concat(i))).glyphManager=void 0,e}return _e(n,[{key:"shouldMerge",value:function(e,t){var r=Ce(ye(n.prototype),"shouldMerge",this).call(this,e,t);if(!r)return!1;if(this.index!==t)return!1;var i=this.instance;return i.parsedStyle.fontSize.value===e.parsedStyle.fontSize.value&&(i.parsedStyle.metrics.font===e.parsedStyle.metrics.font&&!["fontFamily","fontWeight","textBaseline","letterSpacing"].some((function(t){return i.parsedStyle[t]!==e.parsedStyle[t]})))}},{key:"createGeometry",value:function(e){var r=this,n=this.instance.parsedStyle,i=n.textBaseline,o=n.letterSpacing,a=void 0===o?0:o,s=24/n.fontSize.value,u=[],l=[],c=[],f=0;e.forEach((function(e){var n=e.parsedStyle,o=n.metrics,h=n.dx,d=n.dy,p=o.font,_=o.lines,v=o.height,E=o.lineHeight,y=0,g=0;h&&h.unit===t.UnitType.kPixels&&(y+=h.value),d&&d.unit===t.UnitType.kPixels&&(g+=d.value);var m=0;"middle"===i.value?m=-v/2:"bottom"===i.value?m=-v:"top"===i.value||"hanging"===i.value?m=0:"alphabetic"===i.value?m=.25*E-v:"ideographic"===i.value&&(m=-v);var R=r.glyphManager.getAtlas(),T=r.buildTextBuffers({object:e,lines:_,fontStack:p,lineHeight:s*E,offsetX:s*y,offsetY:s*(m+g),letterSpacing:s*a,glyphAtlas:R,indicesOffset:f}),A=T.indexBuffer,S=T.charUVOffsetBuffer;f=T.indicesOffset,c.push.apply(c,Ne(T.charPackedBuffer)),l.push.apply(l,Ne(S)),u.push.apply(u,Ne(A))})),this.geometry.vertexCount=u.length,this.geometry.setIndexBuffer(new Uint32Array(u)),this.geometry.setVertexBuffer({bufferIndex:uo.INSTANCED,byteStride:144,frequency:at.PerVertex,attributes:[{format:gt.F32_RGBA,bufferByteOffset:0,location:Ti.MODEL_MATRIX0},{format:gt.F32_RGBA,bufferByteOffset:16,location:Ti.MODEL_MATRIX1},{format:gt.F32_RGBA,bufferByteOffset:32,location:Ti.MODEL_MATRIX2},{format:gt.F32_RGBA,bufferByteOffset:48,location:Ti.MODEL_MATRIX3},{format:gt.F32_RGBA,bufferByteOffset:64,location:Ti.COLOR},{format:gt.F32_RGBA,bufferByteOffset:80,location:Ti.STROKE_COLOR},{format:gt.F32_RGBA,bufferByteOffset:96,location:Ti.PACKED_STYLE1},{format:gt.F32_RGBA,bufferByteOffset:112,location:Ti.PACKED_STYLE2},{format:gt.F32_RGBA,bufferByteOffset:128,location:Ti.PICKING_COLOR}],data:new Float32Array(c)}),this.geometry.setVertexBuffer({bufferIndex:uo.TEX,byteStride:16,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:lo.TEX},{format:gt.F32_RG,bufferByteOffset:8,location:lo.OFFSET}],data:new Float32Array(l)})}},{key:"createMaterial",value: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(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\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 = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\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}\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\nvoid main() {\n mat4 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 * 0.5 + 0.5;\n#endif\n\n v_UV = a_Tex / u_SDFMapSize;\n\n float fontScale = u_FontSize / 24.;\n\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}",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 vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nin vec2 v_UV;\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=Qe.Back,this.material.defines=le(le({},this.material.defines),gi(lo));var r=this.instance.parsedStyle,n=r.fontSize,i=r.fontFamily,o=void 0===i?"":i,a=r.fontWeight,s=r.fontStyle,u=r.metrics.font,l=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(u,o,""+a,""+s,l,this.device);var c=this.glyphManager.getAtlasTexture(),f=this.glyphManager.getAtlas();this.device.setResourceName(c,"TextSDF Texture");var h=f.image,d=h.width,p=h.height;this.material.setUniforms((ve(t={},co.SDF_MAP,c),ve(t,co.SDF_MAP_SIZE,[d,p]),ve(t,co.FONT_SIZE,n.value),ve(t,co.GAMMA_SCALE,1),ve(t,co.STROKE_BLUR,.2),ve(t,co.HAS_STROKE,this.index),t))}},{key:"changeRenderOrder",value:function(e,t){this.material&&(this.material.programDirty=!0,this.material.geometryDirty=!0)}},{key:"updateAttribute",value:function(e,t,r,n){"text"===r||"fontFamily"===r||"fontSize"===r||"fontWeight"===r||"fontStyle"===r||"fontVariant"===r||"textBaseline"===r||"letterSpacing"===r||"wordWrapWidth"===r||"lineHeight"===r||"wordWrap"===r||"textAlign"===r||"modelMatrix"===r||"visibility"===r||"dx"===r||"dy"===r?(this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0):"fill"!==r&&"fillOpacity"!==r&&"stroke"!==r&&"strokeOpacity"!==r&&"opacity"!==r&&"lineWidth"!==r&&"visibility"!==r&&"pointerEvents"!==r||(this.material.geometryDirty=!0)}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,h=n.parsedStyle,d=h.textAlign,p=h.fill,_=h.stroke,v=h.opacity,E=h.fillOpacity,y=h.strokeOpacity,g=h.lineWidth,m=h.visibility,R=[0,0,0,0];p instanceof t.CSSRGB&&(R=[Number(p.r)/255,Number(p.g)/255,Number(p.b)/255,Number(p.alpha)]);var T=[0,0,0,0];_ instanceof t.CSSRGB&&(T=[Number(_.r)/255,Number(_.g)/255,Number(_.b)/255,Number(_.alpha)]);var A=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=Ve(Ge(),n.getWorldTransform()),C=[],O=[],I=[],N=f,x=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],h=c+s.w*i.scale,d=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:h,y:f},bl:{x:c,y:d},br:{x:h,y:d},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,d.value,s,u,l),c.positions);return x.forEach((function(e){var t=[];t.push.apply(t,Ne(S));var r=[].concat(t,Ne(R),Ne(T),[v.value,E.value,y.value,g.value,"visible"===m.value?1:0,0,0,0],Ne(A),[n.sortable.renderOrder*vi]);C.push.apply(C,Ne(r).concat(Ne(r),Ne(r),Ne(r))),O.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),O.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),O.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),O.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),I.push(0+N,2+N,1+N),I.push(2+N,0+N,3+N),N+=4})),{indexBuffer:I,charUVOffsetBuffer:O,charPackedBuffer:C,indicesOffset:N}}}]),n}(Oi);d([t.inject(fo),p("design:type",fo)],ho.prototype,"glyphManager",void 0),ho=d([t.injectable()],ho);var po=function(e){Ee(n,e);var r=Ae(n);function n(){return de(this,n),r.apply(this,arguments)}return _e(n,[{key:"shouldMerge",value:function(e,r){var i=Ce(ye(n.prototype),"shouldMerge",this).call(this,e,r);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,r,i){Ce(ye(n.prototype),"updateAttribute",this).call(this,e,t,r,i),this.updateBatchedAttribute(e,t,r,i)}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,Ce(ye(n.prototype),"createGeometry",this).call(this,e),this.geometry.build(e),this.observeGeometryChanged()}}]),n}(Oi);po=d([t.injectable()],po);var _o=function(){function e(){de(this,e)}return _e(e,[{key:"update",value:function(e){return e.geometry.computeBoundingBox(),{width:0,height:0,depth:0}}}]),e}();_o=d([t.singleton({token:{token:t.GeometryAABBUpdater,named:t.Shape.MESH}})],_o);var vo=function(){function e(){de(this,e),this.counter=0,this.id2DisplayObjectMap={}}return _e(e,[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=Oe(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}]),e}();vo=d([t.singleton()],vo);var Eo=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Pi,zi],e}return _e(r,[{key:"shouldSubmitRenderInst",value:function(e,t){if(0===t&&e.parsedStyle.fill.isNone)return!1;return 1!==t||this.needDrawStrokeSeparately(e)}},{key:"needDrawStrokeSeparately",value: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.value}));return!s||u&&o.value>0&&(1>a.value||l)}}]),r}(yi);Eo=d([t.injectable({token:[{token:hi,named:t.Shape.CIRCLE},{token:hi,named:t.Shape.ELLIPSE}]})],Eo);var yo=function(e){Ee(n,e);var r=Ae(n);function n(){var e;de(this,n);for(var t=arguments.length,i=Array(t),o=0;t>o;o++)i[o]=arguments[o];return(e=r.call.apply(r,[this].concat(i))).meshes=[to,zi],e}return _e(n,[{key:"shouldSubmitRenderInst",value: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,h=u&&u.length&&u.every((function(e){return 0!==e.value}));if(0===r&&(e.nodeName===t.Shape.POLYLINE||i.isNone))return!1;if(1===r){if(0===s.value||0===a.value||0===l.value||!f)return!1;if(c===t.Shape.CIRCLE||c===t.Shape.ELLIPSE)return h}return!0}}]),n}(yi);yo=d([t.injectable({token:[{token:hi,named:t.Shape.POLYLINE},{token:hi,named:t.Shape.PATH},{token:hi,named:t.Shape.POLYGON},{token:hi,named:t.Shape.RECT}]})],yo);var go=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[],e}return _e(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(yi);go=d([t.injectable({token:[{token:hi,named:t.Shape.GROUP}]})],go);var mo=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[ro],e}return _e(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(yi);mo=d([t.injectable({token:[{token:hi,named:t.Shape.IMAGE}]})],mo);var Ro=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[ho,ho],e}return _e(r,[{key:"shouldSubmitRenderInst",value:function(e,t){var r=e.parsedStyle,n=r.lineWidth;return!(!(r.stroke&&n&&n.value)&&0===t)}},{key:"beforeUploadUBO",value:function(e,t,r){t.material.setUniforms(ve({},co.HAS_STROKE,1-t.index))}}]),r}(yi);Ro=d([t.injectable({token:[{token:hi,named:t.Shape.TEXT}]})],Ro);var To=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[Li],e}return _e(r,[{key:"shouldSubmitRenderInst",value:function(e,t){return!0}}]),r}(yi);To=d([t.injectable({token:{token:hi,named:t.Shape.LINE}})],To);var Ao=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).meshes=[po],e}return _e(r)}(yi);Ao=d([t.injectable({token:[{token:hi,named:t.Shape.MESH}]})],Ao);var So=t.Syringe.defineToken("DeviceContribution"),Co=["style"],Oo=function(e){Ee(r,e);var t=Ae(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=me(e,Co);return de(this,r),t.call(this,le({type:r.tag,style:le({intensity:Math.PI},n)},i))}return _e(r)}(t.DisplayObject);Oo.tag="light";var Io,No=["style"];!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(Io||(Io={}));var xo,Po,Do=function(e){Ee(r,e);var t=Ae(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.style,i=me(e,No);return de(this,r),t.call(this,le({type:r.tag,style:le({type:Io.NONE,fill:"black",start:1,end:1e3,density:0},n)},i))}return _e(r)}(t.DisplayObject);Do.tag="fog";var bo;!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"}(bo||(bo={}));var Mo,Bo,Lo=(xo=function(){function e(){de(this,e),this.canvasConfig=void 0,this.contextService=void 0,this.renderingContext=void 0,this.camera=void 0,this.renderHelper=void 0,this.lightPool=void 0,this.texturePool=void 0,this.batchManager=void 0,this.deviceContribution=void 0,this.device=void 0,this.swapChain=void 0,this.renderLists={world:new Zn,picking:new Zn},this.builder=void 0}return _e(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(e){var r=this,n=function(e){var t=e.target;if(t.nodeName!==Oo.tag)if(t.nodeName!==Do.tag){var n=new Le;t.renderable3D=n,r.batchManager.add(t)}else r.lightPool.addFog(t);else r.lightPool.addLight(t)},i=function(e){var t=e.target;t.nodeName!==Oo.tag?t.nodeName!==Do.tag?(r.batchManager.remove(t),delete t.renderable3D):r.lightPool.removeFog(t):r.lightPool.removeLight(t)},o=function(e){r.batchManager.updateAttribute(e.target,e.attrName,e.newValue)},a=function(e){r.batchManager.changeRenderOrder(e.target,e.detail.renderOrder)};e.hooks.init.tapPromise(Po.tag,he(ce().mark((function s(){var u,l;return ce().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.addEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a),r.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering=!1,u=r.contextService.getDomElement(),r.contextService.resize((l=r.canvasConfig).width,l.height),s.next=10,r.deviceContribution.createSwapChain(u);case 10:r.swapChain=s.sent,r.device=r.swapChain.getDevice(),r.renderHelper.setDevice(r.device),r.renderHelper.renderInstManager.disableSimpleMode(),r.swapChain.configureSwapChain(u.width,u.height),r.renderingContext.root.ownerDocument.defaultView.addEventListener(t.CanvasEvent.RESIZE,(function(){r.swapChain.configureSwapChain(u.width,u.height)})),r.batchManager.attach(r.device,e);case 17:case"end":return s.stop()}}),s)})))),e.hooks.destroy.tap(Po.tag,(function(){r.renderHelper.destroy(),r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o),r.renderingContext.root.removeEventListener(t.ElementEvent.RENDER_ORDER_CHANGED,a)})),e.hooks.beginFrame.tap(Po.tag,(function(){var e=r.swapChain.getCanvas(),n=r.renderHelper.renderInstManager;r.builder=r.renderHelper.renderGraph.newGraphBuilder();var i=t.parseColor(r.canvasConfig.background),o=r.canvasConfig.background?Lt(Number(i.r)/255*Number(i.alpha),Number(i.g)/255*Number(i.alpha),Number(i.b)/255*Number(i.alpha),Number(i.alpha)):Ft,a={backbufferWidth:e.width,backbufferHeight:e.height,antialiasingMode:ri.None},s=si(Cn.Color0,a,ti(o)),u=si(Cn.DepthStencil,a,oi),l=r.builder.createRenderTargetID(s,"Main Color"),c=r.builder.createRenderTargetID(u,"Main Depth");r.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Cn.Color0,l),e.attachRenderTargetID(Cn.DepthStencil,c),e.exec((function(e){r.renderLists.world.drawOnPassRenderer(n.renderCache,e)}))})),r.builder.resolveRenderTargetToExternalTexture(l,r.swapChain.getOnscreenTexture())})),e.hooks.endFrame.tap(Po.tag,(function(){var e=r.renderHelper.renderInstManager,t=r.renderHelper.pushTemplateRenderInst();t.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),t.setMegaStateFlags(ur({depthWrite:!0,blendConstant:Ft},{rgbBlendMode:$e.Add,alphaBlendMode:$e.Add,rgbBlendSrcFactor:Je.SrcAlpha,alphaBlendSrcFactor:Je.One,rgbBlendDstFactor:Je.OneMinusSrcAlpha,alphaBlendDstFactor:Je.OneMinusSrcAlpha}));var n=r.canvasConfig,i=n.width,o=n.height;t.setUniforms(0,[{name:bo.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:bo.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:bo.CAMERA_POSITION,value:r.camera.getPosition()},{name:bo.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:bo.VIEWPORT,value:[i,o]},{name:bo.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:bo.IS_PICKING,value:0}]),r.batchManager.render(r.renderLists.world),e.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),e.resetRenderInsts(),r.swapChain.present()}))}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))}}]),e}(),xo.tag="RenderGraph",Po=xo);d([t.inject(t.CanvasConfig),p("design:type",Object)],Lo.prototype,"canvasConfig",void 0),d([t.inject(t.ContextService),p("design:type",Object)],Lo.prototype,"contextService",void 0),d([t.inject(t.RenderingContext),p("design:type",Object)],Lo.prototype,"renderingContext",void 0),d([t.inject(t.DefaultCamera),p("design:type",t.Camera)],Lo.prototype,"camera",void 0),d([t.inject($n),p("design:type",$n)],Lo.prototype,"renderHelper",void 0),d([t.inject(Fe),p("design:type",Fe)],Lo.prototype,"lightPool",void 0),d([t.inject(ci),p("design:type",ci)],Lo.prototype,"texturePool",void 0),d([t.inject(_i),p("design:type",_i)],Lo.prototype,"batchManager",void 0),d([t.inject(So),p("design:type",Object)],Lo.prototype,"deviceContribution",void 0),Lo=Po=d([t.singleton({contrib:t.RenderingPluginContribution})],Lo);var Fo=(Mo=function(){function e(){de(this,e),this.canvasConfig=void 0,this.sceneGraphService=void 0,this.contextService=void 0,this.renderingContext=void 0,this.renderHelper=void 0,this.renderGraphPlugin=void 0,this.pickingIdGenerator=void 0,this.camera=void 0,this.batchManager=void 0}var r;return _e(e,[{key:"apply",value:function(e){var r=this,n=function(e){var t=e.target,n=t.renderable3D;if(n){var i=r.pickingIdGenerator.getId(t);n.pickingId=i,n.encodedPickingColor=r.pickingIdGenerator.encodePickingColor(i)}};e.hooks.init.tapPromise(Bo.tag,he(ce().mark((function e(){return ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n);case 1:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Bo.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n)})),e.hooks.pick.tapPromise(Bo.tag,function(){var e=he(ce().mark((function e(n){var i,o,a,s,u,l,c,f,h;return ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.topmost,a=(o=n.position).viewportX,s=o.viewportY,u=r.contextService.getDPR(),c=r.canvasConfig.height*u,h=s*u,!((f=a*u)>(l=r.canvasConfig.width*u)||0>f||h>c||0>h)){e.next=10;break}return n.picked=[],e.abrupt("return",n);case 10:return e.next=12,r.pickByRectangleInDepth(new t.Rectangle(t.clamp(Math.round(f),0,l-1),t.clamp(Math.round(h),0,c-1),1,1),i?1:100);case 12:return n.picked=e.sent,e.abrupt("return",n);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pickByRectangleInDepth",value:(r=he(ce().mark((function e(t){var r,n,i,o,a=arguments;return ce().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=a.length>1&&void 0!==a[1]?a[1]:100,n=null,i=1,o=[];case 4:return e.next=6,this.pickByRectangle(t,n);case 6:if(!(n=e.sent)){e.next=12;break}i++,o.push(n),e.next=13;break;case 12:return e.abrupt("break",14);case 13:if(n&&r>=i){e.next=4;break}case 14:return r>1&&this.restorePickingColor(o),e.abrupt("return",o);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"restorePickingColor",value:function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))}},{key:"pickByRectangle",value:function(e,t){var r=this,n=this.renderGraphPlugin.getDevice(),i=this.renderGraphPlugin.getRenderLists(),o=this.renderHelper.renderInstManager,a=this.renderHelper.renderGraph.newGraphBuilder(),s=e.x,u=e.y,l=e.width,c=e.height,f={backbufferWidth:l,backbufferHeight:c,antialiasingMode:ri.None},h=si(Cn.Color0,f,ti(Ft)),d=a.createRenderTargetID(h,"Picking Color"),p=si(Cn.DepthStencil,f,oi),_=a.createRenderTargetID(p,"Picking Depth"),v=le({},this.camera.getView());return new Promise((function(e){r.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),a.pushPass((function(t){t.setDebugName("Picking Pass"),t.attachRenderTargetID(Cn.Color0,d),t.attachRenderTargetID(Cn.DepthStencil,_),t.exec((function(e){i.picking.drawOnPassRenderer(o.renderCache,e)})),t.post((function(t){var i=t.getRenderTargetTexture(Cn.Color0),o=n.createReadback();v&&v.enabled?r.camera.setViewOffset(v.fullWidth,v.fullHeight,v.offsetX,v.offsetY,v.width,v.height):r.camera.clearViewOffset(),r.camera.setEnableUpdate(!0),o.readTexture(i,0,0,l,c,new Uint8Array(l*c*4)).then((function(t){var n,i=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(i=r.pickingIdGenerator.decodePickingColor(t)),i>-1){var a=r.pickingIdGenerator.getById(i);a&&a.isVisible()&&a.isInteractive()&&(n=a)}o.destroy(),e(n)}))}))}));var f=r.renderHelper.pushTemplateRenderInst();f.setBindingLayouts([{numUniformBuffers:2,numSamplers:0}]),f.setMegaStateFlags(ur({depthWrite:!0},{rgbBlendMode:$e.Add,rgbBlendSrcFactor:Je.One,rgbBlendDstFactor:Je.Zero,alphaBlendMode:$e.Add,alphaBlendSrcFactor:Je.One,alphaBlendDstFactor:Je.Zero}));var h=r.canvasConfig,p=h.width,E=h.height,y=r.contextService.getDPR();r.camera.setEnableUpdate(!1),r.camera.setViewOffset(p*y,E*y,s,u,l,c),f.setUniforms(0,[{name:bo.PROJECTION_MATRIX,value:r.camera.getPerspective()},{name:bo.VIEW_MATRIX,value:r.camera.getViewTransform()},{name:bo.CAMERA_POSITION,value:r.camera.getPosition()},{name:bo.DEVICE_PIXEL_RATIO,value:r.contextService.getDPR()},{name:bo.VIEWPORT,value:[p,E]},{name:bo.IS_ORTHO,value:r.camera.isOrtho()?1:0},{name:bo.IS_PICKING,value:1}]),t&&r.batchManager.updateAttribute(t,"pointerEvents",!1,!0),r.batchManager.render(i.picking,!0),o.popTemplateRenderInst(),r.renderHelper.prepareToRender(),r.renderHelper.renderGraph.execute(),o.resetRenderInsts()}))}}]),e}(),Mo.tag="WebGLPicker",Bo=Mo);d([t.inject(t.CanvasConfig),p("design:type",Object)],Fo.prototype,"canvasConfig",void 0),d([t.inject(t.SceneGraphService),p("design:type",Object)],Fo.prototype,"sceneGraphService",void 0),d([t.inject(t.ContextService),p("design:type",Object)],Fo.prototype,"contextService",void 0),d([t.inject(t.RenderingContext),p("design:type",Object)],Fo.prototype,"renderingContext",void 0),d([t.inject($n),p("design:type",$n)],Fo.prototype,"renderHelper",void 0),d([t.inject(Lo),p("design:type",Lo)],Fo.prototype,"renderGraphPlugin",void 0),d([t.inject(vo),p("design:type",vo)],Fo.prototype,"pickingIdGenerator",void 0),d([t.inject(t.DefaultCamera),p("design:type",t.Camera)],Fo.prototype,"camera",void 0),d([t.inject(_i),p("design:type",_i)],Fo.prototype,"batchManager",void 0),Fo=Bo=d([t.singleton({contrib:t.RenderingPluginContribution})],Fo);var Uo,wo,ko,Go="#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}",Vo="#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}",Wo=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).vert=Go,e.frag=Vo,e.features={},e}return _e(r)}(fn),Xo="#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}",Ho=function(e){Ee(r,e);var t=Ae(r);function r(){var e;de(this,r);for(var n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert=Go,e.frag=Xo,e}return _e(r)}(fn),jo=Zt(1,(function(){return new ui}));var Yo,Ko,zo=t.Module((function(e){e($n),e(ci),e(Fe),e(fo),e(vo),e(_i),e(Lo),e(Fo),e(Pi),e(Li),e(zi),e(to),e(ro),e(ho),e(po),e({token:di,useFactory:function(e){return function(t){return e.container.isBound(t)&&e.container.get(t)||null}}}),e(Eo),e(yo),e(mo),e(To),e(Ro),e(Ao),e({token:fi,useFactory:function(e){var t={};return function(r){return t[r]||e.container.isBoundNamed(hi,r)&&(t[r]=e.container.getNamed(hi,r)),t[r]||null}}})})),qo=function(){function e(){de(this,e),this.name="device-renderer",this.container=void 0}return _e(e,[{key:"init",value:function(e){t.GlobalContainer.isBound(_o)||t.GlobalContainer.register(_o),this.container=e,e.load(zo,!0)}},{key:"destroy",value:function(e){t.GlobalContainer.isBound(_o)&&t.GlobalContainer.remove(_o),e.unload(zo)}},{key:"getDevice",value:function(){return this.container.get(Lo).getDevice()}},{key:"loadTexture",value:function(e,t,r){return this.container.get(Lo).loadTexture(e,t,r)}}]),e}(),Zo=Object.freeze({__proto__:null,get AntialiasingMode(){return ri},get Batch(){return yi},get BlendFactor(){return Je},get BlendMode(){return $e},get BufferFrequencyHint(){return ot},BufferGeometry:tn,get BufferUsage(){return it},get ChannelWriteMask(){return ct},get ClipSpaceNearZ(){return pt},get CompareMode(){return qe},CopyProgram:Wo,get CullMode(){return Qe},DeviceContribution:So,DeviceProgram:fn,DynamicUniformBuffer:hn,get Endianness(){return lr},FILL_TEXTURE_MAPPING:Ci,get FillMesh(){return to},Fog:Do,get FogType(){return Io},get Format(){return gt},get FormatCompFlags(){return Et},get FormatFlags(){return yt},get FormatTypeFlags(){return vt},get FrontFaceMode(){return Ze},get GL(){return mt},get GeometryEvent(){return Qr},HashMap:En,IdentityViewportCoords:Nn,get ImageMesh(){return ro},get Instanced(){return Oi},get InstancedLineMesh(){return Li},IsDepthReversed:Gt,get JOINT_TYPE(){return Xi},Light:Oo,get LineMesh(){return zi},Material:ln,get MaterialEvent(){return en},Mesh:we,get MeshMesh(){return po},get MipFilterMode(){return rt},OpaqueBlack:Ut,OpaqueWhite:kt,Plugin:qo,get PrimitiveTopology(){return nt},get QueryPoolType(){return _t},get RGAttachmentSlot(){return Cn},RenderCache:On,get RenderGraphPlugin(){return Lo},get RenderHelper(){return $n},RenderInst:zn,get RenderInstExecutionOrder(){return Kn},get RenderInstFlags(){return Hn},RenderInstList:Zn,RenderInstManager:Jn,Renderable3D:Le,get RendererLayer(){return bn},get ResourceType(){return ze},get SDFMesh(){return Pi},get SamplerFormatKind(){return ht},ShaderMaterial:cn,SingleSampledTexture:Dn,get StencilOp(){return ft},TemporalTexture:li,get TexFilterMode(){return tt},get TextMesh(){return ho},get TextUniform(){return co},get TextureDimension(){return ut},get TextureEvent(){return st},TextureMapping:ui,get TexturePool(){return ci},get TextureUsage(){return lt},TransparentBlack:Ft,TransparentWhite:wt,UNIFORM_SETTERS:Jr,get Uniform(){return Ki},get VertexAttributeBufferIndex(){return Ri},get VertexAttributeLocation(){return Ti},get VertexBufferFrequency(){return at},get ViewportOrigin(){return dt},get WrapMode(){return et},align:jt,alignNonPowerOfTwo:Yt,arrayCopy:hr,arrayEqual:fr,assert:Pt,assertExists:Dt,bindingLayoutDescriptorCopy:Pr,bindingLayoutDescriptorEqual:_r,bindingLayoutSamplerDescriptorCopy:xr,bindingsDescriptorCopy:Nr,bindingsDescriptorEquals:vr,bisectRight:Kt,bufferBindingCopy:Ir,colorCopy:Mt,colorEqual:bt,colorNewCopy:Bt,colorNewFromRGBA:Lt,compareDefines:mi,compareDepthValues:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Gt;if((r=Vt(r,n))===qe.Less)return t>e;if(r===qe.LessEqual)return t>=e;if(r===qe.Greater)return e>t;if(r===qe.GreaterEqual)return e>=t;throw Error("whoops")},containerModule:zo,copyAttachmentState:$t,copyAttachmentStateFromSimple:nr,copyMegaState:rr,defaultBindingLayoutSamplerDescriptor:cr,defaultMegaState:or,definedProps:Ai,enumToObject:gi,fallbackUndefined:Wt,fillArray:Ht,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Yn,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:sr,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 It(Ct(e))*St(e)},getFormatCompByteSize:Nt,getFormatCompFlags:St,getFormatCompFlagsComponentCount:Tt,getFormatComponentCount:function(e){return St(e)},getFormatFlags:Ot,getFormatSamplerKind:xt,getFormatTypeFlags:Ct,getFormatTypeFlagsByteSize:It,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 Ur},getUniformSetter:function(e,t,r){var n=Jr[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)},getUniforms:on,hashCodeNumberFinish:pn,hashCodeNumberUpdate:dn,inputLayoutBufferDescriptorCopy:Mr,inputLayoutBufferDescriptorEquals:Ar,inputLayoutDescriptorCopy:Br,inputLayoutDescriptorEquals:Sr,isPowerOfTwo:function(e){return e&&0==(e&e-1)},leftPad:Qt,makeAttachmentClearDescriptor:ti,makeBackbufferDescSimple:si,makeDepthKey:Fn,makeFormat:At,makeMegaState:ar,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&bn.TRANSLUCENT?Vn(e):kn(e,t)},makeSortKeyOpaque:kn,makeSortKeyTranslucent:Vn,makeStaticDataBuffer:$r,makeTextureDescriptor2D:Rt,nArray:Zt,nullHashFunc:_n,nullify:Xt,opaqueBlackFullClearRenderPassDescriptor:ii,opaqueWhiteFullClearRenderPassDescriptor:oi,parseUniformName:function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(wr);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){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=e.split("\n");return r.map((function(e,r){return"".concat(Qt(""+(t+r),4," ")," ").concat(e)})).join("\n")},preprocessProgramObj_GLSL:un,preprocessProgram_GLSL:sn,preprocessShader_GLSL:an,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===pt.NegativeOne?function(e){He(e,Xn,e)}(e):t===pt.Zero&&function(e){He(e,jn,e)}(e))},pushFXAAPass:function(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Cn.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(sr),a.setBindingLayouts([{numUniformBuffers:1,numSamplers:1}]),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);Yn(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Ho,l=t.renderCache.createProgram(u);a.setProgram(l),Uo||((Uo=new tn(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,frequency:at.PerVertex,attributes:[{format:gt.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([-4,-4,4,-4,0,4])}),Uo.vertexCount=3,ko=t.getCache().createInputLayout(Uo.inputLayoutDescriptor),wo=t.getDevice().createInputState(ko,Uo.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null,l)),i.exec((function(e,r){jo[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(jo),a.setInputLayoutAndState(ko,wo),a.drawOnPass(t.renderCache,e)}))}))},range:function(e,t){for(var r=[],n=e;e+t>n;n++)r.push(n);return r},renderInstCompareNone:null,renderInstCompareSortKey:qn,renderPipelineDescriptorCopy:Dr,renderPipelineDescriptorEquals:Rr,reverseDepthForClearValue:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;return t?1-e:e},reverseDepthForCompareMode:Vt,reverseDepthForDepthOffset:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;return t?-e:e},reverseDepthForOrthographicProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;t&&(e[10]=-e[10],e[14]=1-e[14])},reverseDepthForPerspectiveProjectionMatrix:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;t&&(e[10]=-e[10],e[14]=-e[14])},samplerBindingCopy:Or,samplerBindingNew:function(){return{sampler:null,texture:null,lateBinding:null}},samplerDescriptorEquals:Cr,segmentInstanceGeometry:Mi,setAttachmentStateSimple:ur,setBackbufferDescSimple:ai,setBitFlagEnabled:qt,setFormatComponentCount:function(e,t){return 4294902015&e|t<<8},setFormatFlags:function(e,t){return 4294967040&e|t},setMegaStateFlags:tr,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ln,n=!!(e>>>31&1),i=Fn(t,n,r);return n?Wn(e,i):Gn(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?Wn(e,t):Gn(e,t)},setSortKeyLayer:Un,setSortKeyOpaqueDepth:Gn,setSortKeyProgramKey:wn,setSortKeyTranslucentDepth:Wn,spliceBisectRight:zt,standardFullClearRenderPassDescriptor:ni,updateBuffer:Qi,vertexAttributeDescriptorCopy:br,vertexAttributeDescriptorEquals:Tr});function Qo(){
8
8
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
9
- go=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,v=_&&_(_(S([])));v&&v!==t&&r.call(v,i)&&(p=v);var E=d.prototype=f.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=d,s(E,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),s(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),s(E,a,"Generator"),s(E,i,(function(){return this})),s(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function mo(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Ro(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){mo(o,n,i,a,s,"next",e)}function s(e){mo(o,n,i,a,s,"throw",e)}a(void 0)}))}}var yo=(ho=function(){function e(){this.contextService=void 0,this.renderingContext=void 0}return e.prototype.apply=function(e){var t=this,r=this.renderingContext.root.ownerDocument.defaultView,n=function(t){e.hooks.pointerMove.call(t)},i=function(t){e.hooks.pointerUp.call(t)},o=function(t){e.hooks.pointerDown.call(t)},a=function(t){e.hooks.pointerOver.call(t)},s=function(t){e.hooks.pointerOut.call(t)},u=function(t){e.hooks.pointerCancel.call(t)},c=function(t){e.hooks.pointerWheel.call(t)},l=function(e){globalThis.document.addEventListener("pointermove",n,!0),e.addEventListener("pointerdown",o,!0),e.addEventListener("pointerleave",s,!0),e.addEventListener("pointerover",a,!0),globalThis.addEventListener("pointerup",i,!0)},f=function(e){e.addEventListener("touchstart",o,!0),e.addEventListener("touchend",i,!0),e.addEventListener("touchmove",n,!0),e.addEventListener("touchcancel",u,!0)},h=function(e){globalThis.document.addEventListener("mousemove",n,!0),e.addEventListener("mousedown",o,!0),e.addEventListener("mouseout",s,!0),e.addEventListener("mouseover",a,!0),globalThis.addEventListener("mouseup",i,!0)};e.hooks.init.tapPromise(po.tag,Ro(go().mark((function e(){var n;return go().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(n.style.msContentZooming="none",n.style.msTouchAction="none"):r.supportsPointerEvents&&(n.style.touchAction="none"),r.supportsPointerEvents?l(n):h(n),r.supportsTouchEvents&&f(n),n.addEventListener("wheel",c,{passive:!0,capture:!0});case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(po.tag,(function(){var e=t.contextService.getDomElement();r.supportsPointerEvents?function(e){globalThis.document.removeEventListener("pointermove",n,!0),e.removeEventListener("pointerdown",o,!0),e.removeEventListener("pointerleave",s,!0),e.removeEventListener("pointerover",a,!0),globalThis.removeEventListener("pointerup",i,!0)}(e):function(e){globalThis.document.removeEventListener("mousemove",n,!0),e.removeEventListener("mousedown",o,!0),e.removeEventListener("mouseout",s,!0),e.removeEventListener("mouseover",a,!0),globalThis.removeEventListener("mouseup",i,!0)}(e),r.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",o,!0),e.removeEventListener("touchend",i,!0),e.removeEventListener("touchmove",n,!0)}(e),e.removeEventListener("wheel",c,!0)}))},e}(),ho.tag="DOMInteraction",po=ho);a([t.inject(t.ContextService),s("design:type",Object)],yo.prototype,"contextService",void 0),a([t.inject(t.RenderingContext),s("design:type",Object)],yo.prototype,"renderingContext",void 0),yo=po=a([t.singleton({contrib:t.RenderingPluginContribution})],yo);var To,Ao,So=t.Module((function(e){e(yo)})),Co=function(){function e(){this.name="dom-interaction"}var t=e.prototype;return t.init=function(e){e.load(So,!0)},t.destroy=function(e){e.unload(So)},e}(),Oo=Object.freeze({__proto__:null,Plugin:Co});function Io(){
9
+ Qo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function Jo(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function $o(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Jo(o,n,i,a,s,"next",e)}function s(e){Jo(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ea(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ta(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ra(e,t,r){return t&&ta(e.prototype,t),r&&ta(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var na=(Yo=function(){function e(){ea(this,e),this.contextService=void 0,this.renderingContext=void 0}return ra(e,[{key:"apply",value:function(e){var t=this,r=this.renderingContext.root.ownerDocument.defaultView,n=function(t){e.hooks.pointerMove.call(t)},i=function(t){e.hooks.pointerUp.call(t)},o=function(t){e.hooks.pointerDown.call(t)},a=function(t){e.hooks.pointerOver.call(t)},s=function(t){e.hooks.pointerOut.call(t)},u=function(t){e.hooks.pointerCancel.call(t)},l=function(t){e.hooks.pointerWheel.call(t)},c=function(e){globalThis.document.addEventListener("pointermove",n,!0),e.addEventListener("pointerdown",o,!0),e.addEventListener("pointerleave",s,!0),e.addEventListener("pointerover",a,!0),globalThis.addEventListener("pointerup",i,!0)},f=function(e){e.addEventListener("touchstart",o,!0),e.addEventListener("touchend",i,!0),e.addEventListener("touchmove",n,!0),e.addEventListener("touchcancel",u,!0)},h=function(e){globalThis.document.addEventListener("mousemove",n,!0),e.addEventListener("mousedown",o,!0),e.addEventListener("mouseout",s,!0),e.addEventListener("mouseover",a,!0),globalThis.addEventListener("mouseup",i,!0)};e.hooks.init.tapPromise(Ko.tag,$o(Qo().mark((function e(){var n;return Qo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(n.style.msContentZooming="none",n.style.msTouchAction="none"):r.supportsPointerEvents&&(n.style.touchAction="none"),r.supportsPointerEvents?c(n):h(n),r.supportsTouchEvents&&f(n),n.addEventListener("wheel",l,{passive:!0,capture:!0});case 5:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Ko.tag,(function(){var e=t.contextService.getDomElement();r.supportsPointerEvents?function(e){globalThis.document.removeEventListener("pointermove",n,!0),e.removeEventListener("pointerdown",o,!0),e.removeEventListener("pointerleave",s,!0),e.removeEventListener("pointerover",a,!0),globalThis.removeEventListener("pointerup",i,!0)}(e):function(e){globalThis.document.removeEventListener("mousemove",n,!0),e.removeEventListener("mousedown",o,!0),e.removeEventListener("mouseout",s,!0),e.removeEventListener("mouseover",a,!0),globalThis.removeEventListener("mouseup",i,!0)}(e),r.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",o,!0),e.removeEventListener("touchend",i,!0),e.removeEventListener("touchmove",n,!0)}(e),e.removeEventListener("wheel",l,!0)}))}}]),e}(),Yo.tag="DOMInteraction",Ko=Yo);d([t.inject(t.ContextService),p("design:type",Object)],na.prototype,"contextService",void 0),d([t.inject(t.RenderingContext),p("design:type",Object)],na.prototype,"renderingContext",void 0),na=Ko=d([t.singleton({contrib:t.RenderingPluginContribution})],na);var ia,oa,aa=t.Module((function(e){e(na)})),sa=function(){function e(){ea(this,e),this.name="dom-interaction"}return ra(e,[{key:"init",value:function(e){e.load(aa,!0)}},{key:"destroy",value:function(e){e.unload(aa)}}]),e}(),ua=Object.freeze({__proto__:null,Plugin:sa});function la(){
10
10
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
11
- Io=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,v=_&&_(_(S([])));v&&v!==t&&r.call(v,i)&&(p=v);var E=d.prototype=f.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=d,s(E,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),s(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),s(E,a,"Generator"),s(E,i,(function(){return this})),s(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function No(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function xo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){No(o,n,i,a,s,"next",e)}function s(e){No(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Po=(To=function(){function e(){this.contextService=void 0,this.renderingContext=void 0,this.canvasConfig=void 0,this.$camera=void 0}var r=e.prototype;return r.apply=function(e){var r=this,n=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getOrCreateEl(n),o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(e){i.style[e]=o[e]})),Object.keys(n.attributes).forEach((function(e){r.updateAttribute(e,n)}))}},i=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getId(n),o=r.contextService.getDomElement().parentNode;if(o){var a=o.querySelector("#"+i);a&&o.removeChild(a)}}},o=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&r.updateAttribute(e.attrName,n)};e.hooks.init.tapPromise(Ao.tag,xo(Io().mark((function e(){return Io().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o);case 3:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Ao.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o)}))},r.getId=function(e){return e.id||"g-html-"+e.entity},r.getOrCreateEl=function(e){var t=this.canvasConfig.document,r=this.getId(e),n=this.contextService.getDomElement().parentNode;if(n){var i=n.querySelector("#"+r);if(!i){i=(t||document).createElement("div"),e.parsedStyle.$el=i,i.id=r,e.name&&i.setAttribute("name",e.name),e.className&&(i.className=e.className),n.appendChild(i),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style["will-change"]="transform";var o=e.getWorldTransform();i.style.transform="matrix("+[o[0],o[1],o[4],o[5],o[12],o[13]].join(",")+")"}return i}return null},r.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;t.isString(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"modelMatrix":case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]=o[0].value+" "+o[1].value;var a=r.getWorldTransform();n.style.transform="matrix("+[a[0],a[1],a[4],a[5],a[12],a[13]].join(",")+")";break;case"width":var s=r.computedStyleMap().get("width");n.style.width=s.toString();break;case"height":var u=r.computedStyleMap().get("height");n.style.height=u.toString();break;case"zIndex":n.style["z-index"]=""+r.parsedStyle.zIndex.value;break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity=""+r.parsedStyle.opacity.value;break;case"fill":var c=r.parsedStyle.fill,l="";c instanceof t.CSSRGB?l=c.isNone?"transparent":r.getAttribute("fill"):Array.isArray(c)?l=r.getAttribute("fill"):t.isPattern(c),n.style.background=l;break;case"stroke":var f=r.parsedStyle.stroke,h="";f instanceof t.CSSRGB?h=f.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(f)?h=r.getAttribute("stroke"):t.isPattern(f),n.style["border-color"]=h,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]=(r.parsedStyle.lineWidth.value||0)+"px";break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}},e}(),To.tag="HTMLRendering",Ao=To);a([t.inject(t.ContextService),s("design:type",Object)],Po.prototype,"contextService",void 0),a([t.inject(t.RenderingContext),s("design:type",Object)],Po.prototype,"renderingContext",void 0),a([t.inject(t.CanvasConfig),s("design:type",Object)],Po.prototype,"canvasConfig",void 0),Po=Ao=a([t.singleton({contrib:t.RenderingPluginContribution})],Po);var Do=t.Module((function(e){e(Po)})),Mo=function(){function e(){this.name="html-renderer"}var t=e.prototype;return t.init=function(e){e.load(Do,!0)},t.destroy=function(e){e.unload(Do)},e}(),Bo=Object.freeze({__proto__:null,Plugin:Mo});function Lo(){
11
+ la=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function ca(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function fa(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){ca(o,n,i,a,s,"next",e)}function s(e){ca(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ha(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function da(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function pa(e,t,r){return t&&da(e.prototype,t),r&&da(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var _a=(ia=function(){function e(){ha(this,e),this.contextService=void 0,this.renderingContext=void 0,this.canvasConfig=void 0,this.$camera=void 0}return pa(e,[{key:"apply",value:function(e){var r=this,n=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getOrCreateEl(n),o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(e){i.style[e]=o[e]})),Object.keys(n.attributes).forEach((function(e){r.updateAttribute(e,n)}))}},i=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var i=r.getId(n),o=r.contextService.getDomElement().parentNode;if(o){var a=o.querySelector("#"+i);a&&o.removeChild(a)}}},o=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&r.updateAttribute(e.attrName,n)};e.hooks.init.tapPromise(oa.tag,fa(la().mark((function e(){return la().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,o);case 3:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(oa.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,o)}))}},{key:"getId",value:function(e){return e.id||"g-html-"+e.entity}},{key:"getOrCreateEl",value:function(e){var t=this.canvasConfig.document,r=this.getId(e),n=this.contextService.getDomElement().parentNode;if(n){var i=n.querySelector("#"+r);if(!i){i=(t||document).createElement("div"),e.parsedStyle.$el=i,i.id=r,e.name&&i.setAttribute("name",e.name),e.className&&(i.className=e.className),n.appendChild(i),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style["will-change"]="transform";var o=e.getWorldTransform();i.style.transform="matrix(".concat([o[0],o[1],o[4],o[5],o[12],o[13]].join(","),")")}return i}return null}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;t.isString(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"modelMatrix":case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].value," ").concat(o[1].value);var a=r.getWorldTransform();n.style.transform="matrix(".concat([a[0],a[1],a[4],a[5],a[12],a[13]].join(","),")");break;case"width":var s=r.computedStyleMap().get("width");n.style.width=""+s;break;case"height":var u=r.computedStyleMap().get("height");n.style.height=""+u;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex.value);break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity.value);break;case"fill":var l=r.parsedStyle.fill,c="";l instanceof t.CSSRGB?c=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?c=r.getAttribute("fill"):t.isPattern(l),n.style.background=c;break;case"stroke":var f=r.parsedStyle.stroke,h="";f instanceof t.CSSRGB?h=f.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(f)?h=r.getAttribute("stroke"):t.isPattern(f),n.style["border-color"]=h,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth.value||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}}}]),e}(),ia.tag="HTMLRendering",oa=ia);d([t.inject(t.ContextService),p("design:type",Object)],_a.prototype,"contextService",void 0),d([t.inject(t.RenderingContext),p("design:type",Object)],_a.prototype,"renderingContext",void 0),d([t.inject(t.CanvasConfig),p("design:type",Object)],_a.prototype,"canvasConfig",void 0),_a=oa=d([t.singleton({contrib:t.RenderingPluginContribution})],_a);var va=t.Module((function(e){e(_a)})),Ea=function(){function e(){ha(this,e),this.name="html-renderer"}return pa(e,[{key:"init",value:function(e){e.load(va,!0)}},{key:"destroy",value:function(e){e.unload(va)}}]),e}(),ya=Object.freeze({__proto__:null,Plugin:Ea});function ga(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ma(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ga(Object(r),!0).forEach((function(t){Ia(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ga(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ra(){
12
12
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
13
- Lo=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new A(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function f(){}function h(){}function d(){}var p={};s(p,i,(function(){return this}));var _=Object.getPrototypeOf,v=_&&_(_(S([])));v&&v!==t&&r.call(v,i)&&(p=v);var E=d.prototype=f.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=d,s(E,"constructor",d),s(d,"constructor",h),h.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),s(m.prototype,o,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),s(E,a,"Generator"),s(E,i,(function(){return this})),s(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function bo(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Fo(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){bo(o,n,i,a,s,"next",e)}function s(e){bo(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Uo(){return Uo=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Uo.apply(this,arguments)}function wo(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Go(e,t)}function Go(e,t){return Go=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Go(e,t)}function ko(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var Vo,Wo=t.Syringe.defineToken("WebGPUDeviceOptions"),Xo=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Xo.decode();var Ho=null;function jo(){return null!==Ho&&Ho.buffer===Vo.memory.buffer||(Ho=new Uint8Array(Vo.memory.buffer)),Ho}function Yo(e,t){return Xo.decode(jo().subarray(e,e+t))}var Ko=new Array(32).fill(void 0);Ko.push(void 0,null,!0,!1);var zo=Ko.length;function qo(e){zo===Ko.length&&Ko.push(Ko.length+1);var t=zo;return zo=Ko[t],Ko[t]=e,t}function Zo(e){return Ko[e]}function Qo(e){var t=Zo(e);return function(e){36>e||(Ko[e]=zo,zo=e)}(e),t}var Jo=0,$o=new TextEncoder("utf-8"),ea="function"==typeof $o.encodeInto?function(e,t){return $o.encodeInto(e,t)}:function(e,t){var r=$o.encode(e);return t.set(r),{read:e.length,written:r.length}};function ta(e,t,r){if(void 0===r){var n=$o.encode(e),i=t(n.length);return jo().subarray(i,i+n.length).set(n),Jo=n.length,i}for(var o=e.length,a=t(o),s=jo(),u=0;o>u;u++){var c=e.charCodeAt(u);if(c>127)break;s[a+u]=c}if(u!==o){0!==u&&(e=e.slice(u)),a=r(a,o,o=u+3*e.length);var l=jo().subarray(a+u,a+o);u+=ea(e,l).written}return Jo=u,a}var ra,na,ia=null;function oa(){return null!==ia&&ia.buffer===Vo.memory.buffer||(ia=new Int32Array(Vo.memory.buffer)),ia}function aa(e,t,r){try{var n=Vo.__wbindgen_add_to_stack_pointer(-16),i=ta(e,Vo.__wbindgen_malloc,Vo.__wbindgen_realloc),o=Jo,a=ta(t,Vo.__wbindgen_malloc,Vo.__wbindgen_realloc);Vo.glsl_compile(n,i,o,a,Jo,r);var s=oa()[n/4+0],u=oa()[n/4+1];return Yo(s,u)}finally{Vo.__wbindgen_add_to_stack_pointer(16),Vo.__wbindgen_free(s,u)}}function sa(e,t){return ua.apply(this,arguments)}function ua(){return(ua=Fo(Lo().mark((function e(t,r){var n,i;return Lo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("function"==typeof Response&&t instanceof Response)){e.next=23;break}if("function"!=typeof WebAssembly.instantiateStreaming){e.next=15;break}return e.prev=2,e.next=5,WebAssembly.instantiateStreaming(t,r);case 5:case 20:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),"application/wasm"==t.headers.get("Content-Type")){e.next=14;break}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",e.t0),e.next=15;break;case 14:throw e.t0;case 15:return e.next=17,t.arrayBuffer();case 17:return n=e.sent,e.next=20,WebAssembly.instantiate(n,r);case 23:return e.next=25,WebAssembly.instantiate(t,r);case 25:if(!((i=e.sent)instanceof WebAssembly.Instance)){e.next=30;break}return e.abrupt("return",{instance:i,module:t});case 30:return e.abrupt("return",i);case 31:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function ca(e){return la.apply(this,arguments)}function la(){return(la=Fo(Lo().mark((function e(t){var r,n;return Lo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return qo(Yo(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){Qo(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(Zo(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(Zo(e),Zo(t))},r.wbg.__wbindgen_throw=function(e,t){throw new Error(Yo(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=sa,e.next=12,t;case 12:return e.t1=e.sent,e.t2=r,e.next=16,(0,e.t0)(e.t1,e.t2);case 16:return Vo=(n=e.sent).instance.exports,ca.__wbindgen_wasm_module=n.module,e.abrupt("return",Vo);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fa(e){if(e===Ye.U8_RGBA_RT)return"bgra8unorm";if(e===Ye.U8_RGBA_NORM)return"rgba8unorm";if(e===Ye.U8_RG_NORM)return"rg8unorm";if(e===Ye.U32_R)return"r32uint";if(e===Ye.D24)return"depth24plus";if(e===Ye.D24_S8)return"depth24plus-stencil8";if(e===Ye.D32F)return"depth32float";if(e===Ye.D32F_S8)return"depth32float-stencil8";if(e===Ye.BC1)return"bc1-rgba-unorm";if(e===Ye.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===Ye.BC2)return"bc2-rgba-unorm";if(e===Ye.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===Ye.BC3)return"bc3-rgba-unorm";if(e===Ye.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===Ye.BC4_SNORM)return"bc4-r-snorm";if(e===Ye.BC4_UNORM)return"bc4-r-unorm";if(e===Ye.BC5_SNORM)return"bc5-rg-snorm";if(e===Ye.BC5_UNORM)return"bc5-rg-unorm";throw new Error("whoops")}function ha(e){if(e===Ie.Clamp)return"clamp-to-edge";if(e===Ie.Repeat)return"repeat";if(e===Ie.Mirror)return"mirror-repeat";throw new Error("whoops")}function da(e){if(e===Ne.Bilinear)return"linear";if(e===Ne.Point)return"nearest";throw new Error("whoops")}function pa(e){if(e===xe.Linear)return"linear";if(e===xe.Nearest)return"nearest";if(e===xe.NoMip)return"nearest";throw new Error("whoops")}function _a(e){if(e===Ge.Float)return"float";if(e===Ge.Depth)return"depth";throw new Error("whoops")}function va(e){if(e===be.n2D)return"2d";if(e===be.n2DArray)return"2d-array";if(e===be.n3D)return"3d";if(e===be.Cube)return"cube";throw new Error("whoops")}function Ea(e){return e.gpuBuffer}function ga(e){if(e===We.OcclusionConservative)return"occlusion";throw new Error("whoops")}function ma(e){switch(e){case Pe.Triangles:return"triangle-list";case Pe.Points:return"point-list";case Pe.TriangleStrip:return"triangle-strip";case Pe.Lines:return"line-list";case Pe.LineStrip:return"line-strip";default:throw new Error("Unknown primitive topology mode")}}function Ra(e){if(e===Se.None)return"none";if(e===Se.Front)return"front";if(e===Se.Back)return"back";throw new Error("whoops")}function ya(e){if(e===Ae.CCW)return"ccw";if(e===Ae.CW)return"cw";throw new Error("whoops")}function Ta(e){if(e===Ce.Zero)return"zero";if(e===Ce.One)return"one";if(e===Ce.Src)return"src";if(e===Ce.OneMinusSrc)return"one-minus-src";if(e===Ce.Dst)return"dst";if(e===Ce.OneMinusDst)return"one-minus-dst";if(e===Ce.SrcAlpha)return"src-alpha";if(e===Ce.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===Ce.DstAlpha)return"dst-alpha";if(e===Ce.OneMinusDstAlpha)return"one-minus-dst-alpha";throw new Error("whoops")}function Aa(e){if(e===Oe.Add)return"add";if(e===Oe.Subtract)return"subtract";if(e===Oe.ReverseSubtract)return"reverse-subtract";throw new Error("whoops")}function Sa(e){return{operation:Aa(e.blendMode),srcFactor:Ta(e.blendSrcFactor),dstFactor:Ta(e.blendDstFactor)}}function Ca(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:fa(t),blend:{color:Sa(e.rgbBlendState),alpha:Sa(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function Oa(e){if(e===Te.Never)return"never";if(e===Te.Less)return"less";if(e===Te.Equal)return"equal";if(e===Te.LessEqual)return"less-equal";if(e===Te.Greater)return"greater";if(e===Te.NotEqual)return"not-equal";if(e===Te.GreaterEqual)return"greater-equal";if(e===Te.Always)return"always";throw new Error("whoops")}function Ia(e){if(e===Be.PerVertex)return"vertex";if(e===Be.PerInstance)return"instance";throw new Error("whoops")}function Na(e){if(e===Ye.U8_R)return"uint8x2";if(e===Ye.U8_RG)return"uint8x2";if(e===Ye.U8_RGB)return"uint8x4";if(e===Ye.U8_RGBA)return"uint8x4";if(e===Ye.U8_RGBA_NORM)return"unorm8x4";if(e===Ye.S8_RGB_NORM)return"snorm8x4";if(e===Ye.S8_RGBA_NORM)return"snorm8x4";if(e===Ye.S16_RG)return"uint16x2";if(e===Ye.F32_R)return"float32";if(e===Ye.F32_RG)return"float32x2";if(e===Ye.F32_RGB)return"float32x3";if(e===Ye.F32_RGBA)return"float32x4";throw new Error("whoops")}function xa(e,t,r,n){switch(void 0===r&&(r=!1),e){case Ye.S8_R:case Ye.S8_R_NORM:case Ye.S8_RG_NORM:case Ye.S8_RGB_NORM:case Ye.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case Ye.U8_R:case Ye.U8_R_NORM:case Ye.U8_RG:case Ye.U8_RG_NORM:case Ye.U8_RGB:case Ye.U8_RGB_NORM:case Ye.U8_RGB_SRGB:case Ye.U8_RGBA:case Ye.U8_RGBA_NORM:case Ye.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case Ye.S16_R:case Ye.S16_RG:case Ye.S16_RG_NORM:case Ye.S16_RGB_NORM:case Ye.S16_RGBA:case Ye.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 Ye.U16_R:case Ye.U16_RGB:case Ye.U16_RGBA_5551:case Ye.U16_RGBA_NORM:case Ye.U16_RG_NORM:case Ye.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 Ye.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 Ye.U32_R:case Ye.U32_RG:var c=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&c.set(new Uint32Array(n)),c;case Ye.F32_R:case Ye.F32_RG:case Ye.F32_RGB:case Ye.F32_RGBA:var l=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&l.set(new Float32Array(n)),l}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"}(ra||(ra={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(na||(na={}));var Pa=function(e){function t(t){var r,n=t.id,i=t.device;return(r=e.call(this)||this).type=void 0,r.id=void 0,r.name=void 0,r.device=void 0,r.id=n,r.device=i,r}return wo(t,e),t.prototype.destroy=function(){},t}(l.EventEmitter),Da=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.Bindings,r.bindingLayout=void 0,r.gpuBindGroup=void 0,r.bindGroupLayout=void 0;var i=n.pipeline,o=n.bindingLayout;nt(!!i);var a=r.device._createBindGroupLayout(o),s=[[],[]],u=0;if(o.storageEntries)for(var c=0;o.storageEntries.length>c;c++){var l=n.storageBufferBindings[c];nt(l.wordCount>0);var f={buffer:Ea(l.buffer),offset:0,size:l.wordCount<<2};s[0].push({binding:u++,resource:f})}for(var h=0;o.numUniformBuffers>h;h++){var d=n.uniformBufferBindings[h];nt(d.wordCount>0);var p={buffer:Ea(d.buffer),offset:0,size:d.wordCount<<2};s[0].push({binding:u++,resource:p})}u=0;for(var _=0;o.numSamplers>_;_++){var v=void 0!==o.samplerEntries?o.samplerEntries[_]:Ut,E=n.samplerBindings[_],g=null!==E.texture?E.texture:r.device.getFallbackTexture(v);nt(v.dimension===g.dimension),nt(v.formatKind===rt(g.pixelFormat)),s[1].push({binding:u++,resource:g.gpuTextureView});var m=(null!==E.sampler?E.sampler:r.device.fallbackSampler).gpuSampler;s[1].push({binding:u++,resource:m})}return r.gpuBindGroup=s.map((function(e,t){return r.device.device.createBindGroup({layout:i.getBindGroupLayout(t),entries:e})})),r.bindingLayout=n.bindingLayout,r.bindGroupLayout=a,r}return wo(t,e),t}(Pa);function Ma(e){return void 0!==e.byteLength}var Ba=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.Buffer,r.gpuBuffer=void 0,r.size=void 0,r.view=void 0,r.usage=void 0;var i=n.usage,o=n.viewOrSize,a=Ma(o)?o.byteLength+3&-4:o+3&-4;r.usage=i,r.usage&De.MAP_READ&&(r.usage=De.MAP_READ|De.COPY_DST);var s=Ma(o);if(r.size=Ma(o)?o.byteLength:o,r.view=Ma(o)?o:null,r.gpuBuffer=r.device.device.createBuffer({usage:r.usage,size:a,mappedAtCreation:s}),s){var u=r.gpuBuffer.getMappedRange();new o.constructor(u).set(o),r.gpuBuffer.unmap()}return r}wo(t,e);var r=t.prototype;return r.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer;n=n||t.byteLength,n=Math.min(n,this.size-e);var o=t.byteOffset+r,a=o+n,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 c=15728640,l=0;a-(o+l)>c;)this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,c),l+=c;this.device.device.queue.writeBuffer(i,e+l,t.buffer,o+l,n-l)},r.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Pa),La=function(e){function r(r){var n,i=r.descriptor;(n=e.call(this,{id:r.id,device:r.device})||this).type=ye.InputLayout,n.buffers=void 0,n.indexFormat=void 0;for(var o=[],a=0;i.vertexBufferDescriptors.length>a;a++){var s=i.vertexBufferDescriptors[a];if(!t.isNil(s)){var u=s.byteStride,c=Ia(s.frequency);o[a]={arrayStride:u,stepMode:c,attributes:[]}}}for(var l=0;i.vertexAttributeDescriptors.length>l;l++){var f=i.vertexAttributeDescriptors[l],h=it(o[f.bufferIndex]),d={shaderLocation:f.location,format:Na(f.format),offset:f.bufferByteOffset};h.attributes.push(d)}return n.indexFormat=function(e){if(null!==e){if(e===Ye.U16_R)return"uint16";if(e===Ye.U32_R)return"uint32";throw new Error("whoops")}}(i.indexBufferFormat),n.buffers=o,n}return wo(r,e),r}(Pa),ba=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.Program,r.descriptor=void 0,r.vertexStage=null,r.fragmentStage=null,r.computeStage=null,r.descriptor=n,n.preprocessedVert&&(r.vertexStage=r.createShaderStage(n.preprocessedVert,"vertex")),n.preprocessedFrag&&(r.fragmentStage=r.createShaderStage(n.preprocessedFrag,"fragment")),n.preprocessedCompute&&(r.computeStage=r.createShaderStage(n.preprocessedCompute,"compute")),r}return wo(t,e),t.prototype.createShaderStage=function(e,t){var r=e;if("compute"!==t)try{r=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),new Error("whoops")}for(var n=function(){var e=o[i];if(!r.includes(e))return"continue";r=(r=r.replace("var T_"+e+": texture_2d<f32>;","var T_"+e+": texture_depth_2d;")).replace(new RegExp("textureSample\\(T_"+e+"(.*)\\);$","gm"),(function(t,r){return"vec4<f32>(textureSample(T_"+e+r+"), 0.0, 0.0, 0.0);"}))},i=0,o=["u_TextureFramebufferDepth"];o.length>i;i++)n();return{module:this.device.device.createShaderModule({code:r}),entryPoint:"main"}},t}(Pa),Fa=function(){function e(){this.commandEncoder=null,this.descriptor=void 0,this.gpuRenderPassEncoder=null,this.gpuRenderPassDescriptor=void 0,this.gpuColorAttachments=void 0,this.gpuDepthStencilAttachment=void 0,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],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}}var r=e.prototype;return r.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,null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={});var o=this.gpuColorAttachments[r];o.view=n.gpuTextureView;var a=e.colorClearColor[r];"load"===a?o.loadOp="load":(o.loadOp="clear",o.clearValue=a),o.storeOp=e.colorStore[r]?"store":"discard",o.resolveTarget=void 0,null!==i&&(n.sampleCount>1?o.resolveTarget=i.gpuTextureView:o.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var s=this.gpuDepthStencilAttachment;s.view=e.depthStencilAttachment.gpuTextureView,"load"===e.depthClearValue?s.depthLoadOp="load":(s.depthLoadOp="clear",s.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?s.stencilLoadOp="load":(s.stencilLoadOp="clear",s.stencilClearValue=e.stencilClearValue),s.depthStoreOp=e.depthStencilStore?"store":"discard",s.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(s.depthStoreOp="store",s.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0},r.beginRenderPass=function(e){nt(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},r.setViewport=function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)},r.setScissor=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)},r.setPipeline=function(e){var t=it(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)},r.setInputState=function(e){if(null!==e){var r=e;if(null!==r.indexBuffer){var n=r.inputLayout,i=r.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(Ea(i.buffer),it(n.indexFormat),i.byteOffset)}for(var o=0;r.vertexBuffers.length>o;o++){var a=r.vertexBuffers[o];t.isNil(a)||this.gpuRenderPassEncoder.setVertexBuffer(o,Ea(a.buffer),a.byteOffset)}}},r.setBindings=function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])},r.setStencilRef=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},r.draw=function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)},r.drawIndexed=function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)},r.drawIndexedInstanced=function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)},r.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},r.endOcclusionQuery=function(e){this.gpuRenderPassEncoder.endOcclusionQuery()},r.beginDebugGroup=function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)},r.endDebugGroup=function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()},r.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,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()},r.copyAttachment=function(e,t){nt(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};nt(t.width===e.width),nt(t.height===e.height),nt(!!(t.usage&ra.COPY_SRC)),nt(!!(e.usage&ra.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])},e}(),Ua=function(e){function t(t){var r,n,i,o=t.descriptor;(i=e.call(this,{id:t.id,device:t.device})||this).type=ye.Sampler,i.gpuSampler=void 0;var a=o.minLOD,s=o.mipFilter===xe.NoMip?o.minLOD:o.maxLOD,u=null!==(r=o.maxAnisotropy)&&void 0!==r?r:1;return u>1&&nt(o.minFilter===Ne.Bilinear&&o.magFilter===Ne.Bilinear&&o.mipFilter===xe.Linear),i.gpuSampler=i.device.device.createSampler({addressModeU:ha(o.wrapS),addressModeV:ha(o.wrapT),addressModeW:ha(null!==(n=o.wrapQ)&&void 0!==n?n:o.wrapS),lodMinClamp:a,lodMaxClamp:s,minFilter:da(o.minFilter),magFilter:da(o.magFilter),mipmapFilter:pa(o.mipFilter),maxAnisotropy:u}),i}return wo(t,e),t}(Pa),wa=function(e){function t(t){var r,n=t.descriptor,i=t.skipCreate;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.Texture,r.pixelFormat=void 0,r.dimension=void 0,r.format=void 0,r.width=void 0,r.height=void 0,r.depthOrArrayLayers=void 0,r.numLevels=void 0,r.sampleCount=void 0,r.usage=void 0,r.gpuTexture=void 0,r.gpuTextureView=void 0,r.device.createTextureShared({pixelFormat:n.pixelFormat,dimension:n.dimension,width:n.width,height:n.height,depthOrArrayLayers:n.depth,numLevels:n.numLevels,usage:n.usage,sampleCount:1},ko(r),i),r}wo(t,e);var r=t.prototype;return r.setImageData=function(e,t){},r.destroy=function(){this.gpuTexture.destroy()},t}(Pa),Ga=function(e){function t(t){var r,n=t.inputLayout,i=t.vertexBuffers,o=t.indexBuffer;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.InputState,r.inputLayout=void 0,r.vertexBuffers=void 0,r.indexBuffer=void 0,r.inputLayout=n,r.vertexBuffers=i,r.indexBuffer=o,r}return wo(t,e),t}(Pa),ka=function(e){function t(t){var r,n=t.descriptor;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.RenderPipeline,r.descriptor=void 0,r.isCreating=!1,r.isCreatingAsync=!1,r.gpuRenderPipeline=null,r.descriptor=n,r.device._createRenderPipeline(ko(r),!1),r}return wo(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Pa),Va=function(e){function t(t){var r;return(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.Readback,r}wo(t,e);var r=t.prototype;return r.readTexture=function(e,t,r,n,i,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var u=e,c=this.getBlockInformationFromFormat(u.format),l=Math.ceil(n/c.width)*c.length,f=256*Math.ceil(l/256),h=f*i,d=this.device.createBuffer({usage:De.STORAGE|De.MAP_READ|De.COPY_DST,hint:Me.Static,viewOrSize:h}),p=this.device.device.createCommandEncoder();return p.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:Math.max(0,0)}},{buffer:d.gpuBuffer,offset:0,bytesPerRow:f},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([p.finish()]),this.readBuffer(d,h,o,a,s,u.pixelFormat)},r.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=Ye.U8_RGB),void 0===a&&(a=!1);var c=e,l=i||c.size,f=r||c.view,h=f&&f.constructor&&f.constructor.BYTES_PER_ELEMENT||tt(o),d=c;if(!(c.usage&De.MAP_READ&&c.usage&De.COPY_DST)){var p=this.device.device.createCommandEncoder();d=this.device.createBuffer({usage:De.STORAGE|De.MAP_READ|De.COPY_DST,hint:Me.Static,viewOrSize:l}),p.copyBufferToBuffer(c.gpuBuffer,t,d.gpuBuffer,0,l),this.device.device.queue.submit([p.finish()])}return new Promise((function(e,r){d.gpuBuffer.mapAsync(na.READ,t,l).then((function(){var r=d.gpuBuffer.getMappedRange(t,l),n=f;if(a)n=null===n?xa(o,l,!0,r):xa(o,n.buffer,void 0,r);else if(null===n)switch(h){case 1:(n=new Uint8Array(l)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(l/2,r);break;case 4:(n=new Float32Array(l/4)).set(new Float32Array(r))}else switch(h){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=u.getHalfFloatAsFloatRGBAArrayBuffer(l/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.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/Math.pow(2,10)):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/Math.pow(2,10)));return r},r.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":case"depth24unorm-stencil8":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 new Error("No fixed size for Stencil8 format!");case"depth24plus":throw new Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw new 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}(Pa),Wa=function(){function e(){this.commandEncoder=null,this.descriptor=void 0,this.gpuComputePassDescriptor=void 0,this.gpuComputePassEncoder=null}var t=e.prototype;return t.dispatch=function(e,t,r){this.gpuComputePassEncoder.dispatch(e,t,r)},t.finish=function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()},t.beginComputePass=function(e){nt(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)},t.setPipeline=function(e){var t=it(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},t.setBindings=function(e,t){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0])},t.setComputePassDescriptor=function(e){this.descriptor=e},e}(),Xa=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.ComputePipeline,r.descriptor=void 0,r.gpuComputePipeline=null,r.descriptor=n;var i=n.program.computeStage;if(null===i)return ko(r);var o={compute:Uo({},i),layout:void 0};return r.gpuComputePipeline=r.device.device.createComputePipeline(o),void 0!==r.name&&(r.gpuComputePipeline.label=r.name),r}return wo(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Pa),Ha=function(e){function t(t){var r,n=t.descriptor;(r=e.call(this,{id:t.id,device:t.device})||this).type=ye.QueryPool,r.querySet=void 0;var i=n.elemCount;return r.querySet=r.device.device.createQuerySet({type:ga(n.type),count:i}),r}return wo(t,e),t.prototype.queryResultOcclusion=function(e){return!0},t}(Pa),ja=function(){function e(e,t,r,n,i){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=ra.RENDER_ATTACHMENT|ra.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new Xr(Wt,Vr),this.fallbackTexture2D=void 0,this.fallbackTexture2DDepth=void 0,this.fallbackTexture2DArray=void 0,this.fallbackTexture3D=void 0,this.fallbackTextureCube=void 0,this.fallbackSampler=void 0,this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=ke.UpperLeft,this.clipSpaceNearZ=Ve.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=void 0,this.device=void 0,this.canvas=void 0,this.canvasContext=void 0,this.glsl_compile=void 0,this.adapter=e,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.fallbackTexture2D=this.createFallbackTexture(be.n2D,Ge.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(be.n2D,Ge.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(be.n2DArray,Ge.Float),this.fallbackTexture3D=this.createFallbackTexture(be.n3D,Ge.Float),this.fallbackTextureCube=this.createFallbackTexture(be.Cube,Ge.Float),this.fallbackSampler=this.createSampler({wrapS:Ie.Clamp,wrapT:Ie.Clamp,minFilter:Ne.Point,magFilter:Ne.Point,mipFilter:xe.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}var t=e.prototype;return t.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t,this.canvasContext.configure({device:this.device,format:"bgra8unorm",usage:this.swapChainTextureUsage,compositingAlphaMode:"premultiplied"}))},t.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new wa({id:0,device:this,descriptor:{pixelFormat:Ye.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:be.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r},t.getDevice=function(){return this},t.getCanvas=function(){return this.canvas},t.present=function(){},t.getNextUniqueId=function(){return++this._resourceUniqueId},t.createBuffer=function(e){return new Ba({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createTexture=function(e){return new wa({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createSampler=function(e){return new Ua({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderTarget=function(e){var t=new wa({id:this.getNextUniqueId(),device:this,descriptor:Uo({},e,{dimension:be.n2D,numLevels:1,depth:1,usage:Fe.RenderTarget})});return t.depthOrArrayLayers=1,t.type=ye.RenderTarget,t},t.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,c=e.usage;nt(!!(c&ra.RENDER_ATTACHMENT));var l=new wa({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:be.n2D,numLevels:a,usage:c},skipCreate:!0});return l.depthOrArrayLayers=i,l.sampleCount=o,l.gpuTexture=s,l.gpuTextureView=u,l},t.createProgram=function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)},t.createProgramSimple=function(e){return new ba({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=fa(e.pixelFormat),a=function(e){if(e===be.n2D)return"2d";if(e===be.Cube)return"3d";if(e===be.n2DArray)return"3d";if(e===be.n3D)return"3d";throw new Error("whoops")}(e.dimension),s=function(e){var t=0;return e&Fe.Sampled&&(t|=ra.TEXTURE_BINDING|ra.COPY_DST),e&Fe.RenderTarget&&(t|=ra.RENDER_ATTACHMENT|ra.TEXTURE_BINDING|ra.COPY_SRC|ra.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}),c=u.createView();t.gpuTexture=u,t.gpuTextureView=c}},t.getFallbackTexture=function(e){var t=e.dimension;if(t===be.n2D)return e.formatKind===Ge.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===be.n2DArray)return this.fallbackTexture2DArray;if(t===be.n3D)return this.fallbackTexture3D;if(t===be.Cube)return this.fallbackTextureCube;throw new Error("whoops")},t.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,pixelFormat:t===Ge.Float?Ye.U8_RGBA_NORM:Ye.D24,usage:Fe.Sampled,width:1,height:1,depth:e===be.Cube?6:1,numLevels:1})},t.createBindings=function(e){return new Da({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputLayout=function(e){return new La({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createInputState=function(e,t,r){return new Ga({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})},t.createComputePipeline=function(e){return new Xa({id:this.getNextUniqueId(),device:this,descriptor:e})},t.createRenderPipeline=function(e){return new ka({id:this.getNextUniqueId(),device:this,descriptor:Uo({},e)})},t.createQueryPool=function(e,t){return new Ha({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},t._createBindGroupLayout=function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t},t._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(var o=0;e.numUniformBuffers>o;o++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(var a=0;e.numSamplers>a;a++){n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=void 0!==e.samplerEntries?e.samplerEntries[a]:Ut,{sampleType:_a(t.formatKind),viewDimension:va(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}})}return{gpuBindGroupLayout:n.map((function(e){return r.device.createBindGroupLayout({entries:e})}))}},t._createPipelineLayout=function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})},t._createRenderPipeline=function(e,t){if(!e.isCreating&&null===e.gpuRenderPipeline){var r=e.descriptor,n=r.program,i=n.vertexStage,o=n.fragmentStage;if(null!==i&&null!==o){var a,s=this._createPipelineLayout(r.bindingLayouts),u=(a=r.megaStateDescriptor,{topology:ma(r.topology),cullMode:Ra(a.cullMode),frontFace:ya(a.frontFace)}),c=Ca(r.colorAttachmentFormats,r.megaStateDescriptor),l=function(e,t){if(null!==e)return{format:fa(e),depthWriteEnabled:t.depthWrite,depthCompare:Oa(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(r.depthStencilAttachmentFormat,r.megaStateDescriptor),f=void 0;null!==r.inputLayout&&(f=r.inputLayout.buffers);var h=r.sampleCount;e.isCreating=!0;var d={layout:s,vertex:Uo({},i,{buffers:f}),primitive:u,depthStencil:l,multisample:{count:h},fragment:Uo({},o,{targets:c})};e.gpuRenderPipeline=this.device.createRenderPipeline(d),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}},t.createReadback=function(){return new Va({id:this.getNextUniqueId(),device:this})},t.destroyRenderTarget=function(e){e.gpuTexture.destroy()},t.createRenderPass=function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Fa),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t},t.createComputePass=function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new Wa),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t},t.submitPass=function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null,r instanceof Fa?this.renderPassPool.push(r):this.computePassPool.push(r)},t.copySubTexture2D=function(e,t,r,n,i,o){var a=this.device.createCommandEncoder(),s=e,u=n,c={texture:u.gpuTexture,origin:[i,o,0]},l={texture:s.gpuTexture,origin:[t,r,0]};nt(!!(u.usage&ra.COPY_SRC)),nt(!!(s.usage&ra.COPY_DST)),a.copyTextureToTexture(c,l,[u.width,u.height,1]),this.device.queue.submit([a.finish()])},t.queryLimits=function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}},t.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Je(e)){case Xe.BC1:case Xe.BC2:case Xe.BC3:case Xe.BC4_SNORM:case Xe.BC4_UNORM:case Xe.BC5_SNORM:case Xe.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Je(e)){case Xe.BC1:case Xe.BC2:case Xe.BC3:case Xe.BC4_SNORM:case Xe.BC4_UNORM:case Xe.BC5_SNORM:case Xe.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}return!0},t.queryPlatformAvailable=function(){return!0},t.queryVendorInfo=function(){return this},t.queryRenderPass=function(e){return e.descriptor},t.queryRenderTarget=function(e){return e},t.setResourceName=function(e,t){if(e.name=t,e.type===ye.Buffer)e.gpuBuffer.label=t;else if(e.type===ye.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ye.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ye.Sampler){e.gpuSampler.label=t}else if(e.type===ye.RenderPipeline){null!==e.gpuRenderPipeline&&(e.gpuRenderPipeline.label=t)}},t.setResourceLeakCheck=function(e,t){},t.checkForLeaks=function(){},t.programPatched=function(e){},t.pushDebugGroup=function(e){},t.popDebugGroup=function(){},t.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},t.pipelineForceReady=function(e){this._createRenderPipeline(e,!1)},e}(),Ya=function(){function e(){this.pluginOptions=void 0}return e.prototype.createSwapChain=function(){var e=Fo(Lo().mark((function e(t){var r,n,i,o;return Lo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,navigator.gpu.requestAdapter();case 6:r=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),console.log(e.t0);case 12:if(null!==r){e.next=14;break}return e.abrupt("return",null);case 14:return n=["depth24unorm-stencil8","depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),e.next=18,r.requestDevice({requiredFeatures:n});case 18:if(null!==(i=e.sent)){e.next=21;break}return e.abrupt("return",null);case 21:if(o=t.getContext("webgpu")){e.next=24;break}return e.abrupt("return",null);case 24:return e.prev=24,e.next=27,ca("/glsl_wgsl_compiler_bg.wasm");case 27:e.next=31;break;case 29:e.prev=29,e.t1=e.catch(24);case 31:return e.abrupt("return",new ja(r,i,t,o,aa));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])})));return function(t){return e.apply(this,arguments)}}(),e}();a([t.inject(Wo),s("design:type",Object)],Ya.prototype,"pluginOptions",void 0),Ya=a([t.singleton({token:Hi})],Ya);var Ka=t.Module((function(e){e(Ya)})),za=function(){function e(e){void 0===e&&(e={}),this.options=void 0,this.name="webgpu-device",this.options=e}var t=e.prototype;return t.init=function(e){e.register(Wo,{useValue:Uo({},this.options)}),e.load(Ka,!0)},t.destroy=function(e){e.remove(Wo),e.unload(Ka)},e}(),qa=Object.freeze({__proto__:null,Plugin:za}),Za=function(){function e(){this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}var i=e.prototype;return i.init=function(){var e,i=(e=r().mark((function e(){var n,i,o,a,s,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=(n=this.canvasConfig).container,a=n.devicePixelRatio,(o=n.canvas)?(this.$canvas=o,i&&o.parentElement!==i&&i.appendChild(o),this.$container=o.parentElement,this.canvasConfig.container=this.$container):i&&(this.$container=t.isString(i)?document.getElementById(i):i,this.$container&&(s=document.createElement("canvas"),this.$container.appendChild(s),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=s)),u=1>(u=a||t.isBrowser&&window.devicePixelRatio||1)?1:Math.ceil(u),this.dpr=u;case 5:case"end":return e.stop()}}),e,this)})),function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,u,"next",e)}function u(e){n(a,i,o,s,u,"throw",e)}s(void 0)}))});return function(){return i.apply(this,arguments)}}(),i.getDomElement=function(){return this.$canvas},i.getContext=function(){return this.context},i.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},i.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},i.resize=function(e,r){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}},i.getDPR=function(){return this.dpr},i.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e}();a([t.inject(t.CanvasConfig),s("design:type",Object)],Za.prototype,"canvasConfig",void 0),Za=a([t.singleton({token:t.ContextService})],Za);var Qa=t.Module((function(e){e(Za)})),Ja=function(){function e(){this.name="webgpu-context-register"}var t=e.prototype;return t.init=function(e){e.load(Qa,!0)},t.destroy=function(e){e.unload(Qa)},e}(),$a=function(e){var t,r;function n(t){var r;return(r=e.call(this,t)||this).registerPlugin(new Ja),r.registerPlugin(new E),r.registerPlugin(new za),r.registerPlugin(new vo),r.registerPlugin(new Co),r.registerPlugin(new Mo),r}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,i(t,r),n}(t.AbstractRenderer);e.DeviceRenderer=Eo,e.DomInteraction=Oo,e.HTMLRenderer=Bo,e.Renderer=$a,e.WebGPUDevice=qa,Object.defineProperty(e,"__esModule",{value:!0})}));
13
+ Ra=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new S(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=R(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f={};function h(){}function d(){}function p(){}var _={};u(_,o,(function(){return this}));var v=Object.getPrototypeOf,E=v&&v(v(C([])));E&&E!==t&&r.call(E,o)&&(_=E);var y=p.prototype=h.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){function i(o,a,s,u){var l=c(e[o],e,a);if("throw"!==l.type){var f=l.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,u)}),(function(e){i("throw",e,s,u)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return i("throw",e,s,u)}))}u(l.arg)}var o;this._invoke=function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}}function R(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function C(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(y,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(m.prototype),u(m.prototype,a,(function(){return this})),e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),u(y,s,"Generator"),u(y,o,(function(){return this})),u(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(s){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function Ta(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Aa(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ta(o,n,i,a,s,"next",e)}function s(e){Ta(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Sa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ca(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Oa(e,t,r){return t&&Ca(e.prototype,t),r&&Ca(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ia(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Na(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Pa(e,t)}function xa(e){return xa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},xa(e)}function Pa(e,t){return Pa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Pa(e,t)}function Da(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ba(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Da(e)}function Ma(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=xa(e);if(t){var i=xa(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return ba(this,r)}}function Ba(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=xa(e)););return e}function La(){return La="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=Ba(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(3>arguments.length?e:r):i.value}},La.apply(this,arguments)}var Fa,Ua=t.Syringe.defineToken("WebGPUDeviceOptions"),wa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});wa.decode();var ka=null;function Ga(){return null!==ka&&ka.buffer===Fa.memory.buffer||(ka=new Uint8Array(Fa.memory.buffer)),ka}function Va(e,t){return wa.decode(Ga().subarray(e,e+t))}var Wa=Array(32).fill(void 0);Wa.push(void 0,null,!0,!1);var Xa=Wa.length;function Ha(e){Xa===Wa.length&&Wa.push(Wa.length+1);var t=Xa;return Xa=Wa[t],Wa[t]=e,t}function ja(e){return Wa[e]}function Ya(e){var t=ja(e);return function(e){36>e||(Wa[e]=Xa,Xa=e)}(e),t}var Ka=0,za=new TextEncoder("utf-8"),qa="function"==typeof za.encodeInto?function(e,t){return za.encodeInto(e,t)}:function(e,t){var r=za.encode(e);return t.set(r),{read:e.length,written:r.length}};function Za(e,t,r){if(void 0===r){var n=za.encode(e),i=t(n.length);return Ga().subarray(i,i+n.length).set(n),Ka=n.length,i}for(var o=e.length,a=t(o),s=Ga(),u=0;o>u;u++){var l=e.charCodeAt(u);if(l>127)break;s[a+u]=l}if(u!==o){0!==u&&(e=e.slice(u)),a=r(a,o,o=u+3*e.length);var c=Ga().subarray(a+u,a+o);u+=qa(e,c).written}return Ka=u,a}var Qa,Ja,$a=null;function es(){return null!==$a&&$a.buffer===Fa.memory.buffer||($a=new Int32Array(Fa.memory.buffer)),$a}function ts(e,t,r){try{var n=Fa.__wbindgen_add_to_stack_pointer(-16),i=Za(e,Fa.__wbindgen_malloc,Fa.__wbindgen_realloc),o=Ka,a=Za(t,Fa.__wbindgen_malloc,Fa.__wbindgen_realloc);Fa.glsl_compile(n,i,o,a,Ka,r);var s=es()[n/4+0],u=es()[n/4+1];return Va(s,u)}finally{Fa.__wbindgen_add_to_stack_pointer(16),Fa.__wbindgen_free(s,u)}}function rs(e,t){return ns.apply(this,arguments)}function ns(){return(ns=Aa(Ra().mark((function e(t,r){var n,i;return Ra().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("function"==typeof Response&&t instanceof Response)){e.next=23;break}if("function"!=typeof WebAssembly.instantiateStreaming){e.next=15;break}return e.prev=2,e.next=5,WebAssembly.instantiateStreaming(t,r);case 5:case 20:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),"application/wasm"==t.headers.get("Content-Type")){e.next=14;break}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",e.t0),e.next=15;break;case 14:throw e.t0;case 15:return e.next=17,t.arrayBuffer();case 17:return n=e.sent,e.next=20,WebAssembly.instantiate(n,r);case 23:return e.next=25,WebAssembly.instantiate(t,r);case 25:if(!((i=e.sent)instanceof WebAssembly.Instance)){e.next=30;break}return e.abrupt("return",{instance:i,module:t});case 30:return e.abrupt("return",i);case 31:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function is(e){return os.apply(this,arguments)}function os(){return(os=Aa(Ra().mark((function e(t){var r,n;return Ra().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r={}).wbg={},r.wbg.__wbindgen_string_new=function(e,t){return Ha(Va(e,t))},r.wbg.__wbindgen_object_drop_ref=function(e){Ya(e)},r.wbg.__wbg_log_fbd13631356d44e4=function(e){console.log(ja(e))},r.wbg.__wbg_log_00fa6d531d56c191=function(e,t){console.log(ja(e),ja(t))},r.wbg.__wbindgen_throw=function(e,t){throw Error(Va(e,t))},("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t)),e.t0=rs,e.next=12,t;case 12:return e.t1=e.sent,e.t2=r,e.next=16,(0,e.t0)(e.t1,e.t2);case 16:return Fa=(n=e.sent).instance.exports,is.__wbindgen_wasm_module=n.module,e.abrupt("return",Fa);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function as(e){if(e===gt.U8_RGBA_RT)return"bgra8unorm";if(e===gt.U8_RGBA_NORM)return"rgba8unorm";if(e===gt.U8_RG_NORM)return"rg8unorm";if(e===gt.U32_R)return"r32uint";if(e===gt.D24)return"depth24plus";if(e===gt.D24_S8)return"depth24plus-stencil8";if(e===gt.D32F)return"depth32float";if(e===gt.D32F_S8)return"depth32float-stencil8";if(e===gt.BC1)return"bc1-rgba-unorm";if(e===gt.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===gt.BC2)return"bc2-rgba-unorm";if(e===gt.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===gt.BC3)return"bc3-rgba-unorm";if(e===gt.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===gt.BC4_SNORM)return"bc4-r-snorm";if(e===gt.BC4_UNORM)return"bc4-r-unorm";if(e===gt.BC5_SNORM)return"bc5-rg-snorm";if(e===gt.BC5_UNORM)return"bc5-rg-unorm";throw Error("whoops")}function ss(e){if(e===et.Clamp)return"clamp-to-edge";if(e===et.Repeat)return"repeat";if(e===et.Mirror)return"mirror-repeat";throw Error("whoops")}function us(e){if(e===tt.Bilinear)return"linear";if(e===tt.Point)return"nearest";throw Error("whoops")}function ls(e){if(e===rt.Linear)return"linear";if(e===rt.Nearest)return"nearest";if(e===rt.NoMip)return"nearest";throw Error("whoops")}function cs(e){if(e===ht.Float)return"float";if(e===ht.Depth)return"depth";throw Error("whoops")}function fs(e){if(e===ut.n2D)return"2d";if(e===ut.n2DArray)return"2d-array";if(e===ut.n3D)return"3d";if(e===ut.Cube)return"cube";throw Error("whoops")}function hs(e){return e.gpuBuffer}function ds(e){if(e===_t.OcclusionConservative)return"occlusion";throw Error("whoops")}function ps(e){switch(e){case nt.Triangles:return"triangle-list";case nt.Points:return"point-list";case nt.TriangleStrip:return"triangle-strip";case nt.Lines:return"line-list";case nt.LineStrip:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function _s(e){if(e===Qe.None)return"none";if(e===Qe.Front)return"front";if(e===Qe.Back)return"back";throw Error("whoops")}function vs(e){if(e===Ze.CCW)return"ccw";if(e===Ze.CW)return"cw";throw Error("whoops")}function Es(e){if(e===Je.Zero)return"zero";if(e===Je.One)return"one";if(e===Je.Src)return"src";if(e===Je.OneMinusSrc)return"one-minus-src";if(e===Je.Dst)return"dst";if(e===Je.OneMinusDst)return"one-minus-dst";if(e===Je.SrcAlpha)return"src-alpha";if(e===Je.OneMinusSrcAlpha)return"one-minus-src-alpha";if(e===Je.DstAlpha)return"dst-alpha";if(e===Je.OneMinusDstAlpha)return"one-minus-dst-alpha";throw Error("whoops")}function ys(e){if(e===$e.Add)return"add";if(e===$e.Subtract)return"subtract";if(e===$e.ReverseSubtract)return"reverse-subtract";throw Error("whoops")}function gs(e){return{operation:ys(e.blendMode),srcFactor:Es(e.blendSrcFactor),dstFactor:Es(e.blendDstFactor)}}function ms(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:as(t),blend:{color:gs(e.rgbBlendState),alpha:gs(e.alphaBlendState)},writeMask:e.channelWriteMask}}(t,e[r])}))}function Rs(e){if(e===qe.Never)return"never";if(e===qe.Less)return"less";if(e===qe.Equal)return"equal";if(e===qe.LessEqual)return"less-equal";if(e===qe.Greater)return"greater";if(e===qe.NotEqual)return"not-equal";if(e===qe.GreaterEqual)return"greater-equal";if(e===qe.Always)return"always";throw Error("whoops")}function Ts(e){if(e===at.PerVertex)return"vertex";if(e===at.PerInstance)return"instance";throw Error("whoops")}function As(e){if(e===gt.U8_R)return"uint8x2";if(e===gt.U8_RG)return"uint8x2";if(e===gt.U8_RGB)return"uint8x4";if(e===gt.U8_RGBA)return"uint8x4";if(e===gt.U8_RGBA_NORM)return"unorm8x4";if(e===gt.S8_RGB_NORM)return"snorm8x4";if(e===gt.S8_RGBA_NORM)return"snorm8x4";if(e===gt.S16_RG)return"uint16x2";if(e===gt.F32_R)return"float32";if(e===gt.F32_RG)return"float32x2";if(e===gt.F32_RGB)return"float32x3";if(e===gt.F32_RGBA)return"float32x4";throw Error("whoops")}function Ss(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0;switch(e){case gt.S8_R:case gt.S8_R_NORM:case gt.S8_RG_NORM:case gt.S8_RGB_NORM:case gt.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case gt.U8_R:case gt.U8_R_NORM:case gt.U8_RG:case gt.U8_RG_NORM:case gt.U8_RGB:case gt.U8_RGB_NORM:case gt.U8_RGB_SRGB:case gt.U8_RGBA:case gt.U8_RGBA_NORM:case gt.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case gt.S16_R:case gt.S16_RG:case gt.S16_RG_NORM:case gt.S16_RGB_NORM:case gt.S16_RGBA:case gt.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 gt.U16_R:case gt.U16_RGB:case gt.U16_RGBA_5551:case gt.U16_RGBA_NORM:case gt.U16_RG_NORM:case gt.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 gt.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 gt.U32_R:case gt.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 gt.F32_R:case gt.F32_RG:case gt.F32_RGB:case gt.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"}(Qa||(Qa={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Ja||(Ja={}));var Cs=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device;return Sa(this,r),(n=t.call(this)).type=void 0,n.id=void 0,n.name=void 0,n.device=void 0,n.id=i,n.device=o,n}return Oa(r,[{key:"destroy",value:function(){}}]),r}(_.EventEmitter),Os=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.Bindings,n.bindingLayout=void 0,n.gpuBindGroup=void 0,n.bindGroupLayout=void 0;var s=a.pipeline,u=a.bindingLayout;Pt(!!s);var l=n.device._createBindGroupLayout(u),c=[[],[]],f=0;if(u.storageEntries)for(var h=0;u.storageEntries.length>h;h++){var d=a.storageBufferBindings[h];Pt(d.wordCount>0);var p={buffer:hs(d.buffer),offset:0,size:d.wordCount<<2};c[0].push({binding:f++,resource:p})}for(var _=0;u.numUniformBuffers>_;_++){var v=a.uniformBufferBindings[_];Pt(v.wordCount>0);var E={buffer:hs(v.buffer),offset:0,size:v.wordCount<<2};c[0].push({binding:f++,resource:E})}f=0;for(var y=0;u.numSamplers>y;y++){var g=void 0!==u.samplerEntries?u.samplerEntries[y]:cr,m=a.samplerBindings[y],R=null!==m.texture?m.texture:n.device.getFallbackTexture(g);Pt(g.dimension===R.dimension),Pt(g.formatKind===xt(R.pixelFormat)),c[1].push({binding:f++,resource:R.gpuTextureView});var T=(null!==m.sampler?m.sampler:n.device.fallbackSampler).gpuSampler;c[1].push({binding:f++,resource:T})}return n.gpuBindGroup=c.map((function(e,t){return n.device.device.createBindGroup({layout:s.getBindGroupLayout(t),entries:e})})),n.bindingLayout=a.bindingLayout,n.bindGroupLayout=l,n}return Oa(r)}(Cs);function Is(e){return void 0!==e.byteLength}var Ns=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.Buffer,n.gpuBuffer=void 0,n.size=void 0,n.view=void 0,n.usage=void 0;var s=a.usage,u=a.viewOrSize,l=Is(u)?u.byteLength+3&-4:u+3&-4;n.usage=s,n.usage&it.MAP_READ&&(n.usage=it.MAP_READ|it.COPY_DST);var c=Is(u);if(n.size=Is(u)?u.byteLength:u,n.view=Is(u)?u:null,n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:l,mappedAtCreation:c}),c){var f=n.gpuBuffer.getMappedRange();new u.constructor(f).set(u),n.gpuBuffer.unmap()}return n}return Oa(r,[{key:"setSubData",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,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)}},{key:"destroy",value:function(){La(xa(r.prototype),"destroy",this).call(this),this.gpuBuffer.destroy()}}]),r}(Cs),xs=function(e){Na(n,e);var r=Ma(n);function n(e){var i,o=e.id,a=e.device,s=e.descriptor;Sa(this,n),(i=r.call(this,{id:o,device:a})).type=ze.InputLayout,i.buffers=void 0,i.indexFormat=void 0;for(var u=[],l=0;s.vertexBufferDescriptors.length>l;l++){var c=s.vertexBufferDescriptors[l];if(!t.isNil(c)){var f=c.byteStride,h=Ts(c.frequency);u[l]={arrayStride:f,stepMode:h,attributes:[]}}}for(var d=0;s.vertexAttributeDescriptors.length>d;d++){var p=s.vertexAttributeDescriptors[d],_=Dt(u[p.bufferIndex]),v={shaderLocation:p.location,format:As(p.format),offset:p.bufferByteOffset};_.attributes.push(v)}return i.indexFormat=function(e){if(null!==e){if(e===gt.U16_R)return"uint16";if(e===gt.U32_R)return"uint32";throw Error("whoops")}}(s.indexBufferFormat),i.buffers=u,i}return Oa(n)}(Cs),Ps=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.Program,n.descriptor=void 0,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=a,a.preprocessedVert&&(n.vertexStage=n.createShaderStage(a.preprocessedVert,"vertex")),a.preprocessedFrag&&(n.fragmentStage=n.createShaderStage(a.preprocessedFrag,"fragment")),a.preprocessedCompute&&(n.computeStage=n.createShaderStage(a.preprocessedCompute,"compute")),n}return Oa(r,[{key:"createShaderStage",value:function(e,t){var r=e;if("compute"!==t)try{r=this.device.glsl_compile(e,t,!1)}catch(t){throw console.error(t,e),Error("whoops")}for(var n=function(){var e=o[i];if(!r.includes(e))return"continue";r=(r=r.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);")}))},i=0,o=["u_TextureFramebufferDepth"];o.length>i;i++)n();return{module:this.device.device.createShaderModule({code:r}),entryPoint:"main"}}}]),r}(Cs),Ds=function(){function e(){Sa(this,e),this.commandEncoder=null,this.descriptor=void 0,this.gpuRenderPassEncoder=null,this.gpuRenderPassDescriptor=void 0,this.gpuColorAttachments=void 0,this.gpuDepthStencilAttachment=void 0,this.gfxColorAttachment=[],this.gfxColorResolveTo=[],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 Oa(e,[{key:"setRenderPassDescriptor",value: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,null===n){this.gpuColorAttachments.length=r,this.gfxColorAttachment.length=r,this.gfxColorResolveTo.length=r;break}void 0===this.gpuColorAttachments[r]&&(this.gpuColorAttachments[r]={});var o=this.gpuColorAttachments[r];o.view=n.gpuTextureView;var a=e.colorClearColor[r];"load"===a?o.loadOp="load":(o.loadOp="clear",o.clearValue=a),o.storeOp=e.colorStore[r]?"store":"discard",o.resolveTarget=void 0,null!==i&&(n.sampleCount>1?o.resolveTarget=i.gpuTextureView:o.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,null!==e.depthStencilAttachment){var s=this.gpuDepthStencilAttachment;s.view=e.depthStencilAttachment.gpuTextureView,"load"===e.depthClearValue?s.depthLoadOp="load":(s.depthLoadOp="clear",s.depthClearValue=e.depthClearValue),"load"===e.stencilClearValue?s.stencilLoadOp="load":(s.stencilLoadOp="clear",s.stencilClearValue=e.stencilClearValue),s.depthStoreOp=e.depthStencilStore?"store":"discard",s.stencilStoreOp=e.depthStencilStore?"store":"discard",this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment,null!==this.gfxDepthStencilResolveTo&&(s.depthStoreOp="store",s.stencilStoreOp="store")}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=null!==e.occlusionQueryPool?e.occlusionQueryPool.querySet:void 0}},{key:"beginRenderPass",value:function(e){Pt(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(e),this.gpuRenderPassEncoder=this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)}},{key:"setViewport",value:function(e,t,r,n){this.gpuRenderPassEncoder.setViewport(e,t,r,n,0,1)}},{key:"setScissor",value:function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,t,r,n)}},{key:"setPipeline",value:function(e){var t=Dt(e.gpuRenderPipeline);this.gpuRenderPassEncoder.setPipeline(t)}},{key:"setInputState",value:function(e){if(null!==e){var r=e;if(null!==r.indexBuffer){var n=r.inputLayout,i=r.indexBuffer;this.gpuRenderPassEncoder.setIndexBuffer(hs(i.buffer),Dt(n.indexFormat),i.byteOffset)}for(var o=0;r.vertexBuffers.length>o;o++){var a=r.vertexBuffers[o];t.isNil(a)||this.gpuRenderPassEncoder.setVertexBuffer(o,hs(a.buffer),a.byteOffset)}}}},{key:"setBindings",value:function(e,t,r){var n=t;this.gpuRenderPassEncoder.setBindGroup(e+0,n.gpuBindGroup[0],r.slice(0,n.bindingLayout.numUniformBuffers)),this.gpuRenderPassEncoder.setBindGroup(e+1,n.gpuBindGroup[1])}},{key:"setStencilRef",value:function(e){this.gpuRenderPassEncoder.setStencilReference(e)}},{key:"draw",value:function(e,t){this.gpuRenderPassEncoder.draw(e,1,t,0)}},{key:"drawIndexed",value:function(e,t){this.gpuRenderPassEncoder.drawIndexed(e,1,t,0,0)}},{key:"drawIndexedInstanced",value:function(e,t,r){this.gpuRenderPassEncoder.drawIndexed(e,r,t,0,0)}},{key:"beginOcclusionQuery",value:function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)}},{key:"endOcclusionQuery",value:function(e){this.gpuRenderPassEncoder.endOcclusionQuery()}},{key:"beginDebugGroup",value:function(e){void 0!==this.gpuRenderPassEncoder.pushDebugGroup&&this.gpuRenderPassEncoder.pushDebugGroup(e)}},{key:"endDebugGroup",value:function(){void 0!==this.gpuRenderPassEncoder.popDebugGroup&&this.gpuRenderPassEncoder.popDebugGroup()}},{key:"finish",value: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,t)}return null!==this.gfxDepthStencilAttachment&&null!==this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,this.gfxDepthStencilAttachment)),this.commandEncoder.finish()}},{key:"copyAttachment",value:function(e,t){Pt(1===t.sampleCount);var r={texture:t.gpuTexture},n={texture:e.gpuTexture};Pt(t.width===e.width),Pt(t.height===e.height),Pt(!!(t.usage&Qa.COPY_SRC)),Pt(!!(e.usage&Qa.COPY_DST)),this.commandEncoder.copyTextureToTexture(r,n,[e.width,e.height,1])}}]),e}(),bs=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i,o,a=e.id,s=e.device,u=e.descriptor;Sa(this,r),(o=t.call(this,{id:a,device:s})).type=ze.Sampler,o.gpuSampler=void 0;var l=u.minLOD,c=u.mipFilter===rt.NoMip?u.minLOD:u.maxLOD,f=null!==(n=u.maxAnisotropy)&&void 0!==n?n:1;return f>1&&Pt(u.minFilter===tt.Bilinear&&u.magFilter===tt.Bilinear&&u.mipFilter===rt.Linear),o.gpuSampler=o.device.device.createSampler({addressModeU:ss(u.wrapS),addressModeV:ss(u.wrapT),addressModeW:ss(null!==(i=u.wrapQ)&&void 0!==i?i:u.wrapS),lodMinClamp:l,lodMaxClamp:c,minFilter:us(u.minFilter),magFilter:us(u.magFilter),mipmapFilter:ls(u.mipFilter),maxAnisotropy:f}),o}return Oa(r)}(Cs),Ms=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor,s=e.skipCreate;return Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.Texture,n.pixelFormat=void 0,n.dimension=void 0,n.format=void 0,n.width=void 0,n.height=void 0,n.depthOrArrayLayers=void 0,n.numLevels=void 0,n.sampleCount=void 0,n.usage=void 0,n.gpuTexture=void 0,n.gpuTextureView=void 0,n.device.createTextureShared({pixelFormat:a.pixelFormat,dimension:a.dimension,width:a.width,height:a.height,depthOrArrayLayers:a.depth,numLevels:a.numLevels,usage:a.usage,sampleCount:1},Da(n),s),n}return Oa(r,[{key:"setImageData",value:function(e,t){}},{key:"destroy",value:function(){this.gpuTexture.destroy()}}]),r}(Cs),Bs=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.inputLayout,s=e.vertexBuffers,u=e.indexBuffer;return Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.InputState,n.inputLayout=void 0,n.vertexBuffers=void 0,n.indexBuffer=void 0,n.inputLayout=a,n.vertexBuffers=s,n.indexBuffer=u,n}return Oa(r)}(Cs),Ls=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;return Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.RenderPipeline,n.descriptor=void 0,n.isCreating=!1,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=a,n.device._createRenderPipeline(Da(n),!1),n}return Oa(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)}}]),r}(Cs),Fs=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device;return Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.Readback,n}return Oa(r,[{key:"readTexture",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0,u=e,l=0,c=this.getBlockInformationFromFormat(u.format),f=Math.ceil(n/c.width)*c.length,h=256*Math.ceil(f/256),d=h*i,p=this.device.createBuffer({usage:it.STORAGE|it.MAP_READ|it.COPY_DST,hint:ot.Static,viewOrSize:d}),_=this.device.device.createCommandEncoder();return _.copyTextureToBuffer({texture:u.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:Math.max(l,0)}},{buffer:p.gpuBuffer,offset:0,bytesPerRow:h},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),this.readBuffer(p,d,o,a,s,u.pixelFormat)}},{key:"readBuffer",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:gt.U8_RGB,a=arguments.length>6&&void 0!==arguments[6]&&arguments[6],s=e,u=i||s.size,l=n||s.view,c=l&&l.constructor&&l.constructor.BYTES_PER_ELEMENT||Nt(o),f=s;if(!(s.usage&it.MAP_READ&&s.usage&it.COPY_DST)){var h=this.device.device.createCommandEncoder();f=this.device.createBuffer({usage:it.STORAGE|it.MAP_READ|it.COPY_DST,hint:ot.Static,viewOrSize:u}),h.copyBufferToBuffer(s.gpuBuffer,r,f.gpuBuffer,0,u),this.device.device.queue.submit([h.finish()])}return new Promise((function(e,n){f.gpuBuffer.mapAsync(Ja.READ,r,u).then((function(){var n=f.gpuBuffer.getMappedRange(r,u),i=l;if(a)i=null===i?Ss(o,u,!0,n):Ss(o,i.buffer,void 0,n);else if(null===i)switch(c){case 1:(i=new Uint8Array(u)).set(new Uint8Array(n));break;case 2:i=t.getHalfFloatAsFloatRGBAArrayBuffer(u/2,n);break;case 4:(i=new Float32Array(u/4)).set(new Float32Array(n))}else switch(c){case 1:(i=new Uint8Array(i.buffer)).set(new Uint8Array(n));break;case 2:i=t.getHalfFloatAsFloatRGBAArrayBuffer(u/2,n,l);break;case 4:var s=l&&l.constructor||Float32Array;(i=new s(i.buffer)).set(new s(n))}f.gpuBuffer.unmap(),e(i)}),(function(e){return n(e)}))}))}},{key:"getHalfFloatAsFloatRGBAArrayBuffer",value: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}},{key:"getBlockInformationFromFormat",value: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}(Cs),Us=function(){function e(){Sa(this,e),this.commandEncoder=null,this.descriptor=void 0,this.gpuComputePassDescriptor=void 0,this.gpuComputePassEncoder=null}return Oa(e,[{key:"dispatch",value:function(e,t,r){this.gpuComputePassEncoder.dispatch(e,t,r)}},{key:"finish",value:function(){return this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.commandEncoder.finish()}},{key:"beginComputePass",value:function(e){Pt(null===this.gpuComputePassEncoder),this.setComputePassDescriptor(e),this.gpuComputePassEncoder=this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor)}},{key:"setPipeline",value:function(e){var t=Dt(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)}},{key:"setBindings",value:function(e,t){this.gpuComputePassEncoder.setBindGroup(e,t.gpuBindGroup[0])}},{key:"setComputePassDescriptor",value:function(e){this.descriptor=e}}]),e}(),ws=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.ComputePipeline,n.descriptor=void 0,n.gpuComputePipeline=null,n.descriptor=a;var s=a.program.computeStage;if(null===s)return ba(n);var u={compute:ma({},s),layout:void 0};return n.gpuComputePipeline=n.device.device.createComputePipeline(u),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return Oa(r,[{key:"getBindGroupLayout",value:function(e){return this.gpuComputePipeline.getBindGroupLayout(e)}}]),r}(Cs),ks=function(e){Na(r,e);var t=Ma(r);function r(e){var n,i=e.id,o=e.device,a=e.descriptor;Sa(this,r),(n=t.call(this,{id:i,device:o})).type=ze.QueryPool,n.querySet=void 0;var s=a.elemCount;return n.querySet=n.device.device.createQuerySet({type:ds(a.type),count:s}),n}return Oa(r,[{key:"queryResultOcclusion",value:function(e){return!0}}]),r}(Cs),Gs=function(){function e(t,r,n,i,o){Sa(this,e),this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Qa.RENDER_ATTACHMENT|Qa.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.bindGroupLayoutCache=new En(_r,_n),this.fallbackTexture2D=void 0,this.fallbackTexture2DDepth=void 0,this.fallbackTexture2DArray=void 0,this.fallbackTexture3D=void 0,this.fallbackTextureCube=void 0,this.fallbackSampler=void 0,this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=dt.UpperLeft,this.clipSpaceNearZ=pt.Zero,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.adapter=void 0,this.device=void 0,this.canvas=void 0,this.canvasContext=void 0,this.glsl_compile=void 0,this.adapter=t,this.device=r,this.canvas=n,this.canvasContext=i,this.glsl_compile=o,this.fallbackTexture2D=this.createFallbackTexture(ut.n2D,ht.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(ut.n2D,ht.Depth),this.fallbackTexture2DArray=this.createFallbackTexture(ut.n2DArray,ht.Float),this.fallbackTexture3D=this.createFallbackTexture(ut.n3D,ht.Float),this.fallbackTextureCube=this.createFallbackTexture(ut.Cube,ht.Float),this.fallbackSampler=this.createSampler({wrapS:et.Clamp,wrapT:et.Clamp,minFilter:tt.Point,magFilter:tt.Point,mipFilter:rt.NoMip}),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)}}return Oa(e,[{key:"configureSwapChain",value:function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t,this.canvasContext.configure({device:this.device,format:"bgra8unorm",usage:this.swapChainTextureUsage,compositingAlphaMode:"premultiplied"}))}},{key:"getOnscreenTexture",value:function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Ms({id:0,device:this,descriptor:{pixelFormat:gt.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depth:0,dimension:ut.n2D,numLevels:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r}},{key:"getDevice",value:function(){return this}},{key:"getCanvas",value:function(){return this.canvas}},{key:"present",value:function(){}},{key:"getNextUniqueId",value:function(){return++this._resourceUniqueId}},{key:"createBuffer",value:function(e){return new Ns({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createTexture",value:function(e){return new Ms({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createSampler",value:function(e){return new bs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderTarget",value:function(e){var t=new Ms({id:this.getNextUniqueId(),device:this,descriptor:ma(ma({},e),{},{dimension:ut.n2D,numLevels:1,depth:1,usage:lt.RenderTarget})});return t.depthOrArrayLayers=1,t.type=ze.RenderTarget,t}},{key:"createRenderTargetFromTexture",value: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;Pt(!!(l&Qa.RENDER_ATTACHMENT));var c=new Ms({id:this.getNextUniqueId(),device:this,descriptor:{pixelFormat:t,width:r,height:n,depth:i,dimension:ut.n2D,numLevels:a,usage:l},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=u,c}},{key:"createProgram",value:function(e){return e.ensurePreprocessed(this),this.createProgramSimple(e)}},{key:"createProgramSimple",value:function(e){return new Ps({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createTextureShared",value:function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.numLevels,o=as(e.pixelFormat),a=function(e){if(e===ut.n2D)return"2d";if(e===ut.Cube)return"3d";if(e===ut.n2DArray)return"3d";if(e===ut.n3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&lt.Sampled&&(t|=Qa.TEXTURE_BINDING|Qa.COPY_DST),e&lt.RenderTarget&&(t|=Qa.RENDER_ATTACHMENT|Qa.TEXTURE_BINDING|Qa.COPY_SRC|Qa.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}}},{key:"getFallbackTexture",value:function(e){var t=e.dimension;if(t===ut.n2D)return e.formatKind===ht.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===ut.n2DArray)return this.fallbackTexture2DArray;if(t===ut.n3D)return this.fallbackTexture3D;if(t===ut.Cube)return this.fallbackTextureCube;throw Error("whoops")}},{key:"createFallbackTexture",value:function(e,t){return this.createTexture({dimension:e,pixelFormat:t===ht.Float?gt.U8_RGBA_NORM:gt.D24,usage:lt.Sampled,width:1,height:1,depth:e===ut.Cube?6:1,numLevels:1})}},{key:"createBindings",value:function(e){return new Os({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputLayout",value:function(e){return new xs({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createInputState",value:function(e,t,r){return new Bs({id:this.getNextUniqueId(),device:this,inputLayout:e,vertexBuffers:t,indexBuffer:r})}},{key:"createComputePipeline",value:function(e){return new ws({id:this.getNextUniqueId(),device:this,descriptor:e})}},{key:"createRenderPipeline",value:function(e){return new Ls({id:this.getNextUniqueId(),device:this,descriptor:ma({},e)})}},{key:"createQueryPool",value:function(e,t){return new ks({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})}},{key:"_createBindGroupLayout",value:function(e){var t=this.bindGroupLayoutCache.get(e);return null===t&&(t=this._createBindGroupLayoutInternal(e),this.bindGroupLayoutCache.add(e,t)),t}},{key:"_createBindGroupLayoutInternal",value: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(var o=0;e.numUniformBuffers>o;o++)n[0].push({binding:n[0].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}});for(var a=0;e.numSamplers>a;a++){n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:(t=void 0!==e.samplerEntries?e.samplerEntries[a]:cr,{sampleType:cs(t.formatKind),viewDimension:fs(t.dimension)})}),n[1].push({binding:n[1].length,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}})}return{gpuBindGroupLayout:n.map((function(e){return r.device.createBindGroupLayout({entries:e})}))}}},{key:"_createPipelineLayout",value:function(e){var t=this,r=e.flatMap((function(e){return t._createBindGroupLayout(e).gpuBindGroupLayout}));return this.device.createPipelineLayout({bindGroupLayouts:r})}},{key:"_createRenderPipeline",value:function(e){if(!e.isCreating&&null===e.gpuRenderPipeline){var t=e.descriptor,r=t.program,n=r.vertexStage,i=r.fragmentStage;if(null!==n&&null!==i){var o,a=this._createPipelineLayout(t.bindingLayouts),s=(o=t.megaStateDescriptor,{topology:ps(t.topology),cullMode:_s(o.cullMode),frontFace:vs(o.frontFace)}),u=ms(t.colorAttachmentFormats,t.megaStateDescriptor),l=function(e,t){if(null!==e)return{format:as(e),depthWriteEnabled:t.depthWrite,depthCompare:Rs(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0}}(t.depthStencilAttachmentFormat,t.megaStateDescriptor),c=void 0;null!==t.inputLayout&&(c=t.inputLayout.buffers);var f=t.sampleCount;e.isCreating=!0;var h={layout:a,vertex:ma(ma({},n),{},{buffers:c}),primitive:s,depthStencil:l,multisample:{count:f},fragment:ma(ma({},i),{},{targets:u})};e.gpuRenderPipeline=this.device.createRenderPipeline(h),void 0!==e.name&&(e.gpuRenderPipeline.label=e.name)}}}},{key:"createReadback",value:function(){return new Fs({id:this.getNextUniqueId(),device:this})}},{key:"destroyRenderTarget",value:function(e){e.gpuTexture.destroy()}},{key:"createRenderPass",value:function(e){var t=this.renderPassPool.pop();return void 0===t&&(t=new Ds),t.commandEncoder=this.device.createCommandEncoder(),t.beginRenderPass(e),t}},{key:"createComputePass",value:function(e){var t=this.computePassPool.pop();return void 0===t&&(t=new Us),t.commandEncoder=this.device.createCommandEncoder(),t.beginComputePass(e),t}},{key:"submitPass",value:function(e){var t=this.device.queue,r=e,n=r.finish();t.submit([n]),r.commandEncoder=null,r instanceof Ds?this.renderPassPool.push(r):this.computePassPool.push(r)}},{key:"copySubTexture2D",value: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]};Pt(!!(u.usage&Qa.COPY_SRC)),Pt(!!(s.usage&Qa.COPY_DST)),a.copyTextureToTexture(l,c,[u.width,u.height,1]),this.device.queue.submit([a.finish()])}},{key:"queryLimits",value:function(){return{uniformBufferMaxPageWordSize:4096,uniformBufferWordAlignment:64,supportedSampleCounts:[1]}}},{key:"queryTextureFormatSupported",value:function(e,t,r){if(function(e){switch(Ct(e)){case vt.BC1:case vt.BC2:case vt.BC3:case vt.BC4_SNORM:case vt.BC4_UNORM:case vt.BC5_SNORM:case vt.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ct(e)){case vt.BC1:case vt.BC2:case vt.BC3:case vt.BC4_SNORM:case vt.BC4_UNORM:case vt.BC5_SNORM:case vt.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}return!0}},{key:"queryPlatformAvailable",value:function(){return!0}},{key:"queryVendorInfo",value:function(){return this}},{key:"queryRenderPass",value:function(e){return e.descriptor}},{key:"queryRenderTarget",value:function(e){return e}},{key:"setResourceName",value:function(e,t){if(e.name=t,e.type===ze.Buffer)e.gpuBuffer.label=t;else if(e.type===ze.Texture){var r=e;r.gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===ze.RenderTarget){var n=e;n.gpuTexture.label=t,n.gpuTextureView.label=t}else if(e.type===ze.Sampler){e.gpuSampler.label=t}else if(e.type===ze.RenderPipeline){null!==e.gpuRenderPipeline&&(e.gpuRenderPipeline.label=t)}}},{key:"setResourceLeakCheck",value:function(e,t){}},{key:"checkForLeaks",value:function(){}},{key:"programPatched",value:function(e){}},{key:"pushDebugGroup",value:function(e){}},{key:"popDebugGroup",value:function(){}},{key:"pipelineQueryReady",value:function(e){return null!==e.gpuRenderPipeline}},{key:"pipelineForceReady",value:function(e){this._createRenderPipeline(e,!1)}}]),e}(),Vs=function(){function e(){Sa(this,e),this.pluginOptions=void 0}var t;return Oa(e,[{key:"createSwapChain",value:(t=Aa(Ra().mark((function e(t){var r,n,i,o;return Ra().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==navigator.gpu){e.next=2;break}return e.abrupt("return",null);case 2:return r=null,e.prev=3,e.next=6,navigator.gpu.requestAdapter();case 6:r=e.sent,e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),console.log(e.t0);case 12:if(null!==r){e.next=14;break}return e.abrupt("return",null);case 14:return n=["depth32float-stencil8","texture-compression-bc"].filter((function(e){return r.features.has(e)})),e.next=18,r.requestDevice({requiredFeatures:n});case 18:if(null!==(i=e.sent)){e.next=21;break}return e.abrupt("return",null);case 21:if(o=t.getContext("webgpu")){e.next=24;break}return e.abrupt("return",null);case 24:return e.prev=24,e.next=27,is("/glsl_wgsl_compiler_bg.wasm");case 27:e.next=31;break;case 29:e.prev=29,e.t1=e.catch(24);case 31:return e.abrupt("return",new Gs(r,i,t,o,ts));case 32:case"end":return e.stop()}}),e,null,[[3,9],[24,29]])}))),function(e){return t.apply(this,arguments)})}]),e}();d([t.inject(Ua),p("design:type",Object)],Vs.prototype,"pluginOptions",void 0),Vs=d([t.singleton({token:So})],Vs);var Ws=t.Module((function(e){e(Vs)})),Xs=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Sa(this,e),this.options=void 0,this.name="webgpu-device",this.options=t}return Oa(e,[{key:"init",value:function(e){e.register(Ua,{useValue:ma({},this.options)}),e.load(Ws,!0)}},{key:"destroy",value:function(e){e.remove(Ua),e.unload(Ws)}}]),e}(),Hs=Object.freeze({__proto__:null,Plugin:Xs}),js=function(){function e(){o(this,e),this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}return s(e,[{key:"init",value:function(){var e,n=(e=r().mark((function e(){var n,i,o,a,s,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=(n=this.canvasConfig).container,a=n.devicePixelRatio,(o=n.canvas)?(this.$canvas=o,i&&o.parentElement!==i&&i.appendChild(o),this.$container=o.parentElement,this.canvasConfig.container=this.$container):i&&(this.$container=t.isString(i)?document.getElementById(i):i,this.$container&&(s=document.createElement("canvas"),this.$container.appendChild(s),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=s)),u=a||t.isBrowser&&window.devicePixelRatio||1,this.dpr=u=1>u?1:Math.ceil(u);case 5:case"end":return e.stop()}}),e,this)})),function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function s(e){i(a,n,o,s,u,"next",e)}function u(e){i(a,n,o,s,u,"throw",e)}s(void 0)}))});return function(){return n.apply(this,arguments)}}()},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.context}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){if(this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}}]),e}();d([t.inject(t.CanvasConfig),p("design:type",Object)],js.prototype,"canvasConfig",void 0),js=d([t.singleton({token:t.ContextService})],js);var Ys=t.Module((function(e){e(js)})),Ks=function(){function e(){o(this,e),this.name="webgpu-context-register"}return s(e,[{key:"init",value:function(e){e.load(Ys,!0)}},{key:"destroy",value:function(e){e.unload(Ys)}}]),e}(),zs=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(r,e);var t=f(r);function r(e){var n;return o(this,r),(n=t.call(this,e)).registerPlugin(new Ks),n.registerPlugin(new x),n.registerPlugin(new Xs),n.registerPlugin(new qo),n.registerPlugin(new sa),n.registerPlugin(new Ea),n}return s(r)}(t.AbstractRenderer);e.DeviceRenderer=Zo,e.DomInteraction=ua,e.HTMLRenderer=ya,e.Renderer=zs,e.WebGPUDevice=Hs,Object.defineProperty(e,"__esModule",{value:!0})}));