globe-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/favicon.svg +1 -0
- package/dist/globe-kit.js +41216 -0
- package/dist/globe-kit.umd.cjs +922 -0
- package/dist/icons.svg +24 -0
- package/dist/src/lib/animations/entrance.d.ts +4 -0
- package/dist/src/lib/animations/limbFade.d.ts +3 -0
- package/dist/src/lib/components/Globe.d.ts +2 -0
- package/dist/src/lib/components/GlobeScene.d.ts +6 -0
- package/dist/src/lib/components/GraticuleGrid.d.ts +14 -0
- package/dist/src/lib/components/LabelLayer.d.ts +8 -0
- package/dist/src/lib/components/Starfield.d.ts +8 -0
- package/dist/src/lib/data/labels.d.ts +9 -0
- package/dist/src/lib/index.d.ts +3 -0
- package/dist/src/lib/layout/gridSnap.d.ts +2 -0
- package/dist/src/lib/themes/index.d.ts +8 -0
- package/dist/src/lib/types.d.ts +110 -0
- package/dist/src/lib/utils/accessor.d.ts +3 -0
- package/dist/src/lib/utils/coords.d.ts +6 -0
- package/dist/src/lib/utils/earthTexture.d.ts +4 -0
- package/dist/src/lib/utils/textureCache.d.ts +10 -0
- package/package.json +81 -0
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@react-three/fiber`),require(`@react-three/drei`),require(`three`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@react-three/fiber`,`@react-three/drei`,`three`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.GlobeKit={},e.React,e.ReactThreeFiber,e.Drei,e.THREE,e.jsxRuntime))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),p=(e,t)=>{let n={};for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t||s(n,Symbol.toStringTag,{value:`Module`}),n},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:o(u(e)),m(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));i=h(i,1);var g={name:`catppuccin-mocha`,globeTint:{r:.18,g:.17,b:.26},atmosphere:`#8839ef`,grid:`#585b70`,background:`#11111b`,text:`#cdd6f4`,textSecondary:`#a6adc8`,accent:`#fab387`,frostedBg:`rgba(24, 24, 37, 0.85)`,frostedBorder:`rgba(147, 153, 178, 0.12)`},_={"catppuccin-mocha":g,sepia:{name:`sepia`,globeTint:{r:.32,g:.26,b:.18},atmosphere:`#8a7060`,grid:`#6a5a48`,background:`#0a0a0a`,text:`#d4c8b8`,textSecondary:`#a09080`,accent:`#c8a878`,frostedBg:`rgba(20, 18, 15, 0.88)`,frostedBorder:`rgba(120, 100, 80, 0.15)`},ocean:{name:`ocean`,globeTint:{r:.14,g:.2,b:.28},atmosphere:`#2196f3`,grid:`#37474f`,background:`#060a12`,text:`#b0c4de`,textSecondary:`#78909c`,accent:`#4fc3f7`,frostedBg:`rgba(6, 10, 18, 0.88)`,frostedBorder:`rgba(66, 165, 245, 0.12)`},midnight:{name:`midnight`,globeTint:{r:.16,g:.16,b:.18},atmosphere:`#ffffff`,grid:`#333333`,background:`#000000`,text:`#e0e0e0`,textSecondary:`#888888`,accent:`#ffffff`,frostedBg:`rgba(10, 10, 10, 0.9)`,frostedBorder:`rgba(255, 255, 255, 0.08)`},aurora:{name:`aurora`,globeTint:{r:.12,g:.22,b:.16},atmosphere:`#66bb6a`,grid:`#2e4a3a`,background:`#060a08`,text:`#b8d8c0`,textSecondary:`#6a9a78`,accent:`#81c784`,frostedBg:`rgba(6, 10, 8, 0.88)`,frostedBorder:`rgba(102, 187, 106, 0.12)`}},v=_;function y(e){return e?typeof e==`string`?_[e]??g:e:g}function b(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var x=typeof global==`object`&&global&&global.Object===Object&&global,S=typeof self==`object`&&self&&self.Object===Object&&self,C=x||S||Function(`return this`)(),w=function(){return C.Date.now()},T=/\s/;function E(e){for(var t=e.length;t--&&T.test(e.charAt(t)););return t}var D=/^\s+/;function O(e){return e&&e.slice(0,E(e)+1).replace(D,``)}var k=C.Symbol,A=Object.prototype,ee=A.hasOwnProperty,j=A.toString,te=k?k.toStringTag:void 0;function ne(e){var t=ee.call(e,te),n=e[te];try{e[te]=void 0;var r=!0}catch{}var i=j.call(e);return r&&(t?e[te]=n:delete e[te]),i}var re=Object.prototype.toString;function ie(e){return re.call(e)}var ae=`[object Null]`,oe=`[object Undefined]`,se=k?k.toStringTag:void 0;function ce(e){return e==null?e===void 0?oe:ae:se&&se in Object(e)?ne(e):ie(e)}function le(e){return typeof e==`object`&&!!e}var ue=`[object Symbol]`;function de(e){return typeof e==`symbol`||le(e)&&ce(e)==ue}var fe=NaN,pe=/^[-+]0x[0-9a-f]+$/i,me=/^0b[01]+$/i,he=/^0o[0-7]+$/i,ge=parseInt;function _e(e){if(typeof e==`number`)return e;if(de(e))return fe;if(b(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=b(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=O(e);var n=me.test(e);return n||he.test(e)?ge(e.slice(2),n?2:8):pe.test(e)?fe:+e}var ve=`Expected a function`,ye=Math.max,be=Math.min;function xe(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(ve);t=_e(t)||0,b(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?ye(_e(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?be(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=w();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function x(){return s===void 0?o:v(w())}function S(){var e=w(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return S.cancel=y,S.flush=x,S}function Se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ce(e){if(Array.isArray(e))return e}function we(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Te(e,t,n){return Object.defineProperty(e,`prototype`,{writable:!1}),e}function Ee(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function De(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oe(e,t){return Ce(e)||Ee(e,t)||ke(e,t)||De()}function ke(e,t){if(e){if(typeof e==`string`)return Se(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Se(e,t):void 0}}var Ae=Te(function e(t,n){var r=n.default,i=r===void 0?null:r,a=n.triggerUpdate,o=a===void 0?!0:a,s=n.onChange,c=s===void 0?function(e,t){}:s;we(this,e),this.name=t,this.defaultVal=i,this.triggerUpdate=o,this.onChange=c});function je(e){var t=e.stateInit,n=t===void 0?function(){return{}}:t,r=e.props,i=r===void 0?{}:r,a=e.methods,o=a===void 0?{}:a,s=e.aliases,c=s===void 0?{}:s,l=e.init,u=l===void 0?function(){}:l,d=e.update,f=d===void 0?function(){}:d,p=Object.keys(i).map(function(e){return new Ae(e,i[e])});return function e(){for(var t=arguments.length,r=Array(t),i=0;i<t;i++)r[i]=arguments[i];var a=!!(this instanceof e&&this.constructor),s=a?r.shift():void 0,l=r[0],d=l===void 0?{}:l,m=Object.assign({},n instanceof Function?n(d):n,{initialised:!1}),h={};function g(e){return _(e,d),v(),g}var _=function(e,t){u.call(g,e,m,t),m.initialised=!0},v=xe(function(){m.initialised&&(f.call(g,m,h),h={})},1);return p.forEach(function(e){g[e.name]=t(e);function t(e){var t=e.name,n=e.triggerUpdate,r=n===void 0?!1:n,i=e.onChange,a=i===void 0?function(e,t){}:i,o=e.defaultVal,s=o===void 0?null:o;return function(e){var n=m[t];if(!arguments.length)return n;var i=e===void 0?s:e;return m[t]=i,a.call(g,i,m,n),!h.hasOwnProperty(t)&&(h[t]=n),r&&v(),g}}}),Object.keys(o).forEach(function(e){g[e]=function(){for(var t,n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=o[e]).call.apply(t,[g,m].concat(r))}}),Object.entries(c).forEach(function(e){var t=Oe(e,2),n=t[0];return g[n]=g[t[1]]}),g.resetProps=function(){return p.forEach(function(e){g[e.name](e.defaultVal)}),g},g.resetProps(),m._rerender=v,a&&s&&g(s),g}}var Me=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return e},Out:function(e){return e},InOut:function(e){return e}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return .5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return e===0?0:1024**(e-1)},Out:function(e){return e===1?1:1-2**(-10*e)},InOut:function(e){return e===0?0:e===1?1:(e*=2)<1?.5*1024**(e-1):.5*(-(2**(-10*(e-1)))+2)}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return e===0?0:e===1?1:-(2**(10*(e-1)))*Math.sin((e-1.1)*5*Math.PI)},Out:function(e){return e===0?0:e===1?1:2**(-10*e)*Math.sin((e-.1)*5*Math.PI)+1},InOut:function(e){return e===0?0:e===1?1:(e*=2,e<1?-.5*2**(10*(e-1))*Math.sin((e-1.1)*5*Math.PI):.5*2**(-10*(e-1))*Math.sin((e-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(e){var t=1.70158;return e===1?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return e===0?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=1.70158*1.525;return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-Me.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?Me.Bounce.In(e*2)*.5:Me.Bounce.Out(e*2-1)*.5+.5}}),generatePow:function(e){return e===void 0&&(e=4),e=e<2**-52?2**-52:e,e=e>1e4?1e4:e,{In:function(t){return t**+e},Out:function(t){return 1-(1-t)**e},InOut:function(t){return t<.5?(t*2)**e/2:(1-(2-t*2)**e)/2+.5}}}}),Ne=function(){return performance.now()},Pe=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){e===void 0&&(e=Ne()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var i=this._tweens[n[r]],a=!t;i&&i.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),Fe={Linear:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=Fe.Utils.Linear;return t<0?a(e[0],e[1],r):t>1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=Fe.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=Fe.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n<i+1?n:i+1],e[n<i+2?n:i+2],r-i)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=Fe.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(function(){var e=[1];return function(t){var n=1;if(e[t])return e[t];for(var r=t;r>1;r--)n*=r;return e[t]=n,n}})(),CatmullRom:function(e,t,n,r,i){var a=(n-e)*.5,o=(r-t)*.5,s=i*i,c=i*s;return(2*t-2*n+a+o)*c+(-3*t+3*n-2*a-o)*s+a*i+t}}},Ie=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),Le=new Pe,Re=function(){function e(e,t){t===void 0&&(t=Le),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Me.Linear.None,this._interpolationFunction=Fe.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Ie.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.getDuration=function(){return this._duration},e.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw Error(`Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.`);return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},e.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},e.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},e.prototype.start=function(e,t){if(e===void 0&&(e=Ne()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),c=s?`array`:typeof o,l=!s&&Array.isArray(n[a]);if(!(c===`undefined`||c===`function`)){if(l){var u=n[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var m=this._handleRelativeValue(o,u[f]);if(isNaN(m)){l=!1,console.warn(`Found invalid interpolation list. Skipping.`);break}d.push(m)}l&&(n[a]=d)}if((c===`object`||s)&&o&&!l){t[a]=s?[]:{};var h=o;for(var g in h)t[a][g]=h[g];r[a]=s?[]:{};var u=n[a];if(!this._isDynamic){var _={};for(var g in u)_[g]=u[g];n[a]=u=_}this._setupProperties(h,t[a],u,r[a],i)}else (t[a]===void 0||i)&&(t[a]=o),s||(t[a]*=1),l?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return e===void 0&&(e=Ne()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},e.prototype.resume=function(e){return e===void 0&&(e=Ne()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return e===void 0&&(e=Le),this._group=e,this},e.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return e===void 0&&(e=Me.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return e===void 0&&(e=Fe.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){var n=this;if(e===void 0&&(e=Ne()),t===void 0&&(t=!0),this._isPaused)return!0;var r,i=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>i)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,o=this._duration+(this._repeatDelayTime??this._delayTime),s=this._duration+this._repeat*o,c=function(){if(n._duration===0||a>s)return 1;var e=a-Math.trunc(a/o)*o,t=Math.min(e/n._duration,1);return t===0&&a===n._duration?1:t}(),l=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);for(r in isFinite(this._repeat)&&(this._repeat-=u),this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]==`string`&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,f=this._chainedTweens.length;d<f;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,r){for(var i in n)if(t[i]!==void 0){var a=t[i]||0,o=n[i];!Array.isArray(e[i])&&Array.isArray(o)?e[i]=this._interpolationFunction(o,r):typeof o==`object`&&o?this._updateProperties(e[i],a,o,r):(o=this._handleRelativeValue(a,o),typeof o==`number`&&(e[i]=a+(o-a)*r))}},e.prototype._handleRelativeValue=function(e,t){return typeof t==`string`?t.charAt(0)===`+`||t.charAt(0)===`-`?e+parseFloat(t):parseFloat(t):t},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n==`string`?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},e}();Ie.nextId;var ze=Le;ze.getAll.bind(ze),ze.removeAll.bind(ze),ze.add.bind(ze),ze.remove.bind(ze),ze.update.bind(ze);function Be(e){let t=+this._x.call(null,e),n=+this._y.call(null,e),r=+this._z.call(null,e);return Ve(this.cover(t,n,r),t,n,r,e)}function Ve(e,t,n,r,i){if(isNaN(t)||isNaN(n)||isNaN(r))return e;var a,o=e._root,s={data:i},c=e._x0,l=e._y0,u=e._z0,d=e._x1,f=e._y1,p=e._z1,m,h,g,_,v,y,b,x,S,C,w;if(!o)return e._root=s,e;for(;o.length;)if((b=t>=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g,a=o,!(o=o[C=S<<2|x<<1|b]))return a[C]=s,e;if(_=+e._x.call(null,o.data),v=+e._y.call(null,o.data),y=+e._z.call(null,o.data),t===_&&n===v&&r===y)return s.next=o,a?a[C]=s:e._root=s,e;do a=a?a[C]=Array(8):e._root=Array(8),(b=t>=(m=(c+d)/2))?c=m:d=m,(x=n>=(h=(l+f)/2))?l=h:f=h,(S=r>=(g=(u+p)/2))?u=g:p=g;while((C=S<<2|x<<1|b)==(w=(y>=g)<<2|(v>=h)<<1|_>=m));return a[w]=o,a[C]=s,e}function He(e){Array.isArray(e)||(e=Array.from(e));let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t),a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=0,f,p,m,h;d<t;++d)isNaN(p=+this._x.call(null,f=e[d]))||isNaN(m=+this._y.call(null,f))||isNaN(h=+this._z.call(null,f))||(n[d]=p,r[d]=m,i[d]=h,p<a&&(a=p),p>c&&(c=p),m<o&&(o=m),m>l&&(l=m),h<s&&(s=h),h>u&&(u=h));if(a>c||o>l||s>u)return this;this.cover(a,o,s).cover(c,l,u);for(let a=0;a<t;++a)Ve(this,n[a],r[a],i[a],e[a]);return this}function Ue(e,t,n){if(isNaN(e=+e)||isNaN(t=+t)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,a=this._z0,o=this._x1,s=this._y1,c=this._z1;if(isNaN(r))o=(r=Math.floor(e))+1,s=(i=Math.floor(t))+1,c=(a=Math.floor(n))+1;else{for(var l=o-r||1,u=this._root,d,f;r>e||e>=o||i>t||t>=s||a>n||n>=c;)switch(f=(n<a)<<2|(t<i)<<1|e<r,d=Array(8),d[f]=u,u=d,l*=2,f){case 0:o=r+l,s=i+l,c=a+l;break;case 1:r=o-l,s=i+l,c=a+l;break;case 2:o=r+l,i=s-l,c=a+l;break;case 3:r=o-l,i=s-l,c=a+l;break;case 4:o=r+l,s=i+l,a=c-l;break;case 5:r=o-l,s=i+l,a=c-l;break;case 6:o=r+l,i=s-l,a=c-l;break;case 7:r=o-l,i=s-l,a=c-l;break}this._root&&this._root.length&&(this._root=u)}return this._x0=r,this._y0=i,this._z0=a,this._x1=o,this._y1=s,this._z1=c,this}function We(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Ge(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function Ke(e,t,n,r,i,a,o){this.node=e,this.x0=t,this.y0=n,this.z0=r,this.x1=i,this.y1=a,this.z1=o}function M(e,t,n,r){var i,a=this._x0,o=this._y0,s=this._z0,c,l,u,d,f,p,m=this._x1,h=this._y1,g=this._z1,_=[],v=this._root,y,b;for(v&&_.push(new Ke(v,a,o,s,m,h,g)),r==null?r=1/0:(a=e-r,o=t-r,s=n-r,m=e+r,h=t+r,g=n+r,r*=r);y=_.pop();)if(!(!(v=y.node)||(c=y.x0)>m||(l=y.y0)>h||(u=y.z0)>g||(d=y.x1)<a||(f=y.y1)<o||(p=y.z1)<s))if(v.length){var x=(c+d)/2,S=(l+f)/2,C=(u+p)/2;_.push(new Ke(v[7],x,S,C,d,f,p),new Ke(v[6],c,S,C,x,f,p),new Ke(v[5],x,l,C,d,S,p),new Ke(v[4],c,l,C,x,S,p),new Ke(v[3],x,S,u,d,f,C),new Ke(v[2],c,S,u,x,f,C),new Ke(v[1],x,l,u,d,S,C),new Ke(v[0],c,l,u,x,S,C)),(b=(n>=C)<<2|(t>=S)<<1|e>=x)&&(y=_[_.length-1],_[_.length-1]=_[_.length-1-b],_[_.length-1-b]=y)}else{var w=e-+this._x.call(null,v.data),T=t-+this._y.call(null,v.data),E=n-+this._z.call(null,v.data),D=w*w+T*T+E*E;if(D<r){var O=Math.sqrt(r=D);a=e-O,o=t-O,s=n-O,m=e+O,h=t+O,g=n+O,i=v.data}}return i}var qe=(e,t,n,r,i,a)=>Math.sqrt((e-r)**2+(t-i)**2+(n-a)**2);function Je(e,t,n,r){let i=[],a=e-r,o=t-r,s=n-r,c=e+r,l=t+r,u=n+r;return this.visit((d,f,p,m,h,g,_)=>{if(!d.length)do{let a=d.data;qe(e,t,n,this._x(a),this._y(a),this._z(a))<=r&&i.push(a)}while(d=d.next);return f>c||p>l||m>u||h<a||g<o||_<s}),i}function Ye(e){if(isNaN(f=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e))||isNaN(m=+this._z.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._z0,l=this._x1,u=this._y1,d=this._z1,f,p,m,h,g,_,v,y,b,x,S;if(!n)return this;if(n.length)for(;;){if((v=f>=(h=(o+l)/2))?o=h:l=h,(y=p>=(g=(s+u)/2))?s=g:u=g,(b=m>=(_=(c+d)/2))?c=_:d=_,t=n,!(n=n[x=b<<2|y<<1|v]))return this;if(!n.length)break;(t[x+1&7]||t[x+2&7]||t[x+3&7]||t[x+4&7]||t[x+5&7]||t[x+6&7]||t[x+7&7])&&(r=t,S=x)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[x]=a:delete t[x],(n=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&n===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[S]=n:this._root=n),this):(this._root=a,this)}function Xe(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Ze(){return this._root}function Qe(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function $e(e){var t=[],n,r=this._root,i,a,o,s,c,l,u;for(r&&t.push(new Ke(r,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.z0,c=n.x1,l=n.y1,u=n.z1)&&r.length){var d=(a+c)/2,f=(o+l)/2,p=(s+u)/2;(i=r[7])&&t.push(new Ke(i,d,f,p,c,l,u)),(i=r[6])&&t.push(new Ke(i,a,f,p,d,l,u)),(i=r[5])&&t.push(new Ke(i,d,o,p,c,f,u)),(i=r[4])&&t.push(new Ke(i,a,o,p,d,f,u)),(i=r[3])&&t.push(new Ke(i,d,f,s,c,l,p)),(i=r[2])&&t.push(new Ke(i,a,f,s,d,l,p)),(i=r[1])&&t.push(new Ke(i,d,o,s,c,f,p)),(i=r[0])&&t.push(new Ke(i,a,o,s,d,f,p))}return this}function et(e){var t=[],n=[],r;for(this._root&&t.push(new Ke(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.z0,l=r.x1,u=r.y1,d=r.z1,f=(o+l)/2,p=(s+u)/2,m=(c+d)/2;(a=i[0])&&t.push(new Ke(a,o,s,c,f,p,m)),(a=i[1])&&t.push(new Ke(a,f,s,c,l,p,m)),(a=i[2])&&t.push(new Ke(a,o,p,c,f,u,m)),(a=i[3])&&t.push(new Ke(a,f,p,c,l,u,m)),(a=i[4])&&t.push(new Ke(a,o,s,m,f,p,d)),(a=i[5])&&t.push(new Ke(a,f,s,m,l,p,d)),(a=i[6])&&t.push(new Ke(a,o,p,m,f,u,d)),(a=i[7])&&t.push(new Ke(a,f,p,m,l,u,d))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.z0,r.x1,r.y1,r.z1);return this}function tt(e){return e[0]}function nt(e){return arguments.length?(this._x=e,this):this._x}function rt(e){return e[1]}function it(e){return arguments.length?(this._y=e,this):this._y}function at(e){return e[2]}function ot(e){return arguments.length?(this._z=e,this):this._z}function st(e,t,n,r){var i=new ct(t??tt,n??rt,r??at,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function ct(e,t,n,r,i,a,o,s,c){this._x=e,this._y=t,this._z=n,this._x0=r,this._y0=i,this._z0=a,this._x1=o,this._y1=s,this._z1=c,this._root=void 0}function lt(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var ut=st.prototype=ct.prototype;ut.copy=function(){var e=new ct(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=lt(t),e;for(n=[{source:t,target:e._root=Array(8)}];t=n.pop();)for(var i=0;i<8;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=Array(8)}):t.target[i]=lt(r));return e},ut.add=Be,ut.addAll=He,ut.cover=Ue,ut.data=We,ut.extent=Ge,ut.find=M,ut.findAllWithinRadius=Je,ut.remove=Ye,ut.removeAll=Xe,ut.root=Ze,ut.size=Qe,ut.visit=$e,ut.visitAfter=et,ut.x=nt,ut.y=it,ut.z=ot;function dt(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function ft(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function pt(e){let t,n,r;e.length===2?(t=e===dt||e===ft?e:mt,n=e,r=e):(t=dt,n=(t,n)=>dt(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function mt(){return 0}function ht(e){return e===null?NaN:+e}var gt=pt(dt),_t=gt.right;gt.left,pt(ht).center;function vt(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}var yt=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){let t=this._partials,n=0;for(let r=0;r<this._n&&r<32;r++){let i=t[r],a=e+i,o=Math.abs(e)<Math.abs(i)?e-(a-i):i-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){let e=this._partials,t=this._n,n,r,i,a=0;if(t>0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}},bt=Math.sqrt(50),xt=Math.sqrt(10),St=Math.sqrt(2);function Ct(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=bt?10:a>=xt?5:a>=St?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?Ct(e,t,n*2):[s,c,l]}function wt(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?Ct(t,e,n):Ct(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o;else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Tt(e,t,n){return t=+t,e=+e,n=+n,Ct(e,t,n)[2]}function Et(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Tt(t,e,n):Tt(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Dt(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function Ot(e,t){let n=0,r=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}function*kt(e){for(let t of e)yield*t}function At(e){return Array.from(kt(e))}function jt(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Mt(e,t){let n=0;if(t===void 0)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let i of e)(i=+t(i,++r,e))&&(n+=i)}return n}function Nt(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function Pt(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ft(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function It(){}var Lt=.7,Rt=1/Lt,zt=`\\s*([+-]?\\d+)\\s*`,Bt=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Vt=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,Ht=/^#([0-9a-f]{3,8})$/,Ut=RegExp(`^rgb\\(${zt},${zt},${zt}\\)$`),Wt=RegExp(`^rgb\\(${Vt},${Vt},${Vt}\\)$`),Gt=RegExp(`^rgba\\(${zt},${zt},${zt},${Bt}\\)$`),Kt=RegExp(`^rgba\\(${Vt},${Vt},${Vt},${Bt}\\)$`),qt=RegExp(`^hsl\\(${Bt},${Vt},${Vt}\\)$`),Jt=RegExp(`^hsla\\(${Bt},${Vt},${Vt},${Bt}\\)$`),Yt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Pt(It,en,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Xt,formatHex:Xt,formatHex8:Zt,formatHsl:Qt,formatRgb:$t,toString:$t});function Xt(){return this.rgb().formatHex()}function Zt(){return this.rgb().formatHex8()}function Qt(){return mn(this).formatHsl()}function $t(){return this.rgb().formatRgb()}function en(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=Ht.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?tn(t):n===3?new on(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?nn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?nn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ut.exec(e))?new on(t[1],t[2],t[3],1):(t=Wt.exec(e))?new on(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Gt.exec(e))?nn(t[1],t[2],t[3],t[4]):(t=Kt.exec(e))?nn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qt.exec(e))?pn(t[1],t[2]/100,t[3]/100,1):(t=Jt.exec(e))?pn(t[1],t[2]/100,t[3]/100,t[4]):Yt.hasOwnProperty(e)?tn(Yt[e]):e===`transparent`?new on(NaN,NaN,NaN,0):null}function tn(e){return new on(e>>16&255,e>>8&255,e&255,1)}function nn(e,t,n,r){return r<=0&&(e=t=n=NaN),new on(e,t,n,r)}function rn(e){return e instanceof It||(e=en(e)),e?(e=e.rgb(),new on(e.r,e.g,e.b,e.opacity)):new on}function an(e,t,n,r){return arguments.length===1?rn(e):new on(e,t,n,r??1)}function on(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Pt(on,an,Ft(It,{brighter(e){return e=e==null?Rt:Rt**+e,new on(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lt:Lt**+e,new on(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new on(dn(this.r),dn(this.g),dn(this.b),un(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:sn,formatHex:sn,formatHex8:cn,formatRgb:ln,toString:ln}));function sn(){return`#${fn(this.r)}${fn(this.g)}${fn(this.b)}`}function cn(){return`#${fn(this.r)}${fn(this.g)}${fn(this.b)}${fn((isNaN(this.opacity)?1:this.opacity)*255)}`}function ln(){let e=un(this.opacity);return`${e===1?`rgb(`:`rgba(`}${dn(this.r)}, ${dn(this.g)}, ${dn(this.b)}${e===1?`)`:`, ${e})`}`}function un(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function dn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function fn(e){return e=dn(e),(e<16?`0`:``)+e.toString(16)}function pn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new gn(e,t,n,r)}function mn(e){if(e instanceof gn)return new gn(e.h,e.s,e.l,e.opacity);if(e instanceof It||(e=en(e)),!e)return new gn;if(e instanceof gn)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new gn(o,s,c,e.opacity)}function hn(e,t,n,r){return arguments.length===1?mn(e):new gn(e,t,n,r??1)}function gn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Pt(gn,hn,Ft(It,{brighter(e){return e=e==null?Rt:Rt**+e,new gn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lt:Lt**+e,new gn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new on(yn(e>=240?e-240:e+120,i,r),yn(e,i,r),yn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new gn(_n(this.h),vn(this.s),vn(this.l),un(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=un(this.opacity);return`${e===1?`hsl(`:`hsla(`}${_n(this.h)}, ${vn(this.s)*100}%, ${vn(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function _n(e){return e=(e||0)%360,e<0?e+360:e}function vn(e){return Math.max(0,Math.min(1,e||0))}function yn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var bn=e=>()=>e;function xn(e,t){return function(n){return e+n*t}}function Sn(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Cn(e){return(e=+e)==1?wn:function(t,n){return n-t?Sn(t,n,e):bn(isNaN(t)?n:t)}}function wn(e,t){var n=t-e;return n?xn(e,n):bn(isNaN(e)?t:e)}var Tn=(function e(t){var n=Cn(t);function r(e,t){var r=n((e=an(e)).r,(t=an(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=wn(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function En(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function Dn(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function On(e,t){return(Dn(t)?En:kn)(e,t)}function kn(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=Rn(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function An(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function jn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Mn(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=Rn(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var Nn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Pn=new RegExp(Nn.source,`g`);function Fn(e){return function(){return e}}function In(e){return function(t){return e(t)+``}}function Ln(e,t){var n=Nn.lastIndex=Pn.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Nn.exec(e))&&(i=Pn.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:jn(r,i)})),n=Pn.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?In(c[0].x):Fn(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function Rn(e,t){var n=typeof t,r;return t==null||n===`boolean`?bn(t):(n===`number`?jn:n===`string`?(r=en(t))?(t=r,Tn):Ln:t instanceof en?Tn:t instanceof Date?An:Dn(t)?En:Array.isArray(t)?kn:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Mn:jn)(e,t)}function zn(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function Bn(e){return function(){return e}}function Vn(e){return+e}var Hn=[0,1];function Un(e){return e}function Wn(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Bn(isNaN(t)?NaN:.5)}function Gn(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Kn(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=Wn(i,r),a=n(o,a)):(r=Wn(r,i),a=n(a,o)),function(e){return a(r(e))}}function qn(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=Wn(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=_t(e,t,1,r)-1;return a[n](i[n](t))}}function Jn(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Yn(){var e=Hn,t=Hn,n=Rn,r,i,a,o=Un,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Un&&(o=Gn(e[0],e[n-1])),s=n>2?qn:Kn,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),jn))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Vn),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=zn,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Un,u()):o!==Un},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Xn(){return Yn()(Un,Un)}function Zn(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function Qn(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function $n(e){return e=Qn(Math.abs(e)),e?e[1]:NaN}function er(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function tr(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var nr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function rr(e){if(!(t=nr.exec(e)))throw Error(`invalid format: `+e);var t;return new ir({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}rr.prototype=ir.prototype;function ir(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}ir.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function ar(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var or;function sr(e,t){var n=Qn(e,t);if(!n)return or=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(or=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+Qn(e,Math.max(0,t+a-1))[0]}function cr(e,t){var n=Qn(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var lr={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Zn,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>cr(e*100,t),r:cr,s:sr,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function ur(e){return e}var dr=Array.prototype.map,fr=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function pr(e){var t=e.grouping===void 0||e.thousands===void 0?ur:er(dr.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?ur:tr(dr.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=rr(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):lr[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=lr[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=ar(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&or!==void 0?fr[8+or/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor($n(t)/3)))*3,r=10**-n,i=l((e=rr(e),e.type=`f`,e),{suffix:fr[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var mr,hr,gr;_r({thousands:`,`,grouping:[3],currency:[`$`,``]});function _r(e){return mr=pr(e),hr=mr.format,gr=mr.formatPrefix,mr}function vr(e){return Math.max(0,-$n(Math.abs(e)))}function yr(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor($n(t)/3)))*3-$n(Math.abs(e)))}function br(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,$n(t)-$n(e))+1}function xr(e,t,n,r){var i=Et(e,t,n),a;switch(r=rr(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=yr(i,o))&&(r.precision=a),gr(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=br(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=vr(i))&&(r.precision=a-(r.type===`%`)*2);break}return hr(r)}function Sr(e){var t=e.domain;return e.ticks=function(e){var n=t();return wt(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return xr(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-- >0;){if(l=Tt(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Cr(){var e=Xn();return e.copy=function(){return Jn(e,Cr())},Nt.apply(e,arguments),Sr(e)}function wr(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[_t(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return wr().domain([e,t]).range(i).unknown(a)},Nt.apply(Sr(o),arguments)}var Tr=1e-6,Er=Math.PI,Dr=Er/2,Or=Er/4,kr=Er*2,Ar=180/Er,jr=Er/180,Mr=Math.abs,Nr=Math.atan,Pr=Math.atan2,Fr=Math.cos,Ir=Math.ceil,Lr=Math.exp,Rr=Math.hypot,zr=Math.log,N=Math.sin,Br=Math.sign||function(e){return e>0?1:e<0?-1:0},Vr=Math.sqrt,Hr=Math.tan;function Ur(e){return e>1?0:e<-1?Er:Math.acos(e)}function Wr(e){return e>1?Dr:e<-1?-Dr:Math.asin(e)}function Gr(e){return(e=N(e/2))*e}function Kr(){}function qr(e,t){e&&Yr.hasOwnProperty(e.type)&&Yr[e.type](e,t)}var Jr={Feature:function(e,t){qr(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)qr(n[r].geometry,t)}},Yr={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){Xr(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)Xr(n[r],t,0)},Polygon:function(e,t){P(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)P(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)qr(n[r],t)}};function Xr(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r<i;)a=e[r],t.point(a[0],a[1],a[2]);t.lineEnd()}function P(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)Xr(e[n],t,1);t.polygonEnd()}function F(e,t){e&&Jr.hasOwnProperty(e.type)?Jr[e.type](e,t):qr(e,t)}var Zr=new yt,Qr=new yt,$r,ei,ti,ni,ri,ii={point:Kr,lineStart:Kr,lineEnd:Kr,polygonStart:function(){Zr=new yt,ii.lineStart=ai,ii.lineEnd=oi},polygonEnd:function(){var e=+Zr;Qr.add(e<0?kr+e:e),this.lineStart=this.lineEnd=this.point=Kr},sphere:function(){Qr.add(kr)}};function ai(){ii.point=si}function oi(){ci($r,ei)}function si(e,t){ii.point=ci,$r=e,ei=t,e*=jr,t*=jr,ti=e,ni=Fr(t=t/2+Or),ri=N(t)}function ci(e,t){e*=jr,t*=jr,t=t/2+Or;var n=e-ti,r=n>=0?1:-1,i=r*n,a=Fr(t),o=N(t),s=ri*o,c=ni*a+s*Fr(i),l=s*r*N(i);Zr.add(Pr(l,c)),ti=e,ni=a,ri=o}function li(e){return[Pr(e[1],e[0]),Wr(e[2])]}function ui(e){var t=e[0],n=e[1],r=Fr(n);return[r*Fr(t),r*N(t),N(n)]}function di(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function fi(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function pi(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function mi(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function hi(e){var t=Vr(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di={point:Oi,lineStart:Ai,lineEnd:ji,polygonStart:function(){Di.point=Mi,Di.lineStart=Ni,Di.lineEnd=Pi,wi=new yt,ii.polygonStart()},polygonEnd:function(){ii.polygonEnd(),Di.point=Oi,Di.lineStart=Ai,Di.lineEnd=ji,Zr<0?(gi=-(vi=180),_i=-(yi=90)):wi>1e-6?yi=90:wi<-1e-6&&(_i=-90),Ei[0]=gi,Ei[1]=vi},sphere:function(){gi=-(vi=180),_i=-(yi=90)}};function Oi(e,t){Ti.push(Ei=[gi=e,vi=e]),t<_i&&(_i=t),t>yi&&(yi=t)}function ki(e,t){var n=ui([e*jr,t*jr]);if(Ci){var r=fi(Ci,n),i=fi([r[1],-r[0],0],r);hi(i),i=li(i);var a=e-bi,o=a>0?1:-1,s=i[0]*Ar*o,c,l=Mr(a)>180;l^(o*bi<s&&s<o*e)?(c=i[1]*Ar,c>yi&&(yi=c)):(s=(s+360)%360-180,l^(o*bi<s&&s<o*e)?(c=-i[1]*Ar,c<_i&&(_i=c)):(t<_i&&(_i=t),t>yi&&(yi=t))),l?e<bi?Fi(gi,e)>Fi(gi,vi)&&(vi=e):Fi(e,vi)>Fi(gi,vi)&&(gi=e):vi>=gi?(e<gi&&(gi=e),e>vi&&(vi=e)):e>bi?Fi(gi,e)>Fi(gi,vi)&&(vi=e):Fi(e,vi)>Fi(gi,vi)&&(gi=e)}else Ti.push(Ei=[gi=e,vi=e]);t<_i&&(_i=t),t>yi&&(yi=t),Ci=n,bi=e}function Ai(){Di.point=ki}function ji(){Ei[0]=gi,Ei[1]=vi,Di.point=Oi,Ci=null}function Mi(e,t){if(Ci){var n=e-bi;wi.add(Mr(n)>180?n+(n>0?360:-360):n)}else xi=e,Si=t;ii.point(e,t),ki(e,t)}function Ni(){ii.lineStart()}function Pi(){Mi(xi,Si),ii.lineEnd(),Mr(wi)>1e-6&&(gi=-(vi=180)),Ei[0]=gi,Ei[1]=vi,Ci=null}function Fi(e,t){return(t-=e)<0?t+360:t}function Ii(e,t){return e[0]-t[0]}function Li(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t<e[0]||e[1]<t}function Ri(e){var t,n,r,i,a,o,s;if(yi=vi=-(gi=_i=1/0),Ti=[],F(e,Di),n=Ti.length){for(Ti.sort(Ii),t=1,r=Ti[0],a=[r];t<n;++t)i=Ti[t],Li(r,i[0])||Li(r,i[1])?(Fi(r[0],i[1])>Fi(r[0],r[1])&&(r[1]=i[1]),Fi(i[0],r[1])>Fi(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,n=a.length-1,t=0,r=a[n];t<=n;r=i,++t)i=a[t],(s=Fi(r[1],i[0]))>o&&(o=s,gi=i[0],vi=r[1])}return Ti=Ei=null,gi===1/0||_i===1/0?[[NaN,NaN],[NaN,NaN]]:[[gi,_i],[vi,yi]]}var zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta={sphere:Kr,point:na,lineStart:ia,lineEnd:sa,polygonStart:function(){ta.lineStart=ca,ta.lineEnd=la},polygonEnd:function(){ta.lineStart=ia,ta.lineEnd=sa}};function na(e,t){e*=jr,t*=jr;var n=Fr(t);ra(n*Fr(e),n*N(e),N(t))}function ra(e,t,n){++zi,Vi+=(e-Vi)/zi,Hi+=(t-Hi)/zi,Ui+=(n-Ui)/zi}function ia(){ta.point=aa}function aa(e,t){e*=jr,t*=jr;var n=Fr(t);Qi=n*Fr(e),$i=n*N(e),ea=N(t),ta.point=oa,ra(Qi,$i,ea)}function oa(e,t){e*=jr,t*=jr;var n=Fr(t),r=n*Fr(e),i=n*N(e),a=N(t),o=Pr(Vr((o=$i*a-ea*i)*o+(o=ea*r-Qi*a)*o+(o=Qi*i-$i*r)*o),Qi*r+$i*i+ea*a);Bi+=o,Wi+=o*(Qi+(Qi=r)),Gi+=o*($i+($i=i)),Ki+=o*(ea+(ea=a)),ra(Qi,$i,ea)}function sa(){ta.point=na}function ca(){ta.point=ua}function la(){da(Xi,Zi),ta.point=na}function ua(e,t){Xi=e,Zi=t,e*=jr,t*=jr,ta.point=da;var n=Fr(t);Qi=n*Fr(e),$i=n*N(e),ea=N(t),ra(Qi,$i,ea)}function da(e,t){e*=jr,t*=jr;var n=Fr(t),r=n*Fr(e),i=n*N(e),a=N(t),o=$i*a-ea*i,s=ea*r-Qi*a,c=Qi*i-$i*r,l=Rr(o,s,c),u=Wr(l),d=l&&-u/l;qi.add(d*o),Ji.add(d*s),Yi.add(d*c),Bi+=u,Wi+=u*(Qi+(Qi=r)),Gi+=u*($i+($i=i)),Ki+=u*(ea+(ea=a)),ra(Qi,$i,ea)}function fa(e){zi=Bi=Vi=Hi=Ui=Wi=Gi=Ki=0,qi=new yt,Ji=new yt,Yi=new yt,F(e,ta);var t=+qi,n=+Ji,r=+Yi,i=Rr(t,n,r);return i<1e-12&&(t=Wi,n=Gi,r=Ki,Bi<1e-6&&(t=Vi,n=Hi,r=Ui),i=Rr(t,n,r),i<1e-12)?[NaN,NaN]:[Pr(n,t)*Ar,Wr(r/i)*Ar]}function pa(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function ma(e,t){return Mr(e)>Er&&(e-=Math.round(e/kr)*kr),[e,t]}ma.invert=ma;function ha(e,t,n){return(e%=kr)?t||n?pa(_a(e),va(t,n)):_a(e):t||n?va(t,n):ma}function ga(e){return function(t,n){return t+=e,Mr(t)>Er&&(t-=Math.round(t/kr)*kr),[t,n]}}function _a(e){var t=ga(e);return t.invert=ga(-e),t}function va(e,t){var n=Fr(e),r=N(e),i=Fr(t),a=N(t);function o(e,t){var o=Fr(t),s=Fr(e)*o,c=N(e)*o,l=N(t),u=l*n+s*r;return[Pr(c*i-u*a,s*n-l*r),Wr(u*i+c*a)]}return o.invert=function(e,t){var o=Fr(t),s=Fr(e)*o,c=N(e)*o,l=N(t),u=l*i-c*a;return[Pr(c*i+l*a,s*n+u*r),Wr(u*n-s*r)]},o}function ya(e){e=ha(e[0]*jr,e[1]*jr,e.length>2?e[2]*jr:0);function t(t){return t=e(t[0]*jr,t[1]*jr),t[0]*=Ar,t[1]*=Ar,t}return t.invert=function(t){return t=e.invert(t[0]*jr,t[1]*jr),t[0]*=Ar,t[1]*=Ar,t},t}function ba(e,t,n,r,i,a){if(n){var o=Fr(t),s=N(t),c=r*n;i==null?(i=t+r*kr,a=t-c/2):(i=xa(o,i),a=xa(o,a),(r>0?i<a:i>a)&&(i+=r*kr));for(var l,u=i;r>0?u>a:u<a;u-=c)l=li([o,-s*Fr(u),-s*N(u)]),e.point(l[0],l[1])}}function xa(e,t){t=ui(t),t[0]-=e,hi(t);var n=Ur(-t[1]);return((-t[2]<0?-n:n)+kr-Tr)%kr}function Sa(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:Kr,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Ca(e,t){return Mr(e[0]-t[0])<1e-6&&Mr(e[1]-t[1])<1e-6}function wa(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Ta(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(Ca(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s<t;++s)i.point((n=e[s])[0],n[1]);i.lineEnd();return}r[0]+=2*Tr}a.push(c=new wa(n,e,null,!0)),o.push(c.o=new wa(n,null,c,!1)),a.push(c=new wa(r,e,null,!1)),o.push(c.o=new wa(r,null,c,!0))}}),a.length){for(o.sort(t),Ea(a),Ea(o),s=0,c=o.length;s<c;++s)o[s].e=n=!n;for(var l=a[0],u,d;;){for(var f=l,p=!0;f.v;)if((f=f.n)===l)return;u=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(p)for(s=0,c=u.length;s<c;++s)i.point((d=u[s])[0],d[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(p)for(u=f.p.z,s=u.length-1;s>=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function Ea(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n<t;)r.n=i=e[n],i.p=r,r=i;r.n=i=e[0],i.p=r}}function Da(e){return Mr(e[0])<=Er?e[0]:Br(e[0])*((Mr(e[0])+Er)%kr-Er)}function Oa(e,t){var n=Da(t),r=t[1],i=N(r),a=[N(n),-Fr(n),0],o=0,s=0,c=new yt;i===1?r=Dr+Tr:i===-1&&(r=-Dr-Tr);for(var l=0,u=e.length;l<u;++l)if(f=(d=e[l]).length)for(var d,f,p=d[f-1],m=Da(p),h=p[1]/2+Or,g=N(h),_=Fr(h),v=0;v<f;++v,m=b,g=S,_=C,p=y){var y=d[v],b=Da(y),x=y[1]/2+Or,S=N(x),C=Fr(x),w=b-m,T=w>=0?1:-1,E=T*w,D=E>Er,O=g*S;if(c.add(Pr(O*T*N(E),_*C+O*Fr(E))),o+=D?w+T*kr:w,D^m>=n^b>=n){var k=fi(ui(p),ui(y));hi(k);var A=fi(a,k);hi(A);var ee=(D^w>=0?-1:1)*Wr(A[2]);(r>ee||r===ee&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function ka(e,t,n,r){return function(i){var a=t(i),o=Sa(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=At(u);var e=Oa(l,r);u.length?(c||=(i.polygonStart(),!0),Ta(u,ja,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n<a;++n)i.point((p=f[n])[0],p[1]);i.lineEnd()}return}r>1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(Aa))}}return f}}function Aa(e){return e.length>1}function ja(e,t){return((e=e.x)[0]<0?e[1]-Dr-Tr:Dr-e[1])-((t=t.x)[0]<0?t[1]-Dr-Tr:Dr-t[1])}var Ma=ka(function(){return!0},Na,Fa,[-Er,-Dr]);function Na(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?Er:-Er,c=Mr(a-t);Mr(c-Er)<1e-6?(e.point(t,n=(n+o)/2>0?Dr:-Dr),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=Er&&(Mr(t-r)<1e-6&&(t-=r*Tr),Mr(a-s)<1e-6&&(a-=s*Tr),n=Pa(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function Pa(e,t,n,r){var i,a,o=N(e-n);return Mr(o)>1e-6?Nr((N(t)*(a=Fr(r))*N(n)-N(r)*(i=Fr(t))*N(e))/(i*a*o)):(t+r)/2}function Fa(e,t,n,r){var i;if(e==null)i=n*Dr,r.point(-Er,i),r.point(0,i),r.point(Er,i),r.point(Er,0),r.point(Er,-i),r.point(0,-i),r.point(-Er,-i),r.point(-Er,0),r.point(-Er,i);else if(Mr(e[0]-t[0])>1e-6){var a=e[0]<t[0]?Er:-Er;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(t[0],t[1])}function Ia(e){var t=Fr(e),n=2*jr,r=t>0,i=Mr(t)>Tr;function a(t,r,i,a){ba(a,e,n,i,t,r)}function o(e,n){return Fr(e)*Fr(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?Er:-Er),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||Ca(t,m)||Ca(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!Ca(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=ui(e),a=ui(n),o=[1,0,0],s=fi(i,a),c=di(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=fi(o,s),m=mi(o,d);pi(m,mi(s,f));var h=p,g=di(m,h),_=di(h,h),v=g*g-_*(di(m,m)-1);if(!(v<0)){var y=Vr(v),b=mi(h,(-g-y)/_);if(pi(b,m),b=li(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S<x&&(T=x,x=S,S=T);var E=S-x,D=Mr(E-Er)<Tr,O=D||E<1e-6;if(!D&&w<C&&(T=C,C=w,w=T),O?D?C+w>0^b[1]<(Mr(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>Er^(x<=b[0]&&b[0]<=S)){var k=mi(h,(-g+y)/_);return pi(k,m),[b,li(k)]}}}function l(t,n){var i=r?e:Er-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return ka(o,s,a,r?[0,-e]:[-Er,e-Er])}function La(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m<u)return;m<d&&(d=m)}else if(f>0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m<u)return;m<d&&(d=m)}if(m=r-s,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<d&&(d=m)}else if(p>0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<d&&(d=m)}return u>0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var Ra=1e9,za=-Ra;function Ba(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return Mr(r[0]-e)<1e-6?i>0?0:3:Mr(r[0]-n)<1e-6?i>0?2:1:Mr(r[1]-t)<1e-6?+(i>0):i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=Sa(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;n<i;++n)for(var a=d[n],o=1,s=a.length,c=a[0],l,u,f=c[0],p=c[1];o<s;++o)l=f,u=p,c=a[o],f=c[0],p=c[1],u<=r?p>r&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=At(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&Ta(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(za,Math.min(Ra,g)),_=Math.max(za,Math.min(Ra,_))],u=[a=Math.max(za,Math.min(Ra,a)),o=Math.max(za,Math.min(Ra,o))];La(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}var Va,Ha,Ua,Wa,Ga={sphere:Kr,point:Kr,lineStart:Ka,lineEnd:Kr,polygonStart:Kr,polygonEnd:Kr};function Ka(){Ga.point=Ja,Ga.lineEnd=qa}function qa(){Ga.point=Ga.lineEnd=Kr}function Ja(e,t){e*=jr,t*=jr,Ha=e,Ua=N(t),Wa=Fr(t),Ga.point=Ya}function Ya(e,t){e*=jr,t*=jr;var n=N(t),r=Fr(t),i=Mr(e-Ha),a=Fr(i),o=r*N(i),s=Wa*n-Ua*r*a,c=Ua*n+Wa*r*a;Va.add(Pr(Vr(o*o+s*s),c)),Ha=e,Ua=n,Wa=r}function Xa(e){return Va=new yt,F(e,Ga),+Va}var Za=[null,null],Qa={type:`LineString`,coordinates:Za};function $a(e,t){return Za[0]=e,Za[1]=t,Xa(Qa)}var eo={Feature:function(e,t){return no(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)if(no(n[r].geometry,t))return!0;return!1}},to={Sphere:function(){return!0},Point:function(e,t){return ro(e.coordinates,t)},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(ro(n[r],t))return!0;return!1},LineString:function(e,t){return io(e.coordinates,t)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(io(n[r],t))return!0;return!1},Polygon:function(e,t){return ao(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(ao(n[r],t))return!0;return!1},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)if(no(n[r],t))return!0;return!1}};function no(e,t){return e&&to.hasOwnProperty(e.type)?to[e.type](e,t):!1}function ro(e,t){return $a(e,t)===0}function io(e,t){for(var n,r,i,a=0,o=e.length;a<o;a++){if(r=$a(e[a],t),r===0||a>0&&(i=$a(e[a],e[a-1]),i>0&&n<=i&&r<=i&&(n+r-i)*(1-((n-r)/i)**2)<1e-12*i))return!0;n=r}return!1}function ao(e,t){return!!Oa(e.map(oo),so(t))}function oo(e){return e=e.map(so),e.pop(),e}function so(e){return[e[0]*jr,e[1]*jr]}function co(e,t){return(e&&eo.hasOwnProperty(e.type)?eo[e.type]:no)(e,t)}function lo(e,t,n){var r=jt(e,t-Tr,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function uo(e,t,n){var r=jt(e,t-Tr,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function fo(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return jt(Ir(r/u)*u,n,u).map(m).concat(jt(Ir(s/d)*d,o,d).map(h)).concat(jt(Ir(t/c)*c,e,c).filter(function(e){return Mr(e%u)>Tr}).map(f)).concat(jt(Ir(a/l)*l,i,l).filter(function(e){return Mr(e%d)>Tr}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=lo(a,i,90),p=uo(t,e,g),m=lo(s,o,90),h=uo(r,n,g),_):g},_.extentMajor([[-180,-90+Tr],[180,90-Tr]]).extentMinor([[-180,-80-Tr],[180,80+Tr]])}function po(){return fo()()}function mo(e,t){var n=e[0]*jr,r=e[1]*jr,i=t[0]*jr,a=t[1]*jr,o=Fr(r),s=N(r),c=Fr(a),l=N(a),u=o*Fr(n),d=o*N(n),f=c*Fr(i),p=c*N(i),m=2*Wr(Vr(Gr(a-r)+o*c*Gr(i-n))),h=N(m),g=m?function(e){var t=N(e*=m)/h,n=N(m-e)/h,r=n*u+t*f,i=n*d+t*p,a=n*s+t*l;return[Pr(i,r)*Ar,Pr(a,Vr(r*r+i*i))*Ar]}:function(){return[n*Ar,r*Ar]};return g.distance=m,g}var ho=e=>e,go=1/0,_o=go,vo=-go,yo=vo,bo={point:xo,lineStart:Kr,lineEnd:Kr,polygonStart:Kr,polygonEnd:Kr,result:function(){var e=[[go,_o],[vo,yo]];return vo=yo=-(_o=go=1/0),e}};function xo(e,t){e<go&&(go=e),e>vo&&(vo=e),t<_o&&(_o=t),t>yo&&(yo=t)}function So(e){return function(t){var n=new Co;for(var r in e)n[r]=e[r];return n.stream=t,n}}function Co(){}Co.prototype={constructor:Co,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function wo(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),F(n,e.stream(bo)),t(bo.result()),r!=null&&e.clipExtent(r),e}function To(e,t,n){return wo(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function Eo(e,t,n){return To(e,[[0,0],t],n)}function Do(e,t,n){return wo(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function Oo(e,t,n){return wo(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var ko=16,Ao=Fr(30*jr);function jo(e,t){return+t?No(e,t):Mo(e)}function Mo(e){return So({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function No(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=Vr(b*b+x*x+S*S),w=Wr(S/=C),T=Mr(Mr(S)-1)<1e-6||Mr(a-d)<1e-6?(a+d)/2:Pr(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,ee=v*k-_*A;(ee*ee/y>t||Mr((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m<Ao)&&(n(r,i,a,o,s,c,D,O,T,b/=C,x/=C,S,h,g),g.point(D,O),n(D,O,T,b,x,S,l,u,d,f,p,m,h,g))}}return function(t){var r,i,a,o,s,c,l,u,d,f,p,m,h={point:g,lineStart:_,lineEnd:y,polygonStart:function(){t.polygonStart(),h.lineStart=b},polygonEnd:function(){t.polygonEnd(),h.lineStart=_}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function _(){u=NaN,h.point=v,t.lineStart()}function v(r,i){var a=ui([r,i]),o=e(r,i);n(u,d,l,f,p,m,u=o[0],d=o[1],l=r,f=a[0],p=a[1],m=a[2],ko,t),t.point(u,d)}function y(){h.point=g,t.lineEnd()}function b(){_(),h.point=x,h.lineEnd=S}function x(e,t){v(r=e,t),i=u,a=d,o=f,s=p,c=m,h.point=v}function S(){n(u,d,l,f,p,m,i,a,r,o,s,c,ko,t),h.lineEnd=y,y()}return h}}var Po=So({point:function(e,t){this.stream.point(e*jr,t*jr)}});function Fo(e){return So({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function Io(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function Lo(e,t,n,r,i,a){if(!a)return Io(e,t,n,r,i);var o=Fr(a),s=N(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function Ro(e){return zo(function(){return e})()}function zo(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=Ma,g=null,_,v,y,b=ho,x=.5,S,C,w,T,E;function D(e){return w(e[0]*jr,e[1]*jr)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*Ar,e[1]*Ar]}D.stream=function(e){return T&&E===e?T:T=Po(Fo(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?Ia(m=e*jr):(m=null,Ma),A()):m*Ar},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,ho):Ba(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*jr,o=e[1]%360*jr,k()):[a*Ar,o*Ar]},D.rotate=function(e){return arguments.length?(s=e[0]%360*jr,c=e[1]%360*jr,l=e.length>2?e[2]%360*jr:0,k()):[s*Ar,c*Ar,l*Ar]},D.angle=function(e){return arguments.length?(d=e%360*jr,k()):d*Ar},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=jo(C,x=e*e),A()):Vr(x)},D.fitExtent=function(e,t){return To(D,e,t)},D.fitSize=function(e,t){return Eo(D,e,t)},D.fitWidth=function(e,t){return Do(D,e,t)},D.fitHeight=function(e,t){return Oo(D,e,t)};function k(){var e=Lo(n,0,0,f,p,d).apply(null,t(a,o)),m=Lo(n,r-e[0],i-e[1],f,p,d);return u=ha(s,c,l),C=pa(t,m),w=pa(u,C),S=jo(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Bo(e){return function(t,n){var r=Vr(t*t+n*n),i=e(r),a=N(i),o=Fr(i);return[Pr(t*a,r*o),Wr(r&&n*a/r)]}}function Vo(e,t){return[e,zr(Hr((Dr+t)/2))]}Vo.invert=function(e,t){return[e,2*Nr(Lr(t))-Dr]};function Ho(e,t){var n=Fr(t),r=1+Fr(e)*n;return[n*N(e)/r,N(t)/r]}Ho.invert=Bo(function(e){return 2*Nr(e)});function Uo(){return Ro(Ho).scale(250).clipAngle(142)}function Wo(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Go(e){if(Array.isArray(e))return e}function Ko(e){if(Array.isArray(e))return Wo(e)}function qo(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Jo(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Yo(e,t,n){return t=as(t),fs(e,ss()?Reflect.construct(t,[],as(e).constructor):t.apply(e,n))}function Xo(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Zo(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Qo(e,t){return e.get(qo(e,t))}function $o(e,t,n){Xo(e,t),t.set(e,n)}function es(e,t,n){return e.set(qo(e,t),n),n}function ts(e,t){Xo(e,t),t.add(e)}function ns(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,_s(r.key),r)}}function rs(e,t,n){return t&&ns(e.prototype,t),Object.defineProperty(e,`prototype`,{writable:!1}),e}function is(e,t,n){return(t=_s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function as(e){return as=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},as(e)}function os(e,t){if(typeof t!=`function`&&t!==null)throw 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&&ps(e,t)}function ss(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ss=function(){return!!e})()}function cs(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ls(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function us(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ds(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fs(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Jo(e)}function ps(e,t){return ps=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ps(e,t)}function ms(e,t){return Go(e)||ls(e,t)||vs(e,t)||us()}function hs(e){return Ko(e)||cs(e)||vs(e)||ds()}function gs(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function _s(e){var t=gs(e,`string`);return typeof t==`symbol`?t:t+``}function vs(e,t){if(e){if(typeof e==`string`)return Wo(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wo(e,t):void 0}}var ys=function(e){e instanceof Array?e.forEach(ys):(e.map&&e.map.dispose(),e.dispose())},bs=function(e){e.geometry&&e.geometry.dispose(),e.material&&ys(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(bs)};function xs(e,t,n){var r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return{x:n*Math.sin(r)*Math.cos(i),y:n*Math.cos(r),z:n*Math.sin(r)*Math.sin(i)}}function Ss(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),a=Math.acos(n/i),o=Math.atan2(r,t);return{lat:90-a*180/Math.PI,lng:90-o*180/Math.PI-(o<-Math.PI/2?360:0),r:i}}function Cs(e){return e*Math.PI/180}var ws=function(e){return 1-(Vo(0,(.5-e)*Math.PI)[1]/Math.PI+1)/2},Ts=function(e){return Math.max(0,Math.min(1,ws(e)))},Es=function(e){return .5-Vo.invert(0,(2*(1-e)-1)*Math.PI)[1]/Math.PI},Ds=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Cr().domain([1,0]).range([t,n]).clamp(!0),i=Cr().domain([Ts(t),Ts(n)]).range([1,0]).clamp(!0),a=function(e){return i(Ts(r(e)))},o=e.array,s=0,c=o.length;s<c;s+=2)o[s+1]=a(o[s+1]);e.needsUpdate=!0},Os=function(e,t,n,r){var i=2**e,a=Math.max(0,Math.min(i-1,Math.floor((n+180)*i/360))),o=(90-r)/180;return t&&(o=Math.max(0,Math.min(1,ws(o)))),[a,Math.floor(o*i)]},ks=function(e,t){for(var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=[],s=2**e,c=360/s,l=180/s,u=i===void 0?s-1:i,d=a===void 0?s-1:a,f=n,p=Math.min(s-1,u);f<=p;f++)for(var m=r,h=Math.min(s-1,d);m<=h;m++){var g=m,_=l;t&&(g=m===0?m:Es(m/s)*s,_=((m+1===s?m+1:Es((m+1)/s)*s)-g)*180/s);var v=-180+(f+.5)*c,y=90-(g*180/s+_/2),b=_;o.push({x:f,y:m,lng:v,lat:y,latLen:b})}return o},As=6,js=7,Ms=3,Ns=90,Ps=new WeakMap,Fs=new WeakMap,Is=new WeakMap,Ls=new WeakMap,Rs=new WeakMap,zs=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Hs=new WeakSet,Us=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=r.tileUrl,o=r.minLevel,s=o===void 0?0:o,c=r.maxLevel,l=c===void 0?17:c,u=r.mercatorProjection,d=u===void 0?!0:u;return Zo(this,t),n=Yo(this,t),ts(n,Hs),$o(n,Ps,void 0),$o(n,Fs,void 0),$o(n,Is,void 0),$o(n,Ls,void 0),$o(n,Rs,{}),$o(n,zs,void 0),$o(n,Bs,void 0),$o(n,Vs,void 0),is(n,`minLevel`,void 0),is(n,`maxLevel`,void 0),is(n,`thresholds`,hs(Array(30)).map(function(e,t){return 8/2**t})),is(n,`curvatureResolution`,5),is(n,`tileMargin`,0),is(n,`clearTiles`,function(){Object.values(Qo(Rs,n)).forEach(function(e){e.forEach(function(e){e.obj&&(n.remove(e.obj),bs(e.obj),delete e.obj)})}),es(Rs,n,{})}),es(Ps,n,e),n.tileUrl=a,es(Fs,n,d),n.minLevel=s,n.maxLevel=l,n.level=0,n.add(es(Vs,n,new i.Mesh(new i.SphereGeometry(Qo(Ps,n)*.99,180,90),new i.MeshBasicMaterial({color:0})))),Qo(Vs,n).visible=!1,Qo(Vs,n).material.polygonOffset=!0,Qo(Vs,n).material.polygonOffsetUnits=3,Qo(Vs,n).material.polygonOffsetFactor=1,n}return os(t,e),rs(t,[{key:`tileUrl`,get:function(){return Qo(Is,this)},set:function(e){es(Is,this,e),this.updatePov(Qo(Bs,this))}},{key:`level`,get:function(){return Qo(Ls,this)},set:function(e){var t,n=this;Qo(Rs,this)[e]||qo(Hs,this,Ws).call(this,e);var r=Qo(Ls,this);if(es(Ls,this,e),!(e===r||r===void 0)){if(Qo(Vs,this).visible=e>0,Qo(Rs,this)[e].forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!0)}),r<e&&((t=Qo(Rs,this)[r])==null||t.forEach(function(e){return e.obj&&(e.obj.material.depthWrite=!1)})),r>e)for(var i=e+1;i<=r;i++)Qo(Rs,this)[i]&&Qo(Rs,this)[i].forEach(function(e){e.obj&&(n.remove(e.obj),bs(e.obj),delete e.obj)});qo(Hs,this,Gs).call(this)}}},{key:`updatePov`,value:function(e){var t=this;if(!(!e||!(e instanceof i.Camera))){es(Bs,this,e);var n;if(es(zs,this,function(r){if(!r.hullPnts){var a=360/2**t.level,o=r.lng,s=r.lat,c=r.latLen,l=o-a/2,u=o+a/2,d=s-c/2,f=s+c/2;r.hullPnts=[[s,o],[d,l],[f,l],[d,u],[f,u]].map(function(e){var n=ms(e,2),r=n[0],i=n[1];return xs(r,i,Qo(Ps,t))}).map(function(e){var t=e.x,n=e.y,r=e.z;return new i.Vector3(t,n,r)})}return n||(n=new i.Frustum,e.updateMatrix(),e.updateMatrixWorld(),n.setFromProjectionMatrix(new i.Matrix4().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse))),r.hullPnts.some(function(e){return n.containsPoint(e.clone().applyMatrix4(t.matrixWorld))})}),this.tileUrl){var r=(e.position.clone().distanceTo(this.getWorldPosition(new i.Vector3))-Qo(Ps,this))/Qo(Ps,this),a=this.thresholds.findIndex(function(e){return e&&e<=r});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,a<0?this.thresholds.length:a)),qo(Hs,this,Gs).call(this)}}}}])}(i.Group);function Ws(e){var t=this;if(e>js){Qo(Rs,this)[e]=[];return}var n=Qo(Rs,this)[e]=ks(e,Qo(Fs,this));n.forEach(function(e){return e.centroid=xs(e.lat,e.lng,Qo(Ps,t))}),n.octree=st().x(function(e){return e.centroid.x}).y(function(e){return e.centroid.y}).z(function(e){return e.centroid.z}).addAll(n)}function Gs(){var e=this;if(!(!this.tileUrl||this.level===void 0||!Qo(Rs,this).hasOwnProperty(this.level))&&!(!Qo(zs,this)&&this.level>As)){var t=Qo(Rs,this)[this.level];if(Qo(Bs,this)){var n=this.worldToLocal(Qo(Bs,this).position.clone());if(t.octree){var r,a=this.worldToLocal(Qo(Bs,this).position.clone()),o=(a.length()-Qo(Ps,this))*Ms;t=(r=t.octree).findAllWithinRadius.apply(r,hs(a).concat([o]))}else{var s=Ss(n),c=(s.r/Qo(Ps,this)-1)*Ns,l=c/Math.cos(Cs(s.lat)),u=[s.lng-l,s.lng+l],d=[s.lat+c,s.lat-c],f=ms(Os(this.level,Qo(Fs,this),u[0],d[0]),2),p=f[0],m=f[1],h=ms(Os(this.level,Qo(Fs,this),u[1],d[1]),2),g=h[0],_=h[1];!t.record&&(t.record={});var v=t.record;if(!v.hasOwnProperty(`${Math.round((p+g)/2)}_${Math.round((m+_)/2)}`))t=ks(this.level,Qo(Fs,this),p,m,g,_).map(function(e){var n=`${e.x}_${e.y}`;return v.hasOwnProperty(n)?v[n]:(v[n]=e,t.push(e),e)});else{for(var y=[],b=p;b<=g;b++)for(var x=m;x<=_;x++){var S=`${b}_${x}`;v.hasOwnProperty(S)||(v[S]=ks(this.level,Qo(Fs,this),b,x,b,x)[0],t.push(v[S])),y.push(v[S])}t=y}}}t.filter(function(e){return!e.obj}).filter(Qo(zs,this)||function(){return!0}).forEach(function(t){var n=t.x,r=t.y,a=t.lng,o=t.lat,s=t.latLen,c=360/2**e.level;if(!t.obj){var l=c*(1-e.tileMargin),u=s*(1-e.tileMargin),d=Cs(a),f=Cs(-o),p=new i.Mesh(new i.SphereGeometry(Qo(Ps,e),Math.ceil(l/e.curvatureResolution),Math.ceil(u/e.curvatureResolution),Cs(90-l/2)+d,Cs(l),Cs(90-u/2)+f,Cs(u)),new i.MeshLambertMaterial);if(Qo(Fs,e)){var m=ms([o+s/2,o-s/2].map(function(e){return .5-e/180}),2),h=m[0],g=m[1];Ds(p.geometry.attributes.uv,h,g)}t.obj=p}t.loading||(t.loading=!0,new i.TextureLoader().load(e.tileUrl(n,r,e.level),function(n){var r=t.obj;r&&(n.colorSpace=i.SRGBColorSpace,r.material.map=n,r.material.color=null,r.material.needsUpdate=!0,e.add(r)),t.loading=!1}))})}}function Ks(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=qs(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=ec(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Ys(a,o,n,s,c,l,0),o}function qs(e,t,n,r,i){let a;if(i===wc(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=xc(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=xc(i/r|0,e[i],e[i+1],a);return a&&pc(a,a.next)&&(Sc(a),a=a.next),a}function Js(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(pc(n,n.next)||fc(n.prev,n,n.next)===0)){if(Sc(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function Ys(e,t,n,r,i,a,o){if(!e)return;!o&&a&&ac(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Zs(e,r,i,a):Xs(e)){t.push(c.i,e.i,l.i),Sc(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=Qs(Js(e),t),Ys(e,t,n,r,i,a,2)):o===2&&$s(e,t,n,r,i,a):Ys(Js(e),t,n,r,i,a,1);break}}}function Xs(e){let t=e.prev,n=e,r=e.next;if(fc(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&uc(i,s,a,c,o,l,m.x,m.y)&&fc(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Zs(e,t,n,r){let i=e.prev,a=e,o=e.next;if(fc(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=sc(p,m,t,n,r),v=sc(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&uc(s,u,c,d,l,f,y.x,y.y)&&fc(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&uc(s,u,c,d,l,f,b.x,b.y)&&fc(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&uc(s,u,c,d,l,f,y.x,y.y)&&fc(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&uc(s,u,c,d,l,f,b.x,b.y)&&fc(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Qs(e,t){let n=e;do{let r=n.prev,i=n.next.next;!pc(r,i)&&mc(r,n,n.next,i)&&vc(r,i)&&vc(i,r)&&(t.push(r.i,n.i,i.i),Sc(n),Sc(n.next),n=e=i),n=n.next}while(n!==e);return Js(n)}function $s(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&dc(o,e)){let s=bc(o,e);o=Js(o,o.next),s=Js(s,s.next),Ys(o,t,n,r,i,a,0),Ys(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function ec(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=qs(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(cc(o))}i.sort(tc);for(let e=0;e<i.length;e++)n=nc(i[e],n);return n}function tc(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function nc(e,t){let n=rc(e,t);if(!n)return t;let r=bc(n,e);return Js(r,r.next),Js(n,n.next)}function rc(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(pc(e,n))return n;do{if(pc(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&lc(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);vc(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&ic(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function ic(e,t){return fc(e.prev,e,t.prev)<0&&fc(t.next,e,e.next)<0}function ac(e,t,n,r){let i=e;do i.z===0&&(i.z=sc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,oc(i)}function oc(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function sc(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function cc(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function lc(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function uc(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&lc(e,t,n,r,i,a,o,s)}function dc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!_c(e,t)&&(vc(e,t)&&vc(t,e)&&yc(e,t)&&(fc(e.prev,e,t.prev)||fc(e,t.prev,t))||pc(e,t)&&fc(e.prev,e,e.next)>0&&fc(t.prev,t,t.next)>0)}function fc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function pc(e,t){return e.x===t.x&&e.y===t.y}function mc(e,t,n,r){let i=gc(fc(e,t,n)),a=gc(fc(e,t,r)),o=gc(fc(n,r,e)),s=gc(fc(n,r,t));return!!(i!==a&&o!==s||i===0&&hc(e,n,t)||a===0&&hc(e,r,t)||o===0&&hc(n,e,r)||s===0&&hc(n,t,r))}function hc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function gc(e){return e>0?1:e<0?-1:0}function _c(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&mc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function vc(e,t){return fc(e.prev,e,e.next)<0?fc(e,t,e.next)>=0&&fc(e,e.prev,t)>=0:fc(e,t,e.prev)<0||fc(e,e.next,t)<0}function yc(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function bc(e,t){let n=Cc(e.i,e.x,e.y),r=Cc(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function xc(e,t,n,r){let i=Cc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Sc(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 Cc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function wc(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function Tc(e){let t=[],n=[],r=e[0][0].length,i=0,a=0;for(let o of e){for(let e of o)for(let n=0;n<r;n++)t.push(e[n]);a&&(i+=a,n.push(i)),a=o.length}return{vertices:t,holes:n,dimensions:r}}function Ec(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Dc(e){if(Array.isArray(e))return e}function Oc(e){if(Array.isArray(e))return Ec(e)}function kc(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Ac(e,t,n){return t=Pc(t),Vc(e,Ic()?Reflect.construct(t,[],Pc(e).constructor):t.apply(e,n))}function jc(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Mc(e,t,n){return Object.defineProperty(e,`prototype`,{writable:!1}),e}function Nc(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Gc(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function Pc(e){return Pc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Pc(e)}function Fc(e,t){if(typeof t!=`function`&&t!==null)throw 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&&Hc(e,t)}function Ic(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ic=function(){return!!e})()}function Lc(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Rc(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function zc(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
6
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bc(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
7
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vc(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return kc(e)}function Hc(e,t){return Hc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Hc(e,t)}function Uc(e,t){return Dc(e)||Rc(e,t)||Gc(e,t)||zc()}function Wc(e){return Oc(e)||Lc(e)||Gc(e)||Bc()}function Gc(e,t){if(e){if(typeof e==`string`)return Ec(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ec(e,t):void 0}}var Kc=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){var i=$a(e,r)*180/Math.PI;if(i>t)for(var a=mo(r,e),o=r.length>2||e.length>2?jn(r[2]||0,e[2]||0):null,s=o?function(e){return[].concat(Wc(a(e)),[o(e)])}:a,c=1/Math.ceil(i/t),l=c;l<1;)n.push(s(l)),l+=c}n.push(r=e)}),n},qc=typeof window<`u`&&window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,Float32BufferAttribute:i.Float32BufferAttribute},Jc=new qc.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,Yc=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;jc(this,t),n=Ac(this,t),n.type=`GeoJsonGeometry`,n.parameters={geoJson:e,radius:r,resolution:i};var a=({Point:l,MultiPoint:u,LineString:d,MultiLineString:f,Polygon:p,MultiPolygon:m}[e.type]||function(){return[]})(e.coordinates,r),o=[],s=[],c=0;a.forEach(function(e){var t=o.length;Xc({indices:o,vertices:s},e),n.addGroup(t,o.length-t,c++)}),o.length&&n.setIndex(o),s.length&&n[Jc](`position`,new qc.Float32BufferAttribute(s,3));function l(e,t){return[{vertices:Qc(e[1],e[0],t+(e[2]||0)),indices:[]}]}function u(e,t){var n={vertices:[],indices:[]};return e.map(function(e){return l(e,t)}).forEach(function(e){var t=Uc(e,1)[0];Xc(n,t)}),[n]}function d(e,t){for(var n=Tc([Kc(e,i).map(function(e){var n=Uc(e,3),r=n[0],i=n[1],a=n[2];return Qc(i,r,t+(a===void 0?0:a))})]).vertices,r=Math.round(n.length/3),a=[],o=1;o<r;o++)a.push(o-1,o);return[{vertices:n,indices:a}]}function f(e,t){var n={vertices:[],indices:[]};return e.map(function(e){return d(e,t)}).forEach(function(e){var t=Uc(e,1)[0];Xc(n,t)}),[n]}function p(e,t){for(var n=Tc(e.map(function(e){return Kc(e,i).map(function(e){var n=Uc(e,3),r=n[0],i=n[1],a=n[2];return Qc(i,r,t+(a===void 0?0:a))})})),r=n.vertices,a=n.holes,o=a[0]||1/0,s=r.slice(0,o*3),c=r.slice(o*3),l=new Set(a),u=Math.round(r.length/3),d=[],f=[],p=1;p<u;p++)l.has(p)||(p<o?d.push(p-1,p):f.push(p-1-o,p-o));var m=[{indices:d,vertices:s}];return a.length&&m.push({indices:f,vertices:c}),m}function m(e,t){var n={vertices:[],indices:[]},r={vertices:[],indices:[]};e.map(function(e){return p(e,t)}).forEach(function(e){var t=Uc(e,2),i=t[0],a=t[1];Xc(n,i),a&&Xc(r,a)});var i=[n];return r.vertices.length&&i.push(r),i}return n}return Fc(t,e),Mc(t)}(qc.BufferGeometry);function Xc(e,t){var n=Math.round(e.vertices.length/3);Zc(e.vertices,t.vertices),Zc(e.indices,t.indices.map(function(e){return e+n}))}function Zc(e,t){var n=Nc(t),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;e.push(i)}}catch(e){n.e(e)}finally{n.f()}}function Qc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}var $c=p({computeMikkTSpaceTangents:()=>el,computeMorphedAttributes:()=>ul,deepCloneAttribute:()=>rl,deinterleaveAttribute:()=>al,deinterleaveGeometry:()=>ol,estimateBytesUsed:()=>sl,interleaveAttributes:()=>il,mergeAttributes:()=>nl,mergeGeometries:()=>tl,mergeGroups:()=>dl,mergeVertices:()=>cl,toCreasedNormals:()=>fl,toTrianglesDrawMode:()=>ll});function el(e,t,n=!0){if(!t||!t.isReady)throw Error(`BufferGeometryUtils: Initialized MikkTSpace library required.`);if(!e.hasAttribute(`position`)||!e.hasAttribute(`normal`)||!e.hasAttribute(`uv`))throw Error(`BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.`);function r(e){if(e.normalized||e.isInterleavedBufferAttribute){let t=new Float32Array(e.count*e.itemSize);for(let n=0,r=0;n<e.count;n++)t[r++]=e.getX(n),t[r++]=e.getY(n),e.itemSize>2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}let a=e.index?e.toNonIndexed():e,o=t.generateTangents(r(a.attributes.position),r(a.attributes.normal),r(a.attributes.uv));if(n)for(let e=3;e<o.length;e+=4)o[e]*=-1;return a.setAttribute(`tangent`,new i.BufferAttribute(o,4)),e!==a&&e.copy(a),e}function tl(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),o={},s={},c=e[0].morphTargetsRelative,l=new i.BufferGeometry,u=0;for(let i=0;i<e.length;++i){let d=e[i],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!a.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. .morphAttributes must be consistent throughout all geometries.`),null;s[e]===void 0&&(s[e]=[]),s[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+i+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,e,i),u+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=nl(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=nl(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l}function nl(e){let t,n,r,a=-1,o=0;for(let i=0;i<e.length;++i){let s=e[i];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*n}let s=new t(o),c=new i.BufferAttribute(s,n,r),l=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=l/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);c.setComponent(t+e,i,n)}}else s.set(r.array,l);l+=r.count*n}return a!==void 0&&(c.gpuType=a),c}function rl(e){return e.isInstancedInterleavedBufferAttribute||e.isInterleavedBufferAttribute?al(e):e.isInstancedBufferAttribute?new i.InstancedBufferAttribute().copy(e):new i.BufferAttribute().copy(e)}function il(e){let t,n=0,r=0;for(let i=0,a=e.length;i<a;++i){let a=e[i];if(t===void 0&&(t=a.array.constructor),t!==a.array.constructor)return console.error(`AttributeBuffers of different types cannot be interleaved`),null;n+=a.array.length,r+=a.itemSize}let a=new i.InterleavedBuffer(new t(n),r),o=0,s=[],c=[`getX`,`getY`,`getZ`,`getW`],l=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=e.length;t<n;t++){let n=e[t],r=n.itemSize,u=n.count,d=new i.InterleavedBufferAttribute(a,r,o,n.normalized);s.push(d),o+=r;for(let e=0;e<u;e++)for(let t=0;t<r;t++)d[l[t]](e,n[c[t]](e))}return s}function al(e){let t=e.data.array.constructor,n=e.count,r=e.itemSize,a=e.normalized,o=new t(n*r),s;s=e.isInstancedInterleavedBufferAttribute?new i.InstancedBufferAttribute(o,r,a,e.meshPerAttribute):new i.BufferAttribute(o,r,a);for(let t=0;t<n;t++)s.setX(t,e.getX(t)),r>=2&&s.setY(t,e.getY(t)),r>=3&&s.setZ(t,e.getZ(t)),r>=4&&s.setW(t,e.getW(t));return s}function ol(e){let t=e.attributes,n=e.morphTargets,r=new Map;for(let e in t){let n=t[e];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,al(n)),t[e]=r.get(n))}for(let e in n){let t=n[e];t.isInterleavedBufferAttribute&&(r.has(t)||r.set(t,al(t)),n[e]=r.get(t))}}function sl(e){let t=0;for(let n in e.attributes){let r=e.getAttribute(n);t+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}let n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t}function cl(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.attributes[n];c[n]=new r.constructor(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);let i=e.morphAttributes[n];i&&(l[n]||(l[n]=[]),i.forEach((e,t)=>{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;t<a;t++){let i=r?r.getX(t):t,a=``;for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),o=r.itemSize;for(let e=0;e<o;e++)a+=`${~~(r[d[e]](i)*m+h)},`}if(a in n)u.push(n[a]);else{for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),a=e.morphAttributes[n],u=r.itemSize,p=c[n],m=l[n];for(let e=0;e<u;e++){let t=d[e],n=f[e];if(p[n](o,r[t](i)),a)for(let e=0,r=a.length;e<r;e++)m[e][n](o,a[e][t](i))}}n[a]=o,u.push(o),o++}}let g=e.clone();for(let t in e.attributes){let e=c[t];if(g.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){let n=l[t][e];g.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return g.setIndex(u),g}function ll(e,t){if(t===i.TrianglesDrawMode)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===i.TriangleFanDrawMode||t===i.TriangleStripDrawMode){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,a=[];if(t===i.TriangleFanDrawMode)for(let e=1;e<=r;e++)a.push(n.getX(0)),a.push(n.getX(e)),a.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(a.push(n.getX(e)),a.push(n.getX(e+1)),a.push(n.getX(e+2))):(a.push(n.getX(e+2)),a.push(n.getX(e+1)),a.push(n.getX(e)));a.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let o=e.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}function ul(e){let t=new i.Vector3,n=new i.Vector3,r=new i.Vector3,a=new i.Vector3,o=new i.Vector3,s=new i.Vector3,c=new i.Vector3,l=new i.Vector3,u=new i.Vector3;function d(e,i,d,f,p,m,h,g){t.fromBufferAttribute(i,p),n.fromBufferAttribute(i,m),r.fromBufferAttribute(i,h);let _=e.morphTargetInfluences;if(d&&_){c.set(0,0,0),l.set(0,0,0),u.set(0,0,0);for(let e=0,i=d.length;e<i;e++){let i=_[e],g=d[e];i!==0&&(a.fromBufferAttribute(g,p),o.fromBufferAttribute(g,m),s.fromBufferAttribute(g,h),f?(c.addScaledVector(a,i),l.addScaledVector(o,i),u.addScaledVector(s,i)):(c.addScaledVector(a.sub(t),i),l.addScaledVector(o.sub(n),i),u.addScaledVector(s.sub(r),i)))}t.add(c),n.add(l),r.add(u)}e.isSkinnedMesh&&(e.applyBoneTransform(p,t),e.applyBoneTransform(m,n),e.applyBoneTransform(h,r)),g[p*3+0]=t.x,g[p*3+1]=t.y,g[p*3+2]=t.z,g[m*3+0]=n.x,g[m*3+1]=n.y,g[m*3+2]=n.z,g[h*3+0]=r.x,g[h*3+1]=r.y,g[h*3+2]=r.z}let f=e.geometry,p=e.material,m,h,g,_=f.index,v=f.attributes.position,y=f.morphAttributes.position,b=f.morphTargetsRelative,x=f.attributes.normal,S=f.morphAttributes.position,C=f.groups,w=f.drawRange,T,E,D,O,k,A,ee,j=new Float32Array(v.count*v.itemSize),te=new Float32Array(x.count*x.itemSize);if(_!==null)if(Array.isArray(p))for(T=0,D=C.length;T<D;T++)for(k=C[T],A=Math.max(k.start,w.start),ee=Math.min(k.start+k.count,w.start+w.count),E=A,O=ee;E<O;E+=3)m=_.getX(E),h=_.getX(E+1),g=_.getX(E+2),d(e,v,y,b,m,h,g,j),d(e,x,S,b,m,h,g,te);else for(A=Math.max(0,w.start),ee=Math.min(_.count,w.start+w.count),T=A,D=ee;T<D;T+=3)m=_.getX(T),h=_.getX(T+1),g=_.getX(T+2),d(e,v,y,b,m,h,g,j),d(e,x,S,b,m,h,g,te);else if(Array.isArray(p))for(T=0,D=C.length;T<D;T++)for(k=C[T],A=Math.max(k.start,w.start),ee=Math.min(k.start+k.count,w.start+w.count),E=A,O=ee;E<O;E+=3)m=E,h=E+1,g=E+2,d(e,v,y,b,m,h,g,j),d(e,x,S,b,m,h,g,te);else for(A=Math.max(0,w.start),ee=Math.min(v.count,w.start+w.count),T=A,D=ee;T<D;T+=3)m=T,h=T+1,g=T+2,d(e,v,y,b,m,h,g,j),d(e,x,S,b,m,h,g,te);return{positionAttribute:v,normalAttribute:x,morphedPositionAttribute:new i.Float32BufferAttribute(j,3),morphedNormalAttribute:new i.Float32BufferAttribute(te,3)}}function dl(e){if(e.groups.length===0)return console.warn(`THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge.`),e;let t=e.groups;if(t=t.sort((e,t)=>e.materialIndex===t.materialIndex?e.start-t.start:e.materialIndex-t.materialIndex),e.getIndex()===null){let t=e.getAttribute(`position`),n=[];for(let e=0;e<t.count;e+=3)n.push(e,e+1,e+2);e.setIndex(n)}let n=e.getIndex(),r=[];for(let e=0;e<t.length;e++){let i=t[e],a=i.start,o=a+i.count;for(let e=a;e<o;e++)r.push(n.getX(e))}e.dispose(),e.setIndex(r);let i=0;for(let e=0;e<t.length;e++){let n=t[e];n.start=i,i+=n.count}let a=t[0];e.groups=[a];for(let n=1;n<t.length;n++){let r=t[n];a.materialIndex===r.materialIndex?a.count+=r.count:(a=r,e.groups.push(a))}return e}function fl(e,t=Math.PI/3){let n=Math.cos(t),r=1.0000000001*100,a=[new i.Vector3,new i.Vector3,new i.Vector3],o=new i.Vector3,s=new i.Vector3,c=new i.Vector3,l=new i.Vector3;function u(e){return`${~~(e.x*r)},${~~(e.y*r)},${~~(e.z*r)}`}let d=e.index?e.toNonIndexed():e,f=d.attributes.position,p={};for(let e=0,t=f.count/3;e<t;e++){let t=3*e,n=a[0].fromBufferAttribute(f,t+0),r=a[1].fromBufferAttribute(f,t+1),c=a[2].fromBufferAttribute(f,t+2);o.subVectors(c,r),s.subVectors(n,r);let l=new i.Vector3().crossVectors(o,s).normalize();for(let e=0;e<3;e++){let t=a[e],n=u(t);n in p||(p[n]=[]),p[n].push(l)}}let m=new i.BufferAttribute(new Float32Array(f.count*3),3,!1);for(let e=0,t=f.count/3;e<t;e++){let t=3*e,r=a[0].fromBufferAttribute(f,t+0),i=a[1].fromBufferAttribute(f,t+1),d=a[2].fromBufferAttribute(f,t+2);o.subVectors(d,i),s.subVectors(r,i),c.crossVectors(o,s).normalize();for(let e=0;e<3;e++){let r=a[e],i=p[u(r)];l.set(0,0,0);for(let e=0,t=i.length;e<t;e++){let t=i[e];c.dot(t)>n&&l.add(t)}l.normalize(),m.setXYZ(t+e,l.x,l.y,l.z)}}return d.setAttribute(`normal`,m),d}var I=(function(e){return typeof e==`function`?e:typeof e==`string`?function(t){return t[e]}:function(t){return e}});function pl(e){"@babel/helpers - typeof";return pl=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},pl(e)}var ml=/^\s+/,hl=/\s+$/;function gl(e,t){if(e||=``,t||={},e instanceof gl)return e;if(!(this instanceof gl))return new gl(e,t);var n=_l(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}gl.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=t<=.03928?t/12.92:((t+.055)/1.055)**2.4,a=n<=.03928?n/12.92:((n+.055)/1.055)**2.4,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4;return .2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=Vl(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=xl(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=xl(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?`hsv(`+t+`, `+n+`%, `+r+`%)`:`hsva(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHsl:function(){var e=yl(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=yl(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?`hsl(`+t+`, `+n+`%, `+r+`%)`:`hsla(`+t+`, `+n+`%, `+r+`%, `+this._roundA+`)`},toHex:function(e){return Cl(this._r,this._g,this._b,e)},toHexString:function(e){return`#`+this.toHex(e)},toHex8:function(e){return wl(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return`#`+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?`rgb(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`)`:`rgba(`+Math.round(this._r)+`, `+Math.round(this._g)+`, `+Math.round(this._b)+`, `+this._roundA+`)`},toPercentageRgb:function(){return{r:Math.round(Hl(this._r,255)*100)+`%`,g:Math.round(Hl(this._g,255)*100)+`%`,b:Math.round(Hl(this._b,255)*100)+`%`,a:this._a}},toPercentageRgbString:function(){return this._a==1?`rgb(`+Math.round(Hl(this._r,255)*100)+`%, `+Math.round(Hl(this._g,255)*100)+`%, `+Math.round(Hl(this._b,255)*100)+`%)`:`rgba(`+Math.round(Hl(this._r,255)*100)+`%, `+Math.round(Hl(this._g,255)*100)+`%, `+Math.round(Hl(this._b,255)*100)+`%, `+this._roundA+`)`},toName:function(){return this._a===0?`transparent`:this._a<1?!1:zl[Cl(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t=`#`+Tl(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?`GradientType = 1, `:``;if(e){var i=gl(e);n=`#`+Tl(i._r,i._g,i._b,i._a)}return`progid:DXImageTransform.Microsoft.gradient(`+r+`startColorstr=`+t+`,endColorstr=`+n+`)`},toString:function(e){var t=!!e;e||=this._format;var n=!1,r=this._a<1&&this._a>=0;return!t&&r&&(e===`hex`||e===`hex6`||e===`hex3`||e===`hex4`||e===`hex8`||e===`name`)?e===`name`&&this._a===0?this.toName():this.toRgbString():(e===`rgb`&&(n=this.toRgbString()),e===`prgb`&&(n=this.toPercentageRgbString()),(e===`hex`||e===`hex6`)&&(n=this.toHexString()),e===`hex3`&&(n=this.toHexString(!0)),e===`hex4`&&(n=this.toHex8String(!0)),e===`hex8`&&(n=this.toHex8String()),e===`name`&&(n=this.toName()),e===`hsl`&&(n=this.toHslString()),e===`hsv`&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return gl(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(kl,arguments)},brighten:function(){return this._applyModification(Al,arguments)},darken:function(){return this._applyModification(jl,arguments)},desaturate:function(){return this._applyModification(El,arguments)},saturate:function(){return this._applyModification(Dl,arguments)},greyscale:function(){return this._applyModification(Ol,arguments)},spin:function(){return this._applyModification(Ml,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(Il,arguments)},complement:function(){return this._applyCombination(Nl,arguments)},monochromatic:function(){return this._applyCombination(Ll,arguments)},splitcomplement:function(){return this._applyCombination(Fl,arguments)},triad:function(){return this._applyCombination(Pl,[3])},tetrad:function(){return this._applyCombination(Pl,[4])}},gl.fromRatio=function(e,t){if(pl(e)==`object`){var n={};for(var r in e)e.hasOwnProperty(r)&&(r===`a`?n[r]=e[r]:n[r]=Jl(e[r]));e=n}return gl(e,t)};function _l(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;return typeof e==`string`&&(e=$l(e)),pl(e)==`object`&&(Ql(e.r)&&Ql(e.g)&&Ql(e.b)?(t=vl(e.r,e.g,e.b),o=!0,s=String(e.r).substr(-1)===`%`?`prgb`:`rgb`):Ql(e.h)&&Ql(e.s)&&Ql(e.v)?(r=Jl(e.s),i=Jl(e.v),t=Sl(e.h,r,i),o=!0,s=`hsv`):Ql(e.h)&&Ql(e.s)&&Ql(e.l)&&(r=Jl(e.s),a=Jl(e.l),t=bl(e.h,r,a),o=!0,s=`hsl`),e.hasOwnProperty(`a`)&&(n=e.a)),n=Vl(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}function vl(e,t,n){return{r:Hl(e,255)*255,g:Hl(t,255)*255,b:Hl(n,255)*255}}function yl(e,t,n){e=Hl(e,255),t=Hl(t,255),n=Hl(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=(r+i)/2;if(r==i)a=o=0;else{var c=r-i;switch(o=s>.5?c/(2-r-i):c/(r+i),r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,l:s}}function bl(e,t,n){var r,i,a;e=Hl(e,360),t=Hl(t,100),n=Hl(n,100);function o(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(t===0)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return{r:r*255,g:i*255,b:a*255}}function xl(e,t,n){e=Hl(e,255),t=Hl(t,255),n=Hl(n,255);var r=Math.max(e,t,n),i=Math.min(e,t,n),a,o,s=r,c=r-i;if(o=r===0?0:c/r,r==i)a=0;else{switch(r){case e:a=(t-n)/c+(t<n?6:0);break;case t:a=(n-e)/c+2;break;case n:a=(e-t)/c+4;break}a/=6}return{h:a,s:o,v:s}}function Sl(e,t,n){e=Hl(e,360)*6,t=Hl(t,100),n=Hl(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),c=r%6,l=[n,o,a,a,s,n][c],u=[s,n,n,o,a,a][c],d=[a,a,s,n,n,o][c];return{r:l*255,g:u*255,b:d*255}}function Cl(e,t,n,r){var i=[ql(Math.round(e).toString(16)),ql(Math.round(t).toString(16)),ql(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join(``)}function wl(e,t,n,r,i){var a=[ql(Math.round(e).toString(16)),ql(Math.round(t).toString(16)),ql(Math.round(n).toString(16)),ql(Yl(r))];return i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join(``)}function Tl(e,t,n,r){return[ql(Yl(r)),ql(Math.round(e).toString(16)),ql(Math.round(t).toString(16)),ql(Math.round(n).toString(16))].join(``)}gl.equals=function(e,t){return!e||!t?!1:gl(e).toRgbString()==gl(t).toRgbString()},gl.random=function(){return gl.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function El(e,t){t=t===0?0:t||10;var n=gl(e).toHsl();return n.s-=t/100,n.s=Ul(n.s),gl(n)}function Dl(e,t){t=t===0?0:t||10;var n=gl(e).toHsl();return n.s+=t/100,n.s=Ul(n.s),gl(n)}function Ol(e){return gl(e).desaturate(100)}function kl(e,t){t=t===0?0:t||10;var n=gl(e).toHsl();return n.l+=t/100,n.l=Ul(n.l),gl(n)}function Al(e,t){t=t===0?0:t||10;var n=gl(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),gl(n)}function jl(e,t){t=t===0?0:t||10;var n=gl(e).toHsl();return n.l-=t/100,n.l=Ul(n.l),gl(n)}function Ml(e,t){var n=gl(e).toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,gl(n)}function Nl(e){var t=gl(e).toHsl();return t.h=(t.h+180)%360,gl(t)}function Pl(e,t){if(isNaN(t)||t<=0)throw Error(`Argument to polyad must be a positive number`);for(var n=gl(e).toHsl(),r=[gl(e)],i=360/t,a=1;a<t;a++)r.push(gl({h:(n.h+a*i)%360,s:n.s,l:n.l}));return r}function Fl(e){var t=gl(e).toHsl(),n=t.h;return[gl(e),gl({h:(n+72)%360,s:t.s,l:t.l}),gl({h:(n+216)%360,s:t.s,l:t.l})]}function Il(e,t,n){t||=6,n||=30;var r=gl(e).toHsl(),i=360/n,a=[gl(e)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(gl(r));return a}function Ll(e,t){t||=6;for(var n=gl(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(gl({h:r,s:i,v:a})),a=(a+s)%1;return o}gl.mix=function(e,t,n){n=n===0?0:n||50;var r=gl(e).toRgb(),i=gl(t).toRgb(),a=n/100;return gl({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},gl.readability=function(e,t){var n=gl(e),r=gl(t);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},gl.isReadable=function(e,t,n){var r=gl.readability(e,t),i,a=!1;switch(i=eu(n),i.level+i.size){case`AAsmall`:case`AAAlarge`:a=r>=4.5;break;case`AAlarge`:a=r>=3;break;case`AAAsmall`:a=r>=7;break}return a},gl.mostReadable=function(e,t,n){var r=null,i=0,a,o,s,c;n||={},o=n.includeFallbackColors,s=n.level,c=n.size;for(var l=0;l<t.length;l++)a=gl.readability(e,t[l]),a>i&&(i=a,r=gl(t[l]));return gl.isReadable(e,r,{level:s,size:c})||!o?r:(n.includeFallbackColors=!1,gl.mostReadable(e,[`#fff`,`#000`],n))};var Rl=gl.names={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`0ff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000`,blanchedalmond:`ffebcd`,blue:`00f`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,burntsienna:`ea7e5d`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`0ff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`f0f`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`789`,lightslategrey:`789`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`0f0`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`f0f`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`f00`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`fff`,whitesmoke:`f5f5f5`,yellow:`ff0`,yellowgreen:`9acd32`},zl=gl.hexNames=Bl(Rl);function Bl(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[e[n]]=n);return t}function Vl(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function Hl(e,t){Gl(e)&&(e=`100%`);var n=Kl(e);return e=Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function Ul(e){return Math.min(1,Math.max(0,e))}function Wl(e){return parseInt(e,16)}function Gl(e){return typeof e==`string`&&e.indexOf(`.`)!=-1&&parseFloat(e)===1}function Kl(e){return typeof e==`string`&&e.indexOf(`%`)!=-1}function ql(e){return e.length==1?`0`+e:``+e}function Jl(e){return e<=1&&(e=e*100+`%`),e}function Yl(e){return Math.round(parseFloat(e)*255).toString(16)}function Xl(e){return Wl(e)/255}var Zl=function(){var e=`(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)`,t=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`,n=`[\\s|\\(]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)[,|\\s]+(`+e+`)\\s*\\)?`;return{CSS_UNIT:new RegExp(e),rgb:RegExp(`rgb`+t),rgba:RegExp(`rgba`+n),hsl:RegExp(`hsl`+t),hsla:RegExp(`hsla`+n),hsv:RegExp(`hsv`+t),hsva:RegExp(`hsva`+n),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Ql(e){return!!Zl.CSS_UNIT.exec(e)}function $l(e){e=e.replace(ml,``).replace(hl,``).toLowerCase();var t=!1;if(Rl[e])e=Rl[e],t=!0;else if(e==`transparent`)return{r:0,g:0,b:0,a:0,format:`name`};var n;return(n=Zl.rgb.exec(e))?{r:n[1],g:n[2],b:n[3]}:(n=Zl.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=Zl.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=Zl.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=Zl.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=Zl.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=Zl.hex8.exec(e))?{r:Wl(n[1]),g:Wl(n[2]),b:Wl(n[3]),a:Xl(n[4]),format:t?`name`:`hex8`}:(n=Zl.hex6.exec(e))?{r:Wl(n[1]),g:Wl(n[2]),b:Wl(n[3]),format:t?`name`:`hex`}:(n=Zl.hex4.exec(e))?{r:Wl(n[1]+``+n[1]),g:Wl(n[2]+``+n[2]),b:Wl(n[3]+``+n[3]),a:Xl(n[4]+``+n[4]),format:t?`name`:`hex8`}:(n=Zl.hex3.exec(e))?{r:Wl(n[1]+``+n[1]),g:Wl(n[2]+``+n[2]),b:Wl(n[3]+``+n[3]),format:t?`name`:`hex`}:!1}function eu(e){var t,n;return e||={level:`AA`,size:`small`},t=(e.level||`AA`).toUpperCase(),n=(e.size||`small`).toLowerCase(),t!==`AA`&&t!==`AAA`&&(t=`AA`),n!==`small`&&n!==`large`&&(n=`small`),{level:t,size:n}}function tu(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nu(e){if(Array.isArray(e))return e}function ru(e){if(Array.isArray(e))return tu(e)}function iu(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function au(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function ou(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function su(e,t){return e.get(iu(e,t))}function cu(e,t,n){au(e,t),t.set(e,n)}function lu(e,t,n){return e.set(iu(e,t),n),n}function uu(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,yu(r.key),r)}}function du(e,t,n){return t&&uu(e.prototype,t),Object.defineProperty(e,`prototype`,{writable:!1}),e}function fu(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function pu(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function mu(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hu(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gu(e,t){return nu(e)||pu(e,t)||bu(e,t)||mu()}function _u(e){return ru(e)||fu(e)||bu(e)||hu()}function vu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function yu(e){var t=vu(e,`string`);return typeof t==`symbol`?t:t+``}function bu(e,t){if(e){if(typeof e==`string`)return tu(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tu(e,t):void 0}}var xu=new WeakMap,Su=new WeakMap,Cu=new WeakMap,wu=new WeakMap,Tu=new WeakMap,Eu=new WeakMap,Du=function(){function e(){ou(this,e),cu(this,xu,new Map),cu(this,Su,new Map),cu(this,Cu,function(e){return e}),cu(this,wu,function(){return{}}),cu(this,Tu,function(){}),cu(this,Eu,function(){})}return du(e,[{key:`getObj`,value:function(e){return su(xu,this).get(su(Cu,this).call(this,e))}},{key:`getData`,value:function(e){return su(Su,this).get(e)}},{key:`entries`,value:function(){return _u(su(Su,this).entries()).map(function(e){var t=gu(e,2),n=t[0];return[t[1],n]})}},{key:`id`,value:function(e){return lu(Cu,this,I(e)),this}},{key:`onCreateObj`,value:function(e){return lu(wu,this,e),this}},{key:`onUpdateObj`,value:function(e){return lu(Tu,this,e),this}},{key:`onRemoveObj`,value:function(e){return lu(Eu,this,e),this}},{key:`digest`,value:function(e){var t=this;e.filter(function(e){return!su(xu,t).has(su(Cu,t).call(t,e))}).forEach(function(e){var n=su(wu,t).call(t,e);su(xu,t).set(su(Cu,t).call(t,e),n),su(Su,t).set(n,e)});var n=new Map(e.map(function(e){return[su(Cu,t).call(t,e),e]}));return su(xu,this).forEach(function(e,r){n.has(r)?su(Tu,t).call(t,e,n.get(r)):(su(Eu,t).call(t,e,r),su(xu,t).delete(r),su(Su,t).delete(e))}),this}},{key:`clear`,value:function(){return this.digest([]),this}}])}(),Ou=h(f(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`FrameTicker`,[],r):typeof e==`object`?e.FrameTicker=r():n.FrameTicker=r()})(e,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){"use strict";var r=n(1),i=function(){function e(e,t,n){e===void 0&&(e=NaN),t===void 0&&(t=NaN),n===void 0&&(n=!1),this._minFPS=t,this._maxFPS=e,this._timeScale=1,this._currentTick=0,this._currentTime=0,this._tickDeltaTime=0,this._isRunning=!1,this._maxInterval=isNaN(this._minFPS)?NaN:1e3/this._minFPS,this._minInterval=isNaN(this._maxFPS)?NaN:1e3/this._maxFPS,this._onResume=new r.default,this._onPause=new r.default,this._onTick=new r.default,this._onTickOncePerFrame=new r.default,n||this.resume()}return e.prototype.updateOnce=function(e){e(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.resume=function(){this._isRunning||(this._isRunning=!0,this._lastTimeUpdated=this.getTimer(),this._onResume.dispatch(),this.animateOnce())},e.prototype.pause=function(){this._isRunning&&(this._isRunning=!1,this._onPause.dispatch(),window.cancelAnimationFrame(this._animationFrameHandle))},e.prototype.dispose=function(){this.pause(),this._onResume.removeAll(),this._onPause.removeAll(),this._onTick.removeAll()},Object.defineProperty(e.prototype,`currentTick`,{get:function(){return this._currentTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`currentTimeSeconds`,{get:function(){return this._currentTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`tickDeltaTimeSeconds`,{get:function(){return this._tickDeltaTime/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`timeScale`,{get:function(){return this._timeScale},set:function(e){this._timeScale!==e&&(this._timeScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onResume`,{get:function(){return this._onResume},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onPause`,{get:function(){return this._onPause},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onTick`,{get:function(){return this._onTick},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`onTickOncePerFrame`,{get:function(){return this._onTickOncePerFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`isRunning`,{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),e.prototype.animateOnce=function(){var e=this;this._animationFrameHandle=window.requestAnimationFrame(function(){return e.onFrame()})},e.prototype.onFrame=function(){if(this._now=this.getTimer(),this._frameDeltaTime=this._now-this._lastTimeUpdated,isNaN(this._minInterval)||this._frameDeltaTime>=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},e.prototype.update=function(e,t){t===void 0&&(t=!0),this._currentTick++,this._currentTime+=e,this._tickDeltaTime=e,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),t&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},e.prototype.getTimer=function(){return Date.now()},e}();Object.defineProperty(t,`__esModule`,{value:!0}),t.default=i},function(e,t,n){(function(t,n){e.exports=n()})(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t){"use strict";var n=function(){function e(){this.functions=[]}return e.prototype.add=function(e){return this.functions.indexOf(e)===-1&&(this.functions.push(e),!0)},e.prototype.remove=function(e){var t=this.functions.indexOf(e);return t>-1&&(this.functions.splice(t,1),!0)},e.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},e.prototype.dispatch=function(){var e=[...arguments];this.functions.concat().forEach(function(t){t.apply(void 0,e)})},Object.defineProperty(e.prototype,`numItems`,{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),e}();Object.defineProperty(t,`__esModule`,{value:!0}),t.default=n}])})}])})}))(),1),ku=11102230246251565e-32,Au=134217729,ju=(3+8*ku)*ku;function Mu(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function Nu(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function L(e){return new Float64Array(e)}var Pu=(3+16*ku)*ku,Fu=(2+12*ku)*ku,Iu=(9+64*ku)*ku*ku,Lu=L(4),Ru=L(8),zu=L(12),Bu=L(16),Vu=L(4);function Hu(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=Au*T,p=f-(f-T),m=T-p,f=Au*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=Au*D,p=f-(f-D),m=D-p,f=Au*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,Lu[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,Lu[1]=y-(_+d)+(d-S),w=v+_,d=w-v,Lu[2]=v-(w-d)+(_-d),Lu[3]=w;let k=Nu(4,Lu),A=Fu*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=Iu*o+ju*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=Au*s,p=f-(f-s),m=s-p,f=Au*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=Au*c,p=f-(f-c),m=c-p,f=Au*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,Vu[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,Vu[1]=y-(_+d)+(d-S),w=v+_,d=w-v,Vu[2]=v-(w-d)+(_-d),Vu[3]=w;let ee=Mu(4,Lu,4,Vu,Ru);b=T*u,f=Au*T,p=f-(f-T),m=T-p,f=Au*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=Au*D,p=f-(f-D),m=D-p,f=Au*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,Vu[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,Vu[1]=y-(_+d)+(d-S),w=v+_,d=w-v,Vu[2]=v-(w-d)+(_-d),Vu[3]=w;let j=Mu(ee,Ru,4,Vu,zu);return b=s*u,f=Au*s,p=f-(f-s),m=s-p,f=Au*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=Au*c,p=f-(f-c),m=c-p,f=Au*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,Vu[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,Vu[1]=y-(_+d)+(d-S),w=v+_,d=w-v,Vu[2]=v-(w-d)+(_-d),Vu[3]=w,Bu[Mu(j,zu,4,Vu,Bu)-1]}function Uu(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=Pu*l?c:-Hu(e,t,n,r,i,a,l)}(7+56*ku)*ku,(3+28*ku)*ku,(26+288*ku)*ku*ku,L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(8),L(8),L(8),L(4),L(8),L(8),L(16),L(12),L(192),L(192),(10+96*ku)*ku,(4+48*ku)*ku,(44+576*ku)*ku*ku,L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(8),L(8),L(8),L(8),L(8),L(8),L(8),L(8),L(8),L(4),L(4),L(4),L(8),L(16),L(16),L(16),L(32),L(32),L(48),L(64),L(1152),L(1152),(16+224*ku)*ku,(5+72*ku)*ku,(71+1408*ku)*ku*ku,L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(4),L(24),L(24),L(24),L(24),L(24),L(24),L(24),L(24),L(24),L(24),L(1152),L(1152),L(1152),L(1152),L(1152),L(2304),L(2304),L(3456),L(5760),L(8),L(8),L(8),L(16),L(24),L(48),L(48),L(96),L(192),L(384),L(384),L(384),L(768),L(96),L(96),L(96),L(1152);var Wu=2**-52,Gu=new Uint32Array(512),Ku=class e{static from(t,n=ed,r=td){let i=t.length,a=new Float64Array(i*2);for(let e=0;e<i;e++){let i=t[e];a[2*e]=n(i),a[2*e+1]=r(i)}return new e(a)}constructor(e){let t=e.length>>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;t<a;t++){let n=e[2*t],r=e[2*t+1];n<o&&(o=n),r<s&&(s=r),n>c&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t<a;t++){let r=Ju(u,d,e[2*t],e[2*t+1]);r<n&&(f=t,n=r)}let h=e[2*f],g=e[2*f+1];for(let t=0,n=1/0;t<a;t++){if(t===f)continue;let r=Ju(h,g,e[2*t],e[2*t+1]);r<n&&r>0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;t<a;t++){if(t===f||t===p)continue;let n=Xu(h,g,_,v,e[2*t],e[2*t+1]);n<y&&(m=t,y=n)}let b=e[2*m],x=e[2*m+1];if(y===1/0){for(let t=0;t<a;t++)this._dists[t]=e[2*t]-e[0]||e[2*t+1]-e[1];Qu(this._ids,this._dists,0,a-1);let t=new Uint32Array(a),n=0;for(let e=0,r=-1/0;e<a;e++){let i=this._ids[e],a=this._dists[i];a>r&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(Uu(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=Zu(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t<a;t++)this._dists[t]=Ju(e[2*t],e[2*t+1],S.x,S.y);Qu(this._ids,this._dists,0,a-1),this._hullStart=f;let C=3;n[f]=t[m]=p,n[p]=t[f]=m,n[m]=t[p]=f,r[f]=0,r[p]=1,r[m]=2,i.fill(-1),i[this._hashKey(h,g)]=f,i[this._hashKey(_,v)]=p,i[this._hashKey(b,x)]=m,this.trianglesLen=0,this._addTriangle(f,p,m,-1,-1,-1);for(let a=0,o=0,s=0;a<this._ids.length;a++){let c=this._ids[a],l=e[2*c],u=e[2*c+1];if(a>0&&Math.abs(l-o)<=Wu&&Math.abs(u-s)<=Wu||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e<this._hashSize&&(d=i[(t+e)%this._hashSize],!(d!==-1&&d!==n[d]));e++);d=t[d];let h=d,g;for(;g=n[h],Uu(l,u,e[2*h],e[2*h+1],e[2*g],e[2*g+1])>=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],Uu(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],Uu(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e<C;e++)this.hull[e]=t,t=n[t];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(qu(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){let{_triangles:t,_halfedges:n,coords:r}=this,i=0,a=0;for(;;){let o=n[e],s=e-e%3;if(a=s+(e+2)%3,o===-1){if(i===0)break;e=Gu[--i];continue}let c=o-o%3,l=s+(e+1)%3,u=c+(o+2)%3,d=t[a],f=t[e],p=t[l],m=t[u];if(Yu(r[2*d],r[2*d+1],r[2*f],r[2*f+1],r[2*p],r[2*p+1],r[2*m],r[2*m+1])){t[e]=m,t[o]=d;let r=n[u];if(r===-1){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(o,n[a]),this._link(a,u);let s=c+(o+1)%3;i<Gu.length&&(Gu[i++]=s)}else{if(i===0)break;e=Gu[--i]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,r,i,a){let o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,a),this.trianglesLen+=3,o}};function qu(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Ju(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function Yu(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function Xu(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function Zu(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function Qu(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;$u(e,i,a),t[e[n]]>t[e[r]]&&$u(e,n,r),t[e[a]]>t[e[r]]&&$u(e,a,r),t[e[n]]>t[e[a]]&&$u(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]<c);do o--;while(t[e[o]]>c);if(o<a)break;$u(e,a,o)}e[n+1]=e[o],e[o]=s,r-a+1>=o-n?(Qu(e,t,a,r),Qu(e,t,n,o-1)):(Qu(e,t,n,o-1),Qu(e,t,a,r))}}function $u(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function ed(e){return e[0]}function td(e){return e[1]}function nd(e,t){var n,r,i=0,a,o,s,c,l,u,d,f=e[0],p=e[1],m=t.length;for(n=0;n<m;n++){r=0;var h=t[n],g=h.length-1;if(u=h[0],u[0]!==h[g][0]&&u[1]!==h[g][1])throw Error(`First and last coordinates in a ring must be the same`);for(o=u[0]-f,s=u[1]-p;r<g;r++){if(d=h[r+1],c=d[0]-f,l=d[1]-p,s===0&&l===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(a=Uu(o,c,s,l,0,0),a===0)return 0;(a>0&&l>0&&s<=0||a<0&&l<=0&&s>0)&&i++}u=d,s=l,o=c}}return i%2!=0}function rd(e){if(!e)throw Error(`coord is required`);if(!Array.isArray(e)){if(e.type===`Feature`&&e.geometry!==null&&e.geometry.type===`Point`)return[...e.geometry.coordinates];if(e.type===`Point`)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw Error(`coord must be GeoJSON Point or an Array of numbers`)}function id(e){return e.type===`Feature`?e.geometry:e}function ad(e,t,n={}){if(!e)throw Error(`point is required`);if(!t)throw Error(`polygon is required`);let r=rd(e),i=id(t),a=i.type,o=t.bbox,s=i.coordinates;if(o&&od(r,o)===!1)return!1;a===`Polygon`&&(s=[s]);let c=!1;for(var l=0;l<s.length;++l){let e=nd(r,s[l]);if(e===0)return!n.ignoreBoundary;e&&(c=!0)}return c}function od(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}var sd=ad,cd=1e-6,ld=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>cd||Math.abs(this._y1-i)>cd)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},ud=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}},dd=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r<c;r+=3,s+=2){let c=n[r]*2,d=n[r+1]*2,f=n[r+2]*2,p=e[c],m=e[c+1],h=e[d],g=e[d+1],_=e[f],v=e[f+1],y=h-p,b=g-m,x=_-p,S=v-m,C=(y*S-b*x)*2;if(Math.abs(C)<1e-9){if(i===void 0){i=a=0;for(let n of t)i+=e[n*2],a+=e[n*2+1];i/=t.length,a/=t.length}let n=1e9*Math.sign((i-p)*S-(a-m)*x);l=(p+_)/2-n*S,u=(m+v)/2+n*x}else{let e=1/C,t=y*y+b*b,n=x*x+S*S;l=p+(S*t-b*n)*e,u=m+(y*n-x*t)*e}o[s]=l,o[s+1]=u}let s=t[t.length-1],c,l=s*4,u,d=e[2*s],f,p=e[2*s+1];r.fill(0);for(let n=0;n<t.length;++n)s=t[n],c=l,u=d,f=p,l=s*4,d=e[2*s],p=e[2*s+1],r[c+2]=r[l]=f-p,r[c+3]=r[l+1]=d-u}render(e){let t=e==null?e=new ld:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:a,vectors:o}=this;if(i.length<=1)return null;for(let t=0,r=n.length;t<r;++t){let r=n[t];if(r<t)continue;let i=Math.floor(t/3)*2,o=Math.floor(r/3)*2,s=a[i],c=a[i+1],l=a[o],u=a[o+1];this._renderSegment(s,c,l,u,e)}let s,c=i[i.length-1];for(let t=0;t<i.length;++t){s=c,c=i[t];let n=Math.floor(r[c]/3)*2,l=a[n],u=a[n+1],d=s*4,f=this._project(l,u,o[d+2],o[d+3]);f&&this._renderSegment(l,u,f[0],f[1],e)}return t&&t.value()}renderBounds(e){let t=e==null?e=new ld:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){let n=t==null?t=new ld:void 0,r=this._clip(e);if(r===null||!r.length)return;t.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let e=2;e<i;e+=2)(r[e]!==r[e-2]||r[e+1]!==r[e-1])&&t.lineTo(r[e],r[e+1]);return t.closePath(),n&&n.value()}*cellPolygons(){let{delaunay:{points:e}}=this;for(let t=0,n=e.length/2;t<n;++t){let e=this.cellPolygon(t);e&&(e.index=t,yield e)}}cellPolygon(e){let t=new ud;return this.renderCell(e,t),t.value()}_renderSegment(e,t,n,r,i){let a,o=this._regioncode(e,t),s=this._regioncode(n,r);o===0&&s===0?(i.moveTo(e,t),i.lineTo(n,r)):(a=this._clipSegment(e,t,n,r,o,s))&&(i.moveTo(a[0],a[1]),i.lineTo(a[2],a[3]))}contains(e,t,n){return(t=+t,t!==t)||(n=+n,n!==n)?!1:this.delaunay._step(e,t,n)===e}*neighbors(e){let t=this._clip(e);if(t)for(let n of this.delaunay.neighbors(e)){let e=this._clip(n);if(e){loop:for(let r=0,i=t.length;r<i;r+=2)for(let a=0,o=e.length;a<o;a+=2)if(t[r]===e[a]&&t[r+1]===e[a+1]&&t[(r+2)%i]===e[(a+o-2)%o]&&t[(r+3)%i]===e[(a+o-1)%o]){yield n;break loop}}}}_cell(e){let{circumcenters:t,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,a=n[e];if(a===-1)return null;let o=[],s=a;do{let n=Math.floor(s/3);if(o.push(t[n*2],t[n*2+1]),s=s%3==2?s-2:s+1,i[s]!==e)break;s=r[s]}while(s!==a&&s!==-1);return o}_clip(e){if(e===0&&this.delaunay.hull.length===1)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];let t=this._cell(e);if(t===null)return null;let{vectors:n}=this,r=e*4;return this._simplify(n[r]||n[r+1]?this._clipInfinite(e,t,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(e,t))}_clipFinite(e,t){let n=t.length,r=null,i,a,o=t[n-2],s=t[n-1],c,l=this._regioncode(o,s),u,d=0;for(let f=0;f<n;f+=2)if(i=o,a=s,o=t[f],s=t[f+1],c=l,l=this._regioncode(o,s),c===0&&l===0)u=d,d=0,r?r.push(o,s):r=[o,s];else{let t,n,f,p,m;if(c===0){if((t=this._clipSegment(i,a,o,s,c,l))===null)continue;[n,f,p,m]=t}else{if((t=this._clipSegment(o,s,i,a,l,c))===null)continue;[p,m,n,f]=t,u=d,d=this._edgecode(n,f),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(n,f):r=[n,f]}u=d,d=this._edgecode(p,m),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(p,m):r=[p,m]}if(r)u=d,d=this._edgecode(r[0],r[1]),u&&d&&this._edge(e,u,d,r,r.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return r}_clipSegment(e,t,n,r,i,a){let o=i<a;for(o&&([e,t,n,r,i,a]=[n,r,e,t,a,i]);;){if(i===0&&a===0)return o?[n,r,e,t]:[e,t,n,r];if(i&a)return null;let s,c,l=i||a;l&8?(s=e+(n-e)*(this.ymax-t)/(r-t),c=this.ymax):l&4?(s=e+(n-e)*(this.ymin-t)/(r-t),c=this.ymin):l&2?(c=t+(r-t)*(this.xmax-e)/(n-e),s=this.xmax):(c=t+(r-t)*(this.xmin-e)/(n-e),s=this.xmin),i?(e=s,t=c,i=this._regioncode(e,t)):(n=s,r=c,a=this._regioncode(n,r))}}_clipInfinite(e,t,n,r,i,a){let o=Array.from(t),s;if((s=this._project(o[0],o[1],n,r))&&o.unshift(s[0],s[1]),(s=this._project(o[o.length-2],o[o.length-1],i,a))&&o.push(s[0],s[1]),o=this._clipFinite(e,o))for(let t=0,n=o.length,r,i=this._edgecode(o[n-2],o[n-1]);t<n;t+=2)r=i,i=this._edgecode(o[t],o[t+1]),r&&i&&(t=this._edge(e,r,i,o,t),n=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,n,r,i){for(;t!==n;){let n,a;switch(t){case 5:t=4;continue;case 4:t=6,n=this.xmax,a=this.ymin;break;case 6:t=2;continue;case 2:t=10,n=this.xmax,a=this.ymax;break;case 10:t=8;continue;case 8:t=9,n=this.xmin,a=this.ymax;break;case 9:t=1;continue;case 1:t=5,n=this.xmin,a=this.ymin;break}(r[i]!==n||r[i+1]!==a)&&this.contains(e,n,a)&&(r.splice(i,0,n,a),i+=2)}return i}_project(e,t,n,r){let i=1/0,a,o,s;if(r<0){if(t<=this.ymin)return null;(a=(this.ymin-t)/r)<i&&(s=this.ymin,o=e+(i=a)*n)}else if(r>0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)<i&&(s=this.ymax,o=e+(i=a)*n)}if(n>0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)<i&&(o=this.xmax,s=t+(i=a)*r)}else if(n<0){if(e<=this.xmin)return null;(a=(this.xmin-e)/n)<i&&(o=this.xmin,s=t+(i=a)*r)}return[o,s]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t<e.length;t+=2){let n=(t+2)%e.length,r=(t+4)%e.length;(e[t]===e[n]&&e[n]===e[r]||e[t+1]===e[n+1]&&e[n+1]===e[r+1])&&(e.splice(n,2),t-=2)}e.length||(e=null)}return e}},fd=2*Math.PI,pd=Math.pow;function md(e){return e[0]}function hd(e){return e[1]}function gd(e){let{triangles:t,coords:n}=e;for(let e=0;e<t.length;e+=3){let r=2*t[e],i=2*t[e+1],a=2*t[e+2];if((n[a]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[a+1]-n[r+1])>1e-10)return!1}return!0}function _d(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}var vd=class e{static from(t,n=md,r=hd,i){return new e(`length`in t?yd(t,n,r,i):Float64Array.from(bd(t,n,r,i)))}constructor(e){this._delaunator=new Ku(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&gd(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e<n;++e){let n=_d(t[2*e],t[2*e+1],i);t[2*e]=n[0],t[2*e+1]=n[1]}this._delaunator=new Ku(t)}else delete this.collinear;let n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let e=0,t=n.length;e<t;++e){let t=i[e%3==2?e-2:e+1];(n[e]===-1||a[t]===-1)&&(a[t]=e)}for(let e=0,t=r.length;e<t;++e)o[r[e]]=e;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new dd(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t<o.length-1&&(yield o[t+1]);return}let s=t[e];if(s===-1)return;let c=s,l=-1;do{if(yield l=a[c],c=c%3==2?c-2:c+1,a[c]!==e)return;if(c=i[c],c===-1){let t=n[(r[e]+1)%n.length];t!==l&&(yield t);return}}while(c!==s)}find(e,t,n=0){if((e=+e,e!==e)||(t=+t,t!==t))return-1;let r=n,i;for(;(i=this._step(n,e,t))>=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=pd(t-c[e*2],2)+pd(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=pd(t-c[r*2],2)+pd(n-c[r*2+1],2);if(d<u&&(u=d,l=r),f=f%3==2?f-2:f+1,s[f]!==e)break;if(f=o[f],f===-1){if(f=i[(a[e]+1)%i.length],f!==r&&pd(t-c[f*2],2)+pd(n-c[f*2+1],2)<u)return f;break}}while(f!==d);return l}render(e){let t=e==null?e=new ld:void 0,{points:n,halfedges:r,triangles:i}=this;for(let t=0,a=r.length;t<a;++t){let a=r[t];if(a<t)continue;let o=i[t]*2,s=i[a]*2;e.moveTo(n[o],n[o+1]),e.lineTo(n[s],n[s+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){t===void 0&&(!e||typeof e.moveTo!=`function`)&&(t=e,e=null),t=t==null?2:+t;let n=e==null?e=new ld:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){let i=r[n],a=r[n+1];e.moveTo(i+t,a),e.arc(i,a,t,0,fd)}return n&&n.value()}renderHull(e){let t=e==null?e=new ld:void 0,{hull:n,points:r}=this,i=n[0]*2,a=n.length;e.moveTo(r[i],r[i+1]);for(let t=1;t<a;++t){let i=2*n[t];e.lineTo(r[i],r[i+1])}return e.closePath(),t&&t.value()}hullPolygon(){let e=new ud;return this.renderHull(e),e.value()}renderTriangle(e,t){let n=t==null?t=new ld:void 0,{points:r,triangles:i}=this,a=i[e*=3]*2,o=i[e+1]*2,s=i[e+2]*2;return t.moveTo(r[a],r[a+1]),t.lineTo(r[o],r[o+1]),t.lineTo(r[s],r[s+1]),t.closePath(),n&&n.value()}*trianglePolygons(){let{triangles:e}=this;for(let t=0,n=e.length/3;t<n;++t)yield this.trianglePolygon(t)}trianglePolygon(e){let t=new ud;return this.renderTriangle(e,t),t.value()}};function yd(e,t,n,r){let i=e.length,a=new Float64Array(i*2);for(let o=0;o<i;++o){let i=e[o];a[o*2]=t.call(r,i,o,e),a[o*2+1]=n.call(r,i,o,e)}return a}function*bd(e,t,n,r){let i=0;for(let a of e)yield t.call(r,a,i,e),yield n.call(r,a,i,e),++i}var xd=Math.PI,Sd=xd/2;xd/4,xd*2;var Cd=180/xd,wd=xd/180,Td=Math.atan2,Ed=Math.cos,Dd=Math.max,Od=Math.min,kd=Math.sin,Ad=Math.sign||function(e){return e>0?1:e<0?-1:0},jd=Math.sqrt;function Md(e){return e>1?Sd:e<-1?-Sd:Math.asin(e)}function Nd(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Pd(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Fd(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function Id(e){var t=jd(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]}function Ld(e){return[Td(e[1],e[0])*Cd,Md(Dd(-1,Od(1,e[2])))*Cd]}function Rd(e){let t=e[0]*wd,n=e[1]*wd,r=Ed(n);return[r*Ed(t),r*kd(t),kd(n)]}function zd(e){return e=e.map(e=>Rd(e)),Nd(e[0],Pd(e[2],e[1]))}function Bd(e){let t=Hd(e),n=Wd(t),r=Ud(n,e),i=Kd(n,e.length),a=Vd(i,e),{polygons:o,centers:s}=qd(Gd(n,e),n,e);return{delaunay:t,edges:r,triangles:n,centers:s,neighbors:i,polygons:o,mesh:Yd(o),hull:Zd(n,e),urquhart:Xd(r,n),find:a}}function Vd(e,t){function n(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}return function(r,i,a){a===void 0&&(a=0);let o,s,c=a,l=Rd([r,i]);do o=a,a=null,s=n(l,Rd(t[o])),e[o].forEach(e=>{let r=n(l,Rd(t[e]));if(r<s){s=r,a=e,c=e;return}});while(a!==null);return c}}function Hd(e){if(e.length<2)return{};let t=0;for(;isNaN(e[t][0]+e[t][1])&&t++<e.length;);let n=ya(e[t]),r=Uo().translate([0,0]).scale(1).rotate(n.invert([180,0]));e=e.map(r);let i=[],a=1;for(let t=0,n=e.length;t<n;t++){let n=e[t][0]**2+e[t][1]**2;!isFinite(n)||n>1e32?i.push(t):n>a&&(a=n)}let o=1e6*jd(a);i.forEach(t=>e[t]=[o,0]),e.push([0,o]),e.push([-o,0]),e.push([0,-o]);let s=vd.from(e);s.projection=r;let{triangles:c,halfedges:l,inedges:u}=s,d=[];for(let n=0,r=l.length;n<r;n++)if(l[n]<0){let e=n%3==2?n-2:n+1,r=n%3==0?n+2:n-1,i=l[e],a=l[r];l[i]=a,l[a]=i,l[e]=l[r]=-1,c[n]=c[e]=c[r]=t,u[c[i]]=i%3==0?i+2:i-1,u[c[a]]=a%3==0?a+2:a-1,d.push(Math.min(n,e,r)),n+=2-n%3}else c[n]>e.length-3-1&&(c[n]=t);return s}function Ud(e,t){let n=new Set;return t.length===2?[[0,1]]:(e.forEach(e=>{if(e[0]!==e[1]&&!(zd(e.map(e=>t[e]))<0))for(let t=0,r;t<3;t++)r=(t+1)%3,n.add(vt([e[t],e[r]]).join(`-`))}),Array.from(n,e=>e.split(`-`).map(Number)))}function Wd(e){let{triangles:t}=e;if(!t)return[];let n=[];for(let e=0,r=t.length/3;e<r;e++){let r=t[3*e],i=t[3*e+1],a=t[3*e+2];r!==i&&i!==a&&n.push([r,a,i])}return n}function Gd(e,t){return e.map(e=>{let n=e.map(e=>t[e]).map(Rd);return Ld(Id(Fd(Fd(Pd(n[1],n[0]),Pd(n[2],n[1])),Pd(n[0],n[2]))))})}function Kd(e,t){let n=[];return e.forEach(e=>{for(let t=0;t<3;t++){let r=e[t],i=e[(t+1)%3];n[r]=n[r]||[],n[r].push(i)}}),e.length===0&&(t===2?(n[0]=[1],n[1]=[0]):t===1&&(n[0]=[])),n}function qd(e,t,n){let r=[],i=e.slice();if(t.length===0){if(n.length<2)return{polygons:r,centers:i};if(n.length===2){let e=Rd(n[0]),t=Rd(n[1]),a=Id(Fd(e,t)),s=Pd(a,Id(Pd(e,t))),c=[a,Pd(a,s),Pd(Pd(a,s),s),Pd(Pd(Pd(a,s),s),s)].map(Ld).map(o);return r.push(c),r.push(c.slice().reverse()),{polygons:r,centers:i}}}t.forEach((e,t)=>{for(let n=0;n<3;n++){let i=e[n],a=e[(n+1)%3],o=e[(n+2)%3];r[i]=r[i]||[],r[i].push([a,o,t,[i,a,o]])}});let a=r.map(e=>{let t=[e[0][2]],r=e[0][1];for(let n=1;n<e.length;n++)for(let n=0;n<e.length;n++)if(e[n][0]==r){r=e[n][1],t.push(e[n][2]);break}if(t.length>2)return t;if(t.length==2){let r=Jd(n[e[0][3][0]],n[e[0][3][1]],i[t[0]]),a=Jd(n[e[0][3][2]],n[e[0][3][0]],i[t[0]]),s=o(r),c=o(a);return[t[0],c,t[1],s]}});function o(e){let n=-1;return i.slice(t.length,1/0).forEach((r,i)=>{r[0]===e[0]&&r[1]===e[1]&&(n=i+t.length)}),n<0&&(n=i.length,i.push(e)),n}return{polygons:a,centers:i}}function Jd(e,t,n){e=Rd(e),t=Rd(t),n=Rd(n);let r=Ad(Nd(Pd(t,e),n));return Ld(Id(Fd(e,t)).map(e=>r*e))}function Yd(e){let t=[];return e.forEach(e=>{if(!e)return;let n=e[e.length-1];for(let r of e)r>n&&t.push([n,r]),n=r}),t}function Xd(e,t){return function(n){let r=new Map,i=new Map;return e.forEach((e,t)=>{let a=e.join(`-`);r.set(a,n[t]),i.set(a,!0)}),t.forEach(e=>{let t=0,n=-1;for(let i=0;i<3;i++){let a=vt([e[i],e[(i+1)%3]]).join(`-`);r.get(a)>t&&(t=r.get(a),n=a)}i.set(n,!1)}),e.map(e=>i.get(e.join(`-`)))}}function Zd(e,t){let n=new Set,r=[];e.map(e=>{if(!(zd(e.map(e=>t[e>t.length?0:e]))>1e-12))for(let t=0;t<3;t++){let r=[e[t],e[(t+1)%3]],i=`${r[0]}-${r[1]}`;n.has(i)?n.delete(i):n.add(`${r[1]}-${r[0]}`)}});let i=new Map,a;if(n.forEach(e=>{e=e.split(`-`).map(Number),i.set(e[0],e[1]),a=e[0]}),a===void 0)return r;let o=a;do{r.push(o);let e=i.get(o);i.set(o,-1),o=e}while(o>-1&&o!==a);return r}function Qd(e){let t=function(e){if(t.delaunay=null,t._data=e,typeof t._data==`object`&&t._data.type===`FeatureCollection`&&(t._data=t._data.features),typeof t._data==`object`){let e=t._data.map(e=>[t._vx(e),t._vy(e),e]).filter(e=>isFinite(e[0]+e[1]));t.points=e.map(e=>[e[0],e[1]]),t.valid=e.map(e=>e[2]),t.delaunay=Bd(t.points)}return t};return t._vx=function(e){if(typeof e==`object`&&`type`in e)return fa(e)[0];if(0 in e)return e[0]},t._vy=function(e){if(typeof e==`object`&&`type`in e)return fa(e)[1];if(1 in e)return e[1]},t.x=function(e){return e?(t._vx=e,t):t._vx},t.y=function(e){return e?(t._vy=e,t):t._vy},t.polygons=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n={type:`FeatureCollection`,features:[]};return t.valid.length===0?n:(t.delaunay.polygons.forEach((e,r)=>n.features.push({type:`Feature`,geometry:e?{type:`Polygon`,coordinates:[[...e,e[0]].map(e=>t.delaunay.centers[e])]}:null,properties:{site:t.valid[r],sitecoordinates:t.points[r],neighbours:t.delaunay.neighbors[r]}})),t.valid.length===1&&n.features.push({type:`Feature`,geometry:{type:`Sphere`},properties:{site:t.valid[0],sitecoordinates:t.points[0],neighbours:[]}}),n)},t.triangles=function(e){return e!==void 0&&t(e),t.delaunay?{type:`FeatureCollection`,features:t.delaunay.triangles.map((e,n)=>(e=e.map(e=>t.points[e]),e.center=t.delaunay.centers[n],e)).filter(e=>zd(e)>0).map(e=>({type:`Feature`,properties:{circumcenter:e.center},geometry:{type:`Polygon`,coordinates:[[...e,e[0]]]}}))}:!1},t.links=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let n=t.delaunay.edges.map(e=>$a(t.points[e[0]],t.points[e[1]])),r=t.delaunay.urquhart(n);return{type:`FeatureCollection`,features:t.delaunay.edges.map((e,i)=>({type:`Feature`,properties:{source:t.valid[e[0]],target:t.valid[e[1]],length:n[i],urquhart:!!r[i]},geometry:{type:`LineString`,coordinates:[t.points[e[0]],t.points[e[1]]]}}))}},t.mesh=function(e){return e!==void 0&&t(e),t.delaunay?{type:`MultiLineString`,coordinates:t.delaunay.edges.map(e=>[t.points[e[0]],t.points[e[1]]])}:!1},t.cellMesh=function(e){if(e!==void 0&&t(e),!t.delaunay)return!1;let{centers:n,polygons:r}=t.delaunay,i=[];for(let e of r)if(e)for(let t=e.length,r=e[t-1],a=e[0],o=0;o<t;r=a,a=e[++o])a>r&&i.push([n[r],n[a]]);return{type:`MultiLineString`,coordinates:i}},t._found=void 0,t.find=function(e,n,r){if(t._found=t.delaunay.find(e,n,t._found),!r||$a([e,n],t.points[t._found])<r)return t._found},t.hull=function(e){e!==void 0&&t(e);let n=t.delaunay.hull,r=t.points;return n.length===0?null:{type:`Polygon`,coordinates:[[...n.map(e=>r[e]),r[n[0]]]]}},e?t(e):t}function $d(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ef(e){if(Array.isArray(e))return e}function tf(e){if(Array.isArray(e))return $d(e)}function nf(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function rf(e,t,n){return t=sf(t),mf(e,lf()?Reflect.construct(t,[],sf(e).constructor):t.apply(e,n))}function af(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function of(e,t,n){return Object.defineProperty(e,`prototype`,{writable:!1}),e}function sf(e){return sf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},sf(e)}function cf(e,t){if(typeof t!=`function`&&t!==null)throw 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&&hf(e,t)}function lf(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lf=function(){return!!e})()}function uf(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function df(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function ff(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pf(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
11
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mf(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return nf(e)}function hf(e,t){return hf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},hf(e,t)}function gf(e,t){return ef(e)||df(e,t)||vf(e,t)||ff()}function _f(e){return tf(e)||uf(e)||vf(e)||pf()}function vf(e,t){if(e){if(typeof e==`string`)return $d(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$d(e,t):void 0}}function yf(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).resolution,n=t===void 0?1/0:t,r=bf(e,n),i=At(r),a=xf(e,n),o=[].concat(_f(i),_f(a)),s={type:`Polygon`,coordinates:e},c=gf(Ri(s),2),l=gf(c[0],2),u=l[0],d=l[1],f=gf(c[1],2),p=f[0],m=f[1],h=u>p||m>=89||d<=-89,g=[];if(h){var _=Qd(o).triangles(),v=new Map(o.map(function(e,t){var n=gf(e,2);return[`${n[0]}-${n[1]}`,t]}));_.features.forEach(function(e){var t,n=e.geometry.coordinates[0].slice(0,3).reverse(),r=[];if(n.forEach(function(e){var t=gf(e,2),n=`${t[0]}-${t[1]}`;v.has(n)&&r.push(v.get(n))}),r.length===3){if(r.some(function(e){return e<i.length})){var a=e.properties.circumcenter;if(!Cf(a,s,h))return}(t=g).push.apply(t,r)}})}else if(a.length){for(var y=Ku.from(o),b=function(e){var t,n=[2,1,0].map(function(t){return y.triangles[e+t]}),r=n.map(function(e){return o[e]});if(n.some(function(e){return e<i.length})&&!Cf([0,1].map(function(e){return Ot(r,function(t){return t[e]})}),s,h))return 1;(t=g).push.apply(t,_f(n))},x=0,S=y.triangles.length;x<S;x+=3)if(b(x))continue}else{var C=Tc(r),w=C.vertices,T=C.holes;g=Ks(w,T===void 0?[]:T,2)}var E=Cr(vt(o,function(e){return e[0]}),[0,1]),D=Cr(vt(o,function(e){return e[1]}),[0,1]),O=o.map(function(e){var t=gf(e,2),n=t[0],r=t[1];return[E(n),D(r)]});return{contour:r,triangles:{points:o,indices:g,uvs:O}}}function bf(e,t){return e.map(function(e){var n=[],r;return e.forEach(function(e){if(r){var i=$a(e,r)*180/Math.PI;if(i>t)for(var a=mo(r,e),o=1/Math.ceil(i/t),s=o;s<1;)n.push(a(s)),s+=o}n.push(r=e)}),n})}function xf(e,t){var n={type:`Polygon`,coordinates:e},r=gf(Ri(n),2),i=gf(r[0],2),a=i[0],o=i[1],s=gf(r[1],2),c=s[0],l=s[1];if(Math.min(Math.abs(c-a),Math.abs(l-o))<t)return[];var u=a>c||l>=89||o<=-89;return Sf(t,{minLng:a,maxLng:c,minLat:o,maxLat:l}).filter(function(e){return Cf(e,n,u)})}function Sf(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.minLng,r=t.maxLng,i=t.minLat,a=t.maxLat,o=Math.round((360/e)**2/Math.PI),s=(1+Math.sqrt(5))/2,c=function(e){return e/s*360%360-180},l=function(e){return Math.acos(2*e/o-1)/Math.PI*180-90},u=function(e){return o*(Math.cos((e+90)*Math.PI/180)+1)/2},d=[a===void 0?0:Math.ceil(u(a)),i===void 0?o-1:Math.floor(u(i))],f=n===void 0&&r===void 0?function(){return!0}:n===void 0?function(e){return e<=r}:r===void 0?function(e){return e>=n}:r>=n?function(e){return e>=n&&e<=r}:function(e){return e>=n||e<=r},p=[],m=d[0];m<=d[1];m++){var h=c(m);f(h)&&p.push([h,l(m)])}return p}function Cf(e,t){return arguments.length>2&&arguments[2]!==void 0&&arguments[2]?co(t,e):sd(e,t)}var wf=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,Float32BufferAttribute:i.Float32BufferAttribute},Tf=new wf.BufferGeometry().setAttribute?`setAttribute`:`addAttribute`,Ef=function(e){function t(e,n,r,i,a,o,s){var c;af(this,t),c=rf(this,t),c.type=`ConicPolygonGeometry`,c.parameters={polygonGeoJson:e,bottomHeight:n,topHeight:r,closedBottom:i,closedTop:a,includeSides:o,curvatureResolution:s},n||=0,r||=1,i=i===void 0?!0:i,a=a===void 0?!0:a,o=o===void 0?!0:o,s||=5;var l=yf(e,{resolution:s}),u=l.contour,d=l.triangles,f=At(d.uvs),p=[],m=[],h=[],g=0,_=function(e){var t=Math.round(p.length/3),n=h.length;p=p.concat(e.vertices),m=m.concat(e.uvs),h=h.concat(t?e.indices.map(function(e){return e+t}):e.indices),c.addGroup(n,h.length-n,g++)};o&&_(y()),i&&_(b(n,!1)),a&&_(b(r,!0)),c.setIndex(h),c[Tf](`position`,new wf.Float32BufferAttribute(p,3)),c[Tf](`uv`,new wf.Float32BufferAttribute(m,2)),c.computeVertexNormals();function v(e,t){var n=typeof t==`function`?t:function(){return t};return Tc(e.map(function(e){return e.map(function(e){var t=gf(e,2),r=t[0],i=t[1];return Df(i,r,n(r,i))})}))}function y(){for(var e=v(u,n),t=e.vertices,i=e.holes,a=v(u,r).vertices,o=At([a,t]),s=Math.round(a.length/3),c=new Set(i),l=0,d=[],f=0;f<s;f++){var p=f+1;if(p===s)p=l;else if(c.has(p)){var m=p;p=l,l=m}d.push(f,f+s,p+s),d.push(p+s,p,f)}for(var h=[],g=1;g>=0;g--)for(var _=0;_<s;_+=1)h.push(_/(s-1),g);return{indices:d,vertices:o,uvs:h}}function b(e){return{indices:!(arguments.length>1&&arguments[1]!==void 0)||arguments[1]?d.indices:d.indices.slice().reverse(),vertices:v([d.points],e).vertices,uvs:f}}return c}return cf(t,e),of(t)}(wf.BufferGeometry);function Df(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function Of(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function kf(e){if(Array.isArray(e))return e}function Af(e){if(Array.isArray(e))return Of(e)}function jf(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Mf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nf(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pf(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
13
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ff(e,t){if(e==null)return{};var n,r,i=If(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function If(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Lf(e,t){return kf(e)||Mf(e,t)||Vf(e,t)||Nf()}function Rf(e){return Af(e)||jf(e)||Vf(e)||Pf()}function zf(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function Bf(e){var t=zf(e,`string`);return typeof t==`symbol`?t:t+``}function Vf(e,t){if(e){if(typeof e==`string`)return Of(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Of(e,t):void 0}}var Hf=(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=(t instanceof Array?t.length?t:[void 0]:[t]).map(function(e){return{keyAccessor:e,isProp:!(e instanceof Function)}}),a=e.reduce(function(e,t){var r=e,a=t;return i.forEach(function(e,t){var o=e.keyAccessor,s=e.isProp,c;if(s){var l=a,u=l[o],d=Ff(l,[o].map(Bf));c=u,a=d}else c=o(a,t);t+1<i.length?(r.hasOwnProperty(c)||(r[c]={}),r=r[c]):n?(r.hasOwnProperty(c)||(r[c]=[]),r[c].push(a)):r[c]=a}),e},{});n instanceof Function&&(function e(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;r===i.length?Object.keys(t).forEach(function(e){return t[e]=n(t[e])}):Object.values(t).forEach(function(t){return e(t,r+1)})})(a);var o=a;return r&&(o=[],(function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];n.length===i.length?o.push({keys:n,vals:t}):Object.entries(t).forEach(function(t){var r=Lf(t,2),i=r[0],a=r[1];return e(a,[].concat(Rf(n),[i]))})})(a),t instanceof Array&&t.length===0&&o.length===1&&(o[0].keys=[])),o}),Uf=function(e){e||={};var t=e===void 0?{}:e,n={},r;for(r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);var i=[],a=``;function o(e){return t.locateFile?t.locateFile(e,a):a+e}var s;typeof document<`u`&&document.currentScript&&(a=document.currentScript.src),a=a.indexOf(`blob:`)===0?``:a.substr(0,a.lastIndexOf(`/`)+1),s=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response){t(r.response);return}var i=Ke(e);if(i){t(i.buffer);return}n()},r.onerror=n,r.send(null)};var c=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);n=null,t.arguments&&(i=t.arguments);var u=0,d=function(e){u=e},f=function(){return u},p=8;function m(e,t,n,r){switch(n||=`i8`,n.charAt(n.length-1)===`*`&&(n=`i32`),n){case`i1`:k[e>>0]=t;break;case`i8`:k[e>>0]=t;break;case`i16`:ee[e>>1]=t;break;case`i32`:j[e>>2]=t;break;case`i64`:je=[t>>>0,(Ae=t,+ve(Ae)>=1?Ae>0?(xe(+be(Ae/4294967296),4294967295)|0)>>>0:~~+ye((Ae-+(~~Ae>>>0))/4294967296)>>>0:0)],j[e>>2]=je[0],j[e+4>>2]=je[1];break;case`float`:te[e>>2]=t;break;case`double`:ne[e>>3]=t;break;default:rt(`invalid type for setValue: `+n)}}function h(e,t,n){switch(t||=`i8`,t.charAt(t.length-1)===`*`&&(t=`i32`),t){case`i1`:return k[e>>0];case`i8`:return k[e>>0];case`i16`:return ee[e>>1];case`i32`:return j[e>>2];case`i64`:return j[e>>2];case`float`:return te[e>>2];case`double`:return ne[e>>3];default:rt(`invalid type for getValue: `+t)}return null}var g=!1;function _(e,t){e||rt(`Assertion failed: `+t)}function v(e){var n=t[`_`+e];return _(n,`Cannot call unknown function `+e+`, make sure it is exported`),n}function y(e,t,n,r,i){var a={string:function(e){var t=0;if(e!=null&&e!==0){var n=(e.length<<2)+1;t=Je(n),T(e,t,n)}return t},array:function(e){var t=Je(e.length);return E(e,t),t}};function o(e){return t===`string`?C(e):t===`boolean`?!!e:e}var s=v(e),c=[],l=0;if(r)for(var u=0;u<r.length;u++){var d=a[n[u]];d?(l===0&&(l=Xe()),c[u]=d(r[u])):c[u]=r[u]}var f=s.apply(null,c);return f=o(f),l!==0&&Ye(l),f}function b(e,t,n,r){n||=[];var i=n.every(function(e){return e===`number`});return t!==`string`&&i&&!r?v(e):function(){return y(e,t,n,arguments,r)}}var x=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function S(e,t,n){for(var r=t+n,i=t;e[i]&&!(i>=r);)++i;if(i-t>16&&e.subarray&&x)return x.decode(e.subarray(t,i));for(var a=``;t<i;){var o=e[t++];if(!(o&128)){a+=String.fromCharCode(o);continue}var s=e[t++]&63;if((o&224)==192){a+=String.fromCharCode((o&31)<<6|s);continue}var c=e[t++]&63;if(o=(o&240)==224?(o&15)<<12|s<<6|c:(o&7)<<18|s<<12|c<<6|e[t++]&63,o<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|l&1023)}}return a}function C(e,t){return e?S(A,e,t):``}function w(e,t,n,r){if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343){var c=e.charCodeAt(++o);s=65536+((s&1023)<<10)|c&1023}if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63}}return t[n]=0,n-i}function T(e,t,n){return w(e,A,t,n)}typeof TextDecoder<`u`&&new TextDecoder(`utf-16le`);function E(e,t){k.set(e,t)}function D(e,t){return e%t>0&&(e+=t-e%t),e}var O,k,A,ee,j,te,ne;function re(e){O=e,t.HEAP8=k=new Int8Array(e),t.HEAP16=ee=new Int16Array(e),t.HEAP32=j=new Int32Array(e),t.HEAPU8=A=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=new Uint32Array(e),t.HEAPF32=te=new Float32Array(e),t.HEAPF64=ne=new Float64Array(e)}var ie=5271536,ae=28624,oe=t.TOTAL_MEMORY||33554432;O=t.buffer?t.buffer:new ArrayBuffer(oe),oe=O.byteLength,re(O),j[ae>>2]=ie;function se(e){for(;e.length>0;){var n=e.shift();if(typeof n==`function`){n();continue}var r=n.func;typeof r==`number`?n.arg===void 0?t.dynCall_v(r):t.dynCall_vi(r,n.arg):r(n.arg===void 0?null:n.arg)}}var ce=[],le=[],ue=[],de=[];function fe(){if(t.preRun)for(typeof t.preRun==`function`&&(t.preRun=[t.preRun]);t.preRun.length;)ge(t.preRun.shift());se(ce)}function pe(){se(le)}function me(){se(ue)}function he(){if(t.postRun)for(typeof t.postRun==`function`&&(t.postRun=[t.postRun]);t.postRun.length;)_e(t.postRun.shift());se(de)}function ge(e){ce.unshift(e)}function _e(e){de.unshift(e)}var ve=Math.abs,ye=Math.ceil,be=Math.floor,xe=Math.min,Se=0,Ce=null,we=null;function Te(e){Se++,t.monitorRunDependencies&&t.monitorRunDependencies(Se)}function Ee(e){if(Se--,t.monitorRunDependencies&&t.monitorRunDependencies(Se),Se==0&&(Ce!==null&&(clearInterval(Ce),Ce=null),we)){var n=we;we=null,n()}}t.preloadedImages={},t.preloadedAudios={};var De=null,Oe=`data:application/octet-stream;base64,`;function ke(e){return String.prototype.startsWith?e.startsWith(Oe):e.indexOf(Oe)===0}var Ae,je;De=`data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl`;var Me=28640;function Ne(e){return e}function Pe(e){return e.replace(/\b__Z[\w\d_]+/g,function(e){var t=Ne(e);return e===t?e:t+` [`+e+`]`})}function Fe(){var e=Error();if(!e.stack){try{throw Error(0)}catch(t){e=t}if(!e.stack)return`(no stack trace available)`}return e.stack.toString()}function Ie(){var e=Fe();return t.extraStackTrace&&(e+=`
|
|
14
|
+
`+t.extraStackTrace()),Pe(e)}function Le(e,t,n,r){rt(`Assertion failed: `+C(e)+`, at: `+[t?C(t):`unknown filename`,n,r?C(r):`unknown function`])}function Re(){return k.length}function ze(e,t,n){A.set(A.subarray(t,t+n),e)}function Be(e){return t.___errno_location&&(j[t.___errno_location()>>2]=e),e}function Ve(e){rt(`OOM`)}function He(e){try{var t=new ArrayBuffer(e);return t.byteLength==e?(new Int8Array(t).set(k),qe(t),re(t),1):void 0}catch{}}function Ue(e){var t=Re(),n=16777216,r=2147483648-n;if(e>r)return!1;for(var i=Math.max(t,16777216);i<e;)i=i<=536870912?D(2*i,n):Math.min(D((3*i+2147483648)/4,n),r);return!!He(i)}var We=typeof atob==`function`?atob:function(e){var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,n=``,r,i,a,o,s,c,l,u=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);do o=t.indexOf(e.charAt(u++)),s=t.indexOf(e.charAt(u++)),c=t.indexOf(e.charAt(u++)),l=t.indexOf(e.charAt(u++)),r=o<<2|s>>4,i=(s&15)<<4|c>>2,a=(c&3)<<6|l,n+=String.fromCharCode(r),c!==64&&(n+=String.fromCharCode(i)),l!==64&&(n+=String.fromCharCode(a));while(u<e.length);return n};function Ge(e){try{for(var t=We(e),n=new Uint8Array(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}catch{throw Error(`Converting base64 string to bytes failed.`)}}function Ke(e){if(ke(e))return Ge(e.slice(Oe.length))}var M=(function(e,t,n){"almost asm";var r=new e.Int8Array(n),i=new e.Int32Array(n);new e.Uint8Array(n),new e.Float32Array(n);var a=new e.Float64Array(n),o=t.o|0,s=t.p|0,c=e.Math.floor,l=e.Math.abs,u=e.Math.sqrt,d=e.Math.pow,f=e.Math.cos,p=e.Math.sin,m=e.Math.tan,h=e.Math.acos,g=e.Math.asin,_=e.Math.atan,v=e.Math.atan2,y=e.Math.ceil,b=e.Math.imul,x=e.Math.min,S=e.Math.max,C=e.Math.clz32,w=t.b,T=t.c,E=t.d,D=t.e,O=t.f,k=t.g,A=t.h,ee=t.i,j=28656;function te(e){return r=new Int8Array(e),new Uint8Array(e),i=new Int32Array(e),new Float32Array(e),a=new Float64Array(e),n=e,!0}function ne(e){e|=0;var t=0;return t=j,j=j+e|0,j=j+15&-16,t|0}function re(){return j|0}function ie(e){e|=0,j=e}function ae(e,t){e|=0,t|=0,j=e}function oe(e,t){e|=0,t|=0;var n=0,r=0,a=0;return(e|0)<0?(t=2,t|0):(e|0)>13780509?(t=An(15,t)|0,t|0):(n=((e|0)<0)<<31>>31,a=qr(e|0,n|0,3,0)|0,r=T()|0,n=Vr(e|0,n|0,1,0)|0,n=qr(a|0,r|0,n|0,T()|0)|0,n=Vr(n|0,T()|0,1,0)|0,e=T()|0,i[t>>2]=n,i[t+4>>2]=e,t=0,t|0)}function se(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,ce(e,t,n,r,0)|0}function ce(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0;if(l=j,j=j+16|0,s=l,!(le(e,t,n,r,a)|0))return r=0,j=l,r|0;do if((n|0)>=0){if((n|0)>13780509){if(o=An(15,s)|0,o|0)break;c=s,s=i[c>>2]|0,c=i[c+4>>2]|0}else o=((n|0)<0)<<31>>31,u=qr(n|0,o|0,3,0)|0,c=T()|0,o=Vr(n|0,o|0,1,0)|0,o=qr(u|0,c|0,o|0,T()|0)|0,o=Vr(o|0,T()|0,1,0)|0,c=T()|0,i[s>>2]=o,i[s+4>>2]=c,s=o;if(ni(r|0,0,s<<3|0)|0,a|0){ni(a|0,0,s<<2|0)|0,o=ue(e,t,n,r,a,s,c,0)|0;break}o=Br(s,4)|0,o?(u=ue(e,t,n,r,o,s,c,0)|0,N(o),o=u):o=13}else o=2;while(0);return u=o,j=l,u|0}function le(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=j,j=j+16|0,m=g,h=g+8|0,p=m,i[p>>2]=e,i[p+4>>2]=t,(n|0)<0)return h=2,j=g,h|0;if(o=r,i[o>>2]=e,i[o+4>>2]=t,o=(a|0)!=0,o&&(i[a>>2]=0),Ht(e,t)|0)return h=9,j=g,h|0;i[h>>2]=0;a:do if((n|0)>=1)if(o)for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=de(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,Ht(o,t)|0){o=9;break a}}if(o=de(o,t,i[26800+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,i[a+(d<<2)>>2]=p,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,Ht(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else for(d=1,u=0,f=0,p=1,o=e;;){if(!(u|f)){if(o=de(o,t,4,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,Ht(o,t)|0){o=9;break a}}if(o=de(o,t,i[26800+(f<<2)>>2]|0,h,m)|0,o|0)break a;if(t=m,o=i[t>>2]|0,t=i[t+4>>2]|0,e=r+(d<<3)|0,i[e>>2]=o,i[e+4>>2]=t,e=u+1|0,s=(e|0)==(p|0),c=f+1|0,l=(c|0)==6,Ht(o,t)|0){o=9;break a}if(p=p+(l&s&1)|0,(p|0)>(n|0)){o=0;break}else d=d+1|0,u=s?0:e,f=s?l?0:c:f}else o=0;while(0);return h=o,j=g,h|0}function ue(e,t,n,r,a,o,s,c){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=j,j=j+16|0,m=g+8|0,h=g,l=Yr(e|0,t|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,_=f,v=i[_>>2]|0,_=i[_+4>>2]|0,u=(v|0)==(e|0)&(_|0)==(t|0),!((v|0)==0&(_|0)==0|u))do l=Vr(l|0,d|0,1,0)|0,l=Jr(l|0,T()|0,o|0,s|0)|0,d=T()|0,f=r+(l<<3)|0,v=f,_=i[v>>2]|0,v=i[v+4>>2]|0,u=(_|0)==(e|0)&(v|0)==(t|0);while(!((_|0)==0&(v|0)==0|u));if(l=a+(l<<2)|0,u&&(i[l>>2]|0)<=(c|0)||(v=f,i[v>>2]=e,i[v+4>>2]=t,i[l>>2]=c,(c|0)>=(n|0)))return v=0,j=g,v|0;switch(u=c+1|0,i[m>>2]=0,l=de(e,t,2,m,h)|0,l|0){case 9:p=9;break;case 0:l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l||(p=9);break;default:}a:do if((p|0)==9){switch(i[m>>2]=0,l=de(e,t,3,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=de(e,t,1,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=de(e,t,5,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=de(e,t,4,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}switch(i[m>>2]=0,l=de(e,t,6,m,h)|0,l|0){case 9:break;case 0:if(l=h,l=ue(i[l>>2]|0,i[l+4>>2]|0,n,r,a,o,s,u)|0,l|0)break a;break;default:break a}return v=0,j=g,v|0}while(0);return v=l,j=g,v|0}function de(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(n>>>0>6)return a=1,a|0;if(f=(i[r>>2]|0)%6|0,i[r>>2]=f,(f|0)>0){o=0;do n=at(n)|0,o=o+1|0;while((o|0)<(i[r>>2]|0))}if(f=P(e|0,t|0,45)|0,T()|0,d=f&127,d>>>0>121)return a=5,a|0;l=Xt(e,t)|0,o=P(e|0,t|0,52)|0,T()|0,o&=15;a:do if(!o)u=8;else{for(;;){if(s=(15-o|0)*3|0,c=P(e|0,t|0,s|0)|0,T()|0,c&=7,(c|0)==7){t=5;break}if(h=(nn(o)|0)==0,o=o+-1|0,p=F(7,0,s|0)|0,t&=~(T()|0),m=F(i[(h?432:16)+(c*28|0)+(n<<2)>>2]|0,0,s|0)|0,s=T()|0,n=i[(h?640:224)+(c*28|0)+(n<<2)>>2]|0,e=m|e&~p,t=s|t,!n){n=0;break a}if(!o){u=8;break a}}return t|0}while(0);(u|0)==8&&(h=i[848+(d*28|0)+(n<<2)>>2]|0,m=F(h|0,0,45)|0,e=m|e,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+(n<<2)>>2]|0,(h&127|0)==127&&(h=F(i[848+(d*28|0)+20>>2]|0,0,45)|0,t=T()|0|t&-1040385,n=i[4272+(d*28|0)+20>>2]|0,e=Qt(h|e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1)),c=P(e|0,t|0,45)|0,T()|0,c&=127;b:do if(xe(c)|0){c:do if((Xt(e,t)|0)==1){if((d|0)!=(c|0))if(De(c,i[7696+(d*28|0)>>2]|0)|0){e=en(e,t)|0,s=1,t=T()|0;break}else E(27795,26864,533,26872);switch(l|0){case 3:e=Qt(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+1,s=0;break c;case 5:e=en(e,t)|0,t=T()|0,i[r>>2]=(i[r>>2]|0)+5,s=0;break c;case 0:return h=9,h|0;default:return h=1,h|0}}else s=0;while(0);if((n|0)>0){o=0;do e=Zt(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}if((d|0)!=(c|0)){if(!(Se(c)|0)){if((s|0)!=0|(Xt(e,t)|0)!=5)break;i[r>>2]=(i[r>>2]|0)+1;break}switch(f&127){case 8:case 118:break b;default:}(Xt(e,t)|0)!=3&&(i[r>>2]=(i[r>>2]|0)+1)}}else if((n|0)>0){o=0;do e=Qt(e,t)|0,t=T()|0,o=o+1|0;while((o|0)!=(n|0))}while(0);return i[r>>2]=((i[r>>2]|0)+n|0)%6|0,h=a,i[h>>2]=e,i[h+4>>2]=t,h=0,h|0}function fe(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,pe(e,t,n,r)|0?(ni(r|0,0,n*48|0)|0,r=me(e,t,n,r)|0,r|0):(r=0,r|0)}function pe(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=j,j=j+16|0,p=h,m=h+8|0,f=p,i[f>>2]=e,i[f+4>>2]=t,(n|0)<0)return m=2,j=h,m|0;if(!n)return m=r,i[m>>2]=e,i[m+4>>2]=t,m=0,j=h,m|0;i[m>>2]=0;a:do if(Ht(e,t)|0)e=9;else{a=0,f=e;do{if(e=de(f,t,4,m,p)|0,e|0)break a;if(t=p,f=i[t>>2]|0,t=i[t+4>>2]|0,a=a+1|0,Ht(f,t)|0){e=9;break a}}while((a|0)<(n|0));d=r,i[d>>2]=f,i[d+4>>2]=t,d=n+-1|0,u=0,e=1;do{if(a=26800+(u<<2)|0,(u|0)==5)for(s=i[a>>2]|0,o=0,a=e;;){if(e=p,e=de(i[e>>2]|0,i[e+4>>2]|0,s,m,p)|0,e|0)break a;if((o|0)!=(d|0))if(l=p,c=i[l>>2]|0,l=i[l+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=c,i[e+4>>2]=l,!(Ht(c,l)|0))e=a+1|0;else{e=9;break a}else e=a;if(o=o+1|0,(o|0)>=(n|0))break;a=e}else for(s=p,l=i[a>>2]|0,c=0,a=e,o=i[s>>2]|0,s=i[s+4>>2]|0;;){if(e=de(o,s,l,m,p)|0,e|0)break a;if(s=p,o=i[s>>2]|0,s=i[s+4>>2]|0,e=r+(a<<3)|0,i[e>>2]=o,i[e+4>>2]=s,e=a+1|0,Ht(o,s)|0){e=9;break a}if(c=c+1|0,(c|0)>=(n|0))break;a=e}u=u+1|0}while(u>>>0<6);e=p,e=(f|0)==(i[e>>2]|0)&&(t|0)==(i[e+4>>2]|0)?0:9}while(0);return m=e,j=h,m|0}function me(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;if(f=j,j=j+16|0,s=f,!n)return i[r>>2]=e,i[r+4>>2]=t,r=0,j=f,r|0;do if((n|0)>=0){if((n|0)>13780509){if(a=An(15,s)|0,a|0)break;o=s,a=i[o>>2]|0,o=i[o+4>>2]|0}else a=((n|0)<0)<<31>>31,d=qr(n|0,a|0,3,0)|0,o=T()|0,a=Vr(n|0,a|0,1,0)|0,a=qr(d|0,o|0,a|0,T()|0)|0,a=Vr(a|0,T()|0,1,0)|0,o=T()|0,d=s,i[d>>2]=a,i[d+4>>2]=o;if(u=Br(a,8)|0,!u)a=13;else{if(d=Br(a,4)|0,!d){N(u),a=13;break}if(a=ue(e,t,n,u,d,a,o,0)|0,a|0){N(u),N(d);break}if(t=i[s>>2]|0,s=i[s+4>>2]|0,(s|0)>0|(s|0)==0&t>>>0>0){a=0,c=0,l=0;do e=u+(c<<3)|0,o=i[e>>2]|0,e=i[e+4>>2]|0,!((o|0)==0&(e|0)==0)&&(i[d+(c<<2)>>2]|0)==(n|0)&&(p=r+(a<<3)|0,i[p>>2]=o,i[p+4>>2]=e,a=a+1|0),c=Vr(c|0,l|0,1,0)|0,l=T()|0;while((l|0)<(s|0)|(l|0)==(s|0)&c>>>0<t>>>0)}N(u),N(d),a=0}}else a=2;while(0);return p=a,j=f,p|0}function he(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;for(c=j,j=j+16|0,o=c,s=c+8|0,a=(Ht(e,t)|0)==0,a=a?1:2;;){if(i[s>>2]=0,u=(de(e,t,a,s,o)|0)==0,l=o,u&((i[l>>2]|0)==(n|0)?(i[l+4>>2]|0)==(r|0):0)){e=4;break}if(a=a+1|0,a>>>0>=7){a=7,e=4;break}}return(e|0)==4?(j=c,a|0):0}function ge(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;if(c=j,j=j+48|0,a=c+16|0,o=c+8|0,s=c,n=ar(n)|0,n|0)return s=n,j=c,s|0;if(u=e,l=i[u+4>>2]|0,n=o,i[n>>2]=i[u>>2],i[n+4>>2]=l,ir(o,a),n=Be(a,t,s)|0,!n){if(t=i[o>>2]|0,o=i[e+8>>2]|0,(o|0)>0){a=i[e+12>>2]|0,n=0;do t=(i[a+(n<<3)>>2]|0)+t|0,n=n+1|0;while((n|0)<(o|0))}n=s,a=i[n>>2]|0,n=i[n+4>>2]|0,o=((t|0)<0)<<31>>31,(n|0)<(o|0)|(n|0)==(o|0)&a>>>0<t>>>0?(n=s,i[n>>2]=t,i[n+4>>2]=o,n=o):t=a,l=Vr(t|0,n|0,12,0)|0,u=T()|0,n=s,i[n>>2]=l,i[n+4>>2]=u,n=r,i[n>>2]=l,i[n+4>>2]=u,n=0}return u=n,j=c,u|0}function _e(e,t,n,r,o,s,c){e|=0,t|=0,n|=0,r|=0,o|=0,s|=0,c|=0;var l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,ee=0,te=0,ne=0,re=0,ie=0,ae=0,oe=0,se=0;if(re=j,j=j+64|0,A=re+48|0,ee=re+32|0,te=re+24|0,C=re+8|0,w=re,u=i[e>>2]|0,(u|0)<=0)return ne=0,j=re,ne|0;for(E=e+4|0,D=A+8|0,O=ee+8|0,k=C+8|0,l=0,x=0;;){d=i[E>>2]|0,b=d+(x<<4)|0,i[A>>2]=i[b>>2],i[A+4>>2]=i[b+4>>2],i[A+8>>2]=i[b+8>>2],i[A+12>>2]=i[b+12>>2],(x|0)==(u+-1|0)?(i[ee>>2]=i[d>>2],i[ee+4>>2]=i[d+4>>2],i[ee+8>>2]=i[d+8>>2],i[ee+12>>2]=i[d+12>>2]):(b=d+(x+1<<4)|0,i[ee>>2]=i[b>>2],i[ee+4>>2]=i[b+4>>2],i[ee+8>>2]=i[b+8>>2],i[ee+12>>2]=i[b+12>>2]),u=Ve(A,ee,r,te)|0;a:do if(u)d=0,l=u;else if(u=te,d=i[u>>2]|0,u=i[u+4>>2]|0,(u|0)>0|(u|0)==0&d>>>0>0){y=0,b=0;b:for(;;){if(ae=1/(+(d>>>0)+4294967296*(u|0)),se=+a[A>>3],u=Hr(d|0,u|0,y|0,b|0)|0,oe=+(u>>>0)+4294967296*(T()|0),ie=+(y>>>0)+4294967296*(b|0),a[C>>3]=se*oe*ae+ae*(+a[ee>>3]*ie),a[k>>3]=ae*(+a[D>>3]*oe)+ae*(+a[O>>3]*ie),u=rn(C,r,w)|0,u|0){l=u;break}v=w,_=i[v>>2]|0,v=i[v+4>>2]|0,m=Yr(_|0,v|0,t|0,n|0)|0,f=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0;c:do if((d|0)==0&(p|0)==0)S=u,ne=16;else for(h=0,g=0;;){if((h|0)>(n|0)|(h|0)==(n|0)&g>>>0>t>>>0){l=1;break b}if((d|0)==(_|0)&(p|0)==(v|0))break c;if(u=Vr(m|0,f|0,1,0)|0,m=Jr(u|0,T()|0,t|0,n|0)|0,f=T()|0,g=Vr(g|0,h|0,1,0)|0,h=T()|0,u=c+(m<<3)|0,p=u,d=i[p>>2]|0,p=i[p+4>>2]|0,(d|0)==0&(p|0)==0){S=u,ne=16;break}}while(0);if((ne|0)==16&&(ne=0,!((_|0)==0&(v|0)==0))&&(g=S,i[g>>2]=_,i[g+4>>2]=v,g=s+(i[o>>2]<<3)|0,i[g>>2]=_,i[g+4>>2]=v,g=o,g=Vr(i[g>>2]|0,i[g+4>>2]|0,1,0)|0,_=T()|0,v=o,i[v>>2]=g,i[v+4>>2]=_),y=Vr(y|0,b|0,1,0)|0,b=T()|0,u=te,d=i[u>>2]|0,u=i[u+4>>2]|0,!((u|0)>(b|0)|(u|0)==(b|0)&d>>>0>y>>>0)){d=1;break a}}d=0}else d=1;while(0);if(x=x+1|0,!d){ne=21;break}if(u=i[e>>2]|0,(x|0)>=(u|0)){l=0,ne=21;break}}return(ne|0)==21?(j=re,l|0):0}function ve(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,E=0,D=0,O=0,k=0,A=0,ee=0,te=0,ne=0,re=0,ie=0,ae=0;if(ae=j,j=j+112|0,te=ae+80|0,l=ae+72|0,ne=ae,re=ae+56|0,a=ar(n)|0,a|0)return ie=a,j=ae,ie|0;if(u=e+8|0,ie=zr((i[u>>2]<<5)+32|0)|0,!ie)return ie=13,j=ae,ie|0;if(or(e,ie),a=ar(n)|0,!a){if(A=e,ee=i[A+4>>2]|0,a=l,i[a>>2]=i[A>>2],i[a+4>>2]=ee,ir(l,te),a=Be(te,t,ne)|0,a)A=0,ee=0;else{if(a=i[l>>2]|0,o=i[u>>2]|0,(o|0)>0){s=i[e+12>>2]|0,n=0;do a=(i[s+(n<<3)>>2]|0)+a|0,n=n+1|0;while((n|0)!=(o|0));n=a}else n=a;a=ne,o=i[a>>2]|0,a=i[a+4>>2]|0,s=((n|0)<0)<<31>>31,(a|0)<(s|0)|(a|0)==(s|0)&o>>>0<n>>>0?(a=ne,i[a>>2]=n,i[a+4>>2]=s,a=s):n=o,A=Vr(n|0,a|0,12,0)|0,ee=T()|0,a=ne,i[a>>2]=A,i[a+4>>2]=ee,a=0}if(!a){if(n=Br(A,8)|0,!n)return N(ie),ie=13,j=ae,ie|0;if(c=Br(A,8)|0,!c)return N(ie),N(n),ie=13,j=ae,ie|0;O=te,i[O>>2]=0,i[O+4>>2]=0,O=e,k=i[O+4>>2]|0,a=l,i[a>>2]=i[O>>2],i[a+4>>2]=k,a=_e(l,A,ee,t,te,n,c)|0;a:do if(a)N(n),N(c),N(ie);else{b:do if((i[u>>2]|0)>0){for(s=e+12|0,o=0;a=_e((i[s>>2]|0)+(o<<3)|0,A,ee,t,te,n,c)|0,o=o+1|0,!(a|0);)if((o|0)>=(i[u>>2]|0))break b;N(n),N(c),N(ie);break a}while(0);(ee|0)>0|(ee|0)==0&A>>>0>0&&ni(c|0,0,A<<3|0)|0,k=te,O=i[k+4>>2]|0;c:do if((O|0)>0|(O|0)==0&(i[k>>2]|0)>>>0>0){w=n,E=c,D=n,O=c,k=n,a=n,x=n,S=c,C=c,n=c;d:for(;;){for(_=0,v=0,y=0,b=0,o=0,s=0;;){c=ne,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));if(t=w+(_<<3)|0,u=i[t>>2]|0,t=i[t+4>>2]|0,le(u,t,1,ne,0)|0){c=ne,l=c+56|0;do i[c>>2]=0,c=c+4|0;while((c|0)<(l|0));c=Br(7,4)|0,c|0&&(ue(u,t,1,ne,c,7,0,0)|0,N(c))}for(g=0;;){h=ne+(g<<3)|0,m=i[h>>2]|0,h=i[h+4>>2]|0;e:do if((m|0)==0&(h|0)==0)c=o,l=s;else{if(d=Yr(m|0,h|0,A|0,ee|0)|0,u=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0,!((l|0)==0&(t|0)==0)){f=0,p=0;do{if((f|0)>(ee|0)|(f|0)==(ee|0)&p>>>0>A>>>0)break d;if((l|0)==(m|0)&(t|0)==(h|0)){c=o,l=s;break e}c=Vr(d|0,u|0,1,0)|0,d=Jr(c|0,T()|0,A|0,ee|0)|0,u=T()|0,p=Vr(p|0,f|0,1,0)|0,f=T()|0,c=r+(d<<3)|0,t=c,l=i[t>>2]|0,t=i[t+4>>2]|0}while(!((l|0)==0&(t|0)==0))}if((m|0)==0&(h|0)==0){c=o,l=s;break}sn(m,h,re)|0,sr(e,ie,re)|0&&(p=Vr(o|0,s|0,1,0)|0,s=T()|0,f=c,i[f>>2]=m,i[f+4>>2]=h,o=E+(o<<3)|0,i[o>>2]=m,i[o+4>>2]=h,o=p),c=o,l=s}while(0);if(g=g+1|0,g>>>0>=7)break;o=c,s=l}if(_=Vr(_|0,v|0,1,0)|0,v=T()|0,y=Vr(y|0,b|0,1,0)|0,b=T()|0,s=te,o=i[s>>2]|0,s=i[s+4>>2]|0,(b|0)<(s|0)|(b|0)==(s|0)&y>>>0<o>>>0)o=c,s=l;else break}if((s|0)>0|(s|0)==0&o>>>0>0){o=0,s=0;do b=w+(o<<3)|0,i[b>>2]=0,i[b+4>>2]=0,o=Vr(o|0,s|0,1,0)|0,s=T()|0,b=te,y=i[b+4>>2]|0;while((s|0)<(y|0)|((s|0)==(y|0)?o>>>0<(i[b>>2]|0)>>>0:0))}if(b=te,i[b>>2]=c,i[b+4>>2]=l,(l|0)>0|(l|0)==0&c>>>0>0)g=n,_=C,v=k,y=S,b=E,n=x,C=a,S=D,x=g,a=_,k=O,O=v,D=y,E=w,w=b;else break c}N(D),N(O),N(ie),a=1;break a}else a=c;while(0);N(ie),N(n),N(a),a=0}while(0);return ie=a,j=ae,ie|0}}return N(ie),ie=a,j=ae,ie|0}function ye(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(d=j,j=j+176|0,l=d,(t|0)<1)return Ar(n,0,0),u=0,j=d,u|0;for(c=e,c=P(i[c>>2]|0,i[c+4>>2]|0,52)|0,T()|0,Ar(n,(t|0)>6?t:6,c&15),c=0;r=e+(c<<3)|0,r=cn(i[r>>2]|0,i[r+4>>2]|0,l)|0,!(r|0);){if(r=i[l>>2]|0,(r|0)>0){s=0;do o=l+8+(s<<4)|0,s=s+1|0,r=l+8+(((s|0)%(r|0)|0)<<4)|0,a=Fr(n,r,o)|0,a?Nr(n,a)|0:Pr(n,o,r)|0,r=i[l>>2]|0;while((s|0)<(r|0))}if(c=c+1|0,(c|0)>=(t|0)){r=0,u=13;break}}return(u|0)==13?(j=d,r|0):(jr(n),u=r,j=d,u|0)}function be(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;if(o=j,j=j+32|0,r=o,a=o+16|0,e=ye(e,t,a)|0,e|0)return n=e,j=o,n|0;if(i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,e=Mr(a)|0,e|0)do{t=Rn(n)|0;do zn(t,e)|0,s=e+16|0,i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],i[r+8>>2]=i[s+8>>2],i[r+12>>2]=i[s+12>>2],Nr(a,e)|0,e=Ir(a,r)|0;while(e|0);e=Mr(a)|0}while(e|0);return jr(a),e=Vn(n)|0,e?(Bn(n),s=e,j=o,s|0):(s=0,j=o,s|0)}function xe(e){return e|=0,e>>>0>121?(e=0,e|0):(e=i[7696+(e*28|0)+16>>2]|0,e|0)}function Se(e){return e|=0,(e|0)==4|(e|0)==117|0}function Ce(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)>>2]|0}function we(e){return e|=0,i[11120+((i[e>>2]|0)*216|0)+((i[e+4>>2]|0)*72|0)+((i[e+8>>2]|0)*24|0)+(i[e+12>>2]<<3)+4>>2]|0}function Te(e,t){e|=0,t|=0,e=7696+(e*28|0)|0,i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2]}function Ee(e,t){e|=0,t|=0;var n=0,r=0;if(t>>>0>20)return t=-1,t|0;do if((i[11120+(t*216|0)>>2]|0)!=(e|0))if((i[11120+(t*216|0)+8>>2]|0)!=(e|0))if((i[11120+(t*216|0)+16>>2]|0)!=(e|0))if((i[11120+(t*216|0)+24>>2]|0)!=(e|0))if((i[11120+(t*216|0)+32>>2]|0)!=(e|0))if((i[11120+(t*216|0)+40>>2]|0)!=(e|0))if((i[11120+(t*216|0)+48>>2]|0)!=(e|0))if((i[11120+(t*216|0)+56>>2]|0)!=(e|0))if((i[11120+(t*216|0)+64>>2]|0)!=(e|0))if((i[11120+(t*216|0)+72>>2]|0)!=(e|0))if((i[11120+(t*216|0)+80>>2]|0)!=(e|0))if((i[11120+(t*216|0)+88>>2]|0)!=(e|0))if((i[11120+(t*216|0)+96>>2]|0)!=(e|0))if((i[11120+(t*216|0)+104>>2]|0)!=(e|0))if((i[11120+(t*216|0)+112>>2]|0)!=(e|0))if((i[11120+(t*216|0)+120>>2]|0)!=(e|0))if((i[11120+(t*216|0)+128>>2]|0)!=(e|0))if((i[11120+(t*216|0)+136>>2]|0)==(e|0))e=2,n=1,r=2;else{if((i[11120+(t*216|0)+144>>2]|0)==(e|0)){e=0,n=2,r=0;break}if((i[11120+(t*216|0)+152>>2]|0)==(e|0)){e=0,n=2,r=1;break}if((i[11120+(t*216|0)+160>>2]|0)==(e|0)){e=0,n=2,r=2;break}if((i[11120+(t*216|0)+168>>2]|0)==(e|0)){e=1,n=2,r=0;break}if((i[11120+(t*216|0)+176>>2]|0)==(e|0)){e=1,n=2,r=1;break}if((i[11120+(t*216|0)+184>>2]|0)==(e|0)){e=1,n=2,r=2;break}if((i[11120+(t*216|0)+192>>2]|0)==(e|0)){e=2,n=2,r=0;break}if((i[11120+(t*216|0)+200>>2]|0)==(e|0)){e=2,n=2,r=1;break}if((i[11120+(t*216|0)+208>>2]|0)==(e|0)){e=2,n=2,r=2;break}else e=-1;return e|0}else e=2,n=1,r=1;else e=2,n=1,r=0;else e=1,n=1,r=2;else e=1,n=1,r=1;else e=1,n=1,r=0;else e=0,n=1,r=2;else e=0,n=1,r=1;else e=0,n=1,r=0;else e=2,n=0,r=2;else e=2,n=0,r=1;else e=2,n=0,r=0;else e=1,n=0,r=2;else e=1,n=0,r=1;else e=1,n=0,r=0;else e=0,n=0,r=2;else e=0,n=0,r=1;else e=0,n=0,r=0;while(0);return t=i[11120+(t*216|0)+(n*72|0)+(e*24|0)+(r<<3)+4>>2]|0,t|0}function De(e,t){return e|=0,t|=0,(i[7696+(e*28|0)+20>>2]|0)==(t|0)?(t=1,t|0):(t=(i[7696+(e*28|0)+24>>2]|0)==(t|0),t|0)}function Oe(e,t){return e|=0,t|=0,i[848+(e*28|0)+(t<<2)>>2]|0}function ke(e,t){return e|=0,t|=0,(i[848+(e*28|0)>>2]|0)==(t|0)?(t=0,t|0):(i[848+(e*28|0)+4>>2]|0)==(t|0)?(t=1,t|0):(i[848+(e*28|0)+8>>2]|0)==(t|0)?(t=2,t|0):(i[848+(e*28|0)+12>>2]|0)==(t|0)?(t=3,t|0):(i[848+(e*28|0)+16>>2]|0)==(t|0)?(t=4,t|0):(i[848+(e*28|0)+20>>2]|0)==(t|0)?(t=5,t|0):((i[848+(e*28|0)+24>>2]|0)==(t|0)?6:7)|0}function Ae(){return 122}function je(e){e|=0;var t=0,n=0,r=0;t=0;do F(t|0,0,45)|0,r=T()|134225919,n=e+(t<<3)|0,i[n>>2]=-1,i[n+4>>2]=r,t=t+1|0;while((t|0)!=122);return 0}function Me(e){e|=0;var t=0,n=0,r=0;return r=+a[e+16>>3],n=+a[e+24>>3],t=r-n,+(r<n?t+6.283185307179586:t)}function Ne(e){return e|=0,+a[e+16>>3]<+a[e+24>>3]|0}function Pe(e){return e|=0,+(a[e>>3]-+a[e+8>>3])}function Fe(e,t){e|=0,t|=0;var n=0,r=0,i=0;return n=+a[t>>3],!(n>=+a[e+8>>3])||!(n<=+a[e>>3])?(t=0,t|0):(r=+a[e+16>>3],n=+a[e+24>>3],i=+a[t+8>>3],t=i>=n,e=i<=r&1,r<n?t&&(e=1):t||(e=0),t=(e|0)!=0,t|0)}function Ie(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;return+a[e>>3]<+a[t+8>>3]||+a[e+8>>3]>+a[t>>3]?(r=0,r|0):(o=+a[e+16>>3],n=e+24|0,d=+a[n>>3],s=o<d,r=t+16|0,u=+a[r>>3],i=t+24|0,l=+a[i>>3],c=u<l,t=d-u<l-o,e=s?c|t?1:2:0,t=c?s?1:t?2:1:0,o=+bn(o,e),o<+bn(+a[i>>3],t)||(d=+bn(+a[n>>3],e),d>+bn(+a[r>>3],t))?(c=0,c|0):(c=1,c|0))}function Le(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0;s=+a[e+16>>3],u=+a[e+24>>3],e=s<u,l=+a[t+16>>3],c=+a[t+24>>3],o=l<c,t=u-l<c-s,i[n>>2]=e?o|t?1:2:0,i[r>>2]=o?e?1:t?2:1:0}function Re(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;return+a[e>>3]<+a[t>>3]||+a[e+8>>3]>+a[t+8>>3]?(r=0,r|0):(r=e+16|0,l=+a[r>>3],o=+a[e+24>>3],s=l<o,n=t+16|0,d=+a[n>>3],i=t+24|0,u=+a[i>>3],c=d<u,t=o-d<u-l,e=s?c|t?1:2:0,t=c?s?1:t?2:1:0,o=+bn(o,e),o<=+bn(+a[i>>3],t)?(d=+bn(+a[r>>3],e),c=d>=+bn(+a[n>>3],t),c|0):(c=0,c|0))}function ze(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,l=0;o=j,j=j+176|0,r=o,i[r>>2]=4,l=+a[t>>3],a[r+8>>3]=l,s=+a[t+16>>3],a[r+16>>3]=s,a[r+24>>3]=l,l=+a[t+24>>3],a[r+32>>3]=l,c=+a[t+8>>3],a[r+40>>3]=c,a[r+48>>3]=l,a[r+56>>3]=c,a[r+64>>3]=s,t=r+72|0,n=t+96|0;do i[t>>2]=0,t=t+4|0;while((t|0)<(n|0));ti(e|0,r|0,168)|0,j=o}function Be(e,t,n){e|=0,t|=0,n|=0;var r=0,s=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,b=0,S=0,C=0;b=j,j=j+288|0,h=b+264|0,g=b+96|0,m=b,f=m,p=f+96|0;do i[f>>2]=0,f=f+4|0;while((f|0)<(p|0));return t=fn(t,m)|0,t|0?(v=t,j=b,v|0):(p=m,m=i[p>>2]|0,p=i[p+4>>2]|0,sn(m,p,h)|0,cn(m,p,g)|0,d=+Sn(h,g+8|0),a[h>>3]=+a[e>>3],p=h+8|0,a[p>>3]=+a[e+16>>3],a[g>>3]=+a[e+8>>3],m=g+8|0,a[m>>3]=+a[e+24>>3],s=+Sn(h,g),C=a[p>>3]-+a[m>>3],u=+l(+C),S=a[h>>3]-+a[g>>3],r=+l(+S),!(C==0|S==0)&&(C=+Qr(+u,+r),C=+y(+(s*s/+$r(+(C/+$r(+u,+r)),3)/(d*2.59807621135*d*.8))),a[o>>3]=C,_=~~C>>>0,v=+l(C)>=1?C>0?~~+x(+c(C/4294967296),4294967295)>>>0:~~+y((C-+(~~C>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)!=2146435072)?(g=(_|0)==0&(v|0)==0,t=n,i[t>>2]=g?1:_,i[t+4>>2]=g?0:v,t=0):t=1,v=t,j=b,v|0)}function Ve(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var s=0,u=0,d=0,f=0,p=0,m=0,h=0;m=j,j=j+288|0,d=m+264|0,f=m+96|0,p=m,s=p,u=s+96|0;do i[s>>2]=0,s=s+4|0;while((s|0)<(u|0));return n=fn(n,p)|0,n|0?(r=n,j=m,r|0):(n=p,s=i[n>>2]|0,n=i[n+4>>2]|0,sn(s,n,d)|0,cn(s,n,f)|0,h=+Sn(d,f+8|0),h=+y(+(Sn(e,t)/(h*2))),a[o>>3]=h,n=~~h>>>0,s=+l(h)>=1?h>0?~~+x(+c(h/4294967296),4294967295)>>>0:~~+y((h-+(~~h>>>0))/4294967296)>>>0:0,(i[o+4>>2]&2146435072|0)==2146435072?(r=1,j=m,r|0):(p=(n|0)==0&(s|0)==0,i[r>>2]=p?1:n,i[r+4>>2]=p?0:s,r=0,j=m,r|0))}function He(e,t){e|=0,t=+t;var n=0,r=0,i=0,o=0,s=0,c=0,l=0,u=0,d=0;o=e+16|0,s=+a[o>>3],n=e+24|0,i=+a[n>>3],r=s-i,r=s<i?r+6.283185307179586:r,u=+a[e>>3],c=e+8|0,l=+a[c>>3],d=u-l,r=(r*t-r)*.5,t=(d*t-d)*.5,u+=t,a[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=l-t,a[c>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=s+r,t=t>3.141592653589793?t+-6.283185307179586:t,a[o>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=i-r,t=t>3.141592653589793?t+-6.283185307179586:t,a[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}function Ue(e,t,n,r){e|=0,t|=0,n|=0,r|=0,i[e>>2]=t,i[e+4>>2]=n,i[e+8>>2]=r}function We(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0;m=t+8|0,i[m>>2]=0,d=+a[e>>3],c=+l(+d),f=+a[e+8>>3],u=l(+f)*1.1547005383792515,c+=u*.5,n=~~c,e=~~u,c-=+(n|0),u-=+(e|0);do if(c<.5)if(c<.3333333333333333)if(i[t>>2]=n,u<(c+1)*.5){i[t+4>>2]=e;break}else{e=e+1|0,i[t+4>>2]=e;break}else if(h=1-c,e=(!(u<h)&1)+e|0,i[t+4>>2]=e,h<=u&u<c*2){n=n+1|0,i[t>>2]=n;break}else{i[t>>2]=n;break}else{if(!(c<.6666666666666666))if(n=n+1|0,i[t>>2]=n,u<c*.5){i[t+4>>2]=e;break}else{e=e+1|0,i[t+4>>2]=e;break}if(u<1-c){if(i[t+4>>2]=e,c*2+-1<u){i[t>>2]=n;break}}else e=e+1|0,i[t+4>>2]=e;n=n+1|0,i[t>>2]=n}while(0);do if(d<0)if(e&1){p=(e+1|0)/2|0,p=Hr(n|0,((n|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,n=~~((n|0)-((+(p>>>0)+4294967296*(T()|0))*2+1)),i[t>>2]=n;break}else{p=(e|0)/2|0,p=Hr(n|0,((n|0)<0)<<31>>31|0,p|0,((p|0)<0)<<31>>31|0)|0,n=~~((n|0)-(+(p>>>0)+4294967296*(T()|0))*2),i[t>>2]=n;break}while(0);p=t+4|0,f<0&&(n=n-((e<<1|1)/2|0)|0,i[t>>2]=n,e=0-e|0,i[p>>2]=e),r=e-n|0,(n|0)<0?(o=0-n|0,i[p>>2]=r,i[m>>2]=o,i[t>>2]=0,e=r,n=0):o=0,(e|0)<0&&(n=n-e|0,i[t>>2]=n,o=o-e|0,i[m>>2]=o,i[p>>2]=0,e=0),s=n-o|0,r=e-o|0,(o|0)<0&&(i[t>>2]=s,i[p>>2]=r,i[m>>2]=0,e=r,n=s,o=0),r=(e|0)<(n|0)?e:n,r=(o|0)<(r|0)?o:r,!((r|0)<=0)&&(i[t>>2]=n-r,i[p>>2]=e-r,i[m>>2]=o-r)}function Ge(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0;t=i[e>>2]|0,s=e+4|0,n=i[s>>2]|0,(t|0)<0&&(n=n-t|0,i[s>>2]=n,o=e+8|0,i[o>>2]=(i[o>>2]|0)-t,i[e>>2]=0,t=0),(n|0)<0?(t=t-n|0,i[e>>2]=t,o=e+8|0,a=(i[o>>2]|0)-n|0,i[o>>2]=a,i[s>>2]=0,n=0):(a=e+8|0,o=a,a=i[a>>2]|0),(a|0)<0&&(t=t-a|0,i[e>>2]=t,n=n-a|0,i[s>>2]=n,i[o>>2]=0,a=0),r=(n|0)<(t|0)?n:t,r=(a|0)<(r|0)?a:r,!((r|0)<=0)&&(i[e>>2]=t-r,i[s>>2]=n-r,i[o>>2]=a-r)}function Ke(e,t){e|=0,t|=0;var n=0,r=0;r=i[e+8>>2]|0,n=+((i[e+4>>2]|0)-r|0),a[t>>3]=((i[e>>2]|0)-r|0)-n*.5,a[t+8>>3]=n*.8660254037844386}function M(e,t,n){e|=0,t|=0,n|=0,i[n>>2]=(i[t>>2]|0)+(i[e>>2]|0),i[n+4>>2]=(i[t+4>>2]|0)+(i[e+4>>2]|0),i[n+8>>2]=(i[t+8>>2]|0)+(i[e+8>>2]|0)}function qe(e,t,n){e|=0,t|=0,n|=0,i[n>>2]=(i[e>>2]|0)-(i[t>>2]|0),i[n+4>>2]=(i[e+4>>2]|0)-(i[t+4>>2]|0),i[n+8>>2]=(i[e+8>>2]|0)-(i[t+8>>2]|0)}function Je(e,t){e|=0,t|=0;var n=0,r=0;n=b(i[e>>2]|0,t)|0,i[e>>2]=n,n=e+4|0,r=b(i[n>>2]|0,t)|0,i[n>>2]=r,e=e+8|0,t=b(i[e>>2]|0,t)|0,i[e>>2]=t}function Ye(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;s=i[e>>2]|0,c=(s|0)<0,r=(i[e+4>>2]|0)-(c?s:0)|0,o=(r|0)<0,a=(o?0-r|0:0)+((i[e+8>>2]|0)-(c?s:0))|0,n=(a|0)<0,e=n?0:a,t=(o?0:r)-(n?a:0)|0,a=(c?0:s)-(o?r:0)-(n?a:0)|0,n=(t|0)<(a|0)?t:a,n=(e|0)<(n|0)?e:n,r=(n|0)>0,e=e-(r?n:0)|0,t=t-(r?n:0)|0;a:do switch(a-(r?n:0)|0){case 0:switch(t|0){case 0:return c=e|0?(e|0)==1?1:7:0,c|0;case 1:return c=e|0?(e|0)==1?3:7:2,c|0;default:break a}case 1:switch(t|0){case 0:return c=e|0?(e|0)==1?5:7:4,c|0;case 1:if(!e)e=6;else break a;return e|0;default:break a}default:}while(0);return c=7,c|0}function Xe(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(l=e+8|0,s=i[l>>2]|0,c=(i[e>>2]|0)-s|0,u=e+4|0,s=(i[u>>2]|0)-s|0,c>>>0>715827881|s>>>0>715827881){if(r=(c|0)>0,a=2147483647-c|0,o=-2147483648-c|0,(r?(a|0)<(c|0):(o|0)>(c|0))||(n=c<<1,r?(2147483647-n|0)<(c|0):(-2147483648-n|0)>(c|0))||((s|0)>0?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0))||(t=c*3|0,n=s<<1,(r?(a|0)<(n|0):(o|0)>(n|0))||((c|0)>-1?(t|-2147483648)>=(s|0):(t^-2147483648|0)<(s|0))))return u=1,u|0}else n=s<<1,t=c*3|0;return r=Rr((t-s|0)*.14285714285714285)|0,i[e>>2]=r,a=Rr((n+c|0)*.14285714285714285)|0,i[u>>2]=a,i[l>>2]=0,n=(a|0)<(r|0),t=n?r:a,n=n?a:r,(n|0)<0&&(((n|0)==-2147483648||((t|0)>0?(2147483647-t|0)<(n|0):(-2147483648-t|0)>(n|0)))&&E(27795,26892,354,26903),((t|0)>-1?(t|-2147483648)>=(n|0):(t^-2147483648|0)<(n|0))&&E(27795,26892,354,26903)),t=a-r|0,(r|0)<0?(n=0-r|0,i[u>>2]=t,i[l>>2]=n,i[e>>2]=0,r=0):(t=a,n=0),(t|0)<0&&(r=r-t|0,i[e>>2]=r,n=n-t|0,i[l>>2]=n,i[u>>2]=0,t=0),o=r-n|0,a=t-n|0,(n|0)<0?(i[e>>2]=o,i[u>>2]=a,i[l>>2]=0,t=a,a=o,n=0):a=r,r=(t|0)<(a|0)?t:a,r=(n|0)<(r|0)?n:r,(r|0)<=0?(u=0,u|0):(i[e>>2]=a-r,i[u>>2]=t-r,i[l>>2]=n-r,u=0,u|0)}function Ze(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(s=e+8|0,a=i[s>>2]|0,o=(i[e>>2]|0)-a|0,c=e+4|0,a=(i[c>>2]|0)-a|0,o>>>0>715827881|a>>>0>715827881){if(n=(o|0)>0,(n?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0))||(t=o<<1,r=(a|0)>0,r?(2147483647-a|0)<(a|0):(-2147483648-a|0)>(a|0)))return c=1,c|0;if(l=a<<1,(r?(2147483647-l|0)<(a|0):(-2147483648-l|0)>(a|0))||(n?(2147483647-t|0)<(a|0):(-2147483648-t|0)>(a|0))||(n=a*3|0,(a|0)>-1?(n|-2147483648)>=(o|0):(n^-2147483648|0)<(o|0)))return l=1,l|0}else n=a*3|0,t=o<<1;return r=Rr((t+a|0)*.14285714285714285)|0,i[e>>2]=r,a=Rr((n-o|0)*.14285714285714285)|0,i[c>>2]=a,i[s>>2]=0,n=(a|0)<(r|0),t=n?r:a,n=n?a:r,(n|0)<0&&(((n|0)==-2147483648||((t|0)>0?(2147483647-t|0)<(n|0):(-2147483648-t|0)>(n|0)))&&E(27795,26892,402,26917),((t|0)>-1?(t|-2147483648)>=(n|0):(t^-2147483648|0)<(n|0))&&E(27795,26892,402,26917)),t=a-r|0,(r|0)<0?(n=0-r|0,i[c>>2]=t,i[s>>2]=n,i[e>>2]=0,r=0):(t=a,n=0),(t|0)<0&&(r=r-t|0,i[e>>2]=r,n=n-t|0,i[s>>2]=n,i[c>>2]=0,t=0),o=r-n|0,a=t-n|0,(n|0)<0?(i[e>>2]=o,i[c>>2]=a,i[s>>2]=0,t=a,a=o,n=0):a=r,r=(t|0)<(a|0)?t:a,r=(n|0)<(r|0)?n:r,(r|0)<=0?(l=0,l|0):(i[e>>2]=a-r,i[c>>2]=t-r,i[s>>2]=n-r,l=0,l|0)}function Qe(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;s=e+8|0,n=i[s>>2]|0,t=(i[e>>2]|0)-n|0,c=e+4|0,n=(i[c>>2]|0)-n|0,r=Rr(((t*3|0)-n|0)*.14285714285714285)|0,i[e>>2]=r,t=Rr(((n<<1)+t|0)*.14285714285714285)|0,i[c>>2]=t,i[s>>2]=0,n=t-r|0,(r|0)<0?(o=0-r|0,i[c>>2]=n,i[s>>2]=o,i[e>>2]=0,t=n,r=0,n=o):n=0,(t|0)<0&&(r=r-t|0,i[e>>2]=r,n=n-t|0,i[s>>2]=n,i[c>>2]=0,t=0),o=r-n|0,a=t-n|0,(n|0)<0?(i[e>>2]=o,i[c>>2]=a,i[s>>2]=0,t=a,a=o,n=0):a=r,r=(t|0)<(a|0)?t:a,r=(n|0)<(r|0)?n:r,!((r|0)<=0)&&(i[e>>2]=a-r,i[c>>2]=t-r,i[s>>2]=n-r)}function $e(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;s=e+8|0,n=i[s>>2]|0,t=(i[e>>2]|0)-n|0,c=e+4|0,n=(i[c>>2]|0)-n|0,r=Rr(((t<<1)+n|0)*.14285714285714285)|0,i[e>>2]=r,t=Rr(((n*3|0)-t|0)*.14285714285714285)|0,i[c>>2]=t,i[s>>2]=0,n=t-r|0,(r|0)<0?(o=0-r|0,i[c>>2]=n,i[s>>2]=o,i[e>>2]=0,t=n,r=0,n=o):n=0,(t|0)<0&&(r=r-t|0,i[e>>2]=r,n=n-t|0,i[s>>2]=n,i[c>>2]=0,t=0),o=r-n|0,a=t-n|0,(n|0)<0?(i[e>>2]=o,i[c>>2]=a,i[s>>2]=0,t=a,a=o,n=0):a=r,r=(t|0)<(a|0)?t:a,r=(n|0)<(r|0)?n:r,!((r|0)<=0)&&(i[e>>2]=a-r,i[c>>2]=t-r,i[s>>2]=n-r)}function et(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;t=i[e>>2]|0,s=e+4|0,n=i[s>>2]|0,c=e+8|0,r=i[c>>2]|0,a=n+(t*3|0)|0,i[e>>2]=a,n=r+(n*3|0)|0,i[s>>2]=n,t=(r*3|0)+t|0,i[c>>2]=t,r=n-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=r,i[c>>2]=t,i[e>>2]=0,n=r,r=0):r=a,(n|0)<0&&(r=r-n|0,i[e>>2]=r,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=r-t|0,a=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=a,i[c>>2]=0,r=o,t=0):a=n,n=(a|0)<(r|0)?a:r,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=r-n,i[s>>2]=a-n,i[c>>2]=t-n)}function tt(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;a=i[e>>2]|0,s=e+4|0,t=i[s>>2]|0,c=e+8|0,n=i[c>>2]|0,r=(t*3|0)+a|0,a=n+(a*3|0)|0,i[e>>2]=a,i[s>>2]=r,t=(n*3|0)+t|0,i[c>>2]=t,n=r-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=n,i[c>>2]=t,i[e>>2]=0,a=0):n=r,(n|0)<0&&(a=a-n|0,i[e>>2]=a,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=a-t|0,r=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=r,i[c>>2]=0,a=o,t=0):r=n,n=(r|0)<(a|0)?r:a,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=a-n,i[s>>2]=r-n,i[c>>2]=t-n)}function nt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0;(t+-1|0)>>>0>=6||(a=(i[15440+(t*12|0)>>2]|0)+(i[e>>2]|0)|0,i[e>>2]=a,c=e+4|0,r=(i[15440+(t*12|0)+4>>2]|0)+(i[c>>2]|0)|0,i[c>>2]=r,s=e+8|0,t=(i[15440+(t*12|0)+8>>2]|0)+(i[s>>2]|0)|0,i[s>>2]=t,n=r-a|0,(a|0)<0?(t=t-a|0,i[c>>2]=n,i[s>>2]=t,i[e>>2]=0,r=0):(n=r,r=a),(n|0)<0&&(r=r-n|0,i[e>>2]=r,t=t-n|0,i[s>>2]=t,i[c>>2]=0,n=0),o=r-t|0,a=n-t|0,(t|0)<0?(i[e>>2]=o,i[c>>2]=a,i[s>>2]=0,r=o,t=0):a=n,n=(a|0)<(r|0)?a:r,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=r-n,i[c>>2]=a-n,i[s>>2]=t-n))}function rt(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;a=i[e>>2]|0,s=e+4|0,t=i[s>>2]|0,c=e+8|0,n=i[c>>2]|0,r=t+a|0,a=n+a|0,i[e>>2]=a,i[s>>2]=r,t=n+t|0,i[c>>2]=t,n=r-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=n,i[c>>2]=t,i[e>>2]=0,r=0):(n=r,r=a),(n|0)<0&&(r=r-n|0,i[e>>2]=r,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=r-t|0,a=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=a,i[c>>2]=0,r=o,t=0):a=n,n=(a|0)<(r|0)?a:r,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=r-n,i[s>>2]=a-n,i[c>>2]=t-n)}function it(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;t=i[e>>2]|0,s=e+4|0,r=i[s>>2]|0,c=e+8|0,n=i[c>>2]|0,a=r+t|0,i[e>>2]=a,r=n+r|0,i[s>>2]=r,t=n+t|0,i[c>>2]=t,n=r-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=n,i[c>>2]=t,i[e>>2]=0,r=0):(n=r,r=a),(n|0)<0&&(r=r-n|0,i[e>>2]=r,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=r-t|0,a=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=a,i[c>>2]=0,r=o,t=0):a=n,n=(a|0)<(r|0)?a:r,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=r-n,i[s>>2]=a-n,i[c>>2]=t-n)}function at(e){switch(e|=0,e|0){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1;break;default:}return e|0}function ot(e){switch(e|=0,e|0){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1;break;default:}return e|0}function st(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;t=i[e>>2]|0,s=e+4|0,n=i[s>>2]|0,c=e+8|0,r=i[c>>2]|0,a=n+(t<<1)|0,i[e>>2]=a,n=r+(n<<1)|0,i[s>>2]=n,t=(r<<1)+t|0,i[c>>2]=t,r=n-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=r,i[c>>2]=t,i[e>>2]=0,n=r,r=0):r=a,(n|0)<0&&(r=r-n|0,i[e>>2]=r,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=r-t|0,a=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=a,i[c>>2]=0,r=o,t=0):a=n,n=(a|0)<(r|0)?a:r,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=r-n,i[s>>2]=a-n,i[c>>2]=t-n)}function ct(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;a=i[e>>2]|0,s=e+4|0,t=i[s>>2]|0,c=e+8|0,n=i[c>>2]|0,r=(t<<1)+a|0,a=n+(a<<1)|0,i[e>>2]=a,i[s>>2]=r,t=(n<<1)+t|0,i[c>>2]=t,n=r-a|0,(a|0)<0?(t=t-a|0,i[s>>2]=n,i[c>>2]=t,i[e>>2]=0,a=0):n=r,(n|0)<0&&(a=a-n|0,i[e>>2]=a,t=t-n|0,i[c>>2]=t,i[s>>2]=0,n=0),o=a-t|0,r=n-t|0,(t|0)<0?(i[e>>2]=o,i[s>>2]=r,i[c>>2]=0,a=o,t=0):r=n,n=(r|0)<(a|0)?r:a,n=(t|0)<(n|0)?t:n,!((n|0)<=0)&&(i[e>>2]=a-n,i[s>>2]=r-n,i[c>>2]=t-n)}function lt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0;return s=(i[e>>2]|0)-(i[t>>2]|0)|0,c=(s|0)<0,r=(i[e+4>>2]|0)-(i[t+4>>2]|0)-(c?s:0)|0,o=(r|0)<0,a=(c?0-s|0:0)+(i[e+8>>2]|0)-(i[t+8>>2]|0)+(o?0-r|0:0)|0,e=(a|0)<0,t=e?0:a,n=(o?0:r)-(e?a:0)|0,a=(c?0:s)-(o?r:0)-(e?a:0)|0,e=(n|0)<(a|0)?n:a,e=(t|0)<(e|0)?t:e,r=(e|0)>0,t=t-(r?e:0)|0,n=n-(r?e:0)|0,e=a-(r?e:0)|0,e=(e|0)>-1?e:0-e|0,n=(n|0)>-1?n:0-n|0,t=(t|0)>-1?t:0-t|0,t=(n|0)>(t|0)?n:t,((e|0)>(t|0)?e:t)|0}function ut(e,t){e|=0,t|=0;var n=0;n=i[e+8>>2]|0,i[t>>2]=(i[e>>2]|0)-n,i[t+4>>2]=(i[e+4>>2]|0)-n}function dt(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0;return r=i[e>>2]|0,i[t>>2]=r,a=i[e+4>>2]|0,s=t+4|0,i[s>>2]=a,c=t+8|0,i[c>>2]=0,n=(a|0)<(r|0),e=n?r:a,n=n?a:r,(n|0)<0&&((n|0)==-2147483648||((e|0)>0?(2147483647-e|0)<(n|0):(-2147483648-e|0)>(n|0))||((e|0)>-1?(e|-2147483648)>=(n|0):(e^-2147483648|0)<(n|0)))?(t=1,t|0):(e=a-r|0,(r|0)<0?(n=0-r|0,i[s>>2]=e,i[c>>2]=n,i[t>>2]=0,r=0):(e=a,n=0),(e|0)<0&&(r=r-e|0,i[t>>2]=r,n=n-e|0,i[c>>2]=n,i[s>>2]=0,e=0),o=r-n|0,a=e-n|0,(n|0)<0?(i[t>>2]=o,i[s>>2]=a,i[c>>2]=0,e=a,a=o,n=0):a=r,r=(e|0)<(a|0)?e:a,r=(n|0)<(r|0)?n:r,(r|0)<=0?(t=0,t|0):(i[t>>2]=a-r,i[s>>2]=e-r,i[c>>2]=n-r,t=0,t|0))}function ft(e){e|=0;var t=0,n=0,r=0,a=0;t=e+8|0,a=i[t>>2]|0,n=a-(i[e>>2]|0)|0,i[e>>2]=n,r=e+4|0,e=(i[r>>2]|0)-a|0,i[r>>2]=e,i[t>>2]=0-(e+n)}function pt(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0;n=i[e>>2]|0,t=0-n|0,i[e>>2]=t,s=e+8|0,i[s>>2]=0,c=e+4|0,r=i[c>>2]|0,a=r+n|0,(n|0)>0?(i[c>>2]=a,i[s>>2]=n,i[e>>2]=0,t=0,r=a):n=0,(r|0)<0?(o=t-r|0,i[e>>2]=o,n=n-r|0,i[s>>2]=n,i[c>>2]=0,a=o-n|0,t=0-n|0,(n|0)<0?(i[e>>2]=a,i[c>>2]=t,i[s>>2]=0,r=t,n=0):(r=0,a=o)):a=t,t=(r|0)<(a|0)?r:a,t=(n|0)<(t|0)?n:t,!((t|0)<=0)&&(i[e>>2]=a-t,i[c>>2]=r-t,i[s>>2]=n-t)}function mt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;if(f=j,j=j+64|0,d=f,c=f+56|0,!(!0&(t&2013265920|0)==134217728&(!0&(r&2013265920|0)==134217728)))return a=5,j=f,a|0;if((e|0)==(n|0)&(t|0)==(r|0))return i[a>>2]=0,a=0,j=f,a|0;if(s=P(e|0,t|0,52)|0,T()|0,s&=15,u=P(n|0,r|0,52)|0,T()|0,(s|0)!=(u&15|0))return a=12,j=f,a|0;if(o=s+-1|0,s>>>0>1){Bt(e,t,o,d)|0,Bt(n,r,o,c)|0,u=d,l=i[u>>2]|0,u=i[u+4>>2]|0;a:do if((l|0)==(i[c>>2]|0)&&(u|0)==(i[c+4>>2]|0)){s=(s^15)*3|0,o=P(e|0,t|0,s|0)|0,T()|0,o&=7,s=P(n|0,r|0,s|0)|0,T()|0,s&=7;do if((o|0)==0|(s|0)==0)i[a>>2]=1,o=0;else if((o|0)==7)o=5;else{if((o|0)==1|(s|0)==1&&Ht(l,u)|0){o=5;break}if((i[15536+(o<<2)>>2]|0)!=(s|0)&&(i[15568+(o<<2)>>2]|0)!=(s|0))break a;i[a>>2]=1,o=0}while(0);return a=o,j=f,a|0}while(0)}o=d,s=o+56|0;do i[o>>2]=0,o=o+4|0;while((o|0)<(s|0));return se(e,t,1,d)|0,t=d,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0))&&(t=d+8|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+16|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+24|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+32|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))&&(t=d+40|0,!((i[t>>2]|0)==(n|0)&&(i[t+4>>2]|0)==(r|0)))?(o=d+48|0,o=((i[o>>2]|0)==(n|0)?(i[o+4>>2]|0)==(r|0):0)&1):o=1,i[a>>2]=o,a=0,j=f,a|0}function ht(e,t,n,r,a){return e|=0,t|=0,n|=0,r|=0,a|=0,n=he(e,t,n,r)|0,(n|0)==7?(a=11,a|0):(r=F(n|0,0,56)|0,t=t&-2130706433|T()|268435456,i[a>>2]=e|r,i[a+4>>2]=t,a=0,a|0)}function gt(e,t,n){return e|=0,t|=0,n|=0,!0&(t&2013265920|0)==268435456?(i[n>>2]=e,i[n+4>>2]=t&-2130706433|134217728,n=0,n|0):(n=6,n|0)}function _t(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return a=j,j=j+16|0,r=a,i[r>>2]=0,!0&(t&2013265920|0)==268435456?(o=P(e|0,t|0,56)|0,T()|0,r=de(e,t&-2130706433|134217728,o&7,r,n)|0,j=a,r|0):(r=6,j=a,r|0)}function vt(e,t){e|=0,t|=0;var n=0;switch(n=P(e|0,t|0,56)|0,T()|0,n&7){case 0:case 7:return n=0,n|0;default:}return n=t&-2130706433|134217728,!(!0&(t&2013265920|0)==268435456)||!0&(t&117440512|0)==16777216&(Ht(e,n)|0)!=0?(n=0,n|0):(n=Lt(e,n)|0,n|0)}function yt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return a=j,j=j+16|0,r=a,!0&(t&2013265920|0)==268435456?(o=t&-2130706433|134217728,s=n,i[s>>2]=e,i[s+4>>2]=o,i[r>>2]=0,t=P(e|0,t|0,56)|0,T()|0,r=de(e,o,t&7,r,n+8|0)|0,j=a,r|0):(r=6,j=a,r|0)}function bt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0;return a=(Ht(e,t)|0)==0,t&=-2130706433,r=n,i[r>>2]=a?e:0,i[r+4>>2]=a?t|285212672:0,r=n+8|0,i[r>>2]=e,i[r+4>>2]=t|301989888,r=n+16|0,i[r>>2]=e,i[r+4>>2]=t|318767104,r=n+24|0,i[r>>2]=e,i[r+4>>2]=t|335544320,r=n+32|0,i[r>>2]=e,i[r+4>>2]=t|352321536,n=n+40|0,i[n>>2]=e,i[n+4>>2]=t|369098752,0}function xt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;return s=j,j=j+16|0,a=s,o=t&-2130706433|134217728,!0&(t&2013265920|0)==268435456?(r=P(e|0,t|0,56)|0,T()|0,r=wr(e,o,r&7)|0,(r|0)==-1?(i[n>>2]=0,o=6,j=s,o|0):(on(e,o,a)|0&&E(27795,26932,282,26947),t=P(e|0,t|0,52)|0,T()|0,t&=15,Ht(e,o)|0?Dt(a,t,r,2,n):jt(a,t,r,2,n),o=0,j=s,o|0)):(o=6,j=s,o|0)}function St(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0;r=j,j=j+16|0,i=r,Ct(e,t,n,i),We(i,n+4|0),j=r}function Ct(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0;if(l=j,j=j+16|0,u=l,wt(e,n,u),s=+h(+(1-a[u>>3]*.5)),s<1e-16){i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,i[r+12>>2]=0,j=l;return}if(u=i[n>>2]|0,o=+a[15920+(u*24|0)>>3],o=+vn(o-+vn(+wn(15600+(u<<4)|0,e))),c=nn(t)|0?+vn(o+-.3334731722518321):o,o=m(+s)*2.618033988749896,(t|0)>0){e=0;do o*=2.6457513110645907,e=e+1|0;while((e|0)!=(t|0))}s=+f(+c)*o,a[r>>3]=s,c=+p(+c)*o,a[r+8>>3]=c,j=l}function wt(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0;if(s=j,j=j+32|0,o=s,Cr(e,o),i[t>>2]=0,a[n>>3]=5,r=+Sr(16400,o),r<+a[n>>3]&&(i[t>>2]=0,a[n>>3]=r),r=+Sr(16424,o),r<+a[n>>3]&&(i[t>>2]=1,a[n>>3]=r),r=+Sr(16448,o),r<+a[n>>3]&&(i[t>>2]=2,a[n>>3]=r),r=+Sr(16472,o),r<+a[n>>3]&&(i[t>>2]=3,a[n>>3]=r),r=+Sr(16496,o),r<+a[n>>3]&&(i[t>>2]=4,a[n>>3]=r),r=+Sr(16520,o),r<+a[n>>3]&&(i[t>>2]=5,a[n>>3]=r),r=+Sr(16544,o),r<+a[n>>3]&&(i[t>>2]=6,a[n>>3]=r),r=+Sr(16568,o),r<+a[n>>3]&&(i[t>>2]=7,a[n>>3]=r),r=+Sr(16592,o),r<+a[n>>3]&&(i[t>>2]=8,a[n>>3]=r),r=+Sr(16616,o),r<+a[n>>3]&&(i[t>>2]=9,a[n>>3]=r),r=+Sr(16640,o),r<+a[n>>3]&&(i[t>>2]=10,a[n>>3]=r),r=+Sr(16664,o),r<+a[n>>3]&&(i[t>>2]=11,a[n>>3]=r),r=+Sr(16688,o),r<+a[n>>3]&&(i[t>>2]=12,a[n>>3]=r),r=+Sr(16712,o),r<+a[n>>3]&&(i[t>>2]=13,a[n>>3]=r),r=+Sr(16736,o),r<+a[n>>3]&&(i[t>>2]=14,a[n>>3]=r),r=+Sr(16760,o),r<+a[n>>3]&&(i[t>>2]=15,a[n>>3]=r),r=+Sr(16784,o),r<+a[n>>3]&&(i[t>>2]=16,a[n>>3]=r),r=+Sr(16808,o),r<+a[n>>3]&&(i[t>>2]=17,a[n>>3]=r),r=+Sr(16832,o),r<+a[n>>3]&&(i[t>>2]=18,a[n>>3]=r),r=+Sr(16856,o),!(r<+a[n>>3])){j=s;return}i[t>>2]=19,a[n>>3]=r,j=s}function Tt(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0;if(s=+yr(e),s<1e-16){t=15600+(t<<4)|0,i[o>>2]=i[t>>2],i[o+4>>2]=i[t+4>>2],i[o+8>>2]=i[t+8>>2],i[o+12>>2]=i[t+12>>2];return}if(c=+v(+ +a[e+8>>3],+ +a[e>>3]),(n|0)>0){e=0;do s*=.37796447300922725,e=e+1|0;while((e|0)!=(n|0))}l=s*.3333333333333333,r?(n=(nn(n)|0)==0,s=+_(+((n?l:l*.37796447300922725)*.381966011250105))):(s=+_(+(s*.381966011250105)),nn(n)|0&&(c=+vn(c+.3334731722518321))),Tn(15600+(t<<4)|0,+vn(+a[15920+(t*24|0)>>3]-c),s,o)}function Et(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0;r=j,j=j+16|0,a=r,Ke(e+4|0,a),Tt(a,i[e>>2]|0,t,0,n),j=r}function Dt(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,ee=0,te=0,ne=0,re=0,ie=0;if(ne=j,j=j+272|0,s=ne+256|0,b=ne+240|0,A=ne,ee=ne+224|0,te=ne+208|0,x=ne+176|0,S=ne+160|0,C=ne+192|0,w=ne+144|0,T=ne+128|0,D=ne+112|0,O=ne+96|0,k=ne+80|0,i[s>>2]=t,i[b>>2]=i[e>>2],i[b+4>>2]=i[e+4>>2],i[b+8>>2]=i[e+8>>2],i[b+12>>2]=i[e+12>>2],Ot(b,s,A),i[o>>2]=0,b=r+n+((r|0)==5&1)|0,(b|0)<=(n|0)){j=ne;return}u=i[s>>2]|0,d=ee+4|0,f=x+4|0,p=n+5|0,m=16880+(u<<2)|0,h=16960+(u<<2)|0,g=T+8|0,_=D+8|0,v=O+8|0,y=te+4|0,l=n;a:for(;;){c=A+(((l|0)%5|0)<<4)|0,i[te>>2]=i[c>>2],i[te+4>>2]=i[c+4>>2],i[te+8>>2]=i[c+8>>2],i[te+12>>2]=i[c+12>>2];do;while((kt(te,u,0,1)|0)==2);if((l|0)>(n|0)&(nn(t)|0)!=0){if(i[x>>2]=i[te>>2],i[x+4>>2]=i[te+4>>2],i[x+8>>2]=i[te+8>>2],i[x+12>>2]=i[te+12>>2],Ke(d,S),r=i[x>>2]|0,s=i[17040+(r*80|0)+(i[ee>>2]<<2)>>2]|0,i[x>>2]=i[18640+(r*80|0)+(s*20|0)>>2],c=i[18640+(r*80|0)+(s*20|0)+16>>2]|0,(c|0)>0){e=0;do rt(f),e=e+1|0;while((e|0)<(c|0))}switch(c=18640+(r*80|0)+(s*20|0)+4|0,i[C>>2]=i[c>>2],i[C+4>>2]=i[c+4>>2],i[C+8>>2]=i[c+8>>2],Je(C,(i[m>>2]|0)*3|0),M(f,C,f),Ge(f),Ke(f,w),re=+(i[h>>2]|0),a[T>>3]=re*3,a[g>>3]=0,ie=re*-1.5,a[D>>3]=ie,a[_>>3]=re*2.598076211353316,a[O>>3]=ie,a[v>>3]=re*-2.598076211353316,i[17040+((i[x>>2]|0)*80|0)+(i[te>>2]<<2)>>2]|0){case 1:e=D,r=T;break;case 3:e=O,r=D;break;case 2:e=T,r=O;break;default:e=12;break a}br(S,w,r,e,k),Tt(k,i[x>>2]|0,u,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=(i[o>>2]|0)+1}if((l|0)<(p|0)&&(Ke(y,x),Tt(x,i[te>>2]|0,u,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=(i[o>>2]|0)+1),i[ee>>2]=i[te>>2],i[ee+4>>2]=i[te+4>>2],i[ee+8>>2]=i[te+8>>2],i[ee+12>>2]=i[te+12>>2],l=l+1|0,(l|0)>=(b|0)){e=3;break}}if((e|0)==3){j=ne;return}else (e|0)==12&&E(26970,27017,572,27027)}function Ot(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0;l=j,j=j+128|0,r=l+64|0,a=l,o=r,s=20240,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20304,c=o+60|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));c=(nn(i[t>>2]|0)|0)==0,r=c?r:a,a=e+4|0,st(a),ct(a),nn(i[t>>2]|0)|0&&(tt(a),i[t>>2]=(i[t>>2]|0)+1),i[n>>2]=i[e>>2],t=n+4|0,M(a,r,t),Ge(t),i[n+16>>2]=i[e>>2],t=n+20|0,M(a,r+12|0,t),Ge(t),i[n+32>>2]=i[e>>2],t=n+36|0,M(a,r+24|0,t),Ge(t),i[n+48>>2]=i[e>>2],t=n+52|0,M(a,r+36|0,t),Ge(t),i[n+64>>2]=i[e>>2],n=n+68|0,M(a,r+48|0,n),Ge(n),j=l}function kt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(h=j,j=j+32|0,p=h+12|0,c=h,m=e+4|0,f=i[16960+(t<<2)>>2]|0,d=(r|0)!=0,f=d?f*3|0:f,a=i[m>>2]|0,u=e+8|0,s=i[u>>2]|0,d){if(o=e+12|0,r=i[o>>2]|0,a=s+a+r|0,(a|0)==(f|0))return m=1,j=h,m|0;l=o}else l=e+12|0,r=i[l>>2]|0,a=s+a+r|0;if((a|0)<=(f|0))return m=0,j=h,m|0;do if((r|0)>0){if(r=i[e>>2]|0,(s|0)>0){o=18640+(r*80|0)+60|0,r=e;break}r=18640+(r*80|0)+40|0,n?(Ue(p,f,0,0),qe(m,p,c),it(c),M(c,p,m),o=r,r=e):(o=r,r=e)}else o=18640+((i[e>>2]|0)*80|0)+20|0,r=e;while(0);if(i[r>>2]=i[o>>2],a=o+16|0,(i[a>>2]|0)>0){r=0;do rt(m),r=r+1|0;while((r|0)<(i[a>>2]|0))}return e=o+4|0,i[p>>2]=i[e>>2],i[p+4>>2]=i[e+4>>2],i[p+8>>2]=i[e+8>>2],t=i[16880+(t<<2)>>2]|0,Je(p,d?t*3|0:t),M(m,p,m),Ge(m),r=d&&((i[u>>2]|0)+(i[m>>2]|0)+(i[l>>2]|0)|0)==(f|0)?1:2,m=r,j=h,m|0}function At(e,t){e|=0,t|=0;var n=0;do n=kt(e,t,0,1)|0;while((n|0)==2);return n|0}function jt(e,t,n,r,o){e|=0,t|=0,n|=0,r|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0;if(O=j,j=j+240|0,s=O+224|0,C=O+208|0,w=O,T=O+192|0,D=O+176|0,v=O+160|0,y=O+144|0,b=O+128|0,x=O+112|0,S=O+96|0,i[s>>2]=t,i[C>>2]=i[e>>2],i[C+4>>2]=i[e+4>>2],i[C+8>>2]=i[e+8>>2],i[C+12>>2]=i[e+12>>2],Mt(C,s,w),i[o>>2]=0,_=r+n+((r|0)==6&1)|0,(_|0)<=(n|0)){j=O;return}u=i[s>>2]|0,d=n+6|0,f=16960+(u<<2)|0,p=y+8|0,m=b+8|0,h=x+8|0,g=T+4|0,c=0,l=n,r=-1;a:for(;;){if(s=(l|0)%6|0,e=w+(s<<4)|0,i[T>>2]=i[e>>2],i[T+4>>2]=i[e+4>>2],i[T+8>>2]=i[e+8>>2],i[T+12>>2]=i[e+12>>2],e=c,c=kt(T,u,0,1)|0,(l|0)>(n|0)&(nn(t)|0)!=0&&(e|0)!=1&&(i[T>>2]|0)!=(r|0)){switch(Ke(w+(((s+5|0)%6|0)<<4)+4|0,D),Ke(w+(s<<4)+4|0,v),k=+(i[f>>2]|0),a[y>>3]=k*3,a[p>>3]=0,A=k*-1.5,a[b>>3]=A,a[m>>3]=k*2.598076211353316,a[x>>3]=A,a[h>>3]=k*-2.598076211353316,s=i[C>>2]|0,i[17040+(s*80|0)+(((r|0)==(s|0)?i[T>>2]|0:r)<<2)>>2]|0){case 1:e=b,r=y;break;case 3:e=x,r=b;break;case 2:e=y,r=x;break;default:e=8;break a}br(D,v,r,e,S),!(xr(D,S)|0)&&!(xr(v,S)|0)&&(Tt(S,i[C>>2]|0,u,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=(i[o>>2]|0)+1)}if((l|0)<(d|0)&&(Ke(g,D),Tt(D,i[T>>2]|0,u,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=(i[o>>2]|0)+1),l=l+1|0,(l|0)>=(_|0)){e=3;break}else r=i[T>>2]|0}if((e|0)==3){j=O;return}else (e|0)==8&&E(27054,27017,737,27099)}function Mt(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0;l=j,j=j+160|0,r=l+80|0,a=l,o=r,s=20368,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));o=a,s=20448,c=o+72|0;do i[o>>2]=i[s>>2],o=o+4|0,s=s+4|0;while((o|0)<(c|0));c=(nn(i[t>>2]|0)|0)==0,r=c?r:a,a=e+4|0,st(a),ct(a),nn(i[t>>2]|0)|0&&(tt(a),i[t>>2]=(i[t>>2]|0)+1),i[n>>2]=i[e>>2],t=n+4|0,M(a,r,t),Ge(t),i[n+16>>2]=i[e>>2],t=n+20|0,M(a,r+12|0,t),Ge(t),i[n+32>>2]=i[e>>2],t=n+36|0,M(a,r+24|0,t),Ge(t),i[n+48>>2]=i[e>>2],t=n+52|0,M(a,r+36|0,t),Ge(t),i[n+64>>2]=i[e>>2],t=n+68|0,M(a,r+48|0,t),Ge(t),i[n+80>>2]=i[e>>2],n=n+84|0,M(a,r+60|0,n),Ge(n),j=l}function Nt(e,t){return e|=0,t|=0,t=P(e|0,t|0,52)|0,T()|0,t&15|0}function Pt(e,t){return e|=0,t|=0,t=P(e|0,t|0,45)|0,T()|0,t&127|0}function Ft(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(n+-1|0)>>>0>14?(r=4,r|0):(n=P(e|0,t|0,(15-n|0)*3|0)|0,T()|0,i[r>>2]=n&7,r=0,r|0)}function It(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0;if(e>>>0>15)return a=4,a|0;if(t>>>0>121)return a=17,a|0;c=F(e|0,0,52)|0,o=T()|0,l=F(t|0,0,45)|0,o=o|T()|134225919;a:do if((e|0)>=1){for(l=1,c=(r[20528+t>>0]|0)!=0,s=-1;;){if(t=i[n+(l+-1<<2)>>2]|0,t>>>0>6){o=18,t=10;break}if(!((t|0)==0|c^1))if((t|0)==1){o=19,t=10;break}else c=0;if(d=(15-l|0)*3|0,u=F(7,0,d|0)|0,o&=~(T()|0),t=F(t|0,((t|0)<0)<<31>>31|0,d|0)|0,s=t|s&~u,o=T()|0|o,(l|0)<(e|0))l=l+1|0;else break a}if((t|0)==10)return o|0}else s=-1;while(0);return d=a,i[d>>2]=s,i[d+4>>2]=o,d=0,d|0}function Lt(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!(!0&(t&-16777216|0)==134217728)||(i=P(e|0,t|0,52)|0,T()|0,i&=15,n=P(e|0,t|0,45)|0,T()|0,n&=127,n>>>0>121)?(e=0,e|0):(s=(i^15)*3|0,a=P(e|0,t|0,s|0)|0,s=F(a|0,T()|0,s|0)|0,a=T()|0,o=Hr(-1227133514,-1171,s|0,a|0)|0,!((s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)||(s=(i*3|0)+19|0,o=F(~e|0,~t|0,s|0)|0,s=P(o|0,T()|0,s|0)|0,!((i|0)==15|(s|0)==0&(T()|0)==0))?(s=0,s|0):!(r[20528+n>>0]|0)||(t&=8191,(e|0)==0&(t|0)==0)?(s=1,s|0):(s=Zr(e|0,t|0,0)|0,T()|0,((63-s|0)%3|0)!=0|0))}function Rt(e,t){e|=0,t|=0;var n=0,i=0,a=0,o=0,s=0;return!0&(t&-16777216|0)==134217728&&(i=P(e|0,t|0,52)|0,T()|0,i&=15,n=P(e|0,t|0,45)|0,T()|0,n&=127,n>>>0<=121)&&(s=(i^15)*3|0,a=P(e|0,t|0,s|0)|0,s=F(a|0,T()|0,s|0)|0,a=T()|0,o=Hr(-1227133514,-1171,s|0,a|0)|0,(s&613566756&o|0)==0&(a&4681&(T()|0)|0)==0)&&(s=(i*3|0)+19|0,o=F(~e|0,~t|0,s|0)|0,s=P(o|0,T()|0,s|0)|0,(i|0)==15|(s|0)==0&(T()|0)==0)&&(!(r[20528+n>>0]|0)||(n=t&8191,(e|0)==0&(n|0)==0)||(s=Zr(e|0,n|0,0)|0,T()|0,(63-s|0)%3|0))||vt(e,t)|0?(s=1,s|0):(s=(kr(e,t)|0)!=0&1,s|0)}function zt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(a=F(t|0,0,52)|0,o=T()|0,n=F(n|0,0,45)|0,n=o|T()|134225919,(t|0)<1){o=-1,r=n,t=e,i[t>>2]=o,e=e+4|0,i[e>>2]=r;return}for(o=1,a=-1;s=(15-o|0)*3|0,c=F(7,0,s|0)|0,n&=~(T()|0),s=F(r|0,0,s|0)|0,a=a&~c|s,n=n|T()|0,(o|0)!=(t|0);)o=o+1|0;c=e,s=c,i[s>>2]=a,c=c+4|0,i[c>>2]=n}function Bt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(o=P(e|0,t|0,52)|0,T()|0,o&=15,n>>>0>15)return r=4,r|0;if((o|0)<(n|0))return r=12,r|0;if((o|0)==(n|0))return i[r>>2]=e,i[r+4>>2]=t,r=0,r|0;if(a=F(n|0,0,52)|0,a|=e,e=T()|0|t&-15728641,(o|0)>(n|0))do t=F(7,0,(14-n|0)*3|0)|0,n=n+1|0,a=t|a,e=T()|0|e;while((n|0)<(o|0));return i[r>>2]=a,i[r+4>>2]=e,r=0,r|0}function Vt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(o=P(e|0,t|0,52)|0,T()|0,o&=15,!((n|0)<16&(o|0)<=(n|0)))return r=4,r|0;a=n-o|0,n=P(e|0,t|0,45)|0,T()|0;a:do if(!(xe(n&127)|0))n=Xn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;else{b:do if(o|0){for(n=1;s=F(7,0,(15-n|0)*3|0)|0,(s&e|0)==0&((T()|0)&t|0)==0;)if(n>>>0<o>>>0)n=n+1|0;else break b;n=Xn(7,0,a,((a|0)<0)<<31>>31)|0,a=T()|0;break a}while(0);n=Xn(7,0,a,((a|0)<0)<<31>>31)|0,n=qr(n|0,T()|0,5,0)|0,n=Vr(n|0,T()|0,-5,-1)|0,n=Gr(n|0,T()|0,6,0)|0,n=Vr(n|0,T()|0,1,0)|0,a=T()|0}while(0);return s=r,i[s>>2]=n,i[s+4>>2]=a,s=0,s|0}function Ht(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=P(e|0,t|0,45)|0,T()|0,!(xe(i&127)|0))return i=0,i|0;i=P(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!i)n=0;else for(r=1;;){if(n=P(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0)break a;if(r>>>0<i>>>0)r=r+1|0;else{n=0;break}}while(0);return i=(n|0)==0&1,i|0}function Ut(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0;if(s=j,j=j+16|0,o=s,hn(o,e,t,n),t=o,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0)return j=s,0;a=0,n=0;do c=r+(a<<3)|0,i[c>>2]=e,i[c+4>>2]=t,a=Vr(a|0,n|0,1,0)|0,n=T()|0,_n(o),c=o,e=i[c>>2]|0,t=i[c+4>>2]|0;while(!((e|0)==0&(t|0)==0));return j=s,0}function Wt(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,(r|0)<(n|0)?(n=t,r=e,w(n|0),r|0):(n=F(-1,-1,((r-n|0)*3|0)+3|0)|0,r=F(~n|0,~(T()|0)|0,(15-r|0)*3|0)|0,n=~(T()|0)&t,r=~r&e,w(n|0),r|0)}function Gt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0;return a=P(e|0,t|0,52)|0,T()|0,a&=15,(n|0)<16&(a|0)<=(n|0)?((a|0)<(n|0)&&(a=F(-1,-1,((n+-1-a|0)*3|0)+3|0)|0,a=F(~a|0,~(T()|0)|0,(15-n|0)*3|0)|0,t=~(T()|0)&t,e=~a&e),a=F(n|0,0,52)|0,n=t&-15728641|T()|0,i[r>>2]=e|a,i[r+4>>2]=n,r=0,r|0):(r=4,r|0)}function Kt(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0,k=0,A=0,ee=0,j=0;if((n|0)==0&(r|0)==0)return j=0,j|0;if(a=e,o=i[a>>2]|0,a=i[a+4>>2]|0,!0&(a&15728640|0)==0){if(!((r|0)>0|(r|0)==0&n>>>0>0)||(j=t,i[j>>2]=o,i[j+4>>2]=a,(n|0)==1&(r|0)==0))return j=0,j|0;a=1,o=0;do A=e+(a<<3)|0,ee=i[A+4>>2]|0,j=t+(a<<3)|0,i[j>>2]=i[A>>2],i[j+4>>2]=ee,a=Vr(a|0,o|0,1,0)|0,o=T()|0;while((o|0)<(r|0)|(o|0)==(r|0)&a>>>0<n>>>0);return a=0,a|0}if(k=n<<3,ee=zr(k)|0,!ee)return j=13,j|0;if(ti(ee|0,e|0,k|0)|0,A=Br(n,8)|0,!A)return N(ee),j=13,j|0;a:for(;;){a=ee,u=i[a>>2]|0,a=i[a+4>>2]|0,D=P(u|0,a|0,52)|0,T()|0,D&=15,O=D+-1|0,w=(D|0)!=0,C=(r|0)>0|(r|0)==0&n>>>0>0;b:do if(w&C){if(y=F(O|0,0,52)|0,b=T()|0,O>>>0>15){if(!((u|0)==0&(a|0)==0)){j=16;break a}for(o=0,e=0;;){if(o=Vr(o|0,e|0,1,0)|0,e=T()|0,!((e|0)<(r|0)|(e|0)==(r|0)&o>>>0<n>>>0))break b;if(s=ee+(o<<3)|0,S=i[s>>2]|0,s=i[s+4>>2]|0,!((S|0)==0&(s|0)==0)){a=s,j=16;break a}}}for(c=u,e=a,o=0,s=0;;){if(!((c|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){j=21;break a}if(d=P(c|0,e|0,52)|0,T()|0,d&=15,(d|0)<(O|0)){a=12,j=27;break a}if((d|0)!=(O|0)&&(c|=y,e=e&-15728641|b,d>>>0>=D>>>0)){l=O;do S=F(7,0,(14-l|0)*3|0)|0,l=l+1|0,c=S|c,e=T()|0|e;while(l>>>0<d>>>0)}if(p=Yr(c|0,e|0,n|0,r|0)|0,m=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0,!((f|0)==0&(d|0)==0)){_=0,v=0;do{if((_|0)>(r|0)|(_|0)==(r|0)&v>>>0>n>>>0){j=31;break a}if((f|0)==(c|0)&(d&-117440513|0)==(e|0)){h=P(f|0,d|0,56)|0,T()|0,h&=7,g=h+1|0,S=P(f|0,d|0,45)|0,T()|0;c:do if(!(xe(S&127)|0))d=7;else{if(f=P(f|0,d|0,52)|0,T()|0,f&=15,!f){d=6;break}for(d=1;;){if(S=F(7,0,(15-d|0)*3|0)|0,!((S&c|0)==0&((T()|0)&e|0)==0)){d=7;break c}if(d>>>0<f>>>0)d=d+1|0;else{d=6;break}}}while(0);if((h+2|0)>>>0>d>>>0){j=41;break a}S=F(g|0,0,56)|0,e=T()|0|e&-117440513,x=l,i[x>>2]=0,i[x+4>>2]=0,c=S|c}else p=Vr(p|0,m|0,1,0)|0,p=Jr(p|0,T()|0,n|0,r|0)|0,m=T()|0;v=Vr(v|0,_|0,1,0)|0,_=T()|0,l=A+(p<<3)|0,d=l,f=i[d>>2]|0,d=i[d+4>>2]|0}while(!((f|0)==0&(d|0)==0))}S=l,i[S>>2]=c,i[S+4>>2]=e}if(o=Vr(o|0,s|0,1,0)|0,s=T()|0,!((s|0)<(r|0)|(s|0)==(r|0)&o>>>0<n>>>0))break b;e=ee+(o<<3)|0,c=i[e>>2]|0,e=i[e+4>>2]|0}}while(0);if(S=Vr(n|0,r|0,5,0)|0,x=T()|0,x>>>0<0|(x|0)==0&S>>>0<11){j=85;break}if(S=Gr(n|0,r|0,6,0)|0,T()|0,S=Br(S,8)|0,!S){j=48;break}do if(C){for(g=0,e=0,h=0,_=0;;){if(d=A+(g<<3)|0,s=d,o=i[s>>2]|0,s=i[s+4>>2]|0,(o|0)==0&(s|0)==0)x=h;else{f=P(o|0,s|0,56)|0,T()|0,f&=7,c=f+1|0,p=s&-117440513,x=P(o|0,s|0,45)|0,T()|0;d:do if(xe(x&127)|0){if(m=P(o|0,s|0,52)|0,T()|0,m&=15,m|0)for(l=1;;){if(x=F(7,0,(15-l|0)*3|0)|0,!((o&x|0)==0&(p&(T()|0)|0)==0))break d;if(l>>>0<m>>>0)l=l+1|0;else break}s=F(c|0,0,56)|0,o=s|o,s=T()|0|p,c=d,i[c>>2]=o,i[c+4>>2]=s,c=f+2|0}while(0);(c|0)==7?(x=S+(e<<3)|0,i[x>>2]=o,i[x+4>>2]=s&-117440513,e=Vr(e|0,h|0,1,0)|0,x=T()|0):x=h}if(g=Vr(g|0,_|0,1,0)|0,_=T()|0,(_|0)<(r|0)|(_|0)==(r|0)&g>>>0<n>>>0)h=x;else break}if(C){if(v=O>>>0>15,y=F(O|0,0,52)|0,b=T()|0,!w){for(o=0,l=0,c=0,s=0;(u|0)==0&(a|0)==0||(O=t+(o<<3)|0,i[O>>2]=u,i[O+4>>2]=a,o=Vr(o|0,l|0,1,0)|0,l=T()|0),c=Vr(c|0,s|0,1,0)|0,s=T()|0,(s|0)<(r|0)|(s|0)==(r|0)&c>>>0<n>>>0;)a=ee+(c<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0;a=x;break}for(o=0,l=0,s=0,c=0;;){do if(!((u|0)==0&(a|0)==0)){if(m=P(u|0,a|0,52)|0,T()|0,m&=15,v|(m|0)<(O|0)){j=80;break a}if((m|0)!=(O|0)){if(d=u|y,f=a&-15728641|b,m>>>0>=D>>>0){p=O;do w=F(7,0,(14-p|0)*3|0)|0,p=p+1|0,d=w|d,f=T()|0|f;while(p>>>0<m>>>0)}}else d=u,f=a;h=Yr(d|0,f|0,n|0,r|0)|0,p=0,m=0,_=T()|0;do{if((p|0)>(r|0)|(p|0)==(r|0)&m>>>0>n>>>0){j=81;break a}if(w=A+(h<<3)|0,g=i[w+4>>2]|0,(g&-117440513|0)==(f|0)&&(i[w>>2]|0)==(d|0)){j=65;break}w=Vr(h|0,_|0,1,0)|0,h=Jr(w|0,T()|0,n|0,r|0)|0,_=T()|0,m=Vr(m|0,p|0,1,0)|0,p=T()|0,w=A+(h<<3)|0}while(!((i[w>>2]|0)==(d|0)&&(i[w+4>>2]|0)==(f|0)));if((j|0)==65&&(j=0,!0&(g&117440512|0)==100663296))break;w=t+(o<<3)|0,i[w>>2]=u,i[w+4>>2]=a,o=Vr(o|0,l|0,1,0)|0,l=T()|0}while(0);if(s=Vr(s|0,c|0,1,0)|0,c=T()|0,!((c|0)<(r|0)|(c|0)==(r|0)&s>>>0<n>>>0))break;a=ee+(s<<3)|0,u=i[a>>2]|0,a=i[a+4>>2]|0}a=x}else o=0,a=x}else o=0,e=0,a=0;while(0);if(ni(A|0,0,k|0)|0,ti(ee|0,S|0,e<<3|0)|0,N(S),(e|0)==0&(a|0)==0){j=89;break}else t=t+(o<<3)|0,r=a,n=e}if((j|0)==16)!0&(a&117440512|0)==0?(a=4,j=27):j=21;else if((j|0)==31)E(27795,27122,620,27132);else if((j|0)==41)return N(ee),N(A),j=10,j|0;else if((j|0)==48)return N(ee),N(A),j=13,j|0;else (j|0)==80?E(27795,27122,711,27132):(j|0)==81?E(27795,27122,723,27132):(j|0)==85&&(ti(t|0,ee|0,n<<3|0)|0,j=89);return(j|0)==21?(N(ee),N(A),j=5,j|0):(j|0)==27?(N(ee),N(A),j=a,j|0):(j|0)==89?(N(ee),N(A),j=0,j|0):0}function qt(e,t,n,r,a,o,s){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0,s|=0;var c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(g=j,j=j+16|0,h=g,!((n|0)>0|(n|0)==0&t>>>0>0))return h=0,j=g,h|0;if((s|0)>=16)return h=12,j=g,h|0;p=0,m=0,f=0,c=0;a:for(;;){if(u=e+(p<<3)|0,l=i[u>>2]|0,u=i[u+4>>2]|0,d=P(l|0,u|0,52)|0,T()|0,(d&15|0)>(s|0)){c=12,l=11;break}if(hn(h,l,u,s),d=h,u=i[d>>2]|0,d=i[d+4>>2]|0,(u|0)==0&(d|0)==0)l=f;else{l=f;do{if(!((c|0)<(o|0)|(c|0)==(o|0)&l>>>0<a>>>0)){l=10;break a}f=r+(l<<3)|0,i[f>>2]=u,i[f+4>>2]=d,l=Vr(l|0,c|0,1,0)|0,c=T()|0,_n(h),f=h,u=i[f>>2]|0,d=i[f+4>>2]|0}while(!((u|0)==0&(d|0)==0))}if(p=Vr(p|0,m|0,1,0)|0,m=T()|0,(m|0)<(n|0)|(m|0)==(n|0)&p>>>0<t>>>0)f=l;else{c=0,l=11;break}}return(l|0)==10?(h=14,j=g,h|0):(l|0)==11?(j=g,c|0):0}function Jt(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;p=j,j=j+16|0,f=p;a:do if((n|0)>0|(n|0)==0&t>>>0>0){for(u=0,s=0,o=0,d=0;;){if(l=e+(u<<3)|0,c=i[l>>2]|0,l=i[l+4>>2]|0,!((c|0)==0&(l|0)==0)&&(l=(Vt(c,l,r,f)|0)==0,c=f,s=Vr(i[c>>2]|0,i[c+4>>2]|0,s|0,o|0)|0,o=T()|0,!l)){o=12;break}if(u=Vr(u|0,d|0,1,0)|0,d=T()|0,!((d|0)<(n|0)|(d|0)==(n|0)&u>>>0<t>>>0))break a}return j=p,o|0}else s=0,o=0;while(0);return i[a>>2]=s,i[a+4>>2]=o,a=0,j=p,a|0}function Yt(e,t){return e|=0,t|=0,t=P(e|0,t|0,52)|0,T()|0,t&1|0}function Xt(e,t){e|=0,t|=0;var n=0,r=0,i=0;if(i=P(e|0,t|0,52)|0,T()|0,i&=15,!i)return i=0,i|0;for(r=1;;){if(n=P(e|0,t|0,(15-r|0)*3|0)|0,T()|0,n&=7,n|0){r=5;break}if(r>>>0<i>>>0)r=r+1|0;else{n=0,r=5;break}}return(r|0)==5?n|0:0}function Zt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0;if(c=P(e|0,t|0,52)|0,T()|0,c&=15,!c)return s=t,c=e,w(s|0),c|0;for(s=1,n=0;;){a=(15-s|0)*3|0,r=F(7,0,a|0)|0,i=T()|0,o=P(e|0,t|0,a|0)|0,T()|0,a=F(at(o&7)|0,0,a|0)|0,o=T()|0,e=a|e&~r,t=o|t&~i;a:do if(!n)if((a&r|0)==0&(o&i|0)==0)n=0;else if(r=P(e|0,t|0,52)|0,T()|0,r&=15,!r)n=1;else{n=1;b:for(;;){switch(o=P(e|0,t|0,(15-n|0)*3|0)|0,T()|0,o&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0<r>>>0)n=n+1|0;else{n=1;break a}}for(n=1;;)if(o=(15-n|0)*3|0,i=P(e|0,t|0,o|0)|0,T()|0,a=F(7,0,o|0)|0,t&=~(T()|0),o=F(at(i&7)|0,0,o|0)|0,e=e&~a|o,t=t|T()|0,n>>>0<r>>>0)n=n+1|0;else{n=1;break}}while(0);if(s>>>0<c>>>0)s=s+1|0;else break}return w(t|0),e|0}function Qt(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(r=P(e|0,t|0,52)|0,T()|0,r&=15,!r)return n=t,r=e,w(n|0),r|0;for(n=1;a=(15-n|0)*3|0,o=P(e|0,t|0,a|0)|0,T()|0,i=F(7,0,a|0)|0,t&=~(T()|0),a=F(at(o&7)|0,0,a|0)|0,e=a|e&~i,t=T()|0|t,n>>>0<r>>>0;)n=n+1|0;return w(t|0),e|0}function $t(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0,s=0,c=0;if(c=P(e|0,t|0,52)|0,T()|0,c&=15,!c)return s=t,c=e,w(s|0),c|0;for(s=1,n=0;;){a=(15-s|0)*3|0,r=F(7,0,a|0)|0,i=T()|0,o=P(e|0,t|0,a|0)|0,T()|0,a=F(ot(o&7)|0,0,a|0)|0,o=T()|0,e=a|e&~r,t=o|t&~i;a:do if(!n)if((a&r|0)==0&(o&i|0)==0)n=0;else if(r=P(e|0,t|0,52)|0,T()|0,r&=15,!r)n=1;else{n=1;b:for(;;){switch(o=P(e|0,t|0,(15-n|0)*3|0)|0,T()|0,o&7){case 1:break b;case 0:break;default:n=1;break a}if(n>>>0<r>>>0)n=n+1|0;else{n=1;break a}}for(n=1;;)if(i=(15-n|0)*3|0,a=F(7,0,i|0)|0,o=t&~(T()|0),t=P(e|0,t|0,i|0)|0,T()|0,t=F(ot(t&7)|0,0,i|0)|0,e=e&~a|t,t=o|T()|0,n>>>0<r>>>0)n=n+1|0;else{n=1;break}}while(0);if(s>>>0<c>>>0)s=s+1|0;else break}return w(t|0),e|0}function en(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0,o=0;if(r=P(e|0,t|0,52)|0,T()|0,r&=15,!r)return n=t,r=e,w(n|0),r|0;for(n=1;o=(15-n|0)*3|0,a=F(7,0,o|0)|0,i=t&~(T()|0),t=P(e|0,t|0,o|0)|0,T()|0,t=F(ot(t&7)|0,0,o|0)|0,e=t|e&~a,t=T()|0|i,n>>>0<r>>>0;)n=n+1|0;return w(t|0),e|0}function tn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(l=j,j=j+64|0,c=l+40|0,r=l+24|0,a=l+12|0,o=l,F(t|0,0,52)|0,n=T()|134225919,!t)return(i[e+4>>2]|0)>2||(i[e+8>>2]|0)>2||(i[e+12>>2]|0)>2?(s=0,c=0,w(s|0),j=l,c|0):(F(Ce(e)|0,0,45)|0,s=T()|0|n,c=-1,w(s|0),j=l,c|0);if(i[c>>2]=i[e>>2],i[c+4>>2]=i[e+4>>2],i[c+8>>2]=i[e+8>>2],i[c+12>>2]=i[e+12>>2],s=c+4|0,(t|0)>0)for(e=-1;i[r>>2]=i[s>>2],i[r+4>>2]=i[s+4>>2],i[r+8>>2]=i[s+8>>2],t&1?(Qe(s),i[a>>2]=i[s>>2],i[a+4>>2]=i[s+4>>2],i[a+8>>2]=i[s+8>>2],et(a)):($e(s),i[a>>2]=i[s>>2],i[a+4>>2]=i[s+4>>2],i[a+8>>2]=i[s+8>>2],tt(a)),qe(r,a,o),Ge(o),d=(15-t|0)*3|0,u=F(7,0,d|0)|0,n&=~(T()|0),d=F(Ye(o)|0,0,d|0)|0,e=d|e&~u,n=T()|0|n,(t|0)>1;)t=t+-1|0;else e=-1;a:do if((i[s>>2]|0)<=2&&(i[c+8>>2]|0)<=2&&(i[c+12>>2]|0)<=2){if(r=Ce(c)|0,t=F(r|0,0,45)|0,t|=e,e=T()|0|n&-1040385,o=we(c)|0,!(xe(r)|0)){if((o|0)<=0)break;for(a=0;;){if(r=P(t|0,e|0,52)|0,T()|0,r&=15,r)for(n=1;d=(15-n|0)*3|0,c=P(t|0,e|0,d|0)|0,T()|0,u=F(7,0,d|0)|0,e&=~(T()|0),d=F(at(c&7)|0,0,d|0)|0,t=t&~u|d,e=e|T()|0,n>>>0<r>>>0;)n=n+1|0;if(a=a+1|0,(a|0)==(o|0))break a}}a=P(t|0,e|0,52)|0,T()|0,a&=15;b:do if(a){n=1;c:for(;;){switch(d=P(t|0,e|0,(15-n|0)*3|0)|0,T()|0,d&7){case 1:break c;case 0:break;default:break b}if(n>>>0<a>>>0)n=n+1|0;else break b}if(De(r,i[c>>2]|0)|0)for(n=1;c=(15-n|0)*3|0,u=F(7,0,c|0)|0,d=e&~(T()|0),e=P(t|0,e|0,c|0)|0,T()|0,e=F(ot(e&7)|0,0,c|0)|0,t=t&~u|e,e=d|T()|0,n>>>0<a>>>0;)n=n+1|0;else for(n=1;d=(15-n|0)*3|0,c=P(t|0,e|0,d|0)|0,T()|0,u=F(7,0,d|0)|0,e&=~(T()|0),d=F(at(c&7)|0,0,d|0)|0,t=t&~u|d,e=e|T()|0,n>>>0<a>>>0;)n=n+1|0}while(0);if((o|0)>0){n=0;do t=Zt(t,e)|0,e=T()|0,n=n+1|0;while((n|0)!=(o|0))}}else t=0,e=0;while(0);return u=e,d=t,w(u|0),j=l,d|0}function nn(e){return e|=0,(e|0)%2|0}function rn(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0;return a=j,j=j+16|0,r=a,t>>>0>15?(r=4,j=a,r|0):(i[e+4>>2]&2146435072|0)==2146435072||(i[e+8+4>>2]&2146435072|0)==2146435072?(r=3,j=a,r|0):(St(e,t,r),t=tn(r,t)|0,r=T()|0,i[n>>2]=t,i[n+4>>2]=r,(t|0)==0&(r|0)==0&&E(27795,27122,1050,27145),r=0,j=a,r|0)}function an(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0;if(a=n+4|0,o=P(e|0,t|0,52)|0,T()|0,o&=15,s=P(e|0,t|0,45)|0,T()|0,r=(o|0)==0,!(xe(s&127)|0)){if(r)return s=0,s|0;r=!(i[a>>2]|0)&&!(i[n+8>>2]|0)?(i[n+12>>2]|0)!=0&1:1}else if(r)return s=1,s|0;else r=1;for(n=1;n&1?et(a):tt(a),s=P(e|0,t|0,(15-n|0)*3|0)|0,T()|0,nt(a,s&7),n>>>0<o>>>0;)n=n+1|0;return r|0}function on(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(d=j,j=j+16|0,l=d,u=P(e|0,t|0,45)|0,T()|0,u&=127,u>>>0>121)return i[n>>2]=0,i[n+4>>2]=0,i[n+8>>2]=0,i[n+12>>2]=0,u=5,j=d,u|0;a:do if(xe(u)|0&&(o=P(e|0,t|0,52)|0,T()|0,o&=15,o|0)){r=1;b:for(;;){switch(c=P(e|0,t|0,(15-r|0)*3|0)|0,T()|0,c&7){case 5:break b;case 0:break;default:r=t;break a}if(r>>>0<o>>>0)r=r+1|0;else{r=t;break a}}for(a=1,r=t;t=(15-a|0)*3|0,s=F(7,0,t|0)|0,c=r&~(T()|0),r=P(e|0,r|0,t|0)|0,T()|0,r=F(ot(r&7)|0,0,t|0)|0,e=e&~s|r,r=c|T()|0,a>>>0<o>>>0;)a=a+1|0}else r=t;while(0);if(c=7696+(u*28|0)|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],!(an(e,r,n)|0))return u=0,j=d,u|0;if(s=n+4|0,i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],o=P(e|0,r|0,52)|0,T()|0,c=o&15,o&1?(tt(s),o=c+1|0):o=c,!(xe(u)|0))r=0;else{c:do if(!c)r=0;else for(t=1;;){if(a=P(e|0,r|0,(15-t|0)*3|0)|0,T()|0,a&=7,a|0){r=a;break c}if(t>>>0<c>>>0)t=t+1|0;else{r=0;break}}while(0);r=(r|0)==4&1}if(!(kt(n,o,r,0)|0))(o|0)!=(c|0)&&(i[s>>2]=i[l>>2],i[s+4>>2]=i[l+4>>2],i[s+8>>2]=i[l+8>>2]);else{if(xe(u)|0)do;while(kt(n,o,0,0)|0);(o|0)!=(c|0)&&$e(s)}return u=0,j=d,u|0}function sn(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,a=0;return a=j,j=j+16|0,r=a,i=on(e,t,r)|0,i|0?(j=a,i|0):(i=P(e|0,t|0,52)|0,T()|0,Et(r,i&15,n),i=0,j=a,i|0)}function cn(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,a=0,o=0,s=0;if(o=j,j=j+16|0,a=o,r=on(e,t,a)|0,r|0)return a=r,j=o,a|0;r=P(e|0,t|0,45)|0,T()|0,r=(xe(r&127)|0)==0,i=P(e|0,t|0,52)|0,T()|0,i&=15;a:do if(!r){if(i|0)for(r=1;;){if(s=F(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0))break a;if(r>>>0<i>>>0)r=r+1|0;else break}return Dt(a,i,0,5,n),s=0,j=o,s|0}while(0);return jt(a,i,0,6,n),s=0,j=o,s|0}function ln(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(a=P(e|0,t|0,45)|0,T()|0,!(xe(a&127)|0))return a=2,i[n>>2]=a,0;if(a=P(e|0,t|0,52)|0,T()|0,a&=15,!a)return a=5,i[n>>2]=a,0;for(r=1;;){if(o=F(7,0,(15-r|0)*3|0)|0,!((o&e|0)==0&((T()|0)&t|0)==0)){r=2,e=6;break}if(r>>>0<a>>>0)r=r+1|0;else{r=5,e=6;break}}return(e|0)==6&&(i[n>>2]=r),0}function un(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=j,j=j+128|0,u=f+112|0,o=f+96|0,d=f,a=P(e|0,t|0,52)|0,T()|0,c=a&15,i[u>>2]=c,s=P(e|0,t|0,45)|0,T()|0,s&=127;a:do if(xe(s)|0){if(c|0)for(r=1;;){if(l=F(7,0,(15-r|0)*3|0)|0,!((l&e|0)==0&((T()|0)&t|0)==0)){a=0;break a}if(r>>>0<c>>>0)r=r+1|0;else break}if(a&1)a=1;else return l=F(c+1|0,0,52)|0,d=T()|0|t&-15728641,u=F(7,0,(14-c|0)*3|0)|0,d=un((l|e)&~u,d&~(T()|0),n)|0,j=f,d|0}else a=0;while(0);if(r=on(e,t,o)|0,!r){a?(Ot(o,u,d),l=5):(Mt(o,u,d),l=6);b:do if(xe(s)|0)if(!c)e=5;else for(r=1;;){if(s=F(7,0,(15-r|0)*3|0)|0,!((s&e|0)==0&((T()|0)&t|0)==0)){e=2;break b}if(r>>>0<c>>>0)r=r+1|0;else{e=5;break}}else e=2;while(0);ni(n|0,-1,e<<2|0)|0;c:do if(a)for(o=0;;){if(s=d+(o<<4)|0,At(s,i[u>>2]|0)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}else for(o=0;;){if(s=d+(o<<4)|0,kt(s,i[u>>2]|0,0,1)|0,s=i[s>>2]|0,c=i[n>>2]|0,(c|0)==-1|(c|0)==(s|0))r=n;else{a=0;do{if(a=a+1|0,a>>>0>=e>>>0){r=1;break c}r=n+(a<<2)|0,c=i[r>>2]|0}while(!((c|0)==-1|(c|0)==(s|0)))}if(i[r>>2]=s,o=o+1|0,o>>>0>=l>>>0){r=0;break}}while(0)}return d=r,j=f,d|0}function dn(){return 12}function fn(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e>>>0>15)return c=4,c|0;if(F(e|0,0,52)|0,c=T()|134225919,!e){n=0,r=0;do xe(r)|0&&(F(r|0,0,45)|0,s=c|T()|0,e=t+(n<<3)|0,i[e>>2]=-1,i[e+4>>2]=s,n=n+1|0),r=r+1|0;while((r|0)!=122);return n=0,n|0}n=0,s=0;do{if(xe(s)|0){for(F(s|0,0,45)|0,r=1,a=-1,o=c|T()|0;l=F(7,0,(15-r|0)*3|0)|0,a&=~l,o&=~(T()|0),(r|0)!=(e|0);)r=r+1|0;l=t+(n<<3)|0,i[l>>2]=a,i[l+4>>2]=o,n=n+1|0}s=s+1|0}while((s|0)!=122);return n=0,n|0}function pn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0;if(y=j,j=j+16|0,_=y,v=P(e|0,t|0,52)|0,T()|0,v&=15,n>>>0>15)return v=4,j=y,v|0;if((v|0)<(n|0))return v=12,j=y,v|0;if((v|0)!=(n|0))if(o=F(n|0,0,52)|0,o|=e,c=T()|0|t&-15728641,(v|0)>(n|0)){l=n;do g=F(7,0,(14-l|0)*3|0)|0,l=l+1|0,o=g|o,c=T()|0|c;while((l|0)<(v|0));g=o}else g=o;else g=e,c=t;h=P(g|0,c|0,45)|0,T()|0;a:do if(xe(h&127)|0){if(l=P(g|0,c|0,52)|0,T()|0,l&=15,l|0)for(o=1;;){if(h=F(7,0,(15-o|0)*3|0)|0,!((h&g|0)==0&((T()|0)&c|0)==0)){u=33;break a}if(o>>>0<l>>>0)o=o+1|0;else break}if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(h=t&-15728641,m=v;;){if(p=m,m=m+-1|0,m>>>0>15|(v|0)<(m|0)){u=19;break}if((v|0)!=(m|0))if(o=F(m|0,0,52)|0,o|=e,l=T()|0|h,(v|0)<(p|0))f=o;else{u=m;do f=F(7,0,(14-u|0)*3|0)|0,u=u+1|0,o=f|o,l=T()|0|l;while((u|0)<(v|0));f=o}else f=e,l=t;if(d=P(f|0,l|0,45)|0,T()|0,!(xe(d&127)|0))o=0;else{d=P(f|0,l|0,52)|0,T()|0,d&=15;b:do if(!d)o=0;else for(u=1;;){if(o=P(f|0,l|0,(15-u|0)*3|0)|0,T()|0,o&=7,o|0)break b;if(u>>>0<d>>>0)u=u+1|0;else{o=0;break}}while(0);o=(o|0)==0&1}if(l=P(e|0,t|0,(15-p|0)*3|0)|0,T()|0,l&=7,(l|0)==7){a=5,u=42;break}if(o=(o|0)!=0,(l|0)==1&o){a=5,u=42;break}if(f=l+(((l|0)!=0&o)<<31>>31)|0,f|0&&(u=v-p|0,u=Xn(7,0,u,((u|0)<0)<<31>>31)|0,d=T()|0,o?(o=qr(u|0,d|0,5,0)|0,o=Vr(o|0,T()|0,-5,-1)|0,o=Gr(o|0,T()|0,6,0)|0,o=Vr(o|0,T()|0,1,0)|0,l=T()|0):(o=u,l=d),p=f+-1|0,p=qr(u|0,d|0,p|0,((p|0)<0)<<31>>31|0)|0,p=Vr(o|0,l|0,p|0,T()|0)|0,f=T()|0,d=r,d=Vr(p|0,f|0,i[d>>2]|0,i[d+4>>2]|0)|0,f=T()|0,p=r,i[p>>2]=d,i[p+4>>2]=f),(m|0)<=(n|0)){u=37;break}}if((u|0)==19)E(27795,27122,1367,27158);else if((u|0)==37){s=r,a=i[s+4>>2]|0,s=i[s>>2]|0;break}else if((u|0)==42)return j=y,a|0}else a=0,s=0}else u=33;while(0);c:do if((u|0)==33)if(h=r,i[h>>2]=0,i[h+4>>2]=0,(v|0)>(n|0)){for(o=v;;){if(a=P(e|0,t|0,(15-o|0)*3|0)|0,T()|0,a&=7,(a|0)==7){a=5;break}if(s=v-o|0,s=Xn(7,0,s,((s|0)<0)<<31>>31)|0,a=qr(s|0,T()|0,a|0,0)|0,s=T()|0,h=r,s=Vr(i[h>>2]|0,i[h+4>>2]|0,a|0,s|0)|0,a=T()|0,h=r,i[h>>2]=s,i[h+4>>2]=a,o=o+-1|0,(o|0)<=(n|0))break c}return j=y,a|0}else a=0,s=0;while(0);return Vt(g,c,v,_)|0&&E(27795,27122,1327,27173),v=_,_=i[v+4>>2]|0,((a|0)>-1|(a|0)==-1&s>>>0>4294967295)&((_|0)>(a|0)|((_|0)==(a|0)?(i[v>>2]|0)>>>0>s>>>0:0))?(v=0,j=y,v|0):(E(27795,27122,1407,27158),0)}function mn(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0;if(f=j,j=j+16|0,s=f,a>>>0>15)return o=4,j=f,o|0;if(c=P(n|0,r|0,52)|0,T()|0,c&=15,(c|0)>(a|0))return o=12,j=f,o|0;if(Vt(n,r,a,s)|0&&E(27795,27122,1327,27173),d=s,u=i[d+4>>2]|0,!(((t|0)>-1|(t|0)==-1&e>>>0>4294967295)&((u|0)>(t|0)|((u|0)==(t|0)?(i[d>>2]|0)>>>0>e>>>0:0))))return o=2,j=f,o|0;d=a-c|0,a=F(a|0,0,52)|0,l=T()|0|r&-15728641,u=o,i[u>>2]=a|n,i[u+4>>2]=l,u=P(n|0,r|0,45)|0,T()|0;a:do if(xe(u&127)|0){if(c|0)for(s=1;;){if(u=F(7,0,(15-s|0)*3|0)|0,!((u&n|0)==0&((T()|0)&r|0)==0))break a;if(s>>>0<c>>>0)s=s+1|0;else break}if((d|0)<1)return o=0,j=f,o|0;for(u=c^15,r=-1,l=1,s=1;;){c=d-l|0,c=Xn(7,0,c,((c|0)<0)<<31>>31)|0,n=T()|0;do if(s)if(s=qr(c|0,n|0,5,0)|0,s=Vr(s|0,T()|0,-5,-1)|0,s=Gr(s|0,T()|0,6,0)|0,a=T()|0,(t|0)>(a|0)|(t|0)==(a|0)&e>>>0>s>>>0){t=Vr(e|0,t|0,-1,-1)|0,t=Hr(t|0,T()|0,s|0,a|0)|0,s=T()|0,p=o,h=i[p>>2]|0,p=i[p+4>>2]|0,g=(u+r|0)*3|0,m=F(7,0,g|0)|0,p&=~(T()|0),r=Gr(t|0,s|0,c|0,n|0)|0,e=T()|0,a=Vr(r|0,e|0,2,0)|0,g=F(a|0,T()|0,g|0)|0,p=T()|0|p,a=o,i[a>>2]=g|h&~m,i[a+4>>2]=p,e=qr(r|0,e|0,c|0,n|0)|0,e=Hr(t|0,s|0,e|0,T()|0)|0,s=0,t=T()|0;break}else{g=o,m=i[g>>2]|0,g=i[g+4>>2]|0,h=F(7,0,(u+r|0)*3|0)|0,g&=~(T()|0),s=o,i[s>>2]=m&~h,i[s+4>>2]=g,s=1;break}else m=o,a=i[m>>2]|0,m=i[m+4>>2]|0,r=(u+r|0)*3|0,p=F(7,0,r|0)|0,m&=~(T()|0),g=Gr(e|0,t|0,c|0,n|0)|0,s=T()|0,r=F(g|0,s|0,r|0)|0,m=T()|0|m,h=o,i[h>>2]=r|a&~p,i[h+4>>2]=m,s=qr(g|0,s|0,c|0,n|0)|0,e=Hr(e|0,t|0,s|0,T()|0)|0,s=0,t=T()|0;while(0);if((d|0)>(l|0))r=~l,l=l+1|0;else{t=0;break}}return j=f,t|0}while(0);if((d|0)<1)return g=0,j=f,g|0;for(a=c^15,s=1;;)if(h=d-s|0,h=Xn(7,0,h,((h|0)<0)<<31>>31)|0,g=T()|0,l=o,n=i[l>>2]|0,l=i[l+4>>2]|0,c=(a-s|0)*3|0,r=F(7,0,c|0)|0,l&=~(T()|0),p=Gr(e|0,t|0,h|0,g|0)|0,m=T()|0,c=F(p|0,m|0,c|0)|0,l=T()|0|l,u=o,i[u>>2]=c|n&~r,i[u+4>>2]=l,g=qr(p|0,m|0,h|0,g|0)|0,e=Hr(e|0,t|0,g|0,T()|0)|0,t=T()|0,(d|0)<=(s|0)){t=0;break}else s=s+1|0;return j=f,t|0}function hn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;a=P(t|0,n|0,52)|0,T()|0,a&=15,(t|0)==0&(n|0)==0|((r|0)>15|(a|0)>(r|0))?(o=-1,t=-1,n=0,a=0):(t=Wt(t,n,a+1|0,r)|0,s=(T()|0)&-15728641,n=F(r|0,0,52)|0,n=t|n,s=s|T()|0,t=(Ht(n,s)|0)==0,o=a,t=t?-1:r,a=s),s=e,i[s>>2]=n,i[s+4>>2]=a,i[e+8>>2]=o,i[e+12>>2]=t}function gn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;if(a=P(e|0,t|0,52)|0,T()|0,a&=15,o=r+8|0,i[o>>2]=a,(e|0)==0&(t|0)==0|((n|0)>15|(a|0)>(n|0))){n=r,i[n>>2]=0,i[n+4>>2]=0,i[o>>2]=-1,i[r+12>>2]=-1;return}if(e=Wt(e,t,a+1|0,n)|0,o=(T()|0)&-15728641,a=F(n|0,0,52)|0,a=e|a,o=o|T()|0,e=r,i[e>>2]=a,i[e+4>>2]=o,e=r+12|0,Ht(a,o)|0){i[e>>2]=n;return}else{i[e>>2]=-1;return}}function _n(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0;if(n=e,t=i[n>>2]|0,n=i[n+4>>2]|0,!((t|0)==0&(n|0)==0)&&(r=P(t|0,n|0,52)|0,T()|0,r&=15,c=F(1,0,(r^15)*3|0)|0,t=Vr(c|0,T()|0,t|0,n|0)|0,n=T()|0,c=e,i[c>>2]=t,i[c+4>>2]=n,c=e+8|0,s=i[c>>2]|0,!((r|0)<(s|0)))){for(l=e+12|0,o=r;;){if((o|0)==(s|0)){r=5;break}if(u=(o|0)==(i[l>>2]|0),a=(15-o|0)*3|0,r=P(t|0,n|0,a|0)|0,T()|0,r&=7,u&(r|0)==1&!0){r=7;break}if(!((r|0)==7&!0)){r=10;break}if(u=F(1,0,a|0)|0,t=Vr(t|0,n|0,u|0,T()|0)|0,n=T()|0,u=e,i[u>>2]=t,i[u+4>>2]=n,(o|0)>(s|0))o=o+-1|0;else{r=10;break}}if((r|0)==5){u=e,i[u>>2]=0,i[u+4>>2]=0,i[c>>2]=-1,i[l>>2]=-1;return}else if((r|0)==7){s=F(1,0,a|0)|0,s=Vr(t|0,n|0,s|0,T()|0)|0,c=T()|0,u=e,i[u>>2]=s,i[u+4>>2]=c,i[l>>2]=o+-1;return}else if((r|0)==10)return}}function vn(e){e=+e;var t=0;return t=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function yn(e,t){return e|=0,t|=0,+l(+(a[e>>3]-+a[t>>3]))<17453292519943298e-27?(t=+l(+(a[e+8>>3]-+a[t+8>>3]))<17453292519943298e-27,t|0):(t=0,t|0)}function bn(e,t){switch(e=+e,t|=0,t|0){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e;break;default:}return+e}function xn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+p(+((i-r)*.5)),n=+p(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(f(+i)*+f(+r)*n),+(v(+ +u(+n),+ +u(+(1-n)))*2)}function Sn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+p(+((i-r)*.5)),n=+p(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(f(+i)*+f(+r)*n),+(v(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475)}function Cn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0;return i=+a[t>>3],r=+a[e>>3],o=+p(+((i-r)*.5)),n=+p(+((a[t+8>>3]-+a[e+8>>3])*.5)),n=o*o+n*(f(+i)*+f(+r)*n),+(v(+ +u(+n),+ +u(+(1-n)))*2*6371.007180918475*1e3)}function wn(e,t){e|=0,t|=0;var n=0,r=0,i=0,o=0,s=0;return o=+a[t>>3],r=+f(+o),i=a[t+8>>3]-+a[e+8>>3],s=r*+p(+i),n=+a[e>>3],+ +v(+s,+(p(+o)*+f(+n)-f(+i)*(r*+p(+n))))}function Tn(e,t,n,r){e|=0,t=+t,n=+n,r|=0;var o=0,s=0,c=0,u=0;if(n<1e-16){i[r>>2]=i[e>>2],i[r+4>>2]=i[e+4>>2],i[r+8>>2]=i[e+8>>2],i[r+12>>2]=i[e+12>>2];return}s=t<0?t+6.283185307179586:t,s=t>=6.283185307179586?s+-6.283185307179586:s;do if(s<1e-16)t=+a[e>>3]+n,a[r>>3]=t,o=r;else{if(o=+l(+(s+-3.141592653589793))<1e-16,t=+a[e>>3],o){t-=n,a[r>>3]=t,o=r;break}if(c=+f(+n),n=+p(+n),t=c*+p(+t)+f(+s)*(n*+f(+t)),t=t>1?1:t,t=+g(+(t<-1?-1:t)),a[r>>3]=t,+l(+(t+-1.5707963267948966))<1e-16){a[r>>3]=1.5707963267948966,a[r+8>>3]=0;return}if(+l(+(t+1.5707963267948966))<1e-16){a[r>>3]=-1.5707963267948966,a[r+8>>3]=0;return}if(u=1/f(+t),s=n*+p(+s)*u,n=+a[e>>3],t=u*((c-p(+t)*+p(+n))/f(+n)),c=s>1?1:s,t=t>1?1:t,t=+a[e+8>>3]+ +v(+(c<-1?-1:c),+(t<-1?-1:t)),t>3.141592653589793)do t+=-6.283185307179586;while(t>3.141592653589793);if(t<-3.141592653589793)do t+=6.283185307179586;while(t<-3.141592653589793);a[r+8>>3]=t;return}while(0);if(+l(+(t+-1.5707963267948966))<1e-16){a[o>>3]=1.5707963267948966,a[r+8>>3]=0;return}if(+l(+(t+1.5707963267948966))<1e-16){a[o>>3]=-1.5707963267948966,a[r+8>>3]=0;return}if(t=+a[e+8>>3],t>3.141592653589793)do t+=-6.283185307179586;while(t>3.141592653589793);if(t<-3.141592653589793)do t+=6.283185307179586;while(t<-3.141592653589793);a[r+8>>3]=t}function En(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20656+(e<<3)>>3],t=0,t|0)}function Dn(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20784+(e<<3)>>3],t=0,t|0)}function On(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[20912+(e<<3)>>3],t=0,t|0)}function kn(e,t){return e|=0,t|=0,e>>>0>15?(t=4,t|0):(a[t>>3]=+a[21040+(e<<3)>>3],t=0,t|0)}function An(e,t){e|=0,t|=0;var n=0;return e>>>0>15?(t=4,t|0):(n=Xn(7,0,e,((e|0)<0)<<31>>31)|0,n=qr(n|0,T()|0,120,0)|0,e=T()|0,i[t>>2]=n|2,i[t+4>>2]=e,t=0,t|0)}function jn(e,t,n){e|=0,t|=0,n|=0;var r=0,i=0,o=0,s=0,c=0,l=0,d=0,h=0,g=0,y=0;return y=+a[t>>3],h=+a[e>>3],l=+p(+((y-h)*.5)),o=+a[t+8>>3],d=+a[e+8>>3],s=+p(+((o-d)*.5)),c=+f(+h),g=+f(+y),s=l*l+s*(g*c*s),s=v(+ +u(+s),+ +u(+(1-s)))*2,l=+a[n>>3],y=+p(+((l-y)*.5)),r=+a[n+8>>3],o=+p(+((r-o)*.5)),i=+f(+l),o=y*y+o*(g*i*o),o=v(+ +u(+o),+ +u(+(1-o)))*2,l=+p(+((h-l)*.5)),r=+p(+((d-r)*.5)),r=l*l+r*(c*i*r),r=v(+ +u(+r),+ +u(+(1-r)))*2,i=(s+o+r)*.5,+(_(+ +u(+(m(+(i*.5))*+m(+((i-s)*.5))*m(+((i-o)*.5))*m(+((i-r)*.5)))))*4)}function Mn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0;if(l=j,j=j+192|0,s=l+168|0,c=l,o=sn(e,t,s)|0,o|0)return n=o,j=l,n|0;if(cn(e,t,c)|0&&E(27795,27190,415,27199),t=i[c>>2]|0,(t|0)>0){if(r=+jn(c+8|0,c+8+(((t|0)!=1&1)<<4)|0,s)+0,(t|0)!=1){e=1;do o=e,e=e+1|0,r+=+jn(c+8+(o<<4)|0,c+8+(((e|0)%(t|0)|0)<<4)|0,s);while((e|0)<(t|0))}}else r=0;return a[n>>3]=r,n=0,j=l,n|0}function Nn(e,t,n){return e|=0,t|=0,n|=0,e=Mn(e,t,n)|0,e|0||(a[n>>3]=a[n>>3]*6371.007180918475*6371.007180918475),e|0}function Pn(e,t,n){return e|=0,t|=0,n|=0,e=Mn(e,t,n)|0,e|0||(a[n>>3]=a[n>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Fn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,d=0,m=0,h=0;if(l=j,j=j+176|0,c=l,e=xt(e,t,c)|0,e|0)return c=e,j=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,j=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+p(+((r-m)*.5)),d=o,o=+a[c+8+(e<<4)+8>>3],d=+p(+((o-d)*.5)),d=h*h+d*(f(+r)*+f(+m)*d),s+=v(+ +u(+d),+ +u(+(1-d)))*2;while((e|0)<(t|0));return a[n>>3]=s,c=0,j=l,c|0}function In(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,d=0,m=0,h=0;if(l=j,j=j+176|0,c=l,e=xt(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,a[n>>3]=s,j=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,a[n>>3]=s,j=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+p(+((r-m)*.5)),d=o,o=+a[c+8+(e<<4)+8>>3],d=+p(+((o-d)*.5)),d=h*h+d*(f(+m)*+f(+r)*d),s+=v(+ +u(+d),+ +u(+(1-d)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,a[n>>3]=h,j=l,c|0}function Ln(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,d=0,m=0,h=0;if(l=j,j=j+176|0,c=l,e=xt(e,t,c)|0,e|0)return c=e,s=+a[n>>3],s*=6371.007180918475,s*=1e3,a[n>>3]=s,j=l,c|0;if(a[n>>3]=0,e=i[c>>2]|0,(e|0)<=1)return c=0,s=0,s*=6371.007180918475,s*=1e3,a[n>>3]=s,j=l,c|0;t=e+-1|0,e=0,r=+a[c+8>>3],o=+a[c+16>>3],s=0;do e=e+1|0,m=r,r=+a[c+8+(e<<4)>>3],h=+p(+((r-m)*.5)),d=o,o=+a[c+8+(e<<4)+8>>3],d=+p(+((o-d)*.5)),d=h*h+d*(f(+m)*+f(+r)*d),s+=v(+ +u(+d),+ +u(+(1-d)))*2;while((e|0)!=(t|0));return a[n>>3]=s,c=0,h=s,h*=6371.007180918475,h*=1e3,a[n>>3]=h,j=l,c|0}function Rn(e){e|=0;var t=0,n=0,r=0;return t=Br(1,12)|0,t||E(27280,27235,49,27293),n=e+4|0,r=i[n>>2]|0,r|0?(r=r+8|0,i[r>>2]=t,i[n>>2]=t,t|0):(i[e>>2]|0&&E(27310,27235,61,27333),r=e,i[r>>2]=t,i[n>>2]=t,t|0)}function zn(e,t){e|=0,t|=0;var n=0,r=0;return r=zr(24)|0,r||E(27347,27235,78,27361),i[r>>2]=i[t>>2],i[r+4>>2]=i[t+4>>2],i[r+8>>2]=i[t+8>>2],i[r+12>>2]=i[t+12>>2],i[r+16>>2]=0,t=e+4|0,n=i[t>>2]|0,n|0?(i[n+16>>2]=r,i[t>>2]=r,r|0):(i[e>>2]|0&&E(27376,27235,82,27361),i[e>>2]=r,i[t>>2]=r,r|0)}function Bn(e){e|=0;var t=0,n=0,r=0,a=0;if(e)for(r=1;;){if(t=i[e>>2]|0,t|0)do{if(n=i[t>>2]|0,n|0)do a=n,n=i[n+16>>2]|0,N(a);while(n|0);a=t,t=i[t+8>>2]|0,N(a)}while(t|0);if(t=e,e=i[e+8>>2]|0,r||N(t),e)r=0;else break}}function Vn(e){e|=0;var t=0,n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,D=0,O=0,k=0,A=0,ee=0,j=0,te=0,ne=0,re=0,ie=0;if(o=e+8|0,i[o>>2]|0)return ie=1,ie|0;if(r=i[e>>2]|0,!r)return ie=0,ie|0;t=r,n=0;do n=n+1|0,t=i[t+8>>2]|0;while(t|0);if(n>>>0<2)return ie=0,ie|0;ne=zr(n<<2)|0,ne||E(27396,27235,317,27415),te=zr(n<<5)|0,te||E(27437,27235,321,27415),i[e>>2]=0,T=e+4|0,i[T>>2]=0,i[o>>2]=0,n=0,j=0,w=0,m=0;a:for(;;){if(p=i[r>>2]|0,p){s=0,c=p;do{if(d=+a[c+8>>3],t=c,c=i[c+16>>2]|0,f=(c|0)==0,o=f?p:c,u=+a[o+8>>3],+l(+(d-u))>3.141592653589793){ie=14;break}s+=(u-d)*(+a[t>>3]+ +a[o>>3])}while(!f);if((ie|0)==14){ie=0,s=0,t=p;do C=+a[t+8>>3],ee=t+16|0,A=i[ee>>2]|0,A=A|0?A:p,S=+a[A+8>>3],s+=(+a[t>>3]+ +a[A>>3])*((S<0?S+6.283185307179586:S)-(C<0?C+6.283185307179586:C)),t=i[(t|0?ee:r)>>2]|0;while(t|0)}s>0?(i[ne+(j<<2)>>2]=r,j=j+1|0,o=w,t=m):ie=19}else ie=19;if((ie|0)==19){ie=0;do if(n){if(t=n+8|0,i[t>>2]|0){ie=21;break a}if(n=Br(1,12)|0,!n){ie=23;break a}i[t>>2]=n,o=n+4|0,c=n,t=m}else if(m){o=T,c=m+8|0,t=r,n=e;break}else if(i[e>>2]|0){ie=27;break a}else{o=T,c=e,t=r,n=e;break}while(0);if(i[c>>2]=r,i[o>>2]=r,c=te+(w<<5)|0,f=i[r>>2]|0,f){for(p=te+(w<<5)+8|0,a[p>>3]=17976931348623157e292,m=te+(w<<5)+24|0,a[m>>3]=17976931348623157e292,a[c>>3]=-17976931348623157e292,h=te+(w<<5)+16|0,a[h>>3]=-17976931348623157e292,b=17976931348623157e292,x=-17976931348623157e292,o=0,g=f,d=17976931348623157e292,v=17976931348623157e292,y=-17976931348623157e292,u=-17976931348623157e292;s=+a[g>>3],C=+a[g+8>>3],g=i[g+16>>2]|0,_=(g|0)==0,S=+a[(_?f:g)+8>>3],s<d&&(a[p>>3]=s,d=s),C<v&&(a[m>>3]=C,v=C),s>y?a[c>>3]=s:s=y,C>u&&(a[h>>3]=C,u=C),b=C>0&C<b?C:b,x=C<0&C>x?C:x,o|=+l(+(C-S))>3.141592653589793,!_;)y=s;o&&(a[h>>3]=x,a[m>>3]=b)}else i[c>>2]=0,i[c+4>>2]=0,i[c+8>>2]=0,i[c+12>>2]=0,i[c+16>>2]=0,i[c+20>>2]=0,i[c+24>>2]=0,i[c+28>>2]=0;o=w+1|0}if(ee=r+8|0,r=i[ee>>2]|0,i[ee>>2]=0,r)w=o,m=t;else{ie=45;break}}if((ie|0)==21)E(27213,27235,35,27247);else if((ie|0)==23)E(27267,27235,37,27247);else if((ie|0)==27)E(27310,27235,61,27333);else if((ie|0)==45){b:do if((j|0)>0){for(ee=(o|0)==0,k=o<<2,A=(e|0)==0,O=0,t=0;;){if(D=i[ne+(O<<2)>>2]|0,ee)ie=73;else{if(w=zr(k)|0,!w){ie=50;break}if(T=zr(k)|0,!T){ie=52;break}c:do if(A)n=0;else{for(o=0,n=0,c=e;r=te+(o<<5)|0,Hn(i[c>>2]|0,r,i[D>>2]|0)|0?(i[w+(n<<2)>>2]=c,i[T+(n<<2)>>2]=r,_=n+1|0):_=n,c=i[c+8>>2]|0,c;)o=o+1|0,n=_;if((_|0)>0)if(r=i[w>>2]|0,(_|0)==1)n=r;else for(h=0,g=-1,n=r,m=r;;){for(f=i[m>>2]|0,r=0,c=0;o=i[i[w+(c<<2)>>2]>>2]|0,p=(o|0)==(f|0)?r:r+((Hn(o,i[T+(c<<2)>>2]|0,i[f>>2]|0)|0)&1)|0,c=c+1|0,(c|0)!=(_|0);)r=p;if(o=(p|0)>(g|0),n=o?m:n,r=h+1|0,(r|0)==(_|0))break c;h=r,g=o?p:g,m=i[w+(r<<2)>>2]|0}else n=0}while(0);if(N(w),N(T),n){if(o=n+4|0,r=i[o>>2]|0,r)n=r+8|0;else if(i[n>>2]|0){ie=70;break}i[n>>2]=D,i[o>>2]=D}else ie=73}if((ie|0)==73){if(ie=0,t=i[D>>2]|0,t|0)do T=t,t=i[t+16>>2]|0,N(T);while(t|0);N(D),t=1}if(O=O+1|0,(O|0)>=(j|0)){re=t;break b}}(ie|0)==50?E(27452,27235,249,27471):(ie|0)==52?E(27490,27235,252,27471):(ie|0)==70&&E(27310,27235,61,27333)}else re=0;while(0);return N(ne),N(te),ie=re,ie|0}return 0}function Hn(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;if(!(Fe(t,n)|0)||(t=Ne(t)|0,r=+a[n>>3],o=+a[n+8>>3],o=t&o<0?o+6.283185307179586:o,e=i[e>>2]|0,!e))return e=0,e|0;if(t){t=0,d=o,n=e;a:for(;;){for(;c=+a[n>>3],o=+a[n+8>>3],n=n+16|0,f=i[n>>2]|0,f=f|0?f:e,s=+a[f>>3],l=+a[f+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,r<s|r>u;)if(n=i[n>>2]|0,!n){n=22;break a}if(l=c<0?c+6.283185307179586:c,c=o<0?o+6.283185307179586:o,d=l==d|c==d?d+-2220446049250313e-31:d,u=l+(c-l)*((r-s)/(u-s)),(u<0?u+6.283185307179586:u)>d&&(t^=1),n=i[n>>2]|0,!n){n=22;break}}if((n|0)==22)return t|0}else{t=0,d=o,n=e;b:for(;;){for(;c=+a[n>>3],o=+a[n+8>>3],n=n+16|0,f=i[n>>2]|0,f=f|0?f:e,s=+a[f>>3],l=+a[f+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,r<s|r>u;)if(n=i[n>>2]|0,!n){n=22;break b}if(d=c==d|o==d?d+-2220446049250313e-31:d,c+(o-c)*((r-s)/(u-s))>d&&(t^=1),n=i[n>>2]|0,!n){n=22;break}}if((n|0)==22)return t|0}return 0}function Un(e,t,n,a,o){e|=0,t|=0,n|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(b=j,j=j+32|0,y=b+16|0,v=b,s=P(e|0,t|0,52)|0,T()|0,s&=15,h=P(n|0,a|0,52)|0,T()|0,(s|0)!=(h&15|0))return y=12,j=b,y|0;if(d=P(e|0,t|0,45)|0,T()|0,d&=127,f=P(n|0,a|0,45)|0,T()|0,f&=127,d>>>0>121|f>>>0>121)return y=5,j=b,y|0;if(h=(d|0)!=(f|0),h){if(l=ke(d,f)|0,(l|0)==7)return y=1,j=b,y|0;u=ke(f,d)|0,(u|0)==7?E(27514,27538,161,27548):(g=l,c=u)}else g=0,c=0;p=xe(d)|0,m=xe(f)|0,i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0;do if(g){if(f=i[4272+(d*28|0)+(g<<2)>>2]|0,l=(f|0)>0,!m)if(l){d=0,u=n,l=a;do u=en(u,l)|0,l=T()|0,c=ot(c)|0,d=d+1|0;while((d|0)!=(f|0));f=c,d=u,u=l}else f=c,d=n,u=a;else if(l){d=0,u=n,l=a;do u=$t(u,l)|0,l=T()|0,c=ot(c)|0,(c|0)==1&&(c=ot(1)|0),d=d+1|0;while((d|0)!=(f|0));f=c,d=u,u=l}else f=c,d=n,u=a;if(an(d,u,y)|0,h||E(27563,27538,191,27548),l=(p|0)!=0,c=(m|0)!=0,l&c&&E(27590,27538,192,27548),l){if(c=Xt(e,t)|0,(c|0)==7){s=5;break}if(r[22e3+(c*7|0)+g>>0]|0){s=1;break}u=i[21168+(c*28|0)+(g<<2)>>2]|0,d=u}else if(c){if(c=Xt(d,u)|0,(c|0)==7){s=5;break}if(r[22e3+(c*7|0)+f>>0]|0){s=1;break}d=0,u=i[21168+(f*28|0)+(c<<2)>>2]|0}else d=0,u=0;if((d|u|0)<0)s=5;else{if((u|0)>0){l=y+4|0,c=0;do it(l),c=c+1|0;while((c|0)!=(u|0))}if(i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,nt(v,g),s|0)for(;nn(s)|0?et(v):tt(v),(s|0)>1;)s=s+-1|0;if((d|0)>0){s=0;do it(v),s=s+1|0;while((s|0)!=(d|0))}_=y+4|0,M(_,v,_),Ge(_),_=51}}else if(an(n,a,y)|0,(p|0)!=0&(m|0)!=0)if((f|0)!=(d|0)&&E(27621,27538,261,27548),c=Xt(e,t)|0,s=Xt(n,a)|0,(c|0)==7|(s|0)==7)s=5;else if(r[22e3+(c*7|0)+s>>0]|0)s=1;else if(c=i[21168+(c*28|0)+(s<<2)>>2]|0,(c|0)>0){l=y+4|0,s=0;do it(l),s=s+1|0;while((s|0)!=(c|0));_=51}else _=51;else _=51;while(0);return(_|0)==51&&(s=y+4|0,i[o>>2]=i[s>>2],i[o+4>>2]=i[s+4>>2],i[o+8>>2]=i[s+8>>2],s=0),y=s,j=b,y|0}function Wn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(g=j,j=j+48|0,u=g+36|0,s=g+24|0,c=g+12|0,l=g,a=P(e|0,t|0,52)|0,T()|0,a&=15,p=P(e|0,t|0,45)|0,T()|0,p&=127,p>>>0>121)return r=5,j=g,r|0;if(d=xe(p)|0,F(a|0,0,52)|0,_=T()|134225919,o=r,i[o>>2]=-1,i[o+4>>2]=_,!a)return a=Ye(n)|0,(a|0)==7||(a=Oe(p,a)|0,(a|0)==127)?(_=1,j=g,_|0):(m=F(a|0,0,45)|0,h=T()|0,p=r,h=i[p+4>>2]&-1040385|h,_=r,i[_>>2]=i[p>>2]|m,i[_+4>>2]=h,_=0,j=g,_|0);for(i[u>>2]=i[n>>2],i[u+4>>2]=i[n+4>>2],i[u+8>>2]=i[n+8>>2],n=a;;){if(o=n,n=n+-1|0,i[s>>2]=i[u>>2],i[s+4>>2]=i[u+4>>2],i[s+8>>2]=i[u+8>>2],nn(o)|0){if(a=Xe(u)|0,a|0){n=13;break}i[c>>2]=i[u>>2],i[c+4>>2]=i[u+4>>2],i[c+8>>2]=i[u+8>>2],et(c)}else{if(a=Ze(u)|0,a|0){n=13;break}i[c>>2]=i[u>>2],i[c+4>>2]=i[u+4>>2],i[c+8>>2]=i[u+8>>2],tt(c)}if(qe(s,c,l),Ge(l),a=r,y=i[a>>2]|0,a=i[a+4>>2]|0,b=(15-o|0)*3|0,v=F(7,0,b|0)|0,a&=~(T()|0),b=F(Ye(l)|0,0,b|0)|0,a=T()|0|a,_=r,i[_>>2]=b|y&~v,i[_+4>>2]=a,(o|0)<=1){n=14;break}}a:do if((n|0)!=13&&(n|0)==14)if((i[u>>2]|0)<=1&&(i[u+4>>2]|0)<=1&&(i[u+8>>2]|0)<=1){n=Ye(u)|0,a=Oe(p,n)|0,l=(a|0)==127?0:xe(a)|0;b:do if(n){if(d){if(a=Xt(e,t)|0,(a|0)==7){a=5;break a}if(o=i[21376+(a*28|0)+(n<<2)>>2]|0,(o|0)>0){a=n,n=0;do a=at(a)|0,n=n+1|0;while((n|0)!=(o|0))}else a=n;if((a|0)==1){a=9;break a}n=Oe(p,a)|0,(n|0)==127&&E(27648,27538,411,27678),xe(n)|0?E(27693,27538,412,27678):(h=n,m=o,f=a)}else h=a,m=0,f=n;if(c=i[4272+(p*28|0)+(f<<2)>>2]|0,(c|0)<=-1&&E(27724,27538,419,27678),!l){if((m|0)<0){a=5;break a}if(m|0){o=r,a=0,n=i[o>>2]|0,o=i[o+4>>2]|0;do n=Qt(n,o)|0,o=T()|0,b=r,i[b>>2]=n,i[b+4>>2]=o,a=a+1|0;while((a|0)<(m|0))}if((c|0)<=0){a=h,n=58;break}for(o=r,a=0,n=i[o>>2]|0,o=i[o+4>>2]|0;;)if(n=Qt(n,o)|0,o=T()|0,b=r,i[b>>2]=n,i[b+4>>2]=o,a=a+1|0,(a|0)==(c|0)){a=h,n=58;break b}}if(s=ke(h,p)|0,(s|0)==7&&E(27514,27538,428,27678),a=r,n=i[a>>2]|0,a=i[a+4>>2]|0,(c|0)>0){o=0;do n=Qt(n,a)|0,a=T()|0,b=r,i[b>>2]=n,i[b+4>>2]=a,o=o+1|0;while((o|0)!=(c|0))}if(a=Xt(n,a)|0,(a|0)==7&&E(27795,27538,440,27678),n=Se(h)|0,n=i[(n?21792:21584)+(s*28|0)+(a<<2)>>2]|0,(n|0)<0&&E(27795,27538,454,27678),!n)a=h,n=58;else{s=r,a=0,o=i[s>>2]|0,s=i[s+4>>2]|0;do o=Zt(o,s)|0,s=T()|0,b=r,i[b>>2]=o,i[b+4>>2]=s,a=a+1|0;while((a|0)<(n|0));a=h,n=58}}else if((d|0)!=0&(l|0)!=0){if(n=Xt(e,t)|0,o=r,o=Xt(i[o>>2]|0,i[o+4>>2]|0)|0,(n|0)==7|(o|0)==7){a=5;break a}if(o=i[21376+(n*28|0)+(o<<2)>>2]|0,(o|0)<0){a=5;break a}if(!o)n=59;else{c=r,n=0,s=i[c>>2]|0,c=i[c+4>>2]|0;do s=Qt(s,c)|0,c=T()|0,b=r,i[b>>2]=s,i[b+4>>2]=c,n=n+1|0;while((n|0)<(o|0));n=58}}else n=58;while(0);if((n|0)==58&&l&&(n=59),(n|0)==59&&(b=r,(Xt(i[b>>2]|0,i[b+4>>2]|0)|0)==1)){a=9;break}b=r,v=i[b>>2]|0,b=i[b+4>>2]&-1040385,y=F(a|0,0,45)|0,b=b|T()|0,a=r,i[a>>2]=v|y,i[a+4>>2]=b,a=0}else a=1;while(0);return b=a,j=g,b|0}function Gn(e,t,n,r,i,a){e|=0,t|=0,n|=0,r|=0,i|=0,a|=0;var o=0,s=0;return s=j,j=j+16|0,o=s,i?e=15:(e=Un(e,t,n,r,o)|0,e||=(ut(o,a),0)),j=s,e|0}function Kn(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var a=0,o=0;return o=j,j=j+16|0,a=o,r?n=15:(n=dt(n,a)|0,n||=Wn(e,t,a,i)|0),j=o,n|0}function qn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0;return l=j,j=j+32|0,s=l+12|0,c=l,o=Un(e,t,e,t,s)|0,o|0?(c=o,j=l,c|0):(e=Un(e,t,n,r,c)|0,e|0?(c=e,j=l,c|0):(s=lt(s,c)|0,c=a,i[c>>2]=s,i[c+4>>2]=((s|0)<0)<<31>>31,c=0,j=l,c|0))}function Jn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0;return l=j,j=j+32|0,s=l+12|0,c=l,o=Un(e,t,e,t,s)|0,!o&&(o=Un(e,t,n,r,c)|0,!o)?(r=lt(s,c)|0,r=Vr(r|0,((r|0)<0)<<31>>31|0,1,0)|0,s=T()|0,c=a,i[c>>2]=r,i[c+4>>2]=s,c=0,j=l,c|0):(c=o,j=l,c|0)}function Yn(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,D=0,O=0;if(D=j,j=j+48|0,C=D+24|0,s=D+12|0,w=D,o=Un(e,t,e,t,C)|0,!o&&(o=Un(e,t,n,r,s)|0,!o)){x=lt(C,s)|0,S=((x|0)<0)<<31>>31,i[C>>2]=0,i[C+4>>2]=0,i[C+8>>2]=0,i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,Un(e,t,e,t,C)|0&&E(27795,27538,692,27747),Un(e,t,n,r,s)|0&&E(27795,27538,697,27747),ft(C),ft(s),f=x|0?1/(x|0):0,n=i[C>>2]|0,_=f*+((i[s>>2]|0)-n|0),v=C+4|0,r=i[v>>2]|0,y=f*+((i[s+4>>2]|0)-r|0),b=C+8|0,o=i[b>>2]|0,f*=+((i[s+8>>2]|0)-o|0),i[w>>2]=n,p=w+4|0,i[p>>2]=r,m=w+8|0,i[m>>2]=o;a:do if((x|0)<0)o=0;else for(h=0,g=0;;){u=+(g>>>0)+4294967296*(h|0),O=_*u+ +(n|0),c=y*u+ +(r|0),u=f*u+ +(o|0),n=~~+ei(+O),s=~~+ei(+c),o=~~+ei(+u),O=+l(+(+(n|0)-O)),c=+l(+(+(s|0)-c)),u=+l(+(+(o|0)-u));do if(O>c&O>u)n=0-(s+o)|0,r=s;else if(d=0-n|0,c>u){r=d-o|0;break}else{r=s,o=d-s|0;break}while(0);if(i[w>>2]=n,i[p>>2]=r,i[m>>2]=o,pt(w),o=Wn(e,t,w,a+(g<<3)|0)|0,o|0)break a;if(!((h|0)<(S|0)|(h|0)==(S|0)&g>>>0<x>>>0)){o=0;break a}n=Vr(g|0,h|0,1,0)|0,r=T()|0,h=r,g=n,n=i[C>>2]|0,r=i[v>>2]|0,o=i[b>>2]|0}while(0);return w=o,j=D,w|0}return w=o,j=D,w|0}function Xn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0;if((n|0)==0&(r|0)==0)return i=0,a=1,w(i|0),a|0;a=e,i=t,e=1,t=0;do o=(n&1|0)==0&!0,e=qr((o?1:a)|0,(o?0:i)|0,e|0,t|0)|0,t=T()|0,n=Xr(n|0,r|0,1)|0,r=T()|0,a=qr(a|0,i|0,a|0,i|0)|0,i=T()|0;while(!((n|0)==0&(r|0)==0));return w(t|0),e|0}function Zn(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,d=0,p=0;l=j,j=j+16|0,s=l,c=P(e|0,t|0,52)|0,T()|0,c&=15;do if(c){if(o=sn(e,t,s)|0,!o){d=+a[s>>3],u=1/f(+d),p=+a[25968+(c<<3)>>3],a[n>>3]=d+p,a[n+8>>3]=d-p,d=+a[s+8>>3],u=p*u,a[n+16>>3]=u+d,a[n+24>>3]=d-u;break}return c=o,j=l,c|0}else{if(o=P(e|0,t|0,45)|0,T()|0,o&=127,o>>>0>121)return c=5,j=l,c|0;s=22064+(o<<5)|0,i[n>>2]=i[s>>2],i[n+4>>2]=i[s+4>>2],i[n+8>>2]=i[s+8>>2],i[n+12>>2]=i[s+12>>2],i[n+16>>2]=i[s+16>>2],i[n+20>>2]=i[s+20>>2],i[n+24>>2]=i[s+24>>2],i[n+28>>2]=i[s+28>>2];break}while(0);return He(n,r?1.4:1.1),r=26096+(c<<3)|0,(i[r>>2]|0)==(e|0)&&(i[r+4>>2]|0)==(t|0)&&(a[n>>3]=1.5707963267948966),c=26224+(c<<3)|0,(i[c>>2]|0)==(e|0)&&(i[c+4>>2]|0)==(t|0)&&(a[n+8>>3]=-1.5707963267948966),+a[n>>3]!=1.5707963267948966&&+a[n+8>>3]!=-1.5707963267948966?(c=0,j=l,c|0):(a[n+16>>3]=3.141592653589793,a[n+24>>3]=-3.141592653589793,c=0,j=l,c|0)}function Qn(e,t,n,a){e|=0,t|=0,n|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0;d=j,j=j+48|0,c=d+32|0,s=d+40|0,l=d,zt(c,0,0,0),u=i[c>>2]|0,c=i[c+4>>2]|0;do if(n>>>0<=15){if(o=ar(a)|0,o|0){a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=o,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}if(o=Br((i[t+8>>2]|0)+1|0,32)|0,o){or(t,o),f=l,i[f>>2]=u,i[f+4>>2]=c,i[l+8>>2]=0,i[l+12>>2]=n,i[l+16>>2]=a,i[l+20>>2]=t,i[l+24>>2]=o,r[l+28>>0]=0,u=l+29|0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}else{a=l,i[a>>2]=0,i[a+4>>2]=0,i[l+8>>2]=13,i[l+12>>2]=-1,a=l+16|0,u=l+29|0,i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,r[a+12>>0]=0,r[u>>0]=r[s>>0]|0,r[u+1>>0]=r[s+1>>0]|0,r[u+2>>0]=r[s+2>>0]|0;break}}else u=l,i[u>>2]=0,i[u+4>>2]=0,i[l+8>>2]=4,i[l+12>>2]=-1,u=l+16|0,f=l+29|0,i[u>>2]=0,i[u+4>>2]=0,i[u+8>>2]=0,r[u+12>>0]=0,r[f>>0]=r[s>>0]|0,r[f+1>>0]=r[s+1>>0]|0,r[f+2>>0]=r[s+2>>0]|0;while(0);$n(l),i[e>>2]=i[l>>2],i[e+4>>2]=i[l+4>>2],i[e+8>>2]=i[l+8>>2],i[e+12>>2]=i[l+12>>2],i[e+16>>2]=i[l+16>>2],i[e+20>>2]=i[l+20>>2],i[e+24>>2]=i[l+24>>2],i[e+28>>2]=i[l+28>>2],j=d}function $n(e){e|=0;var t=0,n=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;if(S=j,j=j+336|0,h=S+168|0,g=S,a=e,n=i[a>>2]|0,a=i[a+4>>2]|0,(n|0)==0&(a|0)==0){j=S;return}if(t=e+28|0,r[t>>0]|0?(n=er(n,a)|0,a=T()|0):r[t>>0]=1,x=e+20|0,!(i[i[x>>2]>>2]|0)){t=e+24|0,n=i[t>>2]|0,n|0&&N(n),b=e,i[b>>2]=0,i[b+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[e+16>>2]=0,i[t>>2]=0,j=S;return}b=e+16|0,t=i[b>>2]|0,o=t&15;a:do if((n|0)==0&(a|0)==0)y=e+24|0;else{_=e+12|0,p=(o|0)==3,f=t&255,u=(o|1)==3,m=e+24|0,d=(o+-1|0)>>>0<3,c=(o|2)==3,l=g+8|0;b:for(;;){if(s=P(n|0,a|0,52)|0,T()|0,s&=15,(s|0)==(i[_>>2]|0)){switch(f&15){case 0:case 2:case 3:if(o=sn(n,a,h)|0,o|0){v=15;break b}if(sr(i[x>>2]|0,i[m>>2]|0,h)|0){v=19;break b}break;default:}if(u&&(o=i[(i[x>>2]|0)+4>>2]|0,i[h>>2]=i[o>>2],i[h+4>>2]=i[o+4>>2],i[h+8>>2]=i[o+8>>2],i[h+12>>2]=i[o+12>>2],Fe(26832,h)|0)){if(rn(i[(i[x>>2]|0)+4>>2]|0,s,g)|0){v=25;break}if(o=g,(i[o>>2]|0)==(n|0)&&(i[o+4>>2]|0)==(a|0)){v=29;break}}if(d){if(o=cn(n,a,h)|0,o|0){v=32;break}if(Zn(n,a,g,0)|0){v=36;break}if(c&&cr(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}if(u&&ur(i[x>>2]|0,i[m>>2]|0,h,g)|0){v=42;break}}if(p){if(t=Zn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=45;break}if(Ie(o,h)|0){if(ze(g,h),Re(h,i[m>>2]|0)|0){v=53;break}if(sr(i[x>>2]|0,i[m>>2]|0,l)|0){v=53;break}if(ur(i[x>>2]|0,i[m>>2]|0,g,h)|0){v=53;break}}}}do if((s|0)<(i[_>>2]|0)){if(t=Zn(n,a,h,1)|0,o=i[m>>2]|0,t|0){v=58;break b}if(!(Ie(o,h)|0)){v=73;break}if(Re(i[m>>2]|0,h)|0&&(ze(g,h),cr(i[x>>2]|0,i[m>>2]|0,g,h)|0)){v=65;break b}if(n=Gt(n,a,s+1|0,g)|0,n|0){v=67;break b}a=g,n=i[a>>2]|0,a=i[a+4>>2]|0}else v=73;while(0);if((v|0)==73&&(v=0,n=er(n,a)|0,a=T()|0),(n|0)==0&(a|0)==0){y=m;break a}}switch(v|0){case 15:t=i[m>>2]|0,t|0&&N(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,v=20;break;case 19:i[e>>2]=n,i[e+4>>2]=a,v=20;break;case 25:E(27795,27761,470,27772);break;case 29:i[e>>2]=n,i[e+4>>2]=a,j=S;return;case 32:t=i[m>>2]|0,t|0&&N(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=o,j=S;return;case 36:E(27795,27761,493,27772);break;case 42:i[e>>2]=n,i[e+4>>2]=a,j=S;return;case 45:o|0&&N(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=55;break;case 53:i[e>>2]=n,i[e+4>>2]=a,v=55;break;case 58:o|0&&N(o),v=e,i[v>>2]=0,i[v+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=t,v=71;break;case 65:i[e>>2]=n,i[e+4>>2]=a,v=71;break;case 67:t=i[m>>2]|0,t|0&&N(t),y=e,i[y>>2]=0,i[y+4>>2]=0,i[x>>2]=0,i[_>>2]=-1,i[b>>2]=0,i[m>>2]=0,i[e+8>>2]=n,j=S;return}if((v|0)==20){j=S;return}else if((v|0)==55){j=S;return}else if((v|0)==71){j=S;return}}while(0);t=i[y>>2]|0,t|0&&N(t),v=e,i[v>>2]=0,i[v+4>>2]=0,i[e+8>>2]=0,i[x>>2]=0,i[e+12>>2]=-1,i[b>>2]=0,i[y>>2]=0,j=S}function er(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0;f=j,j=j+16|0,d=f,r=P(e|0,t|0,52)|0,T()|0,r&=15,n=P(e|0,t|0,45)|0,T()|0;do if(r){for(;n=F(r+4095|0,0,52)|0,a=T()|0|t&-15728641,o=(15-r|0)*3|0,s=F(7,0,o|0)|0,c=T()|0,n=n|e|s,a|=c,l=P(e|0,t|0,o|0)|0,T()|0,l&=7,r=r+-1|0,!(l>>>0<6);)if(r)t=a,e=n;else{u=4;break}if((u|0)==4){n=P(n|0,a|0,45)|0,T()|0;break}return d=(l|0)==0&(Ht(n,a)|0)!=0,d=F((d?2:1)+l|0,0,o|0)|0,u=T()|0|t&~c,d|=e&~s,w(u|0),j=f,d|0}while(0);return n&=127,n>>>0>120?(u=0,d=0,w(u|0),j=f,d|0):(zt(d,0,n+1|0,0),u=i[d+4>>2]|0,d=i[d>>2]|0,w(u|0),j=f,d|0)}function tr(e,t,n,r,a,o){e|=0,t|=0,n|=0,r|=0,a|=0,o|=0;var s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0;_=j,j=j+160|0,f=_+80|0,c=_+64|0,p=_+112|0,g=_,Qn(f,e,t,n),u=f,hn(c,i[u>>2]|0,i[u+4>>2]|0,t),u=c,l=i[u>>2]|0,u=i[u+4>>2]|0,s=i[f+8>>2]|0,m=p+4|0,i[m>>2]=i[f>>2],i[m+4>>2]=i[f+4>>2],i[m+8>>2]=i[f+8>>2],i[m+12>>2]=i[f+12>>2],i[m+16>>2]=i[f+16>>2],i[m+20>>2]=i[f+20>>2],i[m+24>>2]=i[f+24>>2],i[m+28>>2]=i[f+28>>2],m=g,i[m>>2]=l,i[m+4>>2]=u,m=g+8|0,i[m>>2]=s,e=g+12|0,t=p,n=e+36|0;do i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0;while((e|0)<(n|0));if(p=g+48|0,i[p>>2]=i[c>>2],i[p+4>>2]=i[c+4>>2],i[p+8>>2]=i[c+8>>2],i[p+12>>2]=i[c+12>>2],(l|0)==0&(u|0)==0)return g=s,j=_,g|0;n=g+16|0,d=g+24|0,f=g+28|0,s=0,c=0,t=l,e=u;do{if(!((s|0)<(a|0)|(s|0)==(a|0)&c>>>0<r>>>0)){h=4;break}if(u=c,c=Vr(c|0,s|0,1,0)|0,s=T()|0,u=o+(u<<3)|0,i[u>>2]=t,i[u+4>>2]=e,_n(p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0,(t|0)==0&(e|0)==0){if($n(n),t=n,e=i[t>>2]|0,t=i[t+4>>2]|0,(e|0)==0&(t|0)==0){h=10;break}gn(e,t,i[f>>2]|0,p),e=p,t=i[e>>2]|0,e=i[e+4>>2]|0}u=g,i[u>>2]=t,i[u+4>>2]=e}while(!((t|0)==0&(e|0)==0));return(h|0)==4?(e=g+40|0,t=i[e>>2]|0,t|0&&N(t),h=g+16|0,i[h>>2]=0,i[h+4>>2]=0,i[d>>2]=0,i[g+36>>2]=0,i[f>>2]=-1,i[g+32>>2]=0,i[e>>2]=0,gn(0,0,0,p),i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=0,g=14,j=_,g|0):((h|0)==10&&(i[g>>2]=0,i[g+4>>2]=0,i[m>>2]=i[d>>2]),g=i[m>>2]|0,j=_,g|0)}function nr(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s=0,c=0,u=0,d=0,p=0,m=0,h=0,g=0,_=0,v=0;if(g=j,j=j+48|0,p=g+32|0,d=g+40|0,m=g,!(i[e>>2]|0))return h=o,i[h>>2]=0,i[h+4>>2]=0,h=0,j=g,h|0;zt(p,0,0,0),u=p,s=i[u>>2]|0,u=i[u+4>>2]|0;do if(t>>>0>15)h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=4,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[d>>0]|0,r[n+1>>0]=r[d+1>>0]|0,r[n+2>>0]=r[d+2>>0]|0,n=4,h=9;else{if(n=ar(n)|0,n|0){p=m,i[p>>2]=0,i[p+4>>2]=0,i[m+8>>2]=n,i[m+12>>2]=-1,p=m+16|0,h=m+29|0,i[p>>2]=0,i[p+4>>2]=0,i[p+8>>2]=0,r[p+12>>0]=0,r[h>>0]=r[d>>0]|0,r[h+1>>0]=r[d+1>>0]|0,r[h+2>>0]=r[d+2>>0]|0,h=9;break}if(n=Br((i[e+8>>2]|0)+1|0,32)|0,!n){h=m,i[h>>2]=0,i[h+4>>2]=0,i[m+8>>2]=13,i[m+12>>2]=-1,h=m+16|0,n=m+29|0,i[h>>2]=0,i[h+4>>2]=0,i[h+8>>2]=0,r[h+12>>0]=0,r[n>>0]=r[d>>0]|0,r[n+1>>0]=r[d+1>>0]|0,r[n+2>>0]=r[d+2>>0]|0,n=13,h=9;break}or(e,n),v=m,i[v>>2]=s,i[v+4>>2]=u,u=m+8|0,i[u>>2]=0,i[m+12>>2]=t,i[m+20>>2]=e,i[m+24>>2]=n,r[m+28>>0]=0,s=m+29|0,r[s>>0]=r[d>>0]|0,r[s+1>>0]=r[d+1>>0]|0,r[s+2>>0]=r[d+2>>0]|0,i[m+16>>2]=3,_=+Pe(n),_*=+Me(n),c=+l(+ +a[n>>3]),c=_/+f(+ +$r(+c,+ +l(+ +a[n+8>>3])))*6371.007180918475*6371.007180918475,s=m+12|0,n=i[s>>2]|0;a:do if((n|0)>0)do{if(En(n+-1|0,p)|0,!(c/+a[p>>3]>10))break a;v=i[s>>2]|0,n=v+-1|0,i[s>>2]=n}while((v|0)>1);while(0);if($n(m),s=o,i[s>>2]=0,i[s+4>>2]=0,s=m,n=i[s>>2]|0,s=i[s+4>>2]|0,!((n|0)==0&(s|0)==0))do Vt(n,s,t,p)|0,d=p,e=o,d=Vr(i[e>>2]|0,i[e+4>>2]|0,i[d>>2]|0,i[d+4>>2]|0)|0,e=T()|0,v=o,i[v>>2]=d,i[v+4>>2]=e,$n(m),v=m,n=i[v>>2]|0,s=i[v+4>>2]|0;while(!((n|0)==0&(s|0)==0));n=i[u>>2]|0}while(0);return v=n,j=g,v|0}function rr(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;if(!(Fe(t,n)|0)||(t=Ne(t)|0,r=+a[n>>3],o=+a[n+8>>3],o=t&o<0?o+6.283185307179586:o,m=i[e>>2]|0,(m|0)<=0))return m=0,m|0;if(p=i[e+4>>2]|0,t){t=0,f=o,n=-1,e=0;a:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,r<s|r>u;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break a}else e=d,d=n,n=e;if(l=c<0?c+6.283185307179586:c,c=o<0?o+6.283185307179586:o,f=l==f|c==f?f+-2220446049250313e-31:f,u=l+(c-l)*((r-s)/(u-s)),(u<0?u+6.283185307179586:u)>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}else{t=0,f=o,n=-1,e=0;b:for(;;){for(d=e;c=+a[p+(d<<4)>>3],o=+a[p+(d<<4)+8>>3],e=(n+2|0)%(m|0)|0,s=+a[p+(e<<4)>>3],l=+a[p+(e<<4)+8>>3],c>s?(u=c,c=l):(u=s,s=c,c=o,o=l),r=r==s|r==u?r+2220446049250313e-31:r,r<s|r>u;)if(n=d+1|0,(n|0)>=(m|0)){n=22;break b}else e=d,d=n,n=e;if(f=c==f|o==f?f+-2220446049250313e-31:f,c+(o-c)*((r-s)/(u-s))>f&&(t^=1),e=d+1|0,(e|0)>=(m|0)){n=22;break}else n=d}if((n|0)==22)return t|0}return 0}function ir(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;if(_=i[e>>2]|0,!_){i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;return}if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,!((_|0)<=0)){for(h=i[e+4>>2]|0,f=17976931348623157e292,p=-17976931348623157e292,m=0,e=-1,s=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,r=-17976931348623157e292,g=0;n=+a[h+(g<<4)>>3],u=+a[h+(g<<4)+8>>3],e=e+2|0,o=+a[h+(((e|0)==(_|0)?0:e)<<4)+8>>3],n<s&&(a[v>>3]=n,s=n),u<c&&(a[y>>3]=u,c=u),n>d?a[t>>3]=n:n=d,u>r&&(a[b>>3]=u,r=u),f=u>0&u<f?u:f,p=u<0&u>p?u:p,m|=+l(+(u-o))>3.141592653589793,e=g+1|0,(e|0)!=(_|0);)x=g,d=n,g=e,e=x;m&&(a[b>>3]=p,a[y>>3]=f)}}function ar(e){return e|=0,(e>>>0<4?0:15)|0}function or(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,c=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(_=i[e>>2]|0,_){if(v=t+8|0,a[v>>3]=17976931348623157e292,y=t+24|0,a[y>>3]=17976931348623157e292,a[t>>3]=-17976931348623157e292,b=t+16|0,a[b>>3]=-17976931348623157e292,(_|0)>0){for(o=i[e+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,r=0,n=-1,d=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,c=-17976931348623157e292,x=0;s=+a[o+(x<<4)>>3],p=+a[o+(x<<4)+8>>3],T=n+2|0,u=+a[o+(((T|0)==(_|0)?0:T)<<4)+8>>3],s<d&&(a[v>>3]=s,d=s),p<f&&(a[y>>3]=p,f=p),s>m?a[t>>3]=s:s=m,p>c&&(a[b>>3]=p,c=p),h=p>0&p<h?p:h,g=p<0&p>g?p:g,r|=+l(+(p-u))>3.141592653589793,n=x+1|0,(n|0)!=(_|0);)T=x,m=s,x=n,n=T;r&&(a[b>>3]=g,a[y>>3]=h)}}else i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,i[t+16>>2]=0,i[t+20>>2]=0,i[t+24>>2]=0,i[t+28>>2]=0;if(T=e+8|0,n=i[T>>2]|0,!((n|0)<=0)){w=e+12|0,C=0;do if(o=i[w>>2]|0,r=C,C=C+1|0,y=t+(C<<5)|0,b=i[o+(r<<3)>>2]|0,b){if(x=t+(C<<5)+8|0,a[x>>3]=17976931348623157e292,e=t+(C<<5)+24|0,a[e>>3]=17976931348623157e292,a[y>>3]=-17976931348623157e292,S=t+(C<<5)+16|0,a[S>>3]=-17976931348623157e292,(b|0)>0){for(_=i[o+(r<<3)+4>>2]|0,h=17976931348623157e292,g=-17976931348623157e292,o=0,r=-1,v=0,d=17976931348623157e292,f=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292;s=+a[_+(v<<4)>>3],m=+a[_+(v<<4)+8>>3],r=r+2|0,u=+a[_+(((r|0)==(b|0)?0:r)<<4)+8>>3],s<d&&(a[x>>3]=s,d=s),m<f&&(a[e>>3]=m,f=m),s>p?a[y>>3]=s:s=p,m>c&&(a[S>>3]=m,c=m),h=m>0&m<h?m:h,g=m<0&m>g?m:g,o|=+l(+(m-u))>3.141592653589793,r=v+1|0,(r|0)!=(b|0);)E=v,v=r,p=s,r=E;o&&(a[S>>3]=g,a[e>>3]=h)}}else i[y>>2]=0,i[y+4>>2]=0,i[y+8>>2]=0,i[y+12>>2]=0,i[y+16>>2]=0,i[y+20>>2]=0,i[y+24>>2]=0,i[y+28>>2]=0,n=i[T>>2]|0;while((C|0)<(n|0))}}function sr(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(!(rr(e,t,n)|0))return a=0,a|0;if(a=e+8|0,(i[a>>2]|0)<=0)return a=1,a|0;for(r=e+12|0,e=0;;){if(o=e,e=e+1|0,rr((i[r>>2]|0)+(o<<3)|0,t+(e<<5)|0,n)|0){e=0,r=6;break}if((e|0)>=(i[a>>2]|0)){e=1,r=6;break}}return(r|0)==6?e|0:0}function cr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(u=j,j=j+16|0,c=u,s=n+8|0,!(rr(e,t,s)|0))return l=0,j=u,l|0;l=e+8|0;a:do if((i[l>>2]|0)>0){for(o=e+12|0,a=0;;){if(d=a,a=a+1|0,rr((i[o>>2]|0)+(d<<3)|0,t+(a<<5)|0,s)|0){a=0;break}if((a|0)>=(i[l>>2]|0))break a}return j=u,a|0}while(0);if(lr(e,t,n,r)|0)return d=0,j=u,d|0;i[c>>2]=i[n>>2],i[c+4>>2]=s,a=i[l>>2]|0;b:do if((a|0)>0)for(e=e+12|0,s=0,o=a;;){if(a=i[e>>2]|0,(i[a+(s<<3)>>2]|0)>0){if(rr(c,r,i[a+(s<<3)+4>>2]|0)|0){a=0;break b}if(a=s+1|0,lr((i[e>>2]|0)+(s<<3)|0,t+(a<<5)|0,n,r)|0){a=0;break b}o=i[l>>2]|0}else a=s+1|0;if((a|0)<(o|0))s=a;else{a=1;break}}else a=1;while(0);return d=a,j=u,d|0}function lr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0;if(w=j,j=j+176|0,b=w+172|0,o=w+168|0,x=w,!(Ie(t,r)|0))return e=0,j=w,e|0;if(Le(t,r,b,o),ti(x|0,n|0,168)|0,(i[n>>2]|0)>0){t=0;do T=x+8+(t<<4)+8|0,y=+bn(+a[T>>3],i[o>>2]|0),a[T>>3]=y,t=t+1|0;while((t|0)<(i[n>>2]|0))}_=+a[r>>3],v=+a[r+8>>3],y=+bn(+a[r+16>>3],i[o>>2]|0),h=+bn(+a[r+24>>3],i[o>>2]|0);a:do if((i[e>>2]|0)>0){if(r=e+4|0,o=i[x>>2]|0,(o|0)<=0){for(t=0;;)if(t=t+1|0,(t|0)>=(i[e>>2]|0)){t=0;break a}}for(n=0;;){if(t=i[r>>2]|0,m=+a[t+(n<<4)>>3],g=+bn(+a[t+(n<<4)+8>>3],i[b>>2]|0),t=i[r>>2]|0,n=n+1|0,T=(n|0)%(i[e>>2]|0)|0,s=+a[t+(T<<4)>>3],c=+bn(+a[t+(T<<4)+8>>3],i[b>>2]|0),!(m>=_)|!(s>=_)&&!(m<=v)|!(s<=v)&&!(g<=h)|!(c<=h)&&!(g>=y)|!(c>=y)){p=s-m,d=c-g,t=0;do if(E=t,t=t+1|0,T=(t|0)==(o|0)?0:t,s=+a[x+8+(E<<4)+8>>3],c=+a[x+8+(T<<4)+8>>3]-s,l=+a[x+8+(E<<4)>>3],u=+a[x+8+(T<<4)>>3]-l,f=p*c-d*u,f!=0&&(S=g-s,C=m-l,u=(S*u-c*C)/f,!(u<0|u>1))&&(f=(p*S-d*C)/f,f>=0&f<=1)){t=1;break a}while((t|0)<(o|0))}if((n|0)>=(i[e>>2]|0)){t=0;break}}}else t=0;while(0);return E=t,j=w,E|0}function ur(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0;if(lr(e,t,n,r)|0)return o=1,o|0;if(o=e+8|0,(i[o>>2]|0)<=0)return o=0,o|0;for(a=e+12|0,e=0;;){if(s=e,e=e+1|0,lr((i[a>>2]|0)+(s<<3)|0,t+(e<<5)|0,n,r)|0){e=1,a=6;break}if((e|0)>=(i[o>>2]|0)){e=0,a=6;break}}return(a|0)==6?e|0:0}function dr(){return 8}function fr(){return 16}function pr(){return 168}function mr(){return 8}function hr(){return 16}function gr(){return 12}function _r(){return 8}function vr(e){return e|=0,+(+((i[e>>2]|0)>>>0)+4294967296*(i[e+4>>2]|0))}function yr(e){e|=0;var t=0,n=0;return n=+a[e>>3],t=+a[e+8>>3],+ +u(+(n*n+t*t))}function br(e,t,n,r,i){e|=0,t|=0,n|=0,r|=0,i|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;u=+a[e>>3],l=+a[t>>3]-u,c=+a[e+8>>3],s=+a[t+8>>3]-c,f=+a[n>>3],o=+a[r>>3]-f,p=+a[n+8>>3],d=+a[r+8>>3]-p,o=(o*(c-p)-(u-f)*d)/(l*d-s*o),a[i>>3]=u+l*o,a[i+8>>3]=c+s*o}function xr(e,t){return e|=0,t|=0,+l(+(a[e>>3]-+a[t>>3]))<1.1920928955078125e-7?(t=+l(+(a[e+8>>3]-+a[t+8>>3]))<1.1920928955078125e-7,t|0):(t=0,t|0)}function Sr(e,t){e|=0,t|=0;var n=0,r=0,i=0;return i=a[e>>3]-+a[t>>3],r=a[e+8>>3]-+a[t+8>>3],n=a[e+16>>3]-+a[t+16>>3],+(i*i+r*r+n*n)}function Cr(e,t){e|=0,t|=0;var n=0,r=0,i=0;n=+a[e>>3],r=+f(+n),n=+p(+n),a[t+16>>3]=n,n=+a[e+8>>3],i=r*+f(+n),a[t>>3]=i,n=r*+p(+n),a[t+8>>3]=n}function wr(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;if(o=j,j=j+16|0,a=o,r=Ht(e,t)|0,(n+-1|0)>>>0>5||(r=(r|0)!=0,(n|0)==1&r))return a=-1,j=o,a|0;do if(Tr(e,t,a)|0)r=-1;else if(r){r=((i[26352+(n<<2)>>2]|0)+5-(i[a>>2]|0)|0)%5|0;break}else{r=((i[26384+(n<<2)>>2]|0)+6-(i[a>>2]|0)|0)%6|0;break}while(0);return a=r,j=o,a|0}function Tr(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0;if(d=j,j=j+32|0,c=d+16|0,l=d,r=on(e,t,c)|0,r|0)return n=r,j=d,n|0;o=Pt(e,t)|0,u=Xt(e,t)|0,Te(o,l),r=Ee(o,i[c>>2]|0)|0;do if(xe(o)|0){do switch(o|0){case 4:a=0;break;case 14:a=1;break;case 24:a=2;break;case 38:a=3;break;case 49:a=4;break;case 58:a=5;break;case 63:a=6;break;case 72:a=7;break;case 83:a=8;break;case 97:a=9;break;case 107:a=10;break;case 117:a=11;break;default:E(27795,27797,75,27806)}while(0);if(s=i[26416+(a*24|0)+8>>2]|0,t=i[26416+(a*24|0)+16>>2]|0,e=i[c>>2]|0,(e|0)!=(i[l>>2]|0)&&(l=Se(o)|0,e=i[c>>2]|0,l|(e|0)==(t|0)&&(r=(r+1|0)%6|0)),(u|0)==3&(e|0)==(t|0)){r=(r+5|0)%6|0;break}(u|0)==5&(e|0)==(s|0)&&(r=(r+1|0)%6|0)}while(0);return i[n>>2]=r,n=0,j=d,n|0}function Er(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;if(b=j,j=j+32|0,y=b+24|0,_=b+20|0,h=b+8|0,m=b+16|0,p=b,l=(Ht(e,t)|0)==0,l=l?6:5,d=P(e|0,t|0,52)|0,T()|0,d&=15,l>>>0<=n>>>0)return r=2,j=b,r|0;f=(d|0)==0,!f&&(g=F(7,0,(d^15)*3|0)|0,(g&e|0)==0&((T()|0)&t|0)==0)?a=n:o=4;a:do if((o|0)==4){if(a=(Ht(e,t)|0)!=0,((a?4:5)|0)<(n|0)||Tr(e,t,y)|0||(o=(i[y>>2]|0)+n|0,a=a?26704+(((o|0)%5|0)<<2)|0:26736+(((o|0)%6|0)<<2)|0,g=i[a>>2]|0,(g|0)==7))return r=1,j=b,r|0;i[_>>2]=0,a=de(e,t,g,_,h)|0;do if(!a){if(c=h,u=i[c>>2]|0,c=i[c+4>>2]|0,s=c>>>0<t>>>0|(c|0)==(t|0)&u>>>0<e>>>0,o=s?u:e,s=s?c:t,!f&&(f=F(7,0,(d^15)*3|0)|0,(u&f|0)==0&(c&(T()|0)|0)==0))a=n;else{if(c=(n+-1+l|0)%(l|0)|0,a=Ht(e,t)|0,(c|0)<0&&E(27795,27797,248,27822),l=(a|0)!=0,((l?4:5)|0)<(c|0)&&E(27795,27797,248,27822),Tr(e,t,y)|0&&E(27795,27797,248,27822),a=(i[y>>2]|0)+c|0,a=l?26704+(((a|0)%5|0)<<2)|0:26736+(((a|0)%6|0)<<2)|0,c=i[a>>2]|0,(c|0)==7&&E(27795,27797,248,27822),i[m>>2]=0,a=de(e,t,c,m,p)|0,a|0)break;u=p,l=i[u>>2]|0,u=i[u+4>>2]|0;do if(u>>>0<s>>>0|(u|0)==(s|0)&l>>>0<o>>>0){if(o=Ht(l,u)|0?he(l,u,e,t)|0:i[26800+((((i[m>>2]|0)+(i[26768+(c<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=Ht(l,u)|0,(o+-1|0)>>>0>5){a=-1,o=l,s=u;break}if(a=(a|0)!=0,(o|0)==1&a){a=-1,o=l,s=u;break}do if(Tr(l,u,y)|0)a=-1;else if(a){a=((i[26352+(o<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26384+(o<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);o=l,s=u}else a=n;while(0);c=h,u=i[c>>2]|0,c=i[c+4>>2]|0}if((o|0)==(u|0)&(s|0)==(c|0)){if(l=(Ht(u,c)|0)!=0,e=l?he(u,c,e,t)|0:i[26800+((((i[_>>2]|0)+(i[26768+(g<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,a=Ht(u,c)|0,(e+-1|0)>>>0<=5&&(v=(a|0)!=0,!((e|0)==1&v)))do if(Tr(u,c,y)|0)a=-1;else if(v){a=((i[26352+(e<<2)>>2]|0)+5-(i[y>>2]|0)|0)%5|0;break}else{a=((i[26384+(e<<2)>>2]|0)+6-(i[y>>2]|0)|0)%6|0;break}while(0);else a=-1;a=a+1|0,a=(a|0)==6|l&(a|0)==5?0:a}t=s,e=o;break a}while(0);return r=a,j=b,r|0}while(0);return v=F(a|0,0,56)|0,y=T()|0|t&-2130706433|536870912,i[r>>2]=v|e,i[r+4>>2]=y,r=0,j=b,r|0}function Dr(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0;return o=(Ht(e,t)|0)==0,r=Er(e,t,0,n)|0,a=(r|0)==0,o?!a||(r=Er(e,t,1,n+8|0)|0,r|0)||(r=Er(e,t,2,n+16|0)|0,r|0)||(r=Er(e,t,3,n+24|0)|0,r|0)||(r=Er(e,t,4,n+32|0)|0,r)?(o=r,o|0):Er(e,t,5,n+40|0)|0:!a||(r=Er(e,t,1,n+8|0)|0,r|0)||(r=Er(e,t,2,n+16|0)|0,r|0)||(r=Er(e,t,3,n+24|0)|0,r|0)||(r=Er(e,t,4,n+32|0)|0,r|0)?(o=r,o|0):(o=n+40|0,i[o>>2]=0,i[o+4>>2]=0,o=0,o|0)}function Or(e,t,n){e|=0,t|=0,n|=0;var r=0,a=0,o=0,s=0,c=0,l=0;return l=j,j=j+192|0,a=l,o=l+168|0,s=P(e|0,t|0,56)|0,T()|0,s&=7,c=t&-2130706433|134217728,r=on(e,c,o)|0,r|0?(c=r,j=l,c|0):(t=P(e|0,t|0,52)|0,T()|0,t&=15,Ht(e,c)|0?Dt(o,t,s,1,a):jt(o,t,s,1,a),c=a+8|0,i[n>>2]=i[c>>2],i[n+4>>2]=i[c+4>>2],i[n+8>>2]=i[c+8>>2],i[n+12>>2]=i[c+12>>2],c=0,j=l,c|0)}function kr(e,t){e|=0,t|=0;var n=0,r=0,a=0,o=0;return a=j,j=j+16|0,n=a,!(!0&(t&2013265920|0)==536870912)||(r=t&-2130706433|134217728,!(Lt(e,r)|0))?(r=0,j=a,r|0):(o=P(e|0,t|0,56)|0,T()|0,o=(Er(e,r,o&7,n)|0)==0,r=n,r=o&((i[r>>2]|0)==(e|0)?(i[r+4>>2]|0)==(t|0):0)&1,j=a,r|0)}function Ar(e,t,n){e|=0,t|=0,n|=0;var r=0;(t|0)>0?(r=Br(t,4)|0,i[e>>2]=r,r||E(27835,27858,40,27872)):i[e>>2]=0,i[e+4>>2]=t,i[e+8>>2]=0,i[e+12>>2]=n}function jr(e){e|=0;var t=0,n=0,r=0,o=0,s=0,c=0,u=0;o=e+4|0,s=e+12|0,c=e+8|0;a:for(;;){for(n=i[o>>2]|0,t=0;;){if((t|0)>=(n|0))break a;if(r=i[e>>2]|0,u=i[r+(t<<2)>>2]|0,!u)t=t+1|0;else break}t=r+(~~(l(+(d(10,+ +(15-(i[s>>2]|0)|0))*(+a[u>>3]+ +a[u+8>>3])))%+(n|0))>>>0<<2)|0,n=i[t>>2]|0;b:do if(n|0){if(r=u+32|0,(n|0)==(u|0))i[t>>2]=i[r>>2];else{if(n=n+32|0,t=i[n>>2]|0,!t)break;for(;(t|0)!=(u|0);)if(n=t+32|0,t=i[n>>2]|0,!t)break b;i[n>>2]=i[r>>2]}N(u),i[c>>2]=(i[c>>2]|0)+-1}while(0)}N(i[e>>2]|0)}function Mr(e){e|=0;var t=0,n=0,r=0;for(r=i[e+4>>2]|0,n=0;;){if((n|0)>=(r|0)){t=0,n=4;break}if(t=i[(i[e>>2]|0)+(n<<2)>>2]|0,!t)n=n+1|0;else{n=4;break}}return(n|0)==4?t|0:0}function Nr(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0;if(n=~~(l(+(d(10,+ +(15-(i[e+12>>2]|0)|0))*(+a[t>>3]+ +a[t+8>>3])))%+(i[e+4>>2]|0))>>>0,n=(i[e>>2]|0)+(n<<2)|0,r=i[n>>2]|0,!r)return s=1,s|0;s=t+32|0;do if((r|0)!=(t|0)){if(n=i[r+32>>2]|0,!n)return s=1,s|0;for(o=n;;){if((o|0)==(t|0)){o=8;break}if(n=i[o+32>>2]|0,n)r=o,o=n;else{n=1,o=10;break}}if((o|0)==8){i[r+32>>2]=i[s>>2];break}else if((o|0)==10)return n|0}else i[n>>2]=i[s>>2];while(0);return N(t),s=e+8|0,i[s>>2]=(i[s>>2]|0)+-1,s=0,s|0}function Pr(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0,s=0,c=0;s=zr(40)|0,s||E(27888,27858,98,27901),i[s>>2]=i[t>>2],i[s+4>>2]=i[t+4>>2],i[s+8>>2]=i[t+8>>2],i[s+12>>2]=i[t+12>>2],o=s+16|0,i[o>>2]=i[n>>2],i[o+4>>2]=i[n+4>>2],i[o+8>>2]=i[n+8>>2],i[o+12>>2]=i[n+12>>2],i[s+32>>2]=0,o=~~(l(+(d(10,+ +(15-(i[e+12>>2]|0)|0))*(+a[t>>3]+ +a[t+8>>3])))%+(i[e+4>>2]|0))>>>0,o=(i[e>>2]|0)+(o<<2)|0,r=i[o>>2]|0;do if(!r)i[o>>2]=s;else{for(;!(yn(r,t)|0&&yn(r+16|0,n)|0);)if(o=i[r+32>>2]|0,r=o|0?o:r,!(i[r+32>>2]|0)){c=10;break}if((c|0)==10){i[r+32>>2]=s;break}return N(s),c=r,c|0}while(0);return c=e+8|0,i[c>>2]=(i[c>>2]|0)+1,c=s,c|0}function Fr(e,t,n){e|=0,t|=0,n|=0;var r=0,o=0;if(o=~~(l(+(d(10,+ +(15-(i[e+12>>2]|0)|0))*(+a[t>>3]+ +a[t+8>>3])))%+(i[e+4>>2]|0))>>>0,o=i[(i[e>>2]|0)+(o<<2)>>2]|0,!o)return n=0,n|0;if(!n){for(e=o;;){if(yn(e,t)|0){r=10;break}if(e=i[e+32>>2]|0,!e){e=0,r=10;break}}if((r|0)==10)return e|0}for(e=o;;){if(yn(e,t)|0&&yn(e+16|0,n)|0){r=10;break}if(e=i[e+32>>2]|0,!e){e=0,r=10;break}}return(r|0)==10?e|0:0}function Ir(e,t){e|=0,t|=0;var n=0;if(n=~~(l(+(d(10,+ +(15-(i[e+12>>2]|0)|0))*(+a[t>>3]+ +a[t+8>>3])))%+(i[e+4>>2]|0))>>>0,e=i[(i[e>>2]|0)+(n<<2)>>2]|0,!e)return n=0,n|0;for(;;){if(yn(e,t)|0){t=5;break}if(e=i[e+32>>2]|0,!e){e=0,t=5;break}}return(t|0)==5?e|0:0}function Lr(){return 27920}function Rr(e){return e=+e,~~+ri(+e)|0}function zr(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0;S=j,j=j+16|0,p=S;do if(e>>>0<245){if(u=e>>>0<11?16:e+11&-8,e=u>>>3,f=i[6981]|0,n=f>>>e,n&3|0)return t=(n&1^1)+e|0,e=27964+(t<<1<<2)|0,n=e+8|0,r=i[n>>2]|0,a=r+8|0,o=i[a>>2]|0,(o|0)==(e|0)?i[6981]=f&~(1<<t):(i[o+12>>2]=e,i[n>>2]=o),x=t<<3,i[r+4>>2]=x|3,x=r+x+4|0,i[x>>2]=i[x>>2]|1,x=a,j=S,x|0;if(d=i[6983]|0,u>>>0>d>>>0){if(n|0)return t=2<<e,t=n<<e&(t|0-t),t=(t&0-t)+-1|0,c=t>>>12&16,t>>>=c,n=t>>>5&8,t>>>=n,o=t>>>2&4,t>>>=o,e=t>>>1&2,t>>>=e,r=t>>>1&1,r=(n|c|o|e|r)+(t>>>r)|0,t=27964+(r<<1<<2)|0,e=t+8|0,o=i[e>>2]|0,c=o+8|0,n=i[c>>2]|0,(n|0)==(t|0)?(e=f&~(1<<r),i[6981]=e):(i[n+12>>2]=t,i[e>>2]=n,e=f),x=r<<3,s=x-u|0,i[o+4>>2]=u|3,a=o+u|0,i[a+4>>2]=s|1,i[o+x>>2]=s,d|0&&(r=i[6986]|0,t=d>>>3,n=27964+(t<<1<<2)|0,t=1<<t,e&t?(e=n+8|0,t=i[e>>2]|0):(i[6981]=e|t,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6983]=s,i[6986]=a,x=c,j=S,x|0;if(o=i[6982]|0,o){for(n=(o&0-o)+-1|0,a=n>>>12&16,n>>>=a,r=n>>>5&8,n>>>=r,s=n>>>2&4,n>>>=s,c=n>>>1&2,n>>>=c,l=n>>>1&1,l=i[28228+((r|a|s|c|l)+(n>>>l)<<2)>>2]|0,n=l,c=l,l=(i[l+4>>2]&-8)-u|0;e=i[n+16>>2]|0,!(!e&&(e=i[n+20>>2]|0,!e));)s=(i[e+4>>2]&-8)-u|0,a=s>>>0<l>>>0,n=e,c=a?e:c,l=a?s:l;if(s=c+u|0,s>>>0>c>>>0){a=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){n=0;break}for(;;)if(r=t+20|0,n=i[r>>2]|0,n)t=n,e=r;else if(r=t+16|0,n=i[r>>2]|0,n)t=n,e=r;else break;i[e>>2]=0,n=t}else n=i[c+8>>2]|0,i[n+12>>2]=t,i[t+8>>2]=n,n=t;while(0);do if(a|0){if(t=i[c+28>>2]|0,e=28228+(t<<2)|0,(c|0)==(i[e>>2]|0)){if(i[e>>2]=n,!n){i[6982]=o&~(1<<t);break}}else if(x=a+16|0,i[((i[x>>2]|0)==(c|0)?x:a+20|0)>>2]=n,!n)break;i[n+24>>2]=a,t=i[c+16>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),t=i[c+20>>2]|0,t|0&&(i[n+20>>2]=t,i[t+24>>2]=n)}while(0);return l>>>0<16?(x=l+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1):(i[c+4>>2]=u|3,i[s+4>>2]=l|1,i[s+l>>2]=l,d|0&&(r=i[6986]|0,t=d>>>3,n=27964+(t<<1<<2)|0,t=1<<t,t&f?(e=n+8|0,t=i[e>>2]|0):(i[6981]=t|f,t=n,e=n+8|0),i[e>>2]=r,i[t+12>>2]=r,i[r+8>>2]=t,i[r+12>>2]=n),i[6983]=l,i[6986]=s),x=c+8|0,j=S,x|0}else f=u}else f=u}else f=u}else if(e>>>0<=4294967231)if(e=e+11|0,u=e&-8,r=i[6982]|0,r){a=0-u|0,e>>>=8,e?u>>>0>16777215?l=31:(f=(e+1048320|0)>>>16&8,g=e<<f,c=(g+520192|0)>>>16&4,g<<=c,l=(g+245760|0)>>>16&2,l=14-(c|f|l)+(g<<l>>>15)|0,l=u>>>(l+7|0)&1|l<<1):l=0,n=i[28228+(l<<2)>>2]|0;a:do if(!n)n=0,e=0,g=61;else for(e=0,c=u<<((l|0)==31?0:25-(l>>>1)|0),o=0;;){if(s=(i[n+4>>2]&-8)-u|0,s>>>0<a>>>0)if(s)e=n,a=s;else{e=n,a=0,g=65;break a}if(g=i[n+20>>2]|0,n=i[n+16+(c>>>31<<2)>>2]|0,o=(g|0)==0|(g|0)==(n|0)?o:g,n)c<<=1;else{n=o,g=61;break}}while(0);if((g|0)==61){if((n|0)==0&(e|0)==0){if(e=2<<l,e=(e|0-e)&r,!e){f=u;break}f=(e&0-e)+-1|0,s=f>>>12&16,f>>>=s,o=f>>>5&8,f>>>=o,c=f>>>2&4,f>>>=c,l=f>>>1&2,f>>>=l,n=f>>>1&1,e=0,n=i[28228+((o|s|c|l|n)+(f>>>n)<<2)>>2]|0}n?g=65:(c=e,s=a)}if((g|0)==65)for(o=n;;)if(f=(i[o+4>>2]&-8)-u|0,n=f>>>0<a>>>0,a=n?f:a,e=n?o:e,n=i[o+16>>2]|0,n||=i[o+20>>2]|0,n)o=n;else{c=e,s=a;break}if(c|0&&s>>>0<((i[6983]|0)-u|0)>>>0&&(d=c+u|0,d>>>0>c>>>0)){o=i[c+24>>2]|0,t=i[c+12>>2]|0;do if((t|0)==(c|0)){if(e=c+20|0,t=i[e>>2]|0,!t&&(e=c+16|0,t=i[e>>2]|0,!t)){t=0;break}for(;;)if(a=t+20|0,n=i[a>>2]|0,n)t=n,e=a;else if(a=t+16|0,n=i[a>>2]|0,n)t=n,e=a;else break;i[e>>2]=0}else x=i[c+8>>2]|0,i[x+12>>2]=t,i[t+8>>2]=x;while(0);do if(o){if(e=i[c+28>>2]|0,n=28228+(e<<2)|0,(c|0)==(i[n>>2]|0)){if(i[n>>2]=t,!t){r&=~(1<<e),i[6982]=r;break}}else if(x=o+16|0,i[((i[x>>2]|0)==(c|0)?x:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,e=i[c+16>>2]|0,e|0&&(i[t+16>>2]=e,i[e+24>>2]=t),e=i[c+20>>2]|0,e&&(i[t+20>>2]=e,i[e+24>>2]=t)}while(0);b:do if(s>>>0<16)x=s+u|0,i[c+4>>2]=x|3,x=c+x+4|0,i[x>>2]=i[x>>2]|1;else{if(i[c+4>>2]=u|3,i[d+4>>2]=s|1,i[d+s>>2]=s,t=s>>>3,s>>>0<256){n=27964+(t<<1<<2)|0,e=i[6981]|0,t=1<<t,e&t?(e=n+8|0,t=i[e>>2]|0):(i[6981]=e|t,t=n,e=n+8|0),i[e>>2]=d,i[t+12>>2]=d,i[d+8>>2]=t,i[d+12>>2]=n;break}if(t=s>>>8,t?s>>>0>16777215?n=31:(b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,n=(x+245760|0)>>>16&2,n=14-(y|b|n)+(x<<n>>>15)|0,n=s>>>(n+7|0)&1|n<<1):n=0,t=28228+(n<<2)|0,i[d+28>>2]=n,e=d+16|0,i[e+4>>2]=0,i[e>>2]=0,e=1<<n,!(r&e)){i[6982]=r|e,i[t>>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break}t=i[t>>2]|0;c:do if((i[t+4>>2]&-8|0)!=(s|0)){for(r=s<<((n|0)==31?0:25-(n>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(s|0)){t=e;break c}else r<<=1,t=e;i[n>>2]=d,i[d+24>>2]=t,i[d+12>>2]=d,i[d+8>>2]=d;break b}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=d,i[b>>2]=d,i[d+8>>2]=x,i[d+12>>2]=t,i[d+24>>2]=0}while(0);return x=c+8|0,j=S,x|0}else f=u}else f=u;else f=-1;while(0);if(n=i[6983]|0,n>>>0>=f>>>0)return t=n-f|0,e=i[6986]|0,t>>>0>15?(x=e+f|0,i[6986]=x,i[6983]=t,i[x+4>>2]=t|1,i[e+n>>2]=t,i[e+4>>2]=f|3):(i[6983]=0,i[6986]=0,i[e+4>>2]=n|3,x=e+n+4|0,i[x>>2]=i[x>>2]|1),x=e+8|0,j=S,x|0;if(s=i[6984]|0,s>>>0>f>>>0)return y=s-f|0,i[6984]=y,x=i[6987]|0,b=x+f|0,i[6987]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,j=S,x|0;if(i[7099]|0?e=i[7101]|0:(i[7101]=4096,i[7100]=4096,i[7102]=-1,i[7103]=-1,i[7104]=0,i[7092]=0,i[7099]=p&-16^1431655768,e=4096),c=f+48|0,l=f+47|0,o=e+l|0,a=0-e|0,u=o&a,u>>>0<=f>>>0||(e=i[7091]|0,e|0&&(d=i[7089]|0,p=d+u|0,p>>>0<=d>>>0|p>>>0>e>>>0)))return x=0,j=S,x|0;d:do if(i[7092]&4)t=0,g=143;else{n=i[6987]|0;e:do if(n){for(r=28372;p=i[r>>2]|0,!(p>>>0<=n>>>0&&(p+(i[r+4>>2]|0)|0)>>>0>n>>>0);)if(e=i[r+8>>2]|0,e)r=e;else{g=128;break e}if(t=o-s&a,t>>>0<2147483647)if(e=ii(t|0)|0,(e|0)==((i[r>>2]|0)+(i[r+4>>2]|0)|0)){if((e|0)!=-1){s=t,o=e,g=145;break d}}else r=e,g=136;else t=0}else g=128;while(0);do if((g|0)==128)if(n=ii(0)|0,(n|0)!=-1&&(t=n,m=i[7100]|0,h=m+-1|0,t=(h&t|0?(h+t&0-m)-t|0:0)+u|0,m=i[7089]|0,h=t+m|0,t>>>0>f>>>0&t>>>0<2147483647)){if(p=i[7091]|0,p|0&&h>>>0<=m>>>0|h>>>0>p>>>0){t=0;break}if(e=ii(t|0)|0,(e|0)==(n|0)){s=t,o=n,g=145;break d}else r=e,g=136}else t=0;while(0);do if((g|0)==136){if(n=0-t|0,!(c>>>0>t>>>0&(t>>>0<2147483647&(r|0)!=-1)))if((r|0)==-1){t=0;break}else{s=t,o=r,g=145;break d}if(e=i[7101]|0,e=l-t+e&0-e,e>>>0>=2147483647){s=t,o=r,g=145;break d}if((ii(e|0)|0)==-1){ii(n|0)|0,t=0;break}else{s=e+t|0,o=r,g=145;break d}}while(0);i[7092]|=4,g=143}while(0);if((g|0)==143&&u>>>0<2147483647&&(y=ii(u|0)|0,h=ii(0)|0,_=h-y|0,v=_>>>0>(f+40|0)>>>0,!((y|0)==-1|v^1|y>>>0<h>>>0&((y|0)!=-1&(h|0)!=-1)^1))&&(s=v?_:t,o=y,g=145),(g|0)==145){t=(i[7089]|0)+s|0,i[7089]=t,t>>>0>(i[7090]|0)>>>0&&(i[7090]=t),l=i[6987]|0;f:do if(l){for(t=28372;;){if(e=i[t>>2]|0,n=i[t+4>>2]|0,(o|0)==(e+n|0)){g=154;break}if(r=i[t+8>>2]|0,r)t=r;else break}if((g|0)==154&&(b=t+4|0,!(i[t+12>>2]&8|0))&&o>>>0>l>>>0&e>>>0<=l>>>0){i[b>>2]=n+s,x=(i[6984]|0)+s|0,y=l+8|0,y=y&7|0?0-y&7:0,b=l+y|0,y=x-y|0,i[6987]=b,i[6984]=y,i[b+4>>2]=y|1,i[l+x+4>>2]=40,i[6988]=i[7103];break}for(o>>>0<(i[6985]|0)>>>0&&(i[6985]=o),n=o+s|0,t=28372;;){if((i[t>>2]|0)==(n|0)){g=162;break}if(e=i[t+8>>2]|0,e)t=e;else break}if((g|0)==162&&!(i[t+12>>2]&8|0)){i[t>>2]=o,d=t+4|0,i[d>>2]=(i[d>>2]|0)+s,d=o+8|0,d=o+(d&7|0?0-d&7:0)|0,t=n+8|0,t=n+(t&7|0?0-t&7:0)|0,u=d+f|0,c=t-d-f|0,i[d+4>>2]=f|3;g:do if((l|0)==(t|0))x=(i[6984]|0)+c|0,i[6984]=x,i[6987]=u,i[u+4>>2]=x|1;else{if((i[6986]|0)==(t|0)){x=(i[6983]|0)+c|0,i[6983]=x,i[6986]=u,i[u+4>>2]=x|1,i[u+x>>2]=x;break}if(e=i[t+4>>2]|0,(e&3|0)==1){s=e&-8,r=e>>>3;h:do if(e>>>0<256)if(e=i[t+8>>2]|0,n=i[t+12>>2]|0,(n|0)==(e|0)){i[6981]&=~(1<<r);break}else{i[e+12>>2]=n,i[n+8>>2]=e;break}else{o=i[t+24>>2]|0,e=i[t+12>>2]|0;do if((e|0)==(t|0)){if(n=t+16|0,r=n+4|0,e=i[r>>2]|0,e)n=r;else if(e=i[n>>2]|0,!e){e=0;break}for(;;)if(a=e+20|0,r=i[a>>2]|0,r)e=r,n=a;else if(a=e+16|0,r=i[a>>2]|0,r)e=r,n=a;else break;i[n>>2]=0}else x=i[t+8>>2]|0,i[x+12>>2]=e,i[e+8>>2]=x;while(0);if(!o)break;n=i[t+28>>2]|0,r=28228+(n<<2)|0;do if((i[r>>2]|0)!=(t|0)){if(x=o+16|0,i[((i[x>>2]|0)==(t|0)?x:o+20|0)>>2]=e,!e)break h}else{if(i[r>>2]=e,e|0)break;i[6982]&=~(1<<n);break h}while(0);if(i[e+24>>2]=o,n=t+16|0,r=i[n>>2]|0,r|0&&(i[e+16>>2]=r,i[r+24>>2]=e),n=i[n+4>>2]|0,!n)break;i[e+20>>2]=n,i[n+24>>2]=e}while(0);t=t+s|0,a=s+c|0}else a=c;if(t=t+4|0,i[t>>2]=i[t>>2]&-2,i[u+4>>2]=a|1,i[u+a>>2]=a,t=a>>>3,a>>>0<256){n=27964+(t<<1<<2)|0,e=i[6981]|0,t=1<<t,e&t?(e=n+8|0,t=i[e>>2]|0):(i[6981]=e|t,t=n,e=n+8|0),i[e>>2]=u,i[t+12>>2]=u,i[u+8>>2]=t,i[u+12>>2]=n;break}t=a>>>8;do if(!t)r=0;else{if(a>>>0>16777215){r=31;break}b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<<r>>>15)|0,r=a>>>(r+7|0)&1|r<<1}while(0);if(t=28228+(r<<2)|0,i[u+28>>2]=r,e=u+16|0,i[e+4>>2]=0,i[e>>2]=0,e=i[6982]|0,n=1<<r,!(e&n)){i[6982]=e|n,i[t>>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}t=i[t>>2]|0;i:do if((i[t+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(a|0)){t=e;break i}else r<<=1,t=e;i[n>>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break g}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=u,i[b>>2]=u,i[u+8>>2]=x,i[u+12>>2]=t,i[u+24>>2]=0}while(0);return x=d+8|0,j=S,x|0}for(t=28372;e=i[t>>2]|0,!(e>>>0<=l>>>0&&(x=e+(i[t+4>>2]|0)|0,x>>>0>l>>>0));)t=i[t+8>>2]|0;a=x+-47|0,e=a+8|0,e=a+(e&7|0?0-e&7:0)|0,a=l+16|0,e=e>>>0<a>>>0?l:e,t=e+8|0,n=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=n-y|0,i[6987]=b,i[6984]=y,i[b+4>>2]=y|1,i[o+n+4>>2]=40,i[6988]=i[7103],n=e+4|0,i[n>>2]=27,i[t>>2]=i[7093],i[t+4>>2]=i[7094],i[t+8>>2]=i[7095],i[t+12>>2]=i[7096],i[7093]=o,i[7094]=s,i[7096]=0,i[7095]=t,t=e+24|0;do b=t,t=t+4|0,i[t>>2]=7;while((b+8|0)>>>0<x>>>0);if((e|0)!=(l|0)){if(o=e-l|0,i[n>>2]=i[n>>2]&-2,i[l+4>>2]=o|1,i[e>>2]=o,t=o>>>3,o>>>0<256){n=27964+(t<<1<<2)|0,e=i[6981]|0,t=1<<t,e&t?(e=n+8|0,t=i[e>>2]|0):(i[6981]=e|t,t=n,e=n+8|0),i[e>>2]=l,i[t+12>>2]=l,i[l+8>>2]=t,i[l+12>>2]=n;break}if(t=o>>>8,t?o>>>0>16777215?r=31:(b=(t+1048320|0)>>>16&8,x=t<<b,y=(x+520192|0)>>>16&4,x<<=y,r=(x+245760|0)>>>16&2,r=14-(y|b|r)+(x<<r>>>15)|0,r=o>>>(r+7|0)&1|r<<1):r=0,n=28228+(r<<2)|0,i[l+28>>2]=r,i[l+20>>2]=0,i[a>>2]=0,t=i[6982]|0,e=1<<r,!(t&e)){i[6982]=t|e,i[n>>2]=l,i[l+24>>2]=n,i[l+12>>2]=l,i[l+8>>2]=l;break}t=i[n>>2]|0;j:do if((i[t+4>>2]&-8|0)!=(o|0)){for(r=o<<((r|0)==31?0:25-(r>>>1)|0);n=t+16+(r>>>31<<2)|0,e=i[n>>2]|0,e;)if((i[e+4>>2]&-8|0)==(o|0)){t=e;break j}else r<<=1,t=e;i[n>>2]=l,i[l+24>>2]=t,i[l+12>>2]=l,i[l+8>>2]=l;break f}while(0);b=t+8|0,x=i[b>>2]|0,i[x+12>>2]=l,i[b>>2]=l,i[l+8>>2]=x,i[l+12>>2]=t,i[l+24>>2]=0}}else x=i[6985]|0,(x|0)==0|o>>>0<x>>>0&&(i[6985]=o),i[7093]=o,i[7094]=s,i[7096]=0,i[6990]=i[7099],i[6989]=-1,i[6994]=27964,i[6993]=27964,i[6996]=27972,i[6995]=27972,i[6998]=27980,i[6997]=27980,i[7e3]=27988,i[6999]=27988,i[7002]=27996,i[7001]=27996,i[7004]=28004,i[7003]=28004,i[7006]=28012,i[7005]=28012,i[7008]=28020,i[7007]=28020,i[7010]=28028,i[7009]=28028,i[7012]=28036,i[7011]=28036,i[7014]=28044,i[7013]=28044,i[7016]=28052,i[7015]=28052,i[7018]=28060,i[7017]=28060,i[7020]=28068,i[7019]=28068,i[7022]=28076,i[7021]=28076,i[7024]=28084,i[7023]=28084,i[7026]=28092,i[7025]=28092,i[7028]=28100,i[7027]=28100,i[7030]=28108,i[7029]=28108,i[7032]=28116,i[7031]=28116,i[7034]=28124,i[7033]=28124,i[7036]=28132,i[7035]=28132,i[7038]=28140,i[7037]=28140,i[7040]=28148,i[7039]=28148,i[7042]=28156,i[7041]=28156,i[7044]=28164,i[7043]=28164,i[7046]=28172,i[7045]=28172,i[7048]=28180,i[7047]=28180,i[7050]=28188,i[7049]=28188,i[7052]=28196,i[7051]=28196,i[7054]=28204,i[7053]=28204,i[7056]=28212,i[7055]=28212,x=s+-40|0,y=o+8|0,y=y&7|0?0-y&7:0,b=o+y|0,y=x-y|0,i[6987]=b,i[6984]=y,i[b+4>>2]=y|1,i[o+x+4>>2]=40,i[6988]=i[7103];while(0);if(t=i[6984]|0,t>>>0>f>>>0)return y=t-f|0,i[6984]=y,x=i[6987]|0,b=x+f|0,i[6987]=b,i[b+4>>2]=y|1,i[x+4>>2]=f|3,x=x+8|0,j=S,x|0}return x=Lr()|0,i[x>>2]=12,x=0,j=S,x|0}function N(e){e|=0;var t=0,n=0,r=0,a=0,o=0,s=0,c=0,l=0;if(e){n=e+-8|0,a=i[6985]|0,e=i[e+-4>>2]|0,t=e&-8,l=n+t|0;do if(e&1)c=n,s=n;else{if(r=i[n>>2]|0,!(e&3)||(s=n+(0-r)|0,o=r+t|0,s>>>0<a>>>0))return;if((i[6986]|0)==(s|0)){if(e=l+4|0,t=i[e>>2]|0,(t&3|0)!=3){c=s,t=o;break}i[6983]=o,i[e>>2]=t&-2,i[s+4>>2]=o|1,i[s+o>>2]=o;return}if(n=r>>>3,r>>>0<256)if(e=i[s+8>>2]|0,t=i[s+12>>2]|0,(t|0)==(e|0)){i[6981]&=~(1<<n),c=s,t=o;break}else{i[e+12>>2]=t,i[t+8>>2]=e,c=s,t=o;break}a=i[s+24>>2]|0,e=i[s+12>>2]|0;do if((e|0)==(s|0)){if(t=s+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){e=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0}else c=i[s+8>>2]|0,i[c+12>>2]=e,i[e+8>>2]=c;while(0);if(a){if(t=i[s+28>>2]|0,n=28228+(t<<2)|0,(i[n>>2]|0)==(s|0)){if(i[n>>2]=e,!e){i[6982]&=~(1<<t),c=s,t=o;break}}else if(c=a+16|0,i[((i[c>>2]|0)==(s|0)?c:a+20|0)>>2]=e,!e){c=s,t=o;break}i[e+24>>2]=a,t=s+16|0,n=i[t>>2]|0,n|0&&(i[e+16>>2]=n,i[n+24>>2]=e),t=i[t+4>>2]|0,t?(i[e+20>>2]=t,i[t+24>>2]=e,c=s,t=o):(c=s,t=o)}else c=s,t=o}while(0);if(!(s>>>0>=l>>>0)&&(e=l+4|0,r=i[e>>2]|0,r&1)){if(r&2)i[e>>2]=r&-2,i[c+4>>2]=t|1,i[s+t>>2]=t,a=t;else{if((i[6987]|0)==(l|0)){if(l=(i[6984]|0)+t|0,i[6984]=l,i[6987]=c,i[c+4>>2]=l|1,(c|0)!=(i[6986]|0))return;i[6986]=0,i[6983]=0;return}if((i[6986]|0)==(l|0)){l=(i[6983]|0)+t|0,i[6983]=l,i[6986]=s,i[c+4>>2]=l|1,i[s+l>>2]=l;return}a=(r&-8)+t|0,n=r>>>3;do if(r>>>0<256)if(t=i[l+8>>2]|0,e=i[l+12>>2]|0,(e|0)==(t|0)){i[6981]&=~(1<<n);break}else{i[t+12>>2]=e,i[e+8>>2]=t;break}else{o=i[l+24>>2]|0,e=i[l+12>>2]|0;do if((e|0)==(l|0)){if(t=l+16|0,n=t+4|0,e=i[n>>2]|0,e)t=n;else if(e=i[t>>2]|0,!e){n=0;break}for(;;)if(r=e+20|0,n=i[r>>2]|0,n)e=n,t=r;else if(r=e+16|0,n=i[r>>2]|0,n)e=n,t=r;else break;i[t>>2]=0,n=e}else n=i[l+8>>2]|0,i[n+12>>2]=e,i[e+8>>2]=n,n=e;while(0);if(o|0){if(e=i[l+28>>2]|0,t=28228+(e<<2)|0,(i[t>>2]|0)==(l|0)){if(i[t>>2]=n,!n){i[6982]&=~(1<<e);break}}else if(r=o+16|0,i[((i[r>>2]|0)==(l|0)?r:o+20|0)>>2]=n,!n)break;i[n+24>>2]=o,e=l+16|0,t=i[e>>2]|0,t|0&&(i[n+16>>2]=t,i[t+24>>2]=n),e=i[e+4>>2]|0,e|0&&(i[n+20>>2]=e,i[e+24>>2]=n)}}while(0);if(i[c+4>>2]=a|1,i[s+a>>2]=a,(c|0)==(i[6986]|0)){i[6983]=a;return}}if(e=a>>>3,a>>>0<256){n=27964+(e<<1<<2)|0,t=i[6981]|0,e=1<<e,t&e?(t=n+8|0,e=i[t>>2]|0):(i[6981]=t|e,e=n,t=n+8|0),i[t>>2]=c,i[e+12>>2]=c,i[c+8>>2]=e,i[c+12>>2]=n;return}e=a>>>8,e?a>>>0>16777215?r=31:(s=(e+1048320|0)>>>16&8,l=e<<s,o=(l+520192|0)>>>16&4,l<<=o,r=(l+245760|0)>>>16&2,r=14-(o|s|r)+(l<<r>>>15)|0,r=a>>>(r+7|0)&1|r<<1):r=0,e=28228+(r<<2)|0,i[c+28>>2]=r,i[c+20>>2]=0,i[c+16>>2]=0,t=i[6982]|0,n=1<<r;a:do if(!(t&n))i[6982]=t|n,i[e>>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;else{e=i[e>>2]|0;b:do if((i[e+4>>2]&-8|0)!=(a|0)){for(r=a<<((r|0)==31?0:25-(r>>>1)|0);n=e+16+(r>>>31<<2)|0,t=i[n>>2]|0,t;)if((i[t+4>>2]&-8|0)==(a|0)){e=t;break b}else r<<=1,e=t;i[n>>2]=c,i[c+24>>2]=e,i[c+12>>2]=c,i[c+8>>2]=c;break a}while(0);s=e+8|0,l=i[s>>2]|0,i[l+12>>2]=c,i[s>>2]=c,i[c+8>>2]=l,i[c+12>>2]=e,i[c+24>>2]=0}while(0);if(l=(i[6989]|0)+-1|0,i[6989]=l,!(l|0)){for(e=28380;e=i[e>>2]|0,e;)e=e+8|0;i[6989]=-1}}}}function Br(e,t){e|=0,t|=0;var n=0;return e?(n=b(t,e)|0,(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(t|0)?n:-1)):n=0,e=zr(n)|0,!e||!(i[e+-4>>2]&3)||ni(e|0,0,n|0)|0,e|0}function Vr(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,n=e+n>>>0,(w(t+r+(n>>>0<e>>>0|0)>>>0|0),n|0)|0}function Hr(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,r=t-r-(n>>>0>e>>>0|0)>>>0,(w(r|0),e-n>>>0|0)|0}function Ur(e){return e|=0,(e?31-(C(e^e-1)|0)|0:32)|0}function Wr(e,t,n,r,a){e|=0,t|=0,n|=0,r|=0,a|=0;var o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0;if(d=e,l=t,u=l,s=n,p=r,c=p,!u)return o=(a|0)!=0,c?o?(i[a>>2]=e|0,i[a+4>>2]=t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0):(o&&(i[a>>2]=(d>>>0)%(s>>>0),i[a+4>>2]=0),p=0,a=(d>>>0)/(s>>>0)>>>0,(w(p|0),a)|0);o=(c|0)==0;do if(s){if(!o){if(o=(C(c|0)|0)-(C(u|0)|0)|0,o>>>0<=31){f=o+1|0,c=31-o|0,t=o-31>>31,s=f,e=d>>>(f>>>0)&t|u<<c,t=u>>>(f>>>0)&t,o=0,c=d<<c;break}return a?(i[a>>2]=e|0,i[a+4>>2]=l|t&0,p=0,a=0,(w(p|0),a)|0):(p=0,a=0,(w(p|0),a)|0)}if(o=s-1|0,o&s|0){c=(C(s|0)|0)+33-(C(u|0)|0)|0,h=64-c|0,f=32-c|0,l=f>>31,m=c-32|0,t=m>>31,s=c,e=f-1>>31&u>>>(m>>>0)|(u<<f|d>>>(c>>>0))&t,t&=u>>>(c>>>0),o=d<<h&l,c=(u<<h|d>>>(m>>>0))&l|d<<f&c-33>>31;break}return a|0&&(i[a>>2]=o&d,i[a+4>>2]=0),(s|0)==1?(m=l|t&0,h=e|0,(w(m|0),h)|0):(h=Ur(s|0)|0,m=u>>>(h>>>0)|0,h=u<<32-h|d>>>(h>>>0)|0,(w(m|0),h)|0)}else{if(o)return a|0&&(i[a>>2]=(u>>>0)%(s>>>0),i[a+4>>2]=0),m=0,h=(u>>>0)/(s>>>0)>>>0,(w(m|0),h)|0;if(!d)return a|0&&(i[a>>2]=0,i[a+4>>2]=(u>>>0)%(c>>>0)),m=0,h=(u>>>0)/(c>>>0)>>>0,(w(m|0),h)|0;if(o=c-1|0,!(o&c))return a|0&&(i[a>>2]=e|0,i[a+4>>2]=o&u|t&0),m=0,h=u>>>((Ur(c|0)|0)>>>0),(w(m|0),h)|0;if(o=(C(c|0)|0)-(C(u|0)|0)|0,o>>>0<=30){t=o+1|0,c=31-o|0,s=t,e=u<<c|d>>>(t>>>0),t=u>>>(t>>>0),o=0,c=d<<c;break}return a?(i[a>>2]=e|0,i[a+4>>2]=l|t&0,m=0,h=0,(w(m|0),h)|0):(m=0,h=0,(w(m|0),h)|0)}while(0);if(!s)u=c,l=0,c=0;else{f=n|0,d=p|r&0,u=Vr(f|0,d|0,-1,-1)|0,n=T()|0,l=c,c=0;do r=l,l=o>>>31|l<<1,o=c|o<<1,r=e<<1|r>>>31|0,p=e>>>31|t<<1|0,Hr(u|0,n|0,r|0,p|0)|0,h=T()|0,m=h>>31|((h|0)<0?-1:0)<<1,c=m&1,e=Hr(r|0,p|0,m&f|0,(((h|0)<0?-1:0)>>31|((h|0)<0?-1:0)<<1)&d|0)|0,t=T()|0,s=s-1|0;while(s|0);u=l,l=0}return s=0,a|0&&(i[a>>2]=e,i[a+4>>2]=t),m=(o|0)>>>31|(u|s)<<1|(s<<1|o>>>31)&0|l,h=(o<<1|0)&-2|c,(w(m|0),h)|0}function Gr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0,o=0,s=0,c=0,l=0;return l=t>>31|((t|0)<0?-1:0)<<1,c=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,a=r>>31|((r|0)<0?-1:0)<<1,i=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,s=Hr(l^e|0,c^t|0,l|0,c|0)|0,o=T()|0,e=a^l,t=i^c,Hr((Wr(s,o,Hr(a^n|0,i^r|0,a|0,i|0)|0,T()|0,0)|0)^e|0,(T()|0)^t|0,e|0,t|0)|0}function Kr(e,t){e|=0,t|=0;var n=0,r=0,i=0,a=0;return a=e&65535,i=t&65535,n=b(i,a)|0,r=e>>>16,e=(n>>>16)+(b(i,r)|0)|0,i=t>>>16,t=b(i,a)|0,(w((e>>>16)+(b(i,r)|0)+(((e&65535)+t|0)>>>16)|0),e+t<<16|n&65535|0)|0}function qr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var i=0,a=0;return i=e,a=n,n=Kr(i,a)|0,e=T()|0,(w((b(t,a)|0)+(b(r,i)|0)+e|e&0|0),n|0)|0}function Jr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0,s=0,c=0,l=0,u=0;return a=j,j=j+16|0,c=a|0,s=t>>31|((t|0)<0?-1:0)<<1,o=((t|0)<0?-1:0)>>31|((t|0)<0?-1:0)<<1,u=r>>31|((r|0)<0?-1:0)<<1,l=((r|0)<0?-1:0)>>31|((r|0)<0?-1:0)<<1,e=Hr(s^e|0,o^t|0,s|0,o|0)|0,t=T()|0,Wr(e,t,Hr(u^n|0,l^r|0,u|0,l|0)|0,T()|0,c)|0,r=Hr(i[c>>2]^s|0,i[c+4>>2]^o|0,s|0,o|0)|0,n=T()|0,j=a,(w(n|0),r)|0}function Yr(e,t,n,r){e|=0,t|=0,n|=0,r|=0;var a=0,o=0;return o=j,j=j+16|0,a=o|0,Wr(e,t,n,r,a)|0,j=o,(w(i[a+4>>2]|0),i[a>>2]|0)|0}function Xr(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(w(((t|0)<0?-1:0)|0),t>>n-32|0)}function P(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(w(0),t>>>n-32|0)}function F(e,t,n){return e|=0,t|=0,n|=0,(n|0)<32?(w(t<<n|(e&(1<<n)-1<<32-n)>>>32-n|0),e<<n):(w(e<<n-32|0),0)}function Zr(e,t,n){return e|=0,t|=0,n|=0,t=C(t)|0,(t|0)==32&&(t=t+(C(e)|0)|0),w(0),t|0}function Qr(e,t){return e=+e,t=+t,e==e?t==t?+S(+e,+t):+e:+t}function $r(e,t){return e=+e,t=+t,e==e?t==t?+x(+e,+t):+e:+t}function ei(e){return e=+e,e>=0?+c(e+.5):+y(e-.5)}function ti(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0;if((n|0)>=8192)return k(e|0,t|0,n|0)|0,e|0;if(s=e|0,o=e+n|0,(e&3)==(t&3)){for(;e&3;){if(!n)return s|0;r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0,n=n-1|0}for(n=o&-4|0,a=n-64|0;(e|0)<=(a|0);)i[e>>2]=i[t>>2],i[e+4>>2]=i[t+4>>2],i[e+8>>2]=i[t+8>>2],i[e+12>>2]=i[t+12>>2],i[e+16>>2]=i[t+16>>2],i[e+20>>2]=i[t+20>>2],i[e+24>>2]=i[t+24>>2],i[e+28>>2]=i[t+28>>2],i[e+32>>2]=i[t+32>>2],i[e+36>>2]=i[t+36>>2],i[e+40>>2]=i[t+40>>2],i[e+44>>2]=i[t+44>>2],i[e+48>>2]=i[t+48>>2],i[e+52>>2]=i[t+52>>2],i[e+56>>2]=i[t+56>>2],i[e+60>>2]=i[t+60>>2],e=e+64|0,t=t+64|0;for(;(e|0)<(n|0);)i[e>>2]=i[t>>2],e=e+4|0,t=t+4|0}else for(n=o-4|0;(e|0)<(n|0);)r[e>>0]=r[t>>0]|0,r[e+1>>0]=r[t+1>>0]|0,r[e+2>>0]=r[t+2>>0]|0,r[e+3>>0]=r[t+3>>0]|0,e=e+4|0,t=t+4|0;for(;(e|0)<(o|0);)r[e>>0]=r[t>>0]|0,e=e+1|0,t=t+1|0;return s|0}function ni(e,t,n){e|=0,t|=0,n|=0;var a=0,o=0,s=0,c=0;if(s=e+n|0,t&=255,(n|0)>=67){for(;e&3;)r[e>>0]=t,e=e+1|0;for(a=s&-4|0,c=t|t<<8|t<<16|t<<24,o=a-64|0;(e|0)<=(o|0);)i[e>>2]=c,i[e+4>>2]=c,i[e+8>>2]=c,i[e+12>>2]=c,i[e+16>>2]=c,i[e+20>>2]=c,i[e+24>>2]=c,i[e+28>>2]=c,i[e+32>>2]=c,i[e+36>>2]=c,i[e+40>>2]=c,i[e+44>>2]=c,i[e+48>>2]=c,i[e+52>>2]=c,i[e+56>>2]=c,i[e+60>>2]=c,e=e+64|0;for(;(e|0)<(a|0);)i[e>>2]=c,e=e+4|0}for(;(e|0)<(s|0);)r[e>>0]=t,e=e+1|0;return s-n|0}function ri(e){return e=+e,e>=0?+c(e+.5):+y(e-.5)}function ii(e){e|=0;var t=0,n=0,r=0;return r=O()|0,n=i[s>>2]|0,t=n+e|0,(e|0)>0&(t|0)<(n|0)|(t|0)<0?(ee(t|0)|0,D(12),-1):(t|0)>(r|0)&&!(A(t|0)|0)?(D(12),-1):(i[s>>2]=t,n|0)}return{___divdi3:Gr,___muldi3:qr,___remdi3:Jr,___uremdi3:Yr,_areNeighborCells:mt,_bitshift64Ashr:Xr,_bitshift64Lshr:P,_bitshift64Shl:F,_calloc:Br,_cellAreaKm2:Nn,_cellAreaM2:Pn,_cellAreaRads2:Mn,_cellToBoundary:cn,_cellToCenterChild:Gt,_cellToChildPos:pn,_cellToChildren:Ut,_cellToChildrenSize:Vt,_cellToLatLng:sn,_cellToLocalIj:Gn,_cellToParent:Bt,_cellToVertex:Er,_cellToVertexes:Dr,_cellsToDirectedEdge:ht,_cellsToLinkedMultiPolygon:be,_childPosToCell:mn,_compactCells:Kt,_constructCell:It,_destroyLinkedMultiPolygon:Bn,_directedEdgeToBoundary:xt,_directedEdgeToCells:yt,_edgeLengthKm:In,_edgeLengthM:Ln,_edgeLengthRads:Fn,_emscripten_replace_memory:te,_free:N,_getBaseCellNumber:Pt,_getDirectedEdgeDestination:_t,_getDirectedEdgeOrigin:gt,_getHexagonAreaAvgKm2:En,_getHexagonAreaAvgM2:Dn,_getHexagonEdgeLengthAvgKm:On,_getHexagonEdgeLengthAvgM:kn,_getIcosahedronFaces:un,_getIndexDigit:Ft,_getNumCells:An,_getPentagons:fn,_getRes0Cells:je,_getResolution:Nt,_greatCircleDistanceKm:Sn,_greatCircleDistanceM:Cn,_greatCircleDistanceRads:xn,_gridDisk:se,_gridDiskDistances:ce,_gridDistance:qn,_gridPathCells:Yn,_gridPathCellsSize:Jn,_gridRing:fe,_gridRingUnsafe:pe,_i64Add:Vr,_i64Subtract:Hr,_isPentagon:Ht,_isResClassIII:Yt,_isValidCell:Lt,_isValidDirectedEdge:vt,_isValidIndex:Rt,_isValidVertex:kr,_latLngToCell:rn,_llvm_ctlz_i64:Zr,_llvm_maxnum_f64:Qr,_llvm_minnum_f64:$r,_llvm_round_f64:ei,_localIjToCell:Kn,_malloc:zr,_maxFaceCount:ln,_maxGridDiskSize:oe,_maxPolygonToCellsSize:ge,_maxPolygonToCellsSizeExperimental:nr,_memcpy:ti,_memset:ni,_originToDirectedEdges:bt,_pentagonCount:dn,_polygonToCells:ve,_polygonToCellsExperimental:tr,_readInt64AsDoubleFromPointer:vr,_res0CellCount:Ae,_round:ri,_sbrk:ii,_sizeOfCellBoundary:pr,_sizeOfCoordIJ:_r,_sizeOfGeoLoop:mr,_sizeOfGeoPolygon:hr,_sizeOfH3Index:dr,_sizeOfLatLng:fr,_sizeOfLinkedGeoPolygon:gr,_uncompactCells:qt,_uncompactCellsSize:Jt,_vertexToLatLng:Or,establishStackSpace:ae,stackAlloc:ne,stackRestore:ie,stackSave:re}})({Math,Int8Array,Int32Array,Uint8Array,Float32Array,Float64Array},{a:rt,b:d,c:f,d:Le,e:Be,f:Re,g:ze,h:Ue,i:Ve,j:Ne,k:Pe,l:He,m:Fe,n:Ie,o:Me,p:ae},O);t.___divdi3=M.___divdi3,t.___muldi3=M.___muldi3,t.___remdi3=M.___remdi3,t.___uremdi3=M.___uremdi3,t._areNeighborCells=M._areNeighborCells,t._bitshift64Ashr=M._bitshift64Ashr,t._bitshift64Lshr=M._bitshift64Lshr,t._bitshift64Shl=M._bitshift64Shl,t._calloc=M._calloc,t._cellAreaKm2=M._cellAreaKm2,t._cellAreaM2=M._cellAreaM2,t._cellAreaRads2=M._cellAreaRads2,t._cellToBoundary=M._cellToBoundary,t._cellToCenterChild=M._cellToCenterChild,t._cellToChildPos=M._cellToChildPos,t._cellToChildren=M._cellToChildren,t._cellToChildrenSize=M._cellToChildrenSize,t._cellToLatLng=M._cellToLatLng,t._cellToLocalIj=M._cellToLocalIj,t._cellToParent=M._cellToParent,t._cellToVertex=M._cellToVertex,t._cellToVertexes=M._cellToVertexes,t._cellsToDirectedEdge=M._cellsToDirectedEdge,t._cellsToLinkedMultiPolygon=M._cellsToLinkedMultiPolygon,t._childPosToCell=M._childPosToCell,t._compactCells=M._compactCells,t._constructCell=M._constructCell,t._destroyLinkedMultiPolygon=M._destroyLinkedMultiPolygon,t._directedEdgeToBoundary=M._directedEdgeToBoundary,t._directedEdgeToCells=M._directedEdgeToCells,t._edgeLengthKm=M._edgeLengthKm,t._edgeLengthM=M._edgeLengthM,t._edgeLengthRads=M._edgeLengthRads;var qe=t._emscripten_replace_memory=M._emscripten_replace_memory;t._free=M._free,t._getBaseCellNumber=M._getBaseCellNumber,t._getDirectedEdgeDestination=M._getDirectedEdgeDestination,t._getDirectedEdgeOrigin=M._getDirectedEdgeOrigin,t._getHexagonAreaAvgKm2=M._getHexagonAreaAvgKm2,t._getHexagonAreaAvgM2=M._getHexagonAreaAvgM2,t._getHexagonEdgeLengthAvgKm=M._getHexagonEdgeLengthAvgKm,t._getHexagonEdgeLengthAvgM=M._getHexagonEdgeLengthAvgM,t._getIcosahedronFaces=M._getIcosahedronFaces,t._getIndexDigit=M._getIndexDigit,t._getNumCells=M._getNumCells,t._getPentagons=M._getPentagons,t._getRes0Cells=M._getRes0Cells,t._getResolution=M._getResolution,t._greatCircleDistanceKm=M._greatCircleDistanceKm,t._greatCircleDistanceM=M._greatCircleDistanceM,t._greatCircleDistanceRads=M._greatCircleDistanceRads,t._gridDisk=M._gridDisk,t._gridDiskDistances=M._gridDiskDistances,t._gridDistance=M._gridDistance,t._gridPathCells=M._gridPathCells,t._gridPathCellsSize=M._gridPathCellsSize,t._gridRing=M._gridRing,t._gridRingUnsafe=M._gridRingUnsafe,t._i64Add=M._i64Add,t._i64Subtract=M._i64Subtract,t._isPentagon=M._isPentagon,t._isResClassIII=M._isResClassIII,t._isValidCell=M._isValidCell,t._isValidDirectedEdge=M._isValidDirectedEdge,t._isValidIndex=M._isValidIndex,t._isValidVertex=M._isValidVertex,t._latLngToCell=M._latLngToCell,t._llvm_ctlz_i64=M._llvm_ctlz_i64,t._llvm_maxnum_f64=M._llvm_maxnum_f64,t._llvm_minnum_f64=M._llvm_minnum_f64,t._llvm_round_f64=M._llvm_round_f64,t._localIjToCell=M._localIjToCell,t._malloc=M._malloc,t._maxFaceCount=M._maxFaceCount,t._maxGridDiskSize=M._maxGridDiskSize,t._maxPolygonToCellsSize=M._maxPolygonToCellsSize,t._maxPolygonToCellsSizeExperimental=M._maxPolygonToCellsSizeExperimental,t._memcpy=M._memcpy,t._memset=M._memset,t._originToDirectedEdges=M._originToDirectedEdges,t._pentagonCount=M._pentagonCount,t._polygonToCells=M._polygonToCells,t._polygonToCellsExperimental=M._polygonToCellsExperimental,t._readInt64AsDoubleFromPointer=M._readInt64AsDoubleFromPointer,t._res0CellCount=M._res0CellCount,t._round=M._round,t._sbrk=M._sbrk,t._sizeOfCellBoundary=M._sizeOfCellBoundary,t._sizeOfCoordIJ=M._sizeOfCoordIJ,t._sizeOfGeoLoop=M._sizeOfGeoLoop,t._sizeOfGeoPolygon=M._sizeOfGeoPolygon,t._sizeOfH3Index=M._sizeOfH3Index,t._sizeOfLatLng=M._sizeOfLatLng,t._sizeOfLinkedGeoPolygon=M._sizeOfLinkedGeoPolygon,t._uncompactCells=M._uncompactCells,t._uncompactCellsSize=M._uncompactCellsSize,t._vertexToLatLng=M._vertexToLatLng,t.establishStackSpace=M.establishStackSpace;var Je=t.stackAlloc=M.stackAlloc,Ye=t.stackRestore=M.stackRestore,Xe=t.stackSave=M.stackSave;if(t.asm=M,t.cwrap=b,t.setValue=m,t.getValue=h,De){ke(De)||(De=o(De)),Te(`memory initializer`);var Ze=function(e){e.byteLength&&(e=new Uint8Array(e)),A.set(e,p),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,Ee(`memory initializer`)},Qe=function(){s(De,Ze,function(){throw`could not load memory initializer `+De})},$e=Ke(De);if($e)Ze($e.buffer);else if(t.memoryInitializerRequest){var et=function(){var e=t.memoryInitializerRequest,n=e.response;if(e.status!==200&&e.status!==0){var r=Ke(t.memoryInitializerRequestURL);if(r)n=r.buffer;else{console.warn(`a problem seems to have happened with Module.memoryInitializerRequest, status: `+e.status+`, retrying `+De),Qe();return}}Ze(n)};t.memoryInitializerRequest.response?setTimeout(et,0):t.memoryInitializerRequest.addEventListener(`load`,et)}else Qe()}var tt;we=function e(){tt||nt(),tt||(we=e)};function nt(e){if(e||=i,Se>0||(fe(),Se>0))return;function n(){tt||(tt=!0,!g&&(pe(),me(),t.onRuntimeInitialized&&t.onRuntimeInitialized(),he()))}t.setStatus?(t.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){t.setStatus(``)},1),n()},1)):n()}t.run=nt;function rt(e){throw t.onAbort&&t.onAbort(e),e+=``,c(e),l(e),g=!0,`abort(`+e+`). Build with -s ASSERTIONS=1 for more info.`}if(t.abort=rt,t.preInit)for(typeof t.preInit==`function`&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return nt(),e}(typeof Uf==`object`?Uf:{}),Wf=`number`,Gf=Wf,Kf=Wf,qf=Wf,Jf=Wf,Yf=Wf,Xf=Wf,Zf=[[`sizeOfH3Index`,Wf],[`sizeOfLatLng`,Wf],[`sizeOfCellBoundary`,Wf],[`sizeOfGeoLoop`,Wf],[`sizeOfGeoPolygon`,Wf],[`sizeOfLinkedGeoPolygon`,Wf],[`sizeOfCoordIJ`,Wf],[`readInt64AsDoubleFromPointer`,Wf],[`isValidCell`,Kf,[qf,Jf]],[`isValidIndex`,Kf,[qf,Jf]],[`latLngToCell`,Gf,[Wf,Wf,Yf,Xf]],[`cellToLatLng`,Gf,[qf,Jf,Xf]],[`cellToBoundary`,Gf,[qf,Jf,Xf]],[`maxGridDiskSize`,Gf,[Wf,Xf]],[`gridDisk`,Gf,[qf,Jf,Wf,Xf]],[`gridDiskDistances`,Gf,[qf,Jf,Wf,Xf,Xf]],[`gridRing`,Gf,[qf,Jf,Wf,Xf]],[`gridRingUnsafe`,Gf,[qf,Jf,Wf,Xf]],[`maxPolygonToCellsSize`,Gf,[Xf,Yf,Wf,Xf]],[`polygonToCells`,Gf,[Xf,Yf,Wf,Xf]],[`maxPolygonToCellsSizeExperimental`,Gf,[Xf,Yf,Wf,Xf]],[`polygonToCellsExperimental`,Gf,[Xf,Yf,Wf,Wf,Wf,Xf]],[`cellsToLinkedMultiPolygon`,Gf,[Xf,Wf,Xf]],[`destroyLinkedMultiPolygon`,null,[Xf]],[`compactCells`,Gf,[Xf,Xf,Wf,Wf]],[`uncompactCells`,Gf,[Xf,Wf,Wf,Xf,Wf,Yf]],[`uncompactCellsSize`,Gf,[Xf,Wf,Wf,Yf,Xf]],[`isPentagon`,Kf,[qf,Jf]],[`isResClassIII`,Kf,[qf,Jf]],[`getBaseCellNumber`,Wf,[qf,Jf]],[`getResolution`,Wf,[qf,Jf]],[`getIndexDigit`,Wf,[qf,Jf,Wf]],[`constructCell`,Gf,[Wf,Wf,Xf,Xf]],[`maxFaceCount`,Gf,[qf,Jf,Xf]],[`getIcosahedronFaces`,Gf,[qf,Jf,Xf]],[`cellToParent`,Gf,[qf,Jf,Yf,Xf]],[`cellToChildren`,Gf,[qf,Jf,Yf,Xf]],[`cellToCenterChild`,Gf,[qf,Jf,Yf,Xf]],[`cellToChildrenSize`,Gf,[qf,Jf,Yf,Xf]],[`cellToChildPos`,Gf,[qf,Jf,Yf,Xf]],[`childPosToCell`,Gf,[Wf,Wf,qf,Jf,Yf,Xf]],[`areNeighborCells`,Gf,[qf,Jf,qf,Jf,Xf]],[`cellsToDirectedEdge`,Gf,[qf,Jf,qf,Jf,Xf]],[`getDirectedEdgeOrigin`,Gf,[qf,Jf,Xf]],[`getDirectedEdgeDestination`,Gf,[qf,Jf,Xf]],[`isValidDirectedEdge`,Kf,[qf,Jf]],[`directedEdgeToCells`,Gf,[qf,Jf,Xf]],[`originToDirectedEdges`,Gf,[qf,Jf,Xf]],[`directedEdgeToBoundary`,Gf,[qf,Jf,Xf]],[`gridDistance`,Gf,[qf,Jf,qf,Jf,Xf]],[`gridPathCells`,Gf,[qf,Jf,qf,Jf,Xf]],[`gridPathCellsSize`,Gf,[qf,Jf,qf,Jf,Xf]],[`cellToLocalIj`,Gf,[qf,Jf,qf,Jf,Wf,Xf]],[`localIjToCell`,Gf,[qf,Jf,Xf,Wf,Xf]],[`getHexagonAreaAvgM2`,Gf,[Yf,Xf]],[`getHexagonAreaAvgKm2`,Gf,[Yf,Xf]],[`getHexagonEdgeLengthAvgM`,Gf,[Yf,Xf]],[`getHexagonEdgeLengthAvgKm`,Gf,[Yf,Xf]],[`greatCircleDistanceM`,Wf,[Xf,Xf]],[`greatCircleDistanceKm`,Wf,[Xf,Xf]],[`greatCircleDistanceRads`,Wf,[Xf,Xf]],[`cellAreaM2`,Gf,[qf,Jf,Xf]],[`cellAreaKm2`,Gf,[qf,Jf,Xf]],[`cellAreaRads2`,Gf,[qf,Jf,Xf]],[`edgeLengthM`,Gf,[qf,Jf,Xf]],[`edgeLengthKm`,Gf,[qf,Jf,Xf]],[`edgeLengthRads`,Gf,[qf,Jf,Xf]],[`getNumCells`,Gf,[Yf,Xf]],[`getRes0Cells`,Gf,[Xf]],[`res0CellCount`,Wf],[`getPentagons`,Gf,[Wf,Xf]],[`pentagonCount`,Wf],[`cellToVertex`,Gf,[qf,Jf,Wf,Xf]],[`cellToVertexes`,Gf,[qf,Jf,Xf]],[`vertexToLatLng`,Gf,[qf,Jf,Xf]],[`isValidVertex`,Kf,[qf,Jf]]],Qf=0,$f=1,ep=2,tp=3,np=4,rp=5,ip=6,ap=7,op=8,sp=9,cp=10,lp=11,up=12,dp=13,fp=14,pp=15,mp=16,hp=17,gp=18,_p=19,vp={};vp[Qf]=`Success`,vp[$f]=`The operation failed but a more specific error is not available`,vp[ep]=`Argument was outside of acceptable range`,vp[tp]=`Latitude or longitude arguments were outside of acceptable range`,vp[np]=`Resolution argument was outside of acceptable range`,vp[rp]=`Cell argument was not valid`,vp[ip]=`Directed edge argument was not valid`,vp[ap]=`Undirected edge argument was not valid`,vp[op]=`Vertex argument was not valid`,vp[sp]=`Pentagon distortion was encountered`,vp[cp]=`Duplicate input`,vp[lp]=`Cell arguments were not neighbors`,vp[up]=`Cell arguments had incompatible resolutions`,vp[dp]=`Memory allocation failed`,vp[fp]=`Bounds of provided memory were insufficient`,vp[pp]=`Mode or flags argument was not valid`,vp[mp]=`Index argument was not valid`,vp[hp]=`Base cell number was outside of acceptable range`,vp[gp]=`Child indexing digits invalid`,vp[_p]=`Child indexing digits refer to a deleted subsequence`;var yp=1e3,bp=1001,xp=1002,Sp={};Sp[yp]=`Unknown unit`,Sp[bp]=`Array length out of bounds`,Sp[xp]=`Got unexpected null value for H3 index`;var Cp=`Unknown error`;function wp(e,t,n){var r=n&&`value`in n,i=Error((e[t]||Cp)+` (code: `+t+(r?`, value: `+n.value:``)+`)`);return i.code=t,i}function Tp(e,t){return wp(vp,e,arguments.length===2?{value:t}:{})}function Ep(e,t){return wp(Sp,e,arguments.length===2?{value:t}:{})}function Dp(e){if(e!==0)throw Tp(e)}var Op={};Zf.forEach(function(e){Op[e[0]]=Uf.cwrap.apply(Uf,e)});var kp=16,Ap=4,jp=8,Mp=8,Np=Op.sizeOfH3Index(),Pp=Op.sizeOfLatLng(),Fp=Op.sizeOfCellBoundary(),Ip=Op.sizeOfGeoPolygon(),Lp=Op.sizeOfGeoLoop();Op.sizeOfLinkedGeoPolygon(),Op.sizeOfCoordIJ();function Rp(e){if(typeof e!=`number`||e<0||e>15||Math.floor(e)!==e)throw Tp(np,e);return e}function zp(e){if(!e)throw Ep(xp);return e}var Bp=2**32-1;function Vp(e){if(e>Bp)throw Ep(bp,e);return e}var Hp=/[^0-9a-fA-F]/;function Up(e){if(Array.isArray(e)&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if(typeof e!=`string`||Hp.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),kp);return[parseInt(e.substring(e.length-8),kp),t]}function Wp(e){if(e>=0)return e.toString(kp);e&=2147483647;var t=Kp(8,e.toString(kp));return t=(parseInt(t[0],kp)+8).toString(kp)+t.substring(1),t}function Gp(e,t){return Wp(t)+Kp(8,Wp(e))}function Kp(e,t){for(var n=e-t.length,r=``,i=0;i<n;i++)r+=`0`;return r+=t,r}function qp(e,t,n){for(var r=e.length,i=Uf._calloc(r,Pp),a=+!!n,o=+!n,s=0;s<r*2;s+=2)Uf.HEAPF64.set([e[s/2][a],e[s/2][o]].map(sm),i/jp+s);return Uf.HEAPU32.set([r,i],t/Ap),t}function Jp(e,t){var n=e.length-1,r=Uf._calloc(Ip),i=0,a=i+Lp,o=a+Ap;qp(e[0],r+i,t);var s;if(n>0){s=Uf._calloc(n,Lp);for(var c=0;c<n;c++)qp(e[c+1],s+Lp*c,t)}return Uf.setValue(r+a,n,`i32`),Uf.setValue(r+o,s,`i32`),r}function Yp(e){var t=0,n=t+Lp,r=n+Ap,i=Ap;Uf._free(Uf.getValue(e+t+i,`i8*`));var a=Uf.getValue(e+n,`i32`);if(a>0){for(var o=Uf.getValue(e+r,`i32`),s=0;s<a;s++)Uf._free(Uf.getValue(o+Lp*s+i,`i8*`));Uf._free(o)}Uf._free(e)}function Xp(e,t){t===void 0&&(t=0);var n=Uf.getValue(e+Np*t,`i32`),r=Uf.getValue(e+Np*t+Ap,`i32`);return r?Gp(n,r):null}function Zp(e){return Op.readInt64AsDoubleFromPointer(e)}function Qp(e,t){for(var n=[],r=0;r<t;r++){var i=Xp(e,r);i!==null&&n.push(i)}return n}function $p(e){return cm(Uf.getValue(e,`double`))}function em(e){return[$p(e),$p(e+jp)]}function tm(e){return[$p(e+jp),$p(e)]}function nm(e,t,n){for(var r=Uf.getValue(e,`i32`),i=e+jp,a=[],o=t?tm:em,s=0;s<r*2;s+=2)a.push(o(i+jp*s));return n&&a.push(a[0]),a}function rm(e,t,n){var r=Uf._malloc(Pp);Uf.HEAPF64.set([e,t].map(sm),r/jp);var i=Uf._malloc(Np);try{return Dp(Op.latLngToCell(r,n,i)),zp(Xp(i))}finally{Uf._free(i),Uf._free(r)}}function im(e){var t=Uf._malloc(Pp),n=Up(e),r=n[0],i=n[1];try{return Dp(Op.cellToLatLng(r,i,t)),em(t)}finally{Uf._free(t)}}function am(e,t){var n=Uf._malloc(Fp),r=Up(e),i=r[0],a=r[1];try{return Dp(Op.cellToBoundary(i,a,n)),nm(n,t,t)}finally{Uf._free(n)}}function om(e,t,n){if(Rp(t),n=!!n,e.length===0||e[0].length===0)return[];var r=Jp(typeof e[0][0]==`number`?[e]:e,n),i=Uf._malloc(Mp);try{Dp(Op.maxPolygonToCellsSize(r,t,0,i));var a=Vp(Zp(i)),o=Uf._calloc(a,Np);try{return Dp(Op.polygonToCells(r,t,0,o)),Qp(o,a)}finally{Uf._free(o)}}finally{Uf._free(i),Yp(r)}}function sm(e){return e*Math.PI/180}function cm(e){return e*180/Math.PI}function lm(e){return e=Math.max(0,Math.min(1,e)),`rgb(`+Math.max(0,Math.min(255,Math.round(34.61+e*(1172.33-e*(10793.56-e*(33300.12-e*(38394.49-e*14825.05)))))))+`, `+Math.max(0,Math.min(255,Math.round(23.31+e*(557.33+e*(1225.33-e*(3574.96-e*(1073.77+e*707.56)))))))+`, `+Math.max(0,Math.min(255,Math.round(27.2+e*(3211.1-e*(15327.97-e*(27814-e*(22569.18-e*6838.66)))))))+`)`}var um=1e3,dm=1001,fm=1002,pm=1003,mm=1004,hm=1005,gm=1006,_m=1007,vm=1008,ym=1008,bm=1009,xm=1010,Sm=1011,Cm=1012,wm=1013,Tm=1014,Em=1015,Dm=1016,Om=1017,km=1018,Am=1020,jm=35902,Mm=35899,Nm=1021,Pm=1022,Fm=1023,Im=1026,Lm=1027,Rm=1028,zm=1029,Bm=1030,Vm=1031,Hm=1032,Um=1033,Wm=33776,Gm=33777,Km=33778,qm=33779,Jm=35840,Ym=35841,Xm=35842,Zm=35843,Qm=36196,$m=37492,eh=37496,th=37488,nh=37489,rh=37490,ih=37491,ah=37808,oh=37809,sh=37810,ch=37811,lh=37812,uh=37813,dh=37814,fh=37815,ph=37816,mh=37817,hh=37818,gh=37819,_h=37820,vh=37821,yh=36492,bh=36494,xh=36495,Sh=36283,Ch=36284,wh=36285,Th=36286,Eh=2300,Dh=2301,Oh=2302,kh=2303,Ah=2400,jh=2401,Mh=2402,Nh=`srgb`,Ph=`srgb-linear`,Fh=`linear`,Ih=`srgb`,Lh=7680,Rh=7681,zh=7682,Bh=7683,Vh=34055,Hh=34056,Uh=5386,Wh=35044,Gh=35048,Kh=2e3,qh=2001,Jh={COMPUTE:`compute`,RENDER:`render`},Yh={TEXTURE_COMPARE:`depthTextureCompare`};function Xh(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Zh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Qh(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function $h(){let e=Qh(`canvas`);return e.style.display=`block`,e}var eg={},tg=null;function ng(...e){let t=`THREE.`+e.shift();tg?tg(`log`,t,...e):console.log(t,...e)}function rg(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function R(...e){e=rg(e);let t=`THREE.`+e.shift();if(tg)tg(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function z(...e){e=rg(e);let t=`THREE.`+e.shift();if(tg)tg(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function ig(...e){let t=e.join(` `);t in eg||(eg[t]=!0,R(...e))}var ag={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},og=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},sg=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),cg=1234567,lg=Math.PI/180,ug=180/Math.PI;function dg(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(sg[e&255]+sg[e>>8&255]+sg[e>>16&255]+sg[e>>24&255]+`-`+sg[t&255]+sg[t>>8&255]+`-`+sg[t>>16&15|64]+sg[t>>24&255]+`-`+sg[n&63|128]+sg[n>>8&255]+`-`+sg[n>>16&255]+sg[n>>24&255]+sg[r&255]+sg[r>>8&255]+sg[r>>16&255]+sg[r>>24&255]).toLowerCase()}function fg(e,t,n){return Math.max(t,Math.min(n,e))}function pg(e,t){return(e%t+t)%t}function mg(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function hg(e,t,n){return e===t?0:(n-e)/(t-e)}function gg(e,t,n){return(1-n)*e+n*t}function _g(e,t,n,r){return gg(e,t,1-Math.exp(-n*r))}function vg(e,t=1){return t-Math.abs(pg(e,t*2)-t)}function yg(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function bg(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function xg(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Sg(e,t){return e+Math.random()*(t-e)}function Cg(e){return e*(.5-Math.random())}function wg(e){e!==void 0&&(cg=e);let t=cg+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Tg(e){return e*lg}function Eg(e){return e*ug}function Dg(e){return(e&e-1)==0&&e!==0}function Og(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function kg(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Ag(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:R(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function jg(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function Mg(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var Ng={DEG2RAD:lg,RAD2DEG:ug,generateUUID:dg,clamp:fg,euclideanModulo:pg,mapLinear:mg,inverseLerp:hg,lerp:gg,damp:_g,pingpong:vg,smoothstep:yg,smootherstep:bg,randInt:xg,randFloat:Sg,randFloatSpread:Cg,seededRandom:wg,degToRad:Tg,radToDeg:Eg,isPowerOfTwo:Dg,ceilPowerOfTwo:Og,floorPowerOfTwo:kg,setQuaternionFromProperEuler:Ag,normalize:Mg,denormalize:jg},Pg=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=fg(this.x,e.x,t.x),this.y=fg(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=fg(this.x,e,t),this.y=fg(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fg(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(fg(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Fg=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:R(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fg(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},B=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Lg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Lg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=fg(this.x,e.x,t.x),this.y=fg(this.y,e.y,t.y),this.z=fg(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=fg(this.x,e,t),this.y=fg(this.y,e,t),this.z=fg(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fg(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ig.copy(this).projectOnVector(e),this.sub(Ig)}reflect(e){return this.sub(Ig.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(fg(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ig=new B,Lg=new Fg,Rg=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(zg.makeScale(e,t)),this}rotate(e){return this.premultiply(zg.makeRotation(-e)),this}translate(e,t){return this.premultiply(zg.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},zg=new Rg,Bg=new Rg().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Vg=new Rg().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Hg(){let e={enabled:!0,workingColorSpace:Ph,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Wg(e.r),e.g=Wg(e.g),e.b=Wg(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Gg(e.r),e.g=Gg(e.g),e.b=Gg(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Fh:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return ig(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return ig(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Ph]:{primaries:t,whitePoint:r,transfer:Fh,toXYZ:Bg,fromXYZ:Vg,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Nh},outputColorSpaceConfig:{drawingBufferColorSpace:Nh}},[Nh]:{primaries:t,whitePoint:r,transfer:Ih,toXYZ:Bg,fromXYZ:Vg,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Nh}}}),e}var Ug=Hg();function Wg(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Gg(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Kg,qg=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Kg===void 0&&(Kg=Qh(`canvas`)),Kg.width=e.width,Kg.height=e.height;let t=Kg.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Kg}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Qh(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=Wg(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Wg(t[e]/255)*255):t[e]=Wg(t[e]);return{data:t,width:e.width,height:e.height}}else return R(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Jg=0,Yg=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:Jg++}),this.uuid=dg(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Xg(r[t].image)):e.push(Xg(r[t]))}else e=Xg(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Xg(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?qg.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(R(`Texture: Unable to serialize Texture.`),{})}var Zg=0,Qg=new B,$g=class e extends og{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=dm,i=dm,a=gm,o=vm,s=Fm,c=bm,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:Zg++}),this.uuid=dg(),this.name=``,this.source=new Yg(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new Pg(0,0),this.repeat=new Pg(1,1),this.center=new Pg(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Rg,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Qg).x}get height(){return this.source.getSize(Qg).y}get depth(){return this.source.getSize(Qg).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){R(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){R(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case um:e.x-=Math.floor(e.x);break;case dm:e.x=e.x<0?0:1;break;case fm:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case um:e.y-=Math.floor(e.y);break;case dm:e.y=e.y<0?0:1;break;case fm:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};$g.DEFAULT_IMAGE=null,$g.DEFAULT_MAPPING=300,$g.DEFAULT_ANISOTROPY=1;var e_=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=fg(this.x,e.x,t.x),this.y=fg(this.y,e.y,t.y),this.z=fg(this.z,e.z,t.z),this.w=fg(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=fg(this.x,e,t),this.y=fg(this.y,e,t),this.z=fg(this.z,e,t),this.w=fg(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(fg(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},t_=class extends og{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:gm,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new e_(0,0,e,t),this.scissorTest=!1,this.viewport=new e_(0,0,e,t),this.textures=[];let r=new $g({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:gm,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Yg(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},n_=class extends $g{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=pm,this.minFilter=pm,this.wrapR=dm,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},r_=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/i_.setFromMatrixColumn(e,0).length(),i=1/i_.setFromMatrixColumn(e,1).length(),a=1/i_.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(o_,e,s_)}lookAt(e,t,n){let r=this.elements;return u_.subVectors(e,t),u_.lengthSq()===0&&(u_.z=1),u_.normalize(),c_.crossVectors(n,u_),c_.lengthSq()===0&&(Math.abs(n.z)===1?u_.x+=1e-4:u_.z+=1e-4,u_.normalize(),c_.crossVectors(n,u_)),c_.normalize(),l_.crossVectors(u_,c_),r[0]=c_.x,r[4]=l_.x,r[8]=u_.x,r[1]=c_.y,r[5]=l_.y,r[9]=u_.y,r[2]=c_.z,r[6]=l_.z,r[10]=u_.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],ee=r[10],j=r[14],te=r[3],ne=r[7],re=r[11],ie=r[15];return i[0]=a*x+o*T+s*k+c*te,i[4]=a*S+o*E+s*A+c*ne,i[8]=a*C+o*D+s*ee+c*re,i[12]=a*w+o*O+s*j+c*ie,i[1]=l*x+u*T+d*k+f*te,i[5]=l*S+u*E+d*A+f*ne,i[9]=l*C+u*D+d*ee+f*re,i[13]=l*w+u*O+d*j+f*ie,i[2]=p*x+m*T+h*k+g*te,i[6]=p*S+m*E+h*A+g*ne,i[10]=p*C+m*D+h*ee+g*re,i[14]=p*w+m*O+h*j+g*ie,i[3]=_*x+v*T+y*k+b*te,i[7]=_*S+v*E+y*A+b*ne,i[11]=_*C+v*D+y*ee+b*re,i[15]=_*w+v*O+y*j+b*ie,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=i_.set(r[0],r[1],r[2]).length(),o=i_.set(r[4],r[5],r[6]).length(),s=i_.set(r[8],r[9],r[10]).length();i<0&&(a=-a),a_.copy(this);let c=1/a,l=1/o,u=1/s;return a_.elements[0]*=c,a_.elements[1]*=c,a_.elements[2]*=c,a_.elements[4]*=l,a_.elements[5]*=l,a_.elements[6]*=l,a_.elements[8]*=u,a_.elements[9]*=u,a_.elements[10]*=u,t.setFromRotationMatrix(a_),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Kh,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Kh,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},i_=new B,a_=new r_,o_=new B(0,0,0),s_=new B(1,1,1),c_=new B,l_=new B,u_=new B,d_=new r_,f_=new Fg,p_=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(fg(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-fg(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(fg(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-fg(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(fg(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-fg(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:R(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return d_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(d_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return f_.setFromEuler(this),this.setFromQuaternion(f_,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};p_.DEFAULT_ORDER=`XYZ`;var m_=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},h_=0,g_=new B,__=new Fg,v_=new r_,y_=new B,b_=new B,x_=new B,S_=new Fg,C_=new B(1,0,0),w_=new B(0,1,0),T_=new B(0,0,1),E_={type:`added`},D_={type:`removed`},O_={type:`childadded`,child:null},k_={type:`childremoved`,child:null},A_=class e extends og{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:h_++}),this.uuid=dg(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new B,n=new p_,r=new Fg,i=new B(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new r_},normalMatrix:{value:new Rg}}),this.matrix=new r_,this.matrixWorld=new r_,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new m_,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return __.setFromAxisAngle(e,t),this.quaternion.multiply(__),this}rotateOnWorldAxis(e,t){return __.setFromAxisAngle(e,t),this.quaternion.premultiply(__),this}rotateX(e){return this.rotateOnAxis(C_,e)}rotateY(e){return this.rotateOnAxis(w_,e)}rotateZ(e){return this.rotateOnAxis(T_,e)}translateOnAxis(e,t){return g_.copy(e).applyQuaternion(this.quaternion),this.position.add(g_.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(C_,e)}translateY(e){return this.translateOnAxis(w_,e)}translateZ(e){return this.translateOnAxis(T_,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(v_.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?y_.copy(e):y_.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),b_.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?v_.lookAt(b_,y_,this.up):v_.lookAt(y_,b_,this.up),this.quaternion.setFromRotationMatrix(v_),r&&(v_.extractRotation(r.matrixWorld),__.setFromRotationMatrix(v_),this.quaternion.premultiply(__.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(z(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(E_),O_.child=e,this.dispatchEvent(O_),O_.child=null):z(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(D_),k_.child=e,this.dispatchEvent(k_),k_.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),v_.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),v_.multiply(e.parent.matrixWorld)),e.applyMatrix4(v_),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(E_),O_.child=e,this.dispatchEvent(O_),O_.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(b_,e,x_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(b_,S_,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};A_.DEFAULT_UP=new B(0,1,0),A_.DEFAULT_MATRIX_AUTO_UPDATE=!0,A_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var j_=class extends A_{constructor(){super(),this.isGroup=!0,this.type=`Group`}},M_={type:`move`},N_=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new j_,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new j_,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new j_,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(M_)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new j_;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},P_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},F_={h:0,s:0,l:0},I_={h:0,s:0,l:0};function L_(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var R_=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ug.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ug.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ug.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ug.workingColorSpace){if(e=pg(e,1),t=fg(t,0,1),n=fg(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=L_(i,r,e+1/3),this.g=L_(i,r,e),this.b=L_(i,r,e-1/3)}return Ug.colorSpaceToWorking(this,r),this}setStyle(e,t=Nh){function n(t){t!==void 0&&parseFloat(t)<1&&R(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:R(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);R(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nh){let n=P_[e.toLowerCase()];return n===void 0?R(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Wg(e.r),this.g=Wg(e.g),this.b=Wg(e.b),this}copyLinearToSRGB(e){return this.r=Gg(e.r),this.g=Gg(e.g),this.b=Gg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nh){return Ug.workingToColorSpace(z_.copy(this),e),Math.round(fg(z_.r*255,0,255))*65536+Math.round(fg(z_.g*255,0,255))*256+Math.round(fg(z_.b*255,0,255))}getHexString(e=Nh){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ug.workingColorSpace){Ug.workingToColorSpace(z_.copy(this),t);let n=z_.r,r=z_.g,i=z_.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Ug.workingColorSpace){return Ug.workingToColorSpace(z_.copy(this),t),e.r=z_.r,e.g=z_.g,e.b=z_.b,e}getStyle(e=Nh){Ug.workingToColorSpace(z_.copy(this),e);let t=z_.r,n=z_.g,r=z_.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(F_),this.setHSL(F_.h+e,F_.s+t,F_.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(F_),e.getHSL(I_);let n=gg(F_.h,I_.h,t),r=gg(F_.s,I_.s,t),i=gg(F_.l,I_.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},z_=new R_;R_.NAMES=P_;var B_=class extends A_{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new p_,this.environmentIntensity=1,this.environmentRotation=new p_,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},V_=new B,H_=new B,U_=new B,W_=new B,G_=new B,K_=new B,q_=new B,J_=new B,Y_=new B,X_=new B,Z_=new e_,Q_=new e_,$_=new e_,ev=class e{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),V_.subVectors(e,t),r.cross(V_);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){V_.subVectors(r,t),H_.subVectors(n,t),U_.subVectors(e,t);let a=V_.dot(V_),o=V_.dot(H_),s=V_.dot(U_),c=H_.dot(H_),l=H_.dot(U_),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,W_)===null?!1:W_.x>=0&&W_.y>=0&&W_.x+W_.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,W_)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,W_.x),s.addScaledVector(a,W_.y),s.addScaledVector(o,W_.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Z_.setScalar(0),Q_.setScalar(0),$_.setScalar(0),Z_.fromBufferAttribute(e,t),Q_.fromBufferAttribute(e,n),$_.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Z_,i.x),a.addScaledVector(Q_,i.y),a.addScaledVector($_,i.z),a}static isFrontFacing(e,t,n,r){return V_.subVectors(n,t),H_.subVectors(e,t),V_.cross(H_).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return V_.subVectors(this.c,this.b),H_.subVectors(this.a,this.b),V_.cross(H_).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;G_.subVectors(r,n),K_.subVectors(i,n),J_.subVectors(e,n);let s=G_.dot(J_),c=K_.dot(J_);if(s<=0&&c<=0)return t.copy(n);Y_.subVectors(e,r);let l=G_.dot(Y_),u=K_.dot(Y_);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(G_,a);X_.subVectors(e,i);let f=G_.dot(X_),p=K_.dot(X_);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(K_,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return q_.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(q_,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(G_,a).addScaledVector(K_,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},tv=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(rv.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(rv.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=rv.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,rv):rv.fromBufferAttribute(r,t),rv.applyMatrix4(e.matrixWorld),this.expandByPoint(rv);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),iv.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),iv.copy(e.boundingBox)),iv.applyMatrix4(e.matrixWorld),this.union(iv)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,rv),rv.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dv),fv.subVectors(this.max,dv),av.subVectors(e.a,dv),ov.subVectors(e.b,dv),sv.subVectors(e.c,dv),cv.subVectors(ov,av),lv.subVectors(sv,ov),uv.subVectors(av,sv);let t=[0,-cv.z,cv.y,0,-lv.z,lv.y,0,-uv.z,uv.y,cv.z,0,-cv.x,lv.z,0,-lv.x,uv.z,0,-uv.x,-cv.y,cv.x,0,-lv.y,lv.x,0,-uv.y,uv.x,0];return!hv(t,av,ov,sv,fv)||(t=[1,0,0,0,1,0,0,0,1],!hv(t,av,ov,sv,fv))?!1:(pv.crossVectors(cv,lv),t=[pv.x,pv.y,pv.z],hv(t,av,ov,sv,fv))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,rv).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(rv).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(nv[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),nv[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),nv[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),nv[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),nv[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),nv[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),nv[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),nv[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(nv),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},nv=[new B,new B,new B,new B,new B,new B,new B,new B],rv=new B,iv=new tv,av=new B,ov=new B,sv=new B,cv=new B,lv=new B,uv=new B,dv=new B,fv=new B,pv=new B,mv=new B;function hv(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){mv.fromArray(e,a);let o=i.x*Math.abs(mv.x)+i.y*Math.abs(mv.y)+i.z*Math.abs(mv.z),s=t.dot(mv),c=n.dot(mv),l=r.dot(mv);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var gv=_v();function _v(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function vv(e){Math.abs(e)>65504&&R(`DataUtils.toHalfFloat(): Value out of range.`),e=fg(e,-65504,65504),gv.floatView[0]=e;let t=gv.uint32View[0],n=t>>23&511;return gv.baseTable[n]+((t&8388607)>>gv.shiftTable[n])}function yv(e){let t=e>>10;return gv.uint32View[0]=gv.mantissaTable[gv.offsetTable[t]+(e&1023)]+gv.exponentTable[t],gv.floatView[0]}var bv=new B,xv=new Pg,Sv=0,Cv=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:Sv++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Wh,this.updateRanges=[],this.gpuType=Em,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xv.fromBufferAttribute(this,t),xv.applyMatrix3(e),this.setXY(t,xv.x,xv.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bv.fromBufferAttribute(this,t),bv.applyMatrix3(e),this.setXYZ(t,bv.x,bv.y,bv.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bv.fromBufferAttribute(this,t),bv.applyMatrix4(e),this.setXYZ(t,bv.x,bv.y,bv.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bv.fromBufferAttribute(this,t),bv.applyNormalMatrix(e),this.setXYZ(t,bv.x,bv.y,bv.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bv.fromBufferAttribute(this,t),bv.transformDirection(e),this.setXYZ(t,bv.x,bv.y,bv.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=jg(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mg(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=jg(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=jg(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=jg(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=jg(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array),i=Mg(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},wv=class extends Cv{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Tv=class extends Cv{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ev=class extends Cv{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=yv(this.array[e*this.itemSize]);return this.normalized&&(t=jg(t,this.array)),t}setX(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize]=vv(t),this}getY(e){let t=yv(this.array[e*this.itemSize+1]);return this.normalized&&(t=jg(t,this.array)),t}setY(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+1]=vv(t),this}getZ(e){let t=yv(this.array[e*this.itemSize+2]);return this.normalized&&(t=jg(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+2]=vv(t),this}getW(e){let t=yv(this.array[e*this.itemSize+3]);return this.normalized&&(t=jg(t,this.array)),t}setW(e,t){return this.normalized&&(t=Mg(t,this.array)),this.array[e*this.itemSize+3]=vv(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array)),this.array[e+0]=vv(t),this.array[e+1]=vv(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array)),this.array[e+0]=vv(t),this.array[e+1]=vv(n),this.array[e+2]=vv(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array),i=Mg(i,this.array)),this.array[e+0]=vv(t),this.array[e+1]=vv(n),this.array[e+2]=vv(r),this.array[e+3]=vv(i),this}},Dv=class extends Cv{constructor(e,t,n){super(new Float32Array(e),t,n)}},Ov=new tv,kv=new B,Av=new B,jv=class{constructor(e=new B,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Ov.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;kv.subVectors(e,this.center);let t=kv.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(kv,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Av.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(kv.copy(e.center).add(Av)),this.expandByPoint(kv.copy(e.center).sub(Av))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Mv=0,Nv=new r_,Pv=new A_,Fv=new B,Iv=new tv,Lv=new tv,Rv=new B,zv=class e extends og{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:Mv++}),this.uuid=dg(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Xh(e)?Tv:wv)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Rg().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Nv.makeRotationFromQuaternion(e),this.applyMatrix4(Nv),this}rotateX(e){return Nv.makeRotationX(e),this.applyMatrix4(Nv),this}rotateY(e){return Nv.makeRotationY(e),this.applyMatrix4(Nv),this}rotateZ(e){return Nv.makeRotationZ(e),this.applyMatrix4(Nv),this}translate(e,t,n){return Nv.makeTranslation(e,t,n),this.applyMatrix4(Nv),this}scale(e,t,n){return Nv.makeScale(e,t,n),this.applyMatrix4(Nv),this}lookAt(e){return Pv.lookAt(e),Pv.updateMatrix(),this.applyMatrix4(Pv.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fv).negate(),this.translate(Fv.x,Fv.y,Fv.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Dv(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&R(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tv);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){z(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Iv.setFromBufferAttribute(n),this.morphTargetsRelative?(Rv.addVectors(this.boundingBox.min,Iv.min),this.boundingBox.expandByPoint(Rv),Rv.addVectors(this.boundingBox.max,Iv.max),this.boundingBox.expandByPoint(Rv)):(this.boundingBox.expandByPoint(Iv.min),this.boundingBox.expandByPoint(Iv.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&z(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jv);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){z(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new B,1/0);return}if(e){let n=this.boundingSphere.center;if(Iv.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Lv.setFromBufferAttribute(n),this.morphTargetsRelative?(Rv.addVectors(Iv.min,Lv.min),Iv.expandByPoint(Rv),Rv.addVectors(Iv.max,Lv.max),Iv.expandByPoint(Rv)):(Iv.expandByPoint(Lv.min),Iv.expandByPoint(Lv.max))}Iv.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Rv.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Rv));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Rv.fromBufferAttribute(a,t),o&&(Fv.fromBufferAttribute(e,t),Rv.add(Fv)),r=Math.max(r,n.distanceToSquared(Rv))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&z(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){z(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Cv(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new B,s[e]=new B;let c=new B,l=new B,u=new B,d=new Pg,f=new Pg,p=new Pg,m=new B,h=new B;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new B,y=new B,b=new B,x=new B;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Cv(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new B,i=new B,a=new B,o=new B,s=new B,c=new B,l=new B,u=new B;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Rv.fromBufferAttribute(e,t),Rv.normalize(),e.setXYZ(t,Rv.x,Rv.y,Rv.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Cv(a,r,i)}if(this.index===null)return R(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},Bv=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Wh,this.updateRanges=[],this.version=0,this.uuid=dg()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dg()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dg()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Vv=new B,Hv=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Vv.fromBufferAttribute(this,t),Vv.applyMatrix4(e),this.setXYZ(t,Vv.x,Vv.y,Vv.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vv.fromBufferAttribute(this,t),Vv.applyNormalMatrix(e),this.setXYZ(t,Vv.x,Vv.y,Vv.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vv.fromBufferAttribute(this,t),Vv.transformDirection(e),this.setXYZ(t,Vv.x,Vv.y,Vv.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=jg(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Mg(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Mg(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Mg(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Mg(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Mg(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=jg(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=jg(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=jg(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=jg(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Mg(t,this.array),n=Mg(n,this.array),r=Mg(r,this.array),i=Mg(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){ng(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Cv(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){ng(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Uv=0,Wv=class extends og{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:Uv++}),this.uuid=dg(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new R_(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lh,this.stencilZFail=Lh,this.stencilZPass=Lh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){R(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){R(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Gv=class extends Wv{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new R_(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Kv=new B,qv=new B,Jv=new B,Yv=new B,Xv=new B,Zv=new B,Qv=new B,$v=class{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Kv)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Kv.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kv.copy(this.origin).addScaledVector(this.direction,t),Kv.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){qv.copy(e).add(t).multiplyScalar(.5),Jv.copy(t).sub(e).normalize(),Yv.copy(this.origin).sub(qv);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Jv),o=Yv.dot(this.direction),s=-Yv.dot(Jv),c=Yv.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(qv).addScaledVector(Jv,d),f}intersectSphere(e,t){Kv.subVectors(e.center,this.origin);let n=Kv.dot(this.direction),r=Kv.dot(Kv)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Kv)!==null}intersectTriangle(e,t,n,r,i){Xv.subVectors(t,e),Zv.subVectors(n,e),Qv.crossVectors(Xv,Zv);let a=this.direction.dot(Qv),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Yv.subVectors(this.origin,e);let s=o*this.direction.dot(Zv.crossVectors(Yv,Zv));if(s<0)return null;let c=o*this.direction.dot(Xv.cross(Yv));if(c<0||s+c>a)return null;let l=-o*Yv.dot(Qv);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ey=class extends Wv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new R_(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new p_,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ty=new r_,ny=new $v,ry=new jv,iy=new B,ay=new B,oy=new B,sy=new B,cy=new B,ly=new B,uy=new B,dy=new B,fy=class extends A_{constructor(e=new zv,t=new ey){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){ly.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(cy.fromBufferAttribute(s,e),a?ly.addScaledVector(cy,r):ly.addScaledVector(cy.sub(t),r))}t.add(ly)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ry.copy(n.boundingSphere),ry.applyMatrix4(i),ny.copy(e.ray).recast(e.near),!(ry.containsPoint(ny.origin)===!1&&(ny.intersectSphere(ry,iy)===null||ny.origin.distanceToSquared(iy)>(e.far-e.near)**2))&&(ty.copy(i).invert(),ny.copy(e.ray).applyMatrix4(ty),!(n.boundingBox!==null&&ny.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ny)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=my(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=my(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=my(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=my(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function py(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;dy.copy(s),dy.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(dy);return l<n.near||l>n.far?null:{distance:l,point:dy.clone(),object:e}}function my(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,ay),e.getVertexPosition(c,oy),e.getVertexPosition(l,sy);let u=py(e,t,n,r,ay,oy,sy,uy);if(u){let e=new B;ev.getBarycoord(uy,ay,oy,sy,e),i&&(u.uv=ev.getInterpolatedAttribute(i,s,c,l,e,new Pg)),a&&(u.uv1=ev.getInterpolatedAttribute(a,s,c,l,e,new Pg)),o&&(u.normal=ev.getInterpolatedAttribute(o,s,c,l,e,new B),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new B,materialIndex:0};ev.getNormal(ay,oy,sy,t.normal),u.face=t,u.barycoord=e}return u}var hy=class extends $g{constructor(e=null,t=1,n=1,r,i,a,o,s,c=pm,l=pm,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},gy=class extends Cv{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},_y=new B,vy=new B,yy=new Rg,by=class{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=_y.subVectors(n,t).cross(vy.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(_y),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||yy.getNormalMatrix(e),r=this.coplanarPoint(_y).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},xy=new jv,Sy=new Pg(.5,.5),Cy=new B,wy=class{constructor(e=new by,t=new by,n=new by,r=new by,i=new by,a=new by){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Kh,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),xy.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xy.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xy)}intersectsSprite(e){return xy.center.set(0,0,0),xy.radius=.7071067811865476+Sy.distanceTo(e.center),xy.applyMatrix4(e.matrixWorld),this.intersectsSphere(xy)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Cy.x=r.normal.x>0?e.max.x:e.min.x,Cy.y=r.normal.y>0?e.max.y:e.min.y,Cy.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Cy)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Ty=new r_,Ey=new wy,Dy=class e{constructor(){this.coordinateSystem=Kh}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(Ty.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ey.setFromProjectionMatrix(Ty,r.coordinateSystem,r.reversedDepth),Ey.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(Ty.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ey.setFromProjectionMatrix(Ty,r.coordinateSystem,r.reversedDepth),Ey.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(Ty.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ey.setFromProjectionMatrix(Ty,r.coordinateSystem,r.reversedDepth),Ey.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(Ty.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ey.setFromProjectionMatrix(Ty,r.coordinateSystem,r.reversedDepth),Ey.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(Ty.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Ey.setFromProjectionMatrix(Ty,r.coordinateSystem,r.reversedDepth),Ey.containsPoint(e))return!0}return!1}clone(){return new e}},Oy=class extends Wv{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new R_(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},ky=class extends Wv{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new R_(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ay=class extends $g{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=pm,this.minFilter=pm,this.generateMipmaps=!1,this.needsUpdate=!0}},jy=class extends $g{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},My=class extends $g{constructor(e,t,n=Tm,r,i,a,o=pm,s=pm,c,l=Im,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Yg(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ny=class extends My{constructor(e,t=Tm,n=301,r,i,a=pm,o=pm,s,c=Im){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Py=class e extends zv{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Dv(c,3)),this.setAttribute(`normal`,new Dv(l,3)),this.setAttribute(`uv`,new Dv(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new B;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Fy=class e extends zv{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Dv(u,3)),this.setAttribute(`normal`,new Dv(d,3)),this.setAttribute(`uv`,new Dv(f,2));function _(){let a=new B,_=new B,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new Pg,m=new B,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Iy=class e extends zv{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Dv(p,3)),this.setAttribute(`normal`,new Dv(m,3)),this.setAttribute(`uv`,new Dv(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},Ly=class e extends zv{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new B,d=new B,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new Dv(p,3)),this.setAttribute(`normal`,new Dv(m,3)),this.setAttribute(`uv`,new Dv(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},Ry=class extends Wv{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new R_(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},zy=class extends Wv{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new R_(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new R_(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new p_,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},By=class extends zy{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pg(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,`reflectivity`,{get:function(){return fg(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new R_(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new R_(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new R_(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Vy=class extends Wv{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new R_(16777215),this.specular=new R_(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new R_(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new p_,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Hy=class extends Wv{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new R_(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new R_(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Uy=class extends Wv{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},Wy=class extends Wv{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new R_(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new R_(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new p_,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Gy=class extends Wv{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new R_(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Pg(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:``},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}},Ky=class extends Oy{constructor(e){super(),this.isLineDashedMaterial=!0,this.type=`LineDashedMaterial`,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function qy(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Jy=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},Yy=class extends Jy{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ah,endingEnd:Ah}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case jh:i=e,o=2*t-n;break;case Mh:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case jh:a=e,s=2*n-t;break;case Mh:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Xy=class extends Jy{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Zy=class extends Jy{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Qy=class extends Jy{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.settings||this.DefaultSettings_,u=l.inTangents,d=l.outTangents;if(!u||!d){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let f=o*2,p=e-1;for(let l=0;l!==o;++l){let o=a[c+l],m=a[s+l],h=p*f+l*2,g=d[h],_=d[h+1],v=e*f+l*2,y=u[v],b=u[v+1],x=(n-t)/(r-t),S,C,w,T,E;for(let e=0;e<8;e++){S=x*x,C=S*x,w=1-x,T=w*w,E=T*w;let e=E*t+3*T*x*g+3*w*S*y+C*r-n;if(Math.abs(e)<1e-10)break;let i=3*T*(g-t)+6*w*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[l]=E*o+3*T*x*_+3*w*S*b+C*m}return i}},$y=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=qy(t,this.TimeBufferType),this.values=qy(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:qy(e.times,Array),values:qy(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Zy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Yy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Qy(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case Eh:t=this.InterpolantFactoryMethodDiscrete;break;case Dh:t=this.InterpolantFactoryMethodLinear;break;case Oh:t=this.InterpolantFactoryMethodSmooth;break;case kh:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return R(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Eh;case this.InterpolantFactoryMethodLinear:return Dh;case this.InterpolantFactoryMethodSmooth:return Oh;case this.InterpolantFactoryMethodBezier:return kh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(z(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(z(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){z(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){z(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Zh(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){z(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Oh,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};$y.prototype.ValueTypeName=``,$y.prototype.TimeBufferType=Float32Array,$y.prototype.ValueBufferType=Float32Array,$y.prototype.DefaultInterpolation=Dh;var eb=class extends $y{constructor(e,t,n){super(e,t,n)}};eb.prototype.ValueTypeName=`bool`,eb.prototype.ValueBufferType=Array,eb.prototype.DefaultInterpolation=Eh,eb.prototype.InterpolantFactoryMethodLinear=void 0,eb.prototype.InterpolantFactoryMethodSmooth=void 0;var tb=class extends $y{constructor(e,t,n,r){super(e,t,n,r)}};tb.prototype.ValueTypeName=`color`;var nb=class extends $y{constructor(e,t,n,r){super(e,t,n,r)}};nb.prototype.ValueTypeName=`number`;var rb=class extends Jy{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)Fg.slerpFlat(i,0,a,c-o,a,c,s);return i}},ib=class extends $y{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new rb(this.times,this.values,this.getValueSize(),e)}};ib.prototype.ValueTypeName=`quaternion`,ib.prototype.InterpolantFactoryMethodSmooth=void 0;var ab=class extends $y{constructor(e,t,n){super(e,t,n)}};ab.prototype.ValueTypeName=`string`,ab.prototype.ValueBufferType=Array,ab.prototype.DefaultInterpolation=Eh,ab.prototype.InterpolantFactoryMethodLinear=void 0,ab.prototype.InterpolantFactoryMethodSmooth=void 0;var ob=class extends $y{constructor(e,t,n,r){super(e,t,n,r)}};ob.prototype.ValueTypeName=`vector`;var sb=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||=new AbortController,this._abortController}},cb=class{constructor(e){this.manager=e===void 0?sb:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};cb.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var lb=class extends A_{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new R_(e),this.intensity=t}dispose(){this.dispatchEvent({type:`dispose`})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},ub=class extends lb{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(A_.DEFAULT_UP),this.updateMatrix(),this.groundColor=new R_(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},db=new r_,fb=new B,pb=new B,mb=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pg(512,512),this.mapType=bm,this.map=null,this.mapPass=null,this.matrix=new r_,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wy,this._frameExtents=new Pg(1,1),this._viewportCount=1,this._viewports=[new e_(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;fb.setFromMatrixPosition(e.matrixWorld),t.position.copy(fb),pb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(pb),t.updateMatrixWorld(),db.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(db,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===2001||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(db)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},hb=new B,gb=new Fg,_b=new B,vb=class extends A_{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new r_,this.projectionMatrix=new r_,this.projectionMatrixInverse=new r_,this.coordinateSystem=Kh,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(hb,gb,_b),_b.x===1&&_b.y===1&&_b.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(hb,gb,_b.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(hb,gb,_b),_b.x===1&&_b.y===1&&_b.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(hb,gb,_b.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},yb=new B,bb=new Pg,xb=new Pg,Sb=class extends vb{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=ug*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(lg*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ug*2*Math.atan(Math.tan(lg*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){yb.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yb.x,yb.y).multiplyScalar(-e/yb.z),yb.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yb.x,yb.y).multiplyScalar(-e/yb.z)}getViewSize(e,t){return this.getViewBounds(e,bb,xb),t.subVectors(xb,bb)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(lg*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Cb=class extends mb{constructor(){super(new Sb(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ug*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},wb=class extends lb{constructor(e,t,n=0,r=Math.PI/3,i=0,a=2){super(e,t),this.isSpotLight=!0,this.type=`SpotLight`,this.position.copy(A_.DEFAULT_UP),this.updateMatrix(),this.target=new A_,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new Cb}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},Tb=class extends mb{constructor(){super(new Sb(90,1,.5,500)),this.isPointLightShadow=!0}},Eb=class extends lb{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type=`PointLight`,this.distance=n,this.decay=r,this.shadow=new Tb}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},Db=class extends vb{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ob=class extends mb{constructor(){super(new Db(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},kb=class extends lb{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(A_.DEFAULT_UP),this.updateMatrix(),this.target=new A_,this.shadow=new Ob}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},Ab=class extends lb{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},jb=class extends lb{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type=`RectAreaLight`,this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Mb=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new B)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*i),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],2*.429043*n*i),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},Nb=class extends lb{constructor(e=new Mb,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Pb=-90,Fb=1,Ib=class extends A_{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Sb(Pb,Fb,e,t);r.layers=this.layers,this.add(r);let i=new Sb(Pb,Fb,e,t);i.layers=this.layers,this.add(i);let a=new Sb(Pb,Fb,e,t);a.layers=this.layers,this.add(a);let o=new Sb(Pb,Fb,e,t);o.layers=this.layers,this.add(o);let s=new Sb(Pb,Fb,e,t);s.layers=this.layers,this.add(s);let c=new Sb(Pb,Fb,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},Lb=class extends Sb{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Rb=`\\[\\]\\.:\\/`,zb=RegExp(`[`+Rb+`]`,`g`),Bb=`[^`+Rb+`]`,Vb=`[^`+Rb.replace(`\\.`,``)+`]`,Hb=`((?:WC+[\\/:])*)`.replace(`WC`,Bb),Ub=`(WCOD+)?`.replace(`WCOD`,Vb),Wb=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Bb),Gb=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Bb),Kb=RegExp(`^`+Hb+Ub+Wb+Gb+`$`),qb=[`material`,`materials`,`bones`,`map`],Jb=class{constructor(e,t,n){let r=n||Yb.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Yb=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(zb,``)}static parseTrackName(e){let t=Kb.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);qb.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){R(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){z(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){z(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){z(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){z(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){z(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){z(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){z(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;z(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){z(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){z(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Yb.Composite=Jb,Yb.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Yb.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Yb.prototype.GetterByBindingType=[Yb.prototype._getValue_direct,Yb.prototype._getValue_array,Yb.prototype._getValue_arrayElement,Yb.prototype._getValue_toArray],Yb.prototype.SetterByBindingTypeAndVersioning=[[Yb.prototype._setValue_direct,Yb.prototype._setValue_direct_setNeedsUpdate,Yb.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Yb.prototype._setValue_array,Yb.prototype._setValue_array_setNeedsUpdate,Yb.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Yb.prototype._setValue_arrayElement,Yb.prototype._setValue_arrayElement_setNeedsUpdate,Yb.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Yb.prototype._setValue_fromArray,Yb.prototype._setValue_fromArray_setNeedsUpdate,Yb.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Xb=class extends Bv{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zb=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};function Qb(e,t,n,r){let i=$b(r);switch(n){case Nm:return e*t;case Rm:return e*t/i.components*i.byteLength;case zm:return e*t/i.components*i.byteLength;case Bm:return e*t*2/i.components*i.byteLength;case Vm:return e*t*2/i.components*i.byteLength;case Pm:return e*t*3/i.components*i.byteLength;case Fm:return e*t*4/i.components*i.byteLength;case Um:return e*t*4/i.components*i.byteLength;case Wm:case Gm:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Km:case qm:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Ym:case Zm:return Math.max(e,16)*Math.max(t,8)/4;case Jm:case Xm:return Math.max(e,8)*Math.max(t,8)/2;case Qm:case $m:case th:case nh:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case eh:case rh:case ih:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case ah:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case oh:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case sh:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case ch:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case lh:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case uh:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case dh:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case fh:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case ph:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case mh:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case hh:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case gh:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case _h:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case vh:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case yh:case bh:case xh:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Sh:case Ch:return Math.ceil(e/4)*Math.ceil(t/4)*8;case wh:case Th:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function $b(e){switch(e){case bm:case xm:return{byteLength:1,components:1};case Cm:case Sm:case Dm:return{byteLength:2,components:1};case Om:case km:return{byteLength:2,components:4};case Tm:case wm:case Em:return{byteLength:4,components:1};case jm:case Mm:return{byteLength:4,components:3}}throw Error(`Unknown texture type ${e}.`)}typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`183`}})),typeof window<`u`&&(window.__THREE__?R(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`183`);var ex=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),tx=new WeakMap,nx=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=ex,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.id,version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){let{object:n,material:r,geometry:i}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;let o=a.material;for(let e in o){let t=o[e],n=r[e];if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}else if(t!==n)return o[e]=n,!1}if(o.transmission>0){let{width:t,height:n}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==n)return a.bufferWidth=t,a.bufferHeight=n,!1}let s=a.geometry,c=i.attributes,l=s.attributes,u=Object.keys(l),d=Object.keys(c);if(s.id!==i.id)return s.id=i.id,!1;if(u.length!==d.length)return a.geometry.attributes=this.getAttributesData(c),!1;for(let e of u){let t=l[e],n=c[e];if(n===void 0)return delete l[e],!1;if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}let f=i.index,p=s.indexId,m=s.indexVersion,h=f?f.id:null,g=f?f.version:null;if(p!==h||m!==g)return s.indexId=h,s.indexVersion=g,!1;if(s.drawRange.start!==i.drawRange.start||s.drawRange.count!==i.drawRange.count)return s.drawRange.start=i.drawRange.start,s.drawRange.count=i.drawRange.count,!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t<a.morphTargetInfluences.length;t++)a.morphTargetInfluences[t]!==n.morphTargetInfluences[t]&&(a.morphTargetInfluences[t]=n.morphTargetInfluences[t],e=!0);if(e)return!1}if(a.lights){for(let e=0;e<t.length;e++)if(a.lights[e].map!==t[e].map)return!1}return a.center&&a.center.equals(n.center)===!1?(a.center.copy(n.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){let t=[];for(let n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(tx.has(e)){let n=tx.get(e);if(n.renderId===t)return n.lightsData}let n=this.getLightsData(e.getLights());return tx.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.getLights(e.lightsNode,n);return this.equals(e,a)!==!0}},rx=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function ix(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
15
|
+
`).map(e=>{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!rx.some(t=>t.test(e.file)))}var ax=class{constructor(e=null){this.isStackTrace=!0,this.stack=ix(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(`
|
|
16
|
+
`)}`}};function ox(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var sx=e=>ox(e),cx=e=>ox(e),lx=(...e)=>ox(e),ux=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),dx=new WeakMap;function fx(e){return ux.get(e)}function px(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function mx(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;z(`TSL: Unsupported type: ${e}`,new ax)}function hx(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;z(`TSL: Unsupported type: ${e}`,new ax)}function gx(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e)||/mat4/.test(e))return 16;z(`TSL: Unsupported type: ${e}`,new ax)}function _x(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function vx(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new R_(...t):n===`vec2`?new Pg(...t):n===`vec3`?new B(...t):n===`vec4`?new e_(...t):n===`mat2`?new Zb(...t):n===`mat3`?new Rg(...t):n===`mat4`?new r_(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?xx(t[0]):null}function yx(e){let t=dx.get(e);return t===void 0&&(t={},dx.set(e,t)),t}function bx(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function xx(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Sx={VERTEX:`vertex`,FRAGMENT:`fragment`},Cx={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},wx={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},Tx={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},Ex=[`fragment`,`vertex`],Dx=[`setup`,`analyze`,`generate`],Ox=[...Ex,`compute`],kx=[`x`,`y`,`z`,`w`],Ax={analyze:`setup`,generate:`analyze`},jx=0,Mx=class e extends og{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=Cx.NONE,this.updateBeforeType=Cx.NONE,this.updateAfterType=Cx.NONE,this.uuid=Ng.generateUUID(),this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:jx++}),this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new ax)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,Cx.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Cx.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Cx.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(e.startsWith(`_`)===!0)continue;let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e||=this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let n=[];for(let{property:r,childNode:i}of this._getChildren(t))n.push(sx(r.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=lx(cx(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){R(`Abstract function.`)}updateAfter(){R(`Abstract function.`)}update(){R(`Abstract function.`)}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){let n=this._beforeNodes;this._beforeNodes=null;for(let r of n)r.build(e,t);this._beforeNodes=n}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Ax[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){if(this.generate.length<2){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(R(`Node: Recursion detected.`,this),a=`/* Recursion detected. */`):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``;a===``&&t!==null&&t!==`void`&&t!==`OutputType`&&(z(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else this[n]=t[e.inputNodes[n]]}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};Mx.captureStackTrace=!1;var Nx=class extends Mx{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},Px=class extends Mx{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},Fx=class extends Mx{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Ix=class extends Fx{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){z(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(z(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},Lx=kx.join(``),Rx=class extends Mx{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(kx.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===Lx.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},zx=class extends Fx{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=kx[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Bx=class extends Fx{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=kx[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Vx=class extends Mx{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?_x(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=_x(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=bx(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?vx(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){R(`Abstract function.`)}},Hx=/float|u?int/,Ux=class extends Vx{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return Hx.test(n)&&Hx.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Wx=class extends Mx{static get type(){return`MemberNode`}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!==`void`}getNodeType(e){return this.hasMember(e)===!1?`float`:this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return`float`;let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){R(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+`.`+this.property}},Gx=null,Kx=new Map;function V(e,t){if(Kx.has(e)){R(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);Kx.set(e,t),e!==`assign`&&(Mx.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Mx.prototype[e+`Assign`]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}var qx=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),Jx=e=>qx(e).split(``).sort().join(``);Mx.prototype.assign=function(...e){if(this.isStackNode!==!0)return Gx===null?z(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new ax):Gx.assign(this,...e),this;{let t=Kx.get(`assign`);return this.addToStack(t(...e))}},Mx.prototype.toVarIntent=function(){return this},Mx.prototype.get=function(e){return new Wx(this,e)};var Yx={};function Xx(e,t,n){Yx[e]=Yx[t]=Yx[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Rx(this,e),this._cache[e]=t),t},set(t){this[e].assign(TS(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();Mx.prototype[`set`+r]=Mx.prototype[`set`+i]=Mx.prototype[`set`+a]=function(t){let n=Jx(e);return new zx(this,n,TS(t))},Mx.prototype[`flip`+r]=Mx.prototype[`flip`+i]=Mx.prototype[`flip`+a]=function(){let t=Jx(e);return new Bx(this,t)}}var Zx=[`x`,`y`,`z`,`w`],Qx=[`r`,`g`,`b`,`a`],$x=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=Zx[e],n=Qx[e],r=$x[e];Xx(t,n,r);for(let i=0;i<4;i++){t=Zx[e]+Zx[i],n=Qx[e]+Qx[i],r=$x[e]+$x[i],Xx(t,n,r);for(let a=0;a<4;a++){t=Zx[e]+Zx[i]+Zx[a],n=Qx[e]+Qx[i]+Qx[a],r=$x[e]+$x[i]+$x[a],Xx(t,n,r);for(let o=0;o<4;o++)t=Zx[e]+Zx[i]+Zx[a]+Zx[o],n=Qx[e]+Qx[i]+Qx[a]+Qx[o],r=$x[e]+$x[i]+$x[a]+$x[o],Xx(t,n,r)}}}for(let e=0;e<32;e++)Yx[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Nx(this,new Ux(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(TS(t))}};Object.defineProperties(Mx.prototype,Yx);var eS=new WeakMap,tS=function(e,t=null){let n=_x(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?TS(bS(e,t)):n===`shader`?e.isFn?e:W(e):e},nS=function(e,t=null){for(let n in e)e[n]=TS(e[n],t);return e},rS=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=TS(e[r],t);return e},iS=function(e,t=null,n=null,r=null){function i(e){return r===null?e=TS(e):(e=TS(Object.assign(e,r)),r.intent===!0&&(e=e.toVarIntent())),e}let a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(z(`TSL: "${n}" parameter length is less than minimum required.`,new ax),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(z(`TSL: "${n}" parameter length exceeds limit.`,new ax),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...OS(l(t)))):n===null?a=(...n)=>i(new e(t,...OS(l(n)))):(n=TS(n),a=(...r)=>i(new e(t,...OS(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},aS=function(e,...t){return new e(...OS(t))},oS=class extends Mx{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){let r=eS.get(e.constructor);r===void 0&&(r=new WeakMap,eS.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=TS(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i);let a=n?sS(n):null;c=TS(i.call(a))}else{let r=new Proxy(e,{get:(e,t,n)=>{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?cS(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=TS(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function sS(e){let t;return DS(e),t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0],t}function cS(e){let t=0;return DS(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield TS(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof Mx&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i));else a=Reflect.get(n,r,i);a=TS(a)}return a}})}var lS=class extends Mx{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new oS(this,e)}setup(){return this.call()}},uS=[!1,!0],dS=[0,1,2,3],fS=[-1,-2],pS=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],mS=new Map;for(let e of uS)mS.set(e,new Ux(e));var hS=new Map;for(let e of dS)hS.set(e,new Ux(e,`uint`));var gS=new Map([...hS].map(e=>new Ux(e.value,`int`)));for(let e of fS)gS.set(e,new Ux(e,`int`));var _S=new Map([...gS].map(e=>new Ux(e.value)));for(let e of pS)_S.set(e,new Ux(e));for(let e of pS)_S.set(-e,new Ux(-e));var vS={bool:mS,uint:hS,ints:gS,float:_S},yS=new Map([...mS,..._S]),bS=(e,t)=>yS.has(e)?yS.get(e):e.isNode===!0?e:new Ux(e,t),xS=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return z(`TSL: Invalid parameter for the type "${e}".`,new ax),new Ux(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[vx(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return ES(t.get(n[0]));if(n.length===1){let t=bS(n[0],e);return t.nodeType===e?ES(t):ES(new Px(t,e))}return ES(new Ix(n.map(e=>bS(e)),e))}},SS=e=>typeof e==`object`&&e?e.value:e,CS=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function wS(e,t){return new lS(e,t)}var TS=(e,t=null)=>tS(e,t),ES=(e,t=null)=>TS(e,t).toVarIntent(),DS=(e,t=null)=>new nS(e,t),OS=(e,t=null)=>new rS(e,t),kS=(e,t=null,n=null,r=null)=>new iS(e,t,n,r),H=(e,...t)=>new aS(e,...t),U=(e,t=null,n=null,r={})=>new iS(e,t,n,{...r,intent:!0}),AS=0,jS=class extends Mx{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:z(`TSL: Invalid layout type.`,new ax),t=null)),this.shaderNode=new wS(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+ AS++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return z(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function W(e,t=null){let n=new jS(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var MS=e=>{Gx=e},NS=()=>Gx,PS=(...e)=>Gx.If(...e),FS=(...e)=>Gx.Switch(...e);function IS(e){return Gx&&Gx.addToStack(e),e}V(`toStack`,IS);var LS=new xS(`color`),G=new xS(`float`,vS.float),K=new xS(`int`,vS.ints),q=new xS(`uint`,vS.uint),RS=new xS(`bool`,vS.bool),J=new xS(`vec2`),zS=new xS(`ivec2`),BS=new xS(`uvec2`),VS=new xS(`bvec2`),Y=new xS(`vec3`),HS=new xS(`ivec3`),US=new xS(`uvec3`),WS=new xS(`bvec3`),GS=new xS(`vec4`),KS=new xS(`ivec4`),qS=new xS(`uvec4`),JS=new xS(`bvec4`),YS=new xS(`mat2`),XS=new xS(`mat3`),ZS=new xS(`mat4`),QS=(e=``)=>new Ux(e,`string`),$S=e=>new Ux(e,`ArrayBuffer`);V(`toColor`,LS),V(`toFloat`,G),V(`toInt`,K),V(`toUint`,q),V(`toBool`,RS),V(`toVec2`,J),V(`toIVec2`,zS),V(`toUVec2`,BS),V(`toBVec2`,VS),V(`toVec3`,Y),V(`toIVec3`,HS),V(`toUVec3`,US),V(`toBVec3`,WS),V(`toVec4`,GS),V(`toIVec4`,KS),V(`toUVec4`,qS),V(`toBVec4`,JS),V(`toMat2`,YS),V(`toMat3`,XS),V(`toMat4`,ZS);var eC=kS(Nx).setParameterLength(2),tC=(e,t)=>new Px(TS(e),t),nC=(e,t)=>new Rx(TS(e),t);V(`element`,eC),V(`convert`,tC);var rC=e=>(R(`TSL: append() has been renamed to Stack().`,new ax),IS(e));V(`append`,e=>(R(`TSL: .append() has been renamed to .toStack().`,new ax),IS(e)));var iC=class extends Mx{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return sx(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}},aC=(e,t)=>new iC(e,t),oC=(e,t)=>new iC(e,t,!0),sC=H(iC,`vec4`,`DiffuseColor`),cC=H(iC,`vec3`,`DiffuseContribution`),lC=H(iC,`vec3`,`EmissiveColor`),uC=H(iC,`float`,`Roughness`),dC=H(iC,`float`,`Metalness`),fC=H(iC,`float`,`Clearcoat`),pC=H(iC,`float`,`ClearcoatRoughness`),mC=H(iC,`vec3`,`Sheen`),hC=H(iC,`float`,`SheenRoughness`),gC=H(iC,`float`,`Iridescence`),_C=H(iC,`float`,`IridescenceIOR`),vC=H(iC,`float`,`IridescenceThickness`),yC=H(iC,`float`,`AlphaT`),bC=H(iC,`float`,`Anisotropy`),xC=H(iC,`vec3`,`AnisotropyT`),SC=H(iC,`vec3`,`AnisotropyB`),CC=H(iC,`color`,`SpecularColor`),wC=H(iC,`color`,`SpecularColorBlended`),TC=H(iC,`float`,`SpecularF90`),EC=H(iC,`float`,`Shininess`),DC=H(iC,`vec4`,`Output`),OC=H(iC,`float`,`dashSize`),kC=H(iC,`float`,`gapSize`),AC=H(iC,`float`,`pointWidth`),jC=H(iC,`float`,`IOR`),MC=H(iC,`float`,`Transmission`),NC=H(iC,`float`,`Thickness`),PC=H(iC,`float`,`AttenuationDistance`),FC=H(iC,`color`,`AttenuationColor`),IC=H(iC,`float`,`Dispersion`),LC=class extends Mx{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},RC=e=>new LC(e),zC=(e,t=0)=>new LC(e,!0,t),BC=zC(`frame`),VC=zC(`render`),HC=RC(`object`),UC=class extends Vx{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=HC}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ax),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},WC=(e,t)=>{let n=CS(t||e);if(n===e&&(e=vx(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new UC(e,n)},GC=class extends Fx{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},KC=(...e)=>{let t;if(e.length===1){let n=e[0];t=new GC(null,n.length,n)}else{let n=e[0],r=e[1];t=new GC(n,r)}return TS(t)};V(`toArray`,(e,t)=>KC(Array(t).fill(e)));var qC=kS(class extends Fx{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return kx.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${l}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=a)}else u=`${a} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=a));return l.initialized=!0,e.format(u,o,t)}}).setParameterLength(2);V(`assign`,qC);var JC=class extends Fx{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)z(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(z(`TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(G(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(z(`TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(G(0),e))):t.push(a(n,e))}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}},YC=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?OS(t):DS(t[0]),new JC(TS(e),t));V(`call`,YC);var XC={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},ZC=class e extends Fx{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(XC[this.op],t)}getNodeType(e,t=null){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i?i.getNodeType(e):null;if(a===`void`||o===`void`)return t||`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`!`||n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===Kh;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},QC=U(ZC,`+`).setParameterLength(2,1/0).setName(`add`),$C=U(ZC,`-`).setParameterLength(2,1/0).setName(`sub`),ew=U(ZC,`*`).setParameterLength(2,1/0).setName(`mul`),tw=U(ZC,`/`).setParameterLength(2,1/0).setName(`div`),nw=U(ZC,`%`).setParameterLength(2).setName(`mod`),rw=U(ZC,`==`).setParameterLength(2).setName(`equal`),iw=U(ZC,`!=`).setParameterLength(2).setName(`notEqual`),aw=U(ZC,`<`).setParameterLength(2).setName(`lessThan`),ow=U(ZC,`>`).setParameterLength(2).setName(`greaterThan`),sw=U(ZC,`<=`).setParameterLength(2).setName(`lessThanEqual`),cw=U(ZC,`>=`).setParameterLength(2).setName(`greaterThanEqual`),lw=U(ZC,`&&`).setParameterLength(2,1/0).setName(`and`),uw=U(ZC,`||`).setParameterLength(2,1/0).setName(`or`),dw=U(ZC,`!`).setParameterLength(1).setName(`not`),fw=U(ZC,`^^`).setParameterLength(2).setName(`xor`),pw=U(ZC,`&`).setParameterLength(2).setName(`bitAnd`),mw=U(ZC,`~`).setParameterLength(1).setName(`bitNot`),hw=U(ZC,`|`).setParameterLength(2).setName(`bitOr`),gw=U(ZC,`^`).setParameterLength(2).setName(`bitXor`),_w=U(ZC,`<<`).setParameterLength(2).setName(`shiftLeft`),vw=U(ZC,`>>`).setParameterLength(2).setName(`shiftRight`),yw=W(([e])=>(e.addAssign(1),e)),bw=W(([e])=>(e.subAssign(1),e)),xw=W(([e])=>{let t=K(e).toConst();return e.addAssign(1),t}),Sw=W(([e])=>{let t=K(e).toConst();return e.subAssign(1),t});V(`add`,QC),V(`sub`,$C),V(`mul`,ew),V(`div`,tw),V(`mod`,nw),V(`equal`,rw),V(`notEqual`,iw),V(`lessThan`,aw),V(`greaterThan`,ow),V(`lessThanEqual`,sw),V(`greaterThanEqual`,cw),V(`and`,lw),V(`or`,uw),V(`not`,dw),V(`xor`,fw),V(`bitAnd`,pw),V(`bitNot`,mw),V(`bitOr`,hw),V(`bitXor`,gw),V(`shiftLeft`,_w),V(`shiftRight`,vw),V(`incrementBefore`,yw),V(`decrementBefore`,bw),V(`increment`,xw),V(`decrement`,Sw);var Cw=(e,t)=>(R(`TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`,new ax),nw(K(e),K(t)));V(`modInt`,Cw);var X=class e extends Fx{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=$C(1,n);else if(i===e.RECIPROCAL)a=tw(1,n);else if(i===e.DIFFERENCE)a=Xw($C(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=GS(Y(i),0):e=GS(Y(e),0);let o=ew(e,i).xyz;a=Hw(o)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(R(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};X.ALL=`all`,X.ANY=`any`,X.RADIANS=`radians`,X.DEGREES=`degrees`,X.EXP=`exp`,X.EXP2=`exp2`,X.LOG=`log`,X.LOG2=`log2`,X.SQRT=`sqrt`,X.INVERSE_SQRT=`inversesqrt`,X.FLOOR=`floor`,X.CEIL=`ceil`,X.NORMALIZE=`normalize`,X.FRACT=`fract`,X.SIN=`sin`,X.COS=`cos`,X.TAN=`tan`,X.ASIN=`asin`,X.ACOS=`acos`,X.ATAN=`atan`,X.ABS=`abs`,X.SIGN=`sign`,X.LENGTH=`length`,X.NEGATE=`negate`,X.ONE_MINUS=`oneMinus`,X.DFDX=`dFdx`,X.DFDY=`dFdy`,X.ROUND=`round`,X.RECIPROCAL=`reciprocal`,X.TRUNC=`trunc`,X.FWIDTH=`fwidth`,X.TRANSPOSE=`transpose`,X.DETERMINANT=`determinant`,X.INVERSE=`inverse`,X.EQUALS=`equals`,X.MIN=`min`,X.MAX=`max`,X.STEP=`step`,X.REFLECT=`reflect`,X.DISTANCE=`distance`,X.DIFFERENCE=`difference`,X.DOT=`dot`,X.CROSS=`cross`,X.POW=`pow`,X.TRANSFORM_DIRECTION=`transformDirection`,X.MIX=`mix`,X.CLAMP=`clamp`,X.REFRACT=`refract`,X.SMOOTHSTEP=`smoothstep`,X.FACEFORWARD=`faceforward`;var ww=G(1e-6),Tw=G(1e6),Ew=G(Math.PI),Dw=G(Math.PI*2),Ow=G(Math.PI*2),kw=G(Math.PI*.5),Aw=U(X,X.ALL).setParameterLength(1),jw=U(X,X.ANY).setParameterLength(1),Mw=U(X,X.RADIANS).setParameterLength(1),Nw=U(X,X.DEGREES).setParameterLength(1),Pw=U(X,X.EXP).setParameterLength(1),Fw=U(X,X.EXP2).setParameterLength(1),Iw=U(X,X.LOG).setParameterLength(1),Lw=U(X,X.LOG2).setParameterLength(1),Rw=U(X,X.SQRT).setParameterLength(1),zw=U(X,X.INVERSE_SQRT).setParameterLength(1),Bw=U(X,X.FLOOR).setParameterLength(1),Vw=U(X,X.CEIL).setParameterLength(1),Hw=U(X,X.NORMALIZE).setParameterLength(1),Uw=U(X,X.FRACT).setParameterLength(1),Ww=U(X,X.SIN).setParameterLength(1),Gw=U(X,X.COS).setParameterLength(1),Kw=U(X,X.TAN).setParameterLength(1),qw=U(X,X.ASIN).setParameterLength(1),Jw=U(X,X.ACOS).setParameterLength(1),Yw=U(X,X.ATAN).setParameterLength(1,2),Xw=U(X,X.ABS).setParameterLength(1),Zw=U(X,X.SIGN).setParameterLength(1),Qw=U(X,X.LENGTH).setParameterLength(1),$w=U(X,X.NEGATE).setParameterLength(1),eT=U(X,X.ONE_MINUS).setParameterLength(1),tT=U(X,X.DFDX).setParameterLength(1),nT=U(X,X.DFDY).setParameterLength(1),rT=U(X,X.ROUND).setParameterLength(1),iT=U(X,X.RECIPROCAL).setParameterLength(1),aT=U(X,X.TRUNC).setParameterLength(1),oT=U(X,X.FWIDTH).setParameterLength(1),sT=U(X,X.TRANSPOSE).setParameterLength(1),cT=U(X,X.DETERMINANT).setParameterLength(1),lT=U(X,X.INVERSE).setParameterLength(1),uT=U(X,X.MIN).setParameterLength(2,1/0),dT=U(X,X.MAX).setParameterLength(2,1/0),fT=U(X,X.STEP).setParameterLength(2),pT=U(X,X.REFLECT).setParameterLength(2),mT=U(X,X.DISTANCE).setParameterLength(2),hT=U(X,X.DIFFERENCE).setParameterLength(2),gT=U(X,X.DOT).setParameterLength(2),_T=U(X,X.CROSS).setParameterLength(2),vT=U(X,X.POW).setParameterLength(2),yT=e=>ew(e,e),bT=e=>ew(e,e,e),xT=e=>ew(e,e,e,e),ST=U(X,X.TRANSFORM_DIRECTION).setParameterLength(2),CT=e=>ew(Zw(e),vT(Xw(e),1/3)),wT=e=>gT(e,e),TT=U(X,X.MIX).setParameterLength(3),ET=(e,t=0,n=1)=>new X(X.CLAMP,TS(e),TS(t),TS(n)),DT=e=>ET(e),OT=U(X,X.REFRACT).setParameterLength(3),kT=U(X,X.SMOOTHSTEP).setParameterLength(3),AT=U(X,X.FACEFORWARD).setParameterLength(3),jT=W(([e])=>Uw(Ww(nw(gT(e.xy,J(12.9898,78.233)),Ew)).mul(43758.5453))),MT=(e,t,n)=>TT(t,n,e),NT=(e,t,n)=>kT(t,n,e),PT=(e,t)=>fT(t,e),FT=AT,IT=zw;V(`all`,Aw),V(`any`,jw),V(`radians`,Mw),V(`degrees`,Nw),V(`exp`,Pw),V(`exp2`,Fw),V(`log`,Iw),V(`log2`,Lw),V(`sqrt`,Rw),V(`inverseSqrt`,zw),V(`floor`,Bw),V(`ceil`,Vw),V(`normalize`,Hw),V(`fract`,Uw),V(`sin`,Ww),V(`cos`,Gw),V(`tan`,Kw),V(`asin`,qw),V(`acos`,Jw),V(`atan`,Yw),V(`abs`,Xw),V(`sign`,Zw),V(`length`,Qw),V(`lengthSq`,wT),V(`negate`,$w),V(`oneMinus`,eT),V(`dFdx`,tT),V(`dFdy`,nT),V(`round`,rT),V(`reciprocal`,iT),V(`trunc`,aT),V(`fwidth`,oT),V(`min`,uT),V(`max`,dT),V(`step`,PT),V(`reflect`,pT),V(`distance`,mT),V(`dot`,gT),V(`cross`,_T),V(`pow`,vT),V(`pow2`,yT),V(`pow3`,bT),V(`pow4`,xT),V(`transformDirection`,ST),V(`mix`,MT),V(`clamp`,ET),V(`refract`,OT),V(`smoothstep`,NT),V(`faceForward`,AT),V(`difference`,hT),V(`saturate`,DT),V(`cbrt`,CT),V(`transpose`,sT),V(`determinant`,cT),V(`inverse`,lT),V(`rand`,jT);var LT=kS(class extends Mx{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?aC(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(R(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
17
|
+
|
|
18
|
+
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
19
|
+
|
|
20
|
+
`).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(R(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
|
|
21
|
+
|
|
22
|
+
`+e.tab+`}
|
|
23
|
+
|
|
24
|
+
`)}else e.addFlowCode(`
|
|
25
|
+
|
|
26
|
+
`);return e.format(l,n,t)}}).setParameterLength(2,3);V(`select`,LT);var RT=class extends Mx{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},zT=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new RT(n,t)},BT=e=>zT(e,{uniformFlow:!0}),VT=(e,t)=>zT(e,{nodeName:t});function HT(e,t,n=null){return zT(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function UT(e,t=null){return zT(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function WT(e,t){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`),VT(e,t)}V(`context`,zT),V(`label`,WT),V(`uniformFlow`,BT),V(`setName`,VT),V(`builtinShadowContext`,(e,t,n)=>HT(t,n,e)),V(`builtinAOContext`,(e,t)=>UT(t,e));var GT=class extends Mx{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0];if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&z(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s)if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}},KT=kS(GT),qT=(e,t=null)=>KT(e,t).toStack(),JT=(e,t=null)=>KT(e,t,!0).toStack(),YT=e=>KT(e).setIntent(!0).toStack();V(`toVar`,qT),V(`toConst`,JT),V(`toVarIntent`,YT);var XT=class extends Mx{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},ZT=(e,t,n=null)=>new XT(TS(e),t,n),QT=kS(class extends Mx{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=ZT(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=ZT(this.node,`VERTEX`)}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Sx.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Sx.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,Sx.VERTEX);e.flowNodeFromShaderStage(Sx.VERTEX,n.node,i,a),n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2),$T=e=>QT(e);V(`toVarying`,QT),V(`toVertexStage`,$T);var eE=W(([e])=>TT(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),tE=W(([e])=>TT(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),nE=`WorkingColorSpace`,rE=`OutputColorSpace`,iE=class extends Fx{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===nE?Ug.workingColorSpace:t===rE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return Ug.enabled===!1||n===r||!n||!r?i:(Ug.getTransfer(n)===`srgb`&&(i=GS(eE(i.rgb),i.a)),Ug.getPrimaries(n)!==Ug.getPrimaries(r)&&(i=GS(XS(Ug._getMatrix(new Rg,n,r)).mul(i.rgb),i.a)),Ug.getTransfer(r)===`srgb`&&(i=GS(tE(i.rgb),i.a)),i)}},aE=(e,t)=>new iE(TS(e),nE,t),oE=(e,t)=>new iE(TS(e),t,nE),sE=(e,t,n)=>new iE(TS(e),t,n);V(`workingToColorSpace`,aE),V(`colorSpaceToWorking`,oE);var cE=class extends Nx{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},lE=class extends Mx{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=Cx.OBJECT}setGroup(e){return this.group=e,this}element(e){return new cE(this,TS(e))}setNodeType(e){let t=WC(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},uE=(e,t,n)=>new lE(e,t,n),dE=class extends lE{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(VC)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},fE=(e,t,n=null)=>new dE(e,t,n),pE=class extends Fx{static get type(){return`ToneMappingNode`}constructor(e,t=hE,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return lx(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(z(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=GS(i(t.rgb,this.exposureNode),t.a),r}},mE=(e,t,n)=>new pE(e,TS(t),TS(n)),hE=fE(`toneMappingExposure`,`float`);V(`toneMapping`,(e,t,n)=>mE(t,n,e));var gE=new WeakMap;function _E(e,t){let n=gE.get(e);return n===void 0&&(n=new Bv(e,t),gE.set(e,n)),n}var vE=class extends Vx{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Wh,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?_E(r.array,i):_E(r,i);let s=new Hv(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;return e.shaderStage===`vertex`||e.shaderStage===`compute`?(this.name=r,i=r):i=QT(this).build(e,t),i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function yE(e,t=null,n=0,r=0,i=Wh,a=!1){return t===`mat3`||t===null&&e.itemSize===9?XS(new vE(e,`vec3`,9,0).setUsage(i).setInstanced(a),new vE(e,`vec3`,9,3).setUsage(i).setInstanced(a),new vE(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?ZS(new vE(e,`vec4`,16,0).setUsage(i).setInstanced(a),new vE(e,`vec4`,16,4).setUsage(i).setInstanced(a),new vE(e,`vec4`,16,8).setUsage(i).setInstanced(a),new vE(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new vE(e,t,n,r).setUsage(i)}var bE=(e,t=null,n=0,r=0)=>yE(e,t,n,r),xE=(e,t=null,n=0,r=0)=>yE(e,t,n,r,Gh),SE=(e,t=null,n=0,r=0)=>yE(e,t,n,r,Wh,!0),CE=(e,t=null,n=0,r=0)=>yE(e,t,n,r,Gh,!0);V(`toAttribute`,e=>bE(e.value));var wE=class extends Mx{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name=``,this.updateBeforeType=Cx.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ax),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},TE=(e,t=[64])=>{(t.length===0||t.length>3)&&z(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new ax);for(let e=0;e<t.length;e++){let n=t[e];(typeof n!=`number`||n<=0||!Number.isInteger(n))&&z(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new ax)}for(;t.length<3;)t.push(1);return new wE(TS(e),t)},EE=(e,t,n)=>TE(e,n).setCount(t);V(`compute`,EE),V(`computeKernel`,TE);var DE=class extends Mx{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},OE=e=>new DE(TS(e));function kE(e,t=!0){return R(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),OE(e).setParent(t)}V(`cache`,kE),V(`isolate`,OE);var AE=kS(class extends Mx{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2);V(`bypass`,AE);var jE=class extends Mx{static get type(){return`RemapNode`}constructor(e,t,n,r=G(0),i=G(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}},ME=kS(jE,null,null,{doClamp:!1}).setParameterLength(3,5),NE=kS(jE).setParameterLength(3,5);V(`remap`,ME),V(`remapClamp`,NE);var PE=class extends Mx{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}},FE=kS(PE).setParameterLength(1,2),IE=e=>(e?LT(e,FE(`discard`)):FE(`discard`)).toStack(),LE=()=>FE(`return`).toStack();V(`discard`,IE);var RE=class extends Fx{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color,n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==Ug.workingColorSpace&&(t=t.workingToColorSpace(r)),t}},zE=(e,t=null,n=null)=>new RE(TS(e),t,n);V(`renderOutput`,zE);var BE=class extends Fx{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`#
|
|
27
|
+
`,i+=e.flow.code.replace(/^\t/gm,``)+`
|
|
28
|
+
`,i+=`/* ... */ `+n+` /* ... */
|
|
29
|
+
`,i+=`// #`+r+`#
|
|
30
|
+
`,ng(i)}return n}},VE=(e,t=null)=>new BE(TS(e),t).toStack();V(`debug`,VE);var HE=class{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},UE=class extends Mx{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=Cx.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==HE&&ig(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function WE(e,t=``,n=null){return e=TS(e),e.before(new UE(e,t,n))}V(`toInspector`,WE);function GE(e){R(`TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var KE=class extends Mx{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):QT(this).build(e,n)}else return R(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},qE=(e,t=null)=>new KE(e,t),JE=(e=0)=>qE(`uv`+(e>0?e:``),`vec2`),YE=kS(class extends Mx{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),XE=kS(class extends UC{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=Cx.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),ZE=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},QE=new $g,$E=class extends UC{static get type(){return`TextureNode`}constructor(e=QE,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Cx.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return JE(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=WC(this.value.matrix)),this._matrixUniform.mul(Y(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=WC(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(K(YE(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new ZE("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=W(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||=this.getDefaultUV(),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Cx.OBJECT:Cx.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(Yh.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,ig(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value,u;return u=i?e.generateTextureBias(l,t,n,i,a,c):s?e.generateTextureGrad(l,t,n,s,a,c):o?e.generateTextureCompare(l,t,n,o,a,c):this.sampler===!1?e.generateTextureLoad(l,t,n,r,a,c):r?e.generateTextureLevel(l,t,n,r,a,c):e.generateTexture(l,t,n,a,c),u}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,offsetNode:m}=r,h=this.generateUV(e,t),g=c?c.build(e,`float`):null,_=l?l.build(e,`float`):null,v=f?f.build(e,`int`):null,y=u?u.build(e,`float`):null,b=d?d.build(e,`float`):null,x=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,S=m?this.generateOffset(e,m):null,C=e.getVarFromNode(this);s=e.getPropertyName(C);let w=this.generateSnippet(e,i,h,g,_,v,y,x,S);if(b!==null){let t=n.compareFunction;w=t===516||t===518?fT(FE(w,o),FE(b,`float`)).build(e,o):fT(FE(b,`float`),FE(w,o)).build(e,o)}e.addLineFlowCode(`${s} = ${w}`,this),a.snippet=w,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=oE(FE(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=TS(e),t.referenceNode=this.getBase(),TS(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=TS(e).mul(XE(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(R(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),TS(t)}level(e){let t=this.clone();return t.levelNode=TS(e),t.referenceNode=this.getBase(),TS(t)}size(e){return YE(this,e)}bias(e){let t=this.clone();return t.biasNode=TS(e),t.referenceNode=this.getBase(),TS(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=TS(e),t.referenceNode=this.getBase(),TS(t)}grad(e,t){let n=this.clone();return n.gradNode=[TS(e),TS(t)],n.referenceNode=this.getBase(),TS(n)}depth(e){let t=this.clone();return t.depthNode=TS(e),t.referenceNode=this.getBase(),TS(t)}offset(e){let t=this.clone();return t.offsetNode=TS(e),t.referenceNode=this.getBase(),TS(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},eD=kS($E).setParameterLength(1,4).setName(`texture`),tD=(e=QE,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=TS(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=TS(t)),n!==null&&(i.levelNode=TS(n)),r!==null&&(i.biasNode=TS(r))):i=eD(e,t,n,r),i},nD=(e=QE)=>tD(e),rD=(...e)=>tD(...e).setSampler(!1),iD=(e,t,n)=>tD(e,t).level(n),aD=e=>(e.isNode===!0?e:tD(e)).convert(`sampler`),oD=e=>(e.isNode===!0?e:tD(e)).convert(`samplerComparison`),sD=class extends UC{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},cD=(e,t,n)=>new sD(e,t,n),lD=class extends Nx{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},uD=class extends sD{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?_x(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Cx.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,this.update(),super.setup(e)}element(e){return new lD(this,TS(e))}},dD=(e,t)=>new uD(e,t),fD=kS(class extends Mx{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),pD,mD,hD=class e extends Mx{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=Cx.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=Cx.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(mD),mD.multiplyScalar(t.getPixelRatio())):mD.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(pD):(pD.width=n.width,pD.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?WC(pD||=new Pg):t===e.VIEWPORT?WC(mD||=new e_):t===e.DPR?WC(1):J(yD.div(vD)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(vD).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};hD.COORDINATE=`coordinate`,hD.VIEWPORT=`viewport`,hD.SIZE=`size`,hD.UV=`uv`,hD.DPR=`dpr`;var gD=H(hD,hD.DPR),_D=H(hD,hD.UV),vD=H(hD,hD.SIZE),yD=H(hD,hD.COORDINATE),bD=H(hD,hD.VIEWPORT),xD=bD.zw,SD=yD.sub(bD.xy),CD=SD.div(xD),wD=W(()=>(R(`TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`,new ax),vD),`vec2`).once()(),TD=null,ED=null,DD=null,OD=null,kD=null,AD=null,jD=null,MD=null,ND=null,PD=null,FD=null,ID=null,LD=null,RD=null,zD=WC(0,`uint`).setName(`u_cameraIndex`).setGroup(zC(`cameraIndex`)).toVarying(`v_cameraIndex`),BD=WC(`float`).setName(`cameraNear`).setGroup(VC).onRenderUpdate(({camera:e})=>e.near),VD=WC(`float`).setName(`cameraFar`).setGroup(VC).onRenderUpdate(({camera:e})=>e.far),HD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);ED===null?ED=dD(n).setGroup(VC).setName(`cameraProjectionMatrices`):ED.array=n,t=ED.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraProjectionMatrix`)}else TD===null&&(TD=WC(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(VC).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=TD;return t}).once()(),UD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);OD===null?OD=dD(n).setGroup(VC).setName(`cameraProjectionMatricesInverse`):OD.array=n,t=OD.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraProjectionMatrixInverse`)}else DD===null&&(DD=WC(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(VC).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=DD;return t}).once()(),WD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);AD===null?AD=dD(n).setGroup(VC).setName(`cameraViewMatrices`):AD.array=n,t=AD.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraViewMatrix`)}else kD===null&&(kD=WC(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(VC).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=kD;return t}).once()(),GD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);MD===null?MD=dD(n).setGroup(VC).setName(`cameraWorldMatrices`):MD.array=n,t=MD.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraWorldMatrix`)}else jD===null&&(jD=WC(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(VC).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=jD;return t}).once()(),KD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.normalMatrix);PD===null?PD=dD(n).setGroup(VC).setName(`cameraNormalMatrices`):PD.array=n,t=PD.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraNormalMatrix`)}else ND===null&&(ND=WC(e.normalMatrix).setName(`cameraNormalMatrix`).setGroup(VC).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=ND;return t}).once()(),qD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t<r;t++)n.push(new B);ID===null?ID=dD(n).setGroup(VC).setName(`cameraPositions`).onRenderUpdate(({camera:e},t)=>{let n=e.cameras,r=t.array;for(let e=0,t=n.length;e<t;e++)r[e].setFromMatrixPosition(n[e].matrixWorld)}):ID.array=n,t=ID.element(e.isMultiViewCamera?fD(`gl_ViewID_OVR`):zD).toConst(`cameraPosition`)}else FD===null&&(FD=WC(new B).setName(`cameraPosition`).setGroup(VC).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=FD;return t}).once()(),JD=W(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.viewport);RD===null?RD=dD(n,`vec4`).setGroup(VC).setName(`cameraViewports`):RD.array=n,t=RD.element(zD).toConst(`cameraViewport`)}else LD===null&&(LD=GS(0,0,vD.x,vD.y).toConst(`cameraViewport`)),t=LD;return t}).once()(),YD=new jv,XD=class e extends Mx{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Cx.OBJECT,this.uniformNode=new UC(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new B,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new B,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new B,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new B,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),YD.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=YD.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};XD.WORLD_MATRIX=`worldMatrix`,XD.POSITION=`position`,XD.SCALE=`scale`,XD.VIEW_POSITION=`viewPosition`,XD.DIRECTION=`direction`,XD.RADIUS=`radius`;var ZD=kS(XD,XD.DIRECTION).setParameterLength(1),QD=kS(XD,XD.WORLD_MATRIX).setParameterLength(1),$D=kS(XD,XD.POSITION).setParameterLength(1),eO=kS(XD,XD.SCALE).setParameterLength(1),tO=kS(XD,XD.VIEW_POSITION).setParameterLength(1),nO=kS(XD,XD.RADIUS).setParameterLength(1),rO=class extends XD{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},iO=H(rO,rO.DIRECTION),aO=H(rO,rO.WORLD_MATRIX),oO=H(rO,rO.POSITION),sO=H(rO,rO.SCALE),cO=H(rO,rO.VIEW_POSITION),lO=H(rO,rO.RADIUS),uO=WC(new Rg).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),dO=WC(new r_).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),fO=W(e=>e.context.modelViewMatrix||pO).once()().toVar(`modelViewMatrix`),pO=WD.mul(aO),mO=W(e=>(e.context.isHighPrecisionModelViewMatrix=!0,WC(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),hO=W(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return WC(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),gO=W(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(ig("TSL: `clipSpace` is only available in fragment stage."),GS())).once()(),_O=qE(`position`,`vec3`),vO=_O.toVarying(`positionLocal`),yO=_O.toVarying(`positionPrevious`),bO=W(e=>aO.mul(vO).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),xO=W(()=>vO.transformDirection(aO).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),SO=W(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=UD.mul(gO);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),CO=W(e=>{let t;return t=e.camera.isOrthographicCamera?Y(0,0,1):SO.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),wO=H(class extends Mx{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}}),TO=G(wO).mul(2).sub(1),EO=W(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(TO)),e}),DO=qE(`normal`,`vec3`),OO=W(e=>e.geometry.hasAttribute(`normal`)===!1?(R(`TSL: Vertex attribute "normal" not found on geometry.`),Y(0,1,0)):DO,`vec3`).once()().toVar(`normalLocal`),kO=SO.dFdx().cross(SO.dFdy()).normalize().toVar(`normalFlat`),AO=W(e=>{let t;return t=e.isFlatShading()?kO:IO(OO).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),jO=W(e=>{let t=AO.transformDirection(WD);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),MO=W(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=AO,e.isFlatShading()!==!0&&(t=EO(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),NO=MO.transformDirection(WD).toVar(`normalWorld`),PO=W(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?MO:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),FO=W(([e,t=aO])=>{let n=XS(t),r=e.div(Y(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),IO=W(([e],t)=>{let n=t.context.modelNormalViewMatrix;if(n)return n.transformDirection(e);let r=uO.mul(e);return WD.transformDirection(r)}),LO=W(()=>(R(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),MO)).once([`NORMAL`,`VERTEX`])(),RO=W(()=>(R(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),NO)).once([`NORMAL`,`VERTEX`])(),zO=W(()=>(R(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),PO)).once([`NORMAL`,`VERTEX`])(),BO=new p_,VO=new r_,HO=WC(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),UO=WC(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),WO=WC(new r_).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(BO.copy(n),VO.makeRotationFromEuler(BO)):VO.identity(),VO}),GO=CO.negate().reflect(MO),KO=CO.negate().refract(MO,HO),qO=GO.transformDirection(WD).toVar(`reflectVector`),JO=KO.transformDirection(WD).toVar(`reflectVector`),YO=new jy,XO=kS(class extends $E{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?qO:e.mapping===302?JO:(z(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),Y(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?Y(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=Y(t.x.negate(),t.yz)),WO.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),ZO=(e=YO,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=TS(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=TS(t)),n!==null&&(i.levelNode=TS(n)),r!==null&&(i.biasNode=TS(r))):i=XO(e,t,n,r),i},QO=(e=YO)=>XO(e),$O=class extends Nx{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},ek=class extends Mx{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Cx.OBJECT}element(e){return new $O(this,TS(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?dD(null,e):e===`texture`?tD(null):e===`cubeTexture`?ZO(null):WC(null,e):cD(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},tk=(e,t,n)=>new ek(e,t,n),nk=(e,t,n,r)=>new ek(e,t,r,n),rk=class extends ek{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},ik=(e,t,n=null)=>new rk(e,t,n),ak=JE(),ok=SO.dFdx(),sk=SO.dFdy(),ck=ak.dFdx(),lk=ak.dFdy(),uk=MO,dk=sk.cross(uk),fk=uk.cross(ok),pk=dk.mul(ck.x).add(fk.mul(lk.x)),mk=dk.mul(ck.y).add(fk.mul(lk.y)),hk=pk.dot(pk).max(mk.dot(mk)),gk=hk.equal(0).select(0,hk.inverseSqrt()),_k=pk.mul(gk).toVar(`tangentViewFrame`),vk=mk.mul(gk).toVar(`bitangentViewFrame`),yk=qE(`tangent`,`vec4`),bk=yk.xyz.toVar(`tangentLocal`),xk=W(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?fO.mul(GS(bk,0)).xyz.toVarying(`v_tangentView`).normalize():_k,e.isFlatShading()!==!0&&(t=EO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),Sk=xk.transformDirection(WD).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),Ck=W(([e,t],n)=>{let r=e.mul(yk.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),wk=Ck(DO.cross(yk),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),Tk=Ck(OO.cross(bk),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),Ek=W(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Ck(MO.cross(xk),`v_bitangentView`).normalize():vk,e.isFlatShading()!==!0&&(t=EO(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),Dk=Ck(NO.cross(Sk),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),Ok=XS(xk,Ek,MO).toVar(`TBNViewMatrix`),kk=CO.mul(Ok),Ak=(e,t)=>e.sub(kk.mul(t)),jk=W(()=>{let e=SC.cross(CO);return e=e.cross(SC).normalize(),e=TT(e,MO,bC.mul(uC.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Mk=e=>TS(e).mul(.5).add(.5),Nk=e=>TS(e).mul(2).sub(1),Pk=e=>Y(e,Rw(DT(G(1).sub(gT(e,e))))),Fk=kS(class extends Fx{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=Pk(i.xy):r===`ga`?i=Pk(i.yw):r!==``&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=EO(t)),i=Y(i.xy.mul(t),i.z)}let a=null;return t===1?a=IO(i):t===0?a=Ok.mul(i).normalize():(z(`NodeMaterial: Unsupported normal map type: ${t}`),a=MO),a}}).setParameterLength(1,2),Ik=W(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||JE()),forceUVContext:!0}),r=G(n(e=>e));return J(G(n(e=>e.add(e.dFdx()))).sub(r),G(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Lk=W(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(TO),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Rk=kS(class extends Fx{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode;return Lk({surf_pos:SO,surf_norm:MO,dHdxy:Ik({textureNode:this.textureNode,bumpScale:e})})}}).setParameterLength(1,2),zk=new Map,Z=class e extends Mx{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=zk.get(e);return n===void 0&&(n=ik(e,t),zk.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?Y():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:G(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Fk(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?Rk(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):MO;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Fk(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):MO;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=YS(CA.x,CA.y,CA.y.negate(),CA.x).mul(e.rg.mul(2).sub(J(1)).normalize().mul(e.b))}else i=CA;else if(r===e.IRIDESCENCE_THICKNESS){let e=tk(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=tk(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):G(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Z.ALPHA_TEST=`alphaTest`,Z.COLOR=`color`,Z.OPACITY=`opacity`,Z.SHININESS=`shininess`,Z.SPECULAR=`specular`,Z.SPECULAR_STRENGTH=`specularStrength`,Z.SPECULAR_INTENSITY=`specularIntensity`,Z.SPECULAR_COLOR=`specularColor`,Z.REFLECTIVITY=`reflectivity`,Z.ROUGHNESS=`roughness`,Z.METALNESS=`metalness`,Z.NORMAL=`normal`,Z.CLEARCOAT=`clearcoat`,Z.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Z.CLEARCOAT_NORMAL=`clearcoatNormal`,Z.EMISSIVE=`emissive`,Z.ROTATION=`rotation`,Z.SHEEN=`sheen`,Z.SHEEN_ROUGHNESS=`sheenRoughness`,Z.ANISOTROPY=`anisotropy`,Z.IRIDESCENCE=`iridescence`,Z.IRIDESCENCE_IOR=`iridescenceIOR`,Z.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Z.IOR=`ior`,Z.TRANSMISSION=`transmission`,Z.THICKNESS=`thickness`,Z.ATTENUATION_DISTANCE=`attenuationDistance`,Z.ATTENUATION_COLOR=`attenuationColor`,Z.LINE_SCALE=`scale`,Z.LINE_DASH_SIZE=`dashSize`,Z.LINE_GAP_SIZE=`gapSize`,Z.LINE_WIDTH=`linewidth`,Z.LINE_DASH_OFFSET=`dashOffset`,Z.POINT_SIZE=`size`,Z.DISPERSION=`dispersion`,Z.LIGHT_MAP=`light`,Z.AO=`ao`;var Bk=H(Z,Z.ALPHA_TEST),Vk=H(Z,Z.COLOR),Hk=H(Z,Z.SHININESS),Uk=H(Z,Z.EMISSIVE),Wk=H(Z,Z.OPACITY),Gk=H(Z,Z.SPECULAR),Kk=H(Z,Z.SPECULAR_INTENSITY),qk=H(Z,Z.SPECULAR_COLOR),Jk=H(Z,Z.SPECULAR_STRENGTH),Yk=H(Z,Z.REFLECTIVITY),Xk=H(Z,Z.ROUGHNESS),Zk=H(Z,Z.METALNESS),Qk=H(Z,Z.NORMAL),$k=H(Z,Z.CLEARCOAT),eA=H(Z,Z.CLEARCOAT_ROUGHNESS),tA=H(Z,Z.CLEARCOAT_NORMAL),nA=H(Z,Z.ROTATION),rA=H(Z,Z.SHEEN),iA=H(Z,Z.SHEEN_ROUGHNESS),aA=H(Z,Z.ANISOTROPY),oA=H(Z,Z.IRIDESCENCE),sA=H(Z,Z.IRIDESCENCE_IOR),cA=H(Z,Z.IRIDESCENCE_THICKNESS),lA=H(Z,Z.TRANSMISSION),uA=H(Z,Z.THICKNESS),dA=H(Z,Z.IOR),fA=H(Z,Z.ATTENUATION_DISTANCE),pA=H(Z,Z.ATTENUATION_COLOR),mA=H(Z,Z.LINE_SCALE),hA=H(Z,Z.LINE_DASH_SIZE),gA=H(Z,Z.LINE_GAP_SIZE),_A=H(Z,Z.LINE_WIDTH),vA=H(Z,Z.LINE_DASH_OFFSET),yA=H(Z,Z.POINT_SIZE),bA=H(Z,Z.DISPERSION),xA=H(Z,Z.LIGHT_MAP),SA=H(Z,Z.AO),CA=WC(new Pg).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),wA=W(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),TA=kS(class extends Nx{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),EA=class extends sD{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=fx(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Tx.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return TA(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Tx.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=bE(this.value),this._varying=QT(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},DA=(e,t=null,n=0)=>new EA(e,t,n),OA=class e extends Mx{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:QT(this).build(t,n),a}};OA.VERTEX=`vertex`,OA.INSTANCE=`instance`,OA.SUBGROUP=`subgroup`,OA.INVOCATION_LOCAL=`invocationLocal`,OA.INVOCATION_SUBGROUP=`invocationSubgroup`,OA.DRAW=`draw`;var kA=H(OA,OA.VERTEX),AA=H(OA,OA.INSTANCE),jA=H(OA,OA.SUBGROUP),MA=H(OA,OA.INVOCATION_SUBGROUP),NA=H(OA,OA.INVOCATION_LOCAL),PA=H(OA,OA.DRAW),FA=class extends Mx{static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Cx.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){let{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){let{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:n}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);let{instanceColor:r,isStorageColor:i}=this;if(r&&n===null){if(i)n=DA(r,`vec3`,Math.max(r.count,1)).element(AA);else{let e=new gy(r.array,3),t=r.usage===35048?CE:SE;this.bufferColor=e,n=Y(t(e,`vec3`,3,0))}this.instanceColorNode=n}let a=t.mul(vO).xyz;if(vO.assign(a),e.needsPreviousData()&&yO.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute(`normal`)){let e=FO(OO,t);OO.assign(e)}this.instanceColorNode!==null&&oC(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(e){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){let t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(yO).xyz}_createInstanceMatrixNode(e,t){let n,{instanceMatrix:r}=this,{count:i}=r;if(this.isStorageMatrix)n=DA(r,`mat4`,Math.max(i,1)).element(AA);else if(i*16*4<=t.getUniformBufferLimit())n=cD(r.array,`mat4`,Math.max(i,1)).element(AA);else{let t=new Xb(r.array,16,1);e===!0&&(this.buffer=t);let i=r.usage===35048?CE:SE;n=ZS(i(t,`vec4`,16,0),i(t,`vec4`,16,4),i(t,`vec4`,16,8),i(t,`vec4`,16,12))}return n}},IA=kS(FA).setParameterLength(2,3),LA=kS(class extends FA{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}).setParameterLength(1),RA=kS(class extends Mx{static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=AA:this.batchingIdNode=PA);let t=W(([e])=>{let t=K(YE(rD(this.batchMesh._indirectTexture),0).x).toConst(),n=K(e).mod(t).toConst(),r=K(e).div(t).toConst();return rD(this.batchMesh._indirectTexture,zS(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]})(K(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=K(YE(rD(n),0).x).toConst(),i=G(t).mul(4).toInt().toConst(),a=i.mod(r).toConst(),o=i.div(r).toConst(),s=ZS(rD(n,zS(a,o)),rD(n,zS(a.add(1),o)),rD(n,zS(a.add(2),o)),rD(n,zS(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){let e=W(([e])=>{let t=K(YE(rD(c),0).x).toConst(),n=e;return rD(c,zS(n.mod(t).toConst(),n.div(t).toConst())).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]})(t);oC(`vec3`,`vBatchColor`).assign(e)}let l=XS(s);vO.assign(s.mul(vO));let u=OO.div(Y(l[0].dot(l[0]),l[1].dot(l[1]),l[2].dot(l[2]))),d=l.mul(u).xyz;OO.assign(d),e.hasGeometryAttribute(`tangent`)&&bk.mulAssign(l)}}).setParameterLength(1),zA=new WeakMap,BA=class extends Mx{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=Cx.OBJECT,this.skinIndexNode=qE(`skinIndex`,`uvec4`),this.skinWeightNode=qE(`skinWeight`,`vec4`),this.bindMatrixNode=tk(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=tk(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=nk(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=vO,this.toPositionNode=vO,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=QC(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=OO,n=bk){let{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:a,bindMatrixInverseNode:o}=this,s=e.element(r.x),c=e.element(r.y),l=e.element(r.z),u=e.element(r.w),d=QC(i.x.mul(s),i.y.mul(c),i.z.mul(l),i.w.mul(u));return d=o.mul(d).mul(a),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=nk(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,yO)}setup(e){e.needsPreviousData()&&yO.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let{skinNormal:t,skinTangent:n}=this.getSkinnedNormalAndTangent();OO.assign(t),e.hasGeometryAttribute(`tangent`)&&bk.assign(n)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;zA.get(t)!==e.frameId&&(zA.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}},VA=e=>new BA(e),HA=(e,t=null)=>{let n=new BA(e);return n.positionNode=DA(new gy(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(AA).toVar(),n.skinIndexNode=DA(new gy(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(AA).toVar(),n.skinWeightNode=DA(new gy(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(AA).toVar(),n.bindMatrixNode=WC(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=WC(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=cD(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,TS(n)},UA=class extends Mx{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=FE(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack(),i=this.params[this.params.length-1](n);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=r;let a=this.params[0];if(a.isNode!==!0&&typeof a.update==`function`){let e=W(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(z(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?`
|
|
31
|
+
`:``)+e.tab+f+` {
|
|
32
|
+
|
|
33
|
+
`).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(`
|
|
34
|
+
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
|
|
35
|
+
|
|
36
|
+
`).removeFlowTab();e.addFlowTab()}},WA=(...e)=>new UA(OS(e,`int`)).toStack(),GA=()=>FE(`continue`).toStack(),KA=()=>FE(`break`).toStack(),qA=new WeakMap,JA=new e_,YA=W(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=K(kA).mul(n).add(a),s=o.div(r);return rD(e,zS(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function XA(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=qA.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],c=e.morphAttributes.normal||[],l=e.morphAttributes.color||[],u=0;t===!0&&(u=1),n===!0&&(u=2),r===!0&&(u=3);let d=e.attributes.position.count*u,f=1,p=4096;d>p&&(f=Math.ceil(d/p),d=p);let m=new Float32Array(d*f*4*a),h=new n_(m,d,f,a);h.type=Em,h.needsUpdate=!0;let g=u*4;for(let e=0;e<a;e++){let a=i[e],o=c[e],s=l[e],u=d*f*4*e;for(let e=0;e<a.count;e++){let i=e*g;t===!0&&(JA.fromBufferAttribute(a,e),m[u+i+0]=JA.x,m[u+i+1]=JA.y,m[u+i+2]=JA.z,m[u+i+3]=0),n===!0&&(JA.fromBufferAttribute(o,e),m[u+i+4]=JA.x,m[u+i+5]=JA.y,m[u+i+6]=JA.z,m[u+i+7]=0),r===!0&&(JA.fromBufferAttribute(s,e),m[u+i+8]=JA.x,m[u+i+9]=JA.y,m[u+i+10]=JA.z,m[u+i+11]=s.itemSize===4?JA.w:1)}}o={count:a,texture:h,stride:u,size:new Pg(d,f)},qA.set(e,o);function s(){h.dispose(),qA.delete(e),e.removeEventListener(`dispose`,s)}e.addEventListener(`dispose`,s)}return o}var ZA=kS(class extends Mx{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=WC(1),this.updateType=Cx.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=XA(t);n===!0&&vO.mulAssign(this.morphBaseInfluence),r===!0&&OO.mulAssign(this.morphBaseInfluence);let l=K(c.width);WA(a,({i:e})=>{let t=G(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(rD(this.mesh.morphTexture,zS(K(e).add(1),K(AA))).r):t.assign(tk(`morphTargetInfluences`,`float`).element(e).toVar()),PS(t.notEqual(0),()=>{n===!0&&vO.addAssign(YA({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:K(0)})),r===!0&&OO.addAssign(YA({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:K(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}).setParameterLength(1),QA=class extends Mx{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},$A=class extends QA{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},ej=kS(class extends RT{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n={directDiffuse:Y().toVar(`directDiffuse`),directSpecular:Y().toVar(`directSpecular`),indirectDiffuse:Y().toVar(`indirectDiffuse`),indirectSpecular:Y().toVar(`indirectSpecular`)};return{radiance:Y().toVar(`radiance`),irradiance:Y().toVar(`irradiance`),iblIrradiance:Y().toVar(`iblIrradiance`),ambientOcclusion:G(1).toVar(`ambientOcclusion`),reflectedLight:n,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),tj=class extends QA{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},nj=new Pg,rj=class extends $E{static get type(){return`ViewportTextureNode`}constructor(e=_D,t=null,n=null){let r=null;n===null?(r=new Ay,r.minFilter=vm,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=Cx.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(nj):nj.set(n.width,n.height);let r=this.getTextureForReference(n);(r.image.width!==nj.width||r.image.height!==nj.height)&&(r.image.width=nj.width,r.image.height=nj.height,r.needsUpdate=!0);let i=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=i}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},ij=kS(rj).setParameterLength(0,3),aj=kS(rj,null,null,{generateMipmaps:!0}).setParameterLength(0,3),oj=aj(),sj=(e=_D,t=null)=>oj.sample(e,t),cj=null,lj=kS(class extends rj{static get type(){return`ViewportDepthTextureNode`}constructor(e=_D,t=null){cj===null&&(cj=new My),super(e,t,cj)}getTextureForReference(){return cj}}).setParameterLength(0,2),uj=class e extends Mx{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=yj().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?mj(SO.z,BD,VD):dj(SO.z,BD,VD):n===e.LINEAR_DEPTH&&(i=r===null?dj(SO.z,BD,VD):t.isPerspectiveCamera?dj(gj(r,BD,VD),BD,VD):r),i}};uj.DEPTH_BASE=`depthBase`,uj.DEPTH=`depth`,uj.LINEAR_DEPTH=`linearDepth`;var dj=(e,t,n)=>e.add(t).div(t.sub(n)),fj=(e,t,n)=>e.add(n).div(n.sub(t)),pj=W(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),mj=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),hj=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),gj=W(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),_j=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Lw(e.negate().div(t)),i=Lw(n.div(t));return r.div(i)},vj=(e,t,n)=>{let r=e.mul(Iw(n.div(t)));return G(Math.E).pow(r).mul(t).negate()},yj=kS(uj,uj.DEPTH_BASE),bj=H(uj,uj.DEPTH),xj=kS(uj,uj.LINEAR_DEPTH).setParameterLength(0,1),Sj=xj(lj());bj.assign=e=>yj(e);var Cj=class e extends Mx{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return W(()=>{let n=G().toVar(`distanceToPlane`),r=G().toVar(`distanceToGradient`),i=G(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=dD(t).setGroup(VC);WA(a,({i:t})=>{let a=e.element(t);n.assign(SO.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(kT(r.negate(),r,n))})}let o=e.length;if(o>0){let t=dD(e).setGroup(VC),a=G(1).toVar(`intersectionClipOpacity`);WA(o,({i:e})=>{let i=t.element(e);n.assign(SO.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(kT(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}sC.a.mulAssign(i),sC.a.equal(0).discard()})()}setupDefault(e,t){return W(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=dD(t).setGroup(VC);WA(n,({i:t})=>{let n=e.element(t);SO.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=dD(e).setGroup(VC),n=RS(!0).toVar(`clipped`);WA(r,({i:e})=>{let r=t.element(e);n.assign(SO.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),W(()=>{let r=dD(e).setGroup(VC),i=fD(t.getClipDistance());WA(n,({i:e})=>{let t=r.element(e),n=SO.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};Cj.ALPHA_TO_COVERAGE=`alphaToCoverage`,Cj.DEFAULT=`default`,Cj.HARDWARE=`hardware`;var wj=()=>new Cj,Tj=()=>new Cj(Cj.ALPHA_TO_COVERAGE),Ej=()=>new Cj(Cj.HARDWARE),Dj=.05,Oj=W(([e])=>Uw(ew(1e4,Ww(ew(17,e.x).add(ew(.1,e.y)))).mul(QC(.1,Xw(Ww(ew(13,e.y).add(e.x))))))),kj=W(([e])=>Oj(J(Oj(e.xy),e.z))),Aj=W(([e])=>{let t=dT(Qw(tT(e.xyz)),Qw(nT(e.xyz))),n=G(1).div(G(Dj).mul(t)).toVar(`pixScale`),r=J(Fw(Bw(Lw(n))),Fw(Vw(Lw(n)))),i=J(kj(Bw(r.x.mul(e.xyz))),kj(Bw(r.y.mul(e.xyz)))),a=Uw(Lw(n)),o=QC(ew(a.oneMinus(),i.x),ew(a,i.y)),s=uT(a,a.oneMinus()),c=Y(o.mul(o).div(ew(2,s).mul($C(1,s))),o.sub(ew(.5,s)).div($C(1,s)),$C(1,$C(1,o).mul($C(1,o)).div(ew(2,s).mul($C(1,s)))));return ET(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),jj=class extends KE{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new e_(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},Mj=(e=0)=>new jj(e),Nj=W(([e,t])=>uT(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Pj=W(([e,t])=>uT(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Fj=W(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Ij=W(([e,t])=>TT(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),fT(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Lj=W(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return GS(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),Rj=W(([e])=>GS(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),zj=W(([e])=>(PS(e.a.equal(0),()=>GS(0)),GS(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),Bj=class extends Wv{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(sx(t.slice(0,-4)),n.getCacheKey());return this.type+cx(e)}build(e){this.setup(e)}setupObserver(e){return new nx(e)}setup(e){e.context.setupNormal=()=>ZT(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:z('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:z('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();let r=this.setupVertex(e),i=ZT(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=GS(r,sC.a).max(0);a=this.setupOutput(e,i),DC.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&DC.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=GS(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=Tj():e.stack.addToStack(wj())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(Ej()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?_j(SO.z,BD,VD):dj(SO.z,BD,VD))}r!==null&&bj.assign(r).toStack()}setupPositionView(){return fO.mul(vO).xyz}setupModelViewProjection(){return HD.mul(SO)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),wA}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&ZA(t).toStack(),t.isSkinnedMesh===!0&&VA(t).toStack(),this.displacementMap){let e=ik(`displacementMap`,`texture`),t=ik(`displacementScale`,`float`),n=ik(`displacementBias`,`float`);vO.addAssign(OO.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&RA(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&LA(t).toStack(),this.positionNode!==null&&vO.assign(ZT(this.positionNode,`POSITION`,`vec3`)),vO}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&RS(this.maskNode).not().discard();let r=this.colorNode?GS(this.colorNode):Vk;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(Mj())),t.instanceColor&&(r=oC(`vec3`,`vInstanceColor`).mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=oC(`vec3`,`vBatchColor`).mul(r)),sC.assign(r);let i=this.opacityNode?G(this.opacityNode):Wk;sC.a.assign(sC.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?Bk:G(this.alphaTestNode),this.alphaToCoverage===!0?(sC.a=kT(a,a.add(oT(sC.a)),sC.a),sC.a.lessThanEqual(0).discard()):sC.a.lessThanEqual(a).discard()),this.alphaHash===!0&&sC.a.lessThan(Aj(vO)).discard(),e.isOpaque()&&sC.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Y(0):sC.rgb}setupNormal(){return this.normalNode?Y(this.normalNode):Qk}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ik(`envMap`,`cubeTexture`):ik(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tj(xA)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let i=this.aoNode;i===null&&e.material.aoMap&&(i=SA),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new $A(i));let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,o=this.setupOutgoingLight(e);return a&&a.getScope().hasLights?o=ej(a,this.setupLightingModel(e)||null,n,r):n!==null&&(o=Y(r===null?n:TT(o,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(lC.assign(Y(i||Uk)),o=o.add(lC)),o}setupFog(e,t){let n=e.fogNode;return n&&(DC.assign(t),t=GS(n.toVar())),t}setupPremultipliedAlpha(e,t){return Rj(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=Wv.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}},Vj=new Oy,Hj=class extends Bj{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Vj),this.setValues(e)}},Uj=new Ky,Wj=class extends Bj{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Uj),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?G(this.offsetNode):vA,t=this.dashScaleNode?G(this.dashScaleNode):mA,n=this.dashSizeNode?G(this.dashSizeNode):hA,r=this.gapSizeNode?G(this.gapSizeNode):gA;OC.assign(n),kC.assign(r);let i=QT(qE(`lineDistance`).mul(t));(e?i.add(e):i).mod(OC.add(kC)).greaterThan(OC).discard()}},Gj=new Uy,Kj=class extends Bj{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Gj),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?G(this.opacityNode):Wk;sC.assign(oE(GS(Mk(MO),e),Nh))}},qj=W(([e=xO])=>J(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),Jj=class extends t_{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let n={width:e,height:e,depth:1};this.texture=new jy([n,n,n,n,n,n]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i=new Py(5,5,5),a=qj(xO),o=new Bj;o.colorNode=tD(t,a,0),o.side=1,o.blending=0;let s=new fy(i,o),c=new B_;c.add(s),t.minFilter===1008&&(t.minFilter=gm);let l=new Ib(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.currentGenerateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},Yj=new WeakMap,Xj=class extends Fx{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=ZO(null);let t=new jy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Cx.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===303||n===304){if(Yj.has(e)){let t=Yj.get(e);$j(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(Zj(n)){let r=new Jj(n.height);r.fromEquirectangularTexture(t,e),$j(r.texture,e.mapping),this._cubeTexture=r.texture,Yj.set(e,r.texture),e.addEventListener(`dispose`,Qj)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function Zj(e){return e==null?!1:e.height>0}function Qj(e){let t=e.target;t.removeEventListener(`dispose`,Qj);let n=Yj.get(t);n!==void 0&&(Yj.delete(t),n.dispose())}function $j(e,t){t===303?e.mapping=301:t===304&&(e.mapping=302)}var eM=kS(Xj).setParameterLength(1),tM=class extends QA{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=eM(this.envNode)}},nM=class extends QA{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=G(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},rM=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},iM=class extends rM{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(GS(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(GS(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(sC.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case 0:r.rgb.assign(TT(r.rgb,r.rgb.mul(i.rgb),Jk.mul(Yk)));break;case 1:r.rgb.assign(TT(r.rgb,i.rgb,Jk.mul(Yk)));break;case 2:r.rgb.addAssign(i.rgb.mul(Jk.mul(Yk)));break;default:R(`BasicLightingModel: Unsupported .combine value:`,t.combine);break}}},aM=new ey,oM=class extends Bj{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(aM),this.setValues(e)}setupNormal(){return EO(AO)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tM(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new nM(xA)),t}setupOutgoingLight(){return sC.rgb}setupLightingModel(){return new iM}},sM=W(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),cM=W(e=>e.diffuseColor.mul(1/Math.PI)),lM=()=>G(.25),uM=W(({dotNH:e})=>EC.mul(G(.5)).add(1).mul(G(1/Math.PI)).mul(e.pow(EC))),dM=W(({lightDirection:e})=>{let t=e.add(CO).normalize(),n=MO.dot(t).clamp(),r=sM({f0:CC,f90:1,dotVH:CO.dot(t).clamp()}),i=lM(),a=uM({dotNH:n});return r.mul(i).mul(a)}),fM=class extends iM{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=MO.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(cM({diffuseColor:sC.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(dM({lightDirection:e})).mul(Jk))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(cM({diffuseColor:sC}))),r.indirectDiffuse.mulAssign(t)}},pM=new Wy,mM=class extends Bj{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(pM),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tM(t):null}setupLightingModel(){return new fM(!1)}},hM=new Vy,gM=class extends Bj{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(hM),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tM(t):null}setupLightingModel(){return new fM}setupVariants(){let e=(this.shininessNode?G(this.shininessNode):Hk).max(1e-4);EC.assign(e);let t=this.specularNode||Gk;CC.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}},_M=W(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return G(0);let t=AO.dFdx().abs().max(AO.dFdy().abs());return t.x.max(t.y).max(t.z)}),vM=W(e=>{let{roughness:t}=e,n=_M(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),yM=W(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return tw(.5,i.add(a).max(ww))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),bM=W(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(Y(e.mul(n),t.mul(r),o).length()),l=o.mul(Y(e.mul(i),t.mul(a),s).length());return tw(.5,c.add(l))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),xM=W(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),SM=G(1/Math.PI),CM=W(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=Y(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return SM.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),wM=W(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=MO,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(CO).normalize(),u=a.dot(e).clamp(),d=a.dot(CO).clamp(),f=a.dot(l).clamp(),p=sM({f0:t,f90:n,dotVH:CO.dot(l).clamp()}),m,h;if(SS(o)&&(p=gC.mix(p,i)),SS(s)){let t=xC.dot(e),n=xC.dot(CO),r=xC.dot(l),i=SC.dot(e),a=SC.dot(CO),o=SC.dot(l);m=bM({alphaT:yC,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=CM({alphaT:yC,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=yM({alpha:c,dotNL:u,dotNV:d}),h=xM({alpha:c,dotNH:f});return p.mul(m).mul(h)}),TM=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),EM=null,DM=W(({roughness:e,dotNV:t})=>{EM===null&&(EM=new hy(TM,16,16,Bm,Dm),EM.name=`DFG_LUT`,EM.minFilter=gm,EM.magFilter=gm,EM.wrapS=dm,EM.wrapT=dm,EM.generateMipmaps=!1,EM.needsUpdate=!0);let n=J(e,t);return tD(EM,n).rg}),OM=W(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let s=wM({lightDirection:e,f0:t,f90:n,roughness:r,f:i,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}),c=MO.dot(e).clamp(),l=DM({roughness:r,dotNV:MO.dot(CO).clamp()}),u=DM({roughness:r,dotNV:c}),d=t.mul(l.x).add(n.mul(l.y)),f=t.mul(u.x).add(n.mul(u.y)),p=l.x.add(l.y),m=u.x.add(u.y),h=G(1).sub(p),g=G(1).sub(m),_=t.add(t.oneMinus().mul(.047619)),v=d.mul(f).mul(_).div(G(1).sub(h.mul(g).mul(_).mul(_)).add(ww)),y=h.mul(g),b=v.mul(y);return s.add(b)}),kM=W(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=DM({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),AM=W(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(Y(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),jM=W(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=G(1).div(n),i=t.pow2().oneMinus().max(.0078125);return G(2).add(r).mul(i.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),MM=W(({dotNV:e,dotNL:t})=>G(1).div(G(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),NM=W(({lightDirection:e})=>{let t=e.add(CO).normalize(),n=MO.dot(e).clamp(),r=MO.dot(CO).clamp(),i=jM({roughness:hC,dotNH:MO.dot(t).clamp()}),a=MM({dotNV:r,dotNL:n});return mC.mul(i).mul(a)}),PM=W(({N:e,V:t,roughness:n})=>{let r=J(n,e.dot(t).saturate().oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),FM=W(({f:e})=>{let t=e.length();return dT(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),IM=W(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,dT(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),LM=W(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=Y().toVar();return PS(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(XS(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=Y(0).toVar();g.addAssign(IM({v1:f,v2:p})),g.addAssign(IM({v1:p,v2:m})),g.addAssign(IM({v1:m,v2:h})),g.addAssign(IM({v1:h,v2:f})),d.assign(Y(FM({f:g})))}),d}).setLayout({name:`LTC_Evaluate`,type:`vec3`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`P`,type:`vec3`},{name:`mInv`,type:`mat3`},{name:`p0`,type:`vec3`},{name:`p1`,type:`vec3`},{name:`p2`,type:`vec3`},{name:`p3`,type:`vec3`}]}),RM=1/6,zM=e=>ew(RM,ew(e,ew(e,e.negate().add(3)).sub(3)).add(1)),BM=e=>ew(RM,ew(e,ew(e,ew(3,e).sub(6))).add(4)),VM=e=>ew(RM,ew(e,ew(e,ew(-3,e).add(3)).add(3)).add(1)),HM=e=>ew(RM,vT(e,3)),UM=e=>zM(e).add(BM(e)),WM=e=>VM(e).add(HM(e)),GM=e=>QC(-1,BM(e).div(zM(e).add(BM(e)))),KM=e=>QC(1,HM(e).div(VM(e).add(HM(e)))),qM=(e,t,n)=>{let r=e.uvNode,i=ew(r,t.zw).add(.5),a=Bw(i),o=Uw(i),s=UM(o.x),c=WM(o.x),l=GM(o.x),u=KM(o.x),d=GM(o.y),f=KM(o.y),p=J(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=J(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=J(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=J(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=UM(o.y).mul(QC(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=WM(o.y).mul(QC(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},JM=W(([e,t])=>{let n=J(e.size(K(t))),r=J(e.size(K(t.add(1)))),i=tw(1,n),a=tw(1,r),o=qM(e,GS(i,n),Bw(t)),s=qM(e,GS(a,r),Vw(t));return Uw(t).mix(o,s)}),YM=W(([e,t])=>JM(e,t.mul(XE(e)))),XM=W(([e,t,n,r,i])=>{let a=Y(OT(t.negate(),Hw(e),tw(1,r))),o=Y(Qw(i[0].xyz),Qw(i[1].xyz),Qw(i[2].xyz));return Hw(a).mul(n.mul(o))}).setLayout({name:`getVolumeTransmissionRay`,type:`vec3`,inputs:[{name:`n`,type:`vec3`},{name:`v`,type:`vec3`},{name:`thickness`,type:`float`},{name:`ior`,type:`float`},{name:`modelMatrix`,type:`mat4`}]}),ZM=W(([e,t])=>e.mul(ET(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),QM=aj(),$M=sj(),eN=W(([e,t,n],{material:r})=>JM((r.side===1?QM:$M).sample(e),Lw(vD.x).mul(ZM(t,n)))),tN=W(([e,t,n])=>(PS(n.notEqual(0),()=>Pw(Iw(t).negate().div(n).negate().mul(e))),Y(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),nN=W(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=GS().toVar(),g=Y().toVar();let i=u.sub(1).mul(m.mul(.025)),a=Y(u.sub(i),u,u.add(i));WA({start:0,end:3},({i})=>{let u=a.element(i),m=XM(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(GS(_,1))),y=J(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(J(y.x,y.y.oneMinus()));let b=eN(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(tN(Qw(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=XM(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(GS(a,1))),_=J(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(J(_.x,_.y.oneMinus())),h=eN(_,n,u),g=r.mul(tN(Qw(i),f,p))}let _=g.rgb.mul(h.rgb),v=Y(kM({dotNV:e.dot(t).clamp(),specularColor:i,specularF90:a,roughness:n})),y=g.r.add(g.g,g.b).div(3);return GS(v.oneMinus().mul(_),h.a.oneMinus().mul(y).oneMinus())}),rN=XS(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),iN=e=>{let t=e.sqrt();return Y(1).add(t).div(Y(1).sub(t))},aN=(e,t)=>e.sub(t).div(e.add(t)).pow2(),oN=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=Y(54856e-17,44201e-17,52481e-17),i=Y(1681e3,1795300,2208400),a=Y(43278e5,93046e5,66121e5),o=G(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());return s=Y(s.x.add(o),s.y,s.z).div(1.0685e-7),rN.mul(s)},sN=W(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=TT(e,t,kT(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()).oneMinus();PS(o.lessThan(0),()=>Y(1));let s=o.sqrt(),c=sM({f0:aN(a,e),f90:1,dotVH:n}),l=c.oneMinus(),u=a.lessThan(e).select(Math.PI,0),d=G(Math.PI).sub(u),f=iN(i.clamp(0,.9999)),p=sM({f0:aN(f,a.toVec3()),f90:1,dotVH:s}),m=Y(f.x.lessThan(a).select(Math.PI,0),f.y.lessThan(a).select(Math.PI,0),f.z.lessThan(a).select(Math.PI,0)),h=a.mul(r,s,2),g=Y(d).add(m),_=c.mul(p).clamp(1e-5,.9999),v=_.sqrt(),y=l.pow2().mul(p).div(Y(1).sub(_)),b=c.add(y).toVar(),x=y.sub(l).toVar();return WA({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{x.mulAssign(v);let t=oN(G(e).mul(h),G(e).mul(g)).mul(2);b.addAssign(x.mul(t))}),b.max(Y(0))}).setLayout({name:`evalIridescence`,type:`vec3`,inputs:[{name:`outsideIOR`,type:`float`},{name:`eta2`,type:`float`},{name:`cosTheta1`,type:`float`},{name:`thinFilmThickness`,type:`float`},{name:`baseF0`,type:`vec3`}]}),cN=W(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.mul(n),a=n.add(.1).reciprocal(),o=G(-1.9362).add(n.mul(1.0678)).add(i.mul(.4573)).sub(a.mul(.8469)),s=G(-.6014).add(n.mul(.5538)).sub(i.mul(.467)).sub(a.mul(.1255));return o.mul(r).add(s).exp().saturate()}),lN=Y(.04),uN=G(1),dN=class extends rM{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Y().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=Y().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=Y().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=Y().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=Y().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=MO.dot(CO).clamp(),t=sN({outsideIOR:G(1),eta2:_C,cosTheta1:e,thinFilmThickness:vC,baseF0:CC}),n=sN({outsideIOR:G(1),eta2:_C,cosTheta1:e,thinFilmThickness:vC,baseF0:sC.rgb});this.iridescenceFresnel=TT(t,n,dC),this.iridescenceF0Dielectric=AM({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=AM({f:n,f90:1,dotVH:e}),this.iridescenceF0=TT(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,dC)}if(this.transmission===!0){let t=bO,n=qD.sub(bO).normalize(),r=NO,i=e.context;i.backdrop=nN(r,n,uC,cC,wC,TC,t,aO,WD,HD,jC,NC,FC,PC,this.dispersion?IC:null),i.backdropAlpha=MC,sC.a.mulAssign(TT(1,i.backdrop.a,MC))}super.start(e)}computeMultiscattering(e,t,n,r,i=null){let a=DM({roughness:uC,dotNV:MO.dot(CO).clamp()}),o=i?gC.mix(r,i):r,s=o.mul(a.x).add(n.mul(a.y)),c=a.x.add(a.y).oneMinus(),l=o.add(o.oneMinus().mul(.047619)),u=s.mul(l).div(c.mul(l).oneMinus());e.addAssign(s),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=MO.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(r.mul(NM({lightDirection:e})));let t=cN({normal:MO,viewDir:CO,roughness:hC}),n=cN({normal:MO,viewDir:e,roughness:hC}),i=mC.r.max(mC.g).max(mC.b).mul(t.max(n)).oneMinus();r.mulAssign(i)}if(this.clearcoat===!0){let n=PO.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(n.mul(wM({lightDirection:e,f0:lN,f90:uN,roughness:pC,normalView:PO})))}n.directDiffuse.addAssign(r.mul(cM({diffuseColor:cC}))),n.directSpecular.addAssign(r.mul(OM({lightDirection:e,f0:wC,f90:1,roughness:uC,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=MO,f=CO,p=SO.toVar(),m=PM({N:d,V:f,roughness:uC}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=XS(Y(h.x,0,h.y),Y(0,1,0),Y(h.z,0,h.w)).toVar(),v=wC.mul(g.x).add(TC.sub(wC).mul(g.y)).toVar();if(i.directSpecular.addAssign(e.mul(v).mul(LM({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(cC).mul(LM({N:d,V:f,P:p,mInv:XS(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u}))),this.clearcoat===!0){let t=PO,n=PM({N:t,V:f,roughness:pC}),r=a.sample(n),i=o.sample(n),d=XS(Y(r.x,0,r.y),Y(0,1,0),Y(r.z,0,r.w)),m=lN.mul(i.x).add(uN.sub(lN).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(LM({N:t,V:f,P:p,mInv:d,p0:s,p1:c,p2:l,p3:u})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context,r=t.mul(cM({diffuseColor:cC})).toVar();if(this.sheen===!0){let e=cN({normal:MO,viewDir:CO,roughness:hC}),t=mC.r.max(mC.g).max(mC.b).mul(e).oneMinus();r.mulAssign(t)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(mC,cN({normal:MO,viewDir:CO,roughness:hC}))),this.clearcoat===!0){let e=kM({dotNV:PO.dot(CO).clamp(),specularColor:lN,specularF90:uN,roughness:pC});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let i=Y().toVar(`singleScatteringDielectric`),a=Y().toVar(`multiScatteringDielectric`),o=Y().toVar(`singleScatteringMetallic`),s=Y().toVar(`multiScatteringMetallic`);this.computeMultiscattering(i,a,TC,CC,this.iridescenceF0Dielectric),this.computeMultiscattering(o,s,TC,sC.rgb,this.iridescenceF0Metallic);let c=TT(i,o,dC),l=TT(a,s,dC),u=i.add(a),d=cC.mul(u.oneMinus()),f=n.mul(1/Math.PI),p=t.mul(c).add(l.mul(f)).toVar(),m=d.mul(f).toVar();if(this.sheen===!0){let e=cN({normal:MO,viewDir:CO,roughness:hC}),t=mC.r.max(mC.g).max(mC.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}r.indirectSpecular.addAssign(p),r.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=MO.dot(CO).clamp().add(t),i=uC.mul(-16).oneMinus().negate().exp2(),a=t.sub(r.pow(i).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=sM({dotVH:PO.dot(CO).clamp(),f0:lN,f90:uN}),n=t.mul(fC.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(fC));t.assign(n)}if(this.sheen===!0){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}},fN=G(1),pN=G(-2),mN=G(.8),hN=G(-1),gN=G(.4),_N=G(2),vN=G(.305),yN=G(3),bN=G(.21),xN=G(4),SN=G(4),CN=G(16),wN=W(([e])=>{let t=Y(Xw(e)).toVar(),n=G(-1).toVar();return PS(t.x.greaterThan(t.z),()=>{PS(t.x.greaterThan(t.y),()=>{n.assign(LT(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(LT(e.y.greaterThan(0),1,4))})}).Else(()=>{PS(t.z.greaterThan(t.y),()=>{n.assign(LT(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(LT(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),TN=W(([e,t])=>{let n=J().toVar();return PS(t.equal(0),()=>{n.assign(J(e.z,e.y).div(Xw(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(J(e.x.negate(),e.z.negate()).div(Xw(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(J(e.x.negate(),e.y).div(Xw(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(J(e.z.negate(),e.y).div(Xw(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(J(e.x.negate(),e.z).div(Xw(e.y)))}).Else(()=>{n.assign(J(e.x,e.y).div(Xw(e.z)))}),ew(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),EN=W(([e])=>{let t=G(0).toVar();return PS(e.greaterThanEqual(mN),()=>{t.assign(fN.sub(e).mul(hN.sub(pN)).div(fN.sub(mN)).add(pN))}).ElseIf(e.greaterThanEqual(gN),()=>{t.assign(mN.sub(e).mul(_N.sub(hN)).div(mN.sub(gN)).add(hN))}).ElseIf(e.greaterThanEqual(vN),()=>{t.assign(gN.sub(e).mul(yN.sub(_N)).div(gN.sub(vN)).add(_N))}).ElseIf(e.greaterThanEqual(bN),()=>{t.assign(vN.sub(e).mul(xN.sub(yN)).div(vN.sub(bN)).add(yN))}).Else(()=>{t.assign(G(-2).mul(Lw(ew(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),DN=W(([e,t])=>{let n=e.toVar();n.assign(ew(2,n).sub(1));let r=Y(n,1).toVar();return PS(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),ON=W(([e,t,n,r,i,a])=>{let o=G(n),s=Y(t),c=ET(EN(o),pN,a),l=Uw(c),u=Bw(c),d=Y(kN(e,s,u,r,i,a)).toVar();return PS(l.notEqual(0),()=>{let t=Y(kN(e,s,u.add(1),r,i,a)).toVar();d.assign(TT(d,t,l))}),d}),kN=W(([e,t,n,r,i,a])=>{let o=G(n).toVar(),s=Y(t),c=G(wN(s)).toVar(),l=G(dT(SN.sub(o),0)).toVar();o.assign(dT(o,SN));let u=G(Fw(o)).toVar(),d=J(TN(s,c).mul(u.sub(2)).add(1)).toVar();return PS(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(ew(3,CN))),d.y.addAssign(ew(4,Fw(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(J(),J())}),AN=W(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=Gw(r);return kN(e,n.mul(c).add(i.cross(n).mul(Ww(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),jN=W(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=Y(LT(t,n,_T(n,r))).toVar();PS(f.equal(Y(0)),()=>{f.assign(Y(r.z,0,r.x.negate()))}),f.assign(Hw(f));let p=Y().toVar();return p.addAssign(i.element(0).mul(AN({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),WA({start:K(1),end:e},({i:e})=>{PS(e.greaterThanEqual(a),()=>{KA()});let t=G(o.mul(G(e))).toVar();p.addAssign(i.element(e).mul(AN({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(AN({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),GS(p,1)}),MN=W(([e])=>{let t=q(e).toVar();return t.assign(t.shiftLeft(q(16)).bitOr(t.shiftRight(q(16)))),t.assign(t.bitAnd(q(1431655765)).shiftLeft(q(1)).bitOr(t.bitAnd(q(2863311530)).shiftRight(q(1)))),t.assign(t.bitAnd(q(858993459)).shiftLeft(q(2)).bitOr(t.bitAnd(q(3435973836)).shiftRight(q(2)))),t.assign(t.bitAnd(q(252645135)).shiftLeft(q(4)).bitOr(t.bitAnd(q(4042322160)).shiftRight(q(4)))),t.assign(t.bitAnd(q(16711935)).shiftLeft(q(8)).bitOr(t.bitAnd(q(4278255360)).shiftRight(q(8)))),G(t).mul(23283064365386963e-26)}),NN=W(([e,t])=>J(G(e).div(G(t)),MN(e))),PN=W(([e,t,n])=>{let r=n.mul(n).toConst(),i=Y(1,0,0).toConst(),a=_T(t,i).toConst(),o=Rw(e.x).toConst(),s=ew(2,3.14159265359).mul(e.y).toConst(),c=o.mul(Gw(s)).toConst(),l=o.mul(Ww(s)).toVar(),u=ew(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(Rw(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(Rw(dT(0,c.mul(c).add(l.mul(l)).oneMinus()))));return Hw(Y(r.mul(d.x),r.mul(d.y),dT(0,d.z)))}),FN=W(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=Y(r).toVar(),l=Y(0).toVar(),u=G(0).toVar();return PS(e.lessThan(.001),()=>{l.assign(kN(n,c,t,a,o,s))}).Else(()=>{let r=Hw(_T(LT(Xw(c.z).lessThan(.999),Y(0,0,1),Y(1,0,0)),c)).toVar(),d=_T(c,r).toVar();WA({start:q(0),end:i},({i:f})=>{let p=PN(NN(f,i),Y(0,0,1),e),m=Hw(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=Hw(m.mul(gT(c,m).mul(2)).sub(c)),g=dT(gT(c,h),0);PS(g.greaterThan(0),()=>{let e=kN(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),PS(u.greaterThan(0),()=>{l.assign(l.div(u))})}),GS(l,1)}),IN=4,LN=[.125,.215,.35,.446,.526,.582],RN=20,zN=512,BN=new Db(-1,1,1,-1,0,1),VN=new Sb(90,1),HN=new R_,UN=null,WN=0,GN=0,KN=new B,qN=new WeakMap,JN=[3,1,5,0,4,2],YN=DN(JE(),qE(`faceIndex`)).normalize(),XN=Y(YN.x,YN.y,YN.z),ZN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=KN,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){R(`PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}UN=this._renderer.getRenderTarget(),WN=this._renderer.getActiveCubeFace(),GN=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return ig(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){R(`PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return ig(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){R(`PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return ig(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=iP(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=aP(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(UN,WN,GN),e.scissorTest=!1,eP(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),UN=this._renderer.getRenderTarget(),WN=this._renderer.getActiveCubeFace(),GN=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){return $N(3*Math.max(this._cubeSize,112),4*this._cubeSize)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$N(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=QN(t)),this._blurMaterial=nP(t,e.width,e.height),this._ggxMaterial=rP(t,e.width,e.height)}}async _compileMaterial(e){let t=new fy(new zv,e);await this._renderer.compile(t,BN)}_sceneToCubeUV(e,t,n,r,i){let a=VN;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(HN),c.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new fy(new Py,new ey({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,f=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,f=!0):(d.color.copy(HN),f=!0),c.setRenderTarget(r),c.clear(),f&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;eP(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=iP(e)):this._equirectMaterial===null&&(this._equirectMaterial=aP(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;eP(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,BN)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let s=qN.get(a),c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l)*(0+c*1.25),{_lodMax:d}=this,f=this._sizeLods[n],p=3*f*(n>d-IN?n-d+IN:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,eP(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,BN),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,eP(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,BN)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&z(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=qN.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*RN-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):RN;m>RN&&R(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${RN}`);let h=[],g=0;for(let e=0;e<RN;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=h,u.latitudinal.value=+(a===`latitudinal`),o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r];eP(t,3*v*(r>_-IN?r-_+IN:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,BN)}};function QN(e){let t=[],n=[],r=[],i=e,a=e-IN+1+LN.length;for(let o=0;o<a;o++){let a=2**i;t.push(a);let s=1/a;o>e-IN?s=LN[o-e+IN-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=JN[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new zv;h.setAttribute(`position`,new Cv(f,3)),h.setAttribute(`uv`,new Cv(p,2)),h.setAttribute(`faceIndex`,new Cv(m,1)),r.push(new fy(h,null)),i>IN&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function $N(e,t){let n=new t_(e,t,{magFilter:gm,minFilter:gm,generateMipmaps:!1,type:Dm,format:Fm,colorSpace:Ph});return n.texture.mapping=306,n.texture.name=`PMREM.cubeUv`,n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function eP(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function tP(e){let t=new Bj;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function nP(e,t,n){let r=dD(Array(RN).fill(0)),i=WC(new B(0,1,0)),a=WC(0),o=G(RN),s=WC(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:XN,dTheta:a,samples:WC(1),envMap:tD(),mipInt:WC(0),CUBEUV_TEXEL_WIDTH:G(1/t),CUBEUV_TEXEL_HEIGHT:G(1/n),CUBEUV_MAX_MIP:G(e)},l=tP(`blur`);return l.fragmentNode=jN({...c,latitudinal:s.equal(1)}),qN.set(l,c),l}function rP(e,t,n){let r={envMap:tD(),roughness:WC(0),mipInt:WC(0),CUBEUV_TEXEL_WIDTH:G(1/t),CUBEUV_TEXEL_HEIGHT:G(1/n),CUBEUV_MAX_MIP:G(e)},i=tP(`ggx`);return i.fragmentNode=FN({...r,N_immutable:XN,GGX_SAMPLES:q(zN)}),qN.set(i,r),i}function iP(e){let t=tP(`cubemap`);return t.fragmentNode=ZO(e,XN),t}function aP(e){let t=tP(`equirect`);return t.fragmentNode=tD(e,qj(XN),0),t}var oP=new WeakMap;function sP(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(2**t,112)),texelHeight:n,maxMip:t}}function cP(e,t,n){let r=lP(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(dP(t))i=n.fromCubemap(e,i);else return null;else if(fP(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function lP(e){let t=oP.get(e);return t===void 0&&(t=new WeakMap,oP.set(e,t)),t}var uP=class extends Fx{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new $g;r.isRenderTargetTexture=!0,this._texture=tD(r),this._width=WC(0),this._height=WC(0),this._maxMip=WC(0),this.updateBeforeType=Cx.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=sP(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:cP(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new ZN(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=WO.mul(Y(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),ON(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function dP(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function fP(e){return e==null?!1:e.height>0}var pP=kS(uP).setParameterLength(1,3),mP=new WeakMap,hP=class extends QA{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let r=n.isTextureNode?n.value:t[n.property],i=this._getPMREMNodeCache(e.renderer),a=i.get(r);a===void 0&&(a=pP(r),i.set(r,a)),n=a}let r=t.useAnisotropy===!0||t.anisotropy>0?jk:MO,i=n.context(gP(uC,r)).mul(UO),a=n.context(_P(NO)).mul(Math.PI).mul(UO),o=OE(i),s=OE(a);e.context.radiance.addAssign(o),e.context.iblIrradiance.addAssign(s);let c=e.context.lightingModel.clearcoatRadiance;if(c){let e=OE(n.context(gP(pC,PO)).mul(UO));c.addAssign(e)}}_getPMREMNodeCache(e){let t=mP.get(e);return t===void 0&&(t=new WeakMap,mP.set(e,t)),t}},gP=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=CO.negate().reflect(t),n=xT(e).mix(n,t).normalize(),n=n.transformDirection(WD)),n),getTextureLevel:()=>e}},_P=e=>({getUV:()=>e,getTextureLevel:()=>G(1)}),vP=new zy,yP=class extends Bj{static get type(){return`MeshStandardNodeMaterial`}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(vP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new hP(t):null}setupLightingModel(){return new dN}setupSpecular(){let e=TT(Y(.04),sC.rgb,dC);CC.assign(Y(.04)),wC.assign(e),TC.assign(1)}setupVariants(){let e=this.metalnessNode?G(this.metalnessNode):Zk;dC.assign(e);let t=this.roughnessNode?G(this.roughnessNode):Xk;t=vM({roughness:t}),uC.assign(t),this.setupSpecular(),cC.assign(sC.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}},bP=new By,xP=class extends yP{static get type(){return`MeshPhysicalNodeMaterial`}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(bP),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){let e=this.iorNode?G(this.iorNode):dA;jC.assign(e),CC.assign(uT(yT(jC.sub(1).div(jC.add(1))).mul(qk),Y(1)).mul(Kk)),wC.assign(TT(CC,sC.rgb,dC)),TC.assign(TT(Kk,1,dC))}setupLightingModel(){return new dN(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?G(this.clearcoatNode):$k,t=this.clearcoatRoughnessNode?G(this.clearcoatRoughnessNode):eA;fC.assign(e),pC.assign(vM({roughness:t}))}if(this.useSheen){let e=this.sheenNode?Y(this.sheenNode):rA,t=this.sheenRoughnessNode?G(this.sheenRoughnessNode):iA;mC.assign(e),hC.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?G(this.iridescenceNode):oA,t=this.iridescenceIORNode?G(this.iridescenceIORNode):sA,n=this.iridescenceThicknessNode?G(this.iridescenceThicknessNode):cA;gC.assign(e),_C.assign(t),vC.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?J(this.anisotropyNode):aA).toVar();bC.assign(e.length()),PS(bC.equal(0),()=>{e.assign(J(1,0))}).Else(()=>{e.divAssign(J(bC)),bC.assign(bC.saturate())}),yC.assign(bC.pow2().mix(uC.pow2(),1)),xC.assign(Ok[0].mul(e.x).add(Ok[1].mul(e.y))),SC.assign(Ok[1].mul(e.x).sub(Ok[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?G(this.transmissionNode):lA,t=this.thicknessNode?G(this.thicknessNode):uA,n=this.attenuationDistanceNode?G(this.attenuationDistanceNode):fA,r=this.attenuationColorNode?Y(this.attenuationColorNode):pA;if(MC.assign(e),NC.assign(t),PC.assign(n),FC.assign(r),this.useDispersion){let e=this.dispersionNode?G(this.dispersionNode):bA;IC.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Y(this.clearcoatNormalNode):tA}setup(e){e.context.setupClearcoatNormal=()=>ZT(this.setupClearcoatNormal(e),`NORMAL`,`vec3`),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}},SP=W(({normal:e,lightDirection:t,builder:n})=>{let r=J(e.dot(t).mul(.5).add(.5),0);if(n.material.gradientMap)return Y(ik(`gradientMap`,`texture`).context({getUV:()=>r}).r);{let e=r.fwidth().mul(.5);return TT(Y(.7),Y(1),kT(G(.7).sub(e.x),G(.7).add(e.x),r.x))}}),CP=class extends rM{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=SP({normal:DO,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(cM({diffuseColor:sC.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(cM({diffuseColor:sC}))),r.indirectDiffuse.mulAssign(t)}},wP=new Hy,TP=class extends Bj{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(wP),this.setValues(e)}setupLightingModel(){return new CP}},EP=W(()=>{let e=Y(CO.z,0,CO.x.negate()).normalize(),t=CO.cross(e);return J(e.dot(MO),t.dot(MO)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),DP=new Gy,OP=class extends Bj{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(DP),this.setValues(e)}setupVariants(e){let t=EP,n;n=e.material.matcap?ik(`matcap`,`texture`).context({getUV:()=>t}):Y(TT(.2,.8,t.y)),sC.rgb.mulAssign(n.rgb)}},kP=kS(class extends Fx{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return YS(e,r,r.negate(),e).mul(n)}else{let e=t,r=ZS(GS(1,0,0,0),GS(0,Gw(e.x),Ww(e.x).negate(),0),GS(0,Ww(e.x),Gw(e.x),0),GS(0,0,0,1)),i=ZS(GS(Gw(e.y),0,Ww(e.y),0),GS(0,1,0,0),GS(Ww(e.y).negate(),0,Gw(e.y),0),GS(0,0,0,1)),a=ZS(GS(Gw(e.z),Ww(e.z).negate(),0,0),GS(Ww(e.z),Gw(e.z),0,0),GS(0,0,1,0),GS(0,0,0,1));return r.mul(i).mul(a).mul(GS(n,1)).xyz}}}).setParameterLength(2),AP=new Gv,jP=class extends Bj{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(AP),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,{positionNode:r,rotationNode:i,scaleNode:a,sizeAttenuation:o}=this,s=fO.mul(Y(r||0)),c=J(aO[0].xyz.length(),aO[1].xyz.length());a!==null&&(c=c.mul(J(a))),n.isPerspectiveCamera&&o===!1&&(c=c.mul(s.z.negate()));let l=_O.xy;if(t.center&&t.center.isVector2===!0){let e=uE(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=G(i||nA),d=kP(l,u);return GS(s.xy.add(d),s.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}},MP=new ky,NP=new Pg,PP=class extends jP{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(MP),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return fO.mul(Y(e||vO)).xyz}setupVertexSprite(e){let{material:t,camera:n}=e,{rotationNode:r,scaleNode:i,sizeNode:a,sizeAttenuation:o}=this,s=super.setupVertex(e);if(t.isNodeMaterial!==!0)return s;let c=a===null?yA:J(a);c=c.mul(gD),n.isPerspectiveCamera&&o===!0&&(c=c.mul(FP.div(SO.z.negate()))),i&&i.isNode&&(c=c.mul(J(i)));let l=_O.xy;if(r&&r.isNode){let e=G(r);l=kP(l,e)}return l=l.mul(c),l=l.div(xD.div(2)),l=l.mul(s.w),s=s.add(GS(l,0,0)),s}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},FP=WC(1).onFrameUpdate(function({renderer:e}){this.value=.5*e.getSize(NP).y}),IP=class extends rM{constructor(){super(),this.shadowNode=G(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){sC.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(sC.rgb)}},LP=new Ry,RP=class extends Bj{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(LP),this.setValues(e)}setupLightingModel(){return new IP}};aC(`vec3`),aC(`vec3`),aC(`vec3`);var zP=class{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},BP=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},VP=0;function HP(e){let t=Object.keys(e),n=Object.getPrototypeOf(e);for(;n;){let e=Object.getOwnPropertyDescriptors(n);for(let n in e)if(e[n]!==void 0){let r=e[n];r&&typeof r.get==`function`&&t.push(n)}n=Object.getPrototypeOf(n)}return t}var UP=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=VP++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=o,this.lightsNode=s,this.context=c,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=l,this.clippingContextCacheKey=l===null?``:l.cacheKey,this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener(`dispose`,this.onMaterialDispose),this.geometry.addEventListener(`dispose`,this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,i={};for(let a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:(e=t.getAttribute(a.name),i[a.name]=e.id),e===void 0)continue;n.push(e);let o=e.isInterleavedBufferAttribute?e.data:e;r.add(o)}return this.attributes=n,this.attributesId=i,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e<n;e++){let n=r[e];t+=n.id+`,`}}return e.index&&(t+=`index,`),t}getMaterialCacheKey(){let{object:e,material:t,renderer:n}=this,r=t.customProgramCacheKey();for(let e of HP(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let i=t[e],a;if(i!==null){let e=typeof i;e===`number`?a=i===0?`0`:`1`:e===`object`?(a=`{`,i.isTexture&&(a+=i.mapping,n.backend.isWebGPUBackend===!0&&(a+=i.magFilter,a+=i.minFilter,a+=i.wrapS,a+=i.wrapT,a+=i.wrapR)),a+=`}`):a=String(i)}else a=String(i);r+=a+`,`}return r+=this.clippingContextCacheKey+`,`,e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+`,`),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+`,`,e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+`,`)),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(r+=e.uuid+`,`),r+=this.context.id+`,`,r+=e.receiveShadow+`,`,sx(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){let e=this.attributesId;for(let t in e){let n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=lx(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=lx(e,1)),e=lx(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.geometry.removeEventListener(`dispose`,this.onGeometryDispose),this.onDispose()}},WP=[],GP=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);WP[0]=e,WP[1]=t,WP[2]=a,WP[3]=i;let l=c.get(WP);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(WP,l)):(l.camera=r,l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),WP[0]=null,WP[1]=null,WP[2]=null,WP[3]=null,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new BP)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new UP(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},KP=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}},qP={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},JP=16,YP=211,XP=212,ZP=class extends KP{constructor(e){super(),this.backend=e}delete(e){let t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===qP.VERTEX?this.backend.createAttribute(e):t===qP.INDEX?this.backend.createIndexAttribute(e):t===qP.STORAGE?this.backend.createStorageAttribute(e):t===qP.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version<t.version||t.usage===35048)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function QP(e){return e.index===null?e.attributes.position.version:e.index.version}function $P(e){return e.index===null?e.attributes.position.id:e.index.id}function eF(e){let t=[],n=e.index,r=e.attributes.position;if(n!==null){let e=n.array;for(let n=0,r=e.length;n<r;n+=3){let r=e[n+0],i=e[n+1],a=e[n+2];t.push(r,i,i,a,a,r)}}else{let e=r.array;for(let n=0,r=e.length/3-1;n<r;n+=3){let e=n+0,r=n+1,i=n+2;t.push(e,r,r,i,i,e)}}let i=new(r.count>=65535?Tv:wv)(t,1);return i.version=QP(e),i.__id=$P(e),i}var tF=class extends KP{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r),this._geometryDisposeListeners.delete(t)};t.addEventListener(`dispose`,r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,qP.STORAGE):this.updateAttribute(e,qP.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,qP.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,qP.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=eF(t),e.set(t,n)):(n.version!==QP(t)||n.__id!==$P(t))&&(this.attributes.delete(n),n=eF(t),e.set(t,n)),r=n}return r}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener(`dispose`,t);this._geometryDisposeListeners.clear()}},nF=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*n:e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=t/2*n:e.isLine?this.render.lines+=n*(t-1):z(`WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}},rF=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},iF=class extends rF{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},aF=class extends rF{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}},oF=0,sF=class{constructor(e,t,n,r=null,i=null){this.id=oF++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},cF=class extends KP{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new sF(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new sF(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new sF(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new aF(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new iF(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}},lF=class extends KP{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings();for(let e of t){let n=this.get(e);n.bindGroup===void 0&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let e of t){let n=this.get(e);n.bindGroup===void 0&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let e of t)this.backend.deleteBindGroupData(e),this.delete(e)}deleteForRender(e){let t=e.getBindings();for(let e of t)this.backend.deleteBindGroupData(e),this.delete(e)}_updateBindings(e){for(let t of e)this._update(t,e)}_init(e){for(let t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){let e=t.attribute,n=e.isIndirectStorageBufferAttribute?qP.INDIRECT:qP.STORAGE;this.attributes.update(e,n)}}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings)if(this.nodes.updateGroup(t)!==!1){if(t.isStorageBuffer){let e=t.attribute,i=e.isIndirectStorageBufferAttribute?qP.INDIRECT:qP.STORAGE,a=n.get(t);this.attributes.update(e,i),a.attribute!==e&&(a.attribute=e,r=!0)}if(t.isUniformBuffer)t.update()&&n.updateBinding(t);else if(t.isSampledTexture){let s=t.update(),c=t.texture,l=this.textures.get(c);if(s&&(this.textures.updateTexture(c),t.generation!==l.generation&&(t.generation=l.generation,r=!0),l.bindGroups.add(e)),n.get(c).externalTexture!==void 0||l.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),c.isStorageTexture===!0&&c.mipmapsAutoUpdate===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t.texture);t.samplerKey!==e&&(t.samplerKey=e,r=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}};function uF(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function dF(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function fF(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===2&&e.forceSinglePass===!1}var pF=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(fF(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(fF(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||uF),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||dF),this.transparent.length>1&&this.transparent.sort(t||dF)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}}},mF=[],hF=class{constructor(e){this.lighting=e,this.lists=new BP}get(e,t){let n=this.lists;mF[0]=e,mF[1]=t;let r=n.get(mF);return r===void 0&&(r=new pF(this.lighting,e,t),n.set(mF,r)),mF[0]=null,mF[1]=null,r}dispose(){this.lists=new BP}},gF=0,_F=class{constructor(){this.id=gF++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new e_,this.scissor=!1,this.scissorValue=new e_,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return vF(this)}};function vF(e){let{textures:t,activeCubeFace:n,activeMipmapLevel:r}=e,i=[n,r];for(let e of t)i.push(e.id);return cx(i)}var yF=class{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,n=0){let r;if(e===null)r=`default`;else{let t=e.texture.format,n=e.texture.type;r=`${e.textures.length}:${t}:${n}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let i=t===null?`default`:t.id,a=r+`-`+i+`-`+n,o=this._renderContexts[a];return o===void 0&&(o=new _F,o.mrt=t,this._renderContexts[a]=o),e!==null&&(o.sampleCount=e.samples===0?1:e.samples),o.clearDepthValue=this.renderer.getClearDepth(),o.clearStencilValue=this.renderer.getClearStencil(),o}dispose(){this._renderContexts={}}},bF=new B,xF=class extends KP{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){let n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||={},a=e.textures,o=this.getSize(a[0]),s=o.width>>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1;l===void 0&&u&&(l=new My,l.format=e.stencilBuffer?Lm:Im,l.type=e.stencilBuffer?Am:Tm,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.renderTarget=e,l.isArrayTexture=e.multiview===!0&&o.depth>1,i[t]=l),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=l.isArrayTexture?l.image.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let f={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,f)}l&&this.updateTexture(l,f)}n.initialized!==!0&&(n.initialized=!0,n.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener(`dispose`,n.onDispose))}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&i.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=bm}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)i.createTexture(e,t),n.generation=e.version;else if(e.version>0){let r=e.image;if(r===void 0)R(`Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)R(`Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t);let a=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!a&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.memory.textures++,e.isVideoTexture&&Ug.enabled===!0&&Ug.getTransfer(e.colorSpace)!==`srgb`&&R(`WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.`),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener(`dispose`,n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=bF){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement<`u`&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<`u`&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture===!0?1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){let t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener(`dispose`,t.onDispose);for(let e=0;e<n.length;e++)this._destroyTexture(n[e]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e)}}_destroyTexture(e){if(this.has(e)===!0){let t=this.get(e);e.removeEventListener(`dispose`,t.onDispose);let n=t.isDefaultTexture;if(this.backend.destroyTexture(e,n),t.bindGroups)for(let e of t.bindGroups){let t=this.backend.get(e);t.groups=void 0,t.versions=void 0}this.delete(e),this.info.memory.textures--}}},SF=class extends R_{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},CF=class extends iC{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(z(`TSL: Member "${t}" not found in struct "${n}".`,new ax),i=`float`):i=r.getMemberType(e,t),i}getHash(){return this.uuid}generate(){return this.name}},wF=(e,t)=>new CF(e,t),TF=kS(class extends Mx{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput(e)?this.outputNode.getElementType(e):`void`}getNodeType(e){return this.hasOutput(e)?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.hasOutput(e)?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=this.nodes.length){return e.isNode===!0?(this.nodes.splice(t,0,e),this):(z(`TSL: Invalid node added to stack.`,new ax),this)}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){return this._currentCond=LT(e,new wS(t)),this.addToStack(this._currentCond)}ElseIf(e,t){let n=LT(e,new wS(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new wS(e),this}Switch(e){return this._expressionNode=TS(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(TS(e[n])));else z(`TSL: Invalid parameter length. Case() requires at least two parameters.`,new ax);let n=e[e.length-1],r=new wS(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=LT(i,r);return this._currentCond===null?(this._currentCond=a,this.addToStack(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),n=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t[`node`+ n++]=r);return t.outputNode||null}hasOutput(e){return this.outputNode&&this.outputNode.isNode&&this.outputNode.getNodeType(e)!==`void`}build(e,...t){let n=NS(),r=e.buildStage;MS(this),e.setActiveStack(this);let i=t=>{if(this._currentNode=t,!(t.isVarNode&&t.isIntent(e)&&t.isAssign(e)!==!0)){if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)return;t.build(e,`void`)}}},a=[...this.nodes];for(let e of a)i(e);this._currentNode=null;let o=this.nodes.filter(e=>a.indexOf(e)===-1);for(let e of o)i(e);let s;return s=this.hasOutput(e)?this.outputNode.build(e,...t):super.build(e,...t),MS(n),e.removeActiveStack(this),s}}).setParameterLength(0,1);function EF(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var DF=class extends Mx{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=EF(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=Float32Array.BYTES_PER_ELEMENT,t=1,n=0;for(let r of this.membersLayout){let i=r.type,a=hx(i),o=gx(i)/e;t=Math.max(t,o);let s=n%t%o;s!==0&&(n+=o-s),n+=a}return Math.ceil(n/t)*t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},OF=class extends Mx{static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},kF=(e,t=null)=>{let n=new DF(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return new OF(n,r)};return r.layout=n,r.isStruct=!0,r},AF=class extends Mx{static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(){return`OutputType`}generate(e){let t=e.getDataFromNode(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let n=e.getOutputStructName(),r=this.members,i=n===``?``:n+`.`;for(let t=0;t<r.length;t++){let n=r[t].build(e);e.addLineFlowCode(`${i}m${t} = ${n}`,this)}return n}},jF=kS(AF),MF=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}},NF=new MF(0),PF=new MF(6);function FF(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var IF=kS(class extends AF{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.blendModes={output:PF},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||NF}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes},n={...this.blendModes,...e.blendModes},r=IF(t);return r.blendings=n,r}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=FF(i,e);r[n]=GS(t[e])}return this.members=r,super.setup(e)}}),LF=class extends Fx{static get type(){return`BitcastNode`}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),n=``;if(this.inputType!==null){let t=this.valueNode.getNodeType(e);n=e.getTypeLength(t)===1?this.inputType:e.changeComponentType(t,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}},RF=U(LF).setParameterLength(2),zF=e=>new LF(e,`int`,`float`),BF=e=>new LF(e,`uint`,`float`),VF=e=>new LF(e,`float`,`int`),HF=e=>new LF(e,`float`,`uint`),UF={},WF=class e extends X{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(RF(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return q;case`int`:return K;case`uvec2`:return BS;case`uvec3`:return US;case`uvec4`:return qS;case`ivec2`:return zS;case`ivec3`:return HS;case`ivec4`:return KS}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{let r=q(0);return this._resolveElementType(e,r,t),n(BF(G(r.bitAnd($w(r)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{PS(e.equal(q(0)),()=>q(32));let r=q(0),i=q(0);return this._resolveElementType(e,r,t),PS(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),PS(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),PS(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),PS(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),PS(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return W(([e])=>{let r=q(0);return this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(q(1)).bitAnd(q(1431655765)))),r.assign(r.bitAnd(q(858993459)).add(r.shiftRight(q(2)).bitAnd(q(858993459)))),n(r.add(r.shiftRight(q(4))).bitAnd(q(252645135)).mul(q(16843009)).shiftRight(q(24)))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return W(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;i<n;i++){let n=a[i];t[n].assign(r(e[n]))}return t}}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}setup(t){let{method:n,aNode:r}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);let a=this.getInputType(t),o=t.getElementType(a),s=t.getTypeLength(a),c=`${n}_base_${o}`,l=`${n}_${a}`,u=UF[c];if(u===void 0){switch(n){case e.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(c,o);break;case e.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(c,o);break;case e.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(c,o);break}UF[c]=u}let d=UF[l];return d===void 0&&(d=this._createMainLayout(l,a,s,u),UF[l]=d),W(()=>d(r))()}};WF.COUNT_TRAILING_ZEROS=`countTrailingZeros`,WF.COUNT_LEADING_ZEROS=`countLeadingZeros`,WF.COUNT_ONE_BITS=`countOneBits`;var GF=U(WF,WF.COUNT_TRAILING_ZEROS).setParameterLength(1),KF=U(WF,WF.COUNT_LEADING_ZEROS).setParameterLength(1),qF=U(WF,WF.COUNT_ONE_BITS).setParameterLength(1),JF=W(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/2**32)}),YF=(e,t)=>vT(ew(4,e.mul($C(1,e))),t),XF=(e,t)=>e.lessThan(.5)?YF(e.mul(2),t).div(2):$C(1,YF(ew($C(1,e),2),t).div(2)),ZF=(e,t,n)=>vT(tw(vT(e,t),QC(vT(e,t),vT($C(1,e),n))),1/t),QF=(e,t)=>Ww(Ew.mul(t.mul(e).sub(1))).div(Ew.mul(t.mul(e).sub(1))),$F=class extends Fx{static get type(){return`PackFloatNode`}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}getNodeType(){return`uint`}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},eI=U($F,`snorm`).setParameterLength(1),tI=U($F,`unorm`).setParameterLength(1),nI=U($F,`float16`).setParameterLength(1),rI=class extends Fx{static get type(){return`UnpackFloatNode`}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}getNodeType(){return`vec2`}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},iI=U(rI,`snorm`).setParameterLength(1),aI=U(rI,`unorm`).setParameterLength(1),oI=U(rI,`float16`).setParameterLength(1),sI=W(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),cI=W(([e])=>Y(sI(e.z.add(sI(e.y.mul(1)))),sI(e.z.add(sI(e.x.mul(1)))),sI(e.y.add(sI(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),lI=W(([e,t,n])=>{let r=Y(e).toVar(),i=G(1.4).toVar(),a=G(0).toVar(),o=Y(r).toVar();return WA({start:G(0),end:G(3),type:`float`,condition:`<=`},()=>{let e=Y(cI(o.mul(2))).toVar();r.addAssign(e.add(n.mul(G(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=G(sI(r.z.add(sI(r.x.add(sI(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]}),uI=kS(class extends Mx{static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}getNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,n=this._candidateFn;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let o=a.inputs;if(t.length===o.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=o[n];r.getNodeType(e)===i.type&&a++}a>i&&(r=n,i=a)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),dI=e=>(...t)=>uI(e,...t),fI=WC(0).setGroup(VC).onRenderUpdate(e=>e.time),pI=WC(0).setGroup(VC).onRenderUpdate(e=>e.deltaTime),mI=WC(0,`uint`).setGroup(VC).onRenderUpdate(e=>e.frameId),hI=(e=fI)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),gI=(e=fI)=>e.fract().round(),_I=(e=fI)=>e.add(.5).fract().mul(2).sub(1).abs(),vI=(e=fI)=>e.fract();function yI(e,t=null){return zT(t,{getUV:typeof e==`function`?e:()=>e})}var bI=W(([e,t,n=J(.5)])=>kP(e.sub(n),t).add(n)),xI=W(([e,t,n=J(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i).mul(t);return e.add(r.mul(a))}),SI=W(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=aO:(r=aO.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=WD.mul(r);return SS(t)&&(i[0][0]=aO[0].length(),i[0][1]=0,i[0][2]=0),SS(n)&&(i[1][0]=0,i[1][1]=aO[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,HD.mul(i).mul(vO)}),CI=W(([e=null])=>{let t=xj();return xj(lj(e)).sub(t).lessThan(0).select(_D,e)}),wI=W(([e,t=JE(),n=G(0)])=>{let r=e.x,i=e.y,a=n.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=e.reciprocal(),l=J(o,s);return t.add(l).mul(c)}),TI=W(([e,t=null,n=null,r=G(1),i=vO,a=OO])=>{let o=a.abs().normalize();o=o.div(o.dot(Y(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value;return QC(tD(u,s).mul(o.x),tD(d,c).mul(o.y),tD(f,l).mul(o.z))}),EI=(...e)=>TI(...e),DI=new by,OI=new B,kI=new B,AI=new B,jI=new r_,MI=new B(0,0,-1),NI=new e_,PI=new B,FI=new B,II=new e_,LI=new Pg,RI=new t_,zI=_D.flipX();RI.depthTexture=new My(1,1);var BI=!1,VI=class e extends $E{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||RI.texture,zI),this._reflectorBaseNode=e.reflector||new HI(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=new e({defaultTexture:RI.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},HI=class extends Mx{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new A_,resolutionScale:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1,samples:s=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(ig(`ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".`),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=a,this.depth=o,this.samples=s,this.updateBeforeType=a?Cx.RENDER:Cx.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolutionScale;t.getDrawingBufferSize(LI),e.setSize(Math.round(LI.width*n),Math.round(LI.height*n))}setup(e){return this._updateResolution(RI,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new t_(0,0,{type:Dm,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=ym,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new My),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&BI)return!1;BI=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(LI),this._updateResolution(s,r),kI.setFromMatrixPosition(a.matrixWorld),AI.setFromMatrixPosition(n.matrixWorld),jI.extractRotation(a.matrixWorld),OI.set(0,0,1),OI.applyMatrix4(jI),PI.subVectors(kI,AI);let c=PI.dot(OI)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){BI=!1;return}l=!0}PI.reflect(OI).negate(),PI.add(kI),jI.extractRotation(n.matrixWorld),MI.set(0,0,-1),MI.applyMatrix4(jI),MI.add(AI),FI.subVectors(kI,MI),FI.reflect(OI).negate(),FI.add(kI),o.coordinateSystem=n.coordinateSystem,o.position.copy(PI),o.up.set(0,1,0),o.up.applyMatrix4(jI),o.up.reflect(OI),o.lookAt(FI),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),DI.setFromNormalAndCoplanarPoint(OI,kI),DI.applyMatrix4(o.matrixWorldInverse),NI.set(DI.normal.x,DI.normal.y,DI.normal.z,DI.constant);let u=o.projectionMatrix;II.x=(Math.sign(NI.x)+u.elements[8])/u.elements[0],II.y=(Math.sign(NI.y)+u.elements[9])/u.elements[5],II.z=-1,II.w=(1+u.elements[10])/u.elements[14],NI.multiplyScalar(1/NI.dot(II)),u.elements[2]=NI.x,u.elements[6]=NI.y,u.elements[10]=r.coordinateSystem===2001?NI.z-0:NI.z+1-0,u.elements[14]=NI.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let d=r.getRenderTarget(),f=r.getMRT(),p=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0;let m=t.name;t.name=(t.name||`Scene`)+` [ Reflector ]`,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),t.name=m,r.setMRT(f),r.setRenderTarget(d),r.autoClear=p,i.visible=!0,BI=!1,this.forceUpdate=!1}get resolution(){return ig(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale}set resolution(e){ig(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale=e}},UI=e=>new VI(e),WI=new Db(-1,1,1,-1,0,1),GI=new class extends zv{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new Dv([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Dv(t,2))}},KI=class extends fy{constructor(e=null){super(GI,e),this.camera=WI,this.isQuadMesh=!0}async renderAsync(e){ig(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await e.init(),e.render(this,WI)}render(e){e.render(this,WI)}},qI=new Pg,JI=class extends $E{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:Dm}){let i=new t_(t,n,r);super(i.texture,JE()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new KI(new Bj),this.updateBeforeType=Cx.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){let t=e.getPixelRatio(),n=e.getSize(qI),r=Math.floor(n.width*t),i=Math.floor(n.height*t);(r!==this.renderTarget.width||i!==this.renderTarget.height)&&(this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0)}let t=`RTT`;this.node.name&&(t=this.node.name+` [ `+t+` ]`),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;let n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(n)}clone(){let e=new $E(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},YI=(e,...t)=>new JI(TS(e),...t),XI=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():YI(e,...t),ZI=W(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===2001?(e=J(e.x,e.y.oneMinus()).mul(2).sub(1),i=GS(Y(e,t),1)):i=GS(Y(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=GS(n.mul(i));return a.xyz.div(a.w)}),QI=W(([e,t])=>{let n=t.mul(GS(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return J(r.x,r.y.oneMinus())}),$I=W(([e,t,n])=>{let r=YE(rD(t)),i=zS(e.mul(r)).toVar(),a=rD(t,i).toVar(),o=rD(t,i.sub(zS(2,0))).toVar(),s=rD(t,i.sub(zS(1,0))).toVar(),c=rD(t,i.add(zS(1,0))).toVar(),l=rD(t,i.add(zS(2,0))).toVar(),u=rD(t,i.add(zS(0,2))).toVar(),d=rD(t,i.add(zS(0,1))).toVar(),f=rD(t,i.sub(zS(0,1))).toVar(),p=rD(t,i.sub(zS(0,2))).toVar(),m=Xw($C(G(2).mul(s).sub(o),a)).toVar(),h=Xw($C(G(2).mul(c).sub(l),a)).toVar(),g=Xw($C(G(2).mul(d).sub(u),a)).toVar(),_=Xw($C(G(2).mul(f).sub(p),a)).toVar(),v=ZI(e,a,n).toVar();return Hw(_T(m.lessThan(h).select(v.sub(ZI(e.sub(J(G(1).div(r.x),0)),s,n)),v.negate().add(ZI(e.add(J(G(1).div(r.x),0)),c,n))),g.lessThan(_).select(v.sub(ZI(e.add(J(0,G(1).div(r.y))),d,n)),v.negate().add(ZI(e.sub(J(0,G(1).div(r.y))),f,n)))))}),eL=W(([e])=>Uw(G(52.9829189).mul(Uw(gT(e,J(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),tL=W(([e,t,n])=>{let r=G(2.399963229728653),i=Rw(G(e).add(.5).div(G(t))),a=G(e).mul(r).add(n);return J(Gw(a),Ww(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),nL=class extends Mx{static get type(){return`SampleNode`}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(JE())}sample(e){return this.callback(e)}},rL=(e,t=null)=>new nL(e,TS(t)),iL=class e extends Mx{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=Cx.OBJECT:t===e.MATERIAL?this.updateType=Cx.RENDER:t===e.BEFORE_OBJECT?this.updateBeforeType=Cx.OBJECT:t===e.BEFORE_MATERIAL&&(this.updateBeforeType=Cx.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};iL.OBJECT=`object`,iL.MATERIAL=`material`,iL.BEFORE_OBJECT=`beforeObject`,iL.BEFORE_MATERIAL=`beforeMaterial`;var aL=(e,t)=>new iL(e,t).toStack(),oL=e=>aL(iL.OBJECT,e),sL=e=>aL(iL.MATERIAL,e),cL=e=>aL(iL.BEFORE_OBJECT,e),lL=e=>aL(iL.BEFORE_MATERIAL,e),uL=class extends gy{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},dL=class extends Cv{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}},fL=(e,t=`float`)=>{let n,r;return t.isStruct===!0?(n=t.layout.getLength(),r=px(`float`)):(n=mx(t),r=px(t)),DA(new dL(e,n,r),t,e)},pL=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=px(`float`)):(n=mx(t),r=px(t));let i=new uL(e,n,r);return DA(i,t,i.count)},mL=H(class extends Mx{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}}),hL=new p_,gL=new r_,_L=WC(0).setGroup(VC).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),vL=WC(1).setGroup(VC).onRenderUpdate(({scene:e})=>e.backgroundIntensity),yL=WC(new r_).setGroup(VC).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300?(hL.copy(e.backgroundRotation),hL.x*=-1,hL.y*=-1,hL.z*=-1,gL.makeRotationFromEuler(hL)):gL.identity(),gL}),bL=kS(class extends $E{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=Tx.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value;return e.generateStorageTextureLoad(l,t,n,r,a,c)}toReadWrite(){return this.setAccess(Tx.READ_WRITE)}toReadOnly(){return this.setAccess(Tx.READ_ONLY)}toWriteOnly(){return this.setAccess(Tx.WRITE_ONLY)}generateStore(e){let{uvNode:t,storeNode:n,depthNode:r}=e.getNodeProperties(this),i=super.generate(e,`property`),a=t.build(e,this.value.is3DTexture===!0?`uvec3`:`uvec2`),o=n.build(e,`vec4`),s=r?r.build(e,`int`):null,c=e.generateTextureStore(e,i,a,s,o);e.addLineFlowCode(c,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}).setParameterLength(1,3),xL=(e,t,n)=>{let r;return e.isStorageTextureNode===!0?(r=e.clone(),r.uvNode=t,r.storeNode=n):r=bL(e,t,n),n!==null&&r.toStack(),r},SL=W(({texture:e,uv:t})=>{let n=1e-4,r=Y().toVar();return PS(t.x.lessThan(n),()=>{r.assign(Y(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(Y(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(Y(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(Y(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(Y(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(Y(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(Y(-n,0,0))).r.sub(e.sample(t.add(Y(n,0,0))).r),a=e.sample(t.add(Y(0,-n,0))).r.sub(e.sample(t.add(Y(0,n,0))).r),o=e.sample(t.add(Y(0,0,-n))).r.sub(e.sample(t.add(Y(0,0,n))).r);r.assign(Y(i,a,o))}),r.normalize()}),CL=kS(class extends $E{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return Y(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}normal(e){return SL({texture:this,uv:e})}}).setParameterLength(1,3),wL=(...e)=>CL(...e).setSampler(!1),TL=(e,t,n)=>CL(e,t).level(n),EL=class extends ek{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},DL=(e,t,n)=>new EL(e,t,n),OL=new WeakMap,kL=class extends Fx{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=Cx.OBJECT,this.updateAfterType=Cx.OBJECT,this.previousModelWorldMatrix=WC(new r_),this.previousProjectionMatrix=WC(new r_).setGroup(VC),this.previousCameraViewMatrix=WC(new r_)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=jL(n);this.previousModelWorldMatrix.value.copy(r);let i=AL(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new r_,i.previousCameraViewMatrix=new r_,i.currentProjectionMatrix=new r_,i.currentCameraViewMatrix=new r_,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){jL(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?HD:WC(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(fO).mul(vO),r=this.previousProjectionMatrix.mul(t).mul(yO);return $C(n.xy.div(n.w),r.xy.div(r.w))}};function AL(e){let t=OL.get(e);return t===void 0&&(t={},OL.set(e,t)),t}function jL(e,t=0){let n=AL(e),r=n[t];return r===void 0&&(n[t]=r=new r_,n[t].copy(e.matrixWorld)),r}var ML=H(kL),NL=W(([e])=>LL(e.rgb)),PL=W(([e,t=G(1)])=>t.mix(LL(e.rgb),e.rgb)),FL=W(([e,t=G(1)])=>{let n=QC(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return TT(e.rgb,r,i)}),IL=W(([e,t=G(1)])=>{let n=Y(.57735,.57735,.57735),r=t.cos();return Y(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(gT(n,e.rgb).mul(r.oneMinus())))))}),LL=(e,t=Y(Ug.getLuminanceCoefficients(new B)))=>gT(e,t),RL=W(([e,t=Y(1),n=Y(0),r=Y(1),i=G(1),a=Y(Ug.getLuminanceCoefficients(new B,Ph))])=>{let o=e.rgb.dot(Y(a)),s=dT(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return PS(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),PS(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),PS(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),GS(s.rgb,e.a)}),zL=W(([e,t])=>e.mul(t).floor().div(t)),BL=null,VL=kS(class extends rj{static get type(){return`ViewportSharedTextureNode`}constructor(e=_D,t=null){BL===null&&(BL=new Ay),super(e,t,BL)}getTextureForReference(){return BL}updateReference(){return this}}).setParameterLength(0,2),HL=new Pg,UL=class extends $E{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},WL=class extends UL{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},GL=class e extends Fx{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new My;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new t_(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Dm,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=WC(0),this._cameraFar=WC(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Cx.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return R(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return R(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new WL(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new WL(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=gj(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=dj(i,n,r)}return t}async compileAsync(e){let t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),HL.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(HL)),this._pixelRatio=i,this.setSize(HL.width,HL.height);let o=t.getRenderTarget(),s=t.getMRT(),c=t.autoClear,l=t.transparent,u=t.opaque,d=r.layers.mask,f=t.contextNode,p=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:zT({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);let m=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=m,n.overrideMaterial=p,t.setRenderTarget(o),t.setMRT(s),t.autoClear=c,t.transparent=l,t.opaque=u,t.contextNode=f,r.layers.mask=d}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new e_),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new e_),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};GL.COLOR=`color`,GL.DEPTH=`depth`;var KL=(e,t,n)=>new GL(GL.COLOR,e,t,n),qL=(e,t)=>new UL(e,t),JL=(e,t,n)=>new GL(GL.DEPTH,e,t,n),YL=class extends GL{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(GL.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap,this.name=`Outline Pass`}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Bj;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=1;let t=OO.negate(),n=HD.mul(fO),r=G(1),i=n.mul(GS(vO,1)),a=n.mul(GS(vO.add(t),1)),o=Hw(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=GS(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},XL=(e,t,n=new R_(0,0,0),r=.003,i=1)=>new YL(e,t,TS(n),TS(r),TS(i)),ZL=W(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),QL=W(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),$L=W(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),eR=W(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),tR=W(([e,t])=>{let n=XS(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=XS(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=eR(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),nR=XS(Y(1.6605,-.1246,-.0182),Y(-.5876,1.1329,-.1006),Y(-.0728,-.0083,1.1187)),rR=XS(Y(.6274,.0691,.0164),Y(.3293,.9195,.088),Y(.0433,.0113,.8956)),iR=W(([e])=>{let t=Y(e).toVar(),n=Y(t.mul(t)).toVar(),r=Y(n.mul(n)).toVar();return G(15.5).mul(r.mul(n)).sub(ew(40.14,r.mul(t))).add(ew(31.96,r).sub(ew(6.868,n.mul(t))).add(ew(.4298,n).add(ew(.1191,t).sub(.00232))))}),aR=W(([e,t])=>{let n=Y(e).toVar(),r=XS(Y(.856627153315983,.137318972929847,.11189821299995),Y(.0951212405381588,.761241990602591,.0767994186031903),Y(.0482516061458583,.101439036467562,.811302368396859)),i=XS(Y(1.1271005818144368,-.1413297634984383,-.14132976349843826),Y(-.11060664309660323,1.157823702216272,-.11060664309660294),Y(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=G(-12.47393),o=G(4.026069);return n.mulAssign(t),n.assign(rR.mul(n)),n.assign(r.mul(n)),n.assign(dT(n,1e-10)),n.assign(Lw(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(ET(n,0,1)),n.assign(iR(n)),n.assign(i.mul(n)),n.assign(vT(dT(Y(0),n),Y(2.2))),n.assign(nR.mul(n)),n.assign(ET(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),oR=W(([e,t])=>{let n=G(.76),r=G(.15);e=e.mul(t);let i=uT(e.r,uT(e.g,e.b)),a=LT(i.lessThan(.08),i.sub(ew(6.25,i.mul(i))),.04);e.subAssign(a);let o=dT(e.r,dT(e.g,e.b));PS(o.lessThan(n),()=>e);let s=$C(1,n),c=$C(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=$C(1,tw(1,r.mul(o.sub(c)).add(1)));return TT(e,Y(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),sR=class extends Mx{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},cR=kS(sR).setParameterLength(1,3),lR=(e,t)=>cR(e,t,`js`),uR=(e,t)=>cR(e,t,`wgsl`),dR=(e,t)=>cR(e,t,`glsl`),fR=class extends sR{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+`
|
|
37
|
+
`,t===`property`?o:e.format(`${o}()`,i,t)}},pR=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=new fR(e,t,n),i=(...e)=>r.call(...e);return i.functionNode=r,i},mR=(e,t)=>pR(e,t,`glsl`),hR=(e,t)=>pR(e,t,`wgsl`);function gR(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||SO.z).negate()}var _R=W(([e,t],n)=>kT(e,t,gR(n))),vR=W(([e],t)=>{let n=gR(t);return e.mul(e,n,n).negate().exp().oneMinus()}),yR=W(([e,t],n)=>{let r=gR(n),i=t.sub(bO.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),bR=W(([e,t])=>GS(t.toFloat().mix(DC.rgb,e.toVec3()),DC.a)),xR=null,SR=null,CR=kS(class extends Mx{static get type(){return`RangeNode`}constructor(e=G(),t=G()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(_x(t.value)),i=e.getTypeLength(_x(n.value));return r>i?r:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}getConstNode(e){let t=null;if(e.traverse(e=>{e.isConstNode===!0&&(t=e)}),t===null)throw new ZE(`THREE.TSL: No "ConstNode" found in node graph.`,this.stackTrace);return t}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),a=r.value,o=i.value,s=e.getTypeLength(_x(a)),c=e.getTypeLength(_x(o));xR||=new e_,SR||=new e_,xR.setScalar(0),SR.setScalar(0),s===1?xR.setScalar(a):a.isColor?xR.set(a.r,a.g,a.b,1):xR.set(a.x,a.y,a.z||0,a.w||0),c===1?SR.setScalar(o):o.isColor?SR.set(o.r,o.g,o.b,1):SR.set(o.x,o.y,o.z||0,o.w||0);let l=4*t.count,u=new Float32Array(l);for(let e=0;e<l;e++){let t=e%4,n=xR.getComponent(t),r=SR.getComponent(t);u[e]=Ng.lerp(n,r,Math.random())}let d=this.getNodeType(e);if(t.count*4*4<=e.getUniformBufferLimit())n=cD(u,`vec4`,t.count).element(AA).convert(d);else{let t=new gy(u,4);e.geometry.setAttribute(`__range`+this.id,t),n=SE(t).convert(d)}}else n=G(0);return n}}).setParameterLength(2),wR=class extends Mx{static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(R(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},TR=(e,t)=>new wR(e,t),ER=TR(`numWorkgroups`,`uvec3`),DR=TR(`workgroupId`,`uvec3`),OR=TR(`globalId`,`uvec3`),kR=TR(`localId`,`uvec3`),AR=TR(`subgroupSize`,`uint`),jR=kS(class extends Mx{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),MR=()=>jR(`workgroup`).toStack(),NR=()=>jR(`storage`).toStack(),PR=()=>jR(`texture`).toStack(),FR=class extends Nx{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},IR=class extends Mx{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=``}setName(e){return this.name=e,this}label(e){return R(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ax),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new FR(this,e)}generate(e){let t=this.name===``?`${this.scope}Array_${this.id}`:this.name;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},LR=(e,t)=>new IR(`Workgroup`,e,t),RR=class extends Mx{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=FE(l,i).toConst()),t.constNode.build(e)}};RR.ATOMIC_LOAD=`atomicLoad`,RR.ATOMIC_STORE=`atomicStore`,RR.ATOMIC_ADD=`atomicAdd`,RR.ATOMIC_SUB=`atomicSub`,RR.ATOMIC_MAX=`atomicMax`,RR.ATOMIC_MIN=`atomicMin`,RR.ATOMIC_AND=`atomicAnd`,RR.ATOMIC_OR=`atomicOr`,RR.ATOMIC_XOR=`atomicXor`;var zR=kS(RR),BR=(e,t,n)=>zR(e,t,n).toStack(),VR=e=>BR(RR.ATOMIC_LOAD,e,null),HR=(e,t)=>BR(RR.ATOMIC_STORE,e,t),UR=(e,t)=>BR(RR.ATOMIC_ADD,e,t),WR=(e,t)=>BR(RR.ATOMIC_SUB,e,t),GR=(e,t)=>BR(RR.ATOMIC_MAX,e,t),KR=(e,t)=>BR(RR.ATOMIC_MIN,e,t),qR=(e,t)=>BR(RR.ATOMIC_AND,e,t),JR=(e,t)=>BR(RR.ATOMIC_OR,e,t),YR=(e,t)=>BR(RR.ATOMIC_XOR,e,t),XR=class e extends Fx{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}getNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};XR.SUBGROUP_ELECT=`subgroupElect`,XR.SUBGROUP_BALLOT=`subgroupBallot`,XR.SUBGROUP_ADD=`subgroupAdd`,XR.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,XR.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,XR.SUBGROUP_MUL=`subgroupMul`,XR.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,XR.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,XR.SUBGROUP_AND=`subgroupAnd`,XR.SUBGROUP_OR=`subgroupOr`,XR.SUBGROUP_XOR=`subgroupXor`,XR.SUBGROUP_MIN=`subgroupMin`,XR.SUBGROUP_MAX=`subgroupMax`,XR.SUBGROUP_ALL=`subgroupAll`,XR.SUBGROUP_ANY=`subgroupAny`,XR.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,XR.QUAD_SWAP_X=`quadSwapX`,XR.QUAD_SWAP_Y=`quadSwapY`,XR.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,XR.SUBGROUP_BROADCAST=`subgroupBroadcast`,XR.SUBGROUP_SHUFFLE=`subgroupShuffle`,XR.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,XR.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,XR.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,XR.QUAD_BROADCAST=`quadBroadcast`;var ZR=U(XR,XR.SUBGROUP_ELECT).setParameterLength(0),QR=U(XR,XR.SUBGROUP_BALLOT).setParameterLength(1),$R=U(XR,XR.SUBGROUP_ADD).setParameterLength(1),ez=U(XR,XR.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),tz=U(XR,XR.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),nz=U(XR,XR.SUBGROUP_MUL).setParameterLength(1),rz=U(XR,XR.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),iz=U(XR,XR.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),az=U(XR,XR.SUBGROUP_AND).setParameterLength(1),oz=U(XR,XR.SUBGROUP_OR).setParameterLength(1),sz=U(XR,XR.SUBGROUP_XOR).setParameterLength(1),cz=U(XR,XR.SUBGROUP_MIN).setParameterLength(1),lz=U(XR,XR.SUBGROUP_MAX).setParameterLength(1),uz=U(XR,XR.SUBGROUP_ALL).setParameterLength(0),dz=U(XR,XR.SUBGROUP_ANY).setParameterLength(0),fz=U(XR,XR.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),pz=U(XR,XR.QUAD_SWAP_X).setParameterLength(1),mz=U(XR,XR.QUAD_SWAP_Y).setParameterLength(1),hz=U(XR,XR.QUAD_SWAP_DIAGONAL).setParameterLength(1),gz=U(XR,XR.SUBGROUP_BROADCAST).setParameterLength(2),_z=U(XR,XR.SUBGROUP_SHUFFLE).setParameterLength(2),vz=U(XR,XR.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),yz=U(XR,XR.SUBGROUP_SHUFFLE_UP).setParameterLength(2),bz=U(XR,XR.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),xz=U(XR,XR.QUAD_BROADCAST).setParameterLength(1),Sz;function Cz(e){Sz||=new WeakMap;let t=Sz.get(e);return t===void 0&&Sz.set(e,t={}),t}function wz(e){let t=Cz(e);return t.shadowMatrix||=WC(`mat4`).setGroup(VC).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix))}function Tz(e,t=bO){let n=wz(e).mul(t);return n.xyz.div(n.w)}function Ez(e){let t=Cz(e);return t.position||=WC(new B).setGroup(VC).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function Dz(e){let t=Cz(e);return t.targetPosition||=WC(new B).setGroup(VC).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function Oz(e){let t=Cz(e);return t.viewPosition||=WC(new B).setGroup(VC).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new B,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}var kz=e=>WD.transformDirection(Ez(e).sub(Dz(e))),Az=e=>e.sort((e,t)=>e.id-t.id),jz=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},Mz=new WeakMap,Nz=[],Pz=class extends Mx{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=aC(`vec3`,`totalDiffuse`),this.totalSpecularNode=aC(`vec3`,`totalSpecular`),this.outgoingLightNode=aC(`vec3`,`outgoingLight`),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(Nz.push(n.id),Nz.push(+!!n.castShadow),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;Nz.push(e,t)}}let t=cx(Nz);return Nz.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=Az(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(TS(e));else{let r=null;if(n!==null&&(r=jz(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){R(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;Mz.has(e)?r=Mz.get(e):(r=new n(e),Mz.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n,a.nodes=e.addStack().nodes,i.start(e);let{backdrop:s,backdropAlpha:c}=r,{directDiffuse:l,directSpecular:u,indirectDiffuse:d,indirectSpecular:f}=r.reflectedLight,p=l.add(d);s!==null&&(p=Y(c===null?s:c.mix(p,s))),t.assign(p),o.assign(u.add(f)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},Fz=(e=[])=>new Pz().setLights(e),Iz=class extends Mx{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=Cx.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){Lz.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||bO)}},Lz=aC(`vec3`,`shadowPositionWorld`);function Rz(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new R_),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function zz(e,t){return t=Rz(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Bz(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function Vz(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function Hz(e,t){return t=Vz(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Uz(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Wz(e,t,n){return n=zz(e,n),n=Hz(t,n),n}function Gz(e,t,n){Bz(e,n),Uz(t,n)}var Kz=new WeakMap,qz=W(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=tD(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),Jz=W(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=tD(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=tk(`mapSize`,`vec2`,n).setGroup(VC),o=tk(`radius`,`float`,n).setGroup(VC),s=J(1).div(a),c=o.mul(s.x),l=eL(yD.xy).mul(6.28318530718);return QC(i(t.xy.add(tL(0,5,l).mul(c)),t.z),i(t.xy.add(tL(1,5,l).mul(c)),t.z),i(t.xy.add(tL(2,5,l).mul(c)),t.z),i(t.xy.add(tL(3,5,l).mul(c)),t.z),i(t.xy.add(tL(4,5,l).mul(c)),t.z)).mul(1/5)}),Yz=W(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=tD(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=tk(`mapSize`,`vec2`,n).setGroup(VC),o=J(1).div(a),s=o.x,c=o.y,l=t.xy,u=Uw(l.mul(a).add(.5));return l.subAssign(u.mul(o)),QC(i(l,t.z),i(l.add(J(s,0)),t.z),i(l.add(J(0,c)),t.z),i(l.add(o),t.z),TT(i(l.add(J(s.negate(),0)),t.z),i(l.add(J(s.mul(2),0)),t.z),u.x),TT(i(l.add(J(s.negate(),c)),t.z),i(l.add(J(s.mul(2),c)),t.z),u.x),TT(i(l.add(J(0,c.negate())),t.z),i(l.add(J(0,c.mul(2))),t.z),u.y),TT(i(l.add(J(s,c.negate())),t.z),i(l.add(J(s,c.mul(2))),t.z),u.y),TT(TT(i(l.add(J(s.negate(),c.negate())),t.z),i(l.add(J(s.mul(2),c.negate())),t.z),u.x),TT(i(l.add(J(s.negate(),c.mul(2))),t.z),i(l.add(J(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),Xz=W(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=tD(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=dT(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?fT(a,t.z):fT(t.z,a),c=G(1).toVar();return PS(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=ET($C(n,.3).div(.65)),c.assign(dT(s,n))}),c}),Zz=e=>{let t=Kz.get(e);return t===void 0&&(t=new Bj,t.colorNode=GS(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,Kz.set(e,t)),t},Qz=e=>{let t=Kz.get(e);t!==void 0&&(t.dispose(),Kz.delete(e))},$z=new BP,eB=[],tB=(e,t,n,r)=>{eB[0]=e,eB[1]=t;let i=$z.get(eB);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(yx(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,$z.set(eB,i)),eB[0]=null,eB[1]=null,i},nB=W(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=G(0).toVar(`meanVertical`),o=G(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),c=e.lessThanEqual(G(1)).select(G(0),G(-1));return WA({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(G(e).mul(s)),u=r.sample(QC(yD.xy,J(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),J(a,Rw(o.sub(a.mul(a)).max(0)))}),rB=W(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=G(0).toVar(`meanHorizontal`),o=G(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(G(1)).select(G(0),G(2).div(e.sub(1))),c=e.lessThanEqual(G(1)).select(G(0),G(-1));return WA({start:K(0),end:K(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(G(e).mul(s)),u=r.sample(QC(yD.xy,J(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(QC(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),J(a,Rw(o.sub(a.mul(a)).max(0)))}),iB=[qz,Jz,Yz,Xz],aB,oB=new KI,sB=class extends Iz{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,G(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||tk(`bias`,`float`,n).setGroup(VC),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=tk(`near`,`float`,n.camera).setGroup(VC),r=tk(`far`,`float`,n.camera).setGroup(VC);o=_j(e.negate(),t,r)}return a=Y(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return iB[e]}setupRenderTarget(e,t){let n=new My(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Yh.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=gm,a.magFilter=gm):(a.minFilter=pm,a.magFilter=pm),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Bm,type:Dm,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Bm,type:Dm,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Bm,type:Dm,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Bm,type:Dm,depthBuffer:!1}));let t=tD(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=tD(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=tk(`blurSamples`,`float`,i).setGroup(VC),s=tk(`radius`,`float`,i).setGroup(VC),c=tk(`mapSize`,`vec2`,i).setGroup(VC),l=this.vsmMaterialVertical||=new Bj;l.fragmentNode=nB({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Bj,l.fragmentNode=rB({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=tk(`intensity`,`float`,i).setGroup(VC),u=tk(`normalBias`,`float`,i).setGroup(VC),d=wz(r).mul(Lz.add(NO.mul(u))),f=this.setupShadowCoord(e,d),p=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(p===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let m=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,h=this.setupShadowFilter(e,{filterFn:p,shadowTexture:o.texture,depthTexture:m,shadowCoord:f,shadow:i,depthLayer:this.depthLayer}),g;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?g=ZO(o.texture,f.xyz):(g=tD(o.texture,f),a.isArrayTexture&&(g=g.depth(this.depthLayer))));let _;_=g?TT(1,h.rgb.mix(g,1),l.mul(g.a)).toVar():TT(1,h,l).toVar(),this.shadowMap=o,this.shadow.map=o;let v=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return g&&_.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?ZO(this.shadowMap.texture):tD(this.shadowMap.texture)),_.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?ZO(this.shadowMap.texture).r.oneMinus():rD(this.shadowMap.depthTexture,JE().mul(YE(tD(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return W(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type;this._depthVersionCached=t.depthTexture.version;let c=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let l=i.getRenderObjectFunction(),u=i.getMRT(),d=u?u.has(`velocity`):!1;aB=Wz(i,a,aB),a.overrideMaterial=Zz(n),i.setRenderObjectFunction(tB(i,r,s,d)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(l),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=c,Gz(i,a,aB)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),oB.material=this.vsmMaterialVertical,oB.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),oB.material=this.vsmMaterialHorizontal,oB.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,Qz(this.light),this.shadowMap&&=(this.shadowMap.dispose(),null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},cB=(e,t)=>new sB(e,t),lB=new R_,uB=new r_,dB=new B,fB=new B,pB=[new B(1,0,0),new B(-1,0,0),new B(0,-1,0),new B(0,1,0),new B(0,0,1),new B(0,0,-1)],mB=[new B(0,-1,0),new B(0,-1,0),new B(0,0,-1),new B(0,0,1),new B(0,-1,0),new B(0,-1,0)],hB=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],gB=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],_B=W(({depthTexture:e,bd3D:t,dp:n})=>ZO(e,t).compare(n)),vB=W(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=tk(`radius`,`float`,r).setGroup(VC),a=tk(`mapSize`,`vec2`,r).setGroup(VC),o=i.div(a.x),s=Xw(t),c=Hw(_T(t,s.x.greaterThan(s.z).select(Y(0,1,0),Y(1,0,0)))),l=_T(t,c),u=eL(yD.xy).mul(6.28318530718),d=tL(0,5,u),f=tL(1,5,u),p=tL(2,5,u),m=tL(3,5,u),h=tL(4,5,u);return ZO(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(ZO(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(ZO(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(ZO(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(ZO(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),yB=W(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=WC(`float`).setGroup(VC).onRenderUpdate(()=>r.camera.near),l=WC(`float`).setGroup(VC).onRenderUpdate(()=>r.camera.far),u=tk(`bias`,`float`,r).setGroup(VC),d=G(1).toVar();return PS(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=hj(s.negate(),c,l),n.subAssign(u)):(n=mj(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),bB=class extends sB{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?_B:vB}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return yB({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new Ny(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===qh,l=c?pB:hB,u=c?mB:gB;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(lB),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),dB.setFromMatrixPosition(r.matrixWorld),o.position.copy(dB),fB.copy(o.position),fB.add(l[e]),o.up.copy(u[e]),o.lookAt(fB),o.updateMatrixWorld(),s.makeTranslation(-dB.x,-dB.y,-dB.z),uB.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(uB,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},xB=(e,t)=>new bB(e,t),SB=class extends QA{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new R_,this.colorNode=e&&e.colorNode||WC(this.color).setGroup(VC),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Cx.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener(`dispose`,this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener(`dispose`,this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return Oz(this.light).sub(e.context.positionView||SO)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return cB(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():TS(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}},CB=W(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),wB=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=CB({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},TB=class extends SB{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=WC(0).setGroup(VC),this.decayExponentNode=WC(2).setGroup(VC)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return xB(this.light)}setupDirect(e){return wB({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}},EB=W(([e=JE()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor();return n.add(r).mod(2).sign()}),DB=W(([e=JE()],{renderer:t,material:n})=>{let r=wT(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=G(r.fwidth()).toVar();i=kT(e.oneMinus(),e.add(1),r).oneMinus()}else i=LT(r.greaterThan(1),0,1);return i}),OB=W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar();return LT(RS(e).toVar(),i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),kB=W(([e,t])=>{let n=RS(t).toVar(),r=G(e).toVar();return LT(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),AB=W(([e])=>K(Bw(G(e).toVar()))).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),jB=W(([e,t])=>{let n=G(e).toVar();return t.assign(AB(n)),n.sub(G(t))}),MB=dI([W(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=G(r).toVar(),l=G(n).toVar(),u=G(t).toVar(),d=G(e).toVar(),f=G($C(1,s)).toVar();return $C(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),W(([e,t,n,r,i,a])=>{let o=G(a).toVar(),s=G(i).toVar(),c=Y(r).toVar(),l=Y(n).toVar(),u=Y(t).toVar(),d=Y(e).toVar(),f=G($C(1,s)).toVar();return $C(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]})]),NB=dI([W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=G(s).toVar(),h=G(o).toVar(),g=G(a).toVar(),_=G(i).toVar(),v=G(r).toVar(),y=G(n).toVar(),b=G(t).toVar(),x=G(e).toVar(),S=G($C(1,p)).toVar(),C=G($C(1,f)).toVar();return G($C(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=G(u).toVar(),f=G(l).toVar(),p=G(c).toVar(),m=Y(s).toVar(),h=Y(o).toVar(),g=Y(a).toVar(),_=Y(i).toVar(),v=Y(r).toVar(),y=Y(n).toVar(),b=Y(t).toVar(),x=Y(e).toVar(),S=G($C(1,p)).toVar(),C=G($C(1,f)).toVar();return G($C(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]})]),PB=dI([W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=q(q(e).toVar().bitAnd(q(7))).toVar(),o=G(OB(a.lessThan(q(4)),i,r)).toVar(),s=G(ew(2,OB(a.lessThan(q(4)),r,i))).toVar();return kB(o,RS(a.bitAnd(q(1)))).add(kB(s,RS(a.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=q(q(e).toVar().bitAnd(q(15))).toVar(),c=G(OB(s.lessThan(q(8)),o,a)).toVar(),l=G(OB(s.lessThan(q(4)),a,OB(s.equal(q(12)).or(s.equal(q(14))),o,i))).toVar();return kB(c,RS(s.bitAnd(q(1)))).add(kB(l,RS(s.bitAnd(q(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),FB=dI([W(([e,t,n])=>{let r=G(n).toVar(),i=G(t).toVar(),a=US(e).toVar();return Y(PB(a.x,i,r),PB(a.y,i,r),PB(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=G(t).toVar(),s=US(e).toVar();return Y(PB(s.x,o,a,i),PB(s.y,o,a,i),PB(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),IB=W(([e])=>ew(.6616,G(e).toVar())).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),LB=W(([e])=>ew(.982,G(e).toVar())).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),RB=dI([IB,W(([e])=>ew(.6616,Y(e).toVar())).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),zB=dI([LB,W(([e])=>ew(.982,Y(e).toVar())).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),BB=W(([e,t])=>{let n=K(t).toVar(),r=q(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(K(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),VB=W(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(BB(n,K(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(BB(e,K(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(BB(t,K(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(BB(n,K(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(BB(e,K(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(BB(t,K(4))),t.addAssign(e)}),HB=W(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=q(e).toVar();return r.bitXorAssign(i),r.subAssign(BB(i,K(14))),a.bitXorAssign(r),a.subAssign(BB(r,K(11))),i.bitXorAssign(a),i.subAssign(BB(a,K(25))),r.bitXorAssign(i),r.subAssign(BB(i,K(16))),a.bitXorAssign(r),a.subAssign(BB(r,K(4))),i.bitXorAssign(a),i.subAssign(BB(a,K(14))),r.bitXorAssign(i),r.subAssign(BB(i,K(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),UB=W(([e])=>G(q(e).toVar()).div(G(q(K(4294967295))))).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),WB=W(([e])=>{let t=G(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),GB=dI([W(([e])=>{let t=K(e).toVar(),n=q(q(1)).toVar(),r=q(q(K(3735928559)).add(n.shiftLeft(q(2))).add(q(13))).toVar();return HB(r.add(q(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),W(([e,t])=>{let n=K(t).toVar(),r=K(e).toVar(),i=q(q(2)).toVar(),a=q().toVar(),o=q().toVar(),s=q().toVar();return a.assign(o.assign(s.assign(q(K(3735928559)).add(i.shiftLeft(q(2))).add(q(13))))),a.addAssign(q(r)),o.addAssign(q(n)),HB(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),W(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=K(e).toVar(),o=q(q(3)).toVar(),s=q().toVar(),c=q().toVar(),l=q().toVar();return s.assign(c.assign(l.assign(q(K(3735928559)).add(o.shiftLeft(q(2))).add(q(13))))),s.addAssign(q(a)),c.addAssign(q(i)),l.addAssign(q(r)),HB(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),W(([e,t,n,r])=>{let i=K(r).toVar(),a=K(n).toVar(),o=K(t).toVar(),s=K(e).toVar(),c=q(q(4)).toVar(),l=q().toVar(),u=q().toVar(),d=q().toVar();return l.assign(u.assign(d.assign(q(K(3735928559)).add(c.shiftLeft(q(2))).add(q(13))))),l.addAssign(q(s)),u.addAssign(q(o)),d.addAssign(q(a)),VB(l,u,d),l.addAssign(q(i)),HB(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),W(([e,t,n,r,i])=>{let a=K(i).toVar(),o=K(r).toVar(),s=K(n).toVar(),c=K(t).toVar(),l=K(e).toVar(),u=q(q(5)).toVar(),d=q().toVar(),f=q().toVar(),p=q().toVar();return d.assign(f.assign(p.assign(q(K(3735928559)).add(u.shiftLeft(q(2))).add(q(13))))),d.addAssign(q(l)),f.addAssign(q(c)),p.addAssign(q(s)),VB(d,f,p),d.addAssign(q(o)),f.addAssign(q(a)),HB(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]})]),KB=dI([W(([e,t])=>{let n=K(t).toVar(),r=q(GB(K(e).toVar(),n)).toVar(),i=US().toVar();return i.x.assign(r.bitAnd(K(255))),i.y.assign(r.shiftRight(K(8)).bitAnd(K(255))),i.z.assign(r.shiftRight(K(16)).bitAnd(K(255))),i}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),W(([e,t,n])=>{let r=K(n).toVar(),i=K(t).toVar(),a=q(GB(K(e).toVar(),i,r)).toVar(),o=US().toVar();return o.x.assign(a.bitAnd(K(255))),o.y.assign(a.shiftRight(K(8)).bitAnd(K(255))),o.z.assign(a.shiftRight(K(16)).bitAnd(K(255))),o}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]})]),qB=dI([W(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(jB(t.x,n)).toVar(),a=G(jB(t.y,r)).toVar(),o=G(WB(i)).toVar(),s=G(WB(a)).toVar();return RB(G(MB(PB(GB(n,r),i,a),PB(GB(n.add(K(1)),r),i.sub(1),a),PB(GB(n,r.add(K(1))),i,a.sub(1)),PB(GB(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=Y(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(jB(t.x,n)).toVar(),o=G(jB(t.y,r)).toVar(),s=G(jB(t.z,i)).toVar(),c=G(WB(a)).toVar(),l=G(WB(o)).toVar(),u=G(WB(s)).toVar();return zB(G(NB(PB(GB(n,r,i),a,o,s),PB(GB(n.add(K(1)),r,i),a.sub(1),o,s),PB(GB(n,r.add(K(1)),i),a,o.sub(1),s),PB(GB(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),PB(GB(n,r,i.add(K(1))),a,o,s.sub(1)),PB(GB(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),PB(GB(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),PB(GB(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]})]),JB=dI([W(([e])=>{let t=J(e).toVar(),n=K().toVar(),r=K().toVar(),i=G(jB(t.x,n)).toVar(),a=G(jB(t.y,r)).toVar(),o=G(WB(i)).toVar(),s=G(WB(a)).toVar();return RB(Y(MB(FB(KB(n,r),i,a),FB(KB(n.add(K(1)),r),i.sub(1),a),FB(KB(n,r.add(K(1))),i,a.sub(1)),FB(KB(n.add(K(1)),r.add(K(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=Y(e).toVar(),n=K().toVar(),r=K().toVar(),i=K().toVar(),a=G(jB(t.x,n)).toVar(),o=G(jB(t.y,r)).toVar(),s=G(jB(t.z,i)).toVar(),c=G(WB(a)).toVar(),l=G(WB(o)).toVar(),u=G(WB(s)).toVar();return zB(Y(NB(FB(KB(n,r,i),a,o,s),FB(KB(n.add(K(1)),r,i),a.sub(1),o,s),FB(KB(n,r.add(K(1)),i),a,o.sub(1),s),FB(KB(n.add(K(1)),r.add(K(1)),i),a.sub(1),o.sub(1),s),FB(KB(n,r,i.add(K(1))),a,o,s.sub(1)),FB(KB(n.add(K(1)),r,i.add(K(1))),a.sub(1),o,s.sub(1)),FB(KB(n,r.add(K(1)),i.add(K(1))),a,o.sub(1),s.sub(1)),FB(KB(n.add(K(1)),r.add(K(1)),i.add(K(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]})]),YB=dI([W(([e])=>UB(GB(K(AB(G(e).toVar())).toVar()))).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),W(([e])=>{let t=J(e).toVar();return UB(GB(K(AB(t.x)).toVar(),K(AB(t.y)).toVar()))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=Y(e).toVar();return UB(GB(K(AB(t.x)).toVar(),K(AB(t.y)).toVar(),K(AB(t.z)).toVar()))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),W(([e])=>{let t=GS(e).toVar();return UB(GB(K(AB(t.x)).toVar(),K(AB(t.y)).toVar(),K(AB(t.z)).toVar(),K(AB(t.w)).toVar()))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]})]),XB=dI([W(([e])=>{let t=K(AB(G(e).toVar())).toVar();return Y(UB(GB(t,K(0))),UB(GB(t,K(1))),UB(GB(t,K(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),W(([e])=>{let t=J(e).toVar(),n=K(AB(t.x)).toVar(),r=K(AB(t.y)).toVar();return Y(UB(GB(n,r,K(0))),UB(GB(n,r,K(1))),UB(GB(n,r,K(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),W(([e])=>{let t=Y(e).toVar(),n=K(AB(t.x)).toVar(),r=K(AB(t.y)).toVar(),i=K(AB(t.z)).toVar();return Y(UB(GB(n,r,i,K(0))),UB(GB(n,r,i,K(1))),UB(GB(n,r,i,K(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),W(([e])=>{let t=GS(e).toVar(),n=K(AB(t.x)).toVar(),r=K(AB(t.y)).toVar(),i=K(AB(t.z)).toVar(),a=K(AB(t.w)).toVar();return Y(UB(GB(n,r,i,a,K(0))),UB(GB(n,r,i,a,K(1))),UB(GB(n,r,i,a,K(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]})]),ZB=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar(),c=G(0).toVar(),l=G(1).toVar();return WA(o,()=>{c.addAssign(l.mul(qB(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),QB=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar(),c=Y(0).toVar(),l=G(1).toVar();return WA(o,()=>{c.addAssign(l.mul(JB(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),$B=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar();return J(ZB(s,o,a,i),ZB(s.add(Y(K(19),K(193),K(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),eV=W(([e,t,n,r])=>{let i=G(r).toVar(),a=G(n).toVar(),o=K(t).toVar(),s=Y(e).toVar();return GS(Y(QB(s,o,a,i)).toVar(),G(ZB(s.add(Y(K(19),K(193),K(17))),o,a,i)).toVar())}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),tV=dI([W(([e,t,n,r,i,a,o])=>{let s=K(o).toVar(),c=G(a).toVar(),l=K(i).toVar(),u=K(r).toVar(),d=K(n).toVar(),f=K(t).toVar(),p=J(e).toVar(),m=Y(XB(J(f.add(u),d.add(l)))).toVar(),h=J(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=J(J(J(G(f),G(d)).add(h)).toVar().sub(p)).toVar();return PS(s.equal(K(2)),()=>Xw(g.x).add(Xw(g.y))),PS(s.equal(K(3)),()=>dT(Xw(g.x),Xw(g.y))),gT(g,g)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),W(([e,t,n,r,i,a,o,s,c])=>{let l=K(c).toVar(),u=G(s).toVar(),d=K(o).toVar(),f=K(a).toVar(),p=K(i).toVar(),m=K(r).toVar(),h=K(n).toVar(),g=K(t).toVar(),_=Y(e).toVar(),v=Y(XB(Y(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=Y(Y(Y(G(g),G(h),G(m)).add(v)).toVar().sub(_)).toVar();return PS(l.equal(K(2)),()=>Xw(y.x).add(Xw(y.y)).add(Xw(y.z))),PS(l.equal(K(3)),()=>dT(Xw(y.x),Xw(y.y),Xw(y.z))),gT(y,y)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),nV=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(jB(a.x,o),jB(a.y,s)).toVar(),l=G(1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(tV(c,e,t,o,s,i,r)).toVar();l.assign(uT(l,n))})}),PS(r.equal(K(0)),()=>{l.assign(Rw(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),rV=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(jB(a.x,o),jB(a.y,s)).toVar(),l=J(1e6,1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(tV(c,e,t,o,s,i,r)).toVar();PS(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),PS(r.equal(K(0)),()=>{l.assign(Rw(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),iV=W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=J(e).toVar(),o=K().toVar(),s=K().toVar(),c=J(jB(a.x,o),jB(a.y,s)).toVar(),l=Y(1e6,1e6,1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{let n=G(tV(c,e,t,o,s,i,r)).toVar();PS(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),PS(r.equal(K(0)),()=>{l.assign(Rw(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),aV=dI([nV,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(jB(a.x,o),jB(a.y,s),jB(a.z,c)).toVar(),u=G(1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{WA({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(tV(l,e,t,n,o,s,c,i,r)).toVar();u.assign(uT(u,a))})})}),PS(r.equal(K(0)),()=>{u.assign(Rw(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),oV=dI([rV,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(jB(a.x,o),jB(a.y,s),jB(a.z,c)).toVar(),u=J(1e6,1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{WA({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(tV(l,e,t,n,o,s,c,i,r)).toVar();PS(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),PS(r.equal(K(0)),()=>{u.assign(Rw(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),sV=dI([iV,W(([e,t,n])=>{let r=K(n).toVar(),i=G(t).toVar(),a=Y(e).toVar(),o=K().toVar(),s=K().toVar(),c=K().toVar(),l=Y(jB(a.x,o),jB(a.y,s),jB(a.z,c)).toVar(),u=Y(1e6,1e6,1e6).toVar();return WA({start:-1,end:K(1),name:`x`,condition:`<=`},({x:e})=>{WA({start:-1,end:K(1),name:`y`,condition:`<=`},({y:t})=>{WA({start:-1,end:K(1),name:`z`,condition:`<=`},({z:n})=>{let a=G(tV(l,e,t,n,o,s,c,i,r)).toVar();PS(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),PS(r.equal(K(0)),()=>{u.assign(Rw(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),cV=W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(e).toVar(),f=J(t).toVar(),p=J(n).toVar(),m=J(r).toVar(),h=G(i).toVar(),g=G(a).toVar(),_=G(o).toVar(),v=RS(s).toVar(),y=K(c).toVar(),b=G(l).toVar(),x=G(u).toVar(),S=f.mul(p).add(m),C=G(0).toVar();return PS(d.equal(K(0)),()=>{C.assign(JB(S))}),PS(d.equal(K(1)),()=>{C.assign(XB(S))}),PS(d.equal(K(2)),()=>{C.assign(sV(S,h,K(0)))}),PS(d.equal(K(3)),()=>{C.assign(QB(Y(S,0),y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),PS(v,()=>{C.assign(ET(C,g,_))}),C}).setLayout({name:`mx_unifiednoise2d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`texcoord`,type:`vec2`},{name:`freq`,type:`vec2`},{name:`offset`,type:`vec2`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),lV=W(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=K(e).toVar(),f=Y(t).toVar(),p=Y(n).toVar(),m=Y(r).toVar(),h=G(i).toVar(),g=G(a).toVar(),_=G(o).toVar(),v=RS(s).toVar(),y=K(c).toVar(),b=G(l).toVar(),x=G(u).toVar(),S=f.mul(p).add(m),C=G(0).toVar();return PS(d.equal(K(0)),()=>{C.assign(JB(S))}),PS(d.equal(K(1)),()=>{C.assign(XB(S))}),PS(d.equal(K(2)),()=>{C.assign(sV(S,h,K(0)))}),PS(d.equal(K(3)),()=>{C.assign(QB(S,y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),PS(v,()=>{C.assign(ET(C,g,_))}),C}).setLayout({name:`mx_unifiednoise3d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`position`,type:`vec3`},{name:`freq`,type:`vec3`},{name:`offset`,type:`vec3`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),uV=W(([e])=>{let t=e.y,n=e.z,r=Y().toVar();return PS(t.lessThan(1e-4),()=>{r.assign(Y(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Bw(i)).mul(6).toVar();let a=K(aT(i)),o=i.sub(G(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());PS(a.equal(K(0)),()=>{r.assign(Y(n,l,s))}).ElseIf(a.equal(K(1)),()=>{r.assign(Y(c,n,s))}).ElseIf(a.equal(K(2)),()=>{r.assign(Y(s,n,l))}).ElseIf(a.equal(K(3)),()=>{r.assign(Y(s,c,n))}).ElseIf(a.equal(K(4)),()=>{r.assign(Y(l,s,n))}).Else(()=>{r.assign(Y(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),dV=W(([e])=>{let t=Y(e).toVar(),n=G(t.x).toVar(),r=G(t.y).toVar(),i=G(t.z).toVar(),a=G(uT(n,uT(r,i))).toVar(),o=G(dT(n,dT(r,i))).toVar(),s=G(o.sub(a)).toVar(),c=G().toVar(),l=G().toVar(),u=G().toVar();return u.assign(o),PS(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),PS(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{PS(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(QC(2,i.sub(n).div(s)))}).Else(()=>{c.assign(QC(4,n.sub(r).div(s)))}),c.mulAssign(1/6),PS(c.lessThan(0),()=>{c.addAssign(1)})}),Y(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),fV=W(([e])=>{let t=Y(e).toVar(),n=WS(ow(t,Y(.04045))).toVar();return TT(Y(t.div(12.92)).toVar(),Y(vT(dT(t.add(Y(.055)),Y(0)).div(1.055),Y(2.4))).toVar(),n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),pV=(e,t)=>{e=G(e),t=G(t);let n=J(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return kT(e.sub(n),e.add(n),t)},mV=(e,t,n,r)=>TT(e,t,n[r].clamp()),hV=(e,t,n=JE())=>mV(e,t,n,`x`),gV=(e,t,n=JE())=>mV(e,t,n,`y`),_V=(e,t,n,r,i=JE())=>{let a=i.x.clamp(),o=i.y.clamp();return TT(TT(e,t,a),TT(n,r,a),o)},vV=(e,t,n,r,i)=>TT(e,t,pV(n,r[i])),yV=(e,t,n,r=JE())=>vV(e,t,n,r,`x`),bV=(e,t,n,r=JE())=>vV(e,t,n,r,`y`),xV=(e=1,t=0,n=JE())=>n.mul(e).add(t),SV=(e,t=1)=>(e=G(e),e.abs().pow(t).mul(e.sign())),CV=(e,t=1,n=.5)=>G(e).sub(n).mul(t).add(n),wV=(e=JE(),t=1,n=0)=>qB(e.convert(`vec2|vec3`)).mul(t).add(n),TV=(e=JE(),t=1,n=0)=>JB(e.convert(`vec2|vec3`)).mul(t).add(n),EV=(e=JE(),t=1,n=0)=>(e=e.convert(`vec2|vec3`),GS(JB(e),qB(e.add(J(19,73)))).mul(t).add(n)),DV=(e,t=JE(),n=J(1,1),r=J(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>cV(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),OV=(e,t=JE(),n=J(1,1),r=J(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>lV(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),kV=(e=JE(),t=1)=>aV(e.convert(`vec2|vec3`),t,K(1)),AV=(e=JE(),t=1)=>oV(e.convert(`vec2|vec3`),t,K(1)),jV=(e=JE(),t=1)=>sV(e.convert(`vec2|vec3`),t,K(1)),MV=(e=JE())=>YB(e.convert(`vec2|vec3`)),NV=(e=JE(),t=3,n=2,r=.5,i=1)=>ZB(e,K(t),n,r).mul(i),PV=(e=JE(),t=3,n=2,r=.5,i=1)=>$B(e,K(t),n,r).mul(i),FV=(e=JE(),t=3,n=2,r=.5,i=1)=>QB(e,K(t),n,r).mul(i),IV=(e=JE(),t=3,n=2,r=.5,i=1)=>eV(e,K(t),n,r).mul(i),LV=(e,t=G(0))=>QC(e,t),RV=(e,t=G(0))=>$C(e,t),zV=(e,t=G(1))=>ew(e,t),BV=(e,t=G(1))=>tw(e,t),VV=(e,t=G(1))=>nw(e,t),HV=(e,t=G(1))=>vT(e,t),UV=(e=G(0),t=G(1))=>Yw(e,t),WV=()=>fI,GV=()=>mI,KV=(e,t=G(1))=>$C(t,e),qV=(e,t,n,r)=>e.greaterThan(t).mix(n,r),JV=(e,t,n,r)=>e.greaterThanEqual(t).mix(n,r),YV=(e,t,n,r)=>e.equal(t).mix(n,r),XV=(e,t=null)=>{if(typeof t==`string`){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,``).toLowerCase();if(n[r]!==void 0)return e.element(n[r])}if(typeof t==`number`)return e.element(t);if(typeof t==`string`&&t.length===1){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(n[t]!==void 0)return e.element(n[t])}return e},ZV=(e,t=J(.5,.5),n=J(1,1),r=G(0),i=J(0,0))=>{let a=e;if(t&&(a=a.sub(t)),n&&(a=a.mul(n)),r){let e=r.mul(Math.PI/180),t=e.cos(),n=e.sin();a=J(a.x.mul(t).sub(a.y.mul(n)),a.x.mul(n).add(a.y.mul(t)))}return t&&(a=a.add(t)),i&&(a=a.add(i)),a},QV=(e,t)=>{e=J(e),t=G(t);let n=t.mul(Math.PI/180);return kP(e,n)},$V=(e,t,n)=>{e=Y(e),t=G(t),n=Y(n);let r=t.mul(Math.PI/180),i=n.normalize(),a=r.cos(),o=r.sin(),s=G(1).sub(a);return e.mul(a).add(i.cross(e).mul(o)).add(i.mul(i.dot(e)).mul(s))},eH=(e,t)=>(e=Y(e),t=G(t),Rk(e,t)),tH=W(([e,t,n])=>{let r=Hw(e).toVar(),i=$C(G(.5).mul(t.sub(n)),bO).div(r).toVar(),a=$C(G(-.5).mul(t.sub(n)),bO).div(r).toVar(),o=Y().toVar();o.x=r.x.greaterThan(G(0)).select(i.x,a.x),o.y=r.y.greaterThan(G(0)).select(i.y,a.y),o.z=r.z.greaterThan(G(0)).select(i.z,a.z);let s=uT(o.x,o.y,o.z).toVar();return bO.add(r.mul(s)).toVar().sub(n)}),nH=W(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(ew(n,n).sub(ew(r,r)))),a}),Q=Object.freeze({__proto__:null,BRDF_GGX:wM,BRDF_Lambert:cM,BasicPointShadowFilter:_B,BasicShadowFilter:qz,Break:KA,Const:JT,Continue:GA,DFGLUT:DM,D_GGX:xM,Discard:IE,EPSILON:ww,F_Schlick:sM,Fn:W,HALF_PI:kw,INFINITY:Tw,If:PS,Loop:WA,NodeAccess:Tx,NodeShaderStage:Sx,NodeType:wx,NodeUpdateType:Cx,OnBeforeMaterialUpdate:lL,OnBeforeObjectUpdate:cL,OnMaterialUpdate:sL,OnObjectUpdate:oL,PCFShadowFilter:Jz,PCFSoftShadowFilter:Yz,PI:Ew,PI2:Dw,PointShadowFilter:vB,Return:LE,Schlick_to_F0:AM,ShaderNode:wS,Stack:IS,Switch:FS,TBNViewMatrix:Ok,TWO_PI:Ow,VSMShadowFilter:Xz,V_GGX_SmithCorrelated:yM,Var:qT,VarIntent:YT,abs:Xw,acesFilmicToneMapping:tR,acos:Jw,add:QC,addMethodChaining:V,addNodeElement:GE,agxToneMapping:aR,all:Aw,alphaT:yC,and:lw,anisotropy:bC,anisotropyB:SC,anisotropyT:xC,any:jw,append:rC,array:KC,arrayBuffer:$S,asin:qw,assign:qC,atan:Yw,atomicAdd:UR,atomicAnd:qR,atomicFunc:BR,atomicLoad:VR,atomicMax:GR,atomicMin:KR,atomicOr:JR,atomicStore:HR,atomicSub:WR,atomicXor:YR,attenuationColor:FC,attenuationDistance:PC,attribute:qE,attributeArray:fL,backgroundBlurriness:_L,backgroundIntensity:vL,backgroundRotation:yL,batch:RA,bentNormalView:jk,billboarding:SI,bitAnd:pw,bitNot:mw,bitOr:hw,bitXor:gw,bitangentGeometry:wk,bitangentLocal:Tk,bitangentView:Ek,bitangentWorld:Dk,bitcast:RF,blendBurn:Nj,blendColor:Lj,blendDodge:Pj,blendOverlay:Ij,blendScreen:Fj,blur:jN,bool:RS,buffer:cD,bufferAttribute:bE,builtin:fD,builtinAOContext:UT,builtinShadowContext:HT,bumpMap:Rk,bvec2:VS,bvec3:WS,bvec4:JS,bypass:AE,cache:kE,call:YC,cameraFar:VD,cameraIndex:zD,cameraNear:BD,cameraNormalMatrix:KD,cameraPosition:qD,cameraProjectionMatrix:HD,cameraProjectionMatrixInverse:UD,cameraViewMatrix:WD,cameraViewport:JD,cameraWorldMatrix:GD,cbrt:CT,cdl:RL,ceil:Vw,checker:EB,cineonToneMapping:$L,clamp:ET,clearcoat:fC,clearcoatNormalView:PO,clearcoatRoughness:pC,clipSpace:gO,code:cR,color:LS,colorSpaceToWorking:oE,colorToDirection:Nk,compute:EE,computeKernel:TE,computeSkinning:HA,context:zT,convert:tC,convertColorSpace:sE,convertToTexture:XI,cos:Gw,countLeadingZeros:KF,countOneBits:qF,countTrailingZeros:GF,cross:_T,cubeTexture:ZO,cubeTextureBase:XO,dFdx:tT,dFdy:nT,dashSize:OC,debug:VE,decrement:Sw,decrementBefore:bw,defaultBuildStages:Dx,defaultShaderStages:Ex,defined:SS,degrees:Nw,deltaTime:pI,densityFogFactor:vR,depth:bj,depthPass:JL,determinant:cT,difference:hT,diffuseColor:sC,diffuseContribution:cC,directPointLight:wB,directionToColor:Mk,directionToFaceDirection:EO,dispersion:IC,disposeShadowMaterial:Qz,distance:mT,div:tw,dot:gT,drawIndex:PA,dynamicBufferAttribute:xE,element:eC,emissive:lC,equal:rw,equirectUV:qj,exp:Pw,exp2:Fw,exponentialHeightFogFactor:yR,expression:FE,faceDirection:TO,faceForward:AT,faceforward:FT,float:G,floatBitsToInt:zF,floatBitsToUint:BF,floor:Bw,fog:bR,fract:Uw,frameGroup:BC,frameId:mI,frontFacing:wO,fwidth:oT,gain:XF,gapSize:kC,getConstNodeType:CS,getCurrentStack:NS,getDirection:DN,getDistanceAttenuation:CB,getGeometryRoughness:_M,getNormalFromDepth:$I,getParallaxCorrectNormal:tH,getRoughness:vM,getScreenPosition:QI,getShIrradianceAt:nH,getShadowMaterial:Zz,getShadowRenderObjectFunction:tB,getTextureIndex:FF,getViewPosition:ZI,ggxConvolution:FN,globalId:OR,glsl:dR,glslFn:mR,grayscale:NL,greaterThan:ow,greaterThanEqual:cw,hash:JF,highpModelNormalViewMatrix:hO,highpModelViewMatrix:mO,hue:IL,increment:xw,incrementBefore:yw,inspector:WE,instance:IA,instanceIndex:AA,instancedArray:pL,instancedBufferAttribute:SE,instancedDynamicBufferAttribute:CE,instancedMesh:LA,int:K,intBitsToFloat:VF,interleavedGradientNoise:eL,inverse:lT,inverseSqrt:zw,inversesqrt:IT,invocationLocalIndex:NA,invocationSubgroupIndex:MA,ior:jC,iridescence:gC,iridescenceIOR:_C,iridescenceThickness:vC,isolate:OE,ivec2:zS,ivec3:HS,ivec4:KS,js:lR,label:WT,length:Qw,lengthSq:wT,lessThan:aw,lessThanEqual:sw,lightPosition:Ez,lightProjectionUV:Tz,lightShadowMatrix:wz,lightTargetDirection:kz,lightTargetPosition:Dz,lightViewPosition:Oz,lightingContext:ej,lights:Fz,linearDepth:xj,linearToneMapping:ZL,localId:kR,log:Iw,log2:Lw,logarithmicDepthToViewZ:vj,luminance:LL,mat2:YS,mat3:XS,mat4:ZS,matcapUV:EP,materialAO:SA,materialAlphaTest:Bk,materialAnisotropy:aA,materialAnisotropyVector:CA,materialAttenuationColor:pA,materialAttenuationDistance:fA,materialClearcoat:$k,materialClearcoatNormal:tA,materialClearcoatRoughness:eA,materialColor:Vk,materialDispersion:bA,materialEmissive:Uk,materialEnvIntensity:UO,materialEnvRotation:WO,materialIOR:dA,materialIridescence:oA,materialIridescenceIOR:sA,materialIridescenceThickness:cA,materialLightMap:xA,materialLineDashOffset:vA,materialLineDashSize:hA,materialLineGapSize:gA,materialLineScale:mA,materialLineWidth:_A,materialMetalness:Zk,materialNormal:Qk,materialOpacity:Wk,materialPointSize:yA,materialReference:ik,materialReflectivity:Yk,materialRefractionRatio:HO,materialRotation:nA,materialRoughness:Xk,materialSheen:rA,materialSheenRoughness:iA,materialShininess:Hk,materialSpecular:Gk,materialSpecularColor:qk,materialSpecularIntensity:Kk,materialSpecularStrength:Jk,materialThickness:uA,materialTransmission:lA,max:dT,maxMipLevel:XE,mediumpModelViewMatrix:pO,metalness:dC,min:uT,mix:TT,mixElement:MT,mod:nw,modInt:Cw,modelDirection:iO,modelNormalMatrix:uO,modelPosition:oO,modelRadius:lO,modelScale:sO,modelViewMatrix:fO,modelViewPosition:cO,modelViewProjection:wA,modelWorldMatrix:aO,modelWorldMatrixInverse:dO,morphReference:ZA,mrt:IF,mul:ew,mx_aastep:pV,mx_add:LV,mx_atan2:UV,mx_cell_noise_float:MV,mx_contrast:CV,mx_divide:BV,mx_fractal_noise_float:NV,mx_fractal_noise_vec2:PV,mx_fractal_noise_vec3:FV,mx_fractal_noise_vec4:IV,mx_frame:GV,mx_heighttonormal:eH,mx_hsvtorgb:uV,mx_ifequal:YV,mx_ifgreater:qV,mx_ifgreatereq:JV,mx_invert:KV,mx_modulo:VV,mx_multiply:zV,mx_noise_float:wV,mx_noise_vec3:TV,mx_noise_vec4:EV,mx_place2d:ZV,mx_power:HV,mx_ramp4:_V,mx_ramplr:hV,mx_ramptb:gV,mx_rgbtohsv:dV,mx_rotate2d:QV,mx_rotate3d:$V,mx_safepower:SV,mx_separate:XV,mx_splitlr:yV,mx_splittb:bV,mx_srgb_texture_to_lin_rec709:fV,mx_subtract:RV,mx_timer:WV,mx_transform_uv:xV,mx_unifiednoise2d:DV,mx_unifiednoise3d:OV,mx_worley_noise_float:kV,mx_worley_noise_vec2:AV,mx_worley_noise_vec3:jV,negate:$w,neutralToneMapping:oR,nodeArray:OS,nodeImmutable:H,nodeObject:TS,nodeObjectIntent:ES,nodeObjects:DS,nodeProxy:kS,nodeProxyIntent:U,normalFlat:kO,normalGeometry:DO,normalLocal:OO,normalMap:Fk,normalView:MO,normalViewGeometry:AO,normalWorld:NO,normalWorldGeometry:jO,normalize:Hw,not:dw,notEqual:iw,numWorkgroups:ER,objectDirection:ZD,objectGroup:HC,objectPosition:$D,objectRadius:nO,objectScale:eO,objectViewPosition:tO,objectWorldMatrix:QD,oneMinus:eT,or:uw,orthographicDepthToViewZ:pj,oscSawtooth:vI,oscSine:hI,oscSquare:gI,oscTriangle:_I,output:DC,outputStruct:jF,overloadingFn:dI,packHalf2x16:nI,packSnorm2x16:eI,packUnorm2x16:tI,parabola:YF,parallaxDirection:kk,parallaxUV:Ak,parameter:wF,pass:KL,passTexture:qL,pcurve:ZF,perspectiveDepthToViewZ:gj,pmremTexture:pP,pointShadow:xB,pointUV:mL,pointWidth:AC,positionGeometry:_O,positionLocal:vO,positionPrevious:yO,positionView:SO,positionViewDirection:CO,positionWorld:bO,positionWorldDirection:xO,posterize:zL,pow:vT,pow2:yT,pow3:bT,pow4:xT,premultiplyAlpha:Rj,property:aC,quadBroadcast:xz,quadSwapDiagonal:hz,quadSwapX:pz,quadSwapY:mz,radians:Mw,rand:jT,range:CR,rangeFogFactor:_R,reciprocal:iT,reference:tk,referenceBuffer:nk,reflect:pT,reflectVector:qO,reflectView:GO,reflector:UI,refract:OT,refractVector:JO,refractView:KO,reinhardToneMapping:QL,remap:ME,remapClamp:NE,renderGroup:VC,renderOutput:zE,rendererReference:fE,replaceDefaultUV:yI,rotate:kP,rotateUV:bI,roughness:uC,round:rT,rtt:YI,sRGBTransferEOTF:eE,sRGBTransferOETF:tE,sample:rL,sampler:aD,samplerComparison:oD,saturate:DT,saturation:PL,screenCoordinate:yD,screenDPR:gD,screenSize:vD,screenUV:_D,select:LT,setCurrentStack:MS,setName:VT,shaderStages:Ox,shadow:cB,shadowPositionWorld:Lz,shapeCircle:DB,sharedUniformGroup:zC,sheen:mC,sheenRoughness:hC,shiftLeft:_w,shiftRight:vw,shininess:EC,sign:Zw,sin:Ww,sinc:QF,skinning:VA,smoothstep:kT,smoothstepElement:NT,specularColor:CC,specularColorBlended:wC,specularF90:TC,spherizeUV:xI,split:nC,spritesheetUV:wI,sqrt:Rw,stack:TF,step:fT,stepElement:PT,storage:DA,storageBarrier:NR,storageTexture:bL,string:QS,struct:kF,sub:$C,subBuild:ZT,subgroupAdd:$R,subgroupAll:uz,subgroupAnd:az,subgroupAny:dz,subgroupBallot:QR,subgroupBroadcast:gz,subgroupBroadcastFirst:fz,subgroupElect:ZR,subgroupExclusiveAdd:tz,subgroupExclusiveMul:iz,subgroupInclusiveAdd:ez,subgroupInclusiveMul:rz,subgroupIndex:jA,subgroupMax:lz,subgroupMin:cz,subgroupMul:nz,subgroupOr:oz,subgroupShuffle:_z,subgroupShuffleDown:bz,subgroupShuffleUp:yz,subgroupShuffleXor:vz,subgroupSize:AR,subgroupXor:sz,tan:Kw,tangentGeometry:yk,tangentLocal:bk,tangentView:xk,tangentWorld:Sk,texture:tD,texture3D:CL,texture3DLevel:TL,texture3DLoad:wL,textureBarrier:PR,textureBicubic:YM,textureBicubicLevel:JM,textureCubeUV:ON,textureLevel:iD,textureLoad:rD,textureSize:YE,textureStore:xL,thickness:NC,time:fI,toneMapping:mE,toneMappingExposure:hE,toonOutlinePass:XL,transformDirection:ST,transformNormal:FO,transformNormalToView:IO,transformedClearcoatNormalView:zO,transformedNormalView:LO,transformedNormalWorld:RO,transmission:MC,transpose:sT,triNoise3D:lI,triplanarTexture:EI,triplanarTextures:TI,trunc:aT,uint:q,uintBitsToFloat:HF,uniform:WC,uniformArray:dD,uniformCubeTexture:QO,uniformFlow:BT,uniformGroup:RC,uniformTexture:nD,unpackHalf2x16:oI,unpackNormal:Pk,unpackSnorm2x16:iI,unpackUnorm2x16:aI,unpremultiplyAlpha:zj,userData:DL,uv:JE,uvec2:BS,uvec3:US,uvec4:qS,varying:QT,varyingProperty:oC,vec2:J,vec3:Y,vec4:GS,vectorComponents:kx,velocity:ML,vertexColor:Mj,vertexIndex:kA,vertexStage:$T,vibrance:FL,viewZToLogarithmicDepth:_j,viewZToOrthographicDepth:dj,viewZToPerspectiveDepth:mj,viewZToReversedOrthographicDepth:fj,viewZToReversedPerspectiveDepth:hj,viewport:bD,viewportCoordinate:SD,viewportDepthTexture:lj,viewportLinearDepth:Sj,viewportMipTexture:aj,viewportOpaqueMipTexture:sj,viewportResolution:wD,viewportSafeUV:CI,viewportSharedTexture:VL,viewportSize:xD,viewportTexture:ij,viewportUV:CD,vogelDiskSample:tL,wgsl:uR,wgslFn:hR,workgroupArray:LR,workgroupBarrier:MR,workgroupId:DR,workingToColorSpace:aE,xor:fw}),rH=new SF,iH=class extends KP{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(rH),rH.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(rH),rH.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;rH.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=GS(a).mul(vL).context({getUV:()=>yL.mul(jO),getTextureLevel:()=>_L}),t=HD.element(3).element(3).equal(1),r=tw(1,HD.element(1).element(1)).mul(3),s=t.select(vO.mul(r),vO),c=fO.mul(GS(s,0)),l=HD.mul(GS(c.xyz,1));l=l.setZ(l.w);let u=new Bj;u.name=`Background.material`,u.side=1,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new fy(new Ly(1,32,32),u),o.frustumCulled=!1,o.name=`Background.mesh`;function d(){i.removeEventListener(`dispose`,d),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,d)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=GS(a).mul(vL),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else z(`Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?rH.set(0,0,0,1):o===`alpha-blend`&&rH.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=rH.r,e.g=rH.g,e.b=rH.b,e.a=rH.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}},aH=0,oH=class{constructor(e=``,t=[],n=0){this.name=e,this.bindings=t,this.index=n,this.id=aH++}},sH=class{constructor(e,t,n,r,i,a,o,s,c,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=l,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){let n=new oH(t.name,[],t.index);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t);return e}},cH=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},lH=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}},uH=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},dH=class extends uH{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},fH=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}},pH=0,mH=class{constructor(e=null){this.id=pH++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}},hH=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},gH=class{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}},_H=class extends gH{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},vH=class extends gH{constructor(e,t=new Pg){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},yH=class extends gH{constructor(e,t=new B){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},bH=class extends gH{constructor(e,t=new e_){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},xH=class extends gH{constructor(e,t=new R_){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},SH=class extends gH{constructor(e,t=new Zb){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},CH=class extends gH{constructor(e,t=new Rg){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},wH=class extends gH{constructor(e,t=new r_){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},TH=class extends _H{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},EH=class extends vH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},DH=class extends yH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},OH=class extends bH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},kH=class extends xH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},AH=class extends SH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},jH=class extends CH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},MH=class extends wH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},NH=0,PH=new WeakMap,FH=new WeakMap,IH=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),LH=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`)),RH=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:``,fragment:``,compute:``},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:``},this.chaining=[],this.stack=TF(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new mH,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,`id`,{value:NH++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute(`normal`)===!1}isOpaque(){let e=this.material;return e.transparent===!1&&e.blending===1&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new t_(e,t,n)}createCubeRenderTarget(e,t){return new Jj(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){let n=t[0].groupNode,r=n.shared;if(r)for(let e=1;e<t.length;e++)n!==t[e].groupNode&&(r=!1);let i;if(r){let n=``;for(let e of t)if(e.isNodeUniformsGroup){e.uniforms.sort((e,t)=>e.nodeUniform.node.id-t.nodeUniform.node.id);for(let t of e.uniforms)n+=t.nodeUniform.node.id}else n+=e.nodeUniform.id;let r=this.renderer._currentRenderContext||this.renderer,a=PH.get(r);a===void 0&&(a=new Map,PH.set(r,a));let o=sx(n);i=a.get(o),i===void 0&&(i=new oH(e,t,this.bindingsIndexes[e].group),a.set(o,i))}else i=new oH(e,t,this.bindingsIndexes[e].group);return i}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of Ox)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);for(let e of i)a.includes(e)===!1&&a.push(e)}e=[];for(let n in t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();(t!==Cx.NONE||n!==Cx.NONE)&&this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==Cx.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==Cx.NONE&&this.updateBeforeNodes.push(e),n!==Cx.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===1006||e.magFilter===1007||e.magFilter===1005||e.magFilter===1008||e.minFilter===1006||e.minFilter===1007||e.minFilter===1005||e.minFilter===1008}getUniformBufferLimit(){return 16384}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error(`NodeBuilder: Invalid node chaining!`)}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new mH(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){R(`Abstract function.`)}getInstanceIndex(){R(`Abstract function.`)}getDrawIndex(){R(`Abstract function.`)}getFrontFacing(){R(`Abstract function.`)}getFragCoord(){R(`Abstract function.`)}isFlipY(){return!1}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){R(`Abstract function.`)}generateTextureLod(){R(`Abstract function.`)}generateArrayDeclaration(e,t){return this.getType(e)+`[ `+t+` ]`}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+`( `;for(let i=0;i<t;i++){let a=n?n[i]:null;a===null?r+=this.generateConst(e):r+=a.build(this,e),i<t-1&&(r+=`, `)}return r+=` )`,r}generateStruct(e,t,n=null){let r=[];for(let e of t){let{name:t,type:i}=e;n&&n[t]&&n[t].isNode?r.push(n[t].build(this,i)):r.push(this.generateConst(i))}return e+`( `+r.join(`, `)+` )`}generateConst(e,t=null){if(t===null&&(e===`float`||e===`int`||e===`uint`?t=0:e===`bool`?t=!1:e===`color`?t=new R_:e===`vec2`||e===`uvec2`||e===`ivec2`?t=new Pg:e===`vec3`||e===`uvec3`||e===`ivec3`?t=new B:(e===`vec4`||e===`uvec4`||e===`ivec4`)&&(t=new e_)),e===`float`)return LH(t);if(e===`int`)return`${Math.round(t)}`;if(e===`uint`)return t>=0?`${Math.round(t)}u`:`0u`;if(e===`bool`)return t?`true`:`false`;if(e===`color`)return`${this.getType(`vec3`)}( ${LH(t.r)}, ${LH(t.g)}, ${LH(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e===`color`?`vec3`:e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new cH(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e===`void`||e===`property`||e===`sampler`||e===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===1013)return`int`;if(t===1014)return`uint`}return`float`}getElementType(e){return e===`mat2`?`vec2`:e===`mat3`?`vec3`:e===`mat4`?`vec4`:this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e===`float`||e===`bool`||e===`int`||e===`uint`)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]===`b`?`bool`:t[1]===`i`?`int`:t[1]===`u`?`uint`:`float`}getVectorType(e){return e===`color`?`vec3`:e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`texture3D`?`vec4`:e}getTypeFromLength(e,t=`float`){if(e===1)return t;let n=fx(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return IH.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof Ev)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?t===`float`||t===`bool`||t===`int`||t===`uint`?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error(`NodeBuilder: Invalid active stack removal.`)}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=TF(this.stack);let e=NS();return this.stacks.push(e),MS(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes){let n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,MS(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let i=r[t],a=r.any?r.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(i.subBuildsCache===void 0&&(i.subBuildsCache={}),i=i.subBuildsCache[o]||(i.subBuildsCache[o]={}),i.subBuilds=a),i}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t){let n=this.getDataFromNode(e,`vertex`),r=n.bufferAttribute;return r===void 0&&(r=new cH(`nodeAttribute`+ this.uniforms.index++,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r),r}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let o=this.structs.index++;n===null&&(n=`StructType`+o),a=new hH(n,t),this.structs[r].push(a),this.types[r][n]=e,i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new lH(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=this.getSubBuildProperty(`variable`,a.subBuilds),s=a[o];if(s===void 0){let c=i?`_const`:`_var`,l=this.vars[r]||(this.vars[r]=[]),u=this.vars[c]||(this.vars[c]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+u,this.vars[c]++),o!==`variable`&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);s=new uH(t,n,i,d),i||l.push(s),this.registerDeclaration(s),a[o]=s}return s}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=this.getSubBuildProperty(`varying`,a.subBuilds),s=a[o];if(s===void 0){let e=this.varyings,c=e.length;t===null&&(t=`nodeVarying`+c),o!==`varying`&&(t=this.getSubBuildProperty(t,a.subBuilds)),s=new dH(t,n,r,i),e.push(s),this.registerDeclaration(s),a[o]=s}return s}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e),i=1,a=r;for(;n[a]!==void 0;)a=r+`_`+ i++;i>1&&(e.name=a,R(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${a}'.`)),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new fH(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===``?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=`;
|
|
38
|
+
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=` `,this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=new fR,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new CF(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowBuildStage(e,t,n=null){let r=this.getBuildStage();this.setBuildStage(t);let i=e.build(this,n);return this.setBuildStage(r),i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,c={code:``};this.flow=c,this.vars={},this.declarations={},this.cache=new mH,this.stack=TF();for(let n of Dx)this.setBuildStage(n),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){R(`Abstract function.`)}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);let c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=` `,this.context=c;let l=null;if(this.buildStage===`generate`){let i=this.flowChildNode(t,n);r!==null&&(i.code+=`${this.tab+r} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){R(`Abstract function.`)}getVaryings(){R(`Abstract function.`)}getVar(e,t,n=null){return`${n===null?this.getType(e):this.generateArrayDeclaration(e,n)} ${t}`}getVars(e){let t=``,n=this.vars[e];if(n!==void 0)for(let e of n)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){R(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+`
|
|
39
|
+
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){R(`Abstract function.`)}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,`any`).subBuilds:e instanceof Set?[...e]:e,!t)return null;let n=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let r=t[e];if(n.includes(r))return r}return null}getSubBuildOutput(e){return this.getSubBuildProperty(`outputNode`,e)}getSubBuildProperty(e=``,t=null){let n;n=t===null?this.subBuildFn:this.getClosestSubBuild(t);let r;return r=n?e?n+`_`+e:n:e,r}build(){let{object:e,material:t,renderer:n}=this;if(t!==null){let e=n.library.fromMaterial(t);e===null&&(z(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Bj),e.build(this)}else this.addFlow(`compute`,e);for(let e of Dx){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.position);for(let t of Ox){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=FH.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){let n=this.getSharedDataFromNode(e),r=n.cache;if(r===void 0){if(t===`float`||t===`int`||t===`uint`)r=new TH(e);else if(t===`vec2`||t===`ivec2`||t===`uvec2`)r=new EH(e);else if(t===`vec3`||t===`ivec3`||t===`uvec3`)r=new DH(e);else if(t===`vec4`||t===`ivec4`||t===`uvec4`)r=new OH(e);else if(t===`color`)r=new kH(e);else if(t===`mat2`)r=new AH(e);else if(t===`mat3`)r=new jH(e);else if(t===`mat4`)r=new MH(e);else throw Error(`Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&i===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?(e=n===`bool`?`all( ${e} )`:`${e}.${`xyz`.slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),n)):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r183 - Node System
|
|
40
|
+
`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has(`velocity`)||yx(this.object).useVelocity===!0}},zH=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Cx.FRAME){let t=this._getMaps(this.updateBeforeMap,n);if(t.frameId!==this.frameId){let n=t.frameId;t.frameId=this.frameId,e.updateBefore(this)===!1&&(t.frameId=n)}}else if(t===Cx.RENDER){let t=this._getMaps(this.updateBeforeMap,n);if(t.renderId!==this.renderId){let n=t.renderId;t.renderId=this.renderId,e.updateBefore(this)===!1&&(t.renderId=n)}}else t===Cx.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Cx.FRAME){let t=this._getMaps(this.updateAfterMap,n);t.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(t.frameId=this.frameId)}else if(t===Cx.RENDER){let t=this._getMaps(this.updateAfterMap,n);t.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(t.renderId=this.renderId)}else t===Cx.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===Cx.FRAME){let t=this._getMaps(this.updateMap,n);t.frameId!==this.frameId&&e.update(this)!==!1&&(t.frameId=this.frameId)}else if(t===Cx.RENDER){let t=this._getMaps(this.updateMap,n);t.renderId!==this.renderId&&e.update(this)!==!1&&(t.renderId=this.renderId)}else t===Cx.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}},BH=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};BH.isNodeFunctionInput=!0;var VH=class extends SB{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},HH=class extends SB{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:kz(this.light),lightColor:e}}},UH=class extends SB{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=Ez(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=WC(new R_).setGroup(VC)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=TT(n,t,NO.dot(r).mul(.5).add(.5));e.context.irradiance.addAssign(i)}},WH=class extends SB{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=WC(0).setGroup(VC),this.penumbraCosNode=WC(0).setGroup(VC),this.cutoffDistanceNode=WC(0).setGroup(VC),this.decayExponentNode=WC(0).setGroup(VC),this.colorNode=WC(this.color).setGroup(VC)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return kT(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=Tz(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(kz(i)),c=this.getSpotAttenuation(e,s),l=CB({lightDistance:a.length(),cutoffDistance:n,decayExponent:r}),u=t.mul(c).mul(l),d,f;return i.colorNode?(f=this.getLightCoord(e),d=i.colorNode(f)):i.map&&(f=this.getLightCoord(e),d=tD(i.map,f.xy).onRenderUpdate(()=>i.map)),d&&(u=f.mul(2).sub(1).abs().lessThan(1).all().select(u.mul(d),u)),{lightColor:u,lightDirection:o}}},GH=class extends WH{static get type(){return`IESSpotLightNode`}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;return r=n&&n.isTexture===!0?tD(n,J(t.acos().mul(1/Math.PI),0),0).r:super.getSpotAttenuation(t),r}},KH=class extends SB{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new B);this.lightProbe=dD(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=nH(NO,this.lightProbe);e.context.irradiance.addAssign(t)}},qH=W(([e,t])=>{let n=e.abs().sub(t);return Qw(dT(n,0)).add(uT(dT(n.x,n.y),0))}),JH=class extends WH{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=G(0),n=this.penumbraCosNode,r=wz(this.light).mul(e.context.positionWorld||bO);return PS(r.w.greaterThan(0),()=>{let e=qH(r.xyz.div(r.w).xy.sub(J(.5)),J(.5)),i=tw(-1,$C(1,Jw(n)).sub(1));t.assign(DT(e.mul(-2).mul(i)))}),t}},YH=new r_,XH=new r_,ZH=null,QH=class extends SB{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=WC(new B).setGroup(VC),this.halfWidth=WC(new B).setGroup(VC),this.updateType=Cx.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;XH.identity(),YH.copy(t.matrixWorld),YH.premultiply(n),XH.extractRotation(YH),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(XH),this.halfHeight.value.applyMatrix4(XH)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=tD(ZH.LTC_FLOAT_1),n=tD(ZH.LTC_FLOAT_2)):(t=tD(ZH.LTC_HALF_1),n=tD(ZH.LTC_HALF_2));let{colorNode:r,light:i}=this;return{lightColor:r,lightPosition:Oz(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){ZH=e}},$H=class{parseFunction(){R(`Abstract function.`)}},eU=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){R(`Abstract function.`)}};eU.isNodeFunction=!0;var tU=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,nU=/[a-z_0-9]+/gi,rU=`#pragma main`,iU=e=>{e=e.trim();let t=e.indexOf(rU),n=t===-1?e:e.slice(t+12),r=n.match(tU);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=nU.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c<a.length;){let e=a[c][0]===`const`;e===!0&&c++;let t=a[c][0];t===`in`||t===`out`||t===`inout`?c++:t=``;let n=a[c++][0],r=Number.parseInt(a[c][0]);Number.isNaN(r)===!1?c++:r=null;let i=a[c++][0];s.push(new BH(n,i,r,t,e))}let l=n.substring(r[0].length),u=r[3]===void 0?``:r[3];return{type:r[2],inputs:s,name:u,precision:r[1]===void 0?``:r[1],inputsCode:i,blockCode:l,headerCode:t===-1?``:e.slice(0,t)}}else throw Error(`FunctionNode: Function is not a GLSL code.`)},aU=class extends eU{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=iU(e);super(t,n,r,i),this.inputsCode=a,this.blockCode=o,this.headerCode=s}getCode(e=this.name){let t,n=this.blockCode;if(n!==``){let{type:r,inputsCode:i,headerCode:a,precision:o}=this,s=`${r} ${e} ( ${i.trim()} )`;o!==``&&(s=`${o} ${s}`),t=a+s+n}else t=``;return t}},oU=class extends $H{parseFunction(e){return new aU(e)}},sU=new WeakMap,cU=[],lU=[],uU=class extends KP{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new zH,this.nodeBuilderCache=new Map,this.callHashCache=new BP,this.groupsData=new BP,this.cacheLib={}}updateGroup(e){let t=e.groupNode,n=t.name;if(n===HC.name)return!0;if(n===VC.name){let t=this.get(e),n=this.nodeFrame.renderId;return t.renderId===n?!1:(t.renderId=n,!0)}if(n===BC.name){let t=this.get(e),n=this.nodeFrame.frameId;return t.frameId===n?!1:(t.frameId=n,!0)}cU[0]=t,cU[1]=e;let r=this.groupsData.get(cU);return r===void 0&&this.groupsData.set(cU,r={}),cU[0]=null,cU[1]=null,r.version===t.version?!1:(r.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0){let{nodeBuilderCache:r}=this,i=this.getForRenderCacheKey(e);if(n=r.get(i),n===void 0){let t=t=>{let n=this.backend.createNodeBuilder(e.object,this.renderer);return n.scene=e.scene,n.material=t,n.camera=e.camera,n.context.material=t,n.lightsNode=e.lightsNode,n.environmentNode=this.getEnvironmentNode(e.scene),n.fogNode=this.getFogNode(e.scene),n.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&n.enableMultiview(),n},a=t(e.material);try{a.build()}catch(e){a=t(new Bj),a.build();let n=e.stackTrace;!n&&e.stack&&(n=new ax(e.stack)),z(`TSL: `+e,n)}n=this._createNodeBuilderState(a),r.set(i,n)}n.usedTimes++,t.nodeBuilderState=n}return n}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new sH(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){cU[0]=e,cU[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(cU)||{};if(r.callId!==n){let i=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&lU.push(t.getCacheKey(!0)),i&&lU.push(i.getCacheKey()),a&&lU.push(a.getCacheKey()),lU.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),lU.push(+!!this.renderer.shadowMap.enabled),lU.push(this.renderer.shadowMap.type),r.callId=n,r.cacheKey=cx(lU),this.callHashCache.set(cU,r),lU.length=0}return cU[0]=null,cU[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;(t.background!==n||r)&&(t.backgroundNode=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===303||n.mapping===304||n.mapping===306){if(e.backgroundBlurriness>0||n.mapping===306)return pP(n);{let e;return e=n.isCubeTexture===!0?ZO(n):tD(n),eM(e)}}else if(n.isTexture===!0)return tD(n,_D.flipY()).setUpdateMatrix(!0);else n.isColor!==!0&&z(`WebGPUNodes: Unsupported background configuration.`,n)},r),t.background=n,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;n?t.fog!==n&&(t.fogNode=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2)return bR(tk(`color`,`color`,n).setGroup(VC),vR(tk(`density`,`float`,n).setGroup(VC)));if(n.isFog)return bR(tk(`color`,`color`,n).setGroup(VC),_R(tk(`near`,`float`,n).setGroup(VC),tk(`far`,`float`,n).setGroup(VC)));z(`Renderer: Unsupported fog configuration.`,n)}),t.fog=n):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),n=e.environment;n?t.environment!==n&&(t.environmentNode=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return ZO(n);if(n.isTexture===!0)return tD(n);z(`Nodes: Unsupported environment configuration.`,n)}),t.environment=n):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}hasOutputChange(e){return sU.get(e)!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?CL(e,Y(_D,fD(`gl_ViewID_OVR`))).renderOutput(t.toneMapping,t.currentColorSpace):tD(e,_D).renderOutput(t.toneMapping,t.currentColorSpace);return sU.set(e,n),r}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new zH,this.nodeBuilderCache=new Map,this.cacheLib={}}},dU=new by,fU=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewNormalMatrix=new Rg,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i<r;i++){dU.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=dU.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=dU.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let r=t.clippingPlanes,i=r.length,a,o;if(this.clipIntersection?(a=this.intersectionPlanes,o=e.intersectionPlanes.length):(a=this.unionPlanes,o=e.unionPlanes.length),a.length!==o+i){a.length=o+i;for(let e=0;e<i;e++)a[o+e]=new e_;n=!0}this.projectPlanes(r,a,o),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(t){if(this.shadowPass&&!t.clipShadows)return this;let n=this.clippingGroupContexts.get(t);return n===void 0&&(n=new e(this),this.clippingGroupContexts.set(t,n)),n.update(this,t),n}get unionClippingCount(){return this.unionPlanes.length}},pU=class{constructor(e,t){this.bundleGroup=e,this.camera=t}},mU=[],hU=class{constructor(){this.bundles=new BP}get(e,t){let n=this.bundles;mU[0]=e,mU[1]=t;let r=n.get(mU);return r===void 0&&(r=new pU(e,t),n.set(mU,r)),mU[0]=null,mU[1]=null,r}dispose(){this.bundles=new BP}},gU=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(let n in e)t[n]=e[n]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){R(`Redefinition of node ${t}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t==`function`||typeof t==`object`)throw Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){R(`Redefinition of node ${t.name}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t!=`function`)throw Error(`Base class ${t.name} is not a class.`);n.set(t,e)}},_U=new Pz,vU=new WeakMap,yU=class{createNode(e=[]){return new Pz().setLights(e)}getNode(e){if(e.isQuadMesh)return _U;let t=vU.get(e);return t===void 0&&(t=this.createNode(),vU.set(e,t)),t}},bU=class extends t_{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}},xU=new B,SU=new B,CU=class extends og{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Sb,this._cameraL.viewport=new e_,this._cameraR=new Sb,this._cameraR.viewport=new e_,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Lb,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<`u`,this._frameBufferTargets=null,this._createXRLayer=AU.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new Pg,this._onSessionEvent=DU.bind(this),this._onSessionEnd=OU.bind(this),this._onInputSourcesChange=kU.bind(this),this._onAnimationFrame=jU.bind(this),this._referenceSpace=null,this._referenceSpaceType=`local-floor`,this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&`createProjectionLayer`in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&R(`XRManager: Cannot change framebuffer scale while presenting.`)}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&R(`XRManager: Cannot change reference space type while presenting.`)}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,r,i,a,o,s={}){let c=new Iy(e,t),l=new bU(i,a,{format:Fm,type:bm,depthTexture:new My(i,a,s.stencil?Am:Tm,void 0,void 0,void 0,void 0,void 0,void 0,s.stencil?Lm:Im),stencilBuffer:s.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});l._autoAllocateDepthBuffer=!0;let u=new ey({color:16777215,side:0});u.map=l.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new fy(c,u);d.position.copy(n),d.quaternion.copy(r);let f={type:`quad`,width:e,height:t,translation:n,quaternion:r,pixelwidth:i,pixelheight:a,plane:d,material:u,rendercall:o,renderTarget:l};if(this._layers.push(f),this._session!==null){f.plane.material=new ey({color:16777215,side:0}),f.plane.material.blending=5,f.plane.material.blendEquation=100,f.plane.material.blendSrc=200,f.plane.material.blendDst=200,f.xrlayer=this._createXRLayer(f);let e=this._session.renderState.layers;e.unshift(f.xrlayer),this._session.updateRenderState({layers:e})}else l.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,n,r,i,a,o,s,c={}){let l=new Fy(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new bU(a,o,{format:Fm,type:bm,depthTexture:new My(a,o,c.stencil?Am:Tm,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?Lm:Im),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;let d=new ey({color:16777215,side:1});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new fy(l,d);f.position.copy(r),f.quaternion.copy(i);let p={type:`cylinder`,radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:i,pixelwidth:a,pixelheight:o,plane:f,material:d,rendercall:s,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new ey({color:16777215,side:1}),p.plane.material.blending=5,p.plane.material.blendEquation=100,p.plane.material.blendSrc=200,p.plane.material.blendDst=200,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return f}renderLayers(){let e=new B,t=new Fg,n=this._renderer,r=this.isPresenting,i=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;let o=new Pg;n.getSize(o);let s=n._quad;for(let r of this._layers)if(r.renderTarget.isXRRenderTarget=this._session!==null,r.renderTarget._hasExternalTextures=r.renderTarget.isXRRenderTarget,r.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){r.xrlayer.transform=new XRRigidTransform(r.plane.getWorldPosition(e),r.plane.getWorldQuaternion(t));let i=this._glBinding.getSubImage(r.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(r.renderTarget,i.colorTexture,void 0),n._setXRLayerSize(r.renderTarget.width,r.renderTarget.height),n.setOutputRenderTarget(r.renderTarget),n.setRenderTarget(null),n._frameBufferTarget=null,this._frameBufferTargets||=new WeakMap;let{frameBufferTarget:a,quad:o}=this._frameBufferTargets.get(r.renderTarget)||{frameBufferTarget:null,quad:null};a?(n._frameBufferTarget=a,n._quad=o):(n._quad=new KI(new Bj),this._frameBufferTargets.set(r.renderTarget,{frameBufferTarget:n._getFrameBufferTarget(),quad:n._quad})),r.rendercall(),n._frameBufferTarget=null}else n.setRenderTarget(r.renderTarget),r.rendercall();n.setRenderTarget(null),n.setOutputRenderTarget(i),n._frameBufferTarget=a,n._setXRLayerSize(o.x,o.y),n._quad=s,this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer,n=t.backend;this._gl=t.getContext();let r=this._gl,i=r.getContextAttributes();if(this._session=e,e!==null){if(n.isWebGPUBackend===!0)throw Error(`THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.`);if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),await n.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let n=null,a=null,o=null;t.depth&&(o=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,n=t.stencil?Lm:Im,a=t.stencil?Am:Tm);let s={colorFormat:r.RGBA8,depthFormat:o,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0),this._glBinding=this.getBinding();let c=this._glBinding.createProjectionLayer(s),l=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);let u=this._useMultiview?2:1,d=new My(c.textureWidth,c.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n,u);if(this._xrRenderTarget=new bU(c.textureWidth,c.textureHeight,{format:Fm,type:bm,colorSpace:t.outputColorSpace,depthTexture:d,stencilBuffer:t.stencil,samples:i.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new ey({color:16777215,side:+(e.type===`cylinder`)}),e.plane.material.blending=5,e.plane.material.blendEquation=100,e.plane.material.blendSrc=200,e.plane.material.blendDst=200,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{let n={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,n);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new bU(i.framebufferWidth,i.framebufferHeight,{format:Fm,type:bm,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=e.layers.mask|6,a.layers.mask=i.layers.mask&-5,o.layers.mask=i.layers.mask&-3;let s=e.parent,c=i.cameras;TU(i,s);for(let e=0;e<c.length;e++)TU(c[e],s);c.length===2?wU(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),EU(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new N_,this._controllers[e]=t),t}};function wU(e,t,n){xU.setFromMatrixPosition(t.matrixWorld),SU.setFromMatrixPosition(n.matrixWorld);let r=xU.distanceTo(SU),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function TU(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function EU(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=ug*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function DU(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(t===-1)return;let n=this._controllers[t];if(n!==void 0){let t=this.getReferenceSpace();n.update(e.inputSource,e.frame,t),n.dispatchEvent({type:e.type,data:e.inputSource})}}function OU(){let e=this._session,t=this._renderer;e.removeEventListener(`select`,this._onSessionEvent),e.removeEventListener(`selectstart`,this._onSessionEvent),e.removeEventListener(`selectend`,this._onSessionEvent),e.removeEventListener(`squeeze`,this._onSessionEvent),e.removeEventListener(`squeezestart`,this._onSessionEvent),e.removeEventListener(`squeezeend`,this._onSessionEvent),e.removeEventListener(`end`,this._onSessionEnd),e.removeEventListener(`inputsourceschange`,this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){let t=this._controllerInputSources[e];t!==null&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(let e of this._layers)e.renderTarget=new bU(e.pixelwidth,e.pixelheight,{format:Fm,type:bm,depthTexture:new My(e.pixelwidth,e.pixelheight,e.stencilBuffer?Am:Tm,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?Lm:Im),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:`sessionend`})}function kU(e){let t=this._controllers,n=this._controllerInputSources;for(let r=0;r<e.removed.length;r++){let i=e.removed[r],a=n.indexOf(i);a>=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r<e.added.length;r++){let i=e.added[r],a=n.indexOf(i);if(a===-1){for(let e=0;e<t.length;e++)if(e>=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function AU(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function jU(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views;this._glBaseLayer!==null&&i.setXRTarget(a.framebuffer);let t=!1;e.length!==n.cameras.length&&(n.cameras.length=0,t=!0);for(let r=0;r<e.length;r++){let o=e[r],s;if(this._supportsLayers===!0){let e=this._glBinding.getViewSubImage(this._glProjLayer,o);s=e.viewport,r===0&&i.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else s=a.getViewport(o);let c=this._cameras[r];c===void 0&&(c=new Sb,c.layers.enable(r),c.viewport=new e_,this._cameras[r]=c),c.matrix.fromArray(o.transform.matrix),c.matrix.decompose(c.position,c.quaternion,c.scale),c.projectionMatrix.fromArray(o.projectionMatrix),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),c.viewport.set(s.x,s.y,s.width,s.height),r===0&&(n.matrix.copy(c.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),t===!0&&n.cameras.push(c)}r.setOutputRenderTarget(this._xrRenderTarget)}for(let e=0;e<this._controllers.length;e++){let n=this._controllerInputSources[e],r=this._controllers[e];n!==null&&r!==void 0&&r.update(n,t,o)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:`planesdetected`,data:t}),this._xrFrame=null}var MU=class extends og{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new e_(0,0,this._width,this._height),this._scissor=new e_(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Ay,this.depthTexture=new My}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){let i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,i=0,a=1){let o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,n,r),o.minDepth=i,o.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:`resize`})}dispose(){this.dispatchEvent({type:`dispose`})}},NU=new B_,PU=new Pg,FU=new e_,IU=new wy,LU=new Dy,RU=new r_,zU=new e_,BU={0:1,1:0,2:2},VU=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:n=!1,reversedDepthBuffer:r=!1,alpha:i=!0,depth:a=!0,stencil:o=!1,antialias:s=!1,samples:c=0,getFallback:l=null,outputBufferType:u=Dm,multiview:d=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=n,this.reversedDepthBuffer=r,this.outputColorSpace=Nh,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=o,this.info=new nF,this.contextNode=zT(),this.library=new gU,this.lighting=new yU,this._samples=c||s===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new MU(e.getDomElement()),this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new HE,this._inspector.setRenderer(this),this._getFallback=l,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new KI(new Bj),this._quad.name=`Output Color Transform`,this._quad.material.name=`outputColorTransform`,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null,this._clearColor=new SF(0,0,0,this.alpha===!0?0:1),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._outputBufferType=u,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:1},this.xr=new CU(this,d),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,n)=>{await this.compileAsync(e,t);let r=this._renderLists.get(e,t),i=this._renderContexts.get(this._renderTarget,this._mrt),a=e.overrideMaterial||n.material,{fragmentShader:o,vertexShader:s}=this._objects.get(n,a,e,t,r.lightsNode,i,i.clippingContext).getNodeBuilderState();return{fragmentShader:o,vertexShader:s}}}}async init(){return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new uU(this,n),this._animation=new zP(this,this._nodes,this.info),this._attributes=new ZP(n),this._background=new iH(this,this._nodes),this._geometries=new tF(this._attributes,this.info),this._textures=new xF(this,n,this.info),this._pipelines=new cF(n,this._nodes),this._bindings=new lF(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new GP(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new hF(this.lighting),this._bundles=new hU,this._renderContexts=new yF(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._handleObjectFunction,c=this._compilationPromises,l=e.isScene===!0?e:NU;n===null&&(n=e);let u=this._renderTarget,d=this._renderContexts.get(u,this._mrt),f=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,r.renderId++,r.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||=new fU,d.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,u);let m=this._renderLists.get(e,t);if(m.begin(),this._projectObject(e,t,0,m,d.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&m.pushLight(e)}),m.finish(),u!==null){this._textures.updateRenderTarget(u,f);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;n===e?this._background.update(l,m,d):this._background.update(n,m,d);let h=m.opaque,g=m.transparent,_=m.transparentDoublePass,v=m.lightsNode;this.opaque===!0&&h.length>0&&this._renderObjects(h,t,l,v),this.transparent===!0&&g.length>0&&this._renderTransparents(g,_,t,l,v),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=s,this._compilationPromises=c,await Promise.all(p)}async renderAsync(e,t){ig(`Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.render(e,t)}async waitForGPU(){z(`Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.`)}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;e===!0?(t.modelViewMatrix=mO,t.modelNormalViewMatrix=hO):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===mO&&e.modelNormalViewMatrix===hO}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return ig(`Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".`),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),z(t),this._isDeviceLost=!0}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i),c=this.backend.get(s);c.renderContexts===void 0&&(c.renderContexts=new Set);let l=r.version!==c.version,u=c.renderContexts.has(o)===!1||l;if(c.renderContexts.add(o),u){this.backend.beginBundle(o),(c.renderObjects===void 0||l)&&(c.renderObjects=[]),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:u,opaque:d}=a;this.opaque===!0&&d.length>0&&this._renderObjects(d,i,t,n),this.transparent===!0&&u.length>0&&this._renderTransparents(u,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t<n;t++){let n=e[t];this._nodes.needsRefresh(n)&&(this._nodes.updateBefore(n),this._nodes.updateForRender(n),this._bindings.updateForRender(n),this._nodes.updateAfter(n))}}this.backend.addBundle(o,s)}render(e,t){if(this._initialized===!1)throw Error(`Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.`);this._renderScene(e,t)}get initialized(){return this._initialized}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,n=e!==0,r=t!==Ug.workingColorSpace;if(n===!1&&r===!1)return null;let{width:i,height:a}=this.getDrawingBufferSize(PU),{depth:o,stencil:s}=this,c=this._frameBufferTarget;c===null&&(c=new t_(i,a,{depthBuffer:o,stencilBuffer:s,type:this._outputBufferType,format:Fm,colorSpace:Ug.workingColorSpace,generateMipmaps:!1,minFilter:gm,magFilter:gm,samples:this.samples}),c.isPostProcessingRenderTarget=!0,this._frameBufferTarget=c);let l=this.getOutputRenderTarget();c.depthBuffer=o,c.stencilBuffer=s,l===null?c.setSize(i,a,1):c.setSize(l.width,l.height,l.depth);let u=this._canvasTarget;return c.viewport.copy(u._viewport),c.scissor.copy(u._scissor),c.viewport.multiplyScalar(u._pixelRatio),c.scissor.multiplyScalar(u._pixelRatio),c.scissorTest=u._scissorTest,c.multiview=l===null?!1:l.multiview,c.resolveDepthBuffer=l===null?!0:l.resolveDepthBuffer,c._autoAllocateDepthBuffer=l===null?!1:l._autoAllocateDepthBuffer,c}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=this._handleObjectFunction;this._callDepth++;let l=e.isScene===!0?e:NU,u=this._renderTarget||this._outputRenderTarget,d=this._activeCubeFace,f=this._activeMipmapLevel,p;r===null?p=u:(p=r,this.setRenderTarget(p));let m=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,p);let h=this.xr;if(h.isPresenting===!1){let e=!1;if(this.reversedDepthBuffer===!0&&t.reversedDepth!==!0){if(t._reversedDepth=!0,t.isArrayCamera)for(let e of t.cameras)e._reversedDepth=!0;e=!0}let n=this.coordinateSystem;if(t.coordinateSystem!==n){if(t.coordinateSystem=n,t.isArrayCamera)for(let e of t.cameras)e.coordinateSystem=n;e=!0}if(e===!0&&(t.updateProjectionMatrix(),t.isArrayCamera))for(let e of t.cameras)e.updateProjectionMatrix()}e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),h.enabled===!0&&h.isPresenting===!0&&(h.cameraAutoUpdate===!0&&h.updateCamera(t),t=h.getCamera());let g=this._canvasTarget,_=g._viewport,v=g._scissor,y=g._pixelRatio;p!==null&&(_=p.viewport,v=p.scissor,y=1),this.getDrawingBufferSize(PU),FU.set(0,0,PU.width,PU.height);let b=_.minDepth===void 0?0:_.minDepth,x=_.maxDepth===void 0?1:_.maxDepth;m.viewportValue.copy(_).multiplyScalar(y).floor(),m.viewportValue.width>>=f,m.viewportValue.height>>=f,m.viewportValue.minDepth=b,m.viewportValue.maxDepth=x,m.viewport=m.viewportValue.equals(FU)===!1,m.scissorValue.copy(v).multiplyScalar(y).floor(),m.scissor=g._scissorTest&&m.scissorValue.equals(FU)===!1,m.scissorValue.width>>=f,m.scissorValue.height>>=f,m.clippingContext||=new fU,m.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);let S=t.isArrayCamera?LU:IU;t.isArrayCamera||(RU.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),S.setFromProjectionMatrix(RU,t.coordinateSystem,t.reversedDepth));let C=this._renderLists.get(e,t);if(C.begin(),this._projectObject(e,t,0,C,m.clippingContext),C.finish(),this.sortObjects===!0&&C.sort(this._opaqueSort,this._transparentSort),p!==null){this._textures.updateRenderTarget(p,f);let e=this._textures.get(p);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=p,m.depth=p.depthBuffer,m.stencil=p.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=PU.width,m.height=PU.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=f,m.height>>=f,m.activeCubeFace=d,m.activeMipmapLevel=f,m.occlusionQueryCount=C.occlusionQueryCount,m.scissorValue.max(zU.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(l,C,m),m.camera=t,this.backend.beginRender(m);let{bundles:w,lightsNode:T,transparentDoublePass:E,transparent:D,opaque:O}=C;return w.length>0&&this._renderBundles(w,l,T),this.opaque===!0&&O.length>0&&this._renderObjects(O,t,l,T),this.transparent===!0&&D.length>0&&this._renderTransparents(D,E,t,l,T),this.backend.finishRender(m),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,this._handleObjectFunction=c,this._callDepth--,r!==null&&(this.setRenderTarget(u,d,f),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);let n=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,i=0,a=1){this._canvasTarget.setViewport(e,t,n,r,i,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw Error(`Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.`);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.get(r),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer;let t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){ig(`Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.clear(e,t,n)}async clearColorAsync(){ig(`Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.`),this.clear(!0,!1,!1)}async clearDepthAsync(){ig(`Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!0,!1)}async clearStencilAsync(){ig(`Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.`),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==0,t=this.currentColorSpace!==Ug.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget===null?this.needsFrameBufferTarget&&(e=0):e=this._renderTarget.samples,e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:0}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Ug.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener(`resize`,this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener(`resize`,this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return R(`Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e,t);let n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let i=this.backend,a=this._pipelines,o=this._bindings,s=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);i.beginCompute(e);for(let n of c){if(a.has(n)===!1){let e=()=>{n.removeEventListener(`dispose`,e),a.delete(n),o.deleteForCompute(n),s.delete(n)};n.addEventListener(`dispose`,e);let t=n.onInitFunction;t!==null&&t.call(n,{renderer:this})}s.updateForCompute(n),o.updateForCompute(n);let r=o.getForCompute(n),c=a.getForCompute(n,r);i.compute(e,n,r,c,t)}i.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return ig(`Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw Error(`Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.`);return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){ig(`Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.`),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw Error(`Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.`);this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw Error(`Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before before using this method.`);this._textures.updateRenderTarget(e);let t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=zU.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=zU.copy(t).floor();else{z(`Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=zU.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?LU:IU;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&zU.setFromMatrixPosition(e.matrixWorld).applyMatrix4(RU);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,zU.z,null,i)}}else if(e.isLineLoop)z(`Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?LU:IU;if(!e.frustumCulled||a.intersectsObject(e,t)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),zU.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(RU)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s<c;s++){let c=o[s],l=a[c.materialIndex];l&&l.visible&&r.push(e,t,l,n,zU.z,c,i)}}else a.visible&&r.push(e,t,a,n,zU.z,null,i)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let n=r;r=this._renderLists.get(e,t),r.begin(),n.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}let a=e.children;for(let e=0,o=a.length;e<o;e++)this._projectObject(a[e],t,n,r,i)}_renderBundles(e,t,n){for(let r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,i){if(t.length>0){for(let{material:e}of t)e.side=1;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=0;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=2}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a<o;a++){let{object:o,geometry:s,material:c,group:l,clippingContext:u}=e[a];this._currentRenderObjectFunction(o,n,t,s,c,l,r,u,i)}}_getShadowNodes(e){let t=e.version,n=this._cacheShadowNodes.get(e);if(n===void 0||n.version!==t){let r=e.map!==null,i=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode,o=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,s=null,c=null,l=null;if(r||i||a||o){let t,n;if(a?(t=e.castShadowNode.rgb,n=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&ig("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=Y(0),n=G(1)),r&&(n=n.mul(tk(`map`,`texture`,e).a)),i&&(n=n.mul(e.colorNode.a)),c=GS(t,n),o){let t=e.maskShadowNode||e.maskNode;c=W(([e])=>(t.not().discard(),e))(c)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?s=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(s=e.positionNode),n={version:t,colorNode:c,depthNode:l,positionNode:s},this._cacheShadowNodes.set(e,n)}return n}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l=!1,u,d,f,p;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){let e=t.overrideMaterial;if(l=!0,u=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,f=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:n,positionNode:r}=this._getShadowNodes(i);this.shadowMap.type===3?e.side=i.shadowSide===null?i.side:i.shadowSide:e.side=i.shadowSide===null?BU[i.side]:i.shadowSide,t!==null&&(e.colorNode=t),n!==null&&(e.depthNode=n),r!==null&&(e.positionNode=r)}i=e}i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=0,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=2):this._handleObjectFunction(e,i,t,n,o,a,s,c),l&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p),e.onAfterRender(this,t,n,r,i,a)}hasCompatibility(e){return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);let l=this._nodes.needsRefresh(c);l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c)}_createObjectPipeline(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}},HU=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}};function UU(e){return e+(JP-e%JP)%JP}var WU=class extends HU{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return UU(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},GU=class extends WU{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}},KU=0,qU=class extends GU{constructor(e,t){super(`UniformBuffer_`+ KU++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}},JU=class extends GU{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map}addUniformUpdateRange(e){let t=e.index;if(this._updateRangeCache.has(t)!==!0){let n=this.updateRanges,r={start:e.offset,count:e.itemSize};n.push(r),this._updateRangeCache.set(t,r)}}clearUpdateRanges(){this._updateRangeCache.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n<r;n++){let r=this.uniforms[n],i=r.boundary,a=r.itemSize*e,o=t%JP,s=o%i,c=o+s;t+=s,c!==0&&JP-c<a&&(t+=JP-c),r.offset=t/e,r.index=n,t+=a}return Math.ceil(t/JP)*JP}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);z(`WebGPUUniformsGroup: Unsupported uniform type.`,e)}updateNumber(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i]!==r){let o=this._getBufferForType(a);o[i]=n[i]=r,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z||n[i+4]!==r.w){let o=this._getBufferForType(a);o[i+0]=n[i+0]=r.x,o[i+1]=n[i+1]=r.y,o[i+2]=n[i+2]=r.z,o[i+3]=n[i+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset;if(n[i+0]!==r.r||n[i+1]!==r.g||n[i+2]!==r.b){let a=this.buffer;a[i+0]=n[i+0]=r.r,a[i+1]=n[i+1]=r.g,a[i+2]=n[i+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;if(n[i+0]!==r[0]||n[i+1]!==r[1]||n[i+2]!==r[2]||n[i+4]!==r[3]||n[i+5]!==r[4]||n[i+6]!==r[5]||n[i+8]!==r[6]||n[i+9]!==r[7]||n[i+10]!==r[8]){let a=this.buffer;a[i+0]=n[i+0]=r[0],a[i+1]=n[i+1]=r[1],a[i+2]=n[i+2]=r[2],a[i+4]=n[i+4]=r[3],a[i+5]=n[i+5]=r[4],a[i+6]=n[i+6]=r[5],a[i+8]=n[i+8]=r[6],a[i+9]=n[i+9]=r[7],a[i+10]=n[i+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;return XU(n,r,i)===!1&&(this.buffer.set(r,i),YU(n,r,i),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`?new Int32Array(this.buffer.buffer):e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`?new Uint32Array(this.buffer.buffer):this.buffer}};function YU(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function XU(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}var ZU=0,QU=class extends JU{constructor(e,t){super(e),this.id=ZU++,this.groupNode=t,this.isNodeUniformsGroup=!0}},$U=class extends HU{constructor(e,t){super(e),this._texture=null,this._onTextureDispose=()=>{this.generation=null,this.version=-1},this.texture=t,this.version=t?t.version:-1,this.generation=null,this.samplerKey=``,this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener(`dispose`,this._onTextureDispose),this._texture=e,this.generation=null,this.version=-1,this._texture&&this._texture.addEventListener(`dispose`,this._onTextureDispose))}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t===e.version?!1:(this.version=e.version,!0)}clone(){let e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=-1},e.texture=this.texture,e}},eW=0,tW=class extends $U{constructor(e,t){super(e,t),this.id=eW++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}},nW=class extends tW{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},rW=class extends nW{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},iW=class extends nW{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}},aW={bitcast_int_uint:new sR(`uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }`),bitcast_uint_int:new sR(`uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }`)},oW={textureDimensions:`textureSize`,equals:`equal`,bitcast_float_int:`floatBitsToInt`,bitcast_int_float:`intBitsToFloat`,bitcast_uint_float:`uintBitsToFloat`,bitcast_float_uint:`floatBitsToUint`,bitcast_uint_int:`tsl_bitcast_uint_to_int`,bitcast_int_uint:`tsl_bitcast_int_to_uint`,floatpack_snorm_2x16:`packSnorm2x16`,floatpack_unorm_2x16:`packUnorm2x16`,floatpack_float16_2x16:`packHalf2x16`,floatunpack_snorm_2x16:`unpackSnorm2x16`,floatunpack_unorm_2x16:`unpackUnorm2x16`,floatunpack_float16_2x16:`unpackHalf2x16`},sW={low:`lowp`,medium:`mediump`,high:`highp`},cW={swizzleAssign:!0,storageBuffer:!1},lW={perspective:`smooth`,linear:`noperspective`},uW={centroid:`centroid`},dW=`
|
|
41
|
+
precision highp float;
|
|
42
|
+
precision highp int;
|
|
43
|
+
precision highp sampler2D;
|
|
44
|
+
precision highp sampler3D;
|
|
45
|
+
precision highp samplerCube;
|
|
46
|
+
precision highp sampler2DArray;
|
|
47
|
+
|
|
48
|
+
precision highp usampler2D;
|
|
49
|
+
precision highp usampler3D;
|
|
50
|
+
precision highp usamplerCube;
|
|
51
|
+
precision highp usampler2DArray;
|
|
52
|
+
|
|
53
|
+
precision highp isampler2D;
|
|
54
|
+
precision highp isampler3D;
|
|
55
|
+
precision highp isamplerCube;
|
|
56
|
+
precision highp isampler2DArray;
|
|
57
|
+
|
|
58
|
+
precision highp sampler2DShadow;
|
|
59
|
+
precision highp sampler2DArrayShadow;
|
|
60
|
+
precision highp samplerCubeShadow;
|
|
61
|
+
`,fW=class extends RH{constructor(e,t){super(e,t,new oU),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==``}_include(e){let t=aW[e];return t.build(this),this.addInclude(t),t}getMethod(e){return aW[e]!==void 0&&this._include(e),oW[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return``}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(this.getType(e.type)+` `+e.name);return`${this.getType(t.type)} ${t.name}( ${r.join(`, `)} ) {
|
|
62
|
+
|
|
63
|
+
${n.vars}
|
|
64
|
+
|
|
65
|
+
${n.code}
|
|
66
|
+
return ${n.result};
|
|
67
|
+
|
|
68
|
+
}`}setupPBO(e){let t=e.value;if(t.pbo===void 0){let e=t.array,n=t.count*t.itemSize,{itemSize:r}=t,i=t.array.constructor.name.toLowerCase().includes(`int`),a=i?zm:Rm;r===2?a=i?Vm:Bm:r===3?a=i?Hm:Pm:r===4&&(a=i?Um:Fm);let o={Float32Array:Em,Uint8Array:bm,Uint16Array:Cm,Uint32Array:Tm,Int8Array:xm,Int16Array:Sm,Int32Array:wm,Uint8ClampedArray:bm},s=2**Math.ceil(Math.log2(Math.sqrt(n/r))),c=Math.ceil(n/r/s);s*c*r<n&&c++;let l=s*c*r,u=new e.constructor(l);u.set(e,0),t.array=u;let d=new hy(t.array,s,c,a,o[t.array.constructor.name]||1015);d.needsUpdate=!0,d.isPBOTexture=!0;let f=new $E(d,null,null);f.setPrecision(`high`),t.pboNode=f,t.pbo=f.value,this.getUniformFromNode(t.pboNode,`texture`,this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?e.name:super.getPropertyName(e,t)}generatePBO(e){let{node:t,indexNode:n}=e,r=t.value;if(this.renderer.backend.has(r)){let e=this.renderer.backend.get(r);e.pbo=r.pbo}let i=this.getUniformFromNode(r.pboNode,`texture`,this.shaderStage,this.context.nodeName),a=this.getPropertyName(i);this.increaseUsage(n);let o=n.build(this,`uint`),s=this.getDataFromNode(e),c=s.propertyName;if(c===void 0){let n=this.getVarFromNode(e);c=this.getPropertyName(n);let i=this.getDataFromNode(t),l=i.propertySizeName;l===void 0&&(l=c+`Size`,this.getVarFromNode(t,l,`uint`),this.addLineFlowCode(`${l} = uint( textureSize( ${a}, 0 ).x )`,e),i.propertySizeName=l);let{itemSize:u}=r,d=`.`+kx.join(``).slice(0,u),f=`ivec2(${o} % ${l}, ${o} / ${l})`,p=this.generateTextureLoad(null,a,f,`0`,null,null),m=`vec4`;r.pbo.type===1014?m=`uvec4`:r.pbo.type===1013&&(m=`ivec4`),this.addLineFlowCode(`${c} = ${m}(${p})${d}`,e),s.propertyName=c}return c}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0`);let o;return o=i?a?`texelFetchOffset( ${t}, ivec3( ${n}, ${i} ), ${r}, ${a} )`:`texelFetch( ${t}, ivec3( ${n}, ${i} ), ${r} )`:a?`texelFetchOffset( ${t}, ${n}, ${r}, ${a} )`:`texelFetch( ${t}, ${n}, ${r} )`,e!==null&&e.isDepthTexture&&(o+=`.x`),o}generateTexture(e,t,n,r,i){return r&&(n=`vec3( ${n}, ${r} )`),e.isDepthTexture?i?`textureOffset( ${t}, ${n}, ${i} ).x`:`texture( ${t}, ${n} ).x`:i?`textureOffset( ${t}, ${n}, ${i} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureLodOffset( ${t}, ${n}, ${r}, ${a} )`:`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureOffset( ${t}, ${n}, ${a}, ${r} )`:`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r,i,a){return i&&(n=`vec3( ${n}, ${i} )`),a?`textureGradOffset( ${t}, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isCubeTexture?`texture( ${t}, vec4( ${n}, ${r} ) )`:i?a?`textureOffset( ${t}, vec4( ${n}, ${i}, ${r} ), ${a} )`:`texture( ${t}, vec4( ${n}, ${i}, ${r} ) )`:a?`textureOffset( ${t}, vec3( ${n}, ${r} ), ${a} )`:`texture( ${t}, vec3( ${n}, ${r} ) )`;z(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}getVars(e){let t=[],n=this.vars[e];if(n!==void 0)for(let e of n)t.push(`${this.getVar(e.type,e.name,e.count)};`);return t.join(`
|
|
69
|
+
`)}getUniforms(e){let t=this.uniforms[e],n=[],r={};for(let e of t){let t=null,i=!1;if(e.type===`texture`||e.type===`texture3D`){let n=e.node.value,r=``;(n.isDataTexture===!0||n.isData3DTexture===!0)&&(n.type===1014?r=`u`:n.type===1013&&(r=`i`)),t=e.type===`texture3D`&&n.isArrayTexture===!1?`${r}sampler3D ${e.name};`:n.compareFunction?n.isArrayTexture===!0?`sampler2DArrayShadow ${e.name};`:`sampler2DShadow ${e.name};`:n.isArrayTexture===!0||n.isDataArrayTexture===!0||n.isCompressedArrayTexture===!0?`${r}sampler2DArray ${e.name};`:`${r}sampler2D ${e.name};`}else if(e.type===`cubeTexture`)t=`samplerCube ${e.name};`;else if(e.type===`cubeDepthTexture`)t=e.node.value.compareFunction?`samplerCubeShadow ${e.name};`:`samplerCube ${e.name};`;else if(e.type===`buffer`){let n=e.node,r=this.getType(n.bufferType),i=n.bufferCount,a=i>0?i:``;t=`${n.name} {\n\t${r} ${e.name}[${a}];\n};\n`}else{let t=e.groupNode.name;if(r[t]===void 0){let e=this.uniformGroups[t];if(e!==void 0){let n=[];for(let t of e.uniforms){let e=t.getType(),r=this.getVectorType(e),i=t.nodeUniform.node.precision,a=`${r} ${t.name};`;i!==null&&(a=sW[i]+` `+a),n.push(` `+a)}r[t]=n}}i=!0}if(!i){let r=e.node.precision;r!==null&&(t=sW[r]+` `+t),t=`uniform `+t,n.push(t)}}let i=``;for(let e in r){let t=r[e];i+=this._getGLSLUniformStruct(e,t.join(`
|
|
70
|
+
`))+`
|
|
71
|
+
`}return i+=n.join(`
|
|
72
|
+
`),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==1013){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t=``;if(e===`vertex`||e===`compute`){let e=this.getAttributesArray(),n=0;for(let r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(`\t${n.type} ${n.name};`);return t.join(`
|
|
73
|
+
`)}getStructs(e){let t=[],n=this.structs[e],r=[];for(let e of n)if(e.output)for(let t of e.members)r.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let n=`struct `+e.name+` {
|
|
74
|
+
`;n+=this.getStructMembers(e),n+=`
|
|
75
|
+
};
|
|
76
|
+
`,t.push(n)}return r.length===0&&r.push(`layout( location = 0 ) out vec4 fragColor;`),`
|
|
77
|
+
`+r.join(`
|
|
78
|
+
`)+`
|
|
79
|
+
|
|
80
|
+
`+t.join(`
|
|
81
|
+
`)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){let e=lW[r.interpolationType]||r.interpolationType,i=uW[r.interpolationSampling]||``;t+=`${e} ${i} out ${n} ${r.name};\n`}else{let e=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${e}out ${n} ${r.name};\n`}else t+=`${n} ${r.name};\n`}else if(e===`fragment`){for(let e of n)if(e.needsInterpolation){let n=this.getType(e.type);if(e.interpolationType){let r=lW[e.interpolationType]||e.interpolationType,i=uW[e.interpolationSampling]||``;t+=`${r} ${i} in ${n} ${e.name};\n`}else{let r=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${r}in ${n} ${e.name};\n`}}}for(let n of this.builtins[e])t+=`${n};\n`;return t}getVertexIndex(){return`uint( gl_VertexID )`}getInstanceIndex(){return`uint( gl_InstanceID )`}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){z(`GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node`)}getInvocationSubgroupIndex(){z(`GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node`)}getSubgroupIndex(){z(`GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node`)}getDrawIndex(){return this.renderer.backend.extensions.has(`WEBGL_multi_draw`)?`uint( gl_DrawID )`:null}getFrontFacing(){return`gl_FrontFacing`}getFragCoord(){return`gl_FragCoord.xy`}getFragDepth(){return`gl_FragDepth`}enableExtension(e,t,n=this.shaderStage){let r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e===`vertex`){let t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has(`WEBGL_multi_draw`)&&this.enableExtension(`GL_ANGLE_multi_draw`,`require`,e)}let n=this.extensions[e];if(n!==void 0)for(let{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join(`
|
|
82
|
+
`)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=cW[e];if(t===void 0){let n;switch(t=!1,e){case`float32Filterable`:n=`OES_texture_float_linear`;break;case`clipDistance`:n=`WEBGL_clip_cull_distance`;break}if(n!==void 0){let e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}cW[e]=t}return t}isFlipY(){return!0}getUniformBufferLimit(){let e=this.renderer.backend.gl;return e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE)}enableHardwareClipping(e){this.enableExtension(`GL_ANGLE_clip_cull_distance`,`require`),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension(`GL_OVR_multiview2`,`require`,`fragment`),this.enableExtension(`GL_OVR_multiview2`,`require`,`vertex`),this.builtins.vertex.push(`layout(num_views = 2) in`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t=``;for(let n=0;n<e.length;n++){let r=e[n],i=this.getPropertyName(r.attributeNode);i&&(t+=`${r.varyingName} = ${i};\n\t`)}return t}_getGLSLUniformStruct(e,t){return`
|
|
83
|
+
layout( std140 ) uniform ${e} {
|
|
84
|
+
${t}
|
|
85
|
+
};`}_getGLSLVertexCode(e){return`#version 300 es
|
|
86
|
+
|
|
87
|
+
${this.getSignature()}
|
|
88
|
+
|
|
89
|
+
// extensions
|
|
90
|
+
${e.extensions}
|
|
91
|
+
|
|
92
|
+
// precision
|
|
93
|
+
${dW}
|
|
94
|
+
|
|
95
|
+
// uniforms
|
|
96
|
+
${e.uniforms}
|
|
97
|
+
|
|
98
|
+
// varyings
|
|
99
|
+
${e.varyings}
|
|
100
|
+
|
|
101
|
+
// attributes
|
|
102
|
+
${e.attributes}
|
|
103
|
+
|
|
104
|
+
// codes
|
|
105
|
+
${e.codes}
|
|
106
|
+
|
|
107
|
+
void main() {
|
|
108
|
+
|
|
109
|
+
// vars
|
|
110
|
+
${e.vars}
|
|
111
|
+
|
|
112
|
+
// transforms
|
|
113
|
+
${e.transforms}
|
|
114
|
+
|
|
115
|
+
// flow
|
|
116
|
+
${e.flow}
|
|
117
|
+
|
|
118
|
+
gl_PointSize = 1.0;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
`}_getGLSLFragmentCode(e){return`#version 300 es
|
|
122
|
+
|
|
123
|
+
${this.getSignature()}
|
|
124
|
+
|
|
125
|
+
// extensions
|
|
126
|
+
${e.extensions}
|
|
127
|
+
|
|
128
|
+
// precision
|
|
129
|
+
${dW}
|
|
130
|
+
|
|
131
|
+
// structs
|
|
132
|
+
${e.structs}
|
|
133
|
+
|
|
134
|
+
// uniforms
|
|
135
|
+
${e.uniforms}
|
|
136
|
+
|
|
137
|
+
// varyings
|
|
138
|
+
${e.varyings}
|
|
139
|
+
|
|
140
|
+
// codes
|
|
141
|
+
${e.codes}
|
|
142
|
+
|
|
143
|
+
void main() {
|
|
144
|
+
|
|
145
|
+
// vars
|
|
146
|
+
${e.vars}
|
|
147
|
+
|
|
148
|
+
// flow
|
|
149
|
+
${e.flow}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
`}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){let n=`// code
|
|
153
|
+
|
|
154
|
+
`;n+=this.flowCode[t];let r=this.flowNodes[t],i=r[r.length-1];for(let e of r){let r=this.getFlowData(e),a=e.name;a&&(n.length>0&&(n+=`
|
|
155
|
+
`),n+=`\t// flow -> ${a}\n\t`),n+=`${r.code}\n\t`,e===i&&t!==`compute`&&(n+=`// result
|
|
156
|
+
`,t===`vertex`?(n+=`gl_Position = `,n+=`${r.result};`):t===`fragment`&&(e.outputNode.isOutputStructNode||(n+=`fragColor = `,n+=`${r.result};`)))}let a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new nW(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`||t===`cubeDepthTexture`)o=new rW(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new iW(i.name,i.node,r),c.push(o);else if(t===`buffer`){i.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),n=t.buffer;n===void 0&&(e.name=`NodeBuffer_${e.id}`,n=new qU(e,r),n.name=e.name,t.buffer=n),c.push(n),o=n}else{let e=this.uniformGroups[s];e===void 0?(e=new QU(s,r),this.uniformGroups[s]=e,c.push(e)):c.indexOf(e)===-1&&c.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}},pW=null,mW=null,hW=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Jh.RENDER]:null,[Jh.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),n=this.renderer.info.frame,r;r=e.isComputeNode===!0?`c:`+this.renderer.info.compute.frameCalls:`r:`+this.renderer.info.render.frameCalls,t.timestampUID=r+`:`+e.id+`:f`+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith(`c:`)?Jh.COMPUTE:Jh.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){ig(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t)return;let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return pW||=new Pg,this.renderer.getDrawingBufferSize(pW)}setScissorTest(){}getClearColor(){let e=this.renderer;return mW||=new SF,e.getClearColor(mW),mW.getRGB(mW),mW}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?$h():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r183 webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}},gW=0,_W=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},vW=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(typeof Float16Array<`u`&&i instanceof Float16Array)l=r.HALF_FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===1013,id:gW++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new _W(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e<t;e++){let t=s[e];n.bufferSubData(o,t.start*r.BYTES_PER_ELEMENT,r,t.start,t.count)}i.clearUpdateRanges()}n.bindBuffer(o,null),a.version=i.version}destroyAttribute(e){let t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,{gl:n}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:i}=t.get(r),a=e.array,o=a.byteLength;n.bindBuffer(n.COPY_READ_BUFFER,i);let s=n.createBuffer();n.bindBuffer(n.COPY_WRITE_BUFFER,s),n.bufferData(n.COPY_WRITE_BUFFER,o,n.STREAM_READ),n.copyBufferSubData(n.COPY_READ_BUFFER,n.COPY_WRITE_BUFFER,0,0,o),await t.utils._clientWaitAsync();let c=new e.array.constructor(a.length);return n.bindBuffer(n.COPY_WRITE_BUFFER,s),n.getBufferSubData(n.COPY_WRITE_BUFFER,0,c),n.deleteBuffer(s),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),c.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}},yW,bW,xW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;yW={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT},bW={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new e_().fromArray(t),this.currentViewport=new e_().fromArray(n),this._tempVec4=new e_}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===0?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===1?t.cullFace(t.BACK):e===2?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){let r=this.gl,i=this.backend.drawBuffersIndexedExt;if(!i){ig(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`);return}for(let a=0;a<e.length;a++){let o=e[a],s=null;if(t!==null){let e=t.getBlendMode(o.name);e.blending===6?s=n:e.blending!==0&&(s=e)}else s=n;s===null?i.blendFuncSeparateiOES(a,r.ONE,r.ZERO,r.ONE,r.ZERO):this._setMRTBlendingIndex(a,s)}}_setMRTBlendingIndex(e,t){let{gl:n}=this,r=this.backend.drawBuffersIndexedExt,i=t.blending,a=t.blendSrc,o=t.blendDst,s=t.blendEquation,c=t.premultipliedAlpha;if(i===5){let n=t.blendSrcAlpha===null?a:t.blendSrcAlpha,i=t.blendDstAlpha===null?o:t.blendDstAlpha,c=t.blendEquationAlpha===null?s:t.blendEquationAlpha;r.blendEquationSeparateiOES(e,yW[s],yW[c]),r.blendFuncSeparateiOES(e,bW[a],bW[o],bW[n],bW[i])}else if(r.blendEquationSeparateiOES(e,n.FUNC_ADD,n.FUNC_ADD),c)switch(i){case 1:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.ONE,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break}else switch(i){case 1:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case 2:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case 3:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case 4:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break}}setBlending(e,t,n,r,i,a,o,s){let{gl:c}=this;if(e===0){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==5){if(e!==this.currentBlending||s!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==100||this.currentBlendEquationAlpha!==100)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=100,this.currentBlendEquationAlpha=100),s)switch(e){case 1:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFunc(c.ONE,c.ONE);break;case 3:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case 4:c.blendFuncSeparate(c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA,c.ZERO,c.ONE);break;default:z(`WebGLState: Invalid blending: `,e);break}else switch(e){case 1:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case 2:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE,c.ONE,c.ONE);break;case 3:z(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:z(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:z(`WebGLState: Invalid blending: `,e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=s}return}i||=t,a||=n,o||=r,(t!==this.currentBlendEquation||i!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(yW[t],yW[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(bW[n],bW[r],bW[a],bW[o]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=o),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get(`EXT_clip_control`);e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=ag[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(i)===!1){let{gl:e}=this;e.scissor(i.x,i.y,i.z,i.w),this.currentScissor.copy(i)}}viewport(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(i)===!1){let{gl:e}=this;e.viewport(i.x,i.y,i.z,i.w),this.currentViewport.copy(i)}}setScissorTest(e){let t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){let{gl:r}=this;e.side===2?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let i=e.side===1;t&&(i=!i),this.setFlipSided(i),e.blending===1&&e.transparent===!1?this.setBlending(0):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t<n?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,n){let{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram===e?!1:(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:n,currentBoundFramebuffers:r}=this;return r[e]===t?!1:(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:n}=this,r=[],i=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));let a=e.textures;if(r.length!==a.length||r[0]!==n.COLOR_ATTACHMENT0){for(let e=0,t=a.length;e<t;e++)r[e]=n.COLOR_ATTACHMENT0+e;r.length=a.length,i=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,i=!0);i&&n.drawBuffers(r)}activeTexture(e){let{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){let{gl:r,currentTextureSlot:i,currentBoundTextures:a,maxTextures:o}=this;n===void 0&&(n=i===null?r.TEXTURE0+o-1:i);let s=a[n];s===void 0&&(s={type:void 0,texture:void 0},a[n]=s),(s.type!==e||s.texture!==t)&&(i!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),s.type=e,s.texture=t)}bindBufferBase(e,t,n){let{gl:r}=this,i=`${e}-${t}`;return this.currentBoundBufferBases[i]===n?!1:(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[i]=n,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}},SW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=``){let{gl:n,extensions:r}=this,i,a=Ug.getTransfer(t);if(e===1009)return n.UNSIGNED_BYTE;if(e===1017)return n.UNSIGNED_SHORT_4_4_4_4;if(e===1018)return n.UNSIGNED_SHORT_5_5_5_1;if(e===35902)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===35899)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===1010)return n.BYTE;if(e===1011)return n.SHORT;if(e===1012)return n.UNSIGNED_SHORT;if(e===1013)return n.INT;if(e===1014)return n.UNSIGNED_INT;if(e===1015)return n.FLOAT;if(e===1016)return n.HALF_FLOAT;if(e===1021)return n.ALPHA;if(e===1022)return n.RGB;if(e===1023)return n.RGBA;if(e===1026)return n.DEPTH_COMPONENT;if(e===1027)return n.DEPTH_STENCIL;if(e===1028)return n.RED;if(e===1029)return n.RED_INTEGER;if(e===1030)return n.RG;if(e===1031)return n.RG_INTEGER;if(e===1033)return n.RGBA_INTEGER;if(e===33776||e===33777||e===33778||e===33779)if(a===`srgb`)if(i=r.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(e===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=r.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(e===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===35840||e===35841||e===35842||e===35843)if(i=r.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(e===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===36196||e===37492||e===37496||e===37488||e===37489||e===37490||e===37491)if(i=r.get(`WEBGL_compressed_texture_etc`),i!==null){if(e===36196||e===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(e===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(e===37488)return i.COMPRESSED_R11_EAC;if(e===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(e===37490)return i.COMPRESSED_RG11_EAC;if(e===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(e===37808||e===37809||e===37810||e===37811||e===37812||e===37813||e===37814||e===37815||e===37816||e===37817||e===37818||e===37819||e===37820||e===37821)if(i=r.get(`WEBGL_compressed_texture_astc`),i!==null){if(e===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===36492)if(i=r.get(`EXT_texture_compression_bptc`),i!==null){if(e===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===36283||e===36284||e===36285||e===36286)if(i=r.get(`EXT_texture_compression_rgtc`),i!==null){if(e===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(e===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===1020?n.UNSIGNED_INT_24_8:n[e]===void 0?null:n[e]}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}},CW=!1,wW,TW,EW,DW=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,CW===!1&&(this._init(),CW=!0)}_init(){let e=this.gl;wW={[um]:e.REPEAT,[dm]:e.CLAMP_TO_EDGE,[fm]:e.MIRRORED_REPEAT},TW={[pm]:e.NEAREST,[mm]:e.NEAREST_MIPMAP_NEAREST,[hm]:e.NEAREST_MIPMAP_LINEAR,[gm]:e.LINEAR,[_m]:e.LINEAR_MIPMAP_NEAREST,[vm]:e.LINEAR_MIPMAP_LINEAR},EW={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i=!1){let{gl:a,extensions:o}=this;if(e!==null){if(a[e]!==void 0)return a[e];R(`WebGLBackend: Attempt to use non-existing WebGL internal format '`+e+`'`)}let s=t;if(t===a.RED&&(n===a.FLOAT&&(s=a.R32F),n===a.HALF_FLOAT&&(s=a.R16F),n===a.UNSIGNED_BYTE&&(s=a.R8),n===a.UNSIGNED_SHORT&&(s=a.R16),n===a.UNSIGNED_INT&&(s=a.R32UI),n===a.BYTE&&(s=a.R8I),n===a.SHORT&&(s=a.R16I),n===a.INT&&(s=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.R8UI),n===a.UNSIGNED_SHORT&&(s=a.R16UI),n===a.UNSIGNED_INT&&(s=a.R32UI),n===a.BYTE&&(s=a.R8I),n===a.SHORT&&(s=a.R16I),n===a.INT&&(s=a.R32I)),t===a.RG&&(n===a.FLOAT&&(s=a.RG32F),n===a.HALF_FLOAT&&(s=a.RG16F),n===a.UNSIGNED_BYTE&&(s=a.RG8),n===a.UNSIGNED_SHORT&&(s=a.RG16),n===a.UNSIGNED_INT&&(s=a.RG32UI),n===a.BYTE&&(s=a.RG8I),n===a.SHORT&&(s=a.RG16I),n===a.INT&&(s=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RG8UI),n===a.UNSIGNED_SHORT&&(s=a.RG16UI),n===a.UNSIGNED_INT&&(s=a.RG32UI),n===a.BYTE&&(s=a.RG8I),n===a.SHORT&&(s=a.RG16I),n===a.INT&&(s=a.RG32I)),t===a.RGB){let e=i?Fh:Ug.getTransfer(r);n===a.FLOAT&&(s=a.RGB32F),n===a.HALF_FLOAT&&(s=a.RGB16F),n===a.UNSIGNED_BYTE&&(s=a.RGB8),n===a.UNSIGNED_SHORT&&(s=a.RGB16),n===a.UNSIGNED_INT&&(s=a.RGB32UI),n===a.BYTE&&(s=a.RGB8I),n===a.SHORT&&(s=a.RGB16I),n===a.INT&&(s=a.RGB32I),n===a.UNSIGNED_BYTE&&(s=e===`srgb`?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(s=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(s=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(s=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(s=a.RGB9_E5),n===a.UNSIGNED_INT_10F_11F_11F_REV&&(s=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RGB8UI),n===a.UNSIGNED_SHORT&&(s=a.RGB16UI),n===a.UNSIGNED_INT&&(s=a.RGB32UI),n===a.BYTE&&(s=a.RGB8I),n===a.SHORT&&(s=a.RGB16I),n===a.INT&&(s=a.RGB32I)),t===a.RGBA){let e=i?Fh:Ug.getTransfer(r);n===a.FLOAT&&(s=a.RGBA32F),n===a.HALF_FLOAT&&(s=a.RGBA16F),n===a.UNSIGNED_BYTE&&(s=a.RGBA8),n===a.UNSIGNED_SHORT&&(s=a.RGBA16),n===a.UNSIGNED_INT&&(s=a.RGBA32UI),n===a.BYTE&&(s=a.RGBA8I),n===a.SHORT&&(s=a.RGBA16I),n===a.INT&&(s=a.RGBA32I),n===a.UNSIGNED_BYTE&&(s=e===`srgb`?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(s=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(s=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(s=a.RGBA16UI),n===a.UNSIGNED_INT&&(s=a.RGBA32UI),n===a.BYTE&&(s=a.RGBA8I),n===a.SHORT&&(s=a.RGBA16I),n===a.INT&&(s=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_SHORT&&(s=a.DEPTH_COMPONENT16),n===a.UNSIGNED_INT&&(s=a.DEPTH_COMPONENT24),n===a.FLOAT&&(s=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(s=a.DEPTH24_STENCIL8),(s===a.R16F||s===a.R32F||s===a.RG16F||s===a.RG32F||s===a.RGBA16F||s===a.RGBA32F)&&o.get(`EXT_color_buffer_float`),s}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,a=Ug.getPrimaries(Ug.workingColorSpace),o=t.colorSpace===``?null:Ug.getPrimaries(t.colorSpace),s=t.colorSpace===``||a===o?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,s),n.texParameteri(e,n.TEXTURE_WRAP_S,wW[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,wW[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,wW[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,TW[t.magFilter]);let c=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===1006&&c?vm:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,TW[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,EW[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===1003||t.minFilter!==1005&&t.minFilter!==1008||t.type===1015&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i})}createTexture(e,t){let{gl:n,backend:r}=this,{levels:i,width:a,height:o,depth:s}=t,c=r.utils.convert(e.format,e.colorSpace),l=r.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,c,l,e.colorSpace,e.isVideoTexture),d=n.createTexture(),f=this.getGLTextureType(e);r.state.bindTexture(f,d),this.setTextureParameters(f,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,i,u,a,o,s):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,i,u,a,o,s):e.isVideoTexture||n.texStorage2D(f,i,u,a,o),r.set(e,{textureGPU:d,glTextureType:f,glFormat:c,glType:l,glInternalFormat:u})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{textureGPU:i,glTextureType:a,glFormat:o,glType:s}=r.get(t),{width:c,height:l}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,i),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,c,l,o,s,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t<r.length;t++){let a=r[t];e.isCompressedArrayTexture?e.format===n.RGBA?n.texSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,c,a.data):s===null?R(`WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()`):n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,a.data):s===null?R(`WebGLBackend: Unsupported compressed texture format`):n.compressedTexSubImage2D(n.TEXTURE_2D,t,0,0,a.width,a.height,s,a.data)}}else if(e.isCubeTexture){let a=t.images,o=e.mipmaps;for(let e=0;e<6;e++){let t=OW(a[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,r,i,s,c,t);for(let t=0;t<o.length;t++){let r=o[t],i=OW(r.images[e]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,i.width,i.height,s,c,i)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let r=t.image;if(e.layerUpdates.size>0){let t=Qb(r.width,r.height,e.format,e.type);for(let i of e.layerUpdates){let e=r.data.subarray(i*t/r.data.BYTES_PER_ELEMENT,(i+1)*t/r.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,i,r.width,r.height,1,s,c,e)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,r.width,r.height,r.depth,s,c,r.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e<t;e++){let t=a[e],r=OW(t);n.texSubImage2D(o,e,0,0,t.width,t.height,s,c,r)}else{let e=OW(t.image);n.texSubImage2D(o,0,0,0,r,i,s,c,e)}}}generateMipmaps(e){let{gl:t,backend:n}=this,{textureGPU:r,glTextureType:i}=n.get(e);n.state.bindTexture(i,r),t.generateMipmap(i)}deallocateRenderBuffers(e){let{gl:t,backend:n}=this;if(e){let r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(let e in r.framebuffers)t.deleteFramebuffer(r.framebuffers[e]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let e=0;e<r.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(r.msaaRenderbuffers[e]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){let{gl:n,backend:r}=this,{textureGPU:i,renderTarget:a}=r.get(e);this.deallocateRenderBuffers(a),t===!1&&n.deleteTexture(i),r.delete(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let{gl:o,backend:s}=this,{state:c}=this.backend,{textureGPU:l,glTextureType:u,glType:d,glFormat:f}=s.get(t);c.bindTexture(u,l);let p,m,h,g,_,v,y,b,x,S=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)p=n.max.x-n.min.x,m=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,g=n.min.x,_=n.min.y,v=n.isBox3?n.min.z:0;else{let t=2**-i;p=Math.floor(S.width*t),m=Math.floor(S.height*t),h=e.isDataArrayTexture||e.isArrayTexture?S.depth:e.isData3DTexture?Math.floor(S.depth*t):1,g=0,_=0,v=0}r===null?(y=0,b=0,x=0):(y=r.x,b=r.y,x=r.z),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);let C=o.getParameter(o.UNPACK_ROW_LENGTH),w=o.getParameter(o.UNPACK_IMAGE_HEIGHT),T=o.getParameter(o.UNPACK_SKIP_PIXELS),E=o.getParameter(o.UNPACK_SKIP_ROWS),D=o.getParameter(o.UNPACK_SKIP_IMAGES);o.pixelStorei(o.UNPACK_ROW_LENGTH,S.width),o.pixelStorei(o.UNPACK_IMAGE_HEIGHT,S.height),o.pixelStorei(o.UNPACK_SKIP_PIXELS,g),o.pixelStorei(o.UNPACK_SKIP_ROWS,_),o.pixelStorei(o.UNPACK_SKIP_IMAGES,v);let O=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,k=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let n=s.get(e),r=s.get(t),u=s.get(n.renderTarget),d=s.get(r.renderTarget),f=u.framebuffers[n.cacheKey],S=d.framebuffers[r.cacheKey];c.bindFramebuffer(o.READ_FRAMEBUFFER,f),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,S);for(let e=0;e<h;e++)O&&(o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,n.textureGPU,i,v+e),o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e)),o.blitFramebuffer(g,_,p,m,y,b,p,m,o.DEPTH_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,null),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||s.has(e)){let t=s.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=o.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=o.createFramebuffer()),c.bindFramebuffer(o.READ_FRAMEBUFFER,this._srcFramebuffer),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<h;e++)O?o.framebufferTextureLayer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,t.textureGPU,i,v+e):o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t.textureGPU,i),k?o.framebufferTextureLayer(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,l,a,x+e):o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,l,a),i===0?k?o.copyTexSubImage3D(u,a,y,b,x+e,g,_,p,m):o.copyTexSubImage2D(u,a,y,b,g,_,p,m):o.blitFramebuffer(g,_,p,m,y,b,p,m,o.COLOR_BUFFER_BIT,o.NEAREST);c.bindFramebuffer(o.READ_FRAMEBUFFER,null),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,null)}else k?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(u,a,y,b,x,p,m,h,f,S.data):o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S):e.isDataTexture?o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S.data):e.isCompressedTexture?o.compressedTexSubImage2D(o.TEXTURE_2D,a,y,b,S.width,S.height,f,S.data):o.texSubImage2D(o.TEXTURE_2D,a,y,b,p,m,f,d,S);o.pixelStorei(o.UNPACK_ROW_LENGTH,C),o.pixelStorei(o.UNPACK_IMAGE_HEIGHT,w),o.pixelStorei(o.UNPACK_SKIP_PIXELS,T),o.pixelStorei(o.UNPACK_SKIP_ROWS,E),o.pixelStorei(o.UNPACK_SKIP_IMAGES,D),a===0&&t.generateMipmaps&&o.generateMipmap(u),c.unbindTexture()}copyFramebufferToTexture(e,t,n){let{gl:r}=this,{state:i}=this.backend,{textureGPU:a}=this.backend.get(e),{x:o,y:s,z:c,w:l}=n,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;r===!0?this.extensions.get(`WEBGL_multisampled_render_to_texture`).renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u):n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();o.state.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i*m,g=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.bufferData(s.PIXEL_PACK_BUFFER,h,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let _=new p(h/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,g),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,_),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.deleteFramebuffer(d),_}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){let{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}};function OW(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var kW=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},AW=class{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}},jW={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-s3tc`,EXT_texture_compression_bptc:`texture-compression-bc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`},MW=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;r<n;r++)this.render(e[r],t[r]);else{this.index===0?s.multiDrawArraysWEBGL(i,e,0,t,0,n):s.multiDrawElementsWEBGL(i,t,0,this.type,e,0,n);let r=0;for(let e=0;e<n;e++)r+=t[e];o.update(a,r,1)}}renderMultiDrawInstances(e,t,n,r){let{extensions:i,mode:a,object:o,info:s}=this;if(n===0)return;let c=i.get(`WEBGL_multi_draw`);if(c===null)for(let i=0;i<n;i++)this.renderInstances(e[i],t[i],r[i]);else{this.index===0?c.multiDrawArraysInstancedWEBGL(a,e,0,t,0,r,0,n):c.multiDrawElementsInstancedWEBGL(a,t,0,this.type,e,0,r,0,n);let i=0;for(let e=0;e<n;e++)i+=t[e]*r[e];s.update(o,i,1)}}},NW=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(R(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},PW=class extends NW{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension(`EXT_disjoint_timer_query_webgl2`)||e.getExtension(`EXT_disjoint_timer_query`),!this.ext){R(`EXT_disjoint_timer_query not supported; timestamps will be disabled.`),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return ig(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){z(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){z(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=new Map;for(let[t,n]of this.queryOffsets)if(this.queryStates.get(n)===`ended`){let r=this.queries[n];e.set(t,this.resolveQuery(r))}if(e.size===0)return this.lastValue;let t={},n=[];for(let[r,i]of e){let e=r.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);n.includes(a)===!1&&n.push(a),t[a]===void 0&&(t[a]=0);let o=await i;this.timestamps.set(r,o),t[a]+=o}let r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return z(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&=(clearTimeout(n),null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(o,1);return}let r=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(r)/1e6)}catch(e){z(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}},FW=class extends hW{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new kW(this),this.capabilities=new AW(this),this.attributeUtils=new vW(this),this.textureUtils=new DW(this),this.bufferRenderer=new MW(this),this.state=new xW(this),this.utils=new SW(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.extensions.get(`EXT_clip_control`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`),this.drawBuffersIndexedExt=this.extensions.get(`OES_draw_buffers_indexed`),t.reversedDepthBuffer===!0&&this.extensions.has(`EXT_clip_control`)&&this.state.setReversedDepth(!0)}get coordinateSystem(){return Kh}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&R(`WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new PW(this.gl,e,2048));let n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){!this.disjoint||!this.trackTimestamp||this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.viewport(0,0,e,n)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:n}=this.getDrawingBufferSize();t.scissor(0,0,e,n)}this.initTimestampQuery(Jh.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e<o.length;e++){let t=o[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=i,this._resolveRenderTarget(e),i!==null){if(this._setFramebuffer(i),i.viewport)this.updateViewport(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.viewport(0,0,e,t)}if(i.scissor)this.updateScissor(i);else{let{width:e,height:t}=this.getDrawingBufferSize();n.scissor(0,0,e,t)}}this.prepareTimestampBuffer(Jh.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let o=0;for(let t=0;t<n.length;t++){let a=n[t];a!==null&&i.getQueryParameter(a,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(a,i.QUERY_RESULT)===0&&e.add(r[t]),n[t]=null,i.deleteQuery(a),o++)}o<n.length?requestAnimationFrame(a):t.occluded=e};a()}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.viewportValue;t.viewport(n,e.height-a-r,i,a)}updateScissor(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.scissorValue;t.scissor(n,e.height-a-r,i,a)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,r=null,i=!0,a=!0){let{gl:o,renderer:s}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let c=0;if(e&&(c|=o.COLOR_BUFFER_BIT),t&&(c|=o.DEPTH_BUFFER_BIT),n&&(c|=o.STENCIL_BUFFER_BIT),c!==0){let l;l=r.clearColorValue?r.clearColorValue:this.getClearColor();let u=s.getClearDepth(),d=s.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)o.clearColor(l.r,l.g,l.b,l.a),o.clear(c);else{if(i&&this._setFramebuffer(r),e)for(let e=0;e<r.textures.length;e++)e===0?o.clearBufferfv(o.COLOR,e,[l.r,l.g,l.b,l.a]):o.clearBufferfv(o.COLOR,e,[0,0,0,1]);t&&n?o.clearBufferfi(o.DEPTH_STENCIL,0,u,d):t?o.clearBufferfv(o.DEPTH,0,[u]):n&&o.clearBufferiv(o.STENCIL,0,[d]),i&&a&&this._resolveRenderTarget(r)}}}beginCompute(e){let{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(Jh.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,i=null){let{state:a,gl:o}=this;this.discard===!1&&(a.enable(o.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:s,transformBuffers:c,attributes:l}=this.get(r),u=this._getVaoKey(l),d=this.vaoCache[u];d===void 0?this.vaoCache[u]=this._createVao(l):a.setVertexState(d),a.useProgram(s),this._bindUniforms(n);let f=this._getTransformFeedback(c);o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,f),o.beginTransformFeedback(o.POINTS),i=i===null?t.count:i,Array.isArray(i)?(ig(`WebGLBackend.compute(): The count parameter must be a single number, not an array.`),i=i[0]):i&&typeof i==`object`&&i.isIndirectStorageBufferAttribute&&(ig(`WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute`),i=t.count),l[0].isStorageInstancedBufferAttribute?o.drawArraysInstanced(o.POINTS,0,1,i):o.drawArrays(o.POINTS,0,i),o.endTransformFeedback(),o.bindTransformFeedback(o.TRANSFORM_FEEDBACK,null);for(let e=0;e<c.length;e++){let t=c[e];t.pbo&&this.has(t.pbo)&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){let{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(Jh.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinant()<0;c.setMaterial(r,d,a),i.mrt!==null&&i.textures!==null&&c.setMRTBlending(i.textures,i.mrt,r),c.useProgram(o);let f=e.getAttributes(),p=this.get(f),m=p.vaoGPU;if(m===void 0){let e=this._getVaoKey(f);m=this.vaoCache[e],m===void 0&&(m=this._createVao(f),this.vaoCache[e]=m,p.vaoGPU=m)}let h=e.getIndex(),g=h===null?null:this.get(h).bufferGPU;c.setVertexState(m,g);let _=l.lastOcclusionObject;if(_!==t&&_!==void 0){if(_!==null&&_.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let v=this.bufferRenderer;t.isPoints?v.mode=s.POINTS:t.isLineSegments?v.mode=s.LINES:t.isLine?v.mode=s.LINE_STRIP:t.isLineLoop?v.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),v.mode=s.LINES):v.mode=s.TRIANGLES;let{vertexCount:y,instanceCount:b}=u,{firstVertex:x}=u;if(v.object=t,h!==null){x*=h.array.BYTES_PER_ELEMENT;let e=this.get(h);v.index=h.count,v.type=e.type}else v.index=0;let S=()=>{t.isBatchedMesh?t._multiDrawInstances===null?this.hasFeature(`WEBGL_multi_draw`)?v.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):ig(`WebGLBackend: WEBGL_multi_draw not supported.`):(ig(`WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),v.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):b>1?v.renderInstances(x,y,b):v.render(x,y)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n<i;n++){let r=s.createBuffer();e[0]=n,s.bindBuffer(s.UNIFORM_BUFFER,r),s.bufferData(s.UNIFORM_BUFFER,e,s.STATIC_DRAW),t.push(r)}n.indexesGPU=t}let a=this.get(i),o=this.renderer.getPixelRatio(),l=this._currentContext.renderTarget,u=this._isRenderCameraDepthArray(this._currentContext),d=this._currentContext.activeCubeFace;if(u){let e=this.get(l.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=l;for(let e=0,n=r.length;e<n;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=d,this._currentContext.activeCubeFace=d}}for(let i=0,l=r.length;i<l;i++){let l=r[i];if(t.layers.test(l.layers)){u&&(this.renderer._activeCubeFace=i,this._currentContext.activeCubeFace=i,this._setFramebuffer(this._currentContext));let t=l.viewport;if(t!==void 0){let n=t.x*o,r=t.y*o,i=t.width*o,a=t.height*o;c.viewport(Math.floor(n),Math.floor(e.context.height-a-r),Math.floor(i),Math.floor(a))}c.bindBufferBase(s.UNIFORM_BUFFER,a.index,n.indexesGPU[i]),S()}this._currentContext.activeCubeFace=d,this.renderer._activeCubeFace=d}}else S()}needsRenderUpdate(){return!1}getRenderCacheKey(){return``}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}updateSampler(){return``}createNodeBuilder(e,t){return new fW(e,t)}createProgram(e){let t=this.gl,{stage:n,code:r}=e,i=n===`fragment`?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,r),t.compileShader(i),this.set(e,{shaderGPU:i})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let n=this.gl,r=e.pipeline,{fragmentProgram:i,vertexProgram:a}=r,o=n.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU;if(n.attachShader(o,s),n.attachShader(o,c),n.linkProgram(o),this.set(r,{programGPU:o,fragmentShader:s,vertexShader:c}),t!==null&&this.parallel){let i=new Promise(t=>{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(`
|
|
157
|
+
`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`
|
|
158
|
+
`)}_getShaderErrors(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+`
|
|
159
|
+
|
|
160
|
+
`+i+`
|
|
161
|
+
|
|
162
|
+
`+this._handleSource(e.getShaderSource(t),r)}else return i}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){let r=this.gl,i=(r.getProgramInfoLog(e)||``).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError==`function`)this.renderer.debug.onShaderError(r,e,n,t);else{let a=this._getShaderErrors(r,n,`vertex`),o=this._getShaderErrors(r,t,`fragment`);z(`THREE.WebGLProgram: Shader Error `+r.getError()+` - VALIDATE_STATUS `+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
|
|
163
|
+
|
|
164
|
+
Program Info Log: `+i+`
|
|
165
|
+
`+a+`
|
|
166
|
+
`+o)}else i!==``&&R(`WebGLProgram: Program Info Log:`,i)}}_completeCompile(e,t){let{state:n,gl:r}=this,{programGPU:i,fragmentShader:a,vertexShader:o}=this.get(t);r.getProgramParameter(i,r.LINK_STATUS)===!1&&this._logProgramError(i,a,o),n.useProgram(i);let s=e.getBindings();this._setupBindings(s,i),this.set(t,{programGPU:i})}createComputePipeline(e,t){let{state:n,gl:r}=this,i={stage:`fragment`,code:`#version 300 es
|
|
167
|
+
precision highp float;
|
|
168
|
+
void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;e<l.length;e++){let t=l[e];u.push(t.varyingName),d.push(t.attributeNode)}r.attachShader(o,s),r.attachShader(o,c),r.transformFeedbackVaryings(o,u,r.SEPARATE_ATTRIBS),r.linkProgram(o),r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,s,c),n.useProgram(o),this._setupBindings(t,o);let f=a.attributes,p=[],m=[];for(let e=0;e<f.length;e++){let t=f[e].node.attribute;p.push(t),this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER)}for(let e=0;e<d.length;e++){let t=d[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER);let n=this.get(t);m.push(n)}this.set(e,{programGPU:o,transformBuffers:m,attributes:p})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let e=0,n=0;for(let r of t){this.set(r,{textures:n,uniformBuffers:e});for(let t of r.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this,n=this.get(e),r=n.uniformBuffers,i=n.textures;for(let n of e.bindings){let e=this.get(n);if(n.isUniformsGroup||n.isUniformBuffer){let i=n.buffer,{bufferGPU:a}=this.get(i);a===void 0?(a=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,a),t.bufferData(t.UNIFORM_BUFFER,i.byteLength,t.DYNAMIC_DRAW),this.set(i,{bufferGPU:a})):t.bindBuffer(t.UNIFORM_BUFFER,a);let o=n.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,a),o.length===0)t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW);else{let e=Zh(i),n=e?1:i.BYTES_PER_ELEMENT;for(let r=0,a=o.length;r<a;r++){let a=o[r],s=a.start*n,c=a.count*n,l=s*(e?i.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,l,i,s,c)}}e.index=r++,e.bufferGPU=a,this.set(n,e)}else if(n.isSampledTexture){let{textureGPU:t,glTextureType:r}=this.get(n.texture);e.index=i++,e.textureGPU=t,e.glTextureType=r,this.set(n,e)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let n=this.get(e).bufferGPU,r=e.buffer,i=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,n),i.length===0)t.bufferData(t.UNIFORM_BUFFER,r,t.DYNAMIC_DRAW);else{let e=Zh(r),n=e?1:r.BYTES_PER_ELEMENT;for(let a=0,o=i.length;a<o;a++){let o=i[a],s=o.start*n,c=o.count*n,l=s*(e?r.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,l,r,s,c)}}}}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(jW).filter(t=>jW[t]===e),n=this.extensions;for(let e=0;e<t.length;e++)if(n.has(t[e]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,r,i,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}hasCompatibility(e){return e===Yh.TEXTURE_COMPARE?!0:super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:n}=this;this._setFramebuffer(e),n.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:n}=this,r=null;if(e.textures!==null){let i=e.renderTarget,a=this.get(i),{samples:o,depthBuffer:s,stencilBuffer:c}=i,l=i.isCubeRenderTarget===!0,u=i.isRenderTarget3D===!0,d=i.depth>1,f=i.isXRRenderTarget===!0,p=f===!0&&i._hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=vF(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,i)}else{a.framebuffers[y]=b;for(let n=0;n<r.length;n++){let a=r[n],s=this.get(a);s.renderTarget=e.renderTarget,s.cacheKey=y;let c=t.COLOR_ATTACHMENT0+n;if(i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,c,s.textureGPU,0,o,0,2);else if(u||d){let e=this.renderer._activeCubeFace,n=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,c,s.textureGPU,n,e)}else if(v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,0,o);else{let e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,e)}}}let f=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let n=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(n,e,0,v),a.xrDepthRenderbuffer=n,s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,f,t.RENDERBUFFER,n)}else if(e.depthTexture!==null){s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let n=this.get(e.depthTexture);if(n.renderTarget=e.renderTarget,n.cacheKey=y,i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,f,n.textureGPU,0,o,0,2);else if(p&&v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,f,n.textureGPU,0,e)}else if(e.depthTexture.isCubeTexture){let e=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0)}a.depthInvalidationArray=s}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.renderer._activeCubeFace,i=this.get(e.depthTexture),a=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,a,i.textureGPU,0,r)}if((f||v||i.multiview)&&i._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.get(e.textures[0]);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,r.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0);let s=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i._autoAllocateDepthBuffer===!0){let e=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{let n=this.get(e.depthTexture);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}}}if(o>0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n<l.length;n++){i[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,i[n]),r.push(t.COLOR_ATTACHMENT0+n);let a=e.textures[n],s=this.get(a);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,s.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,i[n])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=m,a.msaaRenderbuffers=i,s&&h===void 0){h=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(h,e,o),a.depthRenderbuffer=h;let n=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r.push(n)}a.invalidationArray=r}r=a.msaaFrameBuffer}else r=b;n.drawBuffers(e,b)}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t=``;for(let n=0;n<e.length;n++){let r=this.get(e[n]);t+=`:`+r.id}return t}_createVao(e){let{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let n=0;n<e.length;n++){let r=e[n],i=this.get(r);t.bindBuffer(t.ARRAY_BUFFER,i.bufferGPU),t.enableVertexAttribArray(n);let a,o;r.isInterleavedBufferAttribute===!0?(a=r.data.stride*i.bytesPerElement,o=r.offset*i.bytesPerElement):(a=0,o=0),i.isInteger?t.vertexAttribIPointer(n,r.itemSize,i.type,a,o):t.vertexAttribPointer(n,r.itemSize,i.type,r.normalized,a,o),r.isInstancedBufferAttribute&&!r.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,r.meshPerAttribute):r.isInterleavedBufferAttribute&&r.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,r.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t=``;for(let n=0;n<e.length;n++)t+=`:`+e[n].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;let{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let t=0;t<e.length;t++){let n=e[t];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,t,n.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){let n=this.gl;for(let r of e)for(let e of r.bindings){let r=this.get(e).index;if(e.isUniformsGroup||e.isUniformBuffer){let i=n.getUniformBlockIndex(t,e.name);n.uniformBlockBinding(t,i,r)}else if(e.isSampledTexture){let i=n.getUniformLocation(t,e.name);n.uniform1i(i,r)}}}_bindUniforms(e){let{gl:t,state:n}=this;for(let r of e)for(let e of r.bindings){let r=this.get(e),i=r.index;e.isUniformsGroup||e.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,i,r.bufferGPU):e.isSampledTexture&&n.bindTexture(r.glTextureType,r.textureGPU,t.TEXTURE0+i)}}_resolveRenderTarget(e){let{gl:t,state:n}=this,r=e.renderTarget;if(e.textures!==null&&r){let i=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){let a=i.framebuffers[e.getCacheKey()],o=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));let s=i.msaaFrameBuffer,c=i.msaaRenderbuffers,l=e.textures,u=l.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,s),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),u)for(let e=0;e<l.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let n=0;n<l.length;n++){if(u){let{textureGPU:e}=this.get(l[n]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c[n]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){let{x:n,y:r,width:i,height:a}=e.scissorValue,s=e.height-a-r;t.blitFramebuffer(n,s,n+i,s+a,n,s,n+i,s+a,o,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o,t.NEAREST)}if(u)for(let e=0;e<l.length;e++){let{textureGPU:n}=this.get(l[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,n,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,i.invalidationArray)}else if(r.resolveDepthBuffer===!1&&i.framebuffers){let r=i.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,r),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}},IW={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`},LW=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},RW={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},zW={Store:`store`},BW={Load:`load`,Clear:`clear`},VW={CCW:`ccw`,CW:`cw`},HW={None:`none`,Back:`back`},UW={Uint16:`uint16`,Uint32:`uint32`},$={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rg11b10ufloat`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-unorm-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},WW={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},GW={Linear:`linear`,Nearest:`nearest`},KW={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},qW={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},JW={None:0,All:15},YW={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},XW={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},ZW={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},QW={NonFiltering:`non-filtering`,Comparison:`comparison`},$W={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},eG={TwoD:`2d`,ThreeD:`3d`},tG={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},nG={All:`all`},rG={Vertex:`vertex`,Instance:`instance`},iG={CoreFeaturesAndLimits:`core-features-and-limits`,DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionBCSliced3D:`texture-compression-bc-sliced-3d`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TextureCompressionASTCSliced3D:`texture-compression-astc-sliced-3d`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,Float32Blendable:`float32-blendable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`,TextureFormatsTier1:`texture-formats-tier1`,TextureFormatsTier2:`texture-formats-tier2`},aG={"texture-compression-s3tc":`texture-compression-bc`,"texture-compression-etc1":`texture-compression-etc2`},oG=class extends $U{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},sG=class extends WU{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}},cG=0,lG=class extends sG{constructor(e,t){super(`StorageBuffer_`+ cG++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Tx.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}},uG=class extends KP{constructor(e){super(),this.device=e,this.mipmapSampler=e.createSampler({minFilter:GW.Linear}),this.flipYSampler=e.createSampler({minFilter:GW.Nearest}),this.flipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),this.noFlipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM}),this.transferPipelines={},this.mipmapShaderModule=e.createShaderModule({label:`mipmap`,code:`
|
|
169
|
+
struct VarysStruct {
|
|
170
|
+
@builtin( position ) Position: vec4f,
|
|
171
|
+
@location( 0 ) vTex : vec2f,
|
|
172
|
+
@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
@group( 0 ) @binding ( 2 )
|
|
176
|
+
var<uniform> flipY: u32;
|
|
177
|
+
|
|
178
|
+
@vertex
|
|
179
|
+
fn mainVS(
|
|
180
|
+
@builtin( vertex_index ) vertexIndex : u32,
|
|
181
|
+
@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {
|
|
182
|
+
|
|
183
|
+
var Varys : VarysStruct;
|
|
184
|
+
|
|
185
|
+
var pos = array(
|
|
186
|
+
vec2f( -1, -1 ),
|
|
187
|
+
vec2f( -1, 3 ),
|
|
188
|
+
vec2f( 3, -1 ),
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
let p = pos[ vertexIndex ];
|
|
192
|
+
let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );
|
|
193
|
+
Varys.vTex = p * mult + vec2f( 0.5 );
|
|
194
|
+
Varys.Position = vec4f( p, 0, 1 );
|
|
195
|
+
Varys.vBaseArrayLayer = instanceIndex;
|
|
196
|
+
|
|
197
|
+
return Varys;
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@group( 0 ) @binding( 0 )
|
|
202
|
+
var imgSampler : sampler;
|
|
203
|
+
|
|
204
|
+
@group( 0 ) @binding( 1 )
|
|
205
|
+
var img2d : texture_2d<f32>;
|
|
206
|
+
|
|
207
|
+
@fragment
|
|
208
|
+
fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
|
|
209
|
+
|
|
210
|
+
return textureSample( img2d, imgSampler, Varys.vTex );
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@group( 0 ) @binding( 1 )
|
|
215
|
+
var img2dArray : texture_2d_array<f32>;
|
|
216
|
+
|
|
217
|
+
@fragment
|
|
218
|
+
fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
|
|
219
|
+
|
|
220
|
+
return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const faceMat = array(
|
|
225
|
+
mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x
|
|
226
|
+
mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x
|
|
227
|
+
mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y
|
|
228
|
+
mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y
|
|
229
|
+
mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z
|
|
230
|
+
mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
@group( 0 ) @binding( 1 )
|
|
234
|
+
var imgCube : texture_cube<f32>;
|
|
235
|
+
|
|
236
|
+
@fragment
|
|
237
|
+
fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
|
|
238
|
+
|
|
239
|
+
return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
`})}getTransferPipeline(e,t){t||=`2d-array`;let n=`${e}-${t}`,r=this.transferPipelines[n];return r===void 0&&(r=this.device.createRenderPipeline({label:`mipmap-${e}-${t}`,vertex:{module:this.mipmapShaderModule},fragment:{module:this.mipmapShaderModule,entryPoint:`main_${t.replace(`-`,`_`)}`,targets:[{format:e}]},layout:`auto`}),this.transferPipelines[n]=r),r}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size,o=this.device.createTexture({size:{width:i,height:a},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),s=this.getTransferPipeline(r,e.textureBindingViewDimension),c=this.getTransferPipeline(r,o.textureBindingViewDimension),l=this.device.createCommandEncoder({}),u=(e,t,n,r,i,a)=>{let o=e.getBindGroupLayout(0),s=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t.createView({dimension:t.textureBindingViewDimension||`2d-array`,baseMipLevel:0,mipLevelCount:1})},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}}]}),c=l.beginRenderPass({colorAttachments:[{view:r.createView({dimension:`2d`,baseMipLevel:0,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1}),loadOp:BW.Clear,storeOp:zW.Store}]});c.setPipeline(e),c.setBindGroup(0,s),c.draw(3,1,0,n),c.end()};u(s,e,n,o,0,!1),u(c,o,0,e,n,!0),this.device.queue.submit([l.finish()]),o.destroy()}generateMipmaps(e,t=null){let n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),i=t||this.device.createCommandEncoder({label:`mipmapEncoder`});this._mipmapRunBundles(i,r),t===null&&this.device.queue.submit([i.finish()]),n.layers=r}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||`2d-array`,n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),i=[];for(let a=1;a<e.mipLevelCount;a++)for(let o=0;o<e.depthOrArrayLayers;o++){let s=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:e.createView({dimension:t,baseMipLevel:a-1,mipLevelCount:1})},{binding:2,resource:{buffer:this.noFlipUniformBuffer}}]}),c={colorAttachments:[{view:e.createView({dimension:`2d`,baseMipLevel:a,mipLevelCount:1,baseArrayLayer:o,arrayLayerCount:1}),loadOp:BW.Clear,storeOp:zW.Store}]},l=this.device.createRenderBundleEncoder({colorFormats:[e.format]});l.setPipeline(n),l.setBindGroup(0,s),l.draw(3,1,0,o),i.push({renderBundles:[l.finish()],passDescriptor:c})}return i}_mipmapRunBundles(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=e.beginRenderPass(n.passDescriptor);i.executeBundles(n.renderBundles),i.end()}}},dG={512:`never`,513:`less`,514:`equal`,515:`less-equal`,516:`greater`,518:`greater-equal`,519:`always`,517:`not-equal`},fG=[0,1,3,2,4,5],pG=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,n=e.minFilter+`-`+e.magFilter+`-`+e.wrapS+`-`+e.wrapT+`-`+(e.wrapR||`0`)+`-`+e.anisotropy+`-`+(e.compareFunction||0),r=this._samplerCache.get(n);if(r===void 0){let i={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};e.isDepthTexture&&e.compareFunction===null&&(i.magFilter=GW.Nearest,i.minFilter=GW.Nearest,i.mipmapFilter=GW.Nearest),i.magFilter===GW.Linear&&i.minFilter===GW.Linear&&i.mipmapFilter===GW.Linear&&(i.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&t.hasCompatibility(Yh.TEXTURE_COMPARE)&&(i.compare=dG[e.compareFunction]),r={sampler:t.device.createSampler(i),usedTimes:0},this._samplerCache.set(n,r)}let i=t.get(e);if(i.sampler!==r.sampler){if(i.sampler!==void 0){let e=this._samplerCache.get(i.samplerKey);e.usedTimes--,e.usedTimes===0&&this._samplerCache.delete(i.samplerKey)}i.samplerKey=n,i.sampler=r.sampler,r.usedTimes++}return n}createDefaultTexture(e){let t,n=mG(e);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(n):this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){let n=this.backend,r=n.get(e);if(r.initialized)throw Error(`WebGPUTextureUtils: Texture already initialized.`);if(e.isExternalTexture){r.texture=e.sourceTexture,r.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:i,height:a,depth:o,levels:s}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let c=this._getDimension(e),l=e.internalFormat||t.format||mG(e,n.device);r.format=l;let{samples:u,primarySamples:d,isMSAA:f}=n.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(p|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&l!==$.RGB9E5UFloat&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m={label:e.name,size:{width:i,height:a,depthOrArrayLayers:o},mipLevelCount:s,sampleCount:d,dimension:c,format:l,usage:p};if(l===void 0){R(`WebGPURenderer: Texture format not supported.`),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=tG.Cube);try{r.texture=n.device.createTexture(m)}catch{R(`WebGPURenderer: Failed to create texture with descriptor:`,m),this.createDefaultTexture(e);return}if(f){let e=Object.assign({},m);e.label+=`-msaa`,e.sampleCount=u,e.mipLevelCount=1,r.msaaTexture=n.device.createTexture(e)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e,t=!1){let n=this.backend,r=n.get(e);r.texture!==void 0&&t===!1&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),n.delete(e)}generateMipmaps(e,t=null){let n=this.backend.get(e);this._generateMipmaps(n.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:n,height:r}=e.getDrawingBufferSize(),i=e.renderer.currentSamples,a=t.colorTexture,o=e.get(a);if(a.width===n&&a.height===r&&a.samples===i)return o.texture;let s=o.texture;return s&&s.destroy(),s=e.device.createTexture({label:`colorBuffer`,size:{width:n,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),a.source.width=n,a.source.height=r,a.samples=i,o.texture=s,s}getDepthBuffer(e=!0,t=!1){let n=this.backend,r=n.renderer.getCanvasTarget(),{width:i,height:a}=n.getDrawingBufferSize(),o=n.renderer.currentSamples,s=r.depthTexture;if(s.width===i&&s.height===a&&s.samples===o&&s.depth===e&&s.stencil===t)return n.get(s).texture;let c=n.get(s).texture,l,u;if(t?(l=Lm,u=Am):e&&(l=Im,u=Tm),c!==void 0){if(s.image.width===i&&s.image.height===a&&s.format===l&&s.type===u&&s.samples===o)return c;this.destroyTexture(s)}return s.name=`depthBuffer`,s.format=l,s.type=u,s.image.width=i,s.image.height=a,s.samples=o,this.createTexture(s,{width:i,height:a}),n.get(s).texture}updateTexture(e,t){let n=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:i}=n;if(!(e.isRenderTargetTexture||i===void 0)){if(e.isDataTexture)if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyBufferToTexture(a,n.texture,i,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,n.texture,i,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let r=0;r<t.image.depth;r++)this._copyBufferToTexture(t.image,n.texture,i,r,e.flipY,r);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,i);else if(r.length>0)for(let t=0,a=r.length;t<a;t++){let a=r[t];this._copyImageToTexture(a,n.texture,i,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,n.texture,i,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}async copyTextureToBuffer(e,t,n,r,i,a){let o=this.backend.device,s=this.backend.get(e),c=s.texture,l=s.textureDescriptorGPU.format,u=this._getBytesPerTexel(l),d=r*u;d=Math.ceil(d/256)*256;let f=o.createBuffer({size:(i-1)*d+r*u,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),p=o.createCommandEncoder();p.copyTextureToBuffer({texture:c,origin:{x:t,y:n,z:a}},{buffer:f,bytesPerRow:d},{width:r,height:i});let m=this._getTypedArrayType(l);return o.queue.submit([p.finish()]),await f.mapAsync(GPUMapMode.READ),new m(f.getMappedRange())}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let n=new $g;n.minFilter=pm,n.magFilter=pm,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){let n=new jy;n.minFilter=pm,n.magFilter=pm,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){let r=e.images,i=e.mipmaps;for(let a=0;a<6;a++){let o=r[a],s=e.flipY===!0?fG[a]:a;o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha);for(let r=0;r<i.length;r++){let o=i[r].images[a];o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,e.flipY,0,r+1):this._copyImageToTexture(o,t,n,s,e.flipY,e.premultiplyAlpha,r+1)}}}_copyImageToTexture(e,t,n,r,i,a,o=0){let s=this.backend.device,c=o>0?e.width:n.size.width,l=o>0?e.height:n.size.height;try{s.queue.copyExternalImageToTexture({source:e,flipY:i},{texture:t,mipLevel:o,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:c,height:l,depthOrArrayLayers:1})}catch{}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new uG(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0,o=0){let s=this.backend.device,c=e.data,l=this._getBytesPerTexel(n.format),u=e.width*l;s.queue.writeTexture({texture:t,mipLevel:o,origin:{x:0,y:0,z:r}},c,{offset:e.width*e.height*l*a,bytesPerRow:u},{width:e.width,height:e.height,depthOrArrayLayers:1}),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n){let r=this.backend.device,i=this._getBlockData(n.format),a=n.size.depthOrArrayLayers>1;for(let o=0;o<e.length;o++){let s=e[o],c=s.width,l=s.height,u=a?n.size.depthOrArrayLayers:1,d=Math.ceil(c/i.width)*i.byteLength,f=d*Math.ceil(l/i.height);for(let e=0;e<u;e++)r.queue.writeTexture({texture:t,mipLevel:o,origin:{x:0,y:0,z:e}},s.data,{offset:e*f,bytesPerRow:d,rowsPerImage:Math.ceil(l/i.height)},{width:Math.ceil(c/i.width)*i.width,height:Math.ceil(l/i.height)*i.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===$.BC1RGBAUnorm||e===$.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===$.BC2RGBAUnorm||e===$.BC2RGBAUnormSRGB||e===$.BC3RGBAUnorm||e===$.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===$.BC4RUnorm||e===$.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===$.BC5RGUnorm||e===$.BC5RGSnorm||e===$.BC6HRGBUFloat||e===$.BC6HRGBFloat||e===$.BC7RGBAUnorm||e===$.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===$.ETC2RGB8Unorm||e===$.ETC2RGB8UnormSRGB||e===$.ETC2RGB8A1Unorm||e===$.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===$.ETC2RGBA8Unorm||e===$.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===$.EACR11Unorm||e===$.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===$.EACRG11Unorm||e===$.EACRG11Snorm||e===$.ASTC4x4Unorm||e===$.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===$.ASTC5x4Unorm||e===$.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===$.ASTC5x5Unorm||e===$.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===$.ASTC6x5Unorm||e===$.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===$.ASTC6x6Unorm||e===$.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===$.ASTC8x5Unorm||e===$.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===$.ASTC8x6Unorm||e===$.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===$.ASTC8x8Unorm||e===$.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===$.ASTC10x5Unorm||e===$.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===$.ASTC10x6Unorm||e===$.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===$.ASTC10x8Unorm||e===$.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===$.ASTC10x10Unorm||e===$.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===$.ASTC12x10Unorm||e===$.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===$.ASTC12x12Unorm||e===$.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=WW.ClampToEdge;return e===1e3?t=WW.Repeat:e===1002&&(t=WW.MirrorRepeat),t}_convertFilterMode(e){let t=GW.Linear;return(e===1003||e===1004||e===1005)&&(t=GW.Nearest),t}_getBytesPerTexel(e){if(e===$.R8Unorm||e===$.R8Snorm||e===$.R8Uint||e===$.R8Sint)return 1;if(e===$.R16Uint||e===$.R16Sint||e===$.R16Float||e===$.RG8Unorm||e===$.RG8Snorm||e===$.RG8Uint||e===$.RG8Sint)return 2;if(e===$.R32Uint||e===$.R32Sint||e===$.R32Float||e===$.RG16Uint||e===$.RG16Sint||e===$.RG16Float||e===$.RGBA8Unorm||e===$.RGBA8UnormSRGB||e===$.RGBA8Snorm||e===$.RGBA8Uint||e===$.RGBA8Sint||e===$.BGRA8Unorm||e===$.BGRA8UnormSRGB||e===$.RGB9E5UFloat||e===$.RGB10A2Unorm||e===$.RG11B10UFloat||e===$.Depth32Float||e===$.Depth24Plus||e===$.Depth24PlusStencil8||e===$.Depth32FloatStencil8)return 4;if(e===$.RG32Uint||e===$.RG32Sint||e===$.RG32Float||e===$.RGBA16Uint||e===$.RGBA16Sint||e===$.RGBA16Float)return 8;if(e===$.RGBA32Uint||e===$.RGBA32Sint||e===$.RGBA32Float)return 16}_getTypedArrayType(e){if(e===$.R8Uint)return Uint8Array;if(e===$.R8Sint)return Int8Array;if(e===$.R8Unorm)return Uint8Array;if(e===$.R8Snorm)return Int8Array;if(e===$.RG8Uint)return Uint8Array;if(e===$.RG8Sint)return Int8Array;if(e===$.RG8Unorm)return Uint8Array;if(e===$.RG8Snorm)return Int8Array;if(e===$.RGBA8Uint)return Uint8Array;if(e===$.RGBA8Sint)return Int8Array;if(e===$.RGBA8Unorm||e===$.RGBA8UnormSRGB)return Uint8Array;if(e===$.RGBA8Snorm)return Int8Array;if(e===$.R16Uint)return Uint16Array;if(e===$.R16Sint)return Int16Array;if(e===$.RG16Uint)return Uint16Array;if(e===$.RG16Sint)return Int16Array;if(e===$.RGBA16Uint)return Uint16Array;if(e===$.RGBA16Sint)return Int16Array;if(e===$.R16Float||e===$.RG16Float||e===$.RGBA16Float)return Uint16Array;if(e===$.R32Uint)return Uint32Array;if(e===$.R32Sint)return Int32Array;if(e===$.R32Float)return Float32Array;if(e===$.RG32Uint)return Uint32Array;if(e===$.RG32Sint)return Int32Array;if(e===$.RG32Float)return Float32Array;if(e===$.RGBA32Uint)return Uint32Array;if(e===$.RGBA32Sint)return Int32Array;if(e===$.RGBA32Float)return Float32Array;if(e===$.BGRA8Unorm||e===$.BGRA8UnormSRGB)return Uint8Array;if(e===$.RGB10A2Unorm||e===$.RGB9E5UFloat||e===$.RG11B10UFloat)return Uint32Array;if(e===$.Depth32Float)return Float32Array;if(e===$.Depth24Plus||e===$.Depth24PlusStencil8)return Uint32Array;if(e===$.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return t=e.is3DTexture||e.isData3DTexture?eG.ThreeD:eG.TwoD,t}};function mG(e,t=null){let n=e.format,r=e.type,i=e.colorSpace,a=Ug.getTransfer(i),o;if(e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(n){case Wm:case Gm:o=a===`srgb`?$.BC1RGBAUnormSRGB:$.BC1RGBAUnorm;break;case Km:o=a===`srgb`?$.BC2RGBAUnormSRGB:$.BC2RGBAUnorm;break;case qm:o=a===`srgb`?$.BC3RGBAUnormSRGB:$.BC3RGBAUnorm;break;case Sh:o=$.BC4RUnorm;break;case Ch:o=$.BC4RSnorm;break;case wh:o=$.BC5RGUnorm;break;case Th:o=$.BC5RGSnorm;break;case yh:o=a===`srgb`?$.BC7RGBAUnormSRGB:$.BC7RGBAUnorm;break;case $m:case Qm:o=a===`srgb`?$.ETC2RGB8UnormSRGB:$.ETC2RGB8Unorm;break;case eh:o=a===`srgb`?$.ETC2RGBA8UnormSRGB:$.ETC2RGBA8Unorm;break;case th:o=$.EACR11Unorm;break;case nh:o=$.EACR11Snorm;break;case rh:o=$.EACRG11Unorm;break;case ih:o=$.EACRG11Snorm;break;case ah:o=a===`srgb`?$.ASTC4x4UnormSRGB:$.ASTC4x4Unorm;break;case oh:o=a===`srgb`?$.ASTC5x4UnormSRGB:$.ASTC5x4Unorm;break;case sh:o=a===`srgb`?$.ASTC5x5UnormSRGB:$.ASTC5x5Unorm;break;case ch:o=a===`srgb`?$.ASTC6x5UnormSRGB:$.ASTC6x5Unorm;break;case lh:o=a===`srgb`?$.ASTC6x6UnormSRGB:$.ASTC6x6Unorm;break;case uh:o=a===`srgb`?$.ASTC8x5UnormSRGB:$.ASTC8x5Unorm;break;case dh:o=a===`srgb`?$.ASTC8x6UnormSRGB:$.ASTC8x6Unorm;break;case fh:o=a===`srgb`?$.ASTC8x8UnormSRGB:$.ASTC8x8Unorm;break;case ph:o=a===`srgb`?$.ASTC10x5UnormSRGB:$.ASTC10x5Unorm;break;case mh:o=a===`srgb`?$.ASTC10x6UnormSRGB:$.ASTC10x6Unorm;break;case hh:o=a===`srgb`?$.ASTC10x8UnormSRGB:$.ASTC10x8Unorm;break;case gh:o=a===`srgb`?$.ASTC10x10UnormSRGB:$.ASTC10x10Unorm;break;case _h:o=a===`srgb`?$.ASTC12x10UnormSRGB:$.ASTC12x10Unorm;break;case vh:o=a===`srgb`?$.ASTC12x12UnormSRGB:$.ASTC12x12Unorm;break;case Fm:o=a===`srgb`?$.RGBA8UnormSRGB:$.RGBA8Unorm;break;default:z(`WebGPURenderer: Unsupported texture format.`,n)}else switch(n){case Fm:switch(r){case xm:o=$.RGBA8Snorm;break;case Sm:o=$.RGBA16Sint;break;case Cm:o=$.RGBA16Uint;break;case Tm:o=$.RGBA32Uint;break;case wm:o=$.RGBA32Sint;break;case bm:o=a===`srgb`?$.RGBA8UnormSRGB:$.RGBA8Unorm;break;case Dm:o=$.RGBA16Float;break;case Em:o=$.RGBA32Float;break;default:z(`WebGPURenderer: Unsupported texture type with RGBAFormat.`,r)}break;case Pm:switch(r){case jm:o=$.RGB9E5UFloat;break;case Mm:o=$.RG11B10UFloat;break;default:z(`WebGPURenderer: Unsupported texture type with RGBFormat.`,r)}break;case Rm:switch(r){case xm:o=$.R8Snorm;break;case Sm:o=$.R16Sint;break;case Cm:o=$.R16Uint;break;case Tm:o=$.R32Uint;break;case wm:o=$.R32Sint;break;case bm:o=$.R8Unorm;break;case Dm:o=$.R16Float;break;case Em:o=$.R32Float;break;default:z(`WebGPURenderer: Unsupported texture type with RedFormat.`,r)}break;case Bm:switch(r){case xm:o=$.RG8Snorm;break;case Sm:o=$.RG16Sint;break;case Cm:o=$.RG16Uint;break;case Tm:o=$.RG32Uint;break;case wm:o=$.RG32Sint;break;case bm:o=$.RG8Unorm;break;case Dm:o=$.RG16Float;break;case Em:o=$.RG32Float;break;default:z(`WebGPURenderer: Unsupported texture type with RGFormat.`,r)}break;case Im:switch(r){case Cm:o=$.Depth16Unorm;break;case Tm:o=$.Depth24Plus;break;case Em:o=$.Depth32Float;break;default:z(`WebGPURenderer: Unsupported texture type with DepthFormat.`,r)}break;case Lm:switch(r){case Am:o=$.Depth24PlusStencil8;break;case Em:t&&t.features.has(iG.Depth32FloatStencil8)===!1&&z(`WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.`),o=$.Depth32FloatStencil8;break;default:z(`WebGPURenderer: Unsupported texture type with DepthStencilFormat.`,r)}break;case zm:switch(r){case wm:o=$.R32Sint;break;case Tm:o=$.R32Uint;break;default:z(`WebGPURenderer: Unsupported texture type with RedIntegerFormat.`,r)}break;case Vm:switch(r){case wm:o=$.RG32Sint;break;case Tm:o=$.RG32Uint;break;default:z(`WebGPURenderer: Unsupported texture type with RGIntegerFormat.`,r)}break;case Um:switch(r){case wm:o=$.RGBA32Sint;break;case Tm:o=$.RGBA32Uint;break;default:z(`WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.`,r)}break;default:z(`WebGPURenderer: Unsupported texture format.`,n)}return o}var hG=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,gG=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,_G={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2<f32>":`vec2`,"vec2<i32>":`ivec2`,"vec2<u32>":`uvec2`,"vec2<bool>":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3<f32>":`vec3`,"vec3<i32>":`ivec3`,"vec3<u32>":`uvec3`,"vec3<bool>":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4<f32>":`vec4`,"vec4<i32>":`ivec4`,"vec4<u32>":`uvec4`,"vec4<bool>":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2<f32>":`mat2`,mat2x2f:`mat2`,"mat3x3<f32>":`mat3`,mat3x3f:`mat3`,"mat4x4<f32>":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},vG=e=>{e=e.trim();let t=e.match(hG);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=gG.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e<r.length;e++){let{name:t,type:n}=r[e],i=n;i.startsWith(`ptr`)?i=`pointer`:(i.startsWith(`texture`)&&(i=n.split(`<`)[0]),i=_G[i]),a.push(new BH(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1];return{type:_G[s]||s,inputs:a,name:c,inputsCode:n,blockCode:o,outputType:s}}else throw Error(`FunctionNode: Function is not a WGSL code.`)},yG=class extends eU{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=vG(e);super(t,n,r),this.inputsCode=i,this.blockCode=a,this.outputType=o}getCode(e=this.name){let t=this.outputType===`void`?``:`-> `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},bG=class extends $H{parseFunction(e){return new yG(e)}},xG={[Tx.READ_ONLY]:`read`,[Tx.WRITE_ONLY]:`write`,[Tx.READ_WRITE]:`read_write`},SG={[um]:`repeat`,[dm]:`clamp`,[fm]:`mirror`},CG={vertex:LW.VERTEX,fragment:LW.FRAGMENT,compute:LW.COMPUTE},wG={instance:!0,swizzleAssign:!1,storageBuffer:!0},TG={"^^":`tsl_xor`},EG={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3<f32>`,vec2:`vec2<f32>`,ivec2:`vec2<i32>`,uvec2:`vec2<u32>`,bvec2:`vec2<bool>`,vec3:`vec3<f32>`,ivec3:`vec3<i32>`,uvec3:`vec3<u32>`,bvec3:`vec3<bool>`,vec4:`vec4<f32>`,ivec4:`vec4<i32>`,uvec4:`vec4<u32>`,bvec4:`vec4<bool>`,mat2:`mat2x2<f32>`,mat3:`mat3x3<f32>`,mat4:`mat4x4<f32>`},DG={},OG={tsl_xor:new sR(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new sR(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new sR(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new sR(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new sR(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new sR(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new sR(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new sR(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new sR(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new sR(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new sR(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new sR(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new sR(`
|
|
243
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
244
|
+
|
|
245
|
+
let res = vec2f( iRes );
|
|
246
|
+
|
|
247
|
+
let uvScaled = coord * res;
|
|
248
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
249
|
+
|
|
250
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
251
|
+
|
|
252
|
+
let uv = uvWrapping - 0.5;
|
|
253
|
+
let iuv = floor( uv );
|
|
254
|
+
let f = fract( uv );
|
|
255
|
+
|
|
256
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
257
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
258
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
259
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
260
|
+
|
|
261
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
`),biquadraticTextureArray:new sR(`
|
|
265
|
+
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
|
|
266
|
+
|
|
267
|
+
let res = vec2f( iRes );
|
|
268
|
+
|
|
269
|
+
let uvScaled = coord * res;
|
|
270
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
271
|
+
|
|
272
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
273
|
+
|
|
274
|
+
let uv = uvWrapping - 0.5;
|
|
275
|
+
let iuv = floor( uv );
|
|
276
|
+
let f = fract( uv );
|
|
277
|
+
|
|
278
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
|
|
279
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
|
|
280
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
|
|
281
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
|
|
282
|
+
|
|
283
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
`)},kG={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`,floatpack_snorm_2x16:`pack2x16snorm`,floatpack_unorm_2x16:`pack2x16unorm`,floatpack_float16_2x16:`pack2x16float`,floatunpack_snorm_2x16:`unpack2x16snorm`,floatunpack_unorm_2x16:`unpack2x16unorm`,floatunpack_float16_2x16:`unpack2x16float`},AG=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(AG+=`diagnostic( off, derivative_uniformity );
|
|
287
|
+
`);var jG=class extends RH{constructor(e,t){super(e,t,new bG),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,r,i,a=this.shaderStage){return a===`fragment`?r?i?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:i?`textureSample( ${t}, ${t}_sampler, ${n}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,`0`,r)}generateTextureSampleLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateWrapFunction(e){let t=`tsl_coord_${SG[e.wrapS]}S_${SG[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?`3d`:`2d`}T`,n=DG[t];if(n===void 0){let r=[],i=e.is3DTexture||e.isData3DTexture?`vec3f`:`vec2f`,a=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`,o=(e,t)=>{e===1e3?(r.push(OG.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===1001?(r.push(OG.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===1002?(r.push(OG.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,R(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};o(e.wrapS,`x`),a+=`,
|
|
288
|
+
`,o(e.wrapT,`y`),(e.is3DTexture||e.isData3DTexture)&&(a+=`,
|
|
289
|
+
`,o(e.wrapR,`z`)),a+=`
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
`,DG[t]=n=new sR(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,o,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(e),c=s>1;o=e.is3DTexture||e.isData3DTexture?`vec3<u32>`:`vec2<u32>`,a=c||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:``}`,i=new GT(new PE(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new GT(new PE(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new GT(new PE(`6u`,`u32`)))}return i.build(this)}generateFilteredTexture(e,t,n,r,i=`0u`,a){let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,i);return r&&(n=`${n} + vec2<f32>(${r}) / ${s}`),a?(this._include(`biquadraticTextureArray`),`tsl_biquadraticTexture_array( ${t}, ${o}( ${n} ), ${s}, u32( ${a} ), u32( ${i} ) )`):(this._include(`biquadraticTexture`),`tsl_biquadraticTexture( ${t}, ${o}( ${n} ), ${s}, u32( ${i} ) )`)}generateTextureLod(e,t,n,r,i,a=`0u`){if(e.isCubeTexture===!0){i&&(n=`${n} + vec3<f32>(${i})`);let r=e.isDepthTexture?`u32`:`f32`;return`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}( ${a} ) )`}let o=this.generateWrapFunction(e),s=this.generateTextureDimension(e,t,a),c=e.is3DTexture||e.isData3DTexture?`vec3`:`vec2`,l=c===`vec3`?`vec3<u32>( 1, 1, 1 )`:`vec2<u32>( 1, 1 )`;i&&(n=`${n} + ${c}<f32>(${i}) / ${c}<f32>( ${s} )`);let u=`${c}<f32>( 0 )`,d=`${c}<f32>( ${s} - ${l} )`;return n=`${c}<u32>( clamp( floor( ${o}( ${n} ) * ${c}<f32>( ${s} ) ), ${u}, ${d} ) )`,this.generateTextureLoad(e,t,n,a,r,null)}generateStorageTextureLoad(e,t,n,r,i,a){a&&(n=`${n} + ${a}`);let o;return o=i?`textureLoad( ${t}, ${n}, ${i} )`:`textureLoad( ${t}, ${n} )`,o}generateTextureLoad(e,t,n,r,i,a){r===null&&(r=`0u`),a&&(n=`${n} + ${a}`);let o;return i?o=`textureLoad( ${t}, ${n}, ${i}, u32( ${r} ) )`:(o=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=`.x`)),o}generateTextureStore(e,t,n,r,i){let a;return a=r?`textureStore( ${t}, ${n}, ${r}, ${i} )`:`textureStore( ${t}, ${n}, ${i} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(Yh.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!==`float`||!this.isAvailable(`float32Filterable`)&&e.isDataTexture===!0&&e.type===1015||this.isSampleCompare(e)===!1&&e.minFilter===1003&&e.magFilter===1003||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i,a=this.shaderStage){let o=null;return o=this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,i,`0`,a):this._generateTextureSample(e,t,n,r,i,a),o}generateTextureGrad(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${i}, ${r[0]}, ${r[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;z(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;z(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureLevel(e,t,n,r,i,a){return this.isUnfilterable(e)===!1?i?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r,i):this.generateTextureLod(e,t,n,i,a,r)}generateTextureBias(e,t,n,r,i,a,o=this.shaderStage){if(o===`fragment`)return i?a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;z(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t===`vertex`)return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let t=e.name,n=e.type;return n===`texture`||n===`cubeTexture`||n===`cubeDepthTexture`||n===`storageTexture`||n===`texture3D`?t:n===`buffer`||n===`storageBuffer`||n===`indirectStorageBuffer`?this.isCustomStruct(e)?t:t+`.value`:e.groupNode.name+`.`+t}return super.getPropertyName(e)}getOutputStructName(){return`output`}getFunctionOperator(e){let t=TG[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:e.isAtomic===!0?(R(`WebGPURenderer: Atomic operations are only supported in compute shaders.`),Tx.READ_WRITE):Tx.READ_ONLY}getStorageAccess(e,t){return xG[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let o,s=e.groupNode,c=s.name,l=this.getBindGroupArray(c,n);if(t===`texture`||t===`cubeTexture`||t===`cubeDepthTexture`||t===`storageTexture`||t===`texture3D`){let r=null,a=this.getNodeAccess(e,n);if(t===`texture`||t===`storageTexture`?r=e.value.is3DTexture===!0?new iW(i.name,i.node,s,a):new nW(i.name,i.node,s,a):t===`cubeTexture`||t===`cubeDepthTexture`?r=new rW(i.name,i.node,s,a):t===`texture3D`&&(r=new iW(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.mipLevel=r.store?e.mipLevel:0,r.setVisibility(CG[n]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&r.store===!1){let e=new oG(`${i.name}_sampler`,i.node,s);e.setVisibility(CG[n]),l.push(e,r),o=[e,r]}else l.push(r),o=[r]}else if(t===`buffer`||t===`storageBuffer`||t===`indirectStorageBuffer`){let a=this.getSharedDataFromNode(e),c=a.buffer;c===void 0&&(c=new(t===`buffer`?qU:lG)(e,s),a.buffer=c),c.setVisibility(c.getVisibility()|CG[n]),l.push(c),o=c,i.name=r||`NodeBuffer_`+i.id}else{let e=this.uniformGroups[c];e===void 0&&(e=new QU(c,s),e.setVisibility(LW.VERTEX|LW.FRAGMENT|LW.COMPUTE),this.uniformGroups[c]=e),l.indexOf(e)===-1&&l.push(e),o=this.getNodeUniform(i,t);let n=o.name;e.uniforms.some(e=>e.name===n)||e.addUniform(o)}a.uniformGPU=o}return i}getBuiltin(e,t,n,r=this.shaderStage){let i=this.builtins[r]||(this.builtins[r]=new Map);return i.has(e)===!1&&i.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`vertex_index`,`vertexIndex`,`u32`,`attribute`):`vertexIndex`}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+` : `+this.getType(e.type));let i=`fn ${t.name}( ${r.join(`, `)} ) -> ${this.getType(t.type)} {
|
|
294
|
+
${n.vars}
|
|
295
|
+
${n.code}
|
|
296
|
+
`;return n.result&&(i+=`\treturn ${n.result};\n`),i+=`
|
|
297
|
+
}
|
|
298
|
+
`,i}getInstanceIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`instance_index`,`instanceIndex`,`u32`,`attribute`):`instanceIndex`}getInvocationLocalIndex(){return this.getBuiltin(`local_invocation_index`,`invocationLocalIndex`,`u32`,`attribute`)}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`)}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_invocation_id`,`invocationSubgroupIndex`,`u32`,`attribute`)}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_id`,`subgroupIndex`,`u32`,`attribute`)}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin(`front_facing`,`isFront`,`bool`)}getFragCoord(){return this.getBuiltin(`position`,`fragCoord`,`vec4<f32>`)+`.xy`}getFragDepth(){return`output.`+this.getBuiltin(`frag_depth`,`depth`,`f32`,`output`)}getClipDistance(){return`varyings.hw_clip_distances`}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],n=this.directives[e];if(n!==void 0)for(let e of n)t.push(`enable ${e};`);return t.join(`
|
|
299
|
+
`)}enableSubGroups(){this.enableDirective(`subgroups`)}enableSubgroupsF16(){this.enableDirective(`subgroups-f16`)}enableClipDistances(){this.enableDirective(`clip_distances`)}enableShaderF16(){this.enableDirective(`f16`)}enableDualSourceBlending(){this.enableDirective(`dual_source_blending`)}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin(`clip_distances`,`hw_clip_distances`,`array<f32, ${e} >`,`vertex`)}getBuiltins(e){let t=[],n=this.builtins[e];if(n!==void 0)for(let{name:e,property:r,type:i}of n.values())t.push(`@builtin( ${e} ) ${r} : ${i}`);return t.join(`,
|
|
300
|
+
`)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!==`compute`)return;let t=[];for(let{name:e,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){let a=this.getType(r);t.push(`var<${n}> ${e}: array< ${a}, ${i} >;`)}return t.join(`
|
|
301
|
+
`)}getAttributes(e){let t=[];if(e===`compute`&&(this.getBuiltin(`global_invocation_id`,`globalId`,`vec3<u32>`,`attribute`),this.getBuiltin(`workgroup_id`,`workgroupId`,`vec3<u32>`,`attribute`),this.getBuiltin(`local_invocation_id`,`localId`,`vec3<u32>`,`attribute`),this.getBuiltin(`num_workgroups`,`numWorkgroups`,`vec3<u32>`,`attribute`),this.renderer.hasFeature(`subgroups`)&&(this.enableDirective(`subgroups`,e),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`))),e===`vertex`||e===`compute`){let e=this.getBuiltins(`attribute`);e&&t.push(e);let n=this.getAttributesArray();for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.name,a=this.getType(r.type);t.push(`@location( ${e} ) ${i} : ${a}`)}}return t.join(`,
|
|
302
|
+
`)}getStructMembers(e){let t=[];for(let n of e.members){let r=e.output?`@location( `+n.index+` ) `:``,i=this.getType(n.type);n.atomic&&(i=`atomic< `+i+` >`),t.push(`\t${r+n.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins(`output`)}`),t.join(`,
|
|
303
|
+
`)}getStructs(e){let t=``,n=this.structs[e];if(n.length>0){let e=[];for(let t of n){let n=`struct ${t.name} {\n`;n+=this.getStructMembers(t),n+=`
|
|
304
|
+
};`,e.push(n)}t=`
|
|
305
|
+
`+e.join(`
|
|
306
|
+
|
|
307
|
+
`)+`
|
|
308
|
+
`}return t}getVar(e,t,n=null){let r=`var ${t} : `;return n===null?r+=this.getType(e):r+=this.generateArrayDeclaration(e,n),r}getVars(e){let t=[],n=this.vars[e];if(n!==void 0)for(let e of n)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join(`
|
|
309
|
+
`)}\n`}getVaryings(e){let t=[];if(e===`vertex`&&this.getBuiltin(`position`,`builtinClipSpace`,`vec4<f32>`,`vertex`),e===`vertex`||e===`fragment`){let n=this.varyings,r=this.vars[e];for(let i=0;i<n.length;i++){let a=n[i];if(a.needsInterpolation){let e=`@location( ${i} )`;if(a.interpolationType){let t=a.interpolationSampling===null?` )`:`, ${a.interpolationSampling} )`;e+=` @interpolate( ${a.interpolationType}${t}`}else /^(int|uint|ivec|uvec)/.test(a.type)&&(e+=` @interpolate(flat, either)`);t.push(`${e} ${a.name} : ${this.getType(a.type)}`)}else e===`vertex`&&r.includes(a)===!1&&r.push(a)}}let n=this.getBuiltins(e);n&&t.push(n);let r=t.join(`,
|
|
310
|
+
`);return e===`vertex`?this._getWGSLStruct(`VaryingsStruct`,` `+r):r}isCustomStruct(e){let t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,i=n.value&&n.value.array&&typeof n.value.itemSize==`number`&&n.value.array.length>n.value.itemSize;return r&&!i}getUniforms(e){let t=this.uniforms[e],n=[],r=[],i=[],a={};for(let i of t){let t=i.groupNode.name,o=this.bindingsIndexes[t];if(i.type===`texture`||i.type===`cubeTexture`||i.type===`cubeDepthTexture`||i.type===`storageTexture`||i.type===`texture3D`){let t=i.node.value;(t.isCubeTexture===!0||this.isUnfilterable(t)===!1&&i.node.isStorageTextureNode!==!0)&&(this.isSampleCompare(t)?n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name}_sampler : sampler_comparison;`):n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name}_sampler : sampler;`));let r,a=``,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(t);if(s>1&&(a=`_multisampled`),t.isCubeTexture===!0&&t.isDepthTexture===!0)r=`texture_depth_cube`;else if(t.isCubeTexture===!0)r=`texture_cube<f32>`;else if(t.isDepthTexture===!0)r=this.renderer.backend.compatibilityMode&&t.compareFunction===null?`texture${a}_2d<f32>`:`texture_depth${a}_2d${t.isArrayTexture===!0?`_array`:``}`;else if(i.node.isStorageTextureNode===!0){let n=mG(t),a=this.getStorageAccess(i.node,e),o=i.node.value.is3DTexture,s=i.node.value.isArrayTexture;r=`texture_storage_${o?`3d`:`2d${s?`_array`:``}`}<${n}, ${a}>`}else if(t.isArrayTexture===!0||t.isDataArrayTexture===!0||t.isCompressedArrayTexture===!0)r=`texture_2d_array<f32>`;else if(t.is3DTexture===!0||t.isData3DTexture===!0)r=`texture_3d<f32>`;else{let e=this.getComponentTypeFromTexture(t).charAt(0);r=`texture${a}_2d<${e}32>`}n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name} : ${r};`)}else if(i.type===`buffer`||i.type===`storageBuffer`||i.type===`indirectStorageBuffer`){let t=i.node,n=this.getType(t.getNodeType(this)),a=t.bufferCount,s=a>0&&i.type===`buffer`?`, `+a:``,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:`uniform`;if(this.isCustomStruct(i))r.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${c}> ${i.name} : ${n};`);else{let e=`\tvalue : array< ${t.isAtomic?`atomic<${n}>`:`${n}`}${s} >`;r.push(this._getWGSLStructBinding(i.name,e,c,o.binding++,o.group))}}else{let e=i.groupNode.name;if(a[e]===void 0){let t=this.uniformGroups[e];if(t!==void 0){let n=[];for(let e of t.uniforms){let t=e.getType(),r=this.getType(this.getVectorType(t));n.push(`\t${e.name} : ${r}`)}let r=this.uniformGroupsBindings[e];r===void 0&&(r={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=r),a[e]={index:r.index,id:r.id,snippets:n}}}}}for(let e in a){let t=a[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(`,
|
|
311
|
+
`),`uniform`,t.index,t.id))}return[...n,...r,...i].join(`
|
|
312
|
+
`)}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};this.sortBindingGroups();for(let t in e){this.shaderStage=t;let n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code
|
|
313
|
+
|
|
314
|
+
`;r+=this.flowCode[t];let i=this.flowNodes[t],a=i[i.length-1],o=a.outputNode,s=o!==void 0&&o.isOutputStructNode===!0;for(let e of i){let i=this.getFlowData(e),c=e.name;if(c&&(r.length>0&&(r+=`
|
|
315
|
+
`),r+=`\t// flow -> ${c}\n`),r+=`${i.code}\n\t`,e===a&&t!==`compute`){if(r+=`// result
|
|
316
|
+
|
|
317
|
+
`,t===`vertex`)r+=`varyings.builtinClipSpace = ${i.result};`;else if(t===`fragment`)if(s)n.returnType=o.getNodeType(this),n.structs+=`var<private> output : `+n.returnType+`;`,r+=`return ${i.result};`;else{let e=` @location(0) color: vec4<f32>`,t=this.getBuiltins(`output`);t&&(e+=`,
|
|
318
|
+
`+t),n.returnType=`OutputStruct`,n.structs+=this._getWGSLStruct(`OutputStruct`,e),n.structs+=`
|
|
319
|
+
var<private> output : OutputStruct;`,r+=`output.color = ${i.result};\n\n\treturn output;`}}}n.flow=r}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return EG[e]||e}isAvailable(e){let t=wG[e];return t===void 0&&(e===`float32Filterable`?t=this.renderer.hasFeature(`float32-filterable`):e===`clipDistance`&&(t=this.renderer.hasFeature(`clip-distances`)),wG[e]=t),t}getUniformBufferLimit(){return this.renderer.backend.device.limits.maxUniformBufferBindingSize}_getWGSLMethod(e){return OG[e]!==void 0&&this._include(e),kG[e]}_include(e){let t=OG[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
|
|
320
|
+
// directives
|
|
321
|
+
${e.directives}
|
|
322
|
+
|
|
323
|
+
// structs
|
|
324
|
+
${e.structs}
|
|
325
|
+
|
|
326
|
+
// uniforms
|
|
327
|
+
${e.uniforms}
|
|
328
|
+
|
|
329
|
+
// varyings
|
|
330
|
+
${e.varyings}
|
|
331
|
+
var<private> varyings : VaryingsStruct;
|
|
332
|
+
|
|
333
|
+
// codes
|
|
334
|
+
${e.codes}
|
|
335
|
+
|
|
336
|
+
@vertex
|
|
337
|
+
fn main( ${e.attributes} ) -> VaryingsStruct {
|
|
338
|
+
|
|
339
|
+
// vars
|
|
340
|
+
${e.vars}
|
|
341
|
+
|
|
342
|
+
// flow
|
|
343
|
+
${e.flow}
|
|
344
|
+
|
|
345
|
+
return varyings;
|
|
346
|
+
|
|
347
|
+
}
|
|
348
|
+
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
|
|
349
|
+
// global
|
|
350
|
+
${AG}
|
|
351
|
+
|
|
352
|
+
// structs
|
|
353
|
+
${e.structs}
|
|
354
|
+
|
|
355
|
+
// uniforms
|
|
356
|
+
${e.uniforms}
|
|
357
|
+
|
|
358
|
+
// codes
|
|
359
|
+
${e.codes}
|
|
360
|
+
|
|
361
|
+
@fragment
|
|
362
|
+
fn main( ${e.varyings} ) -> ${e.returnType} {
|
|
363
|
+
|
|
364
|
+
// vars
|
|
365
|
+
${e.vars}
|
|
366
|
+
|
|
367
|
+
// flow
|
|
368
|
+
${e.flow}
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
`}_getWGSLComputeCode(e,t){let[n,r,i]=t;return`${this.getSignature()}
|
|
372
|
+
// directives
|
|
373
|
+
${e.directives}
|
|
374
|
+
|
|
375
|
+
// system
|
|
376
|
+
var<private> instanceIndex : u32;
|
|
377
|
+
|
|
378
|
+
// locals
|
|
379
|
+
${e.scopedArrays}
|
|
380
|
+
|
|
381
|
+
// structs
|
|
382
|
+
${e.structs}
|
|
383
|
+
|
|
384
|
+
// uniforms
|
|
385
|
+
${e.uniforms}
|
|
386
|
+
|
|
387
|
+
// codes
|
|
388
|
+
${e.codes}
|
|
389
|
+
|
|
390
|
+
@compute @workgroup_size( ${n}, ${r}, ${i} )
|
|
391
|
+
fn main( ${e.attributes} ) {
|
|
392
|
+
|
|
393
|
+
// system
|
|
394
|
+
instanceIndex = globalId.x
|
|
395
|
+
+ globalId.y * ( ${n} * numWorkgroups.x )
|
|
396
|
+
+ globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y );
|
|
397
|
+
|
|
398
|
+
// vars
|
|
399
|
+
${e.vars}
|
|
400
|
+
|
|
401
|
+
// flow
|
|
402
|
+
${e.flow}
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
`}_getWGSLStruct(e,t){return`
|
|
406
|
+
struct ${e} {
|
|
407
|
+
${t}
|
|
408
|
+
};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`;return`${this._getWGSLStruct(a,t)}
|
|
409
|
+
@binding( ${r} ) @group( ${i} )
|
|
410
|
+
var<${n}> ${e} : ${a};`}},MG=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=e.depthTexture===null?e.stencil?$.Depth24PlusStencil8:$.Depth24Plus:this.getTextureFormatGPU(e.depthTexture)),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorFormats(e){return e.textures===null?[this.getPreferredCanvasFormat()]:e.textures.map(e=>this.getTextureFormatGPU(e))}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return IW.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return IW.LineList;if(e.isLine)return IW.LineStrip;if(e.isMesh)return IW.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.currentSamples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===1009)return $.BGRA8Unorm;if(e===1016)return $.RGBA16Float;throw Error(`Unsupported output buffer type.`)}},NG=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&NG.set(Float16Array,[`float16`]);var PG=new Map([[Ev,[`float16`]]]),FG=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]),IG=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=t.updateRanges;if(s.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=Zh(o),n=e?1:o.BYTES_PER_ELEMENT;for(let t=0,c=s.length;t<c;t++){let c=s[t],l,u;if(i._force3to4BytesAlignment===!0){let e=Math.floor(c.start/3),t=Math.ceil(c.count/3);l=e*4*n,u=t*4*n}else l=c.start*n,u=c.count*n;let d=l*(e?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?rG.Instance:rG.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?rG.Instance:rG.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)).buffer,i=r.size,a=n.createBuffer({label:`${e.name}_readback`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),o=n.createCommandEncoder({label:`readback_encoder_${e.name}`});o.copyBufferToBuffer(r,0,a,0,i);let s=o.finish();n.queue.submit([s]),await a.mapAsync(GPUMapMode.READ);let c=a.getMappedRange(),l=new e.array.constructor(c.slice(0));return a.unmap(),l.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=FG.get(r);else{let e=(PG.get(i)||NG.get(r))[+!!n];if(e){let n=r.BYTES_PER_ELEMENT*t,i=Math.floor((n+3)/4)*4/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${e}x${i}`}}return a||z(`WebGPUAttributeUtils: Vertex format not supported yet.`),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},LG=class{constructor(e){this.layoutGPU=e,this.usedTimes=0}},RG=class{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;let i=this._createLayoutEntries(e),a=sx(JSON.stringify(i)),o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new LG(n.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,r.layout=o,r.layoutKey=a,o.layoutGPU}createBindings(e,t,n,r=0){let{backend:i}=this,a=i.get(e),o=this.createBindingsLayout(e),s;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(s=a.groups[n])),s===void 0&&(s=this.createBindGroup(e,o),n>0&&(a.groups[n]=s,a.versions[n]=r)),a.group=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(i,0,r,0);else{let e=Zh(r),t=e?1:r.BYTES_PER_ELEMENT;for(let o=0,s=a.length;o<s;o++){let s=a[o],c=s.start*t,l=s.count*t,u=c*(e?r.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(i,u,r,c,l)}}}createBindGroupIndex(e,t){let n=this.backend.device,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],a=n.createBuffer({label:`bindingCameraIndex_`+i,size:16,usage:r});n.queue.writeBuffer(a,0,e,0);let o=[{binding:0,resource:{buffer:a}}];return n.createBindGroup({label:`bindGroupCameraIndex_`+i,layout:t,entries:o})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=[];t.visibility&LW.VERTEX&&a.push(`vertex`),t.visibility&LW.FRAGMENT&&a.push(`fragment`),t.visibility&LW.COMPUTE&&a.push(`compute`);let o=`(${a.join(`,`)})`;e.buffer=r.createBuffer({label:`bindingBuffer${t.id}_${t.name}_${o}`,size:n,usage:i})}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t.attribute).buffer;a.push({binding:i,resource:{buffer:e}})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=t.store?t.mipLevel:0,i=`view-${e.texture.width}-${e.texture.height}`;if(e.texture.depthOrArrayLayers>1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${n}-${r}`,o=e[i],o===void 0){let a=nG.All,s;s=t.isSampledCubeTexture?tG.Cube:t.isSampledTexture3D?tG.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?tG.TwoDArray:tG.TwoD,o=e[i]=e.texture.createView({aspect:a,dimension:s,mipLevelCount:n,baseMipLevel:r})}}a.push({binding:i,resource:o})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}_createLayoutEntries(e){let t=[],n=0;for(let r of e.bindings){let e=this.backend,i={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let e={};r.isStorageBuffer&&(r.visibility&LW.COMPUTE&&(r.access===Tx.READ_WRITE||r.access===Tx.WRITE_ONLY)?e.type=XW.Storage:e.type=XW.ReadOnlyStorage),i.buffer=e}else if(r.isSampledTexture&&r.store){let e={};e.format=this.backend.get(r.texture).texture.format;let t=r.access;t===Tx.READ_WRITE?e.access=ZW.ReadWrite:t===Tx.WRITE_ONLY?e.access=ZW.WriteOnly:e.access=ZW.ReadOnly,r.texture.isArrayTexture?e.viewDimension=tG.TwoDArray:r.texture.is3DTexture&&(e.viewDimension=tG.ThreeD),i.storageTexture=e}else if(r.isSampledTexture){let t={},{primarySamples:n}=e.utils.getTextureSampleData(r.texture);if(n>1&&(t.multisampled=!0,r.texture.isDepthTexture||(t.sampleType=$W.UnfilterableFloat)),r.texture.isDepthTexture)e.compatibilityMode&&r.texture.compareFunction===null?t.sampleType=$W.UnfilterableFloat:t.sampleType=$W.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){let e=r.texture.type;e===1013?t.sampleType=$W.SInt:e===1014?t.sampleType=$W.UInt:e===1015&&(this.backend.hasFeature(`float32-filterable`)?t.sampleType=$W.Float:t.sampleType=$W.UnfilterableFloat)}r.isSampledCubeTexture?t.viewDimension=tG.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?t.viewDimension=tG.TwoDArray:r.isSampledTexture3D&&(t.viewDimension=tG.ThreeD),i.texture=t}else if(r.isSampler){let t={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null&&e.hasCompatibility(Yh.TEXTURE_COMPARE)?t.type=QW.Comparison:t.type=QW.NonFiltering),i.sampler=t}else z(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(i),n++}return t}deleteBindGroupData(e){let{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}},zG=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let{layoutGPU:e}=c.get(t).layout;f.push(e)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==0&&(r.blending!==1||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures,n=e.context.mrt;for(let e=0;e<t.length;e++){let r=t[e],i=u.getTextureFormatGPU(r),a;if(n!==null)if(this.backend.compatibilityMode!==!0){let e=n.getBlendMode(r.name);e.blending===6?a=m:e.blending!==0&&(a=this._getBlending(e))}else ig(`WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.`),a=m;else a=m;_.push({format:i,blend:a,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),C=this._getSampleCount(e.context),w={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:C,alphaToCoverageEnabled:r.alphaToCoverage&&C>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},T={},E=e.context.depth,D=e.context.stencil;if((E===!0||D===!0)&&(E===!0&&(T.format=S,T.depthWriteEnabled=r.depthWrite,T.depthCompare=x),D===!0&&(T.stencilFront=h,T.stencilBack=h,T.stencilReadMask=r.stencilFuncMask,T.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(T.depthBias=r.polygonOffsetUnits,T.depthBiasSlopeScale=r.polygonOffsetFactor,T.depthBiasClamp=0),w.depthStencil=T),l.pushErrorScope(`validation`),t===null)d.pipeline=l.createRenderPipeline(w),l.popErrorScope().then(e=>{e!==null&&(d.error=!0,z(e.message))});else{let e=new Promise(async e=>{try{d.pipeline=await l.createRenderPipelineAsync(w)}catch{}let t=await l.popErrorScope();t!==null&&(d.error=!0,z(t.message)),e()});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let{utils:n,device:r}=this.backend,i=n.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:n.getCurrentColorFormats(e),depthStencilFormat:i,sampleCount:this._getSampleCount(e)};return r.createRenderBundleEncoder(a)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let{layoutGPU:t}=n.get(e).layout;o.push(t)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===5){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:qW.Add},n={srcFactor:i,dstFactor:a,operation:qW.Add}};if(i)switch(r){case 1:a(KW.One,KW.OneMinusSrcAlpha,KW.One,KW.OneMinusSrcAlpha);break;case 2:a(KW.One,KW.One,KW.One,KW.One);break;case 3:a(KW.Zero,KW.OneMinusSrc,KW.Zero,KW.One);break;case 4:a(KW.Dst,KW.OneMinusSrcAlpha,KW.Zero,KW.One);break}else switch(r){case 1:a(KW.SrcAlpha,KW.OneMinusSrcAlpha,KW.One,KW.OneMinusSrcAlpha);break;case 2:a(KW.SrcAlpha,KW.One,KW.One,KW.One);break;case 3:z(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break;case 4:z(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?`material`:`blendMode`}.premultipliedAlpha = true".`);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};z(`WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case 200:t=KW.Zero;break;case 201:t=KW.One;break;case 202:t=KW.Src;break;case 203:t=KW.OneMinusSrc;break;case 204:t=KW.SrcAlpha;break;case 205:t=KW.OneMinusSrcAlpha;break;case 208:t=KW.Dst;break;case 209:t=KW.OneMinusDst;break;case 206:t=KW.DstAlpha;break;case 207:t=KW.OneMinusDstAlpha;break;case 210:t=KW.SrcAlphaSaturated;break;case YP:t=KW.Constant;break;case XP:t=KW.OneMinusConstant;break;default:z(`WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case 512:t=RW.Never;break;case 519:t=RW.Always;break;case 513:t=RW.Less;break;case 515:t=RW.LessEqual;break;case 514:t=RW.Equal;break;case 518:t=RW.GreaterEqual;break;case 516:t=RW.Greater;break;case 517:t=RW.NotEqual;break;default:z(`WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case Lh:t=YW.Keep;break;case 0:t=YW.Zero;break;case Rh:t=YW.Replace;break;case Uh:t=YW.Invert;break;case zh:t=YW.IncrementClamp;break;case Bh:t=YW.DecrementClamp;break;case Vh:t=YW.IncrementWrap;break;case Hh:t=YW.DecrementWrap;break;default:z(`WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case 100:t=qW.Add;break;case 101:t=qW.Subtract;break;case 102:t=qW.ReverseSubtract;break;case 103:t=qW.Min;break;case 104:t=qW.Max;break;default:z(`WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={};r.topology=this.backend.utils.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?UW.Uint16:UW.Uint32);let i=n.side===1;return e.isMesh&&e.matrixWorld.determinant()<0&&(i=!i),r.frontFace=i===!0?VW.CW:VW.CCW,r.cullMode=n.side===2?HW.None:HW.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?JW.All:JW.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=RW.Always;else{let n=this.backend.parameters.reversedDepthBuffer?ag[e.depthFunc]:e.depthFunc;switch(n){case 0:t=RW.Never;break;case 1:t=RW.Always;break;case 2:t=RW.Less;break;case 3:t=RW.LessEqual;break;case 4:t=RW.Equal;break;case 5:t=RW.GreaterEqual;break;case 6:t=RW.Greater;break;case 7:t=RW.NotEqual;break;default:z(`WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},BG=class extends NW{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ig(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o={},s=[];for(let[t,n]of e){let e=t.match(/^(.*):f(\d+)$/),r=parseInt(e[2]);s.includes(r)===!1&&s.push(r),o[r]===void 0&&(o[r]=0);let i=a[n],c=a[n+1],l=Number(c-i)/1e6;this.timestamps.set(t,l),o[r]+=l}let c=o[s[s.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=s,c}catch(e){return z(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){z(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){z(`Error unmapping buffer:`,e)}this.querySet&&=(this.querySet.destroy(),null),this.resolveBuffer&&=(this.resolveBuffer.destroy(),null),this.resultBuffer&&=(this.resultBuffer.destroy(),null),this.queryOffsets.clear(),this.pendingResolve=null}}},VG=class extends hW{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new MG(this),this.attributeUtils=new IG(this),this.bindingUtils=new RG(this),this.pipelineUtils=new zG(this),this.textureUtils=new pG(this),this.occludedResolveCache=new Map;let t=typeof navigator>`u`?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[Yh.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:`compatibility`},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(iG),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;this.compatibilityMode=!n.features.has(`core-features-and-limits`),this.compatibilityMode&&(e._samples=0),n.lost.then(t=>{if(t.reason===`destroyed`)return;let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)}),this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(iG.TimestampQuery),this.updateSize()}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),n=t.context;if(n===void 0){let r=this.parameters;n=e.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:e.domElement.getContext(`webgpu`),`setAttribute`in e.domElement&&e.domElement.setAttribute(`data-engine`,`three.js r183 webgpu`);let i=r.alpha?`premultiplied`:`opaque`,a=r.outputType===1016?`extended`:`standard`;n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return qh}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples,i=n.descriptor;if(i===void 0||n.samples!==r){i={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(i.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});let t=i.colorAttachments[0];r>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,n.descriptor=i,n.samples=r}let a=i.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;(i===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples)&&(i={},r.descriptors=i);let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:tG.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=tG.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:tG.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=tG.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(n.dimension=tG.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||BW.Load,storeOp:t.storeOp||zW.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:BW.Load}),this.initTimestampQuery(Jh.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=BW.Clear):r.loadOp=BW.Load,r.storeOp=zW.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=BW.Clear):t.loadOp=BW.Load,t.storeOp=zW.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=BW.Clear):o.depthLoadOp=BW.Load,o.depthStoreOp=zW.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=BW.Clear):o.stencilLoadOp=BW.Load,o.stencilStoreOp=zW.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r);t.bundleEncoders.push(n),t.bundleSets.push({attributes:{},bindingGroups:[],pipeline:null,index:null})}t.currentPass=null}else t.currentPass=s.beginRenderPass(a),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:tG.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||BW.Clear,depthStoreOp:i.depthStoreOp||zW.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=BW.Clear):t.depthLoadOp=BW.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=BW.Clear):t.stencilLoadOp=BW.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}updateScissor(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a}=e.scissorValue;t.setScissorRect(n,r,i,a)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=BW.Clear,e.storeOp=zW.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?BW.Clear:BW.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?BW.Clear:BW.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=zW.Store),u&&(i.stencilLoadOp=n?BW.Clear:BW.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=zW.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&(t?(s.depthLoadOp=BW.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=zW.Store):(s.depthLoadOp=BW.Load,s.depthStoreOp=zW.Store)),u&&s&&(n?(s.stencilLoadOp=BW.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=zW.Store):(s.stencilLoadOp=BW.Load,s.stencilStoreOp=zW.Store));let d=i.createCommandEncoder({label:`clear`});d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s}).end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(Jh.COMPUTE,this.getTimestampUID(e),n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r,i=null){let a=this.get(t),{passEncoderGPU:o}=this.get(e),s=this.get(r).pipeline;this.pipelineUtils.setPipeline(o,s);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);o.setBindGroup(e,r.group)}if(i===null&&(i=t.count),i&&typeof i==`object`&&i.isIndirectStorageBufferAttribute){let e=this.get(i).buffer;o.dispatchWorkgroupsIndirect(e,0);return}if(typeof i==`number`){let e=i;if(a.dispatchSize===void 0||a.count!==e){a.dispatchSize=[0,1,1],a.count=e;let n=t.workgroupSize,r=n[0];for(let e=1;e<n.length;e++)r*=n[e];let o=Math.ceil(e/r),s=this.device.limits.maxComputeWorkgroupsPerDimension;i=[o,1,1],o>s&&(i[0]=Math.min(o,s),i[1]=Math.ceil(o/s)),a.dispatchSize=i}i=a.dispatchSize}o.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a),l=c.pipeline;if(c.error===!0)return;let u=e.getIndex(),d=u!==null,f=e.getDrawParameters();if(f===null)return;let p=(t,n)=>{this.pipelineUtils.setPipeline(t,l),n.pipeline=l;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(d===!0&&n.index!==u){let e=this.get(u).buffer,r=u.array instanceof Uint16Array?UW.Uint16:UW.Uint32;t.setIndexBuffer(e,r),n.index=u}let c=e.getVertexBuffers();for(let e=0,r=c.length;e<r;e++){let r=c[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},m=(i,a)=>{if(p(i,a),n.isBatchedMesh===!0){let e=n._multiDrawStarts,a=n._multiDrawCounts,o=n._multiDrawCount,s=n._multiDrawInstances;s!==null&&ig(`WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);let c=d===!0?u.array.BYTES_PER_ELEMENT:1;r.wireframe&&(c=n.geometry.attributes.position.count>65535?4:2);for(let r=0;r<o;r++){let o=s?s[r]:1,l=o>1?0:r;d===!0?i.drawIndexed(a[r],o,e[r]/c,0,l):i.draw(a[r],o,e[r],l),t.update(n,a[r],o)}}else if(d===!0){let{vertexCount:r,instanceCount:a,firstVertex:o}=f,s=e.getIndirect();if(s!==null){let t=this.get(s).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)i.drawIndexedIndirect(t,r[e])}else i.drawIndexed(r,a,o,0,0);t.update(n,r,a)}else{let{vertexCount:r,instanceCount:a,firstVertex:o}=f,s=e.getIndirect();if(s!==null){let t=this.get(s).buffer,n=e.getIndirectOffset(),r=Array.isArray(n)?n:[n];for(let e=0;e<r.length;e++)i.drawIndirect(t,r[e])}else i.draw(r,a,o,0);t.update(n,r,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let{layoutGPU:r}=e.layout,a=this.bindingUtils.createBindGroupIndex(i,r);n.push(a)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),m(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}m(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context,a=t.isMesh&&t.matrixWorld.determinant()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,a,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new BG(this.device,e,2048));let r=this.timestampQueryPool[e],i=r.allocateQueriesForContext(t);n.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new jG(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass.finish();this.get(t).bundleGPU=r,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}getMaxAnisotropy(){return 16}hasFeature(e){return aG[e]!==void 0&&(e=aG[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){z(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,o),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=BW.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=BW.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=BW.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else this.device.queue.submit([o.finish()])}hasCompatibility(e){return this._compatibility[Yh.TEXTURE_COMPARE]===void 0?super.hasCompatibility(e):this._compatibility[Yh.TEXTURE_COMPARE]}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},HG=class extends wb{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},UG=class extends wb{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},WG=class extends gU{constructor(){super(),this.addMaterial(gM,`MeshPhongMaterial`),this.addMaterial(yP,`MeshStandardMaterial`),this.addMaterial(xP,`MeshPhysicalMaterial`),this.addMaterial(TP,`MeshToonMaterial`),this.addMaterial(oM,`MeshBasicMaterial`),this.addMaterial(mM,`MeshLambertMaterial`),this.addMaterial(Kj,`MeshNormalMaterial`),this.addMaterial(OP,`MeshMatcapMaterial`),this.addMaterial(Hj,`LineBasicMaterial`),this.addMaterial(Wj,`LineDashedMaterial`),this.addMaterial(PP,`PointsMaterial`),this.addMaterial(jP,`SpriteMaterial`),this.addMaterial(RP,`ShadowMaterial`),this.addLight(TB,Eb),this.addLight(HH,kb),this.addLight(QH,jb),this.addLight(WH,wb),this.addLight(VH,Ab),this.addLight(UH,ub),this.addLight(KH,Nb),this.addLight(GH,HG),this.addLight(JH,UG),this.addToneMapping(ZL,1),this.addToneMapping(QL,2),this.addToneMapping($L,3),this.addToneMapping(tR,4),this.addToneMapping(aR,6),this.addToneMapping(oR,7)}},GG=class extends VU{constructor(e={}){let t;e.forceWebGL?t=FW:(t=VG,e.getFallback=()=>(R(`WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new FW(e)));let n=new t(e);super(n,e),this.library=new WG,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}};Q.BRDF_GGX,Q.BRDF_Lambert,Q.BasicPointShadowFilter,Q.BasicShadowFilter,Q.Break,Q.Const,Q.Continue,Q.DFGLUT,Q.D_GGX,Q.Discard,Q.EPSILON,Q.F_Schlick;var KG=Q.Fn;Q.INFINITY;var qG=Q.If,JG=Q.Loop;Q.NodeAccess,Q.NodeShaderStage,Q.NodeType,Q.NodeUpdateType,Q.PCFShadowFilter,Q.PCFSoftShadowFilter,Q.PI,Q.PI2,Q.TWO_PI,Q.HALF_PI,Q.PointShadowFilter,Q.Return,Q.Schlick_to_F0,Q.ShaderNode,Q.Stack,Q.Switch,Q.TBNViewMatrix,Q.VSMShadowFilter,Q.V_GGX_SmithCorrelated,Q.Var,Q.VarIntent,Q.abs,Q.acesFilmicToneMapping,Q.acos,Q.add,Q.addMethodChaining,Q.addNodeElement,Q.agxToneMapping,Q.all,Q.alphaT,Q.and,Q.anisotropy,Q.anisotropyB,Q.anisotropyT,Q.any,Q.append,Q.array,Q.arrayBuffer;var YG=Q.asin;Q.assign,Q.atan,Q.atomicAdd,Q.atomicAnd,Q.atomicFunc,Q.atomicLoad,Q.atomicMax,Q.atomicMin,Q.atomicOr,Q.atomicStore,Q.atomicSub,Q.atomicXor,Q.attenuationColor,Q.attenuationDistance,Q.attribute,Q.attributeArray,Q.backgroundBlurriness,Q.backgroundIntensity,Q.backgroundRotation,Q.batch,Q.bentNormalView,Q.billboarding,Q.bitAnd,Q.bitNot,Q.bitOr,Q.bitXor,Q.bitangentGeometry,Q.bitangentLocal,Q.bitangentView,Q.bitangentWorld,Q.bitcast,Q.blendBurn,Q.blendColor,Q.blendDodge,Q.blendOverlay,Q.blendScreen,Q.blur,Q.bool,Q.buffer,Q.bufferAttribute,Q.bumpMap,Q.builtin,Q.builtinAOContext,Q.builtinShadowContext,Q.bvec2,Q.bvec3,Q.bvec4,Q.bypass,Q.cache,Q.call,Q.cameraFar,Q.cameraIndex,Q.cameraNear,Q.cameraNormalMatrix,Q.cameraPosition,Q.cameraProjectionMatrix,Q.cameraProjectionMatrixInverse,Q.cameraViewMatrix,Q.cameraViewport,Q.cameraWorldMatrix,Q.cbrt,Q.cdl,Q.ceil,Q.checker,Q.cineonToneMapping,Q.clamp,Q.clearcoat,Q.clearcoatNormalView,Q.clearcoatRoughness,Q.clipSpace,Q.code,Q.color,Q.colorSpaceToWorking,Q.colorToDirection,Q.compute,Q.computeKernel,Q.computeSkinning,Q.context,Q.convert,Q.convertColorSpace,Q.convertToTexture,Q.countLeadingZeros,Q.countOneBits,Q.countTrailingZeros;var XG=Q.cos;Q.cross,Q.cubeTexture,Q.cubeTextureBase,Q.dFdx,Q.dFdy,Q.dashSize,Q.debug,Q.decrement,Q.decrementBefore,Q.defaultBuildStages,Q.defaultShaderStages,Q.defined,Q.degrees,Q.deltaTime,Q.densityFog,Q.densityFogFactor,Q.depth,Q.depthPass,Q.determinant,Q.difference,Q.diffuseColor,Q.directPointLight,Q.directionToColor,Q.directionToFaceDirection,Q.dispersion,Q.distance,Q.div,Q.dot,Q.drawIndex,Q.dynamicBufferAttribute,Q.element,Q.emissive,Q.equal,Q.equirectUV;var ZG=Q.exp;Q.exp2,Q.exponentialHeightFogFactor,Q.expression,Q.faceDirection,Q.faceForward,Q.faceforward;var QG=Q.float;Q.floatBitsToInt,Q.floatBitsToUint,Q.floor,Q.fog,Q.fract,Q.frameGroup,Q.frameId,Q.frontFacing,Q.fwidth,Q.gain,Q.gapSize,Q.getConstNodeType,Q.getCurrentStack,Q.getDirection,Q.getDistanceAttenuation,Q.getGeometryRoughness,Q.getNormalFromDepth,Q.interleavedGradientNoise,Q.vogelDiskSample,Q.getParallaxCorrectNormal,Q.getRoughness,Q.getScreenPosition,Q.getShIrradianceAt,Q.getShadowMaterial,Q.getShadowRenderObjectFunction,Q.getTextureIndex,Q.getViewPosition,Q.globalId,Q.glsl,Q.glslFn,Q.grayscale,Q.greaterThan,Q.greaterThanEqual,Q.hash,Q.highpModelNormalViewMatrix,Q.highpModelViewMatrix,Q.hue,Q.increment,Q.incrementBefore,Q.instance;var $G=Q.instanceIndex;Q.instancedArray,Q.instancedBufferAttribute,Q.instancedDynamicBufferAttribute,Q.instancedMesh,Q.int,Q.intBitsToFloat,Q.inverse,Q.inverseSqrt,Q.inversesqrt,Q.invocationLocalIndex,Q.invocationSubgroupIndex,Q.ior,Q.iridescence,Q.iridescenceIOR,Q.iridescenceThickness,Q.ivec2,Q.ivec3,Q.ivec4,Q.js,Q.label,Q.length,Q.lengthSq,Q.lessThan,Q.lessThanEqual,Q.lightPosition,Q.lightProjectionUV,Q.lightShadowMatrix,Q.lightTargetDirection,Q.lightTargetPosition,Q.lightViewPosition,Q.lightingContext,Q.lights,Q.linearDepth,Q.linearToneMapping,Q.localId,Q.log,Q.log2,Q.logarithmicDepthToViewZ,Q.luminance,Q.mat2,Q.mat3,Q.mat4,Q.matcapUV,Q.materialAO,Q.materialAlphaTest,Q.materialAnisotropy,Q.materialAnisotropyVector,Q.materialAttenuationColor,Q.materialAttenuationDistance,Q.materialClearcoat,Q.materialClearcoatNormal,Q.materialClearcoatRoughness,Q.materialColor,Q.materialDispersion,Q.materialEmissive,Q.materialEnvIntensity,Q.materialEnvRotation,Q.materialIOR,Q.materialIridescence,Q.materialIridescenceIOR,Q.materialIridescenceThickness,Q.materialLightMap,Q.materialLineDashOffset,Q.materialLineDashSize,Q.materialLineGapSize,Q.materialLineScale,Q.materialLineWidth,Q.materialMetalness,Q.materialNormal,Q.materialOpacity,Q.materialPointSize,Q.materialReference,Q.materialReflectivity,Q.materialRefractionRatio,Q.materialRotation,Q.materialRoughness,Q.materialSheen,Q.materialSheenRoughness,Q.materialShininess,Q.materialSpecular,Q.materialSpecularColor,Q.materialSpecularIntensity,Q.materialSpecularStrength,Q.materialThickness,Q.materialTransmission,Q.max,Q.maxMipLevel,Q.mediumpModelViewMatrix,Q.metalness,Q.min,Q.mix,Q.mixElement,Q.mod,Q.modInt,Q.modelDirection,Q.modelNormalMatrix,Q.modelPosition,Q.modelRadius,Q.modelScale,Q.modelViewMatrix,Q.modelViewPosition,Q.modelViewProjection,Q.modelWorldMatrix,Q.modelWorldMatrixInverse,Q.morphReference,Q.mrt,Q.mul,Q.mx_aastep,Q.mx_add,Q.mx_atan2,Q.mx_cell_noise_float,Q.mx_contrast,Q.mx_divide,Q.mx_fractal_noise_float,Q.mx_fractal_noise_vec2,Q.mx_fractal_noise_vec3,Q.mx_fractal_noise_vec4,Q.mx_frame,Q.mx_heighttonormal,Q.mx_hsvtorgb,Q.mx_ifequal,Q.mx_ifgreater,Q.mx_ifgreatereq,Q.mx_invert,Q.mx_modulo,Q.mx_multiply,Q.mx_noise_float,Q.mx_noise_vec3,Q.mx_noise_vec4,Q.mx_place2d,Q.mx_power,Q.mx_ramp4,Q.mx_ramplr,Q.mx_ramptb,Q.mx_rgbtohsv,Q.mx_rotate2d,Q.mx_rotate3d,Q.mx_safepower,Q.mx_separate,Q.mx_splitlr,Q.mx_splittb,Q.mx_srgb_texture_to_lin_rec709,Q.mx_subtract,Q.mx_timer,Q.mx_transform_uv,Q.mx_unifiednoise2d,Q.mx_unifiednoise3d,Q.mx_worley_noise_float,Q.mx_worley_noise_vec2,Q.mx_worley_noise_vec3;var eK=Q.negate;Q.neutralToneMapping,Q.nodeArray,Q.nodeImmutable,Q.nodeObject,Q.nodeObjectIntent,Q.nodeObjects,Q.nodeProxy,Q.nodeProxyIntent,Q.normalFlat,Q.normalGeometry,Q.normalLocal,Q.normalMap,Q.normalView,Q.normalViewGeometry,Q.normalWorld,Q.normalWorldGeometry,Q.normalize,Q.not,Q.notEqual,Q.numWorkgroups,Q.objectDirection,Q.objectGroup,Q.objectPosition,Q.objectRadius,Q.objectScale,Q.objectViewPosition,Q.objectWorldMatrix,Q.OnBeforeObjectUpdate,Q.OnBeforeMaterialUpdate,Q.OnObjectUpdate,Q.OnMaterialUpdate,Q.oneMinus,Q.or,Q.orthographicDepthToViewZ,Q.oscSawtooth,Q.oscSine,Q.oscSquare,Q.oscTriangle,Q.output,Q.outputStruct,Q.overloadingFn,Q.packHalf2x16,Q.packSnorm2x16,Q.packUnorm2x16,Q.parabola,Q.parallaxDirection,Q.parallaxUV,Q.parameter,Q.pass,Q.passTexture,Q.pcurve,Q.perspectiveDepthToViewZ,Q.pmremTexture,Q.pointShadow,Q.pointUV,Q.pointWidth,Q.positionGeometry,Q.positionLocal,Q.positionPrevious,Q.positionView,Q.positionViewDirection,Q.positionWorld,Q.positionWorldDirection,Q.posterize,Q.pow,Q.pow2,Q.pow3,Q.pow4,Q.premultiplyAlpha,Q.property,Q.radians,Q.rand,Q.range,Q.rangeFog,Q.rangeFogFactor,Q.reciprocal,Q.reference,Q.referenceBuffer,Q.reflect,Q.reflectVector,Q.reflectView,Q.reflector,Q.refract,Q.refractVector,Q.refractView,Q.reinhardToneMapping,Q.remap,Q.remapClamp,Q.renderGroup,Q.renderOutput,Q.rendererReference,Q.replaceDefaultUV,Q.rotate,Q.rotateUV,Q.roughness,Q.round,Q.rtt,Q.sRGBTransferEOTF,Q.sRGBTransferOETF,Q.sample,Q.sampler,Q.samplerComparison,Q.saturate,Q.saturation,Q.screen,Q.screenCoordinate,Q.screenDPR,Q.screenSize,Q.screenUV,Q.select,Q.setCurrentStack,Q.setName,Q.shaderStages,Q.shadow,Q.shadowPositionWorld,Q.shapeCircle,Q.sharedUniformGroup,Q.sheen,Q.sheenRoughness,Q.shiftLeft,Q.shiftRight,Q.shininess,Q.sign;var tK=Q.sin;Q.sinc,Q.skinning,Q.smoothstep,Q.smoothstepElement,Q.specularColor,Q.specularF90,Q.spherizeUV,Q.split,Q.spritesheetUV;var nK=Q.sqrt;Q.stack,Q.step,Q.stepElement;var rK=Q.storage;Q.storageBarrier,Q.storageTexture,Q.string,Q.struct,Q.sub,Q.subgroupAdd,Q.subgroupAll,Q.subgroupAnd,Q.subgroupAny,Q.subgroupBallot,Q.subgroupBroadcast,Q.subgroupBroadcastFirst,Q.subBuild,Q.subgroupElect,Q.subgroupExclusiveAdd,Q.subgroupExclusiveMul,Q.subgroupInclusiveAdd,Q.subgroupInclusiveMul,Q.subgroupIndex,Q.subgroupMax,Q.subgroupMin,Q.subgroupMul,Q.subgroupOr,Q.subgroupShuffle,Q.subgroupShuffleDown,Q.subgroupShuffleUp,Q.subgroupShuffleXor,Q.subgroupSize,Q.subgroupXor,Q.tan,Q.tangentGeometry,Q.tangentLocal,Q.tangentView,Q.tangentWorld,Q.texture,Q.texture3D,Q.textureBarrier,Q.textureBicubic,Q.textureBicubicLevel,Q.textureCubeUV,Q.textureLoad,Q.textureSize,Q.textureLevel,Q.textureStore,Q.thickness,Q.time,Q.toneMapping,Q.toneMappingExposure,Q.toonOutlinePass,Q.transformDirection,Q.transformNormal,Q.transformNormalToView,Q.transformedClearcoatNormalView,Q.transformedNormalView,Q.transformedNormalWorld,Q.transmission,Q.transpose,Q.triNoise3D,Q.triplanarTexture,Q.triplanarTextures,Q.trunc,Q.uint,Q.uintBitsToFloat;var iK=Q.uniform;Q.uniformArray,Q.uniformCubeTexture,Q.uniformGroup,Q.uniformFlow,Q.uniformTexture,Q.unpackHalf2x16,Q.unpackSnorm2x16,Q.unpackUnorm2x16,Q.unpremultiplyAlpha,Q.userData,Q.uv,Q.uvec2,Q.uvec3,Q.uvec4,Q.varying,Q.varyingProperty,Q.vec2,Q.vec3,Q.vec4,Q.vectorComponents,Q.velocity,Q.vertexColor,Q.vertexIndex,Q.vertexStage,Q.vibrance,Q.viewZToLogarithmicDepth,Q.viewZToOrthographicDepth,Q.viewZToPerspectiveDepth,Q.viewZToReversedOrthographicDepth,Q.viewZToReversedPerspectiveDepth,Q.viewport,Q.viewportCoordinate,Q.viewportDepthTexture,Q.viewportLinearDepth,Q.viewportMipTexture,Q.viewportOpaqueMipTexture,Q.viewportResolution,Q.viewportSafeUV,Q.viewportSharedTexture,Q.viewportSize,Q.viewportTexture,Q.viewportUV,Q.wgsl,Q.wgslFn,Q.workgroupArray,Q.workgroupBarrier,Q.workgroupId,Q.workingToColorSpace,Q.xor;var aK=new i.Box3,oK=new i.Vector3,sK=class extends i.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new i.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new i.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute(`instanceStart`,new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute(`instanceEnd`,new i.InterleavedBufferAttribute(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute(`instanceColorStart`,new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute(`instanceColorEnd`,new i.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new i.WireframeGeometry(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new i.Box3);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),aK.setFromBufferAttribute(t),this.boundingBox.union(aK))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new i.Sphere),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)oK.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(oK)),oK.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(oK));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};i.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new i.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},i.ShaderLib.line={uniforms:i.UniformsUtils.merge([i.UniformsLib.common,i.UniformsLib.fog,i.UniformsLib.line]),vertexShader:`
|
|
411
|
+
#include <common>
|
|
412
|
+
#include <color_pars_vertex>
|
|
413
|
+
#include <fog_pars_vertex>
|
|
414
|
+
#include <logdepthbuf_pars_vertex>
|
|
415
|
+
#include <clipping_planes_pars_vertex>
|
|
416
|
+
|
|
417
|
+
uniform float linewidth;
|
|
418
|
+
uniform vec2 resolution;
|
|
419
|
+
|
|
420
|
+
attribute vec3 instanceStart;
|
|
421
|
+
attribute vec3 instanceEnd;
|
|
422
|
+
|
|
423
|
+
attribute vec3 instanceColorStart;
|
|
424
|
+
attribute vec3 instanceColorEnd;
|
|
425
|
+
|
|
426
|
+
#ifdef WORLD_UNITS
|
|
427
|
+
|
|
428
|
+
varying vec4 worldPos;
|
|
429
|
+
varying vec3 worldStart;
|
|
430
|
+
varying vec3 worldEnd;
|
|
431
|
+
|
|
432
|
+
#ifdef USE_DASH
|
|
433
|
+
|
|
434
|
+
varying vec2 vUv;
|
|
435
|
+
|
|
436
|
+
#endif
|
|
437
|
+
|
|
438
|
+
#else
|
|
439
|
+
|
|
440
|
+
varying vec2 vUv;
|
|
441
|
+
|
|
442
|
+
#endif
|
|
443
|
+
|
|
444
|
+
#ifdef USE_DASH
|
|
445
|
+
|
|
446
|
+
uniform float dashScale;
|
|
447
|
+
attribute float instanceDistanceStart;
|
|
448
|
+
attribute float instanceDistanceEnd;
|
|
449
|
+
varying float vLineDistance;
|
|
450
|
+
|
|
451
|
+
#endif
|
|
452
|
+
|
|
453
|
+
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
454
|
+
|
|
455
|
+
// trim end segment so it terminates between the camera plane and the near plane
|
|
456
|
+
|
|
457
|
+
// conservative estimate of the near plane
|
|
458
|
+
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
459
|
+
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
460
|
+
float nearEstimate = - 0.5 * b / a;
|
|
461
|
+
|
|
462
|
+
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
463
|
+
|
|
464
|
+
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
void main() {
|
|
469
|
+
|
|
470
|
+
#ifdef USE_COLOR
|
|
471
|
+
|
|
472
|
+
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
473
|
+
|
|
474
|
+
#endif
|
|
475
|
+
|
|
476
|
+
#ifdef USE_DASH
|
|
477
|
+
|
|
478
|
+
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
479
|
+
vUv = uv;
|
|
480
|
+
|
|
481
|
+
#endif
|
|
482
|
+
|
|
483
|
+
float aspect = resolution.x / resolution.y;
|
|
484
|
+
|
|
485
|
+
// camera space
|
|
486
|
+
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
487
|
+
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
488
|
+
|
|
489
|
+
#ifdef WORLD_UNITS
|
|
490
|
+
|
|
491
|
+
worldStart = start.xyz;
|
|
492
|
+
worldEnd = end.xyz;
|
|
493
|
+
|
|
494
|
+
#else
|
|
495
|
+
|
|
496
|
+
vUv = uv;
|
|
497
|
+
|
|
498
|
+
#endif
|
|
499
|
+
|
|
500
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
501
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
502
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
503
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
504
|
+
|
|
505
|
+
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
506
|
+
|
|
507
|
+
if ( perspective ) {
|
|
508
|
+
|
|
509
|
+
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
510
|
+
|
|
511
|
+
trimSegment( start, end );
|
|
512
|
+
|
|
513
|
+
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
514
|
+
|
|
515
|
+
trimSegment( end, start );
|
|
516
|
+
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// clip space
|
|
522
|
+
vec4 clipStart = projectionMatrix * start;
|
|
523
|
+
vec4 clipEnd = projectionMatrix * end;
|
|
524
|
+
|
|
525
|
+
// ndc space
|
|
526
|
+
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
527
|
+
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
528
|
+
|
|
529
|
+
// direction
|
|
530
|
+
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
531
|
+
|
|
532
|
+
// account for clip-space aspect ratio
|
|
533
|
+
dir.x *= aspect;
|
|
534
|
+
dir = normalize( dir );
|
|
535
|
+
|
|
536
|
+
#ifdef WORLD_UNITS
|
|
537
|
+
|
|
538
|
+
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
539
|
+
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
540
|
+
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
541
|
+
vec3 worldFwd = cross( worldDir, worldUp );
|
|
542
|
+
worldPos = position.y < 0.5 ? start: end;
|
|
543
|
+
|
|
544
|
+
// height offset
|
|
545
|
+
float hw = linewidth * 0.5;
|
|
546
|
+
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
547
|
+
|
|
548
|
+
// don't extend the line if we're rendering dashes because we
|
|
549
|
+
// won't be rendering the endcaps
|
|
550
|
+
#ifndef USE_DASH
|
|
551
|
+
|
|
552
|
+
// cap extension
|
|
553
|
+
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
554
|
+
|
|
555
|
+
// add width to the box
|
|
556
|
+
worldPos.xyz += worldFwd * hw;
|
|
557
|
+
|
|
558
|
+
// endcaps
|
|
559
|
+
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
560
|
+
|
|
561
|
+
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
562
|
+
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
#endif
|
|
566
|
+
|
|
567
|
+
// project the worldpos
|
|
568
|
+
vec4 clip = projectionMatrix * worldPos;
|
|
569
|
+
|
|
570
|
+
// shift the depth of the projected points so the line
|
|
571
|
+
// segments overlap neatly
|
|
572
|
+
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
573
|
+
clip.z = clipPose.z * clip.w;
|
|
574
|
+
|
|
575
|
+
#else
|
|
576
|
+
|
|
577
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
578
|
+
// undo aspect ratio adjustment
|
|
579
|
+
dir.x /= aspect;
|
|
580
|
+
offset.x /= aspect;
|
|
581
|
+
|
|
582
|
+
// sign flip
|
|
583
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
584
|
+
|
|
585
|
+
// endcaps
|
|
586
|
+
if ( position.y < 0.0 ) {
|
|
587
|
+
|
|
588
|
+
offset += - dir;
|
|
589
|
+
|
|
590
|
+
} else if ( position.y > 1.0 ) {
|
|
591
|
+
|
|
592
|
+
offset += dir;
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// adjust for linewidth
|
|
597
|
+
offset *= linewidth;
|
|
598
|
+
|
|
599
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
600
|
+
offset /= resolution.y;
|
|
601
|
+
|
|
602
|
+
// select end
|
|
603
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
604
|
+
|
|
605
|
+
// back to clip space
|
|
606
|
+
offset *= clip.w;
|
|
607
|
+
|
|
608
|
+
clip.xy += offset;
|
|
609
|
+
|
|
610
|
+
#endif
|
|
611
|
+
|
|
612
|
+
gl_Position = clip;
|
|
613
|
+
|
|
614
|
+
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
615
|
+
|
|
616
|
+
#include <logdepthbuf_vertex>
|
|
617
|
+
#include <clipping_planes_vertex>
|
|
618
|
+
#include <fog_vertex>
|
|
619
|
+
|
|
620
|
+
}
|
|
621
|
+
`,fragmentShader:`
|
|
622
|
+
uniform vec3 diffuse;
|
|
623
|
+
uniform float opacity;
|
|
624
|
+
uniform float linewidth;
|
|
625
|
+
|
|
626
|
+
#ifdef USE_DASH
|
|
627
|
+
|
|
628
|
+
uniform float dashOffset;
|
|
629
|
+
uniform float dashSize;
|
|
630
|
+
uniform float gapSize;
|
|
631
|
+
|
|
632
|
+
#endif
|
|
633
|
+
|
|
634
|
+
varying float vLineDistance;
|
|
635
|
+
|
|
636
|
+
#ifdef WORLD_UNITS
|
|
637
|
+
|
|
638
|
+
varying vec4 worldPos;
|
|
639
|
+
varying vec3 worldStart;
|
|
640
|
+
varying vec3 worldEnd;
|
|
641
|
+
|
|
642
|
+
#ifdef USE_DASH
|
|
643
|
+
|
|
644
|
+
varying vec2 vUv;
|
|
645
|
+
|
|
646
|
+
#endif
|
|
647
|
+
|
|
648
|
+
#else
|
|
649
|
+
|
|
650
|
+
varying vec2 vUv;
|
|
651
|
+
|
|
652
|
+
#endif
|
|
653
|
+
|
|
654
|
+
#include <common>
|
|
655
|
+
#include <color_pars_fragment>
|
|
656
|
+
#include <fog_pars_fragment>
|
|
657
|
+
#include <logdepthbuf_pars_fragment>
|
|
658
|
+
#include <clipping_planes_pars_fragment>
|
|
659
|
+
|
|
660
|
+
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
661
|
+
|
|
662
|
+
float mua;
|
|
663
|
+
float mub;
|
|
664
|
+
|
|
665
|
+
vec3 p13 = p1 - p3;
|
|
666
|
+
vec3 p43 = p4 - p3;
|
|
667
|
+
|
|
668
|
+
vec3 p21 = p2 - p1;
|
|
669
|
+
|
|
670
|
+
float d1343 = dot( p13, p43 );
|
|
671
|
+
float d4321 = dot( p43, p21 );
|
|
672
|
+
float d1321 = dot( p13, p21 );
|
|
673
|
+
float d4343 = dot( p43, p43 );
|
|
674
|
+
float d2121 = dot( p21, p21 );
|
|
675
|
+
|
|
676
|
+
float denom = d2121 * d4343 - d4321 * d4321;
|
|
677
|
+
|
|
678
|
+
float numer = d1343 * d4321 - d1321 * d4343;
|
|
679
|
+
|
|
680
|
+
mua = numer / denom;
|
|
681
|
+
mua = clamp( mua, 0.0, 1.0 );
|
|
682
|
+
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
683
|
+
mub = clamp( mub, 0.0, 1.0 );
|
|
684
|
+
|
|
685
|
+
return vec2( mua, mub );
|
|
686
|
+
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
void main() {
|
|
690
|
+
|
|
691
|
+
float alpha = opacity;
|
|
692
|
+
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
693
|
+
|
|
694
|
+
#include <clipping_planes_fragment>
|
|
695
|
+
|
|
696
|
+
#ifdef USE_DASH
|
|
697
|
+
|
|
698
|
+
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
699
|
+
|
|
700
|
+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
701
|
+
|
|
702
|
+
#endif
|
|
703
|
+
|
|
704
|
+
#ifdef WORLD_UNITS
|
|
705
|
+
|
|
706
|
+
// Find the closest points on the view ray and the line segment
|
|
707
|
+
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
708
|
+
vec3 lineDir = worldEnd - worldStart;
|
|
709
|
+
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
710
|
+
|
|
711
|
+
vec3 p1 = worldStart + lineDir * params.x;
|
|
712
|
+
vec3 p2 = rayEnd * params.y;
|
|
713
|
+
vec3 delta = p1 - p2;
|
|
714
|
+
float len = length( delta );
|
|
715
|
+
float norm = len / linewidth;
|
|
716
|
+
|
|
717
|
+
#ifndef USE_DASH
|
|
718
|
+
|
|
719
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
720
|
+
|
|
721
|
+
float dnorm = fwidth( norm );
|
|
722
|
+
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
723
|
+
|
|
724
|
+
#else
|
|
725
|
+
|
|
726
|
+
if ( norm > 0.5 ) {
|
|
727
|
+
|
|
728
|
+
discard;
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
#endif
|
|
733
|
+
|
|
734
|
+
#endif
|
|
735
|
+
|
|
736
|
+
#else
|
|
737
|
+
|
|
738
|
+
#ifdef USE_ALPHA_TO_COVERAGE
|
|
739
|
+
|
|
740
|
+
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
741
|
+
float a = vUv.x;
|
|
742
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
743
|
+
float len2 = a * a + b * b;
|
|
744
|
+
float dlen = fwidth( len2 );
|
|
745
|
+
|
|
746
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
747
|
+
|
|
748
|
+
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
749
|
+
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
#else
|
|
753
|
+
|
|
754
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
755
|
+
|
|
756
|
+
float a = vUv.x;
|
|
757
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
758
|
+
float len2 = a * a + b * b;
|
|
759
|
+
|
|
760
|
+
if ( len2 > 1.0 ) discard;
|
|
761
|
+
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
#endif
|
|
765
|
+
|
|
766
|
+
#endif
|
|
767
|
+
|
|
768
|
+
#include <logdepthbuf_fragment>
|
|
769
|
+
#include <color_fragment>
|
|
770
|
+
|
|
771
|
+
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
772
|
+
|
|
773
|
+
#include <tonemapping_fragment>
|
|
774
|
+
#include <colorspace_fragment>
|
|
775
|
+
#include <fog_fragment>
|
|
776
|
+
#include <premultiplied_alpha_fragment>
|
|
777
|
+
|
|
778
|
+
}
|
|
779
|
+
`};var cK=class extends i.ShaderMaterial{constructor(e){super({type:`LineMaterial`,uniforms:i.UniformsUtils.clone(i.ShaderLib.line.uniforms),vertexShader:i.ShaderLib.line.vertexShader,fragmentShader:i.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},lK=new i.Vector4,uK=new i.Vector3,dK=new i.Vector3,fK=new i.Vector4,pK=new i.Vector4,mK=new i.Vector4,hK=new i.Vector3,gK=new i.Matrix4,_K=new i.Line3,vK=new i.Vector3,yK=new i.Box3,bK=new i.Sphere,xK=new i.Vector4,SK,CK;function wK(e,t,n){return xK.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),xK.multiplyScalar(1/xK.w),xK.x=CK/n.width,xK.y=CK/n.height,xK.applyMatrix4(e.projectionMatrixInverse),xK.multiplyScalar(1/xK.w),Math.abs(Math.max(xK.x,xK.y))}function TK(e,t){let n=e.matrixWorld,r=e.geometry,a=r.attributes.instanceStart,o=r.attributes.instanceEnd,s=Math.min(r.instanceCount,a.count);for(let r=0,c=s;r<c;r++){_K.start.fromBufferAttribute(a,r),_K.end.fromBufferAttribute(o,r),_K.applyMatrix4(n);let s=new i.Vector3,c=new i.Vector3;SK.distanceSqToSegment(_K.start,_K.end,c,s),c.distanceTo(s)<CK*.5&&t.push({point:c,pointOnLine:s,distance:SK.origin.distanceTo(c),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function EK(e,t,n){let r=t.projectionMatrix,a=e.material.resolution,o=e.matrixWorld,s=e.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-t.near;SK.at(1,mK),mK.w=1,mK.applyMatrix4(t.matrixWorldInverse),mK.applyMatrix4(r),mK.multiplyScalar(1/mK.w),mK.x*=a.x/2,mK.y*=a.y/2,mK.z=0,hK.copy(mK),gK.multiplyMatrices(t.matrixWorldInverse,o);for(let t=0,s=u;t<s;t++){if(fK.fromBufferAttribute(c,t),pK.fromBufferAttribute(l,t),fK.w=1,pK.w=1,fK.applyMatrix4(gK),pK.applyMatrix4(gK),fK.z>d&&pK.z>d)continue;if(fK.z>d){let e=fK.z-pK.z,t=(fK.z-d)/e;fK.lerp(pK,t)}else if(pK.z>d){let e=pK.z-fK.z,t=(pK.z-d)/e;pK.lerp(fK,t)}fK.applyMatrix4(r),pK.applyMatrix4(r),fK.multiplyScalar(1/fK.w),pK.multiplyScalar(1/pK.w),fK.x*=a.x/2,fK.y*=a.y/2,pK.x*=a.x/2,pK.y*=a.y/2,_K.start.copy(fK),_K.start.z=0,_K.end.copy(pK),_K.end.z=0;let s=_K.closestPointToPointParameter(hK,!0);_K.at(s,vK);let u=i.MathUtils.lerp(fK.z,pK.z,s),f=u>=-1&&u<=1,p=hK.distanceTo(vK)<CK*.5;if(f&&p){_K.start.fromBufferAttribute(c,t),_K.end.fromBufferAttribute(l,t),_K.start.applyMatrix4(o),_K.end.applyMatrix4(o);let r=new i.Vector3,a=new i.Vector3;SK.distanceSqToSegment(_K.start,_K.end,a,r),n.push({point:a,pointOnLine:r,distance:SK.origin.distanceTo(a),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var DK=class extends i.Mesh{constructor(e=new sK,t=new cK({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)uK.fromBufferAttribute(t,e),dK.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+uK.distanceTo(dK);let a=new i.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new i.InterleavedBufferAttribute(a,1,0)),e.setAttribute(`instanceDistanceEnd`,new i.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`);let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;SK=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;CK=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),bK.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?CK*.5:wK(r,Math.max(r.near,bK.distanceToPoint(SK.origin)),s.resolution),bK.radius+=c,SK.intersectsSphere(bK)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),yK.copy(o.boundingBox).applyMatrix4(a);let l;l=n?CK*.5:wK(r,Math.max(r.near,yK.distanceToPoint(SK.origin)),s.resolution),yK.expandByScalar(l),SK.intersectsBox(yK)!==!1&&(n?TK(this,t):EK(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(lK),this.material.uniforms.resolution.value.set(lK.z,lK.w))}},OK=class extends sK{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},kK=class extends DK{constructor(e=new OK,t=new cK({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},AK=class extends i.ExtrudeGeometry{constructor(e,t={}){let n=t.font;if(n===void 0)super();else{let r=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t)}this.type=`TextGeometry`}},jK=class{constructor(e){this.isFont=!0,this.type=`Font`,this.data=e}generateShapes(e,t=100,n=`ltr`){let r=[],i=MK(e,t,this.data,n);for(let e=0,t=i.length;e<t;e++)r.push(...i[e].toShapes());return r}};function MK(e,t,n,r){let i=Array.from(e),a=t/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*a,s=[],c=0,l=0;(r==`rtl`||r==`tb`)&&i.reverse();for(let e=0;e<i.length;e++){let t=i[e];if(t===`
|
|
780
|
+
`)c=0,l-=o;else{let e=NK(t,a,c,l,n);r==`tb`?(c=0,l+=n.ascender*a):c+=e.offsetX,s.push(e.path)}}return s}function NK(e,t,n,r,a){let o=a.glyphs[e]||a.glyphs[`?`];if(!o){console.error(`THREE.Font: character "`+e+`" does not exists in font family `+a.familyName+`.`);return}let s=new i.ShapePath,c,l,u,d,f,p,m,h;if(o.o){let e=o._cachedOutline||=o.o.split(` `);for(let i=0,a=e.length;i<a;)switch(e[i++]){case`m`:c=e[i++]*t+n,l=e[i++]*t+r,s.moveTo(c,l);break;case`l`:c=e[i++]*t+n,l=e[i++]*t+r,s.lineTo(c,l);break;case`q`:u=e[i++]*t+n,d=e[i++]*t+r,f=e[i++]*t+n,p=e[i++]*t+r,s.quadraticCurveTo(f,p,u,d);break;case`b`:u=e[i++]*t+n,d=e[i++]*t+r,f=e[i++]*t+n,p=e[i++]*t+r,m=e[i++]*t+n,h=e[i++]*t+r,s.bezierCurveTo(f,p,m,h,u,d);break}}return{offsetX:o.ha*t,path:s}}var PK=class extends i.Object3D{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new i.Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new i.Vector3,new i.Matrix4,new i.Matrix4,new i.Vector3,new i.Vector3;function FK(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function IK(e){if(Array.isArray(e))return e}function LK(e){if(Array.isArray(e))return FK(e)}function RK(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function zK(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function BK(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function VK(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){BK(a,r,i,o,s,`next`,e)}function s(e){BK(a,r,i,o,s,`throw`,e)}o(void 0)})}}function HK(e,t,n){return t=$K(t),uq(e,tq()?Reflect.construct(t,n||[],$K(e).constructor):t.apply(e,n))}function UK(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function WK(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function GK(e,t){return e.get(RK(e,t))}function KK(e,t,n){UK(e,t),t.set(e,n)}function qK(e,t,n){return e.set(RK(e,t),n),n}function JK(e,t,n){if(tq())return Reflect.construct.apply(null,arguments);var r=[null];return r.push.apply(r,t),new(e.bind.apply(e,r))}function YK(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,yq(r.key),r)}}function XK(e,t,n){return t&&YK(e.prototype,t),Object.defineProperty(e,`prototype`,{writable:!1}),e}function ZK(e,t,n){return(t=yq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QK(){return QK=typeof Reflect<`u`&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=hq(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},QK.apply(null,arguments)}function $K(e){return $K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},$K(e)}function eq(e,t){if(typeof t!=`function`&&t!==null)throw 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&&pq(e,t)}function tq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tq=function(){return!!e})()}function nq(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function rq(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function iq(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
781
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aq(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
782
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?oq(Object(n),!0).forEach(function(t){ZK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cq(e,t){if(e==null)return{};var n,r,i=lq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function uq(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return zK(e)}function dq(){var e,t,n=typeof Symbol==`function`?Symbol:{},r=n.iterator||`@@iterator`,i=n.toStringTag||`@@toStringTag`;function a(n,r,i,a){var c=r&&r.prototype instanceof s?r:s,l=Object.create(c.prototype);return fq(l,`_invoke`,function(n,r,i){var a,s,c,l=0,u=i||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return a=t,s=0,c=e,f.n=n,o}};function p(n,r){for(s=n,c=r,t=0;!d&&l&&!i&&t<u.length;t++){var i,a=u[t],p=f.p,m=a[2];n>3?(i=m===r)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=p&&((i=n<2&&p<a[1])?(s=0,f.v=r,f.n=a[1]):p<m&&(i=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,f.n=m,s=0))}if(i||n>1)return o;throw d=!0,r}return function(i,u,m){if(l>1)throw TypeError(`Generator is already running`);for(d&&u===1&&p(u,m),s=u,c=m;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(f.n=-1),p(s,c)):f.n=c:f.v=c);try{if(l=2,a){if(s||(i=`next`),t=a[i]){if(!(t=t.call(a,c)))throw TypeError(`iterator result is not an object`);if(!t.done)return t;c=t.value,s<2&&(s=0)}else s===1&&(t=a.return)&&t.call(a),s<2&&(c=TypeError(`The iterator does not provide a '`+i+`' method`),s=1);a=e}else if((t=(d=f.n<0)?c:n.call(r,f))!==o)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,i,a),!0),l}var o={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(fq(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,fq(e,i,`GeneratorFunction`)),e.prototype=Object.create(d),e}return c.prototype=l,fq(d,`constructor`,l),fq(l,`constructor`,c),c.displayName=`GeneratorFunction`,fq(l,i,`GeneratorFunction`),fq(d),fq(d,i,`Generator`),fq(d,r,function(){return this}),fq(d,`toString`,function(){return`[object Generator]`}),(dq=function(){return{w:a,m:f}})()}function fq(e,t,n,r){var i=Object.defineProperty;try{i({},``,{})}catch{i=0}fq=function(e,t,n,r){function a(t,n){fq(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a(`next`,0),a(`throw`,1),a(`return`,2))},fq(e,t,n,r)}function pq(e,t){return pq=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},pq(e,t)}function mq(e,t){return IK(e)||rq(e,t)||bq(e,t)||iq()}function hq(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=$K(e))!==null;);return e}function gq(e,t,n,r){var i=QK($K(e.prototype),t,n);return typeof i==`function`?function(e){return i.apply(n,e)}:i}function _q(e){return LK(e)||nq(e)||bq(e)||aq()}function vq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function yq(e){var t=vq(e,`string`);return typeof t==`symbol`?t:t+``}function bq(e,t){if(e){if(typeof e==`string`)return FK(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?FK(e,t):void 0}}var xq=function(e){e instanceof Array?e.forEach(xq):(e.map&&e.map.dispose(),e.dispose())},Sq=function(e){e.geometry&&e.geometry.dispose(),e.material&&xq(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(Sq)},Cq=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),Sq(t)}};function wq(e,t){var n=new t;return{linkProp:function(t){return{default:n[t](),onChange:function(n,r){r[e][t](n)},triggerUpdate:!1}},linkMethod:function(t){return function(n){for(var r=n[e],i=arguments.length,a=Array(i>1?i-1:0),o=1;o<i;o++)a[o-1]=arguments[o];var s=r[t].apply(r,a);return s===r?this:s}}}}var Tq=100;function Eq(){return Tq}function Dq(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180,a=Tq*(1+n),o=Math.sin(r);return{x:a*o*Math.cos(i),y:a*Math.cos(r),z:a*o*Math.sin(i)}}function Oq(e){var t=e.x,n=e.y,r=e.z,i=Math.sqrt(t*t+n*n+r*r),a=Math.acos(n/i),o=Math.atan2(r,t);return{lat:90-a*180/Math.PI,lng:90-o*180/Math.PI-(o<-Math.PI/2?360:0),altitude:i/Tq-1}}function kq(e){return e*Math.PI/180}var Aq=window.THREE?window.THREE:{BackSide:i.BackSide,BufferAttribute:i.BufferAttribute,Color:i.Color,Mesh:i.Mesh,ShaderMaterial:i.ShaderMaterial},jq=`
|
|
783
|
+
uniform float hollowRadius;
|
|
784
|
+
|
|
785
|
+
varying vec3 vVertexWorldPosition;
|
|
786
|
+
varying vec3 vVertexNormal;
|
|
787
|
+
varying float vCameraDistanceToObjCenter;
|
|
788
|
+
varying float vVertexAngularDistanceToHollowRadius;
|
|
789
|
+
|
|
790
|
+
void main() {
|
|
791
|
+
vVertexNormal = normalize(normalMatrix * normal);
|
|
792
|
+
vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
793
|
+
|
|
794
|
+
vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
|
795
|
+
vCameraDistanceToObjCenter = length(objCenterViewPosition);
|
|
796
|
+
|
|
797
|
+
float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter);
|
|
798
|
+
float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition)));
|
|
799
|
+
vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle;
|
|
800
|
+
|
|
801
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
802
|
+
}`,Mq=`
|
|
803
|
+
uniform vec3 color;
|
|
804
|
+
uniform float coefficient;
|
|
805
|
+
uniform float power;
|
|
806
|
+
uniform float hollowRadius;
|
|
807
|
+
|
|
808
|
+
varying vec3 vVertexNormal;
|
|
809
|
+
varying vec3 vVertexWorldPosition;
|
|
810
|
+
varying float vCameraDistanceToObjCenter;
|
|
811
|
+
varying float vVertexAngularDistanceToHollowRadius;
|
|
812
|
+
|
|
813
|
+
void main() {
|
|
814
|
+
if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius
|
|
815
|
+
if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius
|
|
816
|
+
|
|
817
|
+
vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;
|
|
818
|
+
vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;
|
|
819
|
+
viewCameraToVertex = normalize(viewCameraToVertex);
|
|
820
|
+
float intensity = pow(
|
|
821
|
+
coefficient + dot(vVertexNormal, viewCameraToVertex),
|
|
822
|
+
power
|
|
823
|
+
);
|
|
824
|
+
gl_FragColor = vec4(color, intensity);
|
|
825
|
+
}`;function Nq(e,t,n,r){return new Aq.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:jq,fragmentShader:Mq,uniforms:{coefficient:{value:e},color:{value:new Aq.Color(t)},power:{value:n},hollowRadius:{value:r}}})}function Pq(e,t){for(var n=e.clone(),r=new Float32Array(e.attributes.position.count*3),i=0,a=r.length;i<a;i++){var o=e.attributes.normal.array[i];r[i]=e.attributes.position.array[i]+o*t}return n.setAttribute(`position`,new Aq.BufferAttribute(r,3)),n}var Fq=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.color,a=i===void 0?`gold`:i,o=r.size,s=o===void 0?2:o,c=r.coefficient,l=c===void 0?.5:c,u=r.power,d=u===void 0?1:u,f=r.hollowRadius,p=f===void 0?0:f,m=r.backside,h=m===void 0?!0:m;WK(this,t),n=HK(this,t);var g=Pq(e,s),_=Nq(l,a,d,p);return h&&(_.side=Aq.BackSide),n.geometry=g,n.material=_,n}return eq(t,e),XK(t)}(Aq.Mesh),Iq=window.THREE?window.THREE:{Color:i.Color,Group:i.Group,LineBasicMaterial:i.LineBasicMaterial,LineSegments:i.LineSegments,Mesh:i.Mesh,MeshPhongMaterial:i.MeshPhongMaterial,SphereGeometry:i.SphereGeometry,SRGBColorSpace:i.SRGBColorSpace,TextureLoader:i.TextureLoader},Lq=je({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:`lightskyblue`},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t===void 0?e.globeObj.material:(e.globeObj.material=t||e.defaultGlobeMaterial,this)},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Sq(e.globeObj),Sq(e.tileEngine),Sq(e.graticulesObj)}},stateInit:function(){var e=new Iq.MeshPhongMaterial({color:0}),t=new Iq.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new Us(Tq),r=new Iq.Group;return r.__globeObjType=`globe`,r.add(t),r.add(n),{globeGroup:r,globeObj:t,graticulesObj:new Iq.LineSegments(new Yc(po(),Tq,2),new Iq.LineBasicMaterial({color:`lightgrey`,transparent:!0,opacity:.1})),defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){Cq(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty(`globeCurvatureResolution`)){var r;(r=e.globeObj.geometry)==null||r.dispose();var i=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new Iq.SphereGeometry(Tq,i,i/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty(`globeImageUrl`)&&(e.globeImageUrl?new Iq.TextureLoader().load(e.globeImageUrl,function(t){var r;t.colorSpace=Iq.SRGBColorSpace,(r=n.map)==null||r.dispose(),n.map=t,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new Iq.Color(0))),t.hasOwnProperty(`bumpImageUrl`)&&(e.bumpImageUrl?e.bumpImageUrl&&new Iq.TextureLoader().load(e.bumpImageUrl,function(e){var t;(t=n.bumpMap)==null||t.dispose(),n.bumpMap=e,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty(`atmosphereColor`)||t.hasOwnProperty(`atmosphereAltitude`))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Sq(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Fq(e.globeObj.geometry,{color:e.atmosphereColor,size:Tq*e.atmosphereAltitude,hollowRadius:Tq,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType=`atmosphere`,e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),Rq=function(e){return isNaN(e)?parseInt(gl(e).toHex(),16):e},zq=function(e){return e&&isNaN(e)?en(e).opacity:1},Bq=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,a=1,o=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(o){var s=mq(o.slice(1),4),c=s[0],l=s[1],u=s[2],d=s[3];r=new i.Color(`rgb(${+c},${+l},${+u})`),a=Math.min(+d,1)}else r=new i.Color(e);n&&r.convertLinearToSRGB();var f=r.toArray();return t?[].concat(_q(f),[a]):f};function Vq(e,t,n){return e.opacity=t,e.transparent=t<1,e.depthWrite=t>=1,e}var Hq=window.THREE?window.THREE:{BufferAttribute:i.BufferAttribute};function Uq(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(t===1)return new Hq.BufferAttribute(new n(e),t);for(var r=new Hq.BufferAttribute(new n(e.length*t),t),i=0,a=e.length;i<a;i++)r.set(e[i],i*t);return r}function Wq(e){for(var t=e.itemSize,n=[],r=0;r<e.count;r++)n.push(e.array.slice(r*t,(r+1)*t));return n}var Gq=new WeakMap,Kq=new WeakMap,qq=new WeakMap,Jq=function(e){function t(e){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=r.dataBindAttr,a=i===void 0?`__data`:i,o=r.objBindAttr,s=o===void 0?`__threeObj`:o,c=r.removeDelay,l=c===void 0?0:c;return WK(this,t),n=HK(this,t),ZK(n,`scene`,void 0),KK(n,Gq,void 0),KK(n,Kq,void 0),KK(n,qq,void 0),n.scene=e,qK(Gq,n,a),qK(Kq,n,s),qK(qq,n,l),n.onRemoveObj(function(){}),n}return eq(t,e),XK(t,[{key:`onCreateObj`,value:function(e){var n=this;return gq(t,`onCreateObj`,this)([function(t){var r=e(t);return t[GK(Kq,n)]=r,r[GK(Gq,n)]=t,n.scene.add(r),r}]),this}},{key:`onRemoveObj`,value:function(e){var n=this;return gq(t,`onRemoveObj`,this)([function(r,i){var a=gq(t,`getData`,n)([r]);e(r,i);var o=function(){n.scene.remove(r),Sq(r),delete a[GK(Kq,n)]};GK(qq,n)?setTimeout(o,GK(qq,n)):o()}]),this}}])}(Du),Yq=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,CylinderGeometry:i.CylinderGeometry,Matrix4:i.Matrix4,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,Object3D:i.Object3D,Vector3:i.Vector3},Xq=Object.assign({},$c),Zq=Xq.BufferGeometryUtils||Xq,Qq=je({props:{pointsData:{default:[]},pointLat:{default:`lat`},pointLng:{default:`lng`},pointColor:{default:function(){return`#ffffaa`}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjPoint`})},update:function(e,t){var n=I(e.pointLat),r=I(e.pointLng),i=I(e.pointAltitude),a=I(e.pointRadius),o=I(e.pointColor),s=new Yq.CylinderGeometry(1,1,1,e.pointResolution);s.applyMatrix4(new Yq.Matrix4().makeRotationX(Math.PI/2)),s.applyMatrix4(new Yq.Matrix4().makeTranslation(0,0,-.5));var c=2*Math.PI*Tq/360,l={};if(!e.pointsMerge&&t.hasOwnProperty(`pointsMerge`)&&Cq(e.scene),e.dataMapper.scene=e.pointsMerge?new Yq.Object3D:e.scene,e.dataMapper.onCreateObj(f).onUpdateObj(p).digest(e.pointsData),e.pointsMerge){var u=e.pointsData.length?(Zq.mergeGeometries||Zq.mergeBufferGeometries)(e.pointsData.map(function(t){var n=e.dataMapper.getObj(t),r=n.geometry.clone();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=Bq(o(t));return r.setAttribute(`color`,Uq(Array(r.getAttribute(`position`).count).fill(i),4)),r})):new Yq.BufferGeometry,d=new Yq.Mesh(u,new Yq.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));d.__globeObjType=`points`,d.__data=e.pointsData,e.dataMapper.clear(),Cq(e.scene),e.scene.add(d)}function f(){var e=new Yq.Mesh(s);return e.__globeObjType=`point`,e}function p(t,s){var u=function(n){var r=t.__currentTargetD=n,i=r.r,a=r.alt,o=r.lat,s=r.lng;Object.assign(t.position,Dq(o,s));var l=e.pointsMerge?new Yq.Vector3(0,0,0):e.scene.localToWorld(new Yq.Vector3(0,0,0));t.lookAt(l),t.scale.x=t.scale.y=Math.min(30,i)*c,t.scale.z=Math.max(a*Tq,.1)},d={alt:+i(s),r:+a(s),lat:+n(s),lng:+r(s)},f=t.__currentTargetD||Object.assign({},d,{alt:-.001});if(Object.keys(d).some(function(e){return f[e]!==d[e]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?u(d):e.tweenGroup.add(new Re(f).to(d,e.pointsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(u).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.pointsMerge){var p=o(s),m=p?zq(p):0,h=!!m;t.visible=h,h&&(l.hasOwnProperty(p)||(l[p]=new Yq.MeshLambertMaterial({color:Rq(p),transparent:m<1,opacity:m})),t.material=l[p])}}}}),$q=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:`
|
|
826
|
+
${i.ShaderChunk.common}
|
|
827
|
+
${i.ShaderChunk.logdepthbuf_pars_vertex}
|
|
828
|
+
|
|
829
|
+
uniform float dashTranslate;
|
|
830
|
+
|
|
831
|
+
attribute vec4 color;
|
|
832
|
+
varying vec4 vColor;
|
|
833
|
+
|
|
834
|
+
attribute float relDistance;
|
|
835
|
+
varying float vRelDistance;
|
|
836
|
+
|
|
837
|
+
void main() {
|
|
838
|
+
// pass through colors and distances
|
|
839
|
+
vColor = color;
|
|
840
|
+
vRelDistance = relDistance + dashTranslate;
|
|
841
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
842
|
+
|
|
843
|
+
${i.ShaderChunk.logdepthbuf_vertex}
|
|
844
|
+
}
|
|
845
|
+
`,fragmentShader:`
|
|
846
|
+
${i.ShaderChunk.logdepthbuf_pars_fragment}
|
|
847
|
+
|
|
848
|
+
uniform float dashOffset;
|
|
849
|
+
uniform float dashSize;
|
|
850
|
+
uniform float gapSize;
|
|
851
|
+
|
|
852
|
+
varying vec4 vColor;
|
|
853
|
+
varying float vRelDistance;
|
|
854
|
+
|
|
855
|
+
void main() {
|
|
856
|
+
// ignore pixels in the gap
|
|
857
|
+
if (vRelDistance < dashOffset) discard;
|
|
858
|
+
if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard;
|
|
859
|
+
|
|
860
|
+
// set px color: [r, g, b, a], interpolated between vertices
|
|
861
|
+
gl_FragColor = vColor;
|
|
862
|
+
|
|
863
|
+
${i.ShaderChunk.logdepthbuf_fragment}
|
|
864
|
+
}
|
|
865
|
+
`}},eJ=function(e){return e.uniforms.uSurfaceRadius={type:`float`,value:0},e.vertexShader=(`attribute float surfaceRadius;
|
|
866
|
+
varying float vSurfaceRadius;
|
|
867
|
+
varying vec3 vPos;
|
|
868
|
+
`+e.vertexShader).replace(`void main() {`,[`void main() {`,`vSurfaceRadius = surfaceRadius;`,`vPos = position;`].join(`
|
|
869
|
+
`)),e.fragmentShader=(`uniform float uSurfaceRadius;
|
|
870
|
+
varying float vSurfaceRadius;
|
|
871
|
+
varying vec3 vPos;
|
|
872
|
+
`+e.fragmentShader).replace(`void main() {`,[`void main() {`,`if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;`].join(`
|
|
873
|
+
`)),e},tJ=function(e){return e.vertexShader=`
|
|
874
|
+
attribute float r;
|
|
875
|
+
|
|
876
|
+
const float PI = 3.1415926535897932384626433832795;
|
|
877
|
+
float toRad(in float a) {
|
|
878
|
+
return a * PI / 180.0;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r]
|
|
882
|
+
float phi = toRad(90.0 - c.x);
|
|
883
|
+
float theta = toRad(90.0 - c.y);
|
|
884
|
+
float r = c.z;
|
|
885
|
+
return vec3( // x,y,z
|
|
886
|
+
r * sin(phi) * cos(theta),
|
|
887
|
+
r * cos(phi),
|
|
888
|
+
r * sin(phi) * sin(theta)
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
vec2 Cartesian2Polar(in vec3 p) {
|
|
893
|
+
float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
|
|
894
|
+
float phi = acos(p.y / r);
|
|
895
|
+
float theta = atan(p.z, p.x);
|
|
896
|
+
return vec2( // lat,lng
|
|
897
|
+
90.0 - phi * 180.0 / PI,
|
|
898
|
+
90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0)
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
${e.vertexShader.replace(`}`,`
|
|
902
|
+
vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r));
|
|
903
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
904
|
+
}
|
|
905
|
+
`)}
|
|
906
|
+
`,e},nJ=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},rJ=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(e){return e};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(e){n(e),t(e.uniforms)}}},iJ=[`stroke`],aJ=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,CubicBezierCurve3:i.CubicBezierCurve3,Curve:i.Curve,Group:i.Group,Line:i.Line,Mesh:i.Mesh,NormalBlending:i.NormalBlending,ShaderMaterial:i.ShaderMaterial,TubeGeometry:i.TubeGeometry,Vector3:i.Vector3},oJ=Ou.default.default||Ou.default,sJ=je({props:{arcsData:{default:[]},arcStartLat:{default:`startLat`},arcStartLng:{default:`startLng`},arcStartAltitude:{default:0},arcEndLat:{default:`endLat`},arcEndLng:{default:`endLng`},arcEndAltitude:{default:0},arcColor:{default:function(){return`#ffffaa`}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new oJ,sharedMaterial:new aJ.ShaderMaterial(sq(sq({},$q()),{},{transparent:!0,blending:aJ.NormalBlending}))}},init:function(e,t){Cq(e),t.scene=e,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjArc`}).onCreateObj(function(){var e=new aJ.Group;return e.__globeObjType=`arc`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return mq(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n,i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r})})},update:function(e){var t=I(e.arcStartLat),n=I(e.arcStartLng),r=I(e.arcStartAltitude),i=I(e.arcEndLat),a=I(e.arcEndLng),o=I(e.arcEndAltitude),s=I(e.arcAltitude),c=I(e.arcAltitudeAutoScale),l=I(e.arcStroke),u=I(e.arcColor),d=I(e.arcDashLength),f=I(e.arcDashGap),p=I(e.arcDashInitialGap),m=I(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(v,y){var b=l(y),x=b!=null;if(!v.children.length||x!==(v.children[0].type===`Mesh`)){Cq(v);var S=x?new aJ.Mesh:new aJ.Line(new aJ.BufferGeometry);S.material=e.sharedMaterial.clone(),v.add(S)}var C=v.children[0];Object.assign(C.material.uniforms,{dashSize:{value:d(y)},gapSize:{value:f(y)},dashOffset:{value:p(y)}});var w=m(y);C.__dashAnimateStep=w>0?1e3/w:0;var T=g(u(y),e.arcCurveResolution,x?e.arcCircularResolution+1:1),E=_(e.arcCurveResolution,x?e.arcCircularResolution+1:1,!0);C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E);var D=function(t){var n=v.__currentTargetD=t,r=n.stroke,i=h(cq(n,iJ));x?(C.geometry&&C.geometry.dispose(),C.geometry=new aJ.TubeGeometry(i,e.arcCurveResolution,r/2,e.arcCircularResolution),C.geometry.setAttribute(`color`,T),C.geometry.setAttribute(`relDistance`,E)):C.geometry.setFromPoints(i.getPoints(e.arcCurveResolution))},O={stroke:b,alt:s(y),altAutoScale:+c(y),startLat:+t(y),startLng:+n(y),startAlt:+r(y),endLat:+i(y),endLng:+a(y),endAlt:+o(y)},k=v.__currentTargetD||Object.assign({},O,{altAutoScale:-.001});Object.keys(O).some(function(e){return k[e]!==O[e]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?D(O):e.tweenGroup.add(new Re(k).to(O,e.arcsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(D).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.arcsData);function h(e){var t=e.alt,n=e.altAutoScale,r=e.startLat,i=e.startLng,a=e.startAlt,o=e.endLat,s=e.endLng,c=e.endAlt,l=function(e){var t=mq(e,3),n=t[0],r=t[1],i=t[2],a=Dq(r,n,i),o=a.x,s=a.y,c=a.z;return new aJ.Vector3(o,s,c)},u=[i,r],d=[s,o],f=t;if(f??=$a(u,d)/2*n+Math.max(a,c),f||a||c){var p=mo(u,d),m=function(e,t){return t+(t-e)*(e<t?.5:.25)},h=mq([.25,.75].map(function(e){return[].concat(_q(p(e)),[m(e<.5?a:c,f)])}),2),g=h[0],_=h[1];return JK(aJ.CubicBezierCurve3,_q([[].concat(u,[a]),g,_,[].concat(d,[c])].map(l)))}else{var v=.001;return y.apply(void 0,_q([[].concat(u,[v]),[].concat(d,[v])].map(l)))}function y(e,t){var n=e.angleTo(t),r=n===0?function(){return e.clone()}:function(r){return new aJ.Vector3().addVectors(e.clone().multiplyScalar(Math.sin((1-r)*n)),t.clone().multiplyScalar(Math.sin(r*n))).divideScalar(Math.sin(n))},i=new aJ.Curve;return i.getPoint=r,i}}function g(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t+1,i;if(e instanceof Array||e instanceof Function){var a=e instanceof Array?Cr().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;i=function(e){return Bq(a(e),!0,!0)}}else{var o=Bq(e,!0,!0);i=function(){return o}}for(var s=[],c=0,l=r;c<l;c++)for(var u=i(c/(l-1)),d=0;d<n;d++)s.push(u);return Uq(s,4)}function _(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e+1,i=[],a=0,o=r;a<o;a++)for(var s=a/(o-1),c=0;c<t;c++)i.push(s);return n&&i.reverse(),Uq(i,1)}}}),cJ=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,DoubleSide:i.DoubleSide,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,Object3D:i.Object3D},lJ=Object.assign({},$c),uJ=lJ.BufferGeometryUtils||lJ,dJ=je({props:{hexBinPointsData:{default:[]},hexBinPointLat:{default:`lat`},hexBinPointLng:{default:`lng`},hexBinPointWeight:{default:1},hexBinResolution:{default:4},hexMargin:{default:.2},hexTopCurvatureResolution:{default:5},hexTopColor:{default:function(){return`#ffffaa`}},hexSideColor:{default:function(){return`#ffffaa`}},hexAltitude:{default:function(e){return e.sumWeight*.01}},hexBinMerge:{default:!1},hexTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjHexbin`})},update:function(e,t){var n=I(e.hexBinPointLat),r=I(e.hexBinPointLng),i=I(e.hexBinPointWeight),a=I(e.hexAltitude),o=I(e.hexTopColor),s=I(e.hexSideColor),c=I(e.hexMargin),l=Hf(e.hexBinPointsData.map(function(t){return sq(sq({},t),{},{h3Idx:rm(n(t),r(t),e.hexBinResolution)})}),`h3Idx`),u=Object.entries(l).map(function(e){var t=mq(e,2),n=t[0],r=t[1];return{h3Idx:n,points:r,sumWeight:r.reduce(function(e,t){return e+ +i(t)},0)}}),d={};if(!e.hexBinMerge&&t.hasOwnProperty(`hexBinMerge`)&&Cq(e.scene),e.dataMapper.scene=e.hexBinMerge?new cJ.Object3D:e.scene,e.dataMapper.id(function(e){return e.h3Idx}).onCreateObj(h).onUpdateObj(g).digest(u),e.hexBinMerge){var f=u.length?(uJ.mergeGeometries||uJ.mergeBufferGeometries)(u.map(function(t){var n=e.dataMapper.getObj(t),r=n.geometry.toNonIndexed();n.updateMatrix(),r.applyMatrix4(n.matrix);var i=Bq(o(t)),a=Bq(s(t)),c=r.getAttribute(`position`).count,l=r.groups[0].count;return r.setAttribute(`color`,Uq(_q(Array(c)).map(function(e,t){return t>=l?i:a}),4)),r})):new cJ.BufferGeometry,p=new cJ.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:cJ.DoubleSide});p.onBeforeCompile=function(e){p.userData.shader=eJ(e)};var m=new cJ.Mesh(f,p);m.__globeObjType=`hexBinPoints`,m.__data=u,e.dataMapper.clear(),Cq(e.scene),e.scene.add(m)}function h(e){var t=new cJ.Mesh;t.__hexCenter=im(e.h3Idx),t.__hexGeoJson=am(e.h3Idx,!0).reverse();var n=t.__hexCenter[1];return t.__hexGeoJson.forEach(function(e){var t=e[0];Math.abs(n-t)>170&&(e[0]+=n>t?360:-360)}),t.__globeObjType=`hexbin`,t}function g(t,n){var r=function(e,t,n){return e-(e-t)*n},i=Math.max(0,Math.min(1,+c(n))),l=mq(t.__hexCenter,2),u=l[0],f=l[1],p=i===0?t.__hexGeoJson:t.__hexGeoJson.map(function(e){var t=mq(e,2),n=t[0],a=t[1];return[[n,f],[a,u]].map(function(e){var t=mq(e,2),n=t[0],a=t[1];return r(n,a,i)})}),m=e.hexTopCurvatureResolution;t.geometry&&t.geometry.dispose(),t.geometry=new Ef([p],0,Tq,!1,!0,!0,m);var h={alt:+a(n)},g=function(e){var n=(t.__currentTargetD=e).alt;t.scale.x=t.scale.y=t.scale.z=1+n;var r=Tq/(n+1);t.geometry.setAttribute(`surfaceRadius`,Uq(Array(t.geometry.getAttribute(`position`).count).fill(r),1))},_=t.__currentTargetD||Object.assign({},h,{alt:-.001});if(Object.keys(h).some(function(e){return _[e]!==h[e]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?g(h):e.tweenGroup.add(new Re(_).to(h,e.hexTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(g).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.hexBinMerge){var v=s(n),y=o(n);[v,y].forEach(function(e){if(!d.hasOwnProperty(e)){var t=zq(e);d[e]=nJ(new cJ.MeshLambertMaterial({color:Rq(e),transparent:t<1,opacity:t,side:cJ.DoubleSide}),eJ)}}),t.material=[v,y].map(function(e){return d[e]})}}}}),fJ=function(e){return e*e},pJ=function(e){return e*Math.PI/180};function mJ(e,t){var n=Math.sqrt,r=Math.cos,i=function(e){return fJ(Math.sin(e/2))},a=pJ(e[1]),o=pJ(t[1]),s=pJ(e[0]),c=pJ(t[0]);return 2*Math.asin(n(i(o-a)+r(a)*r(o)*i(c-s)))}var hJ=Math.sqrt(2*Math.PI);function gJ(e,t){return Math.exp(-fJ(e/t)/2)/(t*hJ)}var _J=function(e){var t=mq(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=a.lngAccessor,s=o===void 0?function(e){return e[0]}:o,c=a.latAccessor,l=c===void 0?function(e){return e[1]}:c,u=a.weightAccessor,d=u===void 0?function(){return 1}:u,f=a.bandwidth,p=[n,r],m=f*Math.PI/180;return Mt(i.map(function(e){var t=d(e);return t?gJ(mJ(p,[s(e),l(e)]),m)*t:0}))},vJ=function(){var e=VK(dq().m(function e(t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,ee,j,te,ne,re,ie,ae,oe,se,ce,le,ue=arguments,de,fe,pe;return dq().w(function(e){for(;;)switch(e.n){case 0:if(r=ue.length>1&&ue[1]!==void 0?ue[1]:[],i=ue.length>2&&ue[2]!==void 0?ue[2]:{},a=i.lngAccessor,o=a===void 0?function(e){return e[0]}:a,s=i.latAccessor,c=s===void 0?function(e){return e[1]}:s,l=i.weightAccessor,u=l===void 0?function(){return 1}:l,d=i.bandwidth,(n=navigator)!=null&&n.gpu){e.n=1;break}return console.warn(`WebGPU not enabled in browser. Please consider enabling it to improve performance.`),e.a(2,t.map(function(e){return _J(e,r,{lngAccessor:o,latAccessor:c,weightAccessor:u,bandwidth:d})}));case 1:return f=4,p=KG,m=qG,h=iK,g=rK,_=QG,v=$G,y=JG,b=nK,x=tK,S=XG,C=YG,w=ZG,T=eK,E=g(new uL(new Float32Array(t.flat().map(pJ)),2),`vec2`,t.length),D=g(new uL(new Float32Array(r.map(function(e){return[pJ(o(e)),pJ(c(e)),u(e)]}).flat()),3),`vec3`,r.length),O=new uL(t.length,1),k=g(O,`float`,t.length),A=_(Math.PI),ee=b(A.mul(2)),j=function(e){return e.mul(e)},te=function(e){return j(x(e.div(2)))},ne=function(e,t){var n=_(e[1]),r=_(t[1]),i=_(e[0]),a=_(t[0]);return _(2).mul(C(b(te(r.sub(n)).add(S(n).mul(S(r)).mul(te(a.sub(i)))))))},re=function(e,t){return w(T(j(e.div(t)).div(2))).div(t.mul(ee))},ie=h(pJ(d)),ae=h(pJ(d*f)),oe=h(r.length),se=p(function(){var e=E.element(v),t=k.element(v);t.assign(0),y(oe,function(n){var r=n.i,i=D.element(r),a=i.z;m(a,function(){var n=ne(i.xy,e.xy);m(n&&n.lessThan(ae),function(){t.addAssign(re(n,ie).mul(a))})})})}),ce=se().compute(t.length),le=new GG,e.n=2,le.computeAsync(ce);case 2:return de=Array,fe=Float32Array,e.n=3,le.getArrayBufferAsync(O);case 3:return pe=e.v,e.a(2,de.from.call(de,new fe(pe)))}},e)}));return function(t){return e.apply(this,arguments)}}(),yJ=window.THREE?window.THREE:{Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,SphereGeometry:i.SphereGeometry},bJ=3.5,xJ=.1,SJ=100,CJ=function(e){var t=en(lm(e));return t.opacity=Math.cbrt(e),t.formatRgb()},wJ=je({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return CJ}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjHeatmap`}).onCreateObj(function(){var e=new yJ.Mesh(new yJ.SphereGeometry(Tq),nJ(new yJ.MeshLambertMaterial({vertexColors:!0,transparent:!0}),tJ));return e.__globeObjType=`heatmap`,e})},update:function(e){var t=I(e.heatmapPoints),n=I(e.heatmapPointLat),r=I(e.heatmapPointLng),i=I(e.heatmapPointWeight),a=I(e.heatmapBandwidth),o=I(e.heatmapColorFn),s=I(e.heatmapColorSaturation),c=I(e.heatmapBaseAltitude),l=I(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(u,d){var f=a(d),p=o(d),m=s(d),h=c(d),g=l(d),_=t(d).map(function(e){var t=n(e),a=r(e),o=Dq(t,a);return{x:o.x,y:o.y,z:o.z,lat:t,lng:a,weight:i(e)}}),v=Math.max(xJ,f/bJ),y=Math.ceil(360/(v||-1));u.geometry.parameters.widthSegments!==y&&(u.geometry.dispose(),u.geometry=new yJ.SphereGeometry(Tq,y,y/2)),vJ(Wq(u.geometry.getAttribute(`position`)).map(function(e){var t=mq(e,3),n=t[0],r=t[1],i=t[2],a=Oq({x:n,y:r,z:i});return[a.lng,a.lat]}),_,{latAccessor:function(e){return e.lat},lngAccessor:function(e){return e.lng},weightAccessor:function(e){return e.weight},bandwidth:f}).then(function(t){var n=_q(Array(SJ)).map(function(e,t){return Bq(p(t/(SJ-1)))}),r=function(e){var t=u.__currentTargetD=e,r=t.kdeVals,i=t.topAlt,a=t.saturation,o=Dt(r.map(Math.abs))||1e-15,s=wr([0,o/a],n);u.geometry.setAttribute(`color`,Uq(r.map(function(e){return s(Math.abs(e))}),4));var c=Cr([0,o],[Tq*(1+h),Tq*(1+(i||h))]);u.geometry.setAttribute(`r`,Uq(r.map(c)))},i={kdeVals:t,topAlt:g,saturation:m},a=u.__currentTargetD||Object.assign({},i,{kdeVals:t.map(function(){return 0}),topAlt:g&&h,saturation:.5});a.kdeVals.length!==t.length&&(a.kdeVals=t.slice()),Object.keys(i).some(function(e){return a[e]!==i[e]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?r(i):e.tweenGroup.add(new Re(a).to(i,e.heatmapsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(r).onComplete(function(){e.tweenGroup.remove(this)}).start()))})}).digest(e.heatmapsData)}}),TJ=window.THREE?window.THREE:{DoubleSide:i.DoubleSide,Group:i.Group,LineBasicMaterial:i.LineBasicMaterial,LineSegments:i.LineSegments,Mesh:i.Mesh,MeshBasicMaterial:i.MeshBasicMaterial},EJ=je({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:`geometry`},polygonSideColor:{default:function(){return`#ffffaa`}},polygonSideMaterial:{},polygonCapColor:{default:function(){return`#ffffaa`}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjPolygon`}).id(function(e){return e.id}).onCreateObj(function(){var e=new TJ.Group;return e.__defaultSideMaterial=nJ(new TJ.MeshBasicMaterial({side:TJ.DoubleSide,depthWrite:!0}),eJ),e.__defaultCapMaterial=new TJ.MeshBasicMaterial({side:TJ.DoubleSide,depthWrite:!0}),e.add(new TJ.Mesh(void 0,[e.__defaultSideMaterial,e.__defaultCapMaterial])),e.add(new TJ.LineSegments(void 0,new TJ.LineBasicMaterial)),e.__globeObjType=`polygon`,e})},update:function(e){var t=I(e.polygonGeoJsonGeometry),n=I(e.polygonAltitude),r=I(e.polygonCapCurvatureResolution),i=I(e.polygonCapColor),a=I(e.polygonCapMaterial),o=I(e.polygonSideColor),s=I(e.polygonSideMaterial),c=I(e.polygonStrokeColor),l=[];e.polygonsData.forEach(function(e){var u={data:e,capColor:i(e),capMaterial:a(e),sideColor:o(e),sideMaterial:s(e),strokeColor:c(e),altitude:+n(e),capCurvatureResolution:+r(e)},d=t(e),f=e.__id||`${Math.round(Math.random()*1e9)}`;e.__id=f,d.type===`Polygon`?l.push(sq({id:`${f}_0`,coords:d.coordinates},u)):d.type===`MultiPolygon`?l.push.apply(l,_q(d.coordinates.map(function(e,t){return sq({id:`${f}_${t}`,coords:e},u)}))):console.warn(`Unsupported GeoJson geometry type: ${d.type}. Skipping geometry...`)}),e.dataMapper.onUpdateObj(function(t,n){var r=n.coords,i=n.capColor,a=n.capMaterial,o=n.sideColor,s=n.sideMaterial,c=n.strokeColor,l=n.altitude,u=n.capCurvatureResolution,d=mq(t.children,2),f=d[0],p=d[1],m=!!c;p.visible=m;var h=!!(i||a),g=!!(o||s);DJ(f.geometry.parameters||{},{polygonGeoJson:r,curvatureResolution:u,closedTop:h,includeSides:g})||(f.geometry&&f.geometry.dispose(),f.geometry=new Ef(r,0,Tq,!1,h,g,u)),m&&(!p.geometry.parameters||p.geometry.parameters.geoJson.coordinates!==r||p.geometry.parameters.resolution!==u)&&(p.geometry&&p.geometry.dispose(),p.geometry=new Yc({type:`Polygon`,coordinates:r},Tq,u));var _=g?0:-1,v=h?+!!g:-1;if(_>=0&&(f.material[_]=s||t.__defaultSideMaterial),v>=0&&(f.material[v]=a||t.__defaultCapMaterial),[[!s&&o,_],[!a&&i,v]].forEach(function(e){var t=mq(e,2),n=t[0],r=t[1];if(!(!n||r<0)){var i=f.material[r],a=zq(n);i.color.set(Rq(n)),i.transparent=a<1,i.opacity=a}}),m){var y=p.material,b=zq(c);y.color.set(Rq(c)),y.transparent=b<1,y.opacity=b}var x={alt:l},S=function(e){var n=(t.__currentTargetD=e).alt;f.scale.x=f.scale.y=f.scale.z=1+n,m&&(p.scale.x=p.scale.y=p.scale.z=1+n+1e-4),rJ(t.__defaultSideMaterial,function(e){return e.uSurfaceRadius.value=Tq/(n+1)})},C=t.__currentTargetD||Object.assign({},x,{alt:-.001});Object.keys(x).some(function(e){return C[e]!==x[e]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||C.alt===x.alt?S(x):e.tweenGroup.add(new Re(C).to(x,e.polygonsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(S).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(l)}});function DJ(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(e,t){return e===t}};return Object.entries(t).every(function(t){var r=mq(t,2),i=r[0],a=r[1];return e.hasOwnProperty(i)&&n(i)(e[i],a)})}var OJ=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,DoubleSide:i.DoubleSide,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,Vector3:i.Vector3},kJ=Object.assign({},$c),AJ=kJ.BufferGeometryUtils||kJ,jJ=je({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:`geometry`},hexPolygonColor:{default:function(){return`#ffffaa`}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjHexPolygon`}).onCreateObj(function(){var e=new OJ.Mesh(void 0,new OJ.MeshLambertMaterial({side:OJ.DoubleSide}));return e.__globeObjType=`hexPolygon`,e})},update:function(e){var t=I(e.hexPolygonGeoJsonGeometry),n=I(e.hexPolygonColor),r=I(e.hexPolygonAltitude),a=I(e.hexPolygonResolution),o=I(e.hexPolygonMargin),s=I(e.hexPolygonUseDots),c=I(e.hexPolygonCurvatureResolution),l=I(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(u,d){var f=t(d),p=a(d),m=r(d),h=Math.max(0,Math.min(1,+o(d))),g=s(d),_=c(d),v=l(d),y=n(d),b=zq(y);u.material.color.set(Rq(y)),u.material.transparent=b<1,u.material.opacity=b;var x={alt:m,margin:h,curvatureResolution:_},S={geoJson:f,h3Res:p},C=u.__currentTargetD||Object.assign({},x,{alt:-.001}),w=u.__currentMemD||S;if(Object.keys(x).some(function(e){return C[e]!==x[e]})||Object.keys(S).some(function(e){return w[e]!==S[e]})){u.__currentMemD=S;var T=[];f.type===`Polygon`?om(f.coordinates,p,!0).forEach(function(e){return T.push(e)}):f.type===`MultiPolygon`?f.coordinates.forEach(function(e){return om(e,p,!0).forEach(function(e){return T.push(e)})}):console.warn(`Unsupported GeoJson geometry type: ${f.type}. Skipping geometry...`);var E=T.map(function(e){var t=im(e),n=am(e,!0).reverse(),r=t[1];return n.forEach(function(e){var t=e[0];Math.abs(r-t)>170&&(e[0]+=r>t?360:-360)}),{h3Idx:e,hexCenter:t,hexGeoJson:n}}),D=function(e){var t=u.__currentTargetD=e,n=t.alt,r=t.margin,a=t.curvatureResolution;u.geometry&&u.geometry.dispose(),u.geometry=E.length?(AJ.mergeGeometries||AJ.mergeBufferGeometries)(E.map(function(e){var t=mq(e.hexCenter,2),o=t[0],s=t[1];if(g){var c=Dq(o,s,n),l=Dq(e.hexGeoJson[0][1],e.hexGeoJson[0][0],n),u=new i.CircleGeometry(.85*(1-r)*new OJ.Vector3(c.x,c.y,c.z).distanceTo(new OJ.Vector3(l.x,l.y,l.z)),v);return u.rotateX(kq(-o)),u.rotateY(kq(s)),u.translate(c.x,c.y,c.z),u}else{var d=function(e,t,n){return e-(e-t)*n};return new Ef([r===0?e.hexGeoJson:e.hexGeoJson.map(function(e){var t=mq(e,2),n=t[0],i=t[1];return[[n,s],[i,o]].map(function(e){var t=mq(e,2),n=t[0],i=t[1];return d(n,i,r)})})],Tq,Tq*(1+n),!1,!0,!1,a)}})):new OJ.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?D(x):e.tweenGroup.add(new Re(C).to(x,e.hexPolygonsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(D).onComplete(function(){e.tweenGroup.remove(this)}).start())}}).digest(e.hexPolygonsData)}}),MJ=window.THREE?window.THREE:{Vector3:i.Vector3};function NJ(e,t){var n=function(e,t){var n=e[e.length-1];return[].concat(_q(e),_q(Array(t-e.length).fill(n)))},r=Math.max(e.length,t.length),i=On.apply(void 0,_q([e,t].map(function(e){return e.map(function(e){return[e.x,e.y,e.z]})}).map(function(e){return n(e,r)})));return function(n){return n===0?e:n===1?t:i(n).map(function(e){var t=mq(e,3),n=t[0],r=t[1],i=t[2];return new MJ.Vector3(n,r,i)})}}var PJ=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,Color:i.Color,Group:i.Group,Line:i.Line,NormalBlending:i.NormalBlending,ShaderMaterial:i.ShaderMaterial,Vector3:i.Vector3},FJ=Ou.default.default||Ou.default,IJ=je({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return`#ffffaa`}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},stateInit:function(e){return{tweenGroup:e.tweenGroup,ticker:new FJ,sharedMaterial:new PJ.ShaderMaterial(sq(sq({},$q()),{},{transparent:!0,blending:PJ.NormalBlending}))}},init:function(e,t){Cq(e),t.scene=e,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjPath`}).onCreateObj(function(){var e=new PJ.Group;return e.__globeObjType=`path`,e}),t.ticker.onTick.add(function(e,n){t.dataMapper.entries().map(function(e){return mq(e,2)[1]}).filter(function(e){return e.children.length&&e.children[0].material&&e.children[0].__dashAnimateStep}).forEach(function(e){var t=e.children[0],r=t.__dashAnimateStep*n;if(t.type===`Line`){var i=t.material.uniforms.dashTranslate.value%1e9;t.material.uniforms.dashTranslate.value=i+r}else if(t.type===`Line2`){for(var a=t.material.dashOffset-r,o=t.material.dashSize+t.material.gapSize;a<=-o;)a+=o;t.material.dashOffset=a}})})},update:function(e){var t=I(e.pathPoints),n=I(e.pathPointLat),r=I(e.pathPointLng),i=I(e.pathPointAlt),a=I(e.pathStroke),o=I(e.pathColor),s=I(e.pathDashLength),c=I(e.pathDashGap),l=I(e.pathDashInitialGap),u=I(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(h,g){var _=a(g),v=_!=null;if(!h.children.length||v===(h.children[0].type===`Line`)){Cq(h);var y=v?new kK(new OK,new cK):new PJ.Line(new PJ.BufferGeometry,e.sharedMaterial.clone());h.add(y)}var b=h.children[0],x=f(t(g),n,r,i,e.pathResolution),S=u(g);if(b.__dashAnimateStep=S>0?1e3/S:0,v){b.material.resolution=e.rendererSize;var C=s(g),w=c(g),T=l(g);b.material.dashed=w>0,b.material.dashed?b.material.defines.USE_DASH=``:delete b.material.defines.USE_DASH,b.material.dashed&&(b.material.dashScale=1/d(x),b.material.dashSize=C,b.material.gapSize=w,b.material.dashOffset=-T);var E=o(g);if(E instanceof Array){var D=p(o(g),x.length-1,1,!1);b.geometry.setColors(D.array),b.material.vertexColors=!0}else{var O=E,k=zq(O);b.material.color=new PJ.Color(Rq(O)),b.material.transparent=k<1,b.material.opacity=k,b.material.vertexColors=!1}b.material.needsUpdate=!0}else{Object.assign(b.material.uniforms,{dashSize:{value:s(g)},gapSize:{value:c(g)},dashOffset:{value:l(g)}});var A=p(o(g),x.length),ee=m(x.length,1,!0);b.geometry.setAttribute(`color`,A),b.geometry.setAttribute(`relDistance`,ee)}var j=NJ(h.__currentTargetD&&h.__currentTargetD.points||[x[0]],x),te=function(e){var t=h.__currentTargetD=e,n=t.stroke,r=t.interpolK,i=h.__currentTargetD.points=j(r);if(v){var a;b.geometry.setPositions((a=[]).concat.apply(a,_q(i.map(function(e){return[e.x,e.y,e.z]})))),b.material.linewidth=n,b.material.dashed&&b.computeLineDistances()}else b.geometry.setFromPoints(i),b.geometry.computeBoundingSphere()},ne={stroke:_,interpolK:1},re=Object.assign({},h.__currentTargetD||ne,{interpolK:0});Object.keys(ne).some(function(e){return re[e]!==ne[e]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?te(ne):e.tweenGroup.add(new Re(re).to(ne,e.pathTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(te).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.pathsData);function d(e){var t=0,n;return e.forEach(function(e){n&&(t+=n.distanceTo(e)),n=e}),t}function f(e,t,n,r,i){var a=function(e,t,n){for(var r=[],i=1;i<=n;i++)r.push(e+(t-e)*i/(n+1));return r};return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(e){if(r){for(;Math.abs(r[1]-e[1])>180;)r[1]+=360*(r[1]<e[1]?1:-1);var i=Math.sqrt((e[0]-r[0])**2+(e[1]-r[1])**2);if(i>t)for(var o=Math.floor(i/t),s=a(r[0],e[0],o),c=a(r[1],e[1],o),l=a(r[2],e[2],o),u=0,d=s.length;u<d;u++)n.push([s[u],c[u],l[u]])}n.push(r=e)}),n}(e.map(function(e){return[t(e),n(e),r(e)]}),i).map(function(e){var t=mq(e,3),n=t[0],r=t[1],i=t[2],a=Dq(n,r,i),o=a.x,s=a.y,c=a.z;return new PJ.Vector3(o,s,c)})}function p(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=t+1,a;if(e instanceof Array||e instanceof Function){var o=e instanceof Array?Cr().domain(e.map(function(t,n){return n/(e.length-1)})).range(e):e;a=function(e){return Bq(o(e),r,!0)}}else{var s=Bq(e,r,!0);a=function(){return s}}for(var c=[],l=0,u=i;l<u;l++)for(var d=a(l/(u-1)),f=0;f<n;f++)c.push(d);return Uq(c,r?4:3)}function m(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e+1,i=[],a=0,o=r;a<o;a++)for(var s=a/(o-1),c=0;c<t;c++)i.push(s);return n&&i.reverse(),Uq(i,1)}}}),LJ=window.THREE?window.THREE:{Euler:i.Euler,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,SphereGeometry:i.SphereGeometry},RJ=je({props:{tilesData:{default:[]},tileLat:{default:`lat`},tileLng:{default:`lng`},tileAltitude:{default:.01},tileWidth:{default:1},tileHeight:{default:1},tileUseGlobeProjection:{default:!0},tileMaterial:{default:function(){return new LJ.MeshLambertMaterial({color:`#ffbb88`,opacity:.4,transparent:!0})}},tileCurvatureResolution:{default:5},tilesTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjTile`}).onCreateObj(function(){var e=new LJ.Mesh;return e.__globeObjType=`tile`,e})},update:function(e){var t=I(e.tileLat),n=I(e.tileLng),r=I(e.tileAltitude),i=I(e.tileWidth),a=I(e.tileHeight),o=I(e.tileUseGlobeProjection),s=I(e.tileMaterial),c=I(e.tileCurvatureResolution);e.dataMapper.onUpdateObj(function(l,u){l.material=s(u);var d=o(u),f=c(u),p=function(e){var t=l.__currentTargetD=e,n=t.lat,r=t.lng,i=t.alt,a=t.width,o=t.height,s=zJ(r),c=zJ(-n);l.geometry&&l.geometry.dispose(),l.geometry=new LJ.SphereGeometry(Tq*(1+i),Math.ceil(a/(f||-1)),Math.ceil(o/(f||-1)),zJ(90-a/2)+(d?s:0),zJ(a),zJ(90-o/2)+(d?c:0),zJ(o)),d||l.setRotationFromEuler(new LJ.Euler(c,s,0,`YXZ`))},m={lat:+t(u),lng:+n(u),alt:+r(u),width:+i(u),height:+a(u)},h=l.__currentTargetD||Object.assign({},m,{width:0,height:0});Object.keys(m).some(function(e){return h[e]!==m[e]})&&(!e.tilesTransitionDuration||e.tilesTransitionDuration<0?p(m):e.tweenGroup.add(new Re(h).to(m,e.tilesTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(p).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.tilesData)}}),zJ=function(e){return e*Math.PI/180},BJ=window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry,Color:i.Color,Points:i.Points,PointsMaterial:i.PointsMaterial},VJ=je({props:{particlesData:{default:[]},particlesList:{default:function(e){return e}},particleLat:{default:`lat`},particleLng:{default:`lng`},particleAltitude:{default:.01},particlesSize:{default:.5},particlesSizeAttenuation:{default:!0},particlesColor:{default:function(){return`white`}},particlesTexture:{}},init:function(e,t){Cq(e),t.scene=e,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjParticles`}).onCreateObj(function(){var e=new BJ.Points(new BJ.BufferGeometry,new BJ.PointsMaterial);return e.__globeObjType=`particles`,e}).onUpdateObj(function(e,n){var r=I(t.particlesList),i=I(t.particleLat),a=I(t.particleLng),o=I(t.particleAltitude);e.geometry.setAttribute(`position`,Uq(r(n).map(function(e){return Object.values(Dq(i(e),a(e),o(e)))}),3))})},update:function(e,t){[`particlesData`,`particlesList`,`particleLat`,`particleLng`,`particleAltitude`].some(function(e){return t.hasOwnProperty(e)})&&e.dataMapper.digest(e.particlesData);var n=I(e.particlesColor),r=I(e.particlesSize),i=I(e.particlesSizeAttenuation),a=I(e.particlesTexture);e.dataMapper.entries().forEach(function(t){var o=mq(t,2),s=o[0],c=o[1];if(c.material.size=r(s),c.material.sizeAttenuation=i(s),e.particlesTexture)c.material.color=new BJ.Color(16777215),c.material.transparent=!1,c.material.alphaTest=.5,c.material.map=a(s);else{var l=n(s),u=zq(l);c.material.color=new BJ.Color(Rq(l)),c.material.transparent=u<1,c.material.opacity=u,c.material.alphaTest=0}})}}),HJ=function(e){function t(){var e,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;WK(this,t),e=HK(this,t),e.type=`CircleLineGeometry`,e.parameters={radius:n,segmentCount:r};for(var i=[],a=0;a<=r;a++){var o=(a/r-.25)*Math.PI*2;i.push({x:Math.cos(o)*n,y:Math.sin(o)*n,z:0})}return e.setFromPoints(i),e}return eq(t,e),XK(t)}((window.THREE?window.THREE:{BufferGeometry:i.BufferGeometry}).BufferGeometry),UJ=window.THREE?window.THREE:{Color:i.Color,Group:i.Group,Line:i.Line,LineBasicMaterial:i.LineBasicMaterial,Vector3:i.Vector3},WJ=Ou.default.default||Ou.default,GJ=je({props:{ringsData:{default:[]},ringLat:{default:`lat`},ringLng:{default:`lng`},ringAltitude:{default:.0015},ringColor:{default:function(){return`#ffffaa`},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)==null||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)==null||t.resume()},_destructor:function(e){var t;(t=e.ticker)==null||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjRing`,removeDelay:3e4}).onCreateObj(function(){var e=new UJ.Group;return e.__globeObjType=`ring`,e}),t.ticker=new WJ,t.ticker.onTick.add(function(e){if(t.ringsData.length){var n=I(t.ringColor),r=I(t.ringAltitude),i=I(t.ringMaxRadius),a=I(t.ringPropagationSpeed),o=I(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(e){return mq(e,2)[1]}).forEach(function(s){var c=mq(s,2),l=c[0],u=c[1];if((u.__nextRingTime||0)<=e){var d=o(l)/1e3;u.__nextRingTime=e+(d<=0?1/0:d);var f=new UJ.Line(new HJ(1,t.ringResolution),new UJ.LineBasicMaterial),p=n(l),m=p instanceof Array||p instanceof Function,h;m?p instanceof Array?(h=Cr().domain(p.map(function(e,t){return t/(p.length-1)})).range(p),f.material.transparent=p.some(function(e){return zq(e)<1})):(h=p,f.material.transparent=!0):(f.material.color=new UJ.Color(Rq(p)),Vq(f.material,zq(p)));var g=Tq*(1+r(l)),_=i(l),v=_*Math.PI/180,y=a(l),b=y<=0,x=function(e){var t=e.t,n=(b?1-t:t)*v;if(f.scale.x=f.scale.y=g*Math.sin(n),f.position.z=g*(1-Math.cos(n)),m){var r=h(t);f.material.color=new UJ.Color(Rq(r)),f.material.transparent&&(f.material.opacity=zq(r))}};if(y===0)x({t:0}),u.add(f);else{var S=Math.abs(_/y)*1e3;t.tweenGroup.add(new Re({t:0}).to({t:1},S).onUpdate(x).onStart(function(){return u.add(f)}).onComplete(function(){t.tweenGroup.remove(this),u.remove(f),Sq(f)}).start())}}})}})},update:function(e){var t=I(e.ringLat),n=I(e.ringLng),r=I(e.ringAltitude),i=e.scene.localToWorld(new UJ.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(e,a){var o=t(a),s=n(a),c=r(a);Object.assign(e.position,Dq(o,s,c)),e.lookAt(i)}).digest(e.ringsData)}}),KJ={glyphs:{0:{x_min:73,x_max:715,ha:792,o:`m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 `},1:{x_min:215.671875,x_max:574,ha:792,o:`m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 `},2:{x_min:59,x_max:731,ha:792,o:`m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 `},3:{x_min:54,x_max:737,ha:792,o:`m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 `},4:{x_min:48,x_max:742.453125,ha:792,o:`m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 `},5:{x_min:54.171875,x_max:738,ha:792,o:`m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 `},6:{x_min:53,x_max:739,ha:792,o:`m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 `},7:{x_min:58.71875,x_max:730.953125,ha:792,o:`m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 `},8:{x_min:55,x_max:736,ha:792,o:`m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 `},9:{x_min:53,x_max:739,ha:792,o:`m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 `},ο:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 `},S:{x_min:0,x_max:788,ha:890,o:`m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 `},"¦":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},"/":{x_min:183.25,x_max:608.328125,ha:792,o:`m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 `},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:`m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 `},y:{x_min:0,x_max:684.78125,ha:771,o:`m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 `},Π:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 `},ΐ:{x_min:-111,x_max:339,ha:361,o:`m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 `},g:{x_min:0,x_max:686,ha:838,o:`m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 `},"²":{x_min:0,x_max:442,ha:539,o:`m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 `},"–":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},Κ:{x_min:0,x_max:819.5625,ha:893,o:`m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:`m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 `},e:{x_min:0,x_max:714,ha:813,o:`m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 `},ό:{x_min:0,x_max:712,ha:815,o:`m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 `},J:{x_min:0,x_max:588,ha:699,o:`m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 `},"»":{x_min:-1,x_max:503,ha:601,o:`m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 `},"©":{x_min:-3,x_max:1008,ha:1106,o:`m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 `},ώ:{x_min:0,x_max:922,ha:1030,o:`m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 `},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:`m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 `},"«":{x_min:0,x_max:507.203125,ha:604,o:`m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 `},D:{x_min:0,x_max:828,ha:935,o:`m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 `},"∙":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},ÿ:{x_min:0,x_max:47,ha:125,o:`m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 `},w:{x_min:0,x_max:1009.71875,ha:1100,o:`m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 `},$:{x_min:0,x_max:700,ha:793,o:`m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 `},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:`m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 `},µ:{x_min:0,x_max:697.21875,ha:747,o:`m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 `},Ι:{x_min:42,x_max:181,ha:297,o:`m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 `},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:`m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"’":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},Ν:{x_min:0,x_max:801,ha:915,o:`m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 `},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:`m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 `},Q:{x_min:0,x_max:968,ha:1072,o:`m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 `},ς:{x_min:1,x_max:676.28125,ha:740,o:`m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 `},M:{x_min:0,x_max:954,ha:1067,o:`m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 `},Ψ:{x_min:0,x_max:1006,ha:1094,o:`m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 `},C:{x_min:0,x_max:886,ha:944,o:`m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 `},"!":{x_min:0,x_max:138,ha:236,o:`m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 `},"{":{x_min:0,x_max:480.5625,ha:578,o:`m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 `},X:{x_min:-.015625,x_max:854.15625,ha:940,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 `},"#":{x_min:0,x_max:963.890625,ha:1061,o:`m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 `},ι:{x_min:42,x_max:284,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 `},Ά:{x_min:0,x_max:906.953125,ha:982,o:`m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},")":{x_min:0,x_max:318,ha:415,o:`m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 `},ε:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 `},Δ:{x_min:0,x_max:952.78125,ha:1028,o:`m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 `},"}":{x_min:0,x_max:481,ha:578,o:`m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 `},"‰":{x_min:-3,x_max:1672,ha:1821,o:`m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 `},a:{x_min:0,x_max:698.609375,ha:794,o:`m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 `},"—":{x_min:0,x_max:941.671875,ha:1039,o:`m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 `},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:`m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 `},N:{x_min:0,x_max:801,ha:914,o:`m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 `},ρ:{x_min:0,x_max:712,ha:797,o:`m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 `},"¯":{x_min:0,x_max:941.671875,ha:938,o:`m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 `},Z:{x_min:0,x_max:779,ha:849,o:`m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 `},u:{x_min:0,x_max:617,ha:729,o:`m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 `},k:{x_min:0,x_max:612.484375,ha:697,o:`m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 `},Η:{x_min:0,x_max:803,ha:917,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},Α:{x_min:0,x_max:906.953125,ha:985,o:`m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 `},s:{x_min:0,x_max:604,ha:697,o:`m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 `},B:{x_min:0,x_max:778,ha:876,o:`m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 `},"…":{x_min:0,x_max:614,ha:708,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 `},"?":{x_min:0,x_max:607,ha:704,o:`m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 `},H:{x_min:0,x_max:803,ha:915,o:`m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 `},ν:{x_min:0,x_max:675,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 `},c:{x_min:1,x_max:701.390625,ha:775,o:`m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 `},"¶":{x_min:0,x_max:566.671875,ha:678,o:`m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 `},β:{x_min:0,x_max:660,ha:745,o:`m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 `},Μ:{x_min:0,x_max:954,ha:1068,o:`m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 `},Ό:{x_min:.109375,x_max:1120,ha:1217,o:`m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ή:{x_min:0,x_max:1158,ha:1275,o:`m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},"•":{x_min:0,x_max:663.890625,ha:775,o:`m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 `},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:`m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 `},"(":{x_min:0,x_max:318.0625,ha:415,o:`m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 `},U:{x_min:0,x_max:796,ha:904,o:`m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 `},γ:{x_min:.5,x_max:744.953125,ha:822,o:`m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 `},α:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 `},F:{x_min:0,x_max:683.328125,ha:717,o:`m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 `},"":{x_min:0,x_max:705.5625,ha:803,o:`m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 `},":":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},Χ:{x_min:0,x_max:854.171875,ha:935,o:`m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 `},"*":{x_min:116,x_max:674,ha:792,o:`m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 `},"†":{x_min:0,x_max:777,ha:835,o:`m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 `},"°":{x_min:0,x_max:347,ha:444,o:`m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 `},V:{x_min:0,x_max:862.71875,ha:940,o:`m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 `},Ξ:{x_min:0,x_max:734.71875,ha:763,o:`m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 `},"\xA0":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 `},"”":{x_min:0,x_max:347,ha:454,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 `},"@":{x_min:0,x_max:1260,ha:1357,o:`m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 `},Ί:{x_min:0,x_max:499,ha:613,o:`m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 `},i:{x_min:14,x_max:136,ha:275,o:`m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 `},Β:{x_min:0,x_max:778,ha:877,o:`m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 `},υ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 `},"]":{x_min:0,x_max:275,ha:372,o:`m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 `},m:{x_min:0,x_max:1019,ha:1128,o:`m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 `},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:`m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 `},ί:{x_min:42,x_max:326.71875,ha:361,o:`m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 `},Ζ:{x_min:0,x_max:779.171875,ha:850,o:`m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 `},R:{x_min:0,x_max:781.953125,ha:907,o:`m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 `},o:{x_min:0,x_max:713,ha:821,o:`m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 `},K:{x_min:0,x_max:819.46875,ha:906,o:`m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 `},",":{x_min:0,x_max:142,ha:239,o:`m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 `},d:{x_min:0,x_max:683,ha:796,o:`m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 `},"¨":{x_min:-109,x_max:247,ha:232,o:`m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 `},E:{x_min:0,x_max:736.109375,ha:789,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},Y:{x_min:0,x_max:820,ha:886,o:`m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 `},'"':{x_min:0,x_max:299,ha:396,o:`m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"„":{x_min:0,x_max:364,ha:467,o:`m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 `},δ:{x_min:1,x_max:710,ha:810,o:`m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 `},έ:{x_min:0,x_max:634.71875,ha:714,o:`m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 `},ω:{x_min:0,x_max:922,ha:1031,o:`m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 `},"´":{x_min:0,x_max:96,ha:251,o:`m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 `},"±":{x_min:11,x_max:781,ha:792,o:`m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 `},"|":{x_min:343,x_max:449,ha:792,o:`m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 `},ϋ:{x_min:0,x_max:617,ha:725,o:`m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 `},"§":{x_min:0,x_max:593,ha:690,o:`m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 `},b:{x_min:0,x_max:685,ha:783,o:`m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 `},q:{x_min:0,x_max:683,ha:876,o:`m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 `},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:`m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 `},ύ:{x_min:0,x_max:617,ha:725,o:`m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 `},z:{x_min:-.015625,x_max:613.890625,ha:697,o:`m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 `},"™":{x_min:0,x_max:894,ha:1e3,o:`m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 `},ή:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 `},Θ:{x_min:0,x_max:960,ha:1056,o:`m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 `},"®":{x_min:-3,x_max:1008,ha:1106,o:`m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 `},"~":{x_min:0,x_max:833,ha:931,o:`m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 `},Ε:{x_min:0,x_max:736.21875,ha:778,o:`m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 `},"³":{x_min:0,x_max:450,ha:547,o:`m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 `},"[":{x_min:0,x_max:273.609375,ha:371,o:`m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 `},L:{x_min:0,x_max:645.828125,ha:696,o:`m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 `},σ:{x_min:0,x_max:803.390625,ha:894,o:`m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 `},ζ:{x_min:0,x_max:573,ha:642,o:`m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 `},θ:{x_min:0,x_max:674,ha:778,o:`m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 `},Ο:{x_min:0,x_max:958,ha:1054,o:`m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 `},Γ:{x_min:0,x_max:705.28125,ha:749,o:`m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 `}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:`m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 `},P:{x_min:0,x_max:726,ha:806,o:`m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 `},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:`m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 `},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:`m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 `},_:{x_min:0,x_max:705.5625,ha:803,o:`m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 `},Ϊ:{x_min:-110,x_max:246,ha:275,o:`m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 `},"+":{x_min:23,x_max:768,ha:792,o:`m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 `},"½":{x_min:0,x_max:1050,ha:1149,o:`m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 `},Ρ:{x_min:0,x_max:720,ha:783,o:`m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 `},"'":{x_min:0,x_max:139,ha:236,o:`m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 `},ª:{x_min:0,x_max:350,ha:397,o:`m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 `},"΅":{x_min:0,x_max:450,ha:553,o:`m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 `},T:{x_min:0,x_max:777,ha:835,o:`m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 `},Φ:{x_min:0,x_max:915,ha:997,o:`m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 `},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:`m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 `},Σ:{x_min:0,x_max:756.953125,ha:819,o:`m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 `},"›":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:`m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 `},"£":{x_min:0,x_max:704.484375,ha:801,o:`m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 `},t:{x_min:0,x_max:367,ha:458,o:`m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 `},"¬":{x_min:0,x_max:706,ha:803,o:`m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 `},λ:{x_min:0,x_max:750,ha:803,o:`m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 `},W:{x_min:0,x_max:1263.890625,ha:1351,o:`m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 `},">":{x_min:18.0625,x_max:774,ha:792,o:`m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 `},v:{x_min:0,x_max:675.15625,ha:761,o:`m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 `},τ:{x_min:.28125,x_max:644.5,ha:703,o:`m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 `},ξ:{x_min:0,x_max:624.9375,ha:699,o:`m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 `},"&":{x_min:-3,x_max:894.25,ha:992,o:`m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 `},Λ:{x_min:0,x_max:862.5,ha:942,o:`m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 `},I:{x_min:41,x_max:180,ha:293,o:`m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 `},G:{x_min:0,x_max:921,ha:1011,o:`m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 `},ΰ:{x_min:0,x_max:617,ha:725,o:`m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 `},"`":{x_min:0,x_max:138.890625,ha:236,o:`m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 `},"·":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 `},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:`m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 `},r:{x_min:0,x_max:355.5625,ha:432,o:`m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 `},x:{x_min:0,x_max:675,ha:764,o:`m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 `},μ:{x_min:0,x_max:696.609375,ha:747,o:`m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 `},h:{x_min:0,x_max:615,ha:724,o:`m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 `},".":{x_min:0,x_max:142,ha:239,o:`m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 `},φ:{x_min:-2,x_max:878,ha:974,o:`m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 `},";":{x_min:0,x_max:142,ha:239,o:`m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 `},f:{x_min:0,x_max:378,ha:472,o:`m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 `},"“":{x_min:1,x_max:348.21875,ha:454,o:`m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 `},A:{x_min:.03125,x_max:906.953125,ha:1008,o:`m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 `},"‘":{x_min:1,x_max:139.890625,ha:236,o:`m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 `},ϊ:{x_min:-70,x_max:283,ha:361,o:`m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 `},π:{x_min:-.21875,x_max:773.21875,ha:857,o:`m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 `},ά:{x_min:0,x_max:765.5625,ha:809,o:`m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 `},O:{x_min:0,x_max:958,ha:1057,o:`m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 `},n:{x_min:0,x_max:615,ha:724,o:`m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 `},l:{x_min:41,x_max:166,ha:279,o:`m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 `},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:`m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 `},κ:{x_min:0,x_max:632.328125,ha:679,o:`m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 `},p:{x_min:0,x_max:685,ha:786,o:`m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 `},"‡":{x_min:0,x_max:777,ha:835,o:`m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 `},ψ:{x_min:0,x_max:808,ha:907,o:`m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 `},η:{x_min:.78125,x_max:697,ha:810,o:`m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 `}},cssFontWeight:`normal`,ascender:1189,underlinePosition:-100,cssFontStyle:`normal`,boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:`Helvetiker-Regular`,version_string:`Version 1.00 2004 initial release`,vendor_url:`http://www.magenta.gr/`,full_font_name:`Helvetiker`,font_family_name:`Helvetiker`,copyright:`Copyright (c) Μagenta ltd, 2004`,description:``,trademark:``,designer:``,designer_url:``,unique_font_identifier:`Μagenta ltd:Helvetiker:22-10-104`,license_url:`http://www.ellak.gr/fonts/MgOpen/license.html`,license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r
|
|
907
|
+
\r
|
|
908
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r
|
|
909
|
+
\r
|
|
910
|
+
The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r
|
|
911
|
+
\r
|
|
912
|
+
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r
|
|
913
|
+
\r
|
|
914
|
+
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r
|
|
915
|
+
\r
|
|
916
|
+
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r
|
|
917
|
+
\r
|
|
918
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:`Μagenta ltd`,font_sub_family_name:`Regular`},descender:-334,familyName:`Helvetiker`,lineHeight:1522,underlineThickness:50},qJ=sq(sq({},window.THREE?window.THREE:{BoxGeometry:i.BoxGeometry,CircleGeometry:i.CircleGeometry,DoubleSide:i.DoubleSide,Group:i.Group,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,TextGeometry:AK,Vector3:i.Vector3}),{},{Font:jK,TextGeometry:AK}),JJ=je({props:{labelsData:{default:[]},labelLat:{default:`lat`},labelLng:{default:`lng`},labelAltitude:{default:.002},labelText:{default:`text`},labelSize:{default:.5},labelTypeFace:{default:KJ,onChange:function(e,t){t.font=new qJ.Font(e)}},labelColor:{default:function(){return`lightgrey`}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return`bottom`}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r;var a=new qJ.CircleGeometry(1,32);t.dataMapper=new Jq(e,{objBindAttr:`__threeObjLabel`}).onCreateObj(function(){var e=new qJ.MeshLambertMaterial;e.side=i.DoubleSide;var t=new qJ.Group;t.add(new qJ.Mesh(a,e));var n=new qJ.Mesh(void 0,e);t.add(n);var r=new qJ.Mesh;return r.visible=!1,n.add(r),t.__globeObjType=`label`,t})},update:function(e){var t=I(e.labelLat),n=I(e.labelLng),r=I(e.labelAltitude),i=I(e.labelText),a=I(e.labelSize),o=I(e.labelRotation),s=I(e.labelColor),c=I(e.labelIncludeDot),l=I(e.labelDotRadius),u=I(e.labelDotOrientation),d=new Set([`right`,`top`,`bottom`]),f=2*Math.PI*Tq/360;e.dataMapper.onUpdateObj(function(p,m){var h=mq(p.children,2),g=h[0],_=h[1],v=mq(_.children,1)[0],y=s(m),b=zq(y);_.material.color.set(Rq(y)),_.material.transparent=b<1,_.material.opacity=b;var x=c(m),S=u(m);!x||!d.has(S)&&(S=`bottom`);var C=x?+l(m)*f:1e-12;g.scale.x=g.scale.y=C;var w=+a(m)*f;if(_.geometry&&_.geometry.dispose(),_.geometry=new qJ.TextGeometry(i(m),{font:e.font,size:w,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),v.geometry&&v.geometry.dispose(),_.geometry.computeBoundingBox(),v.geometry=JK(qJ.BoxGeometry,_q(new qJ.Vector3().subVectors(_.geometry.boundingBox.max,_.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),S!==`right`&&_.geometry.center(),x){var T=C+w/2;S===`right`&&(_.position.x=T),_.position.y={right:-w/2,top:T+w/2,bottom:-T-w/2}[S]}var E=function(t){var n=p.__currentTargetD=t,r=n.lat,i=n.lng,a=n.alt,o=n.rot,s=n.scale;Object.assign(p.position,Dq(r,i,a)),p.lookAt(e.scene.localToWorld(new qJ.Vector3(0,0,0))),p.rotateY(Math.PI),p.rotateZ(-o*Math.PI/180),p.scale.x=p.scale.y=p.scale.z=s},D={lat:+t(m),lng:+n(m),alt:+r(m),rot:+o(m),scale:1},O=p.__currentTargetD||Object.assign({},D,{scale:1e-12});Object.keys(D).some(function(e){return O[e]!==D[e]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?E(D):e.tweenGroup.add(new Re(O).to(D,e.labelsTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(E).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.labelsData)}}),YJ=sq(sq({},window.THREE?window.THREE:{}),{},{CSS2DObject:PK}),XJ=je({props:{htmlElementsData:{default:[]},htmlLat:{default:`lat`},htmlLng:{default:`lng`},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){e.dataMapper&&(t?[t]:e.dataMapper.entries().map(function(e){return mq(e,2)[1]}).filter(function(e){return e})).forEach(function(t){var n=!e.isBehindGlobe||!e.isBehindGlobe(t.position);e.htmlElementVisibilityModifier?(t.visible=!0,e.htmlElementVisibilityModifier(t.element,n)):t.visible=n})}},init:function(e,t,n){var r=n.tweenGroup;Cq(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjHtml`}).onCreateObj(function(e){var n=I(t.htmlElement)(e),r=new YJ.CSS2DObject(n);return r.__globeObjType=`html`,r})},update:function(e,t){var n=this,r=I(e.htmlLat),i=I(e.htmlLng),a=I(e.htmlAltitude);t.hasOwnProperty(`htmlElement`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(t,o){var s=function(e){var r=t.__currentTargetD=e,i=r.alt,a=r.lat,o=r.lng;Object.assign(t.position,Dq(a,o,i)),n.updateObjVisibility(t)},c={lat:+r(o),lng:+i(o),alt:+a(o)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!t.__currentTargetD?s(c):e.tweenGroup.add(new Re(t.__currentTargetD).to(c,e.htmlTransitionDuration).easing(Me.Quadratic.InOut).onUpdate(s).onComplete(function(){e.tweenGroup.remove(this)}).start())}).digest(e.htmlElementsData)}}),ZJ=window.THREE?window.THREE:{Group:i.Group,Mesh:i.Mesh,MeshLambertMaterial:i.MeshLambertMaterial,SphereGeometry:i.SphereGeometry},QJ=je({props:{objectsData:{default:[]},objectLat:{default:`lat`},objectLng:{default:`lng`},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new ZJ.Mesh(new ZJ.SphereGeometry(1,16,8),new ZJ.MeshLambertMaterial({color:`#ffffaa`,transparent:!0,opacity:.7}))}},init:function(e,t){Cq(e),t.scene=e,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjObject`}).onCreateObj(function(e){var n=I(t.objectThreeObject)(e);t.objectThreeObject===n&&(n=n.clone());var r=new ZJ.Group;return r.add(n),r.__globeObjType=`object`,r})},update:function(e,t){var n=I(e.objectLat),r=I(e.objectLng),a=I(e.objectAltitude),o=I(e.objectFacesSurface),s=I(e.objectRotation);t.hasOwnProperty(`objectThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){var c=+n(t),l=+r(t),u=+a(t);Object.assign(e.position,Dq(c,l,u)),o(t)?e.setRotationFromEuler(new i.Euler(kq(-c),kq(l),0,`YXZ`)):e.rotation.set(0,0,0);var d=e.children[0],f=s(t);f&&d.setRotationFromEuler(new i.Euler(kq(f.x||0),kq(f.y||0),kq(f.z||0)))}).digest(e.objectsData)}}),$J=je({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){Cq(e),t.scene=e,t.dataMapper=new Jq(e,{objBindAttr:`__threeObjCustom`}).onCreateObj(function(e){var n=I(t.customThreeObject)(e,Tq);return n&&(t.customThreeObject===n&&(n=n.clone()),n.__globeObjType=`custom`),n})},update:function(e,t){e.customThreeObjectUpdate||Cq(e.scene);var n=I(e.customThreeObjectUpdate);t.hasOwnProperty(`customThreeObject`)&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(e,t){return n(e,t,Tq)}).digest(e.customLayerData)}}),eY=window.THREE?window.THREE:{Camera:i.Camera,Group:i.Group,Vector2:i.Vector2,Vector3:i.Vector3},tY=[`globeLayer`,`pointsLayer`,`arcsLayer`,`hexBinLayer`,`heatmapsLayer`,`polygonsLayer`,`hexedPolygonsLayer`,`pathsLayer`,`tilesLayer`,`particlesLayer`,`ringsLayer`,`labelsLayer`,`htmlElementsLayer`,`objectsLayer`,`customLayer`],nY=wq(`globeLayer`,Lq),rY=Object.assign.apply(Object,_q([`globeImageUrl`,`bumpImageUrl`,`globeCurvatureResolution`,`globeTileEngineUrl`,`globeTileEngineMaxLevel`,`showGlobe`,`showGraticules`,`showAtmosphere`,`atmosphereColor`,`atmosphereAltitude`].map(function(e){return ZK({},e,nY.linkProp(e))}))),iY=Object.assign.apply(Object,_q([`globeMaterial`,`globeTileEngineClearCache`].map(function(e){return ZK({},e,nY.linkMethod(e))}))),aY=wq(`pointsLayer`,Qq),oY=Object.assign.apply(Object,_q([`pointsData`,`pointLat`,`pointLng`,`pointColor`,`pointAltitude`,`pointRadius`,`pointResolution`,`pointsMerge`,`pointsTransitionDuration`].map(function(e){return ZK({},e,aY.linkProp(e))}))),sY=wq(`arcsLayer`,sJ),cY=Object.assign.apply(Object,_q([`arcsData`,`arcStartLat`,`arcStartLng`,`arcStartAltitude`,`arcEndLat`,`arcEndLng`,`arcEndAltitude`,`arcColor`,`arcAltitude`,`arcAltitudeAutoScale`,`arcStroke`,`arcCurveResolution`,`arcCircularResolution`,`arcDashLength`,`arcDashGap`,`arcDashInitialGap`,`arcDashAnimateTime`,`arcsTransitionDuration`].map(function(e){return ZK({},e,sY.linkProp(e))}))),lY=wq(`hexBinLayer`,dJ),uY=Object.assign.apply(Object,_q([`hexBinPointsData`,`hexBinPointLat`,`hexBinPointLng`,`hexBinPointWeight`,`hexBinResolution`,`hexMargin`,`hexTopCurvatureResolution`,`hexTopColor`,`hexSideColor`,`hexAltitude`,`hexBinMerge`,`hexTransitionDuration`].map(function(e){return ZK({},e,lY.linkProp(e))}))),dY=wq(`heatmapsLayer`,wJ),fY=Object.assign.apply(Object,_q([`heatmapsData`,`heatmapPoints`,`heatmapPointLat`,`heatmapPointLng`,`heatmapPointWeight`,`heatmapBandwidth`,`heatmapColorFn`,`heatmapColorSaturation`,`heatmapBaseAltitude`,`heatmapTopAltitude`,`heatmapsTransitionDuration`].map(function(e){return ZK({},e,dY.linkProp(e))}))),pY=wq(`hexedPolygonsLayer`,jJ),mY=Object.assign.apply(Object,_q([`hexPolygonsData`,`hexPolygonGeoJsonGeometry`,`hexPolygonColor`,`hexPolygonAltitude`,`hexPolygonResolution`,`hexPolygonMargin`,`hexPolygonUseDots`,`hexPolygonCurvatureResolution`,`hexPolygonDotResolution`,`hexPolygonsTransitionDuration`].map(function(e){return ZK({},e,pY.linkProp(e))}))),hY=wq(`polygonsLayer`,EJ),gY=Object.assign.apply(Object,_q([`polygonsData`,`polygonGeoJsonGeometry`,`polygonCapColor`,`polygonCapMaterial`,`polygonSideColor`,`polygonSideMaterial`,`polygonStrokeColor`,`polygonAltitude`,`polygonCapCurvatureResolution`,`polygonsTransitionDuration`].map(function(e){return ZK({},e,hY.linkProp(e))}))),_Y=wq(`pathsLayer`,IJ),vY=Object.assign.apply(Object,_q([`pathsData`,`pathPoints`,`pathPointLat`,`pathPointLng`,`pathPointAlt`,`pathResolution`,`pathColor`,`pathStroke`,`pathDashLength`,`pathDashGap`,`pathDashInitialGap`,`pathDashAnimateTime`,`pathTransitionDuration`].map(function(e){return ZK({},e,_Y.linkProp(e))}))),yY=wq(`tilesLayer`,RJ),bY=Object.assign.apply(Object,_q([`tilesData`,`tileLat`,`tileLng`,`tileAltitude`,`tileWidth`,`tileHeight`,`tileUseGlobeProjection`,`tileMaterial`,`tileCurvatureResolution`,`tilesTransitionDuration`].map(function(e){return ZK({},e,yY.linkProp(e))}))),xY=wq(`particlesLayer`,VJ),SY=Object.assign.apply(Object,_q([`particlesData`,`particlesList`,`particleLat`,`particleLng`,`particleAltitude`,`particlesSize`,`particlesSizeAttenuation`,`particlesColor`,`particlesTexture`].map(function(e){return ZK({},e,xY.linkProp(e))}))),CY=wq(`ringsLayer`,GJ),wY=Object.assign.apply(Object,_q([`ringsData`,`ringLat`,`ringLng`,`ringAltitude`,`ringColor`,`ringResolution`,`ringMaxRadius`,`ringPropagationSpeed`,`ringRepeatPeriod`].map(function(e){return ZK({},e,CY.linkProp(e))}))),TY=wq(`labelsLayer`,JJ),EY=Object.assign.apply(Object,_q([`labelsData`,`labelLat`,`labelLng`,`labelAltitude`,`labelRotation`,`labelText`,`labelSize`,`labelTypeFace`,`labelColor`,`labelResolution`,`labelIncludeDot`,`labelDotRadius`,`labelDotOrientation`,`labelsTransitionDuration`].map(function(e){return ZK({},e,TY.linkProp(e))}))),DY=wq(`htmlElementsLayer`,XJ),OY=Object.assign.apply(Object,_q([`htmlElementsData`,`htmlLat`,`htmlLng`,`htmlAltitude`,`htmlElement`,`htmlElementVisibilityModifier`,`htmlTransitionDuration`].map(function(e){return ZK({},e,DY.linkProp(e))}))),kY=wq(`objectsLayer`,QJ),AY=Object.assign.apply(Object,_q([`objectsData`,`objectLat`,`objectLng`,`objectAltitude`,`objectRotation`,`objectFacesSurface`,`objectThreeObject`].map(function(e){return ZK({},e,kY.linkProp(e))}))),jY=wq(`customLayer`,$J),MY=Object.assign.apply(Object,_q([`customLayerData`,`customThreeObject`,`customThreeObjectUpdate`].map(function(e){return ZK({},e,jY.linkProp(e))}))),NY=je({props:sq(sq(sq(sq(sq(sq(sq(sq(sq(sq(sq(sq(sq(sq(sq({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new eY.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},rY),oY),cY),uY),fY),gY),mY),vY),bY),SY),wY),EY),OY),AY),MY),methods:sq({getGlobeRadius:Eq,getCoords:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Dq.apply(void 0,n)},toGeoCoords:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Oq.apply(void 0,n)},setPointOfView:function(e,t){var n=t instanceof eY.Camera?t.position:t,r=Eq(),i=void 0;if(e.scene&&n){var a,o,s,c;i=function(t){a===void 0&&(a=n.clone().applyMatrix4(e.scene.matrixWorld.clone().invert())),o===void 0&&(o=a.length()),s===void 0&&(s=Math.sqrt(o**2-r**2)),c===void 0&&(c=Math.acos(s/o));var i=a.distanceTo(t);if(i<s)return!1;var l=t.length();return Math.acos((o**2+i**2-l**2)/(2*o*i))<c}}e.layersThatNeedUpdatePov.forEach(function(e){return e.updatePov(t)}),e.layersThatNeedBehindGlobeChecker.forEach(function(e){return e.isBehindGlobe(i)})},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),e.pausableLayers.forEach(function(e){return e.pauseAnimation?.call(e)}),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),e.pausableLayers.forEach(function(e){return e.resumeAnimation?.call(e)}),this},_animationCycle:function(e){e.animationFrameRequestId=requestAnimationFrame(this._animationCycle),e.tweenGroup.update()},_destructor:function(e){this.pauseAnimation(),e.destructableLayers.forEach(function(e){return e._destructor()})}},iY),stateInit:function(){var e=new Pe,t={tweenGroup:e},n={globeLayer:Lq(t),pointsLayer:Qq(t),arcsLayer:sJ(t),hexBinLayer:dJ(t),heatmapsLayer:wJ(t),polygonsLayer:EJ(t),hexedPolygonsLayer:jJ(t),pathsLayer:IJ(t),tilesLayer:RJ(t),particlesLayer:VJ(t),ringsLayer:GJ(t),labelsLayer:JJ(t),htmlElementsLayer:XJ(t),objectsLayer:QJ(t),customLayer:$J(t)};return sq(sq({tweenGroup:e},n),{},{layersThatNeedUpdatePov:Object.values(n).filter(function(e){return e.hasOwnProperty(`updatePov`)}),layersThatNeedBehindGlobeChecker:Object.values(n).filter(function(e){return e.hasOwnProperty(`isBehindGlobe`)}),destructableLayers:Object.values(n).filter(function(e){return e.hasOwnProperty(`_destructor`)}),pausableLayers:Object.values(n).filter(function(e){return e.hasOwnProperty(`pauseAnimation`)})})},init:function(e,t,n){var r=n.animateIn,i=r===void 0?!0:r,a=n.waitForGlobeReady,o=a===void 0?!0:a;Cq(e),t.scene=e,t.scene.visible=!1,tY.forEach(function(e){var n=new eY.Group;t.scene.add(n),t[e](n)});var s=function(){if(i){t.scene.scale.set(1e-6,1e-6,1e-6),t.tweenGroup.add(new Re({k:1e-6}).to({k:1},600).easing(Me.Quadratic.Out).onUpdate(function(e){var n=e.k;return t.scene.scale.set(n,n,n)}).onComplete(function(){t.tweenGroup.remove(this)}).start());var e=new eY.Vector3(0,1,0);t.tweenGroup.add(new Re({rot:Math.PI*2}).to({rot:0},1200).easing(Me.Quintic.Out).onUpdate(function(n){var r=n.rot;return t.scene.setRotationFromAxisAngle(e,r)}).onComplete(function(){t.tweenGroup.remove(this)}).start())}t.scene.visible=!0,t.onGlobeReady&&t.onGlobeReady()};o?t.globeLayer.onReady(s):s(),this._animationCycle()},update:function(e){}});function PY(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=function(t){function r(){var t;WK(this,r);for(var i=arguments.length,a=Array(i),o=0;o<i;o++)a[o]=arguments[o];return t=HK(this,r,[].concat(a)),t.__kapsuleInstance=JK(e,[].concat(_q(n?[t]:[]),a)),t}return eq(r,t),XK(r)}(t);return Object.keys(e()).forEach(function(e){return r.prototype[e]=function(){var t,n=(t=this.__kapsuleInstance)[e].apply(t,arguments);return n===this.__kapsuleInstance?this:n}}),r}var FY=PY(NY,(window.THREE?window.THREE:{Group:i.Group}).Group,!0);function IY(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function LY(e,t,n){return t=JY(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function RY(e,t){return VY(e)||IY(e,t)||UY(e,t)||KY()}function zY(e){return BY(e)||HY(e)||UY(e)||GY()}function BY(e){if(Array.isArray(e))return WY(e)}function VY(e){if(Array.isArray(e))return e}function HY(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function UY(e,t){if(e){if(typeof e==`string`)return WY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return WY(e,t)}}function WY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function GY(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
919
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KY(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
920
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qY(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function JY(e){var t=qY(e,`string`);return typeof t==`symbol`?t:String(t)}var YY=function(e,t){var n=new Set(t);return Object.assign.apply(Object,[{}].concat(zY(Object.entries(e).filter(function(e){var t=RY(e,1)[0];return!n.has(t)}).map(function(e){var t=RY(e,2),n=t[0],r=t[1];return LY({},n,r)}))))};function XY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ZY(e){if(Array.isArray(e))return e}function QY(e){if(Array.isArray(e))return XY(e)}function $Y(e,t,n){return(t=dX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eX(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function tX(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function nX(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
921
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rX(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
922
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iX(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aX(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iX(Object(n),!0).forEach(function(t){$Y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iX(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oX(e,t){if(e==null)return{};var n,r,i=sX(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function sX(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function cX(e,t){return ZY(e)||tX(e,t)||fX(e,t)||nX()}function lX(e){return QY(e)||eX(e)||fX(e)||rX()}function uX(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function dX(e){var t=uX(e,`string`);return typeof t==`symbol`?t:t+``}function fX(e,t){if(e){if(typeof e==`string`)return XY(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?XY(e,t):void 0}}function pX(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.methodNames,i=r===void 0?[]:r,a=n.initPropNames,o=a===void 0?[]:a;return(0,t.forwardRef)(function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,a=(0,t.useMemo)(function(){return new e(Object.fromEntries(o.filter(function(e){return n.hasOwnProperty(e)}).map(function(e){return[e,n[e]]})))},[]);(0,t.useEffect)(function(){return a._destructor instanceof Function?a._destructor:void 0},[a]);var s=(0,t.useCallback)(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return a[e]instanceof Function?a[e].apply(a,n):void 0},[a]),c=Object.fromEntries(Object.entries(n).filter(function(e){var t=cX(e,1)[0];return!a[t]||!(a[t]instanceof Function)})),l=(0,t.useRef)({});return Object.keys(YY(n,[].concat(lX(i),lX(o),lX(Object.keys(c))))).filter(function(e){return l.current[e]!==n[e]}).forEach(function(e){return s(e,n[e])}),l.current=n,(0,t.useImperativeHandle)(r,function(){return Object.fromEntries(i.map(function(e){return[e,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return s.apply(void 0,[e].concat(n))}]}))}),(0,t.createElement)(`primitive`,aX(aX({},c),{},{object:a}))})}var mX=[`onHover`,`onClick`],hX=pX(FY,{initPropNames:[`waitForGlobeReady`,`animateIn`],methodNames:[`getGlobeRadius`,`getCoords`,`toGeoCoords`,`pauseAnimation`,`resumeAnimation`,`setPointOfView`,`globeTileEngineClearCache`]}),gX=function(e){var t=e.intersections,n=function(e){return e?e.hasOwnProperty(`__globeObjType`)?e:n(e.parent):null},r=t.find(function(e){var t=n(e.object);return t&&t.__globeObjType!==`atmosphere`});return[n(r?.object),r]},_X=function(e,t){return({polygon:function(e){return e.data},particles:function(e){return t&&t.hasOwnProperty(`index`)&&e.length>t.index?e[t.index]:e}}[e?.__globeObjType]||function(e){return e})(e?.__data)},vX=(0,t.forwardRef)(function(e,n){var r=e.onHover,i=e.onClick,a=oX(e,mX),o=(0,t.useRef)(null),s=(0,t.useCallback)(function(e){if(r){var t=cX(gX(e),2),n=t[0],i=t[1];n!==o.current&&(o.current=n,r(n?.__globeObjType,_X(n,i)))}},[r]),c=(0,t.useCallback)(function(e){var t=cX(gX(e),2),n=t[0],r=t[1];n&&i&&(i(n?.__globeObjType,_X(n,r),e),e.stopPropagation())},[i]);return(0,t.createElement)(hX,aX(aX({},a),{},{ref:n,onPointerMove:r?s:void 0,onClick:i?c:void 0}))});function yX(e,t){return typeof e==`function`?e(t):typeof e==`string`?t[e]:e}function bX(e){return new Promise(t=>{let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>{let r=document.createElement(`canvas`);r.width=n.width,r.height=n.height;let a=r.getContext(`2d`);a.drawImage(n,0,0);let o=a.getImageData(0,0,r.width,r.height),s=o.data;for(let t=0;t<s.length;t+=4){let n=s[t]*.299+s[t+1]*.587+s[t+2]*.114;s[t]=Math.min(255,n*e.globeTint.r),s[t+1]=Math.min(255,n*e.globeTint.g),s[t+2]=Math.min(255,n*e.globeTint.b)}a.putImageData(o,0,0);let c=new i.CanvasTexture(r);c.needsUpdate=!0,t(c)},n.src=`//unpkg.com/three-globe/example/img/earth-blue-marble.jpg`})}function xX(e,t){let n=t.get(e);if(n)return n;let r=document.createElement(`canvas`);r.width=256,r.height=256;let a=r.getContext(`2d`);a.font=`${256*.7}px serif`,a.textAlign=`center`,a.textBaseline=`middle`,a.fillText(e,256/2,256/2);let o=new i.CanvasTexture(r);o.minFilter=i.LinearFilter,o.magFilter=i.LinearFilter,o.needsUpdate=!0;let s=new i.SpriteMaterial({map:o,transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!0});return t.set(e,s),s}function SX(e,t,n){let r=`${e}:${t.width}:${t.height}:${t.font}:${t.color}`,a=n.get(r);if(a)return a;let o=document.createElement(`canvas`);o.width=t.width,o.height=t.height;let s=o.getContext(`2d`);s.font=t.font,s.fillStyle=t.color,s.textAlign=`center`,s.textBaseline=`middle`,s.fillText(e,t.width/2,t.height/2);let c=new i.CanvasTexture(o);c.minFilter=i.LinearFilter,c.magFilter=i.LinearFilter,c.needsUpdate=!0;let l=new i.SpriteMaterial({map:c,transparent:!0,depthWrite:!1,depthTest:!1,sizeAttenuation:!0});return n.set(r,l),l}function CX(e,t,n,r,i){let a=new Set,o=new Map,s=(e,t)=>`${e},${t}`,c=[...e].sort((e,t)=>r(e).localeCompare(r(t)));for(let e of c){let r=t(e),c=n(e),l=Math.round(r/i),u=Math.round(c/i),d=s(l,u);if(!a.has(d))a.add(d),o.set(e,[l*i,u*i]);else{let t=!1;for(let n=-1;n<=1&&!t;n++)for(let r=-1;r<=1&&!t;r++){if(n===0&&r===0)continue;let c=l+n,d=u+r,f=s(c,d);a.has(f)||(a.add(f),o.set(e,[c*i,d*i]),t=!0)}t||o.set(e,[r,c])}}return o}function wX(e,t,n){let r=(90-e)*(Math.PI/180),i=(90-t)*(Math.PI/180);return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function TX(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function EX(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return(t&65535)/65535*Math.PI*2}function DX(e){return e<=0?0:e>=1?1:2**(-10*e)*Math.sin((e-.1)*5*Math.PI)+1}function OX(e,t,n){let r=(performance.now()-e)/1e3-t;return Math.min(Math.max(r/n,0),1)}var kX=new i.Vector3,AX=new i.Vector3;function jX(e,t){kX.copy(e).normalize(),AX.copy(t).normalize();let n=kX.dot(AX);return Math.min(Math.max((n-.05)/.25,0),1)}var MX=[{name:`PACIFIC OCEAN`,lat:0,lng:-160},{name:`ATLANTIC OCEAN`,lat:15,lng:-35},{name:`INDIAN OCEAN`,lat:-20,lng:75},{name:`SOUTHERN OCEAN`,lat:-62,lng:0},{name:`ARCTIC OCEAN`,lat:78,lng:0}],NX=[{name:`ASIA`,lat:45,lng:85},{name:`EUROPE`,lat:54,lng:15},{name:`AFRICA`,lat:5,lng:22},{name:`NORTH AMERICA`,lat:48,lng:-100},{name:`SOUTH AMERICA`,lat:-15,lng:-58},{name:`OCEANIA`,lat:-25,lng:135}],PX=[{name:`Russia`,lat:62,lng:95},{name:`China`,lat:35,lng:103},{name:`India`,lat:22,lng:78},{name:`Japan`,lat:36,lng:138},{name:`Korea`,lat:36,lng:128},{name:`Philippines`,lat:13,lng:122},{name:`Indonesia`,lat:-2,lng:118},{name:`Thailand`,lat:15,lng:101},{name:`Myanmar`,lat:20,lng:97},{name:`Malaysia`,lat:4,lng:109},{name:`Vietnam`,lat:16,lng:108},{name:`Pakistan`,lat:30,lng:70},{name:`Iran`,lat:33,lng:53},{name:`Iraq`,lat:33,lng:44},{name:`Turkey`,lat:39,lng:35},{name:`Saudi Arabia`,lat:24,lng:45},{name:`Egypt`,lat:27,lng:30},{name:`Kazakhstan`,lat:48,lng:68},{name:`Mongolia`,lat:47,lng:105},{name:`France`,lat:47,lng:2},{name:`Spain`,lat:40,lng:-4},{name:`Italy`,lat:43,lng:12},{name:`Germany`,lat:51,lng:10},{name:`Ukraine`,lat:49,lng:32},{name:`Norway`,lat:64,lng:12},{name:`Greece`,lat:39,lng:22},{name:`Morocco`,lat:32,lng:-6},{name:`Algeria`,lat:28,lng:3},{name:`United States`,lat:39,lng:-98},{name:`Canada`,lat:56,lng:-106},{name:`Mexico`,lat:23,lng:-102},{name:`Brazil`,lat:-10,lng:-52},{name:`Argentina`,lat:-35,lng:-65},{name:`Colombia`,lat:4,lng:-72},{name:`Nigeria`,lat:10,lng:8},{name:`Congo`,lat:-3,lng:23},{name:`Sudan`,lat:16,lng:30},{name:`South Africa`,lat:-30,lng:25},{name:`Kenya`,lat:0,lng:38},{name:`Ethiopia`,lat:9,lng:39},{name:`Madagascar`,lat:-19,lng:47},{name:`Australia`,lat:-25,lng:134},{name:`New Zealand`,lat:-42,lng:173},{name:`Sri Lanka`,lat:7.5,lng:80.5}];function FX(e,t){let n=[];if(e.oceans)for(let e of MX)n.push({lat:e.lat,lng:e.lng,type:`ocean`,label:e.name});if(e.continents)for(let e of NX)n.push({lat:e.lat,lng:e.lng,type:`continent`,label:e.name});if(e.countries)for(let e of PX)n.push({lat:e.lat,lng:e.lng,type:`country`,label:e.name});if(t)for(let e of t)n.push({lat:e.lat,lng:e.lng,type:`country`,label:e.text});return n}function IX(e){let n=(0,t.useRef)(new Map),r=(0,t.useRef)(new Map),i=(0,t.useRef)(new Map);return{ocean:(0,t.useCallback)(t=>SX(t,{width:512,height:64,font:`32px 'Inter', system-ui, sans-serif`,color:`${e.textSecondary}4d`},n.current),[e]),continent:(0,t.useCallback)(t=>SX(t.split(``).join(` `),{width:1024,height:128,font:`bold 72px 'Inter', system-ui, sans-serif`,color:`${e.textSecondary}33`},r.current),[e]),country:(0,t.useCallback)(t=>SX(t,{width:512,height:64,font:`36px 'Inter', system-ui, sans-serif`,color:`${e.textSecondary}59`},i.current),[e])}}function LX({gridDeg:e,elevation:n=.08,color:r=`#585b70`}){return(0,a.jsx)(`primitive`,{object:(0,t.useMemo)(()=>{let t=101*(1+n),a=new i.LineBasicMaterial({color:new i.Color(r),transparent:!0,opacity:.15,depthWrite:!1}),o=new i.Group;for(let n=-80;n<=80;n+=e){let e=(90-n)*(Math.PI/180),r=[];for(let n=0;n<=64;n++){let a=n/64*Math.PI*2;r.push(new i.Vector3(t*Math.sin(e)*Math.cos(a),t*Math.cos(e),t*Math.sin(e)*Math.sin(a)))}o.add(new i.Line(new i.BufferGeometry().setFromPoints(r),a))}for(let n=-180;n<180;n+=e){let e=Math.PI/180*n,r=[];for(let n=0;n<=64;n++){let a=n/64*Math.PI;r.push(new i.Vector3(t*Math.sin(a)*Math.cos(e),t*Math.cos(a),t*Math.sin(a)*Math.sin(e)))}o.add(new i.Line(new i.BufferGeometry().setFromPoints(r),a))}return o},[e,n,r])})}function RX(e){let{data:o,lat:s,lng:c,icon:l,id:u,gridSize:d=5,gridElevation:f=.06,iconElevation:p=.005,iconSize:m=7,minDistance:h=200,maxDistance:g=500,autoRotate:_=!0,autoRotateSpeed:v=.3,rotateSpeed:y=.25,entrance:b=`sprout`,entranceDuration:x=2.5,entranceStagger:S=2,selectedId:C,onClick:w,onHover:T,labels:E,customLabels:D,bumpMap:O=!0,atmosphereAltitude:k=.18,resolvedTheme:A}=e,ee=(0,t.useRef)(void 0),j=(0,t.useRef)(null),{camera:te}=(0,n.useThree)(),[ne,re]=(0,t.useState)(_),ie=(0,t.useCallback)(()=>re(!1),[]),[ae,oe]=(0,t.useState)();(0,t.useEffect)(()=>{bX(A).then(e=>{oe(new i.MeshStandardMaterial({map:e,roughness:1,metalness:0}))})},[A]);let se=(0,t.useMemo)(()=>{let e=e=>yX(s,e),t=e=>yX(c,e),n=d>0?CX(o,e,t,e=>u?yX(u,e):String(yX(s,e)),d):null,r=o.map(r=>{let i=n?.get(r)??[e(r),t(r)];return{lat:i[0],lng:i[1],type:`item`,originalItem:r,icon:l?yX(l,r):void 0,id:u?yX(u,r):void 0}}),i=FX(typeof E==`boolean`?{continents:E,countries:E,oceans:E}:E??{},D);return[...r,...i]},[o,s,c,l,u,d,E,D]),ce=(0,t.useRef)(new Map),le=IX(A),ue=(0,t.useRef)(performance.now()),de=(0,t.useMemo)(()=>new i.Vector3,[]),fe=(0,t.useMemo)(()=>new i.Vector3,[]),pe=(0,t.useCallback)((e,t)=>(e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1),e.getWorldPosition(de),t.getWorldPosition(fe),jX(de,fe)),[fe,de]),me=(0,t.useCallback)(e=>{let t=e,n=ue.current;if(t.type===`ocean`){let e=new i.Sprite(le.ocean(t.label).clone());e.scale.set(0,0,1);let r=1.8+Math.random()*.6;return e.onBeforeRender=(t,i,a)=>{let o=OX(n,r,.8),s=DX(o),c=pe(e,a);e.scale.set(18*s,2.2*s,1),e.material.opacity=o*c},e}if(t.type===`continent`){let e=new i.Sprite(le.continent(t.label).clone());e.scale.set(0,0,1);let r=2+Math.random()*.5;return e.onBeforeRender=(t,i,a)=>{let o=OX(n,r,1),s=pe(e,a);e.scale.set(35*o,4.5*o,1),e.material.opacity=o*.22*s},e}if(t.type===`country`){let e=new i.Sprite(le.country(t.label).clone());e.scale.set(0,0,1);let r=2.2+Math.random()*.8;return e.onBeforeRender=(t,i,a)=>{let o=OX(n,r,.6),s=pe(e,a);e.scale.set(10*o,1.5*o,1),e.material.opacity=o*.4*s},e}let r=(typeof t.icon==`string`?t.icon:null)??`📍`,a=new i.Group,o=new i.Sprite(xX(r,ce.current).clone()),s=m,c=0,l=EX(t.id??r),u=b===`none`?0:.3+l/(Math.PI*2)*S,d=b===`none`?0:.7;return o.scale.set(0,0,1),a.renderOrder=10,o.renderOrder=10,o.onBeforeRender=(e,t,r)=>{let i=performance.now()*.001,f=d>0?OX(n,u,d):1,p;p=b===`sprout`?DX(f):b===`fade`?f:b===`scatter`?DX(f):1;let m=pe(a,r),h=f>=1?Math.sin(i*1.2+l)*.4:0,g=(f>=1?s+Math.sin(i*2+l)*.3:s)*p,_=m*Math.min(f,1);c+=(_-c)*.18,o.scale.set(g,g,1),o.material.opacity=c,o.position.y=(1-p)*-3+h},a.add(o),a},[b,S,m,le,pe]),he=(0,t.useCallback)(e=>{let t=e.type;return t===`ocean`?.008:t===`continent`?.003:t===`country`?.006:p},[p]),ge=(0,t.useCallback)((e,t,n)=>{if(!t||!w)return;let r=t;r.type===`item`&&r.originalItem&&w(r.originalItem,n)},[w]),_e=(0,t.useCallback)((e,t)=>{let n=t,r=n?.type===`item`;document.body.style.cursor=r?`pointer`:``,T?.(r&&n?.originalItem?n.originalItem:null)},[T]),ve=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!C)return;let e=se.find(e=>e.type===`item`&&e.id===C);if(!e)return;let t=Math.min(te.position.length(),220),[n,r,a]=wX(e.lat,e.lng,t);ve.current={start:te.position.clone(),end:new i.Vector3(n,r,a),startTime:performance.now(),duration:1500}},[C,se,te]),(0,n.useFrame)(()=>{let e=ve.current;if(!e)return;let t=performance.now()-e.startTime,n=Math.min(t/e.duration,1);te.position.lerpVectors(e.start,e.end,TX(n)),te.lookAt(0,0,0),j.current&&(j.current.target.set(0,0,0),j.current.update()),n>=1&&(ve.current=null)}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(vX,{ref:ee,showGlobe:!0,...ae?{globeMaterial:ae}:{},bumpImageUrl:O?`//unpkg.com/three-globe/example/img/earth-topology.png`:void 0,showAtmosphere:!0,atmosphereColor:A.atmosphere,atmosphereAltitude:k,showGraticules:!1,objectsData:se,objectLat:`lat`,objectLng:`lng`,objectAltitude:he,objectThreeObject:me,onClick:ge,onHover:_e}),(0,a.jsx)(LX,{gridDeg:d,elevation:f,color:A.grid}),(0,a.jsx)(r.OrbitControls,{ref:j,autoRotate:ne,autoRotateSpeed:v,enablePan:!1,minDistance:h,maxDistance:g,rotateSpeed:y,zoomSpeed:.6,enableDamping:!0,dampingFactor:.08,onStart:ie}),(0,a.jsx)(`ambientLight`,{intensity:1.6,color:A.text}),(0,a.jsx)(`directionalLight`,{position:[100,80,100],intensity:.5,color:A.text})]})}function zX({count:e=2e3,theme:n}){return(0,a.jsx)(`points`,{geometry:(0,t.useMemo)(()=>{let t=new Float32Array(e*3),n=new Float32Array(e);for(let r=0;r<e;r++){let e=800+Math.random()*700,i=Math.random()*Math.PI*2,a=Math.acos(2*Math.random()-1);t[r*3]=e*Math.sin(a)*Math.cos(i),t[r*3+1]=e*Math.sin(a)*Math.sin(i),t[r*3+2]=e*Math.cos(a),n[r]=.5+Math.random()*1.5}let r=new i.BufferGeometry;return r.setAttribute(`position`,new i.BufferAttribute(t,3)),r.setAttribute(`size`,new i.BufferAttribute(n,1)),r},[e]),children:(0,a.jsx)(`pointsMaterial`,{color:n.textSecondary,size:1.2,sizeAttenuation:!0,transparent:!0,opacity:.7,depthWrite:!1})})}function BX(e){let{initialDistance:t,resolvedTheme:r,starfield:i,starfieldCount:o,onItemClick:s,onItemHover:c,...l}=e;return(0,a.jsxs)(n.Canvas,{camera:{position:[0,0,t],fov:50,near:1,far:2e3},style:{width:`100%`,height:`100%`},children:[i!==!1&&(0,a.jsx)(zX,{count:o,theme:r}),(0,a.jsx)(RX,{...l,onClick:s,onHover:c,resolvedTheme:r})]})}var VX=(0,t.memo)(BX);function HX(e){let n=y(e.theme),{starfield:r=!0,starfieldCount:i=2e3,initialDistance:o=350,tooltip:s,detailPanel:c,onClick:l}=e,[u,d]=(0,t.useState)(null),f=(0,t.useRef)(null),p=(0,t.useRef)({x:0,y:0}),m=(0,t.useRef)(null),[h,g]=(0,t.useState)(null),_=(0,t.useCallback)(()=>{let e=m.current;e&&(e.style.left=`${p.current.x+16}px`,e.style.top=`${p.current.y-10}px`)},[]),v=(0,t.useCallback)(t=>{f.current!==t&&(f.current=t,d(t),e.onHover?.(t))},[e.onHover]),b=(0,t.useCallback)((e,t)=>{g(e),l?.(e,t)},[l]),x=(0,t.useCallback)(()=>{g(null)},[]),S=(0,t.useCallback)(e=>{p.current={x:e.clientX,y:e.clientY},_()},[_]);(0,t.useEffect)(()=>{_()},[u,_]);let C=h;return(0,a.jsxs)(`div`,{style:{width:`100%`,height:`100%`,background:n.background,position:`relative`},onMouseMove:S,children:[(0,a.jsx)(VX,{...e,initialDistance:o,resolvedTheme:n,starfield:r,starfieldCount:i,onItemClick:b,onItemHover:v}),e.header&&(0,a.jsx)(`div`,{style:{position:`fixed`,top:16,left:`50%`,transform:`translateX(-50%)`,zIndex:50,pointerEvents:`none`},children:(0,a.jsx)(`div`,{style:{pointerEvents:`auto`},children:e.header()})}),e.filterBar&&(0,a.jsx)(`div`,{style:{position:`fixed`,bottom:20,left:`50%`,transform:`translateX(-50%)`,zIndex:50},children:e.filterBar()}),s&&u&&(0,a.jsx)(`div`,{ref:m,style:{position:`fixed`,left:0,top:0,zIndex:300,display:`flex`,alignItems:`center`,gap:8,background:n.frostedBg,backdropFilter:`blur(8px)`,border:`1px solid ${n.frostedBorder}`,borderRadius:8,padding:`8px 12px`,pointerEvents:`none`,maxWidth:240},children:s(u)}),c&&C&&c(C,x)]})}e.Globe=HX,e.themes=v});
|