Files
gemini-viewer-examples/demo/libs/gemini-viewer.esm.min.js
2023-06-01 09:06:56 +00:00

1 line
3.1 MiB

var Lxe=Object.create,z0=Object.defineProperty,Oxe=Object.defineProperties,Nxe=Object.getOwnPropertyDescriptor,Uxe=Object.getOwnPropertyDescriptors,Bxe=Object.getOwnPropertyNames,F4=Object.getOwnPropertySymbols,k4=Object.getPrototypeOf,V4=Object.prototype.hasOwnProperty,Fxe=Object.prototype.propertyIsEnumerable,Hxe=Reflect.get,Kl=Math.pow,H4=(e,t,n)=>t in e?z0(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yn=(e,t)=>{for(var n in t||(t={}))V4.call(t,n)&&H4(e,n,t[n]);if(F4)for(var n of F4(t))Fxe.call(t,n)&&H4(e,n,t[n]);return e},Qr=(e,t)=>Oxe(e,Uxe(t)),kxe=(e,t)=>()=>(e&&(t=e(e=0)),t),F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l_=(e,t)=>{for(var n in t)z0(e,n,{get:t[n],enumerable:!0})},z4=(e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Bxe(t))!V4.call(e,r)&&r!==n&&z0(e,r,{get:()=>t[r],enumerable:!(i=Nxe(t,r))||i.enumerable});return e},wi=(e,t,n)=>(n=null!=e?Lxe(k4(e)):{},z4(!t&&e&&e.__esModule?n:z0(n,"default",{value:e,enumerable:!0}),e)),Vxe=e=>z4(z0({},"__esModule",{value:!0}),e),G4=(e,t,n)=>Hxe(k4(e),n,t),$e=(e,t,n)=>new Promise(((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())})),j4={};function c_(e){return(c_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Gxe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function q4(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function qxe(e,t,n){return t&&q4(e.prototype,t),n&&q4(e,n),e}function Yxe(e,t,n){var i=function(e){do{if(t(e))return e;e=e.replace(/-?[^-]*$/,"")}while(e);return null},r=function(){function r(n){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gxe(this,r),this._locale=function(e){for(var t=W4(e),n=0;n<t.length;++n){var r=i(t[n]);if(r)return r}return i(jxe())}(n),this._select=t(this._locale),this._type=Xxe(a.type),this._nf=new e("en",a)}return qxe(r,[{key:"resolvedOptions",value:function(){var e=this._nf.resolvedOptions(),t=e.minimumIntegerDigits,i=e.minimumFractionDigits,r=e.maximumFractionDigits,a=e.minimumSignificantDigits,s=e.maximumSignificantDigits,o={locale:this._locale,minimumIntegerDigits:t,minimumFractionDigits:i,maximumFractionDigits:r,pluralCategories:n(this._locale,"ordinal"===this._type),type:this._type};return"number"==typeof a&&(o.minimumSignificantDigits=a,o.maximumSignificantDigits=s),o}},{key:"select",value:function(e){if(!(this instanceof r))throw new TypeError("select() called on incompatible ".concat(this));if("number"!=typeof e&&(e=Number(e)),!isFinite(e))return"other";var t=this._nf.format(Math.abs(e));return this._select(t,"ordinal"===this._type)}}],[{key:"supportedLocalesOf",value:function(e){return W4(e).filter(i)}}]),r}();return Object.defineProperty(r,"prototype",{writable:!1}),r}l_(j4,{default:()=>Yxe});var Wxe,W4,jxe,Xxe,X4=kxe((()=>{Wxe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},W4=function(e){if(!e)return[];Array.isArray(e)||(e=[e]);for(var t={},n=0;n<e.length;++n){var i=e[n];if(i&&"object"===c_(i)&&(i=String(i)),"string"!=typeof i){var r="Locales should be strings, ".concat(JSON.stringify(i)," isn't.");throw new TypeError(r)}if("*"!==i[0]){if(!Wxe(i)){var a=JSON.stringify(i),s="The locale ".concat(a," is not a structurally valid BCP 47 language tag.");throw new RangeError(s)}t[i]=!0}}return Object.keys(t)},jxe=function(){return"undefined"!=typeof navigator&&navigator&&(navigator.userLanguage||navigator.language)||"en-US"},Xxe=function(e){if(!e)return"cardinal";if("cardinal"===e||"ordinal"===e)return e;throw new RangeError("Not a valid plural type: "+JSON.stringify(e))}})),Z4=F(((e,t)=>{"use strict";function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(t,n){var i=n.minimumIntegerDigits,r=n.minimumFractionDigits,a=n.maximumFractionDigits,s=n.minimumSignificantDigits,o=n.maximumSignificantDigits;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._minID="number"==typeof i?i:1,this._minFD="number"==typeof r?r:0,this._maxFD="number"==typeof a?a:Math.max(this._minFD,3),("number"==typeof s||"number"==typeof o)&&(this._minSD="number"==typeof s?s:1,this._maxSD="number"==typeof o?o:21)}return function(e,t,i){t&&n(e.prototype,t)}(e,[{key:"resolvedOptions",value:function(){var e={minimumIntegerDigits:this._minID,minimumFractionDigits:this._minFD,maximumFractionDigits:this._maxFD};return"number"==typeof this._minSD&&(e.minimumSignificantDigits=this._minSD,e.maximumSignificantDigits=this._maxSD),e}},{key:"format",value:function(e){if(this._minSD){for(var t=String(e),n=0,i=0;i<t.length;++i){var r=t[i];r>="0"&&r<="9"&&++n}return n<this._minSD?e.toPrecision(this._minSD):n>this._maxSD?e.toPrecision(this._maxSD):t}return this._minFD>0?e.toFixed(this._minFD):0===this._maxFD?e.toFixed(0):String(e)}}]),e}();t.exports=i})),iV=F(((e,t)=>{"use strict";var n=(X4(),Vxe(j4)),i=Z4();function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(n),s=r(i);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var h,c,u,d,p,f,m,g,v={exports:{}};h=v,u=function(e,t){return t?"other":1==e?"one":"other"},d=function(e,t){return t?"other":0==e||1==e?"one":"other"},p=function(e,t){return t?"other":e>=0&&e<=1?"one":"other"},f=function(e,t){var n=!String(e).split(".")[1];return t?"other":1==e&&n?"one":"other"},g=function(e,t){return t?"other":1==e?"one":2==e?"two":"other"},c={_in:m=function(e,t){return"other"},af:u,ak:d,am:p,an:u,ar:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},ars:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},as:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},asa:u,ast:f,az:function(e,t){var n=String(e).split(".")[0],i=n.slice(-1),r=n.slice(-2),a=n.slice(-3);return t?1==i||2==i||5==i||7==i||8==i||20==r||50==r||70==r||80==r?"one":3==i||4==i||100==a||200==a||300==a||400==a||500==a||600==a||700==a||800==a||900==a?"few":0==n||6==i||40==r||60==r||90==r?"many":"other":1==e?"one":"other"},be:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?2!=r&&3!=r||12==a||13==a?"other":"few":1==r&&11!=a?"one":r>=2&&r<=4&&(a<12||a>14)?"few":i&&0==r||r>=5&&r<=9||a>=11&&a<=14?"many":"other"},bem:u,bez:u,bg:u,bho:d,bm:m,bn:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},bo:m,br:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2),s=i&&n[0].slice(-6);return t?"other":1==r&&11!=a&&71!=a&&91!=a?"one":2==r&&12!=a&&72!=a&&92!=a?"two":(3==r||4==r||9==r)&&(a<10||a>19)&&(a<70||a>79)&&(a<90||a>99)?"few":0!=e&&i&&0==s?"many":"other"},brx:u,bs:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ca:function(e,t){var n=!String(e).split(".")[1];return t?1==e||3==e?"one":2==e?"two":4==e?"few":"other":1==e&&n?"one":"other"},ce:u,ceb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},cgg:u,chr:u,ckb:u,cs:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},cy:function(e,t){return t?0==e||7==e||8==e||9==e?"zero":1==e?"one":2==e?"two":3==e||4==e?"few":5==e||6==e?"many":"other":0==e?"zero":1==e?"one":2==e?"two":3==e?"few":6==e?"many":"other"},da:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e;return t||1!=e&&(r||0!=i&&1!=i)?"other":"one"},de:f,doi:p,dsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},dv:u,dz:m,ee:u,el:u,en:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1==a&&11!=s?"one":2==a&&12!=s?"two":3==a&&13!=s?"few":"other":1==e&&i?"one":"other"},eo:u,es:u,et:f,eu:u,fa:p,ff:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},fi:f,fil:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},fo:u,fr:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-6);return t?1==e?"one":"other":e>=0&&e<2?"one":0!=i&&0==a&&r?"many":"other"},fur:u,fy:f,ga:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e?"one":"other":1==e?"one":2==e?"two":i&&e>=3&&e<=6?"few":i&&e>=7&&e<=10?"many":"other"},gd:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||11==e?"one":2==e||12==e?"two":3==e||13==e?"few":"other":1==e||11==e?"one":2==e||12==e?"two":i&&e>=3&&e<=10||i&&e>=13&&e<=19?"few":"other"},gl:f,gsw:u,gu:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},guw:d,gv:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":!r||0!=s&&20!=s&&40!=s&&60!=s&&80!=s?r?"other":"many":"few"},ha:u,haw:u,he:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},hi:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},hr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},hsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},hu:function(e,t){return t?1==e||5==e?"one":"other":1==e?"one":"other"},hy:function(e,t){return t?1==e?"one":"other":e>=0&&e<2?"one":"other"},ia:f,id:m,ig:m,ii:m,io:f,is:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e,a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s||!r?"one":"other"},it:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},iu:g,iw:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},ja:m,jbo:m,jgo:u,ji:f,jmc:u,jv:m,jw:m,ka:function(e,t){var n=String(e).split(".")[0],i=n.slice(-2);return t?1==n?"one":0==n||i>=2&&i<=20||40==i||60==i||80==i?"many":"other":1==e?"one":"other"},kab:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},kaj:u,kcg:u,kde:m,kea:m,kk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1);return t?6==r||9==r||i&&0==r&&0!=e?"many":"other":1==e?"one":"other"},kkj:u,kl:u,km:m,kn:p,ko:m,ks:u,ksb:u,ksh:function(e,t){return t?"other":0==e?"zero":1==e?"one":"other"},ku:u,kw:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-2),a=i&&n[0].slice(-3),s=i&&n[0].slice(-5),o=i&&n[0].slice(-6);return t?i&&e>=1&&e<=4||r>=1&&r<=4||r>=21&&r<=24||r>=41&&r<=44||r>=61&&r<=64||r>=81&&r<=84?"one":5==e||5==r?"many":"other":0==e?"zero":1==e?"one":2==r||22==r||42==r||62==r||82==r||i&&0==a&&(s>=1e3&&s<=2e4||4e4==s||6e4==s||8e4==s)||0!=e&&1e5==o?"two":3==r||23==r||43==r||63==r||83==r?"few":1==e||1!=r&&21!=r&&41!=r&&61!=r&&81!=r?"other":"many"},ky:u,lag:function(e,t){var n=String(e).split(".")[0];return t?"other":0==e?"zero":0!=n&&1!=n||0==e?"other":"one"},lb:u,lg:u,lij:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e;return t?11==e||8==e||r&&e>=80&&e<=89||r&&e>=800&&e<=899?"many":"other":1==e&&i?"one":"other"},lkt:m,ln:d,lo:function(e,t){return t&&1==e?"one":"other"},lt:function(e,t){var n=String(e).split("."),i=n[1]||"",r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?"other":1==a&&(s<11||s>19)?"one":a>=2&&a<=9&&(s<11||s>19)?"few":0!=i?"many":"other"},lv:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},mas:u,mg:d,mgo:u,mk:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?1==s&&11!=o?"one":2==s&&12!=o?"two":7!=s&&8!=s||17==o||18==o?"other":"many":a&&1==s&&11!=o||1==l&&11!=h?"one":"other"},ml:u,mn:u,mo:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},mr:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":"other":1==e?"one":"other"},ms:function(e,t){return t&&1==e?"one":"other"},mt:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":1==e?"one":0==e||i>=2&&i<=10?"few":i>=11&&i<=19?"many":"other"},my:m,nah:u,naq:g,nb:u,nd:u,ne:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?i&&e>=1&&e<=4?"one":"other":1==e?"one":"other"},nl:f,nn:u,nnh:u,no:u,nqo:m,nr:u,nso:d,ny:u,nyn:u,om:u,or:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||5==e||i&&e>=7&&e<=9?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":1==e?"one":"other"},os:u,osa:m,pa:d,pap:u,pcm:p,pl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":1==e&&r?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&1!=i&&(0==a||1==a)||r&&a>=5&&a<=9||r&&s>=12&&s<=14?"many":"other"},prg:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},ps:u,pt:function(e,t){var n=String(e).split(".")[0];return t?"other":0==n||1==n?"one":"other"},pt_PT:f,rm:u,ro:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},rof:u,root:m,ru:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&0==a||r&&a>=5&&a<=9||r&&s>=11&&s<=14?"many":"other"},rwk:u,sah:m,saq:u,sat:g,sc:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},scn:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},sd:u,sdh:u,se:g,seh:u,ses:m,sg:m,sh:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},shi:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":e>=0&&e<=1?"one":i&&e>=2&&e<=10?"few":"other"},si:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"";return t?"other":0==e||1==e||0==i&&1==r?"one":"other"},sk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},sl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":r&&(3==a||4==a)||!r?"few":"other"},sma:g,smi:g,smj:g,smn:g,sms:g,sn:u,so:u,sq:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?1==e?"one":4==r&&14!=a?"many":"other":1==e?"one":"other"},sr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ss:u,ssy:u,st:u,su:m,sv:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1!=a&&2!=a||11==s||12==s?"other":"one":1==e&&i?"one":"other"},sw:f,syr:u,ta:u,te:u,teo:u,th:m,ti:d,tig:u,tk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-1);return t?6==i||9==i||10==e?"few":"other":1==e?"one":"other"},tl:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},tn:u,to:m,tr:u,ts:u,tzm:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":0==e||1==e||i&&e>=11&&e<=99?"one":"other"},ug:u,uk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-1),h=i.slice(-2);return t?3==s&&13!=o?"few":"other":r&&1==l&&11!=h?"one":r&&l>=2&&l<=4&&(h<12||h>14)?"few":r&&0==l||r&&l>=5&&l<=9||r&&h>=11&&h<=14?"many":"other"},ur:f,uz:u,ve:u,vi:function(e,t){return t&&1==e?"one":"other"},vo:u,vun:u,wa:d,wae:u,wo:m,xh:u,xog:u,yi:f,yo:m,yue:m,zh:m,zu:p},Object.defineProperty(c,"__esModule",{value:!0}),h.exports=c;var y=l(v.exports),x=Object.freeze(Object.assign(Object.create(null),v.exports,{default:y})),_={exports:{}};!function(e,t){var n,i="zero",r="one",a="two",s="few",o="many",l="other",h={cardinal:[r,l],ordinal:[l]},c={cardinal:[l],ordinal:[l]},u={cardinal:[r,s,o,l],ordinal:[l]},d={cardinal:[r,l],ordinal:[r,l]},p={cardinal:[r,a,l],ordinal:[l]};n={_in:c,af:h,ak:h,am:h,an:h,ar:{cardinal:[i,r,a,s,o,l],ordinal:[l]},ars:{cardinal:[i,r,a,s,o,l],ordinal:[l]},as:{cardinal:[r,l],ordinal:[r,a,s,o,l]},asa:h,ast:h,az:{cardinal:[r,l],ordinal:[r,s,o,l]},be:{cardinal:[r,s,o,l],ordinal:[s,l]},bem:h,bez:h,bg:h,bho:h,bm:c,bn:{cardinal:[r,l],ordinal:[r,a,s,o,l]},bo:c,br:{cardinal:[r,a,s,o,l],ordinal:[l]},brx:h,bs:{cardinal:[r,s,l],ordinal:[l]},ca:{cardinal:[r,l],ordinal:[r,a,s,l]},ce:h,ceb:h,cgg:h,chr:h,ckb:h,cs:u,cy:{cardinal:[i,r,a,s,o,l],ordinal:[i,r,a,s,o,l]},da:h,de:h,doi:h,dsb:{cardinal:[r,a,s,l],ordinal:[l]},dv:h,dz:c,ee:h,el:h,en:{cardinal:[r,l],ordinal:[r,a,s,l]},eo:h,es:h,et:h,eu:h,fa:h,ff:h,fi:h,fil:d,fo:h,fr:{cardinal:[r,o,l],ordinal:[r,l]},fur:h,fy:h,ga:{cardinal:[r,a,s,o,l],ordinal:[r,l]},gd:{cardinal:[r,a,s,l],ordinal:[r,a,s,l]},gl:h,gsw:h,gu:{cardinal:[r,l],ordinal:[r,a,s,o,l]},guw:h,gv:{cardinal:[r,a,s,o,l],ordinal:[l]},ha:h,haw:h,he:{cardinal:[r,a,o,l],ordinal:[l]},hi:{cardinal:[r,l],ordinal:[r,a,s,o,l]},hr:{cardinal:[r,s,l],ordinal:[l]},hsb:{cardinal:[r,a,s,l],ordinal:[l]},hu:d,hy:d,ia:h,id:c,ig:c,ii:c,io:h,is:h,it:{cardinal:[r,l],ordinal:[o,l]},iu:p,iw:{cardinal:[r,a,o,l],ordinal:[l]},ja:c,jbo:c,jgo:h,ji:h,jmc:h,jv:c,jw:c,ka:{cardinal:[r,l],ordinal:[r,o,l]},kab:h,kaj:h,kcg:h,kde:c,kea:c,kk:{cardinal:[r,l],ordinal:[o,l]},kkj:h,kl:h,km:c,kn:h,ko:c,ks:h,ksb:h,ksh:{cardinal:[i,r,l],ordinal:[l]},ku:h,kw:{cardinal:[i,r,a,s,o,l],ordinal:[r,o,l]},ky:h,lag:{cardinal:[i,r,l],ordinal:[l]},lb:h,lg:h,lij:{cardinal:[r,l],ordinal:[o,l]},lkt:c,ln:h,lo:{cardinal:[l],ordinal:[r,l]},lt:u,lv:{cardinal:[i,r,l],ordinal:[l]},mas:h,mg:h,mgo:h,mk:{cardinal:[r,l],ordinal:[r,a,o,l]},ml:h,mn:h,mo:{cardinal:[r,s,l],ordinal:[r,l]},mr:{cardinal:[r,l],ordinal:[r,a,s,l]},ms:{cardinal:[l],ordinal:[r,l]},mt:u,my:c,nah:h,naq:p,nb:h,nd:h,ne:d,nl:h,nn:h,nnh:h,no:h,nqo:c,nr:h,nso:h,ny:h,nyn:h,om:h,or:{cardinal:[r,l],ordinal:[r,a,s,o,l]},os:h,osa:c,pa:h,pap:h,pcm:h,pl:u,prg:{cardinal:[i,r,l],ordinal:[l]},ps:h,pt:h,pt_PT:h,rm:h,ro:{cardinal:[r,s,l],ordinal:[r,l]},rof:h,root:c,ru:u,rwk:h,sah:c,saq:h,sat:p,sc:{cardinal:[r,l],ordinal:[o,l]},scn:{cardinal:[r,l],ordinal:[o,l]},sd:h,sdh:h,se:p,seh:h,ses:c,sg:c,sh:{cardinal:[r,s,l],ordinal:[l]},shi:{cardinal:[r,s,l],ordinal:[l]},si:h,sk:u,sl:{cardinal:[r,a,s,l],ordinal:[l]},sma:p,smi:p,smj:p,smn:p,sms:p,sn:h,so:h,sq:{cardinal:[r,l],ordinal:[r,o,l]},sr:{cardinal:[r,s,l],ordinal:[l]},ss:h,ssy:h,st:h,su:c,sv:d,sw:h,syr:h,ta:h,te:h,teo:h,th:c,ti:h,tig:h,tk:{cardinal:[r,l],ordinal:[s,l]},tl:d,tn:h,to:c,tr:h,ts:h,tzm:h,ug:h,uk:{cardinal:[r,s,o,l],ordinal:[s,l]},ur:h,uz:h,ve:h,vi:{cardinal:[l],ordinal:[r,l]},vo:h,vun:h,wa:h,wae:h,wo:c,xh:h,xog:h,yi:h,yo:c,yue:c,zh:c,zu:h},Object.defineProperty(n,"__esModule",{value:!0}),e.exports=n}(_);var b=l(_.exports),M=Object.freeze(Object.assign(Object.create(null),_.exports,{default:b})),w=y||x,S=b||M,E="object"===("undefined"==typeof Intl?"undefined":o(Intl))&&Intl.NumberFormat||s.default,T=function(e){return"in"===e?"_in":"pt-PT"===e?"pt_PT":e},A=a.default(E,(function(e){return w[T(e)]}),(function(e,t){return S[T(e)][t?"ordinal":"cardinal"]}));t.exports=A})),oV=F((e=>{"use strict";var t,n,i=(t=iV())&&"object"==typeof t&&"default"in t?t:{default:t};"undefined"==typeof Intl?("undefined"!=typeof global?global.Intl={PluralRules:i.default}:"undefined"!=typeof window?window.Intl={PluralRules:i.default}:e.Intl={PluralRules:i.default},i.default.polyfill=!0):Intl.PluralRules?(n=["en","es","ru","zh"],Intl.PluralRules.supportedLocalesOf(n).length<n.length&&(Intl.PluralRules=i.default,i.default.polyfill=!0)):(Intl.PluralRules=i.default,i.default.polyfill=!0)})),Ot=F(((e,t)=>{var n=function(e){return e&&e.Math==Math&&e};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof global&&global)||function(){return this}()||Function("return this")()})),dt=F(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),on=F(((e,t)=>{var n=dt();t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),um=F(((e,t)=>{var n=dt();t.exports=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),Bn=F(((e,t)=>{var n=um(),i=Function.prototype.call;t.exports=n?i.bind(i):function(){return i.apply(i,arguments)}})),G0=F((e=>{"use strict";var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,i=n&&!t.call({1:2},1);e.f=i?function(e){var t=n(this,e);return!!t&&t.enumerable}:t})),Da=F(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),yt=F(((e,t)=>{var n=um(),i=Function.prototype,r=i.call,a=n&&i.bind.bind(r,r);t.exports=n?a:function(e){return function(){return r.apply(e,arguments)}}})),ls=F(((e,t)=>{var n=yt(),i=n({}.toString),r=n("".slice);t.exports=function(e){return r(i(e),8,-1)}})),af=F(((e,t)=>{var n=yt(),i=dt(),r=ls(),a=Object,s=n("".split);t.exports=i((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==r(e)?s(e,""):a(e)}:a})),Cs=F(((e,t)=>{t.exports=function(e){return null==e}})),Mi=F(((e,t)=>{var n=Cs(),i=TypeError;t.exports=function(e){if(n(e))throw i("Can't call method on "+e);return e}})),Ni=F(((e,t)=>{var n=af(),i=Mi();t.exports=function(e){return n(i(e))}})),j3=F(((e,t)=>{var n="object"==typeof document&&document.all,i=void 0===n&&void 0!==n;t.exports={all:n,IS_HTMLDDA:i}})),Xn=F(((e,t)=>{var n=j3(),i=n.all;t.exports=n.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}})),Yn=F(((e,t)=>{var n=Xn(),i=j3(),r=i.all;t.exports=i.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:n(e)||e===r}:function(e){return"object"==typeof e?null!==e:n(e)}})),Xr=F(((e,t)=>{var n=Ot(),i=Xn();t.exports=function(e,t){return arguments.length<2?function(e){return i(e)?e:void 0}(n[e]):n[e]&&n[e][t]}})),La=F(((e,t)=>{var n=yt();t.exports=n({}.isPrototypeOf)})),Jl=F(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),Ql=F(((e,t)=>{var n,i,r=Ot(),a=Jl(),s=r.process,o=r.Deno,l=s&&s.versions||o&&o.version,h=l&&l.v8;h&&(i=(n=h.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!i&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(i=+n[1]),t.exports=i})),of=F(((e,t)=>{var n=Ql(),i=dt();t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41}))})),$3=F(((e,t)=>{var n=of();t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Mh=F(((e,t)=>{var n=Xr(),i=Xn(),r=La(),a=$3(),s=Object;t.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=n("Symbol");return i(t)&&r(t.prototype,s(e))}})),Sh=F(((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch(e){return"Object"}}})),ui=F(((e,t)=>{var n=Xn(),i=Sh(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a function")}})),ec=F(((e,t)=>{var n=ui(),i=Cs();t.exports=function(e,t){var r=e[t];return i(r)?void 0:n(r)}})),Q3=F(((e,t)=>{var n=Bn(),i=Xn(),r=Yn(),a=TypeError;t.exports=function(e,t){var s,o;if("string"===t&&i(s=e.toString)&&!r(o=n(s,e))||i(s=e.valueOf)&&!r(o=n(s,e))||"string"!==t&&i(s=e.toString)&&!r(o=n(s,e)))return o;throw a("Can't convert object to primitive value")}})),hi=F(((e,t)=>{t.exports=!1})),p_=F(((e,t)=>{var n=Ot(),i=Object.defineProperty;t.exports=function(e,t){try{i(n,e,{value:t,configurable:!0,writable:!0})}catch(i){n[e]=t}return t}})),m_=F(((e,t)=>{var n=Ot(),i=p_(),r="__core-js_shared__",a=n[r]||i(r,{});t.exports=a})),lf=F(((e,t)=>{var n=hi(),i=m_();(t.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.29.1",mode:n?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.29.1/LICENSE",source:"https://github.com/zloirock/core-js"})})),xr=F(((e,t)=>{var n=Mi(),i=Object;t.exports=function(e){return i(n(e))}})),ar=F(((e,t)=>{var n=yt(),i=xr(),r=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(i(e),t)}})),cf=F(((e,t)=>{var n=yt(),i=0,r=Math.random(),a=n(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++i+r,36)}})),$n=F(((e,t)=>{var n=Ot(),i=lf(),r=ar(),a=cf(),s=of(),o=$3(),l=n.Symbol,h=i("wks"),c=o?l.for||l:l&&l.withoutSetter||a;t.exports=function(e){return r(h,e)||(h[e]=s&&r(l,e)?l[e]:c("Symbol."+e)),h[e]}})),q0=F(((e,t)=>{var n=Bn(),i=Yn(),r=Mh(),a=ec(),s=Q3(),o=$n(),l=TypeError,h=o("toPrimitive");t.exports=function(e,t){if(!i(e)||r(e))return e;var o,c=a(e,h);if(c){if(void 0===t&&(t="default"),o=n(c,e,t),!i(o)||r(o))return o;throw l("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}})),lu=F(((e,t)=>{var n=q0(),i=Mh();t.exports=function(e){var t=n(e,"string");return i(t)?t:t+""}})),W0=F(((e,t)=>{var n=Ot(),i=Yn(),r=n.document,a=i(r)&&i(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),n2=F(((e,t)=>{var n=on(),i=dt(),r=W0();t.exports=!n&&!i((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Ki=F((e=>{var t=on(),n=Bn(),i=G0(),r=Da(),a=Ni(),s=lu(),o=ar(),l=n2(),h=Object.getOwnPropertyDescriptor;e.f=t?h:function(e,t){if(e=a(e),t=s(t),l)try{return h(e,t)}catch(e){}if(o(e,t))return r(!n(i.f,e,t),e[t])}})),r2=F(((e,t)=>{var n=on(),i=dt();t.exports=n&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),Cn=F(((e,t)=>{var n=Yn(),i=String,r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not an object")}})),Yr=F((e=>{var t=on(),n=n2(),i=r2(),r=Cn(),a=lu(),s=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h="enumerable",c="configurable",u="writable";e.f=t?i?function(e,t,n){if(r(e),t=a(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&u in n&&!n[u]){var i=l(e,t);i&&i[u]&&(e[t]=n.value,n={configurable:c in n?n[c]:i[c],enumerable:h in n?n[h]:i[h],writable:!1})}return o(e,t,n)}:o:function(e,t,i){if(r(e),t=a(t),r(i),n)try{return o(e,t,i)}catch(e){}if("get"in i||"set"in i)throw s("Accessors not supported");return"value"in i&&(e[t]=i.value),e}})),cs=F(((e,t)=>{var n=on(),i=Yr(),r=Da();t.exports=n?function(e,t,n){return i.f(e,t,r(1,n))}:function(e,t,n){return e[t]=n,e}})),uf=F(((e,t)=>{var n=on(),i=ar(),r=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,s=i(r,"name"),o=s&&"something"===function(){}.name,l=s&&(!n||n&&a(r,"name").configurable);t.exports={EXISTS:s,PROPER:o,CONFIGURABLE:l}})),v_=F(((e,t)=>{var n=yt(),i=Xn(),r=m_(),a=n(Function.toString);i(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),h2=F(((e,t)=>{var n=Ot(),i=Xn(),r=n.WeakMap;t.exports=i(r)&&/native code/.test(String(r))})),j0=F(((e,t)=>{var n=lf(),i=cf(),r=n("keys");t.exports=function(e){return r[e]||(r[e]=i(e))}})),dm=F(((e,t)=>{t.exports={}})),Si=F(((e,t)=>{var n,i,r,a,s,o=h2(),l=Ot(),h=Yn(),c=cs(),u=ar(),d=m_(),p=j0(),f=dm(),m="Object already initialized",g=l.TypeError,v=l.WeakMap;o||d.state?((a=d.state||(d.state=new v)).get=a.get,a.has=a.has,a.set=a.set,n=function(e,t){if(a.has(e))throw g(m);return t.facade=e,a.set(e,t),t},i=function(e){return a.get(e)||{}},r=function(e){return a.has(e)}):(f[s=p("state")]=!0,n=function(e,t){if(u(e,s))throw g(m);return t.facade=e,c(e,s,t),t},i=function(e){return u(e,s)?e[s]:{}},r=function(e){return u(e,s)}),t.exports={set:n,get:i,has:r,enforce:function(e){return r(e)?i(e):n(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=i(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return n}}}})),__=F(((e,t)=>{var n=yt(),i=dt(),r=Xn(),a=ar(),s=on(),o=uf().CONFIGURABLE,l=v_(),h=Si(),c=h.enforce,u=h.get,d=String,p=Object.defineProperty,f=n("".slice),m=n("".replace),g=n([].join),v=s&&!i((function(){return 8!==p((function(){}),"length",{value:8}).length})),y=String(String).split("String"),x=t.exports=function(e,t,n){"Symbol("===f(d(t),0,7)&&(t="["+m(d(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!a(e,"name")||o&&e.name!==t)&&(s?p(e,"name",{value:t,configurable:!0}):e.name=t),v&&n&&a(n,"arity")&&e.length!==n.arity&&p(e,"length",{value:n.arity});try{n&&a(n,"constructor")&&n.constructor?s&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var i=c(e);return a(i,"source")||(i.source=g(y,"string"==typeof t?t:"")),e};Function.prototype.toString=x((function(){return r(this)&&u(this).source||l(this)}),"toString")})),ei=F(((e,t)=>{var n=Xn(),i=Yr(),r=__(),a=p_();t.exports=function(e,t,s,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:t;if(n(s)&&r(s,h,o),o.global)l?e[t]=s:a(t,s);else{try{o.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=s:i.f(e,t,{value:s,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}})),v2=F(((e,t)=>{var n=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?i:n)(t)}})),di=F(((e,t)=>{var n=v2();t.exports=function(e){var t=+e;return t!=t||0===t?0:n(t)}})),hl=F(((e,t)=>{var n=di(),i=Math.max,r=Math.min;t.exports=function(e,t){var a=n(e);return a<0?i(a+t,0):r(a,t)}})),ra=F(((e,t)=>{var n=di(),i=Math.min;t.exports=function(e){return e>0?i(n(e),9007199254740991):0}})),_r=F(((e,t)=>{var n=ra();t.exports=function(e){return n(e.length)}})),fm=F(((e,t)=>{var n=Ni(),i=hl(),r=_r(),a=function(e){return function(t,a,s){var o,l=n(t),h=r(l),c=i(s,h);if(e&&a!=a){for(;h>c;)if((o=l[c++])!=o)return!0}else for(;h>c;c++)if((e||c in l)&&l[c]===a)return e||c||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}})),y2=F(((e,t)=>{var n=yt(),i=ar(),r=Ni(),a=fm().indexOf,s=dm(),o=n([].push);t.exports=function(e,t){var n,l=r(e),h=0,c=[];for(n in l)!i(s,n)&&i(l,n)&&o(c,n);for(;t.length>h;)i(l,n=t[h++])&&(~a(c,n)||o(c,n));return c}})),T_=F(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),cu=F((e=>{var t=y2(),n=T_().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,n)}})),Y0=F((e=>{e.f=Object.getOwnPropertySymbols})),w_=F(((e,t)=>{var n=Xr(),i=yt(),r=cu(),a=Y0(),s=Cn(),o=i([].concat);t.exports=n("Reflect","ownKeys")||function(e){var t=r.f(s(e)),n=a.f;return n?o(t,n(e)):t}})),$0=F(((e,t)=>{var n=ar(),i=w_(),r=Ki(),a=Yr();t.exports=function(e,t,s){for(var o=i(t),l=a.f,h=r.f,c=0;c<o.length;c++){var u=o[c];!n(e,u)&&(!s||!n(s,u))&&l(e,u,h(t,u))}}})),pm=F(((e,t)=>{var n=dt(),i=Xn(),r=/#|\.prototype\./,a=function(e,t){var r=o[s(e)];return r==h||r!=l&&(i(t)?n(t):!!t)},s=a.normalize=function(e){return String(e).replace(r,".").toLowerCase()},o=a.data={},l=a.NATIVE="N",h=a.POLYFILL="P";t.exports=a})),we=F(((e,t)=>{var n=Ot(),i=Ki().f,r=cs(),a=ei(),s=p_(),o=$0(),l=pm();t.exports=function(e,t){var h,c,u,d,p,f=e.target,m=e.global,g=e.stat;if(h=m?n:g?n[f]||s(f,{}):(n[f]||{}).prototype)for(c in t){if(d=t[c],u=e.dontCallGetSet?(p=i(h,c))&&p.value:h[c],!l(m?c:f+(g?".":"#")+c,e.forced)&&void 0!==u){if(typeof d==typeof u)continue;o(d,u)}(e.sham||u&&u.sham)&&r(d,"sham",!0),a(h,c,d,e)}}})),M_=F(((e,t)=>{var n={};n[$n()("toStringTag")]="z",t.exports="[object z]"===String(n)})),dl=F(((e,t)=>{var n=M_(),i=Xn(),r=ls(),a=$n()("toStringTag"),s=Object,o="Arguments"==r(function(){return arguments}());t.exports=n?r:function(e){var t,n,l;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=s(e),a))?n:o?r(t):"Object"==(l=r(t))&&i(t.callee)?"Arguments":l}})),Hn=F(((e,t)=>{var n=dl(),i=String;t.exports=function(e){if("Symbol"===n(e))throw TypeError("Cannot convert a Symbol value to a string");return i(e)}})),mm=F(((e,t)=>{var n=y2(),i=T_();t.exports=Object.keys||function(e){return n(e,i)}})),R_=F((e=>{var t=on(),n=r2(),i=Yr(),r=Cn(),a=Ni(),s=mm();e.f=t&&!n?Object.defineProperties:function(e,t){r(e);for(var n,o=a(t),l=s(t),h=l.length,c=0;h>c;)i.f(e,n=l[c++],o[n]);return e}})),b2=F(((e,t)=>{var n=Xr();t.exports=n("document","documentElement")})),ia=F(((e,t)=>{var n,i=Cn(),r=R_(),a=T_(),s=dm(),o=b2(),l=W0(),h=j0(),c="prototype",u="script",d=h("IE_PROTO"),p=function(){},f=function(e){return"<"+u+">"+e+"</"+u+">"},m=function(e){e.write(f("")),e.close();var t=e.parentWindow.Object;return e=null,t},g=function(){try{n=new ActiveXObject("htmlfile")}catch(e){}g="undefined"!=typeof document?document.domain&&n?m(n):function(){var e,t=l("iframe"),n="java"+u+":";return t.style.display="none",o.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(f("document.F=Object")),e.close(),e.F}():m(n);for(var e=a.length;e--;)delete g[c][a[e]];return g()};s[d]=!0,t.exports=Object.create||function(e,t){var n;return null!==e?(p[c]=i(e),n=new p,p[c]=null,n[d]=e):n=g(),void 0===t?n:r.f(n,t)}})),tc=F(((e,t)=>{"use strict";var n=lu(),i=Yr(),r=Da();t.exports=function(e,t,a){var s=n(t);s in e?i.f(e,s,r(0,a)):e[s]=a}})),gm=F(((e,t)=>{var n=hl(),i=_r(),r=tc(),a=Array,s=Math.max;t.exports=function(e,t,o){for(var l=i(e),h=n(t,l),c=n(void 0===o?l:o,l),u=a(s(c-h,0)),d=0;h<c;h++,d++)r(u,d,e[h]);return u.length=d,u}})),P_=F(((e,t)=>{var n=ls(),i=Ni(),r=cu().f,a=gm(),s="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(e){return s&&"Window"==n(e)?function(e){try{return r(e)}catch(e){return a(s)}}(e):r(i(e))}})),Vi=F(((e,t)=>{var n=__(),i=Yr();t.exports=function(e,t,r){return r.get&&n(r.get,t,{getter:!0}),r.set&&n(r.set,t,{setter:!0}),i.f(e,t,r)}})),M2=F((e=>{var t=$n();e.f=t})),I_=F(((e,t)=>{var n=Ot();t.exports=n})),Ps=F(((e,t)=>{var n=I_(),i=ar(),r=M2(),a=Yr().f;t.exports=function(e){var t=n.Symbol||(n.Symbol={});i(t,e)||a(t,e,{value:r.f(e)})}})),S2=F(((e,t)=>{var n=Bn(),i=Xr(),r=$n(),a=ei();t.exports=function(){var e=i("Symbol"),t=e&&e.prototype,s=t&&t.valueOf,o=r("toPrimitive");t&&!t[o]&&a(t,o,(function(e){return n(s,this)}),{arity:1})}})),sa=F(((e,t)=>{var n=Yr().f,i=ar(),r=$n()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!i(e,r)&&n(e,r,{configurable:!0,value:t})}})),uu=F(((e,t)=>{var n=ls(),i=yt();t.exports=function(e){if("Function"===n(e))return i(e)}})),mo=F(((e,t)=>{var n=uu(),i=ui(),r=um(),a=n(n.bind);t.exports=function(e,t){return i(e),void 0===t?e:r?a(e,t):function(){return e.apply(t,arguments)}}})),hu=F(((e,t)=>{var n=ls();t.exports=Array.isArray||function(e){return"Array"==n(e)}})),df=F(((e,t)=>{var n=yt(),i=dt(),r=Xn(),a=dl(),s=Xr(),o=v_(),l=function(){},h=[],c=s("Reflect","construct"),u=/^\s*(?:class|function)\b/,d=n(u.exec),p=!u.exec(l),f=function(e){if(!r(e))return!1;try{return c(l,h,e),!0}catch(e){return!1}},m=function(e){if(!r(e))return!1;switch(a(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return p||!!d(u,o(e))}catch(e){return!0}};m.sham=!0,t.exports=!c||i((function(){var e;return f(f.call)||!f(Object)||!f((function(){e=!0}))||e}))?m:f})),k8=F(((e,t)=>{var n=hu(),i=df(),r=Yn(),a=$n()("species"),s=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,(i(t)&&(t===s||n(t.prototype))||r(t)&&null===(t=t[a]))&&(t=void 0)),void 0===t?s:t}})),vm=F(((e,t)=>{var n=k8();t.exports=function(e,t){return new(n(e))(0===t?0:t)}})),zi=F(((e,t)=>{var n=mo(),i=yt(),r=af(),a=xr(),s=_r(),o=vm(),l=i([].push),h=function(e){var t=1==e,i=2==e,h=3==e,c=4==e,u=6==e,d=7==e,p=5==e||u;return function(f,m,g,v){for(var y,x,_=a(f),b=r(_),M=n(m,g),w=s(b),S=0,E=v||o,T=t?E(f,w):i||d?E(f,0):void 0;w>S;S++)if((p||S in b)&&(x=M(y=b[S],S,_),e))if(t)T[S]=x;else if(x)switch(e){case 3:return!0;case 5:return y;case 6:return S;case 2:l(T,y)}else switch(e){case 4:return!1;case 7:l(T,y)}return u?-1:h||c?c:T}};t.exports={forEach:h(0),map:h(1),filter:h(2),some:h(3),every:h(4),find:h(5),findIndex:h(6),filterReject:h(7)}})),sG=F((()=>{"use strict";var e=we(),t=Ot(),n=Bn(),i=yt(),r=hi(),a=on(),s=of(),o=dt(),l=ar(),h=La(),c=Cn(),u=Ni(),d=lu(),p=Hn(),f=Da(),m=ia(),g=mm(),v=cu(),y=P_(),x=Y0(),_=Ki(),b=Yr(),M=R_(),w=G0(),S=ei(),E=Vi(),T=lf(),A=j0(),C=dm(),R=cf(),P=$n(),L=M2(),D=Ps(),I=S2(),O=sa(),U=Si(),N=zi().forEach,F=A("hidden"),k="Symbol",B="prototype",z=U.set,V=U.getterFor(k),H=Object[B],G=t.Symbol,j=G&&G[B],W=t.TypeError,X=t.QObject,q=_.f,Y=b.f,$=y.f,K=w.f,Z=i([].push),J=T("symbols"),Q=T("op-symbols"),ee=T("wks"),te=!X||!X[B]||!X[B].findChild,ne=a&&o((function(){return 7!=m(Y({},"a",{get:function(){return Y(this,"a",{value:7}).a}})).a}))?function(e,t,n){var i=q(H,t);i&&delete H[t],Y(e,t,n),i&&e!==H&&Y(H,t,i)}:Y,ie=function(e,t){var n=J[e]=m(j);return z(n,{type:k,tag:e,description:t}),a||(n.description=t),n},re=function(e,t,n){e===H&&re(Q,t,n),c(e);var i=d(t);return c(n),l(J,i)?(n.enumerable?(l(e,F)&&e[F][i]&&(e[F][i]=!1),n=m(n,{enumerable:f(0,!1)})):(l(e,F)||Y(e,F,f(1,{})),e[F][i]=!0),ne(e,i,n)):Y(e,i,n)},ae=function(e,t){c(e);var i=u(t),r=g(i).concat(he(i));return N(r,(function(t){(!a||n(se,i,t))&&re(e,t,i[t])})),e},se=function(e){var t=d(e),i=n(K,this,t);return!(this===H&&l(J,t)&&!l(Q,t))&&(!(i||!l(this,t)||!l(J,t)||l(this,F)&&this[F][t])||i)},oe=function(e,t){var n=u(e),i=d(t);if(n!==H||!l(J,i)||l(Q,i)){var r=q(n,i);return r&&l(J,i)&&!(l(n,F)&&n[F][i])&&(r.enumerable=!0),r}},le=function(e){var t=$(u(e)),n=[];return N(t,(function(e){!l(J,e)&&!l(C,e)&&Z(n,e)})),n},he=function(e){var t=e===H,n=$(t?Q:u(e)),i=[];return N(n,(function(e){l(J,e)&&(!t||l(H,e))&&Z(i,J[e])})),i};s||(S(j=(G=function(){if(h(j,this))throw W("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=R(e),i=function(e){this===H&&n(i,Q,e),l(this,F)&&l(this[F],t)&&(this[F][t]=!1),ne(this,t,f(1,e))};return a&&te&&ne(H,t,{configurable:!0,set:i}),ie(t,e)})[B],"toString",(function(){return V(this).tag})),S(G,"withoutSetter",(function(e){return ie(R(e),e)})),w.f=se,b.f=re,M.f=ae,_.f=oe,v.f=y.f=le,x.f=he,L.f=function(e){return ie(P(e),e)},a&&(E(j,"description",{configurable:!0,get:function(){return V(this).description}}),r||S(H,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:G}),N(g(ee),(function(e){D(e)})),e({target:k,stat:!0,forced:!s},{useSetter:function(){te=!0},useSimple:function(){te=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):ae(m(e),t)},defineProperty:re,defineProperties:ae,getOwnPropertyDescriptor:oe}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:le}),I(),O(G,k),C[F]=!0})),V2=F(((e,t)=>{var n=of();t.exports=n&&!!Symbol.for&&!!Symbol.keyFor})),lG=F((()=>{var e=we(),t=Xr(),n=ar(),i=Hn(),r=lf(),a=V2(),s=r("string-to-symbol-registry"),o=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{for:function(e){var r=i(e);if(n(s,r))return s[r];var a=t("Symbol")(r);return s[r]=a,o[a]=r,a}})})),uG=F((()=>{var e=we(),t=ar(),n=Mh(),i=Sh(),r=lf(),a=V2(),s=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{keyFor:function(e){if(!n(e))throw TypeError(i(e)+" is not a symbol");if(t(s,e))return s[e]}})})),Oa=F(((e,t)=>{var n=um(),i=Function.prototype,r=i.apply,a=i.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?a.bind(r):function(){return a.apply(r,arguments)})})),Ah=F(((e,t)=>{var n=yt();t.exports=n([].slice)})),EG=F(((e,t)=>{var n=yt(),i=hu(),r=Xn(),a=ls(),s=Hn(),o=n([].push);t.exports=function(e){if(r(e))return e;if(i(e)){for(var t=e.length,n=[],l=0;l<t;l++){var h=e[l];"string"==typeof h?o(n,h):("number"==typeof h||"Number"==a(h)||"String"==a(h))&&o(n,s(h))}var c=n.length,u=!0;return function(e,t){if(u)return u=!1,t;if(i(this))return t;for(var r=0;r<c;r++)if(n[r]===e)return t}}}})),G2=F((()=>{var e=we(),t=Xr(),n=Oa(),i=Bn(),r=yt(),a=dt(),s=Xn(),o=Mh(),l=Ah(),h=EG(),c=of(),u=String,d=t("JSON","stringify"),p=r(/./.exec),f=r("".charAt),m=r("".charCodeAt),g=r("".replace),v=r(1..toString),y=/[\uD800-\uDFFF]/g,x=/^[\uD800-\uDBFF]$/,_=/^[\uDC00-\uDFFF]$/,b=!c||a((function(){var e=t("Symbol")();return"[null]"!=d([e])||"{}"!=d({a:e})||"{}"!=d(Object(e))})),M=a((function(){return'"\\udf06\\ud834"'!==d("\udf06\ud834")||'"\\udead"'!==d("\udead")})),w=function(e,t){var r=l(arguments),a=h(t);if(s(a)||void 0!==e&&!o(e))return r[1]=function(e,t){if(s(a)&&(t=i(a,this,u(e),t)),!o(t))return t},n(d,null,r)},S=function(e,t,n){var i=f(n,t-1),r=f(n,t+1);return p(x,e)&&!p(_,r)||p(_,e)&&!p(x,i)?"\\u"+v(m(e,0),16):e};d&&e({target:"JSON",stat:!0,arity:3,forced:b||M},{stringify:function(e,t,i){var r=l(arguments),a=n(b?w:d,null,r);return M&&"string"==typeof a?g(a,y,S):a}})})),LG=F((()=>{var e=we(),t=of(),n=dt(),i=Y0(),r=xr();e({target:"Object",stat:!0,forced:!t||n((function(){i.f(1)}))},{getOwnPropertySymbols:function(e){var t=i.f;return t?t(r(e)):[]}})})),OG=F((()=>{sG(),lG(),uG(),G2(),LG()})),VG=F((()=>{"use strict";var e,t,n,i,r,a,s,o,l=we(),h=on(),c=Ot(),u=yt(),d=ar(),p=Xn(),f=La(),m=Hn(),g=Vi(),v=$0(),y=c.Symbol,x=y&&y.prototype;h&&p(y)&&(!("description"in x)||void 0!==y().description)&&(e={},v(t=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:m(arguments[0]),n=f(x,this)?new y(t):void 0===t?y():y(t);return""===t&&(e[n]=!0),n},y),t.prototype=x,x.constructor=t,n="Symbol(test)"==String(y("test")),i=u(x.valueOf),r=u(x.toString),a=/^Symbol\((.*)\)[^)]+$/,s=u("".replace),o=u("".slice),g(x,"description",{configurable:!0,get:function(){var t=i(this);if(d(e,t))return"";var l=r(t),h=n?o(l,7,-1):s(l,a,"$1");return""===h?void 0:h}}),l({global:!0,constructor:!0,forced:!0},{Symbol:t}))})),zG=F((()=>{Ps()("asyncIterator")})),GG=F((()=>{Ps()("hasInstance")})),qG=F((()=>{Ps()("isConcatSpreadable")})),WG=F((()=>{Ps()("iterator")})),jG=F((()=>{Ps()("match")})),XG=F((()=>{Ps()("matchAll")})),YG=F((()=>{Ps()("replace")})),$G=F((()=>{Ps()("search")})),ZG=F((()=>{Ps()("species")})),KG=F((()=>{Ps()("split")})),JG=F((()=>{var e=Ps(),t=S2();e("toPrimitive"),t()})),QG=F((()=>{var e=Xr(),t=Ps(),n=sa();t("toStringTag"),n(e("Symbol"),"Symbol")})),e7=F((()=>{Ps()("unscopables")})),n7=F(((e,t)=>{var n=yt(),i=ui();t.exports=function(e,t,r){try{return n(i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),W2=F(((e,t)=>{var n=Xn(),i=String,r=TypeError;t.exports=function(e){if("object"==typeof e||n(e))return e;throw r("Can't set "+i(e)+" as a prototype")}})),fl=F(((e,t)=>{var n=n7(),i=Cn(),r=W2();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=n(Object.prototype,"__proto__","set"))(a,[]),t=a instanceof Array}catch(e){}return function(n,a){return i(n),r(a),t?e(n,a):n.__proto__=a,n}}():void 0)})),j2=F(((e,t)=>{var n=Yr().f;t.exports=function(e,t,i){i in e||n(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})}})),gf=F(((e,t)=>{var n=Xn(),i=Yn(),r=fl();t.exports=function(e,t,a){var s,o;return r&&n(s=t.constructor)&&s!==a&&i(o=s.prototype)&&o!==a.prototype&&r(e,o),e}})),Em=F(((e,t)=>{var n=Hn();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}})),X2=F(((e,t)=>{var n=Yn(),i=cs();t.exports=function(e,t){n(t)&&"cause"in t&&i(e,"cause",t.cause)}})),H_=F(((e,t)=>{var n=yt(),i=Error,r=n("".replace),a=String(i("zxcasd").stack),s=/\n\s*at [^:]*:[^\n]*/,o=s.test(a);t.exports=function(e,t){if(o&&"string"==typeof e&&!i.prepareStackTrace)for(;t--;)e=r(e,s,"");return e}})),Y2=F(((e,t)=>{var n=dt(),i=Da();t.exports=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",i(1,7)),7!==e.stack)}))})),$2=F(((e,t)=>{var n=cs(),i=H_(),r=Y2(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):n(e,"stack",i(s,o)))}})),Z2=F(((e,t)=>{"use strict";var n=Xr(),i=ar(),r=cs(),a=La(),s=fl(),o=$0(),l=j2(),h=gf(),c=Em(),u=X2(),d=$2(),p=on(),f=hi();t.exports=function(e,t,m,g){var v="stackTraceLimit",y=g?2:1,x=e.split("."),_=x[x.length-1],b=n.apply(null,x);if(b){var M=b.prototype;if(!f&&i(M,"cause")&&delete M.cause,!m)return b;var w=n("Error"),S=t((function(e,t){var n=c(g?t:e,void 0),i=g?new b(e):new b;return void 0!==n&&r(i,"message",n),d(i,S,i.stack,2),this&&a(M,this)&&h(i,this,S),arguments.length>y&&u(i,arguments[y]),i}));if(S.prototype=M,"Error"!==_?s?s(S,w):o(S,w,{name:!0}):p&&v in b&&(l(S,b,v),l(S,b,"prepareStackTrace")),o(S,b),!f)try{M.name!==_&&r(M,"name",_),M.constructor=S}catch(e){}return S}}})),S7=F((()=>{var e=we(),t=Ot(),n=Oa(),i=Z2(),r="WebAssembly",a=t[r],s=7!==Error("e",{cause:7}).cause,o=function(t,n){var r={};r[t]=i(t,n,s),e({global:!0,constructor:!0,arity:1,forced:s},r)},l=function(t,n){if(a&&a[t]){var o={};o[t]=i(r+"."+t,n,s),e({target:r,stat:!0,constructor:!0,arity:1,forced:s},o)}};o("Error",(function(e){return function(t){return n(e,this,arguments)}})),o("EvalError",(function(e){return function(t){return n(e,this,arguments)}})),o("RangeError",(function(e){return function(t){return n(e,this,arguments)}})),o("ReferenceError",(function(e){return function(t){return n(e,this,arguments)}})),o("SyntaxError",(function(e){return function(t){return n(e,this,arguments)}})),o("TypeError",(function(e){return function(t){return n(e,this,arguments)}})),o("URIError",(function(e){return function(t){return n(e,this,arguments)}})),l("CompileError",(function(e){return function(t){return n(e,this,arguments)}})),l("LinkError",(function(e){return function(t){return n(e,this,arguments)}})),l("RuntimeError",(function(e){return function(t){return n(e,this,arguments)}}))})),Q2=F(((e,t)=>{"use strict";var n=on(),i=dt(),r=Cn(),a=ia(),s=Em(),o=Error.prototype.toString,l=i((function(){if(n){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==o.call(e))return!0}return"2: 1"!==o.call({message:1,name:2})||"Error"!==o.call({})}));t.exports=l?function(){var e=r(this),t=s(e.name,"Error"),n=s(e.message);return t?n?t+": "+n:t:n}:o})),I7=F((()=>{var e=ei(),t=Q2(),n=Error.prototype;n.toString!==t&&e(n,"toString",t)})),z_=F(((e,t)=>{var n=dt();t.exports=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),Na=F(((e,t)=>{var n=ar(),i=Xn(),r=xr(),a=j0(),s=z_(),o=a("IE_PROTO"),l=Object,h=l.prototype;t.exports=s?l.getPrototypeOf:function(e){var t=r(e);if(n(t,o))return t[o];var a=t.constructor;return i(a)&&t instanceof a?a.prototype:t instanceof l?h:null}})),bm=F(((e,t)=>{t.exports={}})),G_=F(((e,t)=>{var n=$n(),i=bm(),r=n("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||a[r]===e)}})),_m=F(((e,t)=>{var n=dl(),i=ec(),r=Cs(),a=bm(),s=$n()("iterator");t.exports=function(e){if(!r(e))return i(e,s)||i(e,"@@iterator")||a[n(e)]}})),i1=F(((e,t)=>{var n=Bn(),i=ui(),r=Cn(),a=Sh(),s=_m(),o=TypeError;t.exports=function(e,t){var l=arguments.length<2?s(e):t;if(i(l))return r(n(l,e));throw o(a(e)+" is not iterable")}})),tP=F(((e,t)=>{var n=Bn(),i=Cn(),r=ec();t.exports=function(e,t,a){var s,o;i(e);try{if(!(s=r(e,"return"))){if("throw"===t)throw a;return a}s=n(s,e)}catch(e){o=!0,s=e}if("throw"===t)throw a;if(o)throw s;return i(s),a}})),pl=F(((e,t)=>{var n=mo(),i=Bn(),r=Cn(),a=Sh(),s=G_(),o=_r(),l=La(),h=i1(),c=_m(),u=tP(),d=TypeError,p=function(e,t){this.stopped=e,this.result=t},f=p.prototype;t.exports=function(e,t,m){var g,v,y,x,_,b,M,w=m&&m.that,S=!(!m||!m.AS_ENTRIES),E=!(!m||!m.IS_RECORD),T=!(!m||!m.IS_ITERATOR),A=!(!m||!m.INTERRUPTED),C=n(t,w),R=function(e){return g&&u(g,"normal",e),new p(!0,e)},P=function(e){return S?(r(e),A?C(e[0],e[1],R):C(e[0],e[1])):A?C(e,R):C(e)};if(E)g=e.iterator;else if(T)g=e;else{if(!(v=c(e)))throw d(a(e)+" is not iterable");if(s(v)){for(y=0,x=o(e);x>y;y++)if((_=P(e[y]))&&l(f,_))return _;return new p(!1)}g=h(e,v)}for(b=E?e.next:g.next;!(M=i(b,g)).done;){try{_=P(M.value)}catch(e){u(g,"throw",e)}if("object"==typeof _&&_&&l(f,_))return _}return new p(!1)}})),X7=F((()=>{"use strict";var e=we(),t=La(),n=Na(),i=fl(),r=$0(),a=ia(),s=cs(),o=Da(),l=X2(),h=$2(),c=pl(),u=Em(),d=$n()("toStringTag"),p=Error,f=[].push,m=function(e,r){var o,v=t(g,this);i?o=i(p(),v?n(this):g):(o=v?this:a(g),s(o,d,"Error")),void 0!==r&&s(o,"message",u(r)),h(o,m,o.stack,1),arguments.length>2&&l(o,arguments[2]);var y=[];return c(e,f,{that:y}),s(o,"errors",y),o};i?i(m,p):r(m,p,{name:!0});var g=m.prototype=a(p.prototype,{constructor:o(1,m),message:o(1,""),name:o(1,"AggregateError")});e({global:!0,constructor:!0,arity:2},{AggregateError:m})})),Y7=F((()=>{X7()})),J7=F((()=>{var e=we(),t=Xr(),n=Oa(),i=dt(),r=Z2(),a="AggregateError",s=t(a),o=!i((function(){return 1!==s([1]).errors[0]}))&&i((function(){return 7!==s([1],a,{cause:7}).cause}));e({global:!0,constructor:!0,arity:2,forced:o},{AggregateError:r(a,(function(e){return function(t,i){return n(e,this,arguments)}}),o,!0)})})),Is=F(((e,t)=>{var n=$n(),i=ia(),r=Yr().f,a=n("unscopables"),s=Array.prototype;null==s[a]&&r(s,a,{configurable:!0,value:i(null)}),t.exports=function(e){s[a][e]=!0}})),e9=F((()=>{"use strict";var e=we(),t=xr(),n=_r(),i=di(),r=Is();e({target:"Array",proto:!0},{at:function(e){var r=t(this),a=n(r),s=i(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}}),r("at")})),xf=F(((e,t)=>{var n=TypeError;t.exports=function(e){if(e>9007199254740991)throw n("Maximum allowed index exceeded");return e}})),wm=F(((e,t)=>{var n=dt(),i=$n(),r=Ql(),a=i("species");t.exports=function(e){return r>=51||!n((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}})),a9=F((()=>{"use strict";var e=we(),t=dt(),n=hu(),i=Yn(),r=xr(),a=_r(),s=xf(),o=tc(),l=vm(),h=wm(),c=$n(),u=Ql(),d=c("isConcatSpreadable"),p=u>=51||!t((function(){var e=[];return e[d]=!1,e.concat()[0]!==e})),f=function(e){if(!i(e))return!1;var t=e[d];return void 0!==t?!!t:n(e)};e({target:"Array",proto:!0,arity:1,forced:!p||!h("concat")},{concat:function(e){var t,n,i,h,c,u=r(this),d=l(u,0),p=0;for(t=-1,i=arguments.length;t<i;t++)if(f(c=-1===t?u:arguments[t]))for(h=a(c),s(p+h),n=0;n<h;n++,p++)n in c&&o(d,p,c[n]);else s(p+1),o(d,p++,c);return d.length=p,d}})})),s1=F(((e,t)=>{"use strict";var n=Sh(),i=TypeError;t.exports=function(e,t){if(!delete e[t])throw i("Cannot delete property "+n(t)+" of "+n(e))}})),cP=F(((e,t)=>{"use strict";var n=xr(),i=hl(),r=_r(),a=s1(),s=Math.min;t.exports=[].copyWithin||function(e,t){var o=n(this),l=r(o),h=i(e,l),c=i(t,l),u=arguments.length>2?arguments[2]:void 0,d=s((void 0===u?l:i(u,l))-c,l-h),p=1;for(c<h&&h<c+d&&(p=-1,c+=d-1,h+=d-1);d-- >0;)c in o?o[h]=o[c]:a(o,h),h+=p,c+=p;return o}})),u9=F((()=>{var e=we(),t=cP(),n=Is();e({target:"Array",proto:!0},{copyWithin:t}),n("copyWithin")})),rc=F(((e,t)=>{"use strict";var n=dt();t.exports=function(e,t){var i=[][e];return!!i&&n((function(){i.call(null,t||function(){return 1},1)}))}})),d9=F((()=>{"use strict";var e=we(),t=zi().every;e({target:"Array",proto:!0,forced:!rc()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),X_=F(((e,t)=>{"use strict";var n=xr(),i=hl(),r=_r();t.exports=function(e){for(var t=n(this),a=r(t),s=arguments.length,o=i(s>1?arguments[1]:void 0,a),l=s>2?arguments[2]:void 0,h=void 0===l?a:i(l,a);h>o;)t[o++]=e;return t}})),m9=F((()=>{var e=we(),t=X_(),n=Is();e({target:"Array",proto:!0},{fill:t}),n("fill")})),g9=F((()=>{"use strict";var e=we(),t=zi().filter;e({target:"Array",proto:!0,forced:!wm()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),x9=F((()=>{"use strict";var e=we(),t=zi().find,n=Is(),i="find",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{find:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),E9=F((()=>{"use strict";var e=we(),t=zi().findIndex,n=Is(),i="findIndex",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{findIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),a1=F(((e,t)=>{var n=mo(),i=af(),r=xr(),a=_r(),s=function(e){var t=1==e;return function(s,o,l){for(var h,c=r(s),u=i(c),d=n(o,l),p=a(u);p-- >0;)if(d(h=u[p],p,c))switch(e){case 0:return h;case 1:return p}return t?-1:void 0}};t.exports={findLast:s(0),findLastIndex:s(1)}})),T9=F((()=>{"use strict";var e=we(),t=a1().findLast,n=Is();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLast")})),w9=F((()=>{"use strict";var e=we(),t=a1().findLastIndex,n=Is();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLastIndex")})),dP=F(((e,t)=>{"use strict";var n=hu(),i=_r(),r=xf(),a=mo(),s=function(e,t,o,l,h,c,u,d){for(var p,f,m=h,g=0,v=!!u&&a(u,d);g<l;)g in o&&(p=v?v(o[g],g,t):o[g],c>0&&n(p)?(f=i(p),m=s(e,t,p,f,m,c-1)-1):(r(m+1),e[m]=p),m++),g++;return m};t.exports=s})),R9=F((()=>{"use strict";var e=we(),t=dP(),n=xr(),i=_r(),r=di(),a=vm();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,s=n(this),o=i(s),l=a(s,0);return l.length=t(l,s,s,o,0,void 0===e?1:r(e)),l}})})),A9=F((()=>{"use strict";var e=we(),t=dP(),n=ui(),i=xr(),r=_r(),a=vm();e({target:"Array",proto:!0},{flatMap:function(e){var s,o=i(this),l=r(o);return n(e),(s=a(o,0)).length=t(s,o,o,l,0,1,e,arguments.length>1?arguments[1]:void 0),s}})})),fP=F(((e,t)=>{"use strict";var n=zi().forEach,i=rc()("forEach");t.exports=i?[].forEach:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})),I9=F((()=>{"use strict";var e=we(),t=fP();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),L9=F(((e,t)=>{var n=Cn(),i=tP();t.exports=function(e,t,r,a){try{return a?t(n(r)[0],r[1]):t(r)}catch(t){i(e,"throw",t)}}})),pP=F(((e,t)=>{"use strict";var n=mo(),i=Bn(),r=xr(),a=L9(),s=G_(),o=df(),l=_r(),h=tc(),c=i1(),u=_m(),d=Array;t.exports=function(e){var t=r(e),p=o(this),f=arguments.length,m=f>1?arguments[1]:void 0,g=void 0!==m;g&&(m=n(m,f>2?arguments[2]:void 0));var v,y,x,_,b,M,w=u(t),S=0;if(!w||this===d&&s(w))for(v=l(t),y=p?new this(v):d(v);v>S;S++)M=g?m(t[S],S):t[S],h(y,S,M);else for(b=(_=c(t,w)).next,y=p?new this:[];!(x=i(b,_)).done;S++)M=g?a(_,m,[x.value,S],!0):x.value,h(y,S,M);return y.length=S,y}})),o1=F(((e,t)=>{var n,i,r=$n()("iterator"),a=!1;try{n=0,(i={next:function(){return{done:!!n++}},return:function(){a=!0}})[r]=function(){return this},Array.from(i,(function(){throw 2}))}catch(e){}t.exports=function(e,t){if(!t&&!a)return!1;var n=!1;try{var i={};i[r]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(e){}return n}})),V9=F((()=>{var e=we(),t=pP();e({target:"Array",stat:!0,forced:!o1()((function(e){Array.from(e)}))},{from:t})})),z9=F((()=>{"use strict";var e=we(),t=fm().includes,n=dt(),i=Is();e({target:"Array",proto:!0,forced:n((function(){return!Array(1).includes()}))},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("includes")})),q9=F((()=>{"use strict";var e=we(),t=uu(),n=fm().indexOf,i=rc(),r=t([].indexOf),a=!!r&&1/r([1],1,-0)<0;e({target:"Array",proto:!0,forced:a||!i("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return a?r(this,e,t)||0:n(this,e,t)}})})),W9=F((()=>{we()({target:"Array",stat:!0},{isArray:hu()})})),EP=F(((e,t)=>{"use strict";var n,i,r,a=dt(),s=Xn(),o=Yn(),l=ia(),h=Na(),c=ei(),u=$n(),d=hi(),p=u("iterator"),f=!1;[].keys&&("next"in(r=[].keys())?(i=h(h(r)))!==Object.prototype&&(n=i):f=!0),!o(n)||a((function(){var e={};return n[p].call(e)!==e}))?n={}:d&&(n=l(n)),s(n[p])||c(n,p,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:f}})),Y_=F(((e,t)=>{"use strict";var n=EP().IteratorPrototype,i=ia(),r=Da(),a=sa(),s=bm(),o=function(){return this};t.exports=function(e,t,l,h){var c=t+" Iterator";return e.prototype=i(n,{next:r(+!h,l)}),a(e,c,!1,!0),s[c]=o,e}})),K_=F(((e,t)=>{"use strict";var n=we(),i=Bn(),r=hi(),a=uf(),s=Xn(),o=Y_(),l=Na(),h=fl(),c=sa(),u=cs(),d=ei(),p=$n(),f=bm(),m=EP(),g=a.PROPER,v=a.CONFIGURABLE,y=m.IteratorPrototype,x=m.BUGGY_SAFARI_ITERATORS,_=p("iterator"),b="keys",M="values",w="entries",S=function(){return this};t.exports=function(e,t,a,p,m,E,T){o(a,t,p);var A,C,R,P=function(e){if(e===m&&U)return U;if(!x&&e in I)return I[e];switch(e){case b:case M:case w:return function(){return new a(this,e)}}return function(){return new a(this)}},L=t+" Iterator",D=!1,I=e.prototype,O=I[_]||I["@@iterator"]||m&&I[m],U=!x&&O||P(m),N="Array"==t&&I.entries||O;if(N&&(A=l(N.call(new e)))!==Object.prototype&&A.next&&(!r&&l(A)!==y&&(h?h(A,y):s(A[_])||d(A,_,S)),c(A,L,!0,!0),r&&(f[L]=S)),g&&m==M&&O&&O.name!==M&&(!r&&v?u(I,"name",M):(D=!0,U=function(){return i(O,this)})),m)if(C={values:P(M),keys:E?U:P(b),entries:P(w)},T)for(R in C)(x||D||!(R in I))&&d(I,R,C[R]);else n({target:t,proto:!0,forced:x||D},C);return(!r||T)&&I[_]!==U&&d(I,_,U,{name:m}),f[t]=U,C}})),u1=F(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),h1=F(((e,t)=>{"use strict";var n=Ni(),i=Is(),r=bm(),a=Si(),s=Yr().f,o=K_(),l=u1(),h=hi(),c=on(),u="Array Iterator",d=a.set,p=a.getterFor(u);t.exports=o(Array,"Array",(function(e,t){d(this,{type:u,target:n(e),index:0,kind:t})}),(function(){var e=p(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,l(void 0,!0)):l("keys"==n?i:"values"==n?t[i]:[i,t[i]],!1)}),"values");var f=r.Arguments=r.Array;if(i("keys"),i("values"),i("entries"),!h&&c&&"values"!==f.name)try{s(f,"name",{value:"values"})}catch(e){}})),dq=F((()=>{"use strict";var e=we(),t=yt(),n=af(),i=Ni(),r=rc(),a=t([].join);e({target:"Array",proto:!0,forced:n!=Object||!r("join",",")},{join:function(e){return a(i(this),void 0===e?",":e)}})})),wP=F(((e,t)=>{"use strict";var n=Oa(),i=Ni(),r=di(),a=_r(),s=rc(),o=Math.min,l=[].lastIndexOf,h=!!l&&1/[1].lastIndexOf(1,-0)<0,c=s("lastIndexOf"),u=h||!c;t.exports=u?function(e){if(h)return n(l,this,arguments)||0;var t=i(this),s=a(t),c=s-1;for(arguments.length>1&&(c=o(c,r(arguments[1]))),c<0&&(c=s+c);c>=0;c--)if(c in t&&t[c]===e)return c||0;return-1}:l})),gq=F((()=>{var e=we(),t=wP();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),vq=F((()=>{"use strict";var e=we(),t=zi().map;e({target:"Array",proto:!0,forced:!wm()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),yq=F((()=>{"use strict";var e=we(),t=dt(),n=df(),i=tc(),r=Array;e({target:"Array",stat:!0,forced:t((function(){function e(){}return!(r.of.call(e)instanceof e)}))},{of:function(){for(var e=0,t=arguments.length,a=new(n(this)?this:r)(t);t>e;)i(a,e,arguments[e++]);return a.length=t,a}})})),Q_=F(((e,t)=>{"use strict";var n=on(),i=hu(),r=TypeError,a=Object.getOwnPropertyDescriptor,s=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();t.exports=s?function(e,t){if(i(e)&&!a(e,"length").writable)throw r("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}})),bq=F((()=>{"use strict";var e=we(),t=xr(),n=_r(),i=Q_(),r=xf();e({target:"Array",proto:!0,arity:1,forced:dt()((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var a=t(this),s=n(a),o=arguments.length;r(s+o);for(var l=0;l<o;l++)a[s]=arguments[l],s++;return i(a,s),s}})})),d1=F(((e,t)=>{var n=ui(),i=xr(),r=af(),a=_r(),s=TypeError,o=function(e){return function(t,o,l,h){n(o);var c=i(t),u=r(c),d=a(c),p=e?d-1:0,f=e?-1:1;if(l<2)for(;;){if(p in u){h=u[p],p+=f;break}if(p+=f,e?p<0:d<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:d>p;p+=f)p in u&&(h=o(h,u[p],p,c));return h}};t.exports={left:o(!1),right:o(!0)}})),ic=F(((e,t)=>{var n=ls();t.exports="undefined"!=typeof process&&"process"==n(process)})),Sq=F((()=>{"use strict";var e=we(),t=d1().left,n=rc(),i=Ql();e({target:"Array",proto:!0,forced:!ic()&&i>79&&i<83||!n("reduce")},{reduce:function(e){var n=arguments.length;return t(this,e,n,n>1?arguments[1]:void 0)}})})),Aq=F((()=>{"use strict";var e=we(),t=d1().right,n=rc(),i=Ql();e({target:"Array",proto:!0,forced:!ic()&&i>79&&i<83||!n("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),Pq=F((()=>{"use strict";var e=we(),t=yt(),n=hu(),i=t([].reverse),r=[1,2];e({target:"Array",proto:!0,forced:String(r)===String(r.reverse())},{reverse:function(){return n(this)&&(this.length=this.length),i(this)}})})),Lq=F((()=>{"use strict";var e=we(),t=hu(),n=df(),i=Yn(),r=hl(),a=_r(),s=Ni(),o=tc(),l=$n(),h=wm(),c=Ah(),u=h("slice"),d=l("species"),p=Array,f=Math.max;e({target:"Array",proto:!0,forced:!u},{slice:function(e,l){var h,u,m,g=s(this),v=a(g),y=r(e,v),x=r(void 0===l?v:l,v);if(t(g)&&(h=g.constructor,(n(h)&&(h===p||t(h.prototype))||i(h)&&null===(h=h[d]))&&(h=void 0),h===p||void 0===h))return c(g,y,x);for(u=new(void 0===h?p:h)(f(x-y,0)),m=0;y<x;y++,m++)y in g&&o(u,m,g[y]);return u.length=m,u}})})),Oq=F((()=>{"use strict";var e=we(),t=zi().some;e({target:"Array",proto:!0,forced:!rc()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),eT=F(((e,t)=>{var n=gm(),i=Math.floor,r=function(e,t){var o=e.length,l=i(o/2);return o<8?a(e,t):s(e,r(n(e,0,l),t),r(n(e,l),t),t)},a=function(e,t){for(var n,i,r=e.length,a=1;a<r;){for(i=a,n=e[a];i&&t(e[i-1],n)>0;)e[i]=e[--i];i!==a++&&(e[i]=n)}return e},s=function(e,t,n,i){for(var r=t.length,a=n.length,s=0,o=0;s<r||o<a;)e[s+o]=s<r&&o<a?i(t[s],n[o])<=0?t[s++]:n[o++]:s<r?t[s++]:n[o++];return e};t.exports=r})),RP=F(((e,t)=>{var n=Jl().match(/firefox\/(\d+)/i);t.exports=!!n&&+n[1]})),AP=F(((e,t)=>{var n=Jl();t.exports=/MSIE|Trident/.test(n)})),tT=F(((e,t)=>{var n=Jl().match(/AppleWebKit\/(\d+)\./);t.exports=!!n&&+n[1]})),Zq=F((()=>{"use strict";var e=we(),t=yt(),n=ui(),i=xr(),r=_r(),a=s1(),s=Hn(),o=dt(),l=eT(),h=rc(),c=RP(),u=AP(),d=Ql(),p=tT(),f=[],m=t(f.sort),g=t(f.push),v=o((function(){f.sort(void 0)})),y=o((function(){f.sort(null)})),x=h("sort"),_=!o((function(){if(d)return d<70;if(!(c&&c>3)){if(u)return!0;if(p)return p<603;var e,t,n,i,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)f.push({k:t+i,v:n})}for(f.sort((function(e,t){return t.v-e.v})),i=0;i<f.length;i++)t=f[i].k.charAt(0),r.charAt(r.length-1)!==t&&(r+=t);return"DGBEFHACIJK"!==r}}));e({target:"Array",proto:!0,forced:v||!y||!x||!_},{sort:function(e){void 0!==e&&n(e);var t=i(this);if(_)return void 0===e?m(t):m(t,e);var o,h,c=[],u=r(t);for(h=0;h<u;h++)h in t&&g(c,t[h]);for(l(c,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:s(t)>s(n)?1:-1}}(e)),o=r(c),h=0;h<o;)t[h]=c[h++];for(;h<u;)a(t,h++);return t}})})),yf=F(((e,t)=>{"use strict";var n=Xr(),i=Vi(),r=$n(),a=on(),s=r("species");t.exports=function(e){var t=n(e);a&&t&&!t[s]&&i(t,s,{configurable:!0,get:function(){return this}})}})),Qq=F((()=>{yf()("Array")})),eW=F((()=>{"use strict";var e=we(),t=xr(),n=hl(),i=di(),r=_r(),a=Q_(),s=xf(),o=vm(),l=tc(),h=s1(),c=wm()("splice"),u=Math.max,d=Math.min;e({target:"Array",proto:!0,forced:!c},{splice:function(e,c){var p,f,m,g,v,y,x=t(this),_=r(x),b=n(e,_),M=arguments.length;for(0===M?p=f=0:1===M?(p=0,f=_-b):(p=M-2,f=d(u(i(c),0),_-b)),s(_+p-f),m=o(x,f),g=0;g<f;g++)(v=b+g)in x&&l(m,g,x[v]);if(m.length=f,p<f){for(g=b;g<_-f;g++)y=g+p,(v=g+f)in x?x[y]=x[v]:h(x,y);for(g=_;g>_-f+p;g--)h(x,g-1)}else if(p>f)for(g=_-f;g>b;g--)y=g+p-1,(v=g+f-1)in x?x[y]=x[v]:h(x,y);for(g=0;g<p;g++)x[g+b]=arguments[g+2];return a(x,_-f+p),m}})})),IP=F(((e,t)=>{var n=_r();t.exports=function(e,t){for(var i=n(e),r=new t(i),a=0;a<i;a++)r[a]=e[i-a-1];return r}})),nW=F((()=>{"use strict";var e=we(),t=IP(),n=Ni(),i=Is(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(n(this),r)}}),i("toReversed")})),nT=F(((e,t)=>{var n=_r();t.exports=function(e,t){for(var i=0,r=n(t),a=new e(r);r>i;)a[i]=t[i++];return a}})),sW=F(((e,t)=>{var n=Ot();t.exports=function(e){return n[e].prototype}})),aW=F((()=>{"use strict";var e=we(),t=yt(),n=ui(),i=Ni(),r=nT(),a=sW(),s=Is(),o=Array,l=t(a("Array").sort);e({target:"Array",proto:!0},{toSorted:function(e){void 0!==e&&n(e);var t=i(this),a=r(o,t);return l(a,e)}}),s("toSorted")})),oW=F((()=>{"use strict";var e=we(),t=Is(),n=xf(),i=_r(),r=hl(),a=Ni(),s=di(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var c,u,d,p,f=a(this),m=i(f),g=r(e,m),v=arguments.length,y=0;for(0===v?c=u=0:1===v?(c=0,u=m-g):(c=v-2,u=h(l(s(t),0),m-g)),d=n(m+c-u),p=o(d);y<g;y++)p[y]=f[y];for(;y<g+c;y++)p[y]=arguments[y-g+2];for(;y<d;y++)p[y]=f[y+u-c];return p}}),t("toSpliced")})),lW=F((()=>{Is()("flat")})),cW=F((()=>{Is()("flatMap")})),uW=F((()=>{"use strict";var e=we(),t=xr(),n=_r(),i=Q_(),r=s1(),a=xf();e({target:"Array",proto:!0,arity:1,forced:1!==[].unshift(0)||!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(e){return e instanceof TypeError}}()},{unshift:function(e){var s=t(this),o=n(s),l=arguments.length;if(l){a(o+l);for(var h=o;h--;){var c=h+l;h in s?s[c]=s[h]:r(s,c)}for(var u=0;u<l;u++)s[u]=arguments[u]}return i(s,o+l)}})})),DP=F(((e,t)=>{var n=_r(),i=di(),r=RangeError;t.exports=function(e,t,a,s){var o=n(e),l=i(a),h=l<0?o+l:l;if(h>=o||h<0)throw r("Incorrect index");for(var c=new t(o),u=0;u<o;u++)c[u]=u===h?s:e[u];return c}})),dW=F((()=>{"use strict";var e=we(),t=DP(),n=Ni(),i=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(n(this),i,e,r)}})})),rT=F(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),Mm=F(((e,t)=>{var n=ei();t.exports=function(e,t,i){for(var r in t)n(e,r,t[r],i);return e}})),ml=F(((e,t)=>{var n=La(),i=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw i("Incorrect invocation")}})),LP=F(((e,t)=>{var n=di(),i=ra(),r=RangeError;t.exports=function(e){if(void 0===e)return 0;var t=n(e),a=i(t);if(t!==a)throw r("Wrong length or index");return a}})),xW=F(((e,t)=>{var n=Array,i=Math.abs,r=Math.pow,a=Math.floor,s=Math.log,o=Math.LN2;t.exports={pack:function(e,t,l){var h,c,u,d=n(l),p=8*l-t-1,f=(1<<p)-1,m=f>>1,g=23===t?r(2,-24)-r(2,-77):0,v=e<0||0===e&&1/e<0?1:0,y=0;for((e=i(e))!=e||e===1/0?(c=e!=e?1:0,h=f):(h=a(s(e)/o),e*(u=r(2,-h))<1&&(h--,u*=2),(e+=h+m>=1?g/u:g*r(2,1-m))*u>=2&&(h++,u/=2),h+m>=f?(c=0,h=f):h+m>=1?(c=(e*u-1)*r(2,t),h+=m):(c=e*r(2,m-1)*r(2,t),h=0));t>=8;)d[y++]=255&c,c/=256,t-=8;for(h=h<<t|c,p+=t;p>0;)d[y++]=255&h,h/=256,p-=8;return d[--y]|=128*v,d},unpack:function(e,t){var n,i=e.length,a=8*i-t-1,s=(1<<a)-1,o=s>>1,l=a-7,h=i-1,c=e[h--],u=127&c;for(c>>=7;l>0;)u=256*u+e[h--],l-=8;for(n=u&(1<<-l)-1,u>>=-l,l+=t;l>0;)n=256*n+e[h--],l-=8;if(0===u)u=1-o;else{if(u===s)return n?NaN:c?-1/0:1/0;n+=r(2,t),u-=o}return(c?-1:1)*n*r(2,u-t)}}})),m1=F(((e,t)=>{"use strict";var n,i,r,a,s,o,l=Ot(),h=yt(),c=on(),u=rT(),d=uf(),p=cs(),f=Vi(),m=Mm(),g=dt(),v=ml(),y=di(),x=ra(),_=LP(),b=xW(),M=Na(),w=fl(),S=cu().f,E=X_(),T=gm(),A=sa(),C=Si(),R=d.PROPER,P=d.CONFIGURABLE,L="ArrayBuffer",D="DataView",I="prototype",O="Wrong index",U=C.getterFor(L),N=C.getterFor(D),F=C.set,k=l[L],B=k,z=B&&B[I],V=l[D],H=V&&V[I],G=Object.prototype,j=l.Array,W=l.RangeError,X=h(E),q=h([].reverse),Y=b.pack,$=b.unpack,K=function(e){return[255&e]},Z=function(e){return[255&e,e>>8&255]},J=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Q=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ee=function(e){return Y(e,23,4)},te=function(e){return Y(e,52,8)},ne=function(e,t,n){f(e[I],t,{configurable:!0,get:function(){return n(this)[t]}})},ie=function(e,t,n,i){var r=_(n),a=N(e);if(r+t>a.byteLength)throw W(O);var s=a.bytes,o=r+a.byteOffset,l=T(s,o,o+t);return i?l:q(l)},re=function(e,t,n,i,r,a){var s=_(n),o=N(e);if(s+t>o.byteLength)throw W(O);for(var l=o.bytes,h=s+o.byteOffset,c=i(+r),u=0;u<t;u++)l[h+u]=c[a?u:t-u-1]};if(u){if(n=R&&k.name!==L,g((function(){k(1)}))&&g((function(){new k(-1)}))&&!g((function(){return new k,new k(1.5),new k(NaN),1!=k.length||n&&!P})))n&&P&&p(k,"name",L);else{for((B=function(e){return v(this,z),new k(_(e))})[I]=z,i=S(k),r=0;i.length>r;)(a=i[r++])in B||p(B,a,k[a]);z.constructor=B}w&&M(H)!==G&&w(H,G),s=new V(new B(2)),o=h(H.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(H,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else z=(B=function(e){v(this,z);var t=_(e);F(this,{type:L,bytes:X(j(t),0),byteLength:t}),c||(this.byteLength=t,this.detached=!1)})[I],H=(V=function(e,t,n){v(this,H),v(e,z);var i=U(e),r=i.byteLength,a=y(t);if(a<0||a>r)throw W("Wrong offset");if(a+(n=void 0===n?r-a:x(n))>r)throw W("Wrong length");F(this,{type:D,buffer:e,byteLength:n,byteOffset:a,bytes:i.bytes}),c||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[I],c&&(ne(B,"byteLength",U),ne(V,"buffer",N),ne(V,"byteLength",N),ne(V,"byteOffset",N)),m(H,{getInt8:function(e){return ie(this,1,e)[0]<<24>>24},getUint8:function(e){return ie(this,1,e)[0]},getInt16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return $(ie(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return $(ie(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){re(this,1,e,K,t)},setUint8:function(e,t){re(this,1,e,K,t)},setInt16:function(e,t){re(this,2,e,Z,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){re(this,2,e,Z,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){re(this,4,e,J,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){re(this,4,e,J,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2?arguments[2]:void 0)}});A(B,L),A(V,D),t.exports={ArrayBuffer:B,DataView:V}})),FW=F((()=>{"use strict";var e=we(),t=Ot(),n=m1(),i=yf(),r="ArrayBuffer",a=n[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),i(r)})),kn=F(((e,t)=>{"use strict";var n,i,r,a=rT(),s=on(),o=Ot(),l=Xn(),h=Yn(),c=ar(),u=dl(),d=Sh(),p=cs(),f=ei(),m=Vi(),g=La(),v=Na(),y=fl(),x=$n(),_=cf(),b=Si(),M=b.enforce,w=b.get,S=o.Int8Array,E=S&&S.prototype,T=o.Uint8ClampedArray,A=T&&T.prototype,C=S&&v(S),R=E&&v(E),P=Object.prototype,L=o.TypeError,D=x("toStringTag"),I=_("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",U=a&&!!y&&"Opera"!==u(o.opera),N=!1,F={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},k={BigInt64Array:8,BigUint64Array:8},B=function(e){var t=v(e);if(h(t)){var n=w(t);return n&&c(n,O)?n[O]:B(t)}},z=function(e){if(!h(e))return!1;var t=u(e);return c(F,t)||c(k,t)};for(n in F)(r=(i=o[n])&&i.prototype)?M(r)[O]=i:U=!1;for(n in k)(r=(i=o[n])&&i.prototype)&&(M(r)[O]=i);if((!U||!l(C)||C===Function.prototype)&&(C=function(){throw L("Incorrect invocation")},U))for(n in F)o[n]&&y(o[n],C);if((!U||!R||R===P)&&(R=C.prototype,U))for(n in F)o[n]&&y(o[n].prototype,R);if(U&&v(A)!==R&&y(A,R),s&&!c(R,D))for(n in N=!0,m(R,D,{configurable:!0,get:function(){return h(this)?this[I]:void 0}}),F)o[n]&&p(o[n],I,n);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:U,TYPED_ARRAY_TAG:N&&I,aTypedArray:function(e){if(z(e))return e;throw L("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw L(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(s){if(n)for(var r in F){var a=o[r];if(a&&c(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}(!R[e]||n)&&f(R,e,n?t:U&&E[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(s){if(y){if(n)for(i in F)if((r=o[i])&&c(r,e))try{delete r[e]}catch(e){}if(C[e]&&!n)return;try{return f(C,e,n?t:U&&C[e]||t)}catch(e){}}for(i in F)(r=o[i])&&(!r[e]||n)&&f(r,e,t)}},getTypedArrayConstructor:B,isView:function(e){if(!h(e))return!1;var t=u(e);return"DataView"===t||c(F,t)||c(k,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:R}})),ZW=F((()=>{var e=we(),t=kn();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),mT=F(((e,t)=>{var n=df(),i=Sh(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a constructor")}})),bf=F(((e,t)=>{var n=Cn(),i=mT(),r=Cs(),a=$n()("species");t.exports=function(e,t){var s,o=n(e).constructor;return void 0===o||r(s=n(o)[a])?t:i(s)}})),sj=F((()=>{"use strict";var e=we(),t=uu(),n=dt(),i=m1(),r=Cn(),a=hl(),s=ra(),o=bf(),l=i.ArrayBuffer,h=i.DataView,c=h.prototype,u=t(l.prototype.slice),d=t(c.getUint8),p=t(c.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:n((function(){return!new l(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(u&&void 0===t)return u(r(this),e);for(var n=r(this).byteLength,i=a(e,n),c=a(void 0===t?n:t,n),f=new(o(this,l))(s(c-i)),m=new h(this),g=new h(f),v=0;i<c;)p(g,v++,d(m,i++));return f}})})),aj=F((()=>{var e=we(),t=m1();e({global:!0,constructor:!0,forced:!rT()},{DataView:t.DataView})})),oj=F((()=>{aj()})),lj=F((()=>{"use strict";var e=we(),t=yt(),n=dt()((function(){return 120!==new Date(16e11).getYear()})),i=t(Date.prototype.getFullYear);e({target:"Date",proto:!0,forced:n},{getYear:function(){return i(this)-1900}})})),uj=F((()=>{var e=we(),t=yt(),n=Date,i=t(n.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return i(new n)}})})),fj=F((()=>{"use strict";var e=we(),t=yt(),n=di(),i=Date.prototype,r=t(i.getTime),a=t(i.setFullYear);e({target:"Date",proto:!0},{setYear:function(e){r(this);var t=n(e);return a(this,0<=t&&t<=99?t+1900:t)}})})),pj=F((()=>{we()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),g1=F(((e,t)=>{"use strict";var n=di(),i=Hn(),r=Mi(),a=RangeError;t.exports=function(e){var t=i(r(this)),s="",o=n(e);if(o<0||o==1/0)throw a("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(t+=t))1&o&&(s+=t);return s}})),gT=F(((e,t)=>{var n=yt(),i=ra(),r=Hn(),a=g1(),s=Mi(),o=n(a),l=n("".slice),h=Math.ceil,c=function(e){return function(t,n,a){var c,u,d=r(s(t)),p=i(n),f=d.length,m=void 0===a?" ":r(a);return p<=f||""==m?d:((u=o(m,h((c=p-f)/m.length))).length>c&&(u=l(u,0,c)),e?d+u:u+d)}};t.exports={start:c(!1),end:c(!0)}})),_j=F(((e,t)=>{"use strict";var n=yt(),i=dt(),r=gT().start,a=RangeError,s=isFinite,o=Math.abs,l=Date.prototype,h=l.toISOString,c=n(l.getTime),u=n(l.getUTCDate),d=n(l.getUTCFullYear),p=n(l.getUTCHours),f=n(l.getUTCMilliseconds),m=n(l.getUTCMinutes),g=n(l.getUTCMonth),v=n(l.getUTCSeconds);t.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=h.call(new Date(-50000000000001))}))||!i((function(){h.call(new Date(NaN))}))?function(){if(!s(c(this)))throw a("Invalid time value");var e=this,t=d(e),n=f(e),i=t<0?"-":t>9999?"+":"";return i+r(o(t),i?6:4,0)+"-"+r(g(e)+1,2,0)+"-"+r(u(e),2,0)+"T"+r(p(e),2,0)+":"+r(m(e),2,0)+":"+r(v(e),2,0)+"."+r(n,3,0)+"Z"}:h})),wj=F((()=>{var e=we(),t=_j();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),Mj=F((()=>{"use strict";var e=we(),t=dt(),n=xr(),i=q0();e({target:"Date",proto:!0,arity:1,forced:t((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=n(this),r=i(t,"number");return"number"!=typeof r||isFinite(r)?t.toISOString():null}})})),Rj=F(((e,t)=>{"use strict";var n=Cn(),i=Q3(),r=TypeError;t.exports=function(e){if(n(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw r("Incorrect hint");return i(this,e)}})),Pj=F((()=>{var e=ar(),t=ei(),n=Rj(),i=$n()("toPrimitive"),r=Date.prototype;e(r,i)||t(r,i,n)})),Oj=F((()=>{var e=yt(),t=ei(),n=Date.prototype,i="Invalid Date",r="toString",a=e(n[r]),s=e(n.getTime);String(new Date(NaN))!=i&&t(n,r,(function(){var e=s(this);return e==e?a(this):i}))})),Uj=F((()=>{"use strict";var e=we(),t=yt(),n=Hn(),i=t("".charAt),r=t("".charCodeAt),a=t(/./.exec),s=t(1..toString),o=t("".toUpperCase),l=/[\w*+\-./@]/,h=function(e,t){for(var n=s(e,16);n.length<t;)n="0"+n;return n};e({global:!0},{escape:function(e){for(var t,s,c=n(e),u="",d=c.length,p=0;p<d;)t=i(c,p++),a(l,t)?u+=t:u+=(s=r(t,0))<256?"%"+h(s,2):"%u"+o(h(s,4));return u}})})),nI=F(((e,t)=>{"use strict";var n=yt(),i=ui(),r=Yn(),a=ar(),s=Ah(),o=um(),l=Function,h=n([].concat),c=n([].join),u={};t.exports=o?l.bind:function(e){var t=i(this),n=t.prototype,o=s(arguments,1),d=function(){var n=h(o,s(arguments));return this instanceof d?function(e,t,n){if(!a(u,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";u[t]=l("C,a","return new C("+c(i,",")+")")}return u[t](e,n)}(t,n.length,n):t.apply(e,n)};return r(n)&&(d.prototype=n),d}})),zj=F((()=>{var e=we(),t=nI();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),Wj=F((()=>{"use strict";var e=Xn(),t=Yn(),n=Yr(),i=Na(),r=$n(),a=__(),s=r("hasInstance"),o=Function.prototype;s in o||n.f(o,s,{value:a((function(n){if(!e(this)||!t(n))return!1;var r=this.prototype;if(!t(r))return n instanceof this;for(;n=i(n);)if(r===n)return!0;return!1}),s)})})),$j=F((()=>{var e=on(),t=uf().EXISTS,n=yt(),i=Vi(),r=Function.prototype,a=n(r.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,o=n(s.exec);e&&!t&&i(r,"name",{configurable:!0,get:function(){try{return o(s,a(this))[1]}catch(e){return""}}})})),Zj=F((()=>{var e=we(),t=Ot();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),Kj=F((()=>{var e=Ot();sa()(e.JSON,"JSON",!0)})),vT=F(((e,t)=>{var n=dt();t.exports=n((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),yT=F(((e,t)=>{var n=dt(),i=Yn(),r=ls(),a=vT(),s=Object.isExtensible,o=n((function(){s(1)}));t.exports=o||a?function(e){return!(!i(e)||a&&"ArrayBuffer"==r(e))&&(!s||s(e))}:s})),Tf=F(((e,t)=>{var n=dt();t.exports=!n((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),Uh=F(((e,t)=>{var n=we(),i=yt(),r=dm(),a=Yn(),s=ar(),o=Yr().f,l=cu(),h=P_(),c=yT(),u=cf(),d=Tf(),p=!1,f=u("meta"),m=0,g=function(e){o(e,f,{value:{objectID:"O"+m++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},p=!0;var e=l.f,t=i([].splice),r={};r[f]=1,e(r).length&&(l.f=function(n){for(var i=e(n),r=0,a=i.length;r<a;r++)if(i[r]===f){t(i,r,1);break}return i},n({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:h.f}))},fastKey:function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!s(e,f)){if(!c(e))return"F";if(!t)return"E";g(e)}return e[f].objectID},getWeakData:function(e,t){if(!s(e,f)){if(!c(e))return!0;if(!t)return!1;g(e)}return e[f].weakData},onFreeze:function(e){return d&&p&&c(e)&&!s(e,f)&&g(e),e}};r[f]=!0})),x1=F(((e,t)=>{"use strict";var n=we(),i=Ot(),r=yt(),a=pm(),s=ei(),o=Uh(),l=pl(),h=ml(),c=Xn(),u=Cs(),d=Yn(),p=dt(),f=o1(),m=sa(),g=gf();t.exports=function(e,t,v){var y=-1!==e.indexOf("Map"),x=-1!==e.indexOf("Weak"),_=y?"set":"add",b=i[e],M=b&&b.prototype,w=b,S={},E=function(e){var t=r(M[e]);s(M,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return x&&!d(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!c(b)||!(x||M.forEach&&!p((function(){(new b).entries().next()})))))w=v.getConstructor(t,e,y,_),o.enable();else if(a(e,!0)){var T=new w,A=T[_](x?{}:-0,1)!=T,C=p((function(){T.has(1)})),R=f((function(e){new b(e)})),P=!x&&p((function(){for(var e=new b,t=5;t--;)e[_](t,t);return!e.has(-0)}));R||((w=t((function(e,t){h(e,M);var n=g(new b,e,w);return u(t)||l(t,n[_],{that:n,AS_ENTRIES:y}),n}))).prototype=M,M.constructor=w),(C||P)&&(E("delete"),E("has"),y&&E("get")),(P||A)&&E(_),x&&M.clear&&delete M.clear}return S[e]=w,n({global:!0,constructor:!0,forced:w!=b},S),m(w,e),x||v.setStrong(w,e,y),w}})),hI=F(((e,t)=>{"use strict";var n=ia(),i=Vi(),r=Mm(),a=mo(),s=ml(),o=Cs(),l=pl(),h=K_(),c=u1(),u=yf(),d=on(),p=Uh().fastKey,f=Si(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,i){s(e,f),m(e,{type:t,index:n(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(i)||l(i,e[c],{that:e,AS_ENTRIES:h})})),f=u.prototype,v=g(t),y=function(e,t,n){var i,r,a=v(e),s=x(e,t);return s?s.value=n:(a.last=s={index:r=p(t,!0),key:t,value:n,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=s),i&&(i.next=s),d?a.size++:e.size++,"F"!==r&&(a.index[r]=s)),e},x=function(e,t){var n,i=v(e),r=p(t);if("F"!==r)return i.index[r];for(n=i.first;n;n=n.next)if(n.key==t)return n};return r(f,{clear:function(){for(var e=v(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,d?e.size=0:this.size=0},delete:function(e){var t=this,n=v(t),i=x(t,e);if(i){var r=i.next,a=i.previous;delete n.index[i.index],i.removed=!0,a&&(a.next=r),r&&(r.previous=a),n.first==i&&(n.first=r),n.last==i&&(n.last=a),d?n.size--:t.size--}return!!i},forEach:function(e){for(var t,n=v(this),i=a(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!x(this,e)}}),r(f,h?{get:function(e){var t=x(this,e);return t&&t.value},set:function(e,t){return y(this,0===e?0:e,t)}}:{add:function(e){return y(this,e=0===e?0:e,e)}}),d&&i(f,"size",{configurable:!0,get:function(){return v(this).size}}),u},setStrong:function(e,t,n){var i=t+" Iterator",r=g(t),a=g(i);h(e,t,(function(e,t){m(this,{type:i,target:e,state:r(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?c("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,c(void 0,!0))}),n?"entries":"values",!n,!0),u(t)}}})),dX=F((()=>{"use strict";x1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hI())})),fX=F((()=>{dX()})),dI=F(((e,t)=>{var n=Math.log;t.exports=Math.log1p||function(e){var t=+e;return t>-1e-8&&t<1e-8?t-t*t/2:n(1+t)}})),gX=F((()=>{var e=we(),t=dI(),n=Math.acosh,i=Math.log,r=Math.sqrt,a=Math.LN2;e({target:"Math",stat:!0,forced:!n||710!=Math.floor(n(Number.MAX_VALUE))||n(1/0)!=1/0},{acosh:function(e){var n=+e;return n<1?NaN:n>94906265.62425156?i(n)+a:t(n-1+r(n-1)*r(n+1))}})})),yX=F((()=>{var e=we(),t=Math.asinh,n=Math.log,i=Math.sqrt;e({target:"Math",stat:!0,forced:!(t&&1/t(0)>0)},{asinh:function e(t){var r=+t;return isFinite(r)&&0!=r?r<0?-e(-r):n(r+i(r*r+1)):r}})})),bX=F((()=>{var e=we(),t=Math.atanh,n=Math.log;e({target:"Math",stat:!0,forced:!(t&&1/t(-0)<0)},{atanh:function(e){var t=+e;return 0==t?t:n((1+t)/(1-t))/2}})})),bT=F(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),TX=F((()=>{var e=we(),t=bT(),n=Math.abs,i=Math.pow;e({target:"Math",stat:!0},{cbrt:function(e){var r=+e;return t(r)*i(n(r),1/3)}})})),wX=F((()=>{var e=we(),t=Math.floor,n=Math.log,i=Math.LOG2E;e({target:"Math",stat:!0},{clz32:function(e){var r=e>>>0;return r?31-t(n(r+.5)*i):32}})})),b1=F(((e,t)=>{var n=Math.expm1,i=Math.exp;t.exports=!n||n(10)>22025.465794806718||n(10)<22025.465794806718||-2e-17!=n(-2e-17)?function(e){var t=+e;return 0==t?t:t>-1e-6&&t<1e-6?t+t*t/2:i(t)-1}:n})),RX=F((()=>{var e=we(),t=b1(),n=Math.cosh,i=Math.abs,r=Math.E;e({target:"Math",stat:!0,forced:!n||n(710)===1/0},{cosh:function(e){var n=t(i(e)-1)+1;return(n+1/(n*r*r))*(r/2)}})})),CX=F((()=>{var e=we(),t=b1();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),IX=F(((e,t)=>{var n=bT(),i=Math.abs,r=Math.pow,a=r(2,-52),s=r(2,-23),o=r(2,127)*(2-s),l=r(2,-126);t.exports=Math.fround||function(e){var t,r,h=+e,c=i(h),u=n(h);return c<l?u*(c/l/s+1/a-1/a)*l*s:(r=(t=(1+s/a)*c)-(t-c))>o||r!=r?u*(1/0):u*r}})),DX=F((()=>{we()({target:"Math",stat:!0},{fround:IX()})})),OX=F((()=>{var e=we(),t=Math.hypot,n=Math.abs,i=Math.sqrt;e({target:"Math",stat:!0,arity:2,forced:!!t&&t(1/0,NaN)!==1/0},{hypot:function(e,t){for(var r,a,s=0,o=0,l=arguments.length,h=0;o<l;)h<(r=n(arguments[o++]))?(s=s*(a=h/r)*a+1,h=r):s+=r>0?(a=r/h)*a:r;return h===1/0?1/0:h*i(s)}})})),UX=F((()=>{var e=we(),t=dt(),n=Math.imul;e({target:"Math",stat:!0,forced:t((function(){return-5!=n(4294967295,5)||2!=n.length}))},{imul:function(e,t){var n=65535,i=+e,r=+t,a=n&i,s=n&r;return 0|a*s+((n&i>>>16)*s+a*(n&r>>>16)<<16>>>0)}})})),vI=F(((e,t)=>{var n=Math.log,i=Math.LOG10E;t.exports=Math.log10||function(e){return n(e)*i}})),FX=F((()=>{we()({target:"Math",stat:!0},{log10:vI()})})),HX=F((()=>{we()({target:"Math",stat:!0},{log1p:dI()})})),kX=F((()=>{var e=we(),t=Math.log,n=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/n}})})),VX=F((()=>{we()({target:"Math",stat:!0},{sign:bT()})})),qX=F((()=>{var e=we(),t=dt(),n=b1(),i=Math.abs,r=Math.exp,a=Math.E;e({target:"Math",stat:!0,forced:t((function(){return-2e-17!=Math.sinh(-2e-17)}))},{sinh:function(e){var t=+e;return i(t)<1?(n(t)-n(-t))/2:(r(t-1)-r(-t-1))*(a/2)}})})),XX=F((()=>{var e=we(),t=b1(),n=Math.exp;e({target:"Math",stat:!0},{tanh:function(e){var i=+e,r=t(i),a=t(-i);return r==1/0?1:a==1/0?-1:(r-a)/(n(i)+n(-i))}})})),YX=F((()=>{sa()(Math,"Math",!0)})),$X=F((()=>{we()({target:"Math",stat:!0},{trunc:v2()})})),_1=F(((e,t)=>{var n=yt();t.exports=n(1..valueOf)})),T1=F(((e,t)=>{t.exports="\t\n\v\f\r \xa0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff"})),wf=F(((e,t)=>{var n=yt(),i=Mi(),r=Hn(),a=T1(),s=n("".replace),o=RegExp("^["+a+"]+"),l=RegExp("(^|[^"+a+"])["+a+"]+$"),h=function(e){return function(t){var n=r(i(t));return 1&e&&(n=s(n,o,"")),2&e&&(n=s(n,l,"$1")),n}};t.exports={start:h(1),end:h(2),trim:h(3)}})),aY=F((()=>{"use strict";var e=we(),t=hi(),n=on(),i=Ot(),r=I_(),a=yt(),s=pm(),o=ar(),l=gf(),h=La(),c=Mh(),u=q0(),d=dt(),p=cu().f,f=Ki().f,m=Yr().f,g=_1(),v=wf().trim,y="Number",x=i[y],_=r[y],b=x.prototype,M=i.TypeError,w=a("".slice),S=a("".charCodeAt),E=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),T=function(e){var t,n=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t:function(e){var t,n,i,r,a,s,o,l,h=u(e,"number");if(c(h))throw M("Cannot convert a Symbol value to a number");if("string"==typeof h&&h.length>2)if(h=v(h),43===(t=S(h,0))||45===t){if(88===(n=S(h,2))||120===n)return NaN}else if(48===t){switch(S(h,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+h}for(s=(a=w(h,2)).length,o=0;o<s;o++)if((l=S(a,o))<48||l>r)return NaN;return parseInt(a,i)}return+h}(t)}(e));return h(b,t=this)&&d((function(){g(t)}))?l(Object(n),this,T):n};T.prototype=b,E&&!t&&(b.constructor=T),e({global:!0,constructor:!0,wrap:!0,forced:E},{Number:T});var A=function(e,t){for(var i,r=n?p(t):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),a=0;r.length>a;a++)o(t,i=r[a])&&!o(e,i)&&m(e,i,f(t,i))};t&&_&&A(r[y],_),(E||t)&&A(r[y],x)})),oY=F((()=>{we()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),cY=F(((e,t)=>{var n=Ot().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&n(e)}})),uY=F((()=>{we()({target:"Number",stat:!0},{isFinite:cY()})})),ST=F(((e,t)=>{var n=Yn(),i=Math.floor;t.exports=Number.isInteger||function(e){return!n(e)&&isFinite(e)&&i(e)===e}})),dY=F((()=>{we()({target:"Number",stat:!0},{isInteger:ST()})})),fY=F((()=>{we()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),pY=F((()=>{var e=we(),t=ST(),n=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&n(e)<=9007199254740991}})})),mY=F((()=>{we()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),gY=F((()=>{we()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),wI=F(((e,t)=>{var n=Ot(),i=dt(),r=yt(),a=Hn(),s=wf().trim,o=T1(),l=r("".charAt),h=n.parseFloat,c=n.Symbol,u=c&&c.iterator,d=1/h(o+"-0")!=-1/0||u&&!i((function(){h(Object(u))}));t.exports=d?function(e){var t=s(a(e)),n=h(t);return 0===n&&"-"==l(t,0)?-0:n}:h})),_Y=F((()=>{var e=we(),t=wI();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),MI=F(((e,t)=>{var n=Ot(),i=dt(),r=yt(),a=Hn(),s=wf().trim,o=T1(),l=n.parseInt,h=n.Symbol,c=h&&h.iterator,u=/^[+-]?0x/i,d=r(u.exec),p=8!==l(o+"08")||22!==l(o+"0x16")||c&&!i((function(){l(Object(c))}));t.exports=p?function(e,t){var n=s(a(e));return l(n,t>>>0||(d(u,n)?16:10))}:l})),PY=F((()=>{var e=we(),t=MI();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),NY=F((()=>{"use strict";var e=we(),t=yt(),n=di(),i=_1(),r=g1(),a=vI(),s=dt(),o=RangeError,l=String,h=isFinite,c=Math.abs,u=Math.floor,d=Math.pow,p=Math.round,f=t(1..toExponential),m=t(r),g=t("".slice),v="-6.9000e-11"===f(-69e-12,4)&&"1.25e+0"===f(1.255,2)&&"1.235e+4"===f(12345,3)&&"3e+1"===f(25,0);e({target:"Number",proto:!0,forced:!v||!(s((function(){f(1,1/0)}))&&s((function(){f(1,-1/0)})))||!!s((function(){f(1/0,1/0),f(NaN,1/0)}))},{toExponential:function(e){var t=i(this);if(void 0===e)return f(t);var r=n(e);if(!h(t))return String(t);if(r<0||r>20)throw o("Incorrect fraction digits");if(v)return f(t,r);var s="",y="",x=0,_="",b="";if(t<0&&(s="-",t=-t),0===t)x=0,y=m("0",r+1);else{var M=a(t);x=u(M);var w=0,S=d(10,x-r);2*t>=(2*(w=p(t/S))+1)*S&&(w+=1),w>=d(10,r+1)&&(w/=10,x+=1),y=l(w)}return 0!==r&&(y=g(y,0,1)+"."+g(y,1)),0===x?(_="+",b="0"):(_=x>0?"+":"-",b=l(c(x))),s+(y+"e")+_+b}})})),VY=F((()=>{"use strict";var e=we(),t=yt(),n=di(),i=_1(),r=g1(),a=dt(),s=RangeError,o=String,l=Math.floor,h=t(r),c=t("".slice),u=t(1..toFixed),d=function(e,t,n){return 0===t?n:t%2==1?d(e,t-1,n*e):d(e*e,t/2,n)},p=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=l(r/1e7)},f=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=l(i/t),i=i%t*1e7},m=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var i=o(e[t]);n=""===n?i:n+h("0",7-i.length)+i}return n};e({target:"Number",proto:!0,forced:a((function(){return"0.000"!==u(8e-5,3)||"1"!==u(.9,0)||"1.25"!==u(1.255,2)||"1000000000000000128"!==u(0xde0b6b3a7640080,0)}))||!a((function(){u({})}))},{toFixed:function(e){var t,r,a,l,u=i(this),g=n(e),v=[0,0,0,0,0,0],y="",x="0";if(g<0||g>20)throw s("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||u>=1e21)return o(u);if(u<0&&(y="-",u=-u),u>1e-21)if(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(u*d(2,69,1))-69,r=t<0?u*d(2,-t,1):u/d(2,t,1),r*=4503599627370496,(t=52-t)>0){for(p(v,0,r),a=g;a>=7;)p(v,1e7,0),a-=7;for(p(v,d(10,a,1),0),a=t-1;a>=23;)f(v,1<<23),a-=23;f(v,1<<a),p(v,1,1),f(v,2),x=m(v)}else p(v,0,r),p(v,1<<-t,0),x=m(v)+h("0",g);return x=g>0?y+((l=x.length)<=g?"0."+h("0",g-l)+x:c(x,0,l-g)+"."+c(x,l-g)):y+x}})})),qY=F((()=>{"use strict";var e=we(),t=yt(),n=dt(),i=_1(),r=t(1..toPrecision);e({target:"Number",proto:!0,forced:n((function(){return"1"!==r(1,void 0)}))||!n((function(){r({})}))},{toPrecision:function(e){return void 0===e?r(i(this)):r(i(this),e)}})})),DI=F(((e,t)=>{"use strict";var n=on(),i=yt(),r=Bn(),a=dt(),s=mm(),o=Y0(),l=G0(),h=xr(),c=af(),u=Object.assign,d=Object.defineProperty,p=i([].concat);t.exports=!u||a((function(){if(n&&1!==u({b:1},u(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=u({},e)[i]||s(u({},t)).join("")!=r}))?function(e,t){for(var i=h(e),a=arguments.length,u=1,d=o.f,f=l.f;a>u;)for(var m,g=c(arguments[u++]),v=d?p(s(g),d(g)):s(g),y=v.length,x=0;y>x;)m=v[x++],(!n||r(f,g,m))&&(i[m]=g[m]);return i}:u})),$Y=F((()=>{var e=we(),t=DI();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),ZY=F((()=>{we()({target:"Object",stat:!0,sham:!on()},{create:ia()})})),R1=F(((e,t)=>{"use strict";var n=hi(),i=Ot(),r=dt(),a=tT();t.exports=n||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete i[e]}}))})),QY=F((()=>{"use strict";var e=we(),t=on(),n=R1(),i=ui(),r=xr(),a=Yr();t&&e({target:"Object",proto:!0,forced:n},{__defineGetter__:function(e,t){a.f(r(this),e,{get:i(t),enumerable:!0,configurable:!0})}})})),t$=F((()=>{var e=we(),t=on(),n=R_().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==n,sham:!t},{defineProperties:n})})),r$=F((()=>{var e=we(),t=on(),n=Yr().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==n,sham:!t},{defineProperty:n})})),i$=F((()=>{"use strict";var e=we(),t=on(),n=R1(),i=ui(),r=xr(),a=Yr();t&&e({target:"Object",proto:!0,forced:n},{__defineSetter__:function(e,t){a.f(r(this),e,{set:i(t),enumerable:!0,configurable:!0})}})})),LI=F(((e,t)=>{var n=on(),i=yt(),r=mm(),a=Ni(),s=i(G0().f),o=i([].push),l=function(e){return function(t){for(var i,l=a(t),h=r(l),c=h.length,u=0,d=[];c>u;)i=h[u++],(!n||s(l,i))&&o(d,e?[i,l[i]]:l[i]);return d}};t.exports={entries:l(!0),values:l(!1)}})),l$=F((()=>{var e=we(),t=LI().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),c$=F((()=>{var e=we(),t=Tf(),n=dt(),i=Yn(),r=Uh().onFreeze,a=Object.freeze;e({target:"Object",stat:!0,forced:n((function(){a(1)})),sham:!t},{freeze:function(e){return a&&i(e)?a(r(e)):e}})})),u$=F((()=>{var e=we(),t=pl(),n=tc();e({target:"Object",stat:!0},{fromEntries:function(e){var i={};return t(e,(function(e,t){n(i,e,t)}),{AS_ENTRIES:!0}),i}})})),f$=F((()=>{var e=we(),t=dt(),n=Ni(),i=Ki().f,r=on();e({target:"Object",stat:!0,forced:!r||t((function(){i(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return i(n(e),t)}})})),p$=F((()=>{var e=we(),t=on(),n=w_(),i=Ni(),r=Ki(),a=tc();e({target:"Object",stat:!0,sham:!t},{getOwnPropertyDescriptors:function(e){for(var t,s,o=i(e),l=r.f,h=n(o),c={},u=0;h.length>u;)void 0!==(s=l(o,t=h[u++]))&&a(c,t,s);return c}})})),m$=F((()=>{var e=we(),t=dt(),n=P_().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:n})})),v$=F((()=>{var e=we(),t=dt(),n=xr(),i=Na(),r=z_();e({target:"Object",stat:!0,forced:t((function(){i(1)})),sham:!r},{getPrototypeOf:function(e){return i(n(e))}})})),x$=F((()=>{we()({target:"Object",stat:!0},{hasOwn:ar()})})),NI=F(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),E$=F((()=>{we()({target:"Object",stat:!0},{is:NI()})})),_$=F((()=>{var e=we(),t=yT();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),w$=F((()=>{var e=we(),t=dt(),n=Yn(),i=ls(),r=vT(),a=Object.isFrozen;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isFrozen:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),S$=F((()=>{var e=we(),t=dt(),n=Yn(),i=ls(),r=vT(),a=Object.isSealed;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isSealed:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),A$=F((()=>{var e=we(),t=xr(),n=mm();e({target:"Object",stat:!0,forced:dt()((function(){n(1)}))},{keys:function(e){return n(t(e))}})})),C$=F((()=>{"use strict";var e=we(),t=on(),n=R1(),i=xr(),r=lu(),a=Na(),s=Ki().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupGetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.get}while(n=a(n))}})})),P$=F((()=>{"use strict";var e=we(),t=on(),n=R1(),i=xr(),r=lu(),a=Na(),s=Ki().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupSetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.set}while(n=a(n))}})})),I$=F((()=>{var e=we(),t=Yn(),n=Uh().onFreeze,i=Tf(),r=dt(),a=Object.preventExtensions;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{preventExtensions:function(e){return a&&t(e)?a(n(e)):e}})})),B$=F((()=>{"use strict";var e=on(),t=Vi(),n=Yn(),i=xr(),r=Mi(),a=Object.getPrototypeOf,s=Object.setPrototypeOf,o=Object.prototype,l="__proto__";if(e&&a&&s&&!(l in o))try{t(o,l,{configurable:!0,get:function(){return a(i(this))},set:function(e){var t=r(this);!n(e)&&null!==e||!n(t)||s(t,e)}})}catch(e){}})),F$=F((()=>{var e=we(),t=Yn(),n=Uh().onFreeze,i=Tf(),r=dt(),a=Object.seal;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{seal:function(e){return a&&t(e)?a(n(e)):e}})})),H$=F((()=>{we()({target:"Object",stat:!0},{setPrototypeOf:fl()})})),V$=F(((e,t)=>{"use strict";var n=M_(),i=dl();t.exports=n?{}.toString:function(){return"[object "+i(this)+"]"}})),z$=F((()=>{var e=M_(),t=ei(),n=V$();e||t(Object.prototype,"toString",n,{unsafe:!0})})),G$=F((()=>{var e=we(),t=LI().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),W$=F((()=>{var e=we(),t=wI();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),X$=F((()=>{var e=we(),t=MI();e({global:!0,forced:parseInt!=t},{parseInt:t})})),Eu=F(((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw n("Not enough arguments");return e}})),kI=F(((e,t)=>{var n=Jl();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)})),P1=F(((e,t)=>{var n,i,r,a,s=Ot(),o=Oa(),l=mo(),h=Xn(),c=ar(),u=dt(),d=b2(),p=Ah(),f=W0(),m=Eu(),g=kI(),v=ic(),y=s.setImmediate,x=s.clearImmediate,_=s.process,b=s.Dispatch,M=s.Function,w=s.MessageChannel,S=s.String,E=0,T={},A="onreadystatechange";u((function(){n=s.location}));var C=function(e){if(c(T,e)){var t=T[e];delete T[e],t()}},R=function(e){return function(){C(e)}},P=function(e){C(e.data)},L=function(e){s.postMessage(S(e),n.protocol+"//"+n.host)};(!y||!x)&&(y=function(e){m(arguments.length,1);var t=h(e)?e:M(e),n=p(arguments,1);return T[++E]=function(){o(t,void 0,n)},i(E),E},x=function(e){delete T[e]},v?i=function(e){_.nextTick(R(e))}:b&&b.now?i=function(e){b.now(R(e))}:w&&!g?(a=(r=new w).port2,r.port1.onmessage=P,i=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&n&&"file:"!==n.protocol&&!u(L)?(i=L,s.addEventListener("message",P,!1)):i=A in f("script")?function(e){d.appendChild(f("script"))[A]=function(){d.removeChild(this),C(e)}}:function(e){setTimeout(R(e),0)}),t.exports={set:y,clear:x}})),$I=F(((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}},t.exports=n})),lZ=F(((e,t)=>{var n=Jl();t.exports=/ipad|iphone|ipod/i.test(n)&&"undefined"!=typeof Pebble})),uZ=F(((e,t)=>{var n=Jl();t.exports=/web0s(?!.*chrome)/i.test(n)})),tD=F(((e,t)=>{var n,i,r,a,s,o,l,h=Ot(),c=mo(),u=Ki().f,d=P1().set,p=$I(),f=kI(),m=lZ(),g=uZ(),v=ic(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,_=h.process,b=h.Promise,M=u(h,"queueMicrotask"),w=M&&M.value;w||(o=new p,l=function(){var e,t;for(v&&(e=_.domain)&&e.exit();t=o.get();)try{t()}catch(e){throw o.head&&n(),e}e&&e.enter()},f||v||g||!y||!x?!m&&b&&b.resolve?((a=b.resolve(void 0)).constructor=b,s=c(a.then,a),n=function(){s(l)}):v?n=function(){_.nextTick(l)}:(d=c(d,h),n=function(){d(l)}):(i=!0,r=x.createTextNode(""),new y(l).observe(r,{characterData:!0}),n=function(){r.data=i=!i}),w=function(e){o.head||n(),o.add(e)}),t.exports=w})),yZ=F(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),Um=F(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),Rf=F(((e,t)=>{var n=Ot();t.exports=n.Promise})),IT=F(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),nD=F(((e,t)=>{var n=IT(),i=ic();t.exports=!n&&!i&&"object"==typeof window&&"object"==typeof document})),Bm=F(((e,t)=>{var n=Ot(),i=Rf(),r=Xn(),a=pm(),s=v_(),o=$n(),l=nD(),h=IT(),c=hi(),u=Ql(),d=i&&i.prototype,p=o("species"),f=!1,m=r(n.PromiseRejectionEvent),g=a("Promise",(function(){var e=s(i),t=e!==String(i);if(!t&&66===u||c&&(!d.catch||!d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new i((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[p]=r,!(f=n.then((function(){}))instanceof r))return!0}return!t&&(l||h)&&!m}));t.exports={CONSTRUCTOR:g,REJECTION_EVENT:m,SUBCLASSING:f}})),Bh=F(((e,t)=>{"use strict";var n=ui(),i=TypeError,r=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw i("Bad Promise constructor");t=e,r=n})),this.resolve=n(t),this.reject=n(r)};t.exports.f=function(e){return new r(e)}})),XZ=F((()=>{"use strict";var e,t,n,i=we(),r=hi(),a=ic(),s=Ot(),o=Bn(),l=ei(),h=fl(),c=sa(),u=yf(),d=ui(),p=Xn(),f=Yn(),m=ml(),g=bf(),v=P1().set,y=tD(),x=yZ(),_=Um(),b=$I(),M=Si(),w=Rf(),S=Bm(),E=Bh(),T="Promise",A=S.CONSTRUCTOR,C=S.REJECTION_EVENT,R=S.SUBCLASSING,P=M.getterFor(T),L=M.set,D=w&&w.prototype,I=w,O=D,U=s.TypeError,N=s.document,F=s.process,k=E.f,B=k,z=!!(N&&N.createEvent&&s.dispatchEvent),V="unhandledrejection",H=function(e){var t;return!(!f(e)||!p(t=e.then))&&t},G=function(e,t){var n,i,r,a=t.value,s=1==t.state,l=s?e.ok:e.fail,h=e.resolve,c=e.reject,u=e.domain;try{l?(s||(2===t.rejection&&Y(t),t.rejection=1),!0===l?n=a:(u&&u.enter(),n=l(a),u&&(u.exit(),r=!0)),n===e.promise?c(U("Promise-chain cycle")):(i=H(n))?o(i,n,h,c):h(n)):c(a)}catch(e){u&&!r&&u.exit(),c(e)}},j=function(e,t){e.notified||(e.notified=!0,y((function(){for(var n,i=e.reactions;n=i.get();)G(n,e);e.notified=!1,t&&!e.rejection&&X(e)})))},W=function(e,t,n){var i,r;z?((i=N.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),s.dispatchEvent(i)):i={promise:t,reason:n},!C&&(r=s["on"+e])?r(i):e===V&&x("Unhandled promise rejection",n)},X=function(e){o(v,s,(function(){var t,n=e.facade,i=e.value;if(q(e)&&(t=_((function(){a?F.emit("unhandledRejection",i,n):W(V,n,i)})),e.rejection=a||q(e)?2:1,t.error))throw t.value}))},q=function(e){return 1!==e.rejection&&!e.parent},Y=function(e){o(v,s,(function(){var t=e.facade;a?F.emit("rejectionHandled",t):W("rejectionhandled",t,e.value)}))},$=function(e,t,n){return function(i){e(t,i,n)}},K=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,j(e,!0))},Z=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw U("Promise can't be resolved itself");var i=H(t);i?y((function(){var n={done:!1};try{o(i,t,$(Z,n,e),$(K,n,e))}catch(t){K(n,t,e)}})):(e.value=t,e.state=1,j(e,!1))}catch(t){K({done:!1},t,e)}}};if(A&&(O=(I=function(t){m(this,O),d(t),o(e,this);var n=P(this);try{t($(Z,n),$(K,n))}catch(e){K(n,e)}}).prototype,(e=function(e){L(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new b,rejection:!1,state:0,value:void 0})}).prototype=l(O,"then",(function(e,t){var n=P(this),i=k(g(this,I));return n.parent=!0,i.ok=!p(e)||e,i.fail=p(t)&&t,i.domain=a?F.domain:void 0,0==n.state?n.reactions.add(i):y((function(){G(i,n)})),i.promise})),t=function(){var t=new e,n=P(t);this.promise=t,this.resolve=$(Z,n),this.reject=$(K,n)},E.f=k=function(e){return e===I||void 0===e?new t(e):B(e)},!r&&p(w)&&D!==Object.prototype)){n=D.then,R||l(D,"then",(function(e,t){var i=this;return new I((function(e,t){o(n,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete D.constructor}catch(e){}h&&h(D,O)}i({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:I}),c(I,T,!1,!0),u(T)})),O1=F(((e,t)=>{var n=Rf(),i=o1(),r=Bm().CONSTRUCTOR;t.exports=r||!i((function(e){n.all(e).then(void 0,(function(){}))}))})),$Z=F((()=>{"use strict";var e=we(),t=Bn(),n=ui(),i=Bh(),r=Um(),a=pl();e({target:"Promise",stat:!0,forced:O1()},{all:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,c=1;a(e,(function(e){var n=o++,a=!1;c++,t(i,s,e).then((function(e){a||(a=!0,r[n]=e,--c||l(r))}),h)})),--c||l(r)}));return c.error&&h(c.value),o.promise}})})),KZ=F((()=>{"use strict";var e,t=we(),n=hi(),i=Bm().CONSTRUCTOR,r=Rf(),a=Xr(),s=Xn(),o=ei(),l=r&&r.prototype;t({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(e){return this.then(void 0,e)}}),!n&&s(r)&&(e=a("Promise").prototype.catch,l.catch!==e&&o(l,"catch",e,{unsafe:!0}))})),JZ=F((()=>{"use strict";var e=we(),t=Bn(),n=ui(),i=Bh(),r=Um(),a=pl();e({target:"Promise",stat:!0,forced:O1()},{race:function(e){var s=this,o=i.f(s),l=o.reject,h=r((function(){var i=n(s.resolve);a(e,(function(e){t(i,s,e).then(o.resolve,l)}))}));return h.error&&l(h.value),o.promise}})})),QZ=F((()=>{"use strict";var e=we(),t=Bn(),n=Bh();e({target:"Promise",stat:!0,forced:Bm().CONSTRUCTOR},{reject:function(e){var i=n.f(this);return t(i.reject,void 0,e),i.promise}})})),mD=F(((e,t)=>{var n=Cn(),i=Yn(),r=Bh();t.exports=function(e,t){if(n(e),i(t)&&t.constructor===e)return t;var a=r.f(e);return(0,a.resolve)(t),a.promise}})),rK=F((()=>{"use strict";var e=we(),t=Xr(),n=hi(),i=Rf(),r=Bm().CONSTRUCTOR,a=mD(),s=t("Promise"),o=n&&!r;e({target:"Promise",stat:!0,forced:n||r},{resolve:function(e){return a(o&&this===s?i:this,e)}})})),iK=F((()=>{XZ(),$Z(),KZ(),JZ(),QZ(),rK()})),sK=F((()=>{"use strict";var e=we(),t=Bn(),n=ui(),i=Bh(),r=Um(),a=pl();e({target:"Promise",stat:!0,forced:O1()},{allSettled:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,h=1;a(e,(function(e){var n=o++,a=!1;h++,t(i,s,e).then((function(e){a||(a=!0,r[n]={status:"fulfilled",value:e},--h||l(r))}),(function(e){a||(a=!0,r[n]={status:"rejected",reason:e},--h||l(r))}))})),--h||l(r)}));return c.error&&h(c.value),o.promise}})})),oK=F((()=>{"use strict";var e=we(),t=Bn(),n=ui(),i=Xr(),r=Bh(),a=Um(),s=pl(),o=O1(),l="No one promise resolved";e({target:"Promise",stat:!0,forced:o},{any:function(e){var o=this,h=i("AggregateError"),c=r.f(o),u=c.resolve,d=c.reject,p=a((function(){var i=n(o.resolve),r=[],a=0,c=1,p=!1;s(e,(function(e){var n=a++,s=!1;c++,t(i,o,e).then((function(e){s||p||(p=!0,u(e))}),(function(e){s||p||(s=!0,r[n]=e,--c||d(new h(r,l)))}))})),--c||d(new h(r,l))}));return p.error&&d(p.value),c.promise}})})),hK=F((()=>{"use strict";var e,t=we(),n=hi(),i=Rf(),r=dt(),a=Xr(),s=Xn(),o=bf(),l=mD(),h=ei(),c=i&&i.prototype;t({target:"Promise",proto:!0,real:!0,forced:!!i&&r((function(){c.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=o(this,a("Promise")),n=s(e);return this.then(n?function(n){return l(t,e()).then((function(){return n}))}:e,n?function(n){return l(t,e()).then((function(){throw n}))}:e)}}),!n&&s(i)&&(e=a("Promise").prototype.finally,c.finally!==e&&h(c,"finally",e,{unsafe:!0}))})),dK=F((()=>{var e=we(),t=Oa(),n=ui(),i=Cn();e({target:"Reflect",stat:!0,forced:!dt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(n(e),r,i(a))}})})),yK=F((()=>{var e=we(),t=Xr(),n=Oa(),i=nI(),r=mT(),a=Cn(),s=Yn(),o=ia(),l=dt(),h=t("Reflect","construct"),c=Object.prototype,u=[].push,d=l((function(){function e(){}return!(h((function(){}),[],e)instanceof e)})),p=!l((function(){h((function(){}))})),f=d||p;e({target:"Reflect",stat:!0,forced:f,sham:f},{construct:function(e,t){r(e),a(t);var l=arguments.length<3?e:r(arguments[2]);if(p&&!d)return h(e,t,l);if(e==l){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var f=[null];return n(u,f,t),new(n(i,e,f))}var m=l.prototype,g=o(s(m)?m:c),v=n(e,g,t);return s(v)?v:g}})})),_K=F((()=>{var e=we(),t=on(),n=Cn(),i=lu(),r=Yr();e({target:"Reflect",stat:!0,forced:dt()((function(){Reflect.defineProperty(r.f({},1,{value:1}),1,{value:2})})),sham:!t},{defineProperty:function(e,t,a){n(e);var s=i(t);n(a);try{return r.f(e,s,a),!0}catch(e){return!1}}})})),TK=F((()=>{var e=we(),t=Cn(),n=Ki().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,i){var r=n(t(e),i);return!(r&&!r.configurable)&&delete e[i]}})})),ED=F(((e,t)=>{var n=ar();t.exports=function(e){return void 0!==e&&(n(e,"value")||n(e,"writable"))}})),RK=F((()=>{var e=we(),t=Bn(),n=Yn(),i=Cn(),r=ED(),a=Ki(),s=Na();e({target:"Reflect",stat:!0},{get:function e(o,l){var h,c,u=arguments.length<3?o:arguments[2];return i(o)===u?o[l]:(h=a.f(o,l))?r(h)?h.value:void 0===h.get?void 0:t(h.get,u):n(c=s(o))?e(c,l,u):void 0}})})),AK=F((()=>{var e=we(),t=on(),n=Cn(),i=Ki();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return i.f(n(e),t)}})})),CK=F((()=>{var e=we(),t=Cn(),n=Na();e({target:"Reflect",stat:!0,sham:!z_()},{getPrototypeOf:function(e){return n(t(e))}})})),PK=F((()=>{we()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),IK=F((()=>{var e=we(),t=Cn(),n=yT();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),n(e)}})})),DK=F((()=>{we()({target:"Reflect",stat:!0},{ownKeys:w_()})})),LK=F((()=>{var e=we(),t=Xr(),n=Cn();e({target:"Reflect",stat:!0,sham:!Tf()},{preventExtensions:function(e){n(e);try{var i=t("Object","preventExtensions");return i&&i(e),!0}catch(e){return!1}}})})),FK=F((()=>{var e=we(),t=Bn(),n=Cn(),i=Yn(),r=ED(),a=dt(),s=Yr(),o=Ki(),l=Na(),h=Da();e({target:"Reflect",stat:!0,forced:a((function(){var e=function(){},t=s.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(a,c,u){var d,p,f,m=arguments.length<4?a:arguments[3],g=o.f(n(a),c);if(!g){if(i(p=l(a)))return e(p,c,u,m);g=h(0)}if(r(g)){if(!1===g.writable||!i(m))return!1;if(d=o.f(m,c)){if(d.get||d.set||!1===d.writable)return!1;d.value=u,s.f(m,c,d)}else s.f(m,c,h(0,u))}else{if(void 0===(f=g.set))return!1;t(f,m,u)}return!0}})})),kK=F((()=>{var e=we(),t=Cn(),n=W2(),i=fl();i&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),n(r);try{return i(e,r),!0}catch(e){return!1}}})})),VK=F((()=>{var e=we(),t=Ot(),n=sa();e({global:!0},{Reflect:{}}),n(t.Reflect,"Reflect",!0)})),zm=F(((e,t)=>{var n=Yn(),i=ls(),r=$n()("match");t.exports=function(e){var t;return n(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==i(e))}})),HT=F(((e,t)=>{"use strict";var n=Cn();t.exports=function(){var e=n(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t}})),Gm=F(((e,t)=>{var n=Bn(),i=ar(),r=La(),a=HT(),s=RegExp.prototype;t.exports=function(e){var t=e.flags;return void 0!==t||"flags"in s||i(e,"flags")||!r(s,e)?t:n(a,e)}})),N1=F(((e,t)=>{var n=dt(),i=Ot().RegExp,r=n((function(){var e=i("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),a=r||n((function(){return!i("a","y").sticky})),s=r||n((function(){var e=i("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));t.exports={BROKEN_CARET:s,MISSED_STICKY:a,UNSUPPORTED_Y:r}})),kT=F(((e,t)=>{var n=dt(),i=Ot().RegExp;t.exports=n((function(){var e=i(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),MD=F(((e,t)=>{var n=dt(),i=Ot().RegExp;t.exports=n((function(){var e=i("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}))})),rJ=F((()=>{var e,t,n,i=on(),r=Ot(),a=yt(),s=pm(),o=gf(),l=cs(),h=cu().f,c=La(),u=zm(),d=Hn(),p=Gm(),f=N1(),m=j2(),g=ei(),v=dt(),y=ar(),x=Si().enforce,_=yf(),b=$n(),M=kT(),w=MD(),S=b("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),R=a("".charAt),P=a("".replace),L=a("".indexOf),D=a("".slice),I=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,O=/a/g,U=/a/g,N=new E(O)!==O,F=f.MISSED_STICKY,k=f.UNSUPPORTED_Y;if(s("RegExp",i&&(!N||F||M||w||v((function(){return U[S]=!1,E(O)!=O||E(U)==U||"/a/i"!=E(O,"i")}))))){for(e=function(t,n){var i,r,a,s,h,f,m=c(T,this),g=u(t),v=void 0===n,_=[],b=t;if(!m&&g&&v&&t.constructor===e)return t;if((g||c(T,t))&&(t=t.source,v&&(n=p(b))),t=void 0===t?"":d(t),n=void 0===n?"":d(n),b=t,M&&"dotAll"in O&&(r=!!n&&L(n,"s")>-1)&&(n=P(n,/s/g,"")),i=n,F&&"sticky"in O&&(a=!!n&&L(n,"y")>-1)&&k&&(n=P(n,/y/g,"")),w&&(s=function(e){for(var t,n=e.length,i=0,r="",a=[],s={},o=!1,l=!1,h=0,c="";i<=n;i++){if("\\"===(t=R(e,i)))t+=R(e,++i);else if("]"===t)o=!1;else if(!o)switch(!0){case"["===t:o=!0;break;case"("===t:C(I,D(e,i+1))&&(i+=2,l=!0),r+=t,h++;continue;case">"===t&&l:if(""===c||y(s,c))throw new A("Invalid capture group name");s[c]=!0,a[a.length]=[c,h],l=!1,c="";continue}l?c+=t:r+=t}return[r,a]}(t),t=s[0],_=s[1]),h=o(E(t,n),m?this:T,e),(r||a||_.length)&&(f=x(h),r&&(f.dotAll=!0,f.raw=e(function(e){for(var t,n=e.length,i=0,r="",a=!1;i<=n;i++)"\\"!==(t=R(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),r+=t):r+="[\\s\\S]":r+=t+R(e,++i);return r}(t),i)),a&&(f.sticky=!0),_.length&&(f.groups=_)),t!==b)try{l(h,"source",""===b?"(?:)":b)}catch(e){}return h},t=h(E),n=0;t.length>n;)m(e,E,t[n++]);T.constructor=e,e.prototype=T,g(r,"RegExp",e,{constructor:!0})}_("RegExp")})),sJ=F((()=>{var e=on(),t=kT(),n=ls(),i=Vi(),r=Si().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"dotAll",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).dotAll;throw s("Incompatible receiver, RegExp required")}}})})),B1=F(((e,t)=>{"use strict";var n,i,r=Bn(),a=yt(),s=Hn(),o=HT(),l=N1(),h=lf(),c=ia(),u=Si().get,d=kT(),p=MD(),f=h("native-string-replace",String.prototype.replace),m=RegExp.prototype.exec,g=m,v=a("".charAt),y=a("".indexOf),x=a("".replace),_=a("".slice),b=(i=/b*/g,r(m,n=/a/,"a"),r(m,i,"a"),0!==n.lastIndex||0!==i.lastIndex),M=l.BROKEN_CARET,w=void 0!==/()??/.exec("")[1];(b||w||M||d||p)&&(g=function(e){var t,n,i,a,l,h,d,p=this,S=u(p),E=s(e),T=S.raw;if(T)return T.lastIndex=p.lastIndex,t=r(g,T,E),p.lastIndex=T.lastIndex,t;var A=S.groups,C=M&&p.sticky,R=r(o,p),P=p.source,L=0,D=E;if(C&&(R=x(R,"y",""),-1===y(R,"g")&&(R+="g"),D=_(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(P="(?: "+P+")",D=" "+D,L++),n=new RegExp("^(?:"+P+")",R)),w&&(n=new RegExp("^"+P+"$(?!\\s)",R)),b&&(i=p.lastIndex),a=r(m,C?n:p,D),C?a?(a.input=_(a.input,L),a[0]=_(a[0],L),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:b&&a&&(p.lastIndex=p.global?a.index+a[0].length:i),w&&a&&a.length>1&&r(f,a[0],n,(function(){for(l=1;l<arguments.length-2;l++)void 0===arguments[l]&&(a[l]=void 0)})),a&&A)for(a.groups=h=c(null),l=0;l<A.length;l++)h[(d=A[l])[0]]=a[d[1]];return a}),t.exports=g})),qT=F((()=>{"use strict";var e=we(),t=B1();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),hJ=F((()=>{var e=Ot(),t=on(),n=Vi(),i=HT(),r=dt(),a=e.RegExp,s=a.prototype;t&&r((function(){var e=!0;try{a(".","d")}catch(t){e=!1}var t={},n="",i=e?"dgimsy":"gimsy",r=function(e,i){Object.defineProperty(t,e,{get:function(){return n+=i,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var l in e&&(o.hasIndices="d"),o)r(l,o[l]);return Object.getOwnPropertyDescriptor(s,"flags").get.call(t)!==i||n!==i}))&&n(s,"flags",{configurable:!0,get:i})})),fJ=F((()=>{var e=on(),t=N1().MISSED_STICKY,n=ls(),i=Vi(),r=Si().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"sticky",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).sticky;throw s("Incompatible receiver, RegExp required")}}})})),gJ=F((()=>{"use strict";qT();var e,t,n=we(),i=Bn(),r=Xn(),a=Cn(),s=Hn(),o=(e=!1,(t=/[ac]/).exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e),l=/./.test;n({target:"RegExp",proto:!0,forced:!o},{test:function(e){var t=a(this),n=s(e),o=t.exec;if(!r(o))return i(l,t,n);var h=i(o,t,n);return null!==h&&(a(h),!0)}})})),yJ=F((()=>{"use strict";var e=uf().PROPER,t=ei(),n=Cn(),i=Hn(),r=dt(),a=Gm(),s="toString",o=RegExp.prototype[s],l=r((function(){return"/a/b"!=o.call({source:"a",flags:"b"})})),h=e&&o.name!=s;(l||h)&&t(RegExp.prototype,s,(function(){var e=n(this);return"/"+i(e.source)+"/"+i(a(e))}),{unsafe:!0})})),EJ=F((()=>{"use strict";x1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hI())})),bJ=F((()=>{EJ()})),_J=F((()=>{"use strict";var e=we(),t=yt(),n=Mi(),i=di(),r=Hn(),a=dt(),s=t("".charAt);e({target:"String",proto:!0,forced:a((function(){return"\ud842"!=="\ud842\udfb7".at(-2)}))},{at:function(e){var t=r(n(this)),a=t.length,o=i(e),l=o>=0?o:a+o;return l<0||l>=a?void 0:s(t,l)}})})),F1=F(((e,t)=>{var n=yt(),i=di(),r=Hn(),a=Mi(),s=n("".charAt),o=n("".charCodeAt),l=n("".slice),h=function(e){return function(t,n){var h,c,u=r(a(t)),d=i(n),p=u.length;return d<0||d>=p?e?"":void 0:(h=o(u,d))<55296||h>56319||d+1===p||(c=o(u,d+1))<56320||c>57343?e?s(u,d):h:e?l(u,d,d+2):c-56320+(h-55296<<10)+65536}};t.exports={codeAt:h(!1),charAt:h(!0)}})),SJ=F((()=>{"use strict";var e=we(),t=F1().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),WT=F(((e,t)=>{var n=zm(),i=TypeError;t.exports=function(e){if(n(e))throw i("The method doesn't accept regular expressions");return e}})),jT=F(((e,t)=>{var n=$n()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[n]=!1,"/./"[e](t)}catch(e){}}return!1}})),LJ=F((()=>{"use strict";var e,t=we(),n=uu(),i=Ki().f,r=ra(),a=Hn(),s=WT(),o=Mi(),l=jT(),h=hi(),c=n("".endsWith),u=n("".slice),d=Math.min,p=l("endsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"endsWith"),e&&!e.writable))&&!p},{endsWith:function(e){var t=a(o(this));s(e);var n=arguments.length>1?arguments[1]:void 0,i=t.length,l=void 0===n?i:d(r(n),i),h=a(e);return c?c(t,h,l):u(t,l-h.length,l)===h}})})),UJ=F((()=>{var e=we(),t=yt(),n=hl(),i=RangeError,r=String.fromCharCode,a=String.fromCodePoint,s=t([].join);e({target:"String",stat:!0,arity:1,forced:!!a&&1!=a.length},{fromCodePoint:function(e){for(var t,a=[],o=arguments.length,l=0;o>l;){if(t=+arguments[l++],n(t,1114111)!==t)throw i(t+" is not a valid code point");a[l]=t<65536?r(t):r(55296+((t-=65536)>>10),t%1024+56320)}return s(a,"")}})})),FJ=F((()=>{"use strict";var e=we(),t=yt(),n=WT(),i=Mi(),r=Hn(),a=jT(),s=t("".indexOf);e({target:"String",proto:!0,forced:!a("includes")},{includes:function(e){return!!~s(r(i(this)),r(n(e)),arguments.length>1?arguments[1]:void 0)}})})),UD=F((()=>{"use strict";var e=F1().charAt,t=Hn(),n=Si(),i=K_(),r=u1(),a="String Iterator",s=n.set,o=n.getterFor(a);i(String,"String",(function(e){s(this,{type:a,string:t(e),index:0})}),(function(){var t,n=o(this),i=n.string,a=n.index;return a>=i.length?r(void 0,!0):(t=e(i,a),n.index+=t.length,r(t,!1))}))})),H1=F(((e,t)=>{"use strict";qT();var n=uu(),i=ei(),r=B1(),a=dt(),s=$n(),o=cs(),l=s("species"),h=RegExp.prototype;t.exports=function(e,t,c,u){var d=s(e),p=!a((function(){var t={};return t[d]=function(){return 7},7!=""[e](t)})),f=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[l]=function(){return n},n.flags="",n[d]=/./[d]),n.exec=function(){return t=!0,null},n[d](""),!t}));if(!p||!f||c){var m=n(/./[d]),g=t(d,""[e],(function(e,t,i,a,s){var o=n(e),l=t.exec;return l===r||l===h.exec?p&&!s?{done:!0,value:m(t,i,a)}:{done:!0,value:o(i,t,a)}:{done:!1}}));i(String.prototype,e,g[0]),i(h,d,g[1])}u&&o(h[d],"sham",!0)}})),k1=F(((e,t)=>{"use strict";var n=F1().charAt;t.exports=function(e,t,i){return t+(i?n(e,t).length:1)}})),jm=F(((e,t)=>{var n=Bn(),i=Cn(),r=Xn(),a=ls(),s=B1(),o=TypeError;t.exports=function(e,t){var l=e.exec;if(r(l)){var h=n(l,e,t);return null!==h&&i(h),h}if("RegExp"===a(e))return n(s,e,t);throw o("RegExp#exec called on incompatible receiver")}})),KJ=F((()=>{"use strict";var e=Bn(),t=H1(),n=Cn(),i=Cs(),r=ra(),a=Hn(),s=Mi(),o=ec(),l=k1(),h=jm();t("match",(function(t,c,u){return[function(n){var r=s(this),l=i(n)?void 0:o(n,t);return l?e(l,n,r):new RegExp(n)[t](a(r))},function(e){var t=n(this),i=a(e),s=u(c,t,i);if(s.done)return s.value;if(!t.global)return h(t,i);var o=t.unicode;t.lastIndex=0;for(var d,p=[],f=0;null!==(d=h(t,i));){var m=a(d[0]);p[f]=m,""===m&&(t.lastIndex=l(i,r(t.lastIndex),o)),f++}return 0===f?null:p}]}))})),oQ=F((()=>{"use strict";var e=we(),t=Bn(),n=uu(),i=Y_(),r=u1(),a=Mi(),s=ra(),o=Hn(),l=Cn(),h=Cs(),c=ls(),u=zm(),d=Gm(),p=ec(),f=ei(),m=dt(),g=$n(),v=bf(),y=k1(),x=jm(),_=Si(),b=hi(),M=g("matchAll"),w="RegExp String",S=w+" Iterator",E=_.set,T=_.getterFor(S),A=RegExp.prototype,C=TypeError,R=n("".indexOf),P=n("".matchAll),L=!!P&&!m((function(){P("a",/./)})),D=i((function(e,t,n,i){E(this,{type:S,regexp:e,string:t,global:n,unicode:i,done:!1})}),w,(function(){var e=T(this);if(e.done)return r(void 0,!0);var t=e.regexp,n=e.string,i=x(t,n);return null===i?(e.done=!0,r(void 0,!0)):e.global?(""===o(i[0])&&(t.lastIndex=y(n,s(t.lastIndex),e.unicode)),r(i,!1)):(e.done=!0,r(i,!1))})),I=function(e){var t,n,i,r=l(this),a=o(e),h=v(r,RegExp),c=o(d(r));return t=new h(h===RegExp?r.source:r,c),n=!!~R(c,"g"),i=!!~R(c,"u"),t.lastIndex=s(r.lastIndex),new D(t,a,n,i)};e({target:"String",proto:!0,forced:L},{matchAll:function(e){var n,i,r,s,l=a(this);if(h(e)){if(L)return P(l,e)}else{if(u(e)&&(n=o(a(d(e))),!~R(n,"g")))throw C("`.matchAll` does not allow non-global regexes");if(L)return P(l,e);if(void 0===(r=p(e,M))&&b&&"RegExp"==c(e)&&(r=I),r)return t(r,e,l)}return i=o(l),s=new RegExp(e,"g"),b?t(I,s,i):s[M](i)}}),b||M in A||f(A,M,I)})),GD=F(((e,t)=>{var n=Jl();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)})),cQ=F((()=>{"use strict";var e=we(),t=gT().end;e({target:"String",proto:!0,forced:GD()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),uQ=F((()=>{"use strict";var e=we(),t=gT().start;e({target:"String",proto:!0,forced:GD()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),pQ=F((()=>{var e=we(),t=yt(),n=Ni(),i=xr(),r=Hn(),a=_r(),s=t([].push),o=t([].join);e({target:"String",stat:!0},{raw:function(e){var t=n(i(e).raw),l=a(t);if(!l)return"";for(var h=arguments.length,c=[],u=0;;){if(s(c,r(t[u++])),u===l)return o(c,"");u<h&&s(c,r(arguments[u]))}}})})),mQ=F((()=>{we()({target:"String",proto:!0},{repeat:g1()})})),XD=F(((e,t)=>{var n=yt(),i=xr(),r=Math.floor,a=n("".charAt),s=n("".replace),o=n("".slice),l=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,h=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,c,u,d){var p=n+e.length,f=c.length,m=h;return void 0!==u&&(u=i(u),m=l),s(d,m,(function(i,s){var l;switch(a(s,0)){case"$":return"$";case"&":return e;case"`":return o(t,0,n);case"'":return o(t,p);case"<":l=u[o(s,1,-1)];break;default:var h=+s;if(0===h)return i;if(h>f){var d=r(h/10);return 0===d?i:d<=f?void 0===c[d-1]?a(s,1):c[d-1]+a(s,1):i}l=c[h-1]}return void 0===l?"":l}))}})),bQ=F((()=>{"use strict";var e=Oa(),t=Bn(),n=yt(),i=H1(),r=dt(),a=Cn(),s=Xn(),o=Cs(),l=di(),h=ra(),c=Hn(),u=Mi(),d=k1(),p=ec(),f=XD(),m=jm(),g=$n()("replace"),v=Math.max,y=Math.min,x=n([].concat),_=n([].push),b=n("".indexOf),M=n("".slice),w=function(e){return void 0===e?e:String(e)},S="$0"==="a".replace(/./,"$0"),E=!!/./[g]&&""===/./[g]("a","$0");i("replace",(function(n,i,r){var S=E?"$":"$0";return[function(e,n){var r=u(this),a=o(e)?void 0:p(e,g);return a?t(a,e,r,n):t(i,c(r),e,n)},function(t,n){var o=a(this),u=c(t);if("string"==typeof n&&-1===b(n,S)&&-1===b(n,"$<")){var p=r(i,o,u,n);if(p.done)return p.value}var g=s(n);g||(n=c(n));var E=o.global;if(E){var T=o.unicode;o.lastIndex=0}for(var A=[];;){var C=m(o,u);if(null===C||(_(A,C),!E))break;""===c(C[0])&&(o.lastIndex=d(u,h(o.lastIndex),T))}for(var R="",P=0,L=0;L<A.length;L++){for(var D=c((C=A[L])[0]),I=v(y(l(C.index),u.length),0),O=[],U=1;U<C.length;U++)_(O,w(C[U]));var N=C.groups;if(g){var F=x([D],O,I,u);void 0!==N&&_(F,N);var k=c(e(n,void 0,F))}else k=f(D,u,I,O,N,n);I>=P&&(R+=M(u,P,I)+k,P=I+D.length)}return R+M(u,P)}]}),!!r((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!S||E)})),SQ=F((()=>{"use strict";var e=we(),t=Bn(),n=yt(),i=Mi(),r=Xn(),a=Cs(),s=zm(),o=Hn(),l=ec(),h=Gm(),c=XD(),u=$n(),d=hi(),p=u("replace"),f=TypeError,m=n("".indexOf),g=n("".replace),v=n("".slice),y=Math.max,x=function(e,t,n){return n>e.length?-1:""===t?n:m(e,t,n)};e({target:"String",proto:!0},{replaceAll:function(e,n){var u,_,b,M,w,S,E,T,A,C=i(this),R=0,P=0,L="";if(!a(e)){if((u=s(e))&&(_=o(i(h(e))),!~m(_,"g")))throw f("`.replaceAll` does not allow non-global regexes");if(b=l(e,p))return t(b,e,C,n);if(d&&u)return g(o(C),e,n)}for(M=o(C),w=o(e),(S=r(n))||(n=o(n)),E=w.length,T=y(1,E),R=x(M,w,0);-1!==R;)A=S?o(n(w,R,M)):c(w,M,R,[],void 0,n),L+=v(M,P,R)+A,P=R+E,R=x(M,w,R+T);return P<M.length&&(L+=v(M,P)),L}})})),CQ=F((()=>{"use strict";var e=Bn(),t=H1(),n=Cn(),i=Cs(),r=Mi(),a=NI(),s=Hn(),o=ec(),l=jm();t("search",(function(t,h,c){return[function(n){var a=r(this),l=i(n)?void 0:o(n,t);return l?e(l,n,a):new RegExp(n)[t](s(a))},function(e){var t=n(this),i=s(e),r=c(h,t,i);if(r.done)return r.value;var o=t.lastIndex;a(o,0)||(t.lastIndex=0);var u=l(t,i);return a(t.lastIndex,o)||(t.lastIndex=o),null===u?-1:u.index}]}))})),NQ=F((()=>{"use strict";var e=Oa(),t=Bn(),n=yt(),i=H1(),r=Cn(),a=Cs(),s=zm(),o=Mi(),l=bf(),h=k1(),c=ra(),u=Hn(),d=ec(),p=gm(),f=jm(),m=B1(),g=N1(),v=dt(),y=g.UNSUPPORTED_Y,x=4294967295,_=Math.min,b=[].push,M=n(/./.exec),w=n(b),S=n("".slice);i("split",(function(n,i,g){var v;return v="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(n,r){var a=u(o(this)),l=void 0===r?x:r>>>0;if(0===l)return[];if(void 0===n)return[a];if(!s(n))return t(i,a,n,l);for(var h,c,d,f=[],g=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(n.sticky?"y":""),v=0,y=new RegExp(n.source,g+"g");(h=t(m,y,a))&&!((c=y.lastIndex)>v&&(w(f,S(a,v,h.index)),h.length>1&&h.index<a.length&&e(b,f,p(h,1)),d=h[0].length,v=c,f.length>=l));)y.lastIndex===h.index&&y.lastIndex++;return v===a.length?(d||!M(y,""))&&w(f,""):w(f,S(a,v)),f.length>l?p(f,0,l):f}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t(i,this,e,n)}:i,[function(e,i){var r=o(this),s=a(e)?void 0:d(e,n);return s?t(s,e,r,i):t(v,u(r),e,i)},function(e,t){var n=r(this),a=u(e),s=g(v,n,a,t,v!==i);if(s.done)return s.value;var o=l(n,RegExp),d=n.unicode,p=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(y?"g":"y"),m=new o(y?"^(?:"+n.source+")":n,p),b=void 0===t?x:t>>>0;if(0===b)return[];if(0===a.length)return null===f(m,a)?[a]:[];for(var M=0,E=0,T=[];E<a.length;){m.lastIndex=y?0:E;var A,C=f(m,y?S(a,E):a);if(null===C||(A=_(c(m.lastIndex+(y?E:0)),a.length))===M)E=h(a,E,d);else{if(w(T,S(a,M,E)),T.length===b)return T;for(var R=1;R<=C.length-1;R++)if(w(T,C[R]),T.length===b)return T;E=M=A}}return w(T,S(a,M)),T}]}),!!v((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),y)})),kQ=F((()=>{"use strict";var e,t=we(),n=uu(),i=Ki().f,r=ra(),a=Hn(),s=WT(),o=Mi(),l=jT(),h=hi(),c=n("".startsWith),u=n("".slice),d=Math.min,p=l("startsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"startsWith"),e&&!e.writable))&&!p},{startsWith:function(e){var t=a(o(this));s(e);var n=r(d(arguments.length>1?arguments[1]:void 0,t.length)),i=a(e);return c?c(t,i,n):u(t,n,n+i.length)===i}})})),zQ=F((()=>{"use strict";var e=we(),t=yt(),n=Mi(),i=di(),r=Hn(),a=t("".slice),s=Math.max,o=Math.min;e({target:"String",proto:!0,forced:!"".substr||"b"!=="ab".substr(-1)},{substr:function(e,t){var l,h,c=r(n(this)),u=c.length,d=i(e);return d===1/0&&(d=0),d<0&&(d=s(u+d,0)),(l=void 0===t?u:i(t))<=0||l===1/0||d>=(h=o(d+l,u))?"":a(c,d,h)}})})),KT=F(((e,t)=>{var n=uf().PROPER,i=dt(),r=T1();t.exports=function(e){return i((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||n&&r[e].name!==e}))}})),jQ=F((()=>{"use strict";var e=we(),t=wf().trim;e({target:"String",proto:!0,forced:KT()("trim")},{trim:function(){return t(this)}})})),QD=F(((e,t)=>{"use strict";var n=wf().end,i=KT();t.exports=i("trimEnd")?function(){return n(this)}:"".trimEnd})),$Q=F((()=>{var e=we(),t=QD();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),KQ=F((()=>{$Q();var e=we(),t=QD();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),eL=F(((e,t)=>{"use strict";var n=wf().start,i=KT();t.exports=i("trimStart")?function(){return n(this)}:"".trimStart})),eee=F((()=>{var e=we(),t=eL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),nee=F((()=>{eee();var e=we(),t=eL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),la=F(((e,t)=>{var n=yt(),i=Mi(),r=Hn(),a=/"/g,s=n("".replace);t.exports=function(e,t,n,o){var l=r(i(e)),h="<"+t;return""!==n&&(h+=" "+n+'="'+s(r(o),a,"&quot;")+'"'),h+">"+l+"</"+t+">"}})),ca=F(((e,t)=>{var n=dt();t.exports=function(e){return n((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),aee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),oee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("big")},{big:function(){return t(this,"big","","")}})})),lee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("blink")},{blink:function(){return t(this,"blink","","")}})})),cee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("bold")},{bold:function(){return t(this,"b","","")}})})),uee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),hee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),dee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),fee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("italics")},{italics:function(){return t(this,"i","","")}})})),pee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("link")},{link:function(e){return t(this,"a","href",e)}})})),mee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("small")},{small:function(){return t(this,"small","","")}})})),gee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("strike")},{strike:function(){return t(this,"strike","","")}})})),vee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("sub")},{sub:function(){return t(this,"sub","","")}})})),xee=F((()=>{"use strict";var e=we(),t=la();e({target:"String",proto:!0,forced:ca()("sup")},{sup:function(){return t(this,"sup","","")}})})),JT=F(((e,t)=>{var n=Ot(),i=dt(),r=o1(),a=kn().NATIVE_ARRAY_BUFFER_VIEWS,s=n.ArrayBuffer,o=n.Int8Array;t.exports=!a||!i((function(){o(1)}))||!i((function(){new o(-1)}))||!r((function(e){new o,new o(null),new o(1.5),new o(e)}),!0)||i((function(){return 1!==new o(new s(2),1,void 0).length}))})),_ee=F(((e,t)=>{var n=di(),i=RangeError;t.exports=function(e){var t=n(e);if(t<0)throw i("The argument can't be less than 0");return t}})),nL=F(((e,t)=>{var n=_ee(),i=RangeError;t.exports=function(e,t){var r=n(e);if(r%t)throw i("Wrong offset");return r}})),rL=F(((e,t)=>{var n=dl();t.exports=function(e){var t=n(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),QT=F(((e,t)=>{var n=q0(),i=TypeError;t.exports=function(e){var t=n(e,"number");if("number"==typeof t)throw i("Can't convert number to bigint");return BigInt(t)}})),iL=F(((e,t)=>{var n=mo(),i=Bn(),r=mT(),a=xr(),s=_r(),o=i1(),l=_m(),h=G_(),c=rL(),u=kn().aTypedArrayConstructor,d=QT();t.exports=function(e){var t,p,f,m,g,v,y,x,_=r(this),b=a(e),M=arguments.length,w=M>1?arguments[1]:void 0,S=void 0!==w,E=l(b);if(E&&!h(E))for(x=(y=o(b,E)).next,b=[];!(v=i(x,y)).done;)b.push(v.value);for(S&&M>2&&(w=n(w,arguments[2])),p=s(b),f=new(u(_))(p),m=c(f),t=0;p>t;t++)g=S?w(b[t],t):b[t],f[t]=m?d(g):+g;return f}})),lc=F(((e,t)=>{"use strict";var n=we(),i=Ot(),r=Bn(),a=on(),s=JT(),o=kn(),l=m1(),h=ml(),c=Da(),u=cs(),d=ST(),p=ra(),f=LP(),m=nL(),g=lu(),v=ar(),y=dl(),x=Yn(),_=Mh(),b=ia(),M=La(),w=fl(),S=cu().f,E=iL(),T=zi().forEach,A=yf(),C=Vi(),R=Yr(),P=Ki(),L=Si(),D=gf(),I=L.get,O=L.set,U=L.enforce,N=R.f,F=P.f,k=Math.round,B=i.RangeError,z=l.ArrayBuffer,V=z.prototype,H=l.DataView,G=o.NATIVE_ARRAY_BUFFER_VIEWS,j=o.TYPED_ARRAY_TAG,W=o.TypedArray,X=o.TypedArrayPrototype,q=o.aTypedArrayConstructor,Y=o.isTypedArray,$="BYTES_PER_ELEMENT",K="Wrong length",Z=function(e,t){q(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},J=function(e,t){C(e,t,{configurable:!0,get:function(){return I(this)[t]}})},Q=function(e){var t;return M(V,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return Y(e)&&!_(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?c(2,e[t]):F(e,t)},ne=function(e,t,n){return t=g(t),!(ee(e,t)&&x(n)&&v(n,"value"))||v(n,"get")||v(n,"set")||n.configurable||v(n,"writable")&&!n.writable||v(n,"enumerable")&&!n.enumerable?N(e,t,n):(e[t]=n.value,e)};a?(G||(P.f=te,R.f=ne,J(X,"buffer"),J(X,"byteOffset"),J(X,"byteLength"),J(X,"length")),n({target:"Object",stat:!0,forced:!G},{getOwnPropertyDescriptor:te,defineProperty:ne}),t.exports=function(e,t,a){var o=e.match(/\d+/)[0]/8,l=e+(a?"Clamped":"")+"Array",c="get"+e,d="set"+e,g=i[l],v=g,y=v&&v.prototype,_={},M=function(e,t){N(e,t,{get:function(){return function(e,t){var n=I(e);return n.view[c](t*o+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var i=I(e);a&&(n=(n=k(n))<0?0:n>255?255:255&n),i.view[d](t*o+i.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};G?s&&(v=t((function(e,t,n,i){return h(e,y),D(x(t)?Q(t)?void 0!==i?new g(t,m(n,o),i):void 0!==n?new g(t,m(n,o)):new g(t):Y(t)?Z(v,t):r(E,v,t):new g(f(t)),e,v)})),w&&w(v,W),T(S(g),(function(e){e in v||u(v,e,g[e])})),v.prototype=y):(v=t((function(e,t,n,i){h(e,y);var a,s,l,c=0,u=0;if(x(t)){if(!Q(t))return Y(t)?Z(v,t):r(E,v,t);a=t,u=m(n,o);var d=t.byteLength;if(void 0===i){if(d%o||(s=d-u)<0)throw B(K)}else if((s=p(i)*o)+u>d)throw B(K);l=s/o}else l=f(t),a=new z(s=l*o);for(O(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new H(a)});c<l;)M(e,c++)})),w&&w(v,W),y=v.prototype=b(X)),y.constructor!==v&&u(y,"constructor",v),U(y).TypedArrayConstructor=v,j&&u(y,j,l);var C=v!=g;_[l]=v,n({global:!0,constructor:!0,forced:C,sham:!G},_),$ in v||u(v,$,o),$ in y||u(y,$,o),A(l)}):t.exports=function(){}})),jee=F((()=>{lc()("Float32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Xee=F((()=>{lc()("Float64",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Yee=F((()=>{lc()("Int8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),$ee=F((()=>{lc()("Int16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Zee=F((()=>{lc()("Int32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Kee=F((()=>{lc()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Jee=F((()=>{lc()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}),!0)})),Qee=F((()=>{lc()("Uint16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),ete=F((()=>{lc()("Uint32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),nte=F((()=>{"use strict";var e=kn(),t=_r(),n=di(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("at",(function(e){var r=i(this),a=t(r),s=n(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}))})),ite=F((()=>{"use strict";var e=yt(),t=kn(),n=e(cP()),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return n(i(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),ate=F((()=>{"use strict";var e=kn(),t=zi().every,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),lte=F((()=>{"use strict";var e=kn(),t=X_(),n=QT(),i=dl(),r=Bn(),a=yt(),s=dt(),o=e.aTypedArray,l=e.exportTypedArrayMethod,h=a("".slice);l("fill",(function(e){var a=arguments.length;o(this);var s="Big"===h(i(this),0,3)?n(e):+e;return r(t,this,s,a>1?arguments[1]:void 0,a>2?arguments[2]:void 0)}),s((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})))})),X1=F(((e,t)=>{var n=kn(),i=bf(),r=n.aTypedArrayConstructor,a=n.getTypedArrayConstructor;t.exports=function(e){return r(i(e,a(e)))}})),dte=F(((e,t)=>{var n=nT(),i=X1();t.exports=function(e,t){return n(i(e),t)}})),pte=F((()=>{"use strict";var e=kn(),t=zi().filter,n=dte(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("filter",(function(e){var r=t(i(this),e,arguments.length>1?arguments[1]:void 0);return n(this,r)}))})),gte=F((()=>{"use strict";var e=kn(),t=zi().find,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),xte=F((()=>{"use strict";var e=kn(),t=zi().findIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Ete=F((()=>{"use strict";var e=kn(),t=a1().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),_te=F((()=>{"use strict";var e=kn(),t=a1().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),wte=F((()=>{"use strict";var e=kn(),t=zi().forEach,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Mte=F((()=>{"use strict";var e=JT();(0,kn().exportTypedArrayStaticMethod)("from",iL(),e)})),Rte=F((()=>{"use strict";var e=kn(),t=fm().includes,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Cte=F((()=>{"use strict";var e=kn(),t=fm().indexOf,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Ote=F((()=>{"use strict";var e=Ot(),t=dt(),n=yt(),i=kn(),r=h1(),a=$n()("iterator"),s=e.Uint8Array,o=n(r.values),l=n(r.keys),h=n(r.entries),c=i.aTypedArray,u=i.exportTypedArrayMethod,d=s&&s.prototype,p=!t((function(){d[a].call([1])})),f=!!d&&d.values&&d[a]===d.values&&"values"===d.values.name,m=function(){return o(c(this))};u("entries",(function(){return h(c(this))}),p),u("keys",(function(){return l(c(this))}),p),u("values",m,p||!f,{name:"values"}),u(a,m,p||!f,{name:"values"})})),Ute=F((()=>{"use strict";var e=kn(),t=yt(),n=e.aTypedArray,i=e.exportTypedArrayMethod,r=t([].join);i("join",(function(e){return r(n(this),e)}))})),Fte=F((()=>{"use strict";var e=kn(),t=Oa(),n=wP(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(n,i(this),r>1?[e,arguments[1]]:[e])}))})),kte=F((()=>{"use strict";var e=kn(),t=zi().map,n=X1(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("map",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(n(e))(t)}))}))})),zte=F((()=>{"use strict";var e=kn(),t=JT(),n=e.aTypedArrayConstructor;(0,e.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,i=new(n(this))(t);t>e;)i[e]=arguments[e++];return i}),t)})),qte=F((()=>{"use strict";var e=kn(),t=d1().left,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduce",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),jte=F((()=>{"use strict";var e=kn(),t=d1().right,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduceRight",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),Yte=F((()=>{"use strict";var e=kn(),t=e.aTypedArray,n=e.exportTypedArrayMethod,i=Math.floor;n("reverse",(function(){for(var e,n=this,r=t(n).length,a=i(r/2),s=0;s<a;)e=n[s],n[s++]=n[--r],n[r]=e;return n}))})),ene=F((()=>{"use strict";var e=Ot(),t=Bn(),n=kn(),i=_r(),r=nL(),a=xr(),s=dt(),o=e.RangeError,l=e.Int8Array,h=l&&l.prototype,c=h&&h.set,u=n.aTypedArray,d=n.exportTypedArrayMethod,p=!s((function(){var e=new Uint8ClampedArray(2);return t(c,e,{length:1,0:3},1),3!==e[1]})),f=p&&n.NATIVE_ARRAY_BUFFER_VIEWS&&s((function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));d("set",(function(e){u(this);var n=r(arguments.length>1?arguments[1]:void 0,1),s=a(e);if(p)return t(c,this,s,n);var l=this.length,h=i(s),d=0;if(h+n>l)throw o("Wrong length");for(;d<h;)this[n+d]=s[d++]}),!p||f)})),nne=F((()=>{"use strict";var e=kn(),t=X1(),n=dt(),i=Ah(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("slice",(function(e,n){for(var a=i(r(this),e,n),s=t(this),o=0,l=a.length,h=new s(l);l>o;)h[o]=a[o++];return h}),n((function(){new Int8Array(1).slice()})))})),ine=F((()=>{"use strict";var e=kn(),t=zi().some,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),une=F((()=>{"use strict";var e=Ot(),t=uu(),n=dt(),i=ui(),r=eT(),a=kn(),s=RP(),o=AP(),l=Ql(),h=tT(),c=a.aTypedArray,u=a.exportTypedArrayMethod,d=e.Uint16Array,p=d&&t(d.prototype.sort),f=!(!p||n((function(){p(new d(2),null)}))&&n((function(){p(new d(2),{})}))),m=!!p&&!n((function(){if(l)return l<74;if(s)return s<67;if(o)return!0;if(h)return h<602;var e,t,n=new d(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(p(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==i[e])return!0}));u("sort",(function(e){return void 0!==e&&i(e),m?p(this,e):r(c(this),(t=e,function(e,n){return void 0!==t?+t(e,n)||0:n!=n?-1:e!=e?1:0===e&&0===n?1/e>0&&1/n<0?1:-1:e>n}));var t}),!m||f)})),fne=F((()=>{"use strict";var e=kn(),t=ra(),n=hl(),i=X1(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("subarray",(function(e,a){var s=r(this),o=s.length,l=n(e,o);return new(i(s))(s.buffer,s.byteOffset+l*s.BYTES_PER_ELEMENT,t((void 0===a?o:n(a,o))-l))}))})),xne=F((()=>{"use strict";var e=Ot(),t=Oa(),n=kn(),i=dt(),r=Ah(),a=e.Int8Array,s=n.aTypedArray,o=n.exportTypedArrayMethod,l=[].toLocaleString,h=!!a&&i((function(){l.call(new a(1))}));o("toLocaleString",(function(){return t(l,h?r(s(this)):s(this),r(arguments))}),i((function(){return[1,2].toLocaleString()!=new a([1,2]).toLocaleString()}))||!i((function(){a.prototype.toLocaleString.call([1,2])})))})),yne=F((()=>{"use strict";var e=IP(),t=kn(),n=t.aTypedArray,i=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;i("toReversed",(function(){return e(n(this),r(this))}))})),Ene=F((()=>{"use strict";var e=kn(),t=yt(),n=ui(),i=nT(),r=e.aTypedArray,a=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,o=t(e.TypedArrayPrototype.sort);s("toSorted",(function(e){void 0!==e&&n(e);var t=r(this),s=i(a(t),t);return o(s,e)}))})),_ne=F((()=>{"use strict";var e=kn().exportTypedArrayMethod,t=dt(),n=Ot(),i=yt(),r=n.Uint8Array,a=r&&r.prototype||{},s=[].toString,o=i([].join);t((function(){s.call({})}))&&(s=function(){return o(this)});var l=a.toString!=s;e("toString",s,l)})),Tne=F((()=>{"use strict";var e=DP(),t=kn(),n=rL(),i=di(),r=QT(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=i(t),c=n(l)?r(o):+o;return e(l,s(l),h,c)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Ane=F((()=>{"use strict";var e=we(),t=yt(),n=Hn(),i=String.fromCharCode,r=t("".charAt),a=t(/./.exec),s=t("".slice),o=/^[\da-f]{2}$/i,l=/^[\da-f]{4}$/i;e({global:!0},{unescape:function(e){for(var t,h,c=n(e),u="",d=c.length,p=0;p<d;){if("%"===(t=r(c,p++)))if("u"===r(c,p)){if(h=s(c,p+1,p+5),a(l,h)){u+=i(parseInt(h,16)),p+=5;continue}}else if(h=s(c,p,p+2),a(o,h)){u+=i(parseInt(h,16)),p+=2;continue}u+=t}return u}})})),RL=F(((e,t)=>{"use strict";var n=yt(),i=Mm(),r=Uh().getWeakData,a=ml(),s=Cn(),o=Cs(),l=Yn(),h=pl(),c=zi(),u=ar(),d=Si(),p=d.set,f=d.getterFor,m=c.find,g=c.findIndex,v=n([].splice),y=0,x=function(e){return e.frozen||(e.frozen=new _)},_=function(){this.entries=[]},b=function(e,t){return m(e.entries,(function(e){return e[0]===t}))};_.prototype={get:function(e){var t=b(this,e);if(t)return t[1]},has:function(e){return!!b(this,e)},set:function(e,t){var n=b(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=g(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},t.exports={getConstructor:function(e,t,n,c){var d=e((function(e,i){a(e,m),p(e,{type:t,id:y++,frozen:void 0}),o(i)||h(i,e[c],{that:e,AS_ENTRIES:n})})),m=d.prototype,g=f(t),v=function(e,t,n){var i=g(e),a=r(s(t),!0);return!0===a?x(i).set(t,n):a[i.id]=n,e};return i(m,{delete:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).delete(e):n&&u(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).has(e):n&&u(n,t.id)}}),i(m,n?{get:function(e){var t=g(this);if(l(e)){var n=r(e);return!0===n?x(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return v(this,e,t)}}:{add:function(e){return v(this,e,!0)}}),d}}})),qne=F((()=>{"use strict";var e,t,n,i,r=Tf(),a=Ot(),s=yt(),o=Mm(),l=Uh(),h=x1(),c=RL(),u=Yn(),d=Si().enforce,p=dt(),f=h2(),m=Object,g=Array.isArray,v=m.isExtensible,y=m.isFrozen,x=m.isSealed,_=m.freeze,b=m.seal,M={},w={},S=!a.ActiveXObject&&"ActiveXObject"in a,E=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},T=h("WeakMap",E,c),A=T.prototype,C=s(A.set);f&&(S?(e=c.getConstructor(E,"WeakMap",!0),l.enable(),t=s(A.delete),n=s(A.has),i=s(A.get),o(A,{delete:function(n){if(u(n)&&!v(n)){var i=d(this);return i.frozen||(i.frozen=new e),t(this,n)||i.frozen.delete(n)}return t(this,n)},has:function(t){if(u(t)&&!v(t)){var i=d(this);return i.frozen||(i.frozen=new e),n(this,t)||i.frozen.has(t)}return n(this,t)},get:function(t){if(u(t)&&!v(t)){var r=d(this);return r.frozen||(r.frozen=new e),n(this,t)?i(this,t):r.frozen.get(t)}return i(this,t)},set:function(t,i){if(u(t)&&!v(t)){var r=d(this);r.frozen||(r.frozen=new e),n(this,t)?C(this,t,i):r.frozen.set(t,i)}else C(this,t,i);return this}})):r&&p((function(){var e=_([]);return C(new T,e,1),!y(e)}))&&o(A,{set:function(e,t){var n;return g(e)&&(y(e)?n=M:x(e)&&(n=w)),C(this,e,t),n==M&&_(e),n==w&&b(e),this}}))})),Wne=F((()=>{qne()})),jne=F((()=>{"use strict";x1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),RL())})),Xne=F((()=>{jne()})),PL=F(((e,t)=>{var n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(n=0;n<66;n++)r[i.charAt(n)]=n;t.exports={itoc:i,ctoi:r}})),nre=F((()=>{var e=we(),t=Ot(),n=Xr(),i=yt(),r=Bn(),a=dt(),s=Hn(),o=ar(),l=Eu(),h=PL().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,p=n("atob"),f=String.fromCharCode,m=i("".charAt),g=i("".replace),v=i(c.exec),y=a((function(){return""!==p(" ")})),x=!a((function(){p("a")})),_=!y&&!x&&!a((function(){p()})),b=!y&&!x&&1!==p.length;e({global:!0,bind:!0,enumerable:!0,forced:y||x||_||b},{atob:function(e){if(l(arguments.length,1),_||b)return r(p,t,e);var i,a,y=g(s(e),u,""),x="",M=0,w=0;if(y.length%4==0&&(y=g(y,d,"")),y.length%4==1||v(c,y))throw new(n("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;i=m(y,M++);)o(h,i)&&(a=w%4?64*a+h[i]:h[i],w++%4&&(x+=f(255&a>>(-2*w&6))));return x}})})),hre=F((()=>{var e=we(),t=Ot(),n=Xr(),i=yt(),r=Bn(),a=dt(),s=Hn(),o=Eu(),l=PL().itoc,h=n("btoa"),c=i("".charAt),u=i("".charCodeAt),d=!!h&&!a((function(){h()})),p=!!h&&a((function(){return"bnVsbA=="!==h(null)})),f=!!h&&1!==h.length;e({global:!0,bind:!0,enumerable:!0,forced:d||p||f},{btoa:function(e){if(o(arguments.length,1),d||p||f)return r(h,t,s(e));for(var i,a,m=s(e),g="",v=0,y=l;c(m,v)||(y="=",v%1);){if((a=u(m,v+=3/4))>255)throw new(n("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");g+=c(y,63&(i=i<<8|a)>>8-v%1*8)}return g}})})),UL=F(((e,t)=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}})),FL=F(((e,t)=>{var n=W0()("span").classList,i=n&&n.constructor&&n.constructor.prototype;t.exports=i===Object.prototype?void 0:i})),xre=F((()=>{var e,t=Ot(),n=UL(),i=FL(),r=fP(),a=cs(),s=function(e){if(e&&e.forEach!==r)try{a(e,"forEach",r)}catch(t){e.forEach=r}};for(e in n)n[e]&&s(t[e]&&t[e].prototype);s(i)})),wre=F((()=>{var e,t=Ot(),n=UL(),i=FL(),r=h1(),a=cs(),s=$n(),o=s("iterator"),l=s("toStringTag"),h=r.values,c=function(e,t){if(e){if(e[o]!==h)try{a(e,o,h)}catch(t){e[o]=h}if(e[l]||a(e,l,t),n[t])for(var i in r)if(e[i]!==r[i])try{a(e,i,r[i])}catch(t){e[i]=r[i]}}};for(e in n)c(t[e]&&t[e].prototype,e);c(i,"DOMTokenList")})),Sre=F(((e,t)=>{var n=ic();t.exports=function(e){try{if(n)return Function('return require("'+e+'")')()}catch(e){}}})),GL=F(((e,t)=>{t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}})),Fre=F((()=>{"use strict";var e=we(),t=Sre(),n=Xr(),i=dt(),r=ia(),a=Da(),s=Yr().f,o=ei(),l=Vi(),h=ar(),c=ml(),u=Cn(),d=Q2(),p=Em(),f=GL(),m=H_(),g=Si(),v=on(),y=hi(),x="DOMException",_="DATA_CLONE_ERR",b=n("Error"),M=n(x)||function(){try{(new(n("MessageChannel")||t("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==_&&25==e.code)return e.constructor}}(),w=M&&M.prototype,S=b.prototype,E=g.set,T=g.getterFor(x),A="stack"in b(x),C=function(e){return h(f,e)&&f[e].m?f[e].c:0},R=function(){c(this,P);var e=arguments.length,t=p(e<1?void 0:arguments[0]),n=p(e<2?void 0:arguments[1],"Error"),i=C(n);if(E(this,{type:x,name:n,message:t,code:i}),v||(this.name=n,this.message=t,this.code=i),A){var r=b(t);r.name=x,s(this,"stack",a(1,m(r.stack,1)))}},P=R.prototype=r(S),L=function(e){return{enumerable:!0,configurable:!0,get:e}},D=function(e){return L((function(){return T(this)[e]}))};v&&(l(P,"code",D("code")),l(P,"message",D("message")),l(P,"name",D("name"))),s(P,"constructor",a(1,R));var I=i((function(){return!(new M instanceof b)})),O=I||i((function(){return S.toString!==d||"2: 1"!==String(new M(1,2))})),U=I||i((function(){return 25!==new M(1,"DataCloneError").code})),N=I||25!==M[_]||25!==w[_],F=y?O||U||N:I;e({global:!0,constructor:!0,forced:F},{DOMException:F?R:M});var k,B,z,V,H=n(x),G=H.prototype;for(V in O&&(y||M===H)&&o(G,"toString",d),U&&v&&M===H&&l(G,"code",L((function(){return C(u(this).name)}))),f)h(f,V)&&(B=(k=f[V]).s,z=a(6,k.c),h(H,B)||s(H,B,z),h(G,B)||s(G,B,z))})),Wre=F((()=>{"use strict";var e=we(),t=Ot(),n=Xr(),i=Da(),r=Yr().f,a=ar(),s=ml(),o=gf(),l=Em(),h=GL(),c=H_(),u=on(),d=hi(),p="DOMException",f=n("Error"),m=n(p),g=function(){s(this,v);var e=arguments.length,t=l(e<1?void 0:arguments[0]),n=l(e<2?void 0:arguments[1],"Error"),a=new m(t,n),h=f(t);return h.name=p,r(a,"stack",i(1,c(h.stack,1))),o(a,this,g),a},v=g.prototype=m.prototype,y="stack"in f(p),x="stack"in new m(1,2),_=m&&u&&Object.getOwnPropertyDescriptor(t,p),b=!(!_||_.writable&&_.configurable),M=y&&!b&&!x;e({global:!0,constructor:!0,forced:d||M},{DOMException:M?g:m});var w,S,E,T=n(p),A=T.prototype;if(A.constructor!==T)for(E in d||r(A,"constructor",i(1,T)),h)a(h,E)&&(a(T,S=(w=h[E]).s)||r(T,S,i(6,w.c)))})),Xre=F((()=>{var e=Xr(),t="DOMException";sa()(e(t),t)})),$re=F((()=>{var e=we(),t=Ot(),n=P1().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==n},{clearImmediate:n})})),Kre=F(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),Mw=F(((e,t)=>{"use strict";var n,i=Ot(),r=Oa(),a=Xn(),s=Kre(),o=Jl(),l=Ah(),h=Eu(),c=i.Function,u=/MSIE .\./.test(o)||s&&((n=i.Bun.version.split(".")).length<3||0==n[0]&&(n[1]<3||3==n[1]&&0==n[2]));t.exports=function(e,t){var n=t?2:1;return u?function(i,s){var o=h(arguments.length,1)>n,u=a(i)?i:c(i),d=o?l(arguments,n):[],p=o?function(){r(u,this,d)}:u;return t?e(p,s):e(p)}:e}})),rie=F((()=>{var e=we(),t=Ot(),n=P1().set,i=Mw(),r=t.setImmediate?i(n,!1):n;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),iie=F((()=>{$re(),rie()})),sie=F((()=>{var e=we(),t=Ot(),n=tD(),i=ui(),r=Eu(),a=ic(),s=t.process;e({global:!0,enumerable:!0,dontCallGetSet:!0},{queueMicrotask:function(e){r(arguments.length,1),i(e);var t=a&&s.domain;n(t?t.bind(e):e)}})})),oie=F((()=>{"use strict";var e,t=we(),n=Ot(),i=Vi(),r=on(),a=TypeError,s=Object.defineProperty,o=n.self!==n;try{r?(e=Object.getOwnPropertyDescriptor(n,"self"),(o||!e||!e.get||!e.enumerable)&&i(n,"self",{get:function(){return n},set:function(e){if(this!==n)throw a("Illegal invocation");s(n,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})):t({global:!0,simple:!0,forced:o},{self:n})}catch(e){}})),cie=F(((e,t)=>{var n=yt(),i=Map.prototype;t.exports={Map:Map,set:n(i.set),get:n(i.get),has:n(i.has),remove:n(i.delete),proto:i}})),hie=F(((e,t)=>{var n=yt(),i=Set.prototype;t.exports={Set:Set,add:n(i.add),has:n(i.has),remove:n(i.delete),proto:i,$has:i.has,$keys:i.keys}})),pie=F(((e,t)=>{var n=Ot(),i=dt(),r=Ql(),a=nD(),s=IT(),o=ic(),l=n.structuredClone;t.exports=!!l&&!i((function(){if(s&&r>92||o&&r>94||a&&r>97)return!1;var e=new ArrayBuffer(8),t=l(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength}))})),wie=F((()=>{var e,t=hi(),n=we(),i=Ot(),r=Xr(),a=yt(),s=dt(),o=cf(),l=Xn(),h=df(),c=Cs(),u=Yn(),d=Mh(),p=pl(),f=Cn(),m=dl(),g=ar(),v=tc(),y=cs(),x=_r(),_=Eu(),b=Gm(),M=cie(),w=hie(),S=Y2(),E=pie(),T=i.Object,A=i.Array,C=i.Date,R=i.Error,P=i.EvalError,L=i.RangeError,D=i.ReferenceError,I=i.SyntaxError,O=i.TypeError,U=i.URIError,N=i.PerformanceMark,F=i.WebAssembly,k=F&&F.CompileError||R,B=F&&F.LinkError||R,z=F&&F.RuntimeError||R,V=r("DOMException"),H=M.Map,G=M.has,j=M.get,W=M.set,X=w.Set,q=w.add,Y=r("Object","keys"),$=a([].push),K=a((!0).valueOf),Z=a(1..valueOf),J=a("".valueOf),Q=a(C.prototype.getTime),ee=o("structuredClone"),te="DataCloneError",ne="Transferring",ie=function(e){return!s((function(){var t=new i.Set([7]),n=e(t),r=e(T(7));return n==t||!n.has(7)||"object"!=typeof r||7!=r}))&&e},re=function(e,t){return!s((function(){var n=new t,i=e({a:n,b:n});return!(i&&i.a===i.b&&i.a instanceof t&&i.a.stack===n.stack)}))},ae=i.structuredClone,se=t||!re(ae,R)||!re(ae,V)||(e=ae,!!s((function(){var t=e(new i.AggregateError([1],ee,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ee||3!=t.cause}))),oe=!ae&&ie((function(e){return new N(ee,{detail:e}).detail})),le=ie(ae)||oe,he=function(e){throw new V("Uncloneable type: "+e,te)},ce=function(e,t){throw new V((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ue=function(e,t){if(d(e)&&he("Symbol"),!u(e))return e;if(t){if(G(t,e))return j(t,e)}else t=new H;var n,a,s,o,h,c,p,f,_,M,w,E=m(e),N=!1;switch(E){case"Array":s=A(x(e)),N=!0;break;case"Object":s={},N=!0;break;case"Map":s=new H,N=!0;break;case"Set":s=new X,N=!0;break;case"RegExp":s=new RegExp(e.source,b(e));break;case"Error":switch(a=e.name){case"AggregateError":s=r("AggregateError")([]);break;case"EvalError":s=P();break;case"RangeError":s=L();break;case"ReferenceError":s=D();break;case"SyntaxError":s=I();break;case"TypeError":s=O();break;case"URIError":s=U();break;case"CompileError":s=k();break;case"LinkError":s=B();break;case"RuntimeError":s=z();break;default:s=R()}N=!0;break;case"DOMException":s=new V(e.message,e.name),N=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":n=i[E],u(n)||ce(E),s=new n(ue(e.buffer,t),e.byteOffset,"DataView"===E?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(ue(e.p1,t),ue(e.p2,t),ue(e.p3,t),ue(e.p4,t))}catch(t){le?s=le(e):ce(E)}break;case"FileList":if(o=function(){var e;try{e=new i.DataTransfer}catch(t){try{e=new i.ClipboardEvent("").clipboardData}catch(e){}}return e&&e.items&&e.files?e:null}(),o){for(h=0,c=x(e);h<c;h++)o.items.add(ue(e[h],t));s=o.files}else le?s=le(e):ce(E);break;case"ImageData":try{s=new ImageData(ue(e.data,t),e.width,e.height,{colorSpace:e.colorSpace})}catch(t){le?s=le(e):ce(E)}break;default:if(le)s=le(e);else switch(E){case"BigInt":s=T(e.valueOf());break;case"Boolean":s=T(K(e));break;case"Number":s=T(Z(e));break;case"String":s=T(J(e));break;case"Date":s=new C(Q(e));break;case"ArrayBuffer":!(n=i.DataView)&&"function"!=typeof e.slice&&ce(E);try{if("function"!=typeof e.slice||e.resizable)for((c=e.byteLength,w="maxByteLength"in e?{maxByteLength:e.maxByteLength}:void 0,s=new ArrayBuffer(c,w),_=new n(e),M=new n(s),h=0);h<c;h++)M.setUint8(h,_.getUint8(h));else s=e.slice(0)}catch(e){throw new V("ArrayBuffer is detached",te)}break;case"SharedArrayBuffer":s=e;break;case"Blob":try{s=e.slice(0,e.size,e.type)}catch(e){ce(E)}break;case"DOMPoint":case"DOMPointReadOnly":n=i[E];try{s=n.fromPoint?n.fromPoint(e):new n(e.x,e.y,e.z,e.w)}catch(e){ce(E)}break;case"DOMRect":case"DOMRectReadOnly":n=i[E];try{s=n.fromRect?n.fromRect(e):new n(e.x,e.y,e.width,e.height)}catch(e){ce(E)}break;case"DOMMatrix":case"DOMMatrixReadOnly":n=i[E];try{s=n.fromMatrix?n.fromMatrix(e):new n(e)}catch(e){ce(E)}break;case"AudioData":case"VideoFrame":l(e.clone)||ce(E);try{s=e.clone()}catch(e){he(E)}break;case"File":try{s=new File([e],e.name,e)}catch(e){ce(E)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":ce(E);default:he(E)}}if(W(t,e,s),N)switch(E){case"Array":case"Object":for(p=Y(e),h=0,c=x(p);h<c;h++)f=p[h],v(s,f,ue(e[f],t));break;case"Map":e.forEach((function(e,n){W(s,ue(n,t),ue(e,t))}));break;case"Set":e.forEach((function(e){q(s,ue(e,t))}));break;case"Error":y(s,"message",ue(e.message,t)),g(e,"cause")&&y(s,"cause",ue(e.cause,t)),"AggregateError"==a&&(s.errors=ue(e.errors,t));case"DOMException":S&&y(s,"stack",ue(e.stack,t))}return s};n({global:!0,enumerable:!0,sham:!E,forced:se},{structuredClone:function(e){var t,n=_(arguments.length,1)>1&&!c(arguments[1])?f(arguments[1]):void 0,r=n?n.transfer:void 0;return void 0!==r&&function(e,t){if(!u(e))throw O("Transfer option cannot be converted to a sequence");var n=[];p(e,(function(e){$(n,f(e))}));var r,a,s,o,c,d,g=0,v=x(n);if(E)for(o=ae(n,{transfer:n});g<v;)W(t,n[g],o[g++]);else for(;g<v;){if(r=n[g++],G(t,r))throw new V("Duplicate transferable",te);switch(a=m(r)){case"ImageBitmap":s=i.OffscreenCanvas,h(s)||ce(a,ne);try{(d=new s(r.width,r.height)).getContext("bitmaprenderer").transferFromImageBitmap(r),c=d.transferToImageBitmap()}catch(e){}break;case"AudioData":case"VideoFrame":(!l(r.clone)||!l(r.close))&&ce(a,ne);try{c=r.clone(),r.close()}catch(e){}break;case"ArrayBuffer":l(r.transfer)||ce(a,ne),c=r.transfer();break;case"MediaSourceHandle":case"MessagePort":case"OffscreenCanvas":case"ReadableStream":case"TransformStream":case"WritableStream":ce(a,ne)}if(void 0===c)throw new V("This object cannot be transferred: "+a,te);W(t,r,c)}}(r,t=new H),ue(e,t)}})})),Rie=F((()=>{var e=we(),t=Ot(),n=Mw()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==n},{setInterval:n})})),Pie=F((()=>{var e=we(),t=Ot(),n=Mw()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==n},{setTimeout:n})})),Iie=F((()=>{Rie(),Pie()})),vO=F(((e,t)=>{var n=dt(),i=$n(),r=on(),a=hi(),s=i("iterator");t.exports=!n((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,i){t.delete("b"),n+=i+e})),a&&!e.toJSON||!t.size&&(a||!r)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://\u0442\u0435\u0441\u0442").host||"#%D0%B1"!==new URL("http://a#\u0431").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))})),zie=F(((e,t)=>{var n=yt(),i=2147483647,r=/[^\0-\u007E]/,a=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",o=RangeError,l=n(a.exec),h=Math.floor,c=String.fromCharCode,u=n("".charCodeAt),d=n([].join),p=n([].push),f=n("".replace),m=n("".split),g=n("".toLowerCase),v=function(e){return e+22+75*(e<26)},y=function(e,t,n){var i=0;for(e=n?h(e/700):e>>1,e+=h(e/t);e>455;)e=h(e/35),i+=36;return h(i+36*e/(e+38))},x=function(e){var t=[];e=function(e){for(var t=[],n=0,i=e.length;n<i;){var r=u(e,n++);if(r>=55296&&r<=56319&&n<i){var a=u(e,n++);56320==(64512&a)?p(t,((1023&r)<<10)+(1023&a)+65536):(p(t,r),n--)}else p(t,r)}return t}(e);var n,r,a=e.length,l=128,f=0,m=72;for(n=0;n<e.length;n++)(r=e[n])<128&&p(t,c(r));var g=t.length,x=g;for(g&&p(t,"-");x<a;){var _=i;for(n=0;n<e.length;n++)(r=e[n])>=l&&r<_&&(_=r);var b=x+1;if(_-l>h((i-f)/b))throw o(s);for(f+=(_-l)*b,l=_,n=0;n<e.length;n++){if((r=e[n])<l&&++f>i)throw o(s);if(r==l){for(var M=f,w=36;;){var S=w<=m?1:w>=m+26?26:w-m;if(M<S)break;var E=M-S,T=36-S;p(t,c(v(S+E%T))),M=h(E/T),w+=36}p(t,c(v(M))),m=y(f,b,x==g),f=0,x++}}f++,l++}return d(t,"")};t.exports=function(e){var t,n,i=[],s=m(f(g(e),a,"."),".");for(t=0;t<s.length;t++)n=s[t],p(i,l(r,n)?"xn--"+x(n):n);return d(i,".")}})),IO=F(((e,t)=>{"use strict";h1();var n=we(),i=Ot(),r=Bn(),a=yt(),s=on(),o=vO(),l=ei(),h=Vi(),c=Mm(),u=sa(),d=Y_(),p=Si(),f=ml(),m=Xn(),g=ar(),v=mo(),y=dl(),x=Cn(),_=Yn(),b=Hn(),M=ia(),w=Da(),S=i1(),E=_m(),T=Eu(),A=$n(),C=eT(),R=A("iterator"),P="URLSearchParams",L=P+"Iterator",D=p.set,I=p.getterFor(P),O=p.getterFor(L),U=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return i[e];var t=U(i,e);return t&&t.value},F=N("fetch"),k=N("Request"),B=N("Headers"),z=k&&k.prototype,V=B&&B.prototype,H=i.RegExp,G=i.TypeError,j=i.decodeURIComponent,W=i.encodeURIComponent,X=a("".charAt),q=a([].join),Y=a([].push),$=a("".replace),K=a([].shift),Z=a([].splice),J=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ne=function(e){return te[e-1]||(te[e-1]=H("((?:%[\\da-f]{2}){"+e+"})","gi"))},ie=function(e){try{return j(e)}catch(t){return e}},re=function(e){var t=$(e,ee," "),n=4;try{return j(t)}catch(e){for(;n;)t=$(t,ne(n--),ie);return t}},ae=/[!'()~]|%20/g,se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},oe=function(e){return se[e]},le=function(e){return $(W(e),ae,oe)},he=d((function(e,t){D(this,{type:L,iterator:S(I(e).entries),kind:t})}),"Iterator",(function(){var e=O(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value="keys"===t?i.key:"values"===t?i.value:[i.key,i.value]),n}),!0),ce=function(e){this.entries=[],this.url=null,void 0!==e&&(_(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:b(e)))};ce.prototype={type:P,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,a,s,o,l,h=E(e);if(h)for(n=(t=S(e,h)).next;!(i=r(n,t)).done;){if(s=(a=S(x(i.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw G("Expected sequence with length 2");Y(this.entries,{key:b(o.value),value:b(l.value)})}else for(var c in e)g(e,c)&&Y(this.entries,{key:c,value:b(e[c])})},parseQuery:function(e){if(e)for(var t,n,i=J(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=J(t,"="),Y(this.entries,{key:re(K(n)),value:re(q(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],Y(n,le(e.key)+"="+le(e.value));return q(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var ue,de,pe,fe,me=function(){f(this,ge);var e=D(this,new ce(arguments.length>0?arguments[0]:void 0));s||(this.length=e.entries.length)},ge=me.prototype;c(ge,{append:function(e,t){T(arguments.length,2);var n=I(this);Y(n.entries,{key:b(e),value:b(t)}),s||this.length++,n.updateURL()},delete:function(e){T(arguments.length,1);for(var t=I(this),n=t.entries,i=b(e),r=0;r<n.length;)n[r].key===i?Z(n,r,1):r++;s||(this.length=n.length),t.updateURL()},get:function(e){T(arguments.length,1);for(var t=I(this).entries,n=b(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){T(arguments.length,1);for(var t=I(this).entries,n=b(e),i=[],r=0;r<t.length;r++)t[r].key===n&&Y(i,t[r].value);return i},has:function(e){T(arguments.length,1);for(var t=I(this).entries,n=b(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){T(arguments.length,1);for(var n,i=I(this),r=i.entries,a=!1,o=b(e),l=b(t),h=0;h<r.length;h++)(n=r[h]).key===o&&(a?Z(r,h--,1):(a=!0,n.value=l));a||Y(r,{key:o,value:l}),s||(this.length=r.length),i.updateURL()},sort:function(){var e=I(this);C(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=I(this).entries,i=v(e,arguments.length>1?arguments[1]:void 0),r=0;r<n.length;)i((t=n[r++]).value,t.key,this)},keys:function(){return new he(this,"keys")},values:function(){return new he(this,"values")},entries:function(){return new he(this,"entries")}},{enumerable:!0}),l(ge,R,ge.entries,{name:"entries"}),l(ge,"toString",(function(){return I(this).serialize()}),{enumerable:!0}),s&&h(ge,"size",{get:function(){return I(this).entries.length},configurable:!0,enumerable:!0}),u(me,P),n({global:!0,constructor:!0,forced:!o},{URLSearchParams:me}),!o&&m(B)&&(ue=a(V.has),de=a(V.set),pe=function(e){if(_(e)){var t,n=e.body;if(y(n)===P)return t=e.headers?new B(e.headers):new B,ue(t,"content-type")||de(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),M(e,{body:w(0,b(n)),headers:w(0,t)})}return e},m(F)&&n({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return F(e,arguments.length>1?pe(arguments[1]):{})}}),m(k)&&(fe=function(e){return f(this,z),new k(e,arguments.length>1?pe(arguments[1]):{})},z.constructor=fe,fe.prototype=z,n({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fe}))),t.exports={URLSearchParams:me,getState:I}})),Sse=F((()=>{"use strict";UD();var e,t=we(),n=on(),i=vO(),r=Ot(),a=mo(),s=yt(),o=ei(),l=Vi(),h=ml(),c=ar(),u=DI(),d=pP(),p=gm(),f=F1().codeAt,m=zie(),g=Hn(),v=sa(),y=Eu(),x=IO(),_=Si(),b=_.set,M=_.getterFor("URL"),w=x.URLSearchParams,S=x.getState,E=r.URL,T=r.TypeError,A=r.parseInt,C=Math.floor,R=Math.pow,P=s("".charAt),L=s(/./.exec),D=s([].join),I=s(1..toString),O=s([].pop),U=s([].push),N=s("".replace),F=s([].shift),k=s("".split),B=s("".slice),z=s("".toLowerCase),V=s([].unshift),H="Invalid scheme",G="Invalid host",j="Invalid port",W=/[a-z]/i,X=/[\d+-.a-z]/i,q=/\d/,Y=/^0x/i,$=/^[0-7]+$/,K=/^\d+$/,Z=/^[\da-f]+$/i,J=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+/,te=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ne=/[\t\n\r]/g,ie=function(e){var t,n,i,r;if("number"==typeof e){for(t=[],n=0;n<4;n++)V(t,e%256),e=C(e/256);return D(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,n=1,i=null,r=0,a=0;a<8;a++)0!==e[a]?(r>n&&(t=i,n=r),i=null,r=0):(null===i&&(i=a),++r);return r>n&&(t=i,n=r),t}(e),n=0;n<8;n++)r&&0===e[n]||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=I(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},re={},ae=u({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=u({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=u({},se,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),le=function(e,t){var n=f(e,0);return n>32&&n<127&&!c(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ce=function(e,t){var n;return 2==e.length&&L(W,P(e,0))&&(":"==(n=P(e,1))||!t&&"|"==n)},ue=function(e){var t;return e.length>1&&ce(B(e,0,2))&&(2==e.length||"/"===(t=P(e,2))||"\\"===t||"?"===t||"#"===t)},de=function(e){return"."===e||"%2e"===z(e)},pe=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},fe={},me={},ge={},ve={},ye={},xe={},_e={},be={},Me={},Se={},Ee={},Te={},Ae={},Ce={},Re={},Pe={},Le={},De={},Ie={},Oe={},Ue={},Ne=function(e,t,n){var i,r,a,s=g(e);if(t){if(r=this.parse(s))throw T(r);this.searchParams=null}else{if(void 0!==n&&(i=new Ne(n,!0)),r=this.parse(s,null,i))throw T(r);(a=S(new w)).bindURL(this),this.searchParams=a}};Ne.prototype={type:"URL",parse:function(t,n,i){var r,a,s,o,l=this,h=n||fe,u=0,f="",m=!1,v=!1,y=!1;for(t=g(t),n||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,t=N(t,ee,""),t=N(t,te,"$1")),t=N(t,ne,""),r=d(t);u<=r.length;){switch(a=r[u],h){case fe:if(!a||!L(W,a)){if(n)return H;h=ge;continue}f+=z(a),h=me;break;case me:if(a&&(L(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(n)return H;f="",h=ge,u=0;continue}if(n&&(l.isSpecial()!=c(he,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,n)return void(l.isSpecial()&&he[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Ce:l.isSpecial()&&i&&i.scheme==l.scheme?h=ve:l.isSpecial()?h=be:"/"==r[u+1]?(h=ye,u++):(l.cannotBeABaseURL=!0,U(l.path,""),h=Ie)}break;case ge:if(!i||i.cannotBeABaseURL&&"#"!=a)return H;if(i.cannotBeABaseURL&&"#"==a){l.scheme=i.scheme,l.path=p(i.path),l.query=i.query,l.fragment="",l.cannotBeABaseURL=!0,h=Ue;break}h="file"==i.scheme?Ce:xe;continue;case ve:if("/"!=a||"/"!=r[u+1]){h=xe;continue}h=Me,u++;break;case ye:if("/"==a){h=Se;break}h=De;continue;case xe:if(l.scheme=i.scheme,a==e)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query;else if("/"==a||"\\"==a&&l.isSpecial())h=_e;else if("?"==a)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query="",h=Oe;else{if("#"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.path.length--,h=De;continue}l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query,l.fragment="",h=Ue}break;case _e:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,h=De;continue}h=Se}else h=Me;break;case be:if(h=Me,"/"!=a||"/"!=P(f,u+1))continue;u++;break;case Me:if("/"!=a&&"\\"!=a){h=Se;continue}break;case Se:if("@"==a){m&&(f="%40"+f),m=!0,s=d(f);for(var x=0;x<s.length;x++){var _=s[x];if(":"!=_||y){var b=le(_,oe);y?l.password+=b:l.username+=b}else y=!0}f=""}else if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(m&&""==f)return"Invalid authority";u-=d(f).length+1,f="",h=Ee}else f+=a;break;case Ee:case Te:if(n&&"file"==l.scheme){h=Pe;continue}if(":"!=a||v){if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(l.isSpecial()&&""==f)return G;if(n&&""==f&&(l.includesCredentials()||null!==l.port))return;if(o=l.parseHost(f))return o;if(f="",h=Le,n)return;continue}"["==a?v=!0:"]"==a&&(v=!1),f+=a}else{if(""==f)return G;if(o=l.parseHost(f))return o;if(f="",h=Ae,n==Te)return}break;case Ae:if(!L(q,a)){if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()||n){if(""!=f){var M=A(f,10);if(M>65535)return j;l.port=l.isSpecial()&&M===he[l.scheme]?null:M,f=""}if(n)return;h=Le;continue}return j}f+=a;break;case Ce:if(l.scheme="file","/"==a||"\\"==a)h=Re;else{if(!i||"file"!=i.scheme){h=De;continue}if(a==e)l.host=i.host,l.path=p(i.path),l.query=i.query;else if("?"==a)l.host=i.host,l.path=p(i.path),l.query="",h=Oe;else{if("#"!=a){ue(D(p(r,u),""))||(l.host=i.host,l.path=p(i.path),l.shortenPath()),h=De;continue}l.host=i.host,l.path=p(i.path),l.query=i.query,l.fragment="",h=Ue}}break;case Re:if("/"==a||"\\"==a){h=Pe;break}i&&"file"==i.scheme&&!ue(D(p(r,u),""))&&(ce(i.path[0],!0)?U(l.path,i.path[0]):l.host=i.host),h=De;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&ce(f))h=De;else if(""==f){if(l.host="",n)return;h=Le}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),n)return;f="",h=Le}continue}f+=a;break;case Le:if(l.isSpecial()){if(h=De,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=e&&(h=De,"/"!=a))continue}else l.fragment="",h=Ue;else l.query="",h=Oe;break;case De:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!n&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&U(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&U(l.path,""):("file"==l.scheme&&!l.path.length&&ce(f)&&(l.host&&(l.host=""),f=P(f,0)+":"),U(l.path,f)),f="","file"==l.scheme&&(a==e||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)F(l.path);"?"==a?(l.query="",h=Oe):"#"==a&&(l.fragment="",h=Ue)}else f+=le(a,se);break;case Ie:"?"==a?(l.query="",h=Oe):"#"==a?(l.fragment="",h=Ue):a!=e&&(l.path[0]+=le(a,re));break;case Oe:n||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=Ue);break;case Ue:a!=e&&(l.fragment+=le(a,ae))}u++}},parseHost:function(e){var t,n,i;if("["==P(e,0)){if("]"!=P(e,e.length-1)||(t=function(e){var t,n,i,r,a,s,o,l=[0,0,0,0,0,0,0,0],h=0,c=null,u=0,d=function(){return P(e,u)};if(":"==d()){if(":"!=P(e,1))return;u+=2,c=++h}for(;d();){if(8==h)return;if(":"!=d()){for(t=n=0;n<4&&L(Z,d());)t=16*t+A(d(),16),u++,n++;if("."==d()){if(0==n||(u-=n,h>6))return;for(i=0;d();){if(r=null,i>0){if(!("."==d()&&i<4))return;u++}if(!L(q,d()))return;for(;L(q,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;u++}l[h]=256*l[h]+r,(2==++i||4==i)&&h++}if(4!=i)return;break}if(":"==d()){if(u++,!d())return}else if(d())return;l[h++]=t}else{if(null!==c)return;u++,c=++h}}if(null!==c)for(s=h-c,h=7;0!=h&&s>0;)o=l[h],l[h--]=l[c+s-1],l[c+--s]=o;else if(8!=h)return;return l}(B(e,1,-1)),!t))return G;this.host=t}else if(this.isSpecial()){if(e=m(e),L(J,e)||(t=function(e){var t,n,i,r,a,s,o,l=k(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(n=[],i=0;i<t;i++){if(""==(r=l[i]))return e;if(a=10,r.length>1&&"0"==P(r,0)&&(a=L(Y,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!L(10==a?K:8==a?$:Z,r))return e;s=A(r,a)}U(n,s)}for(i=0;i<t;i++)if(s=n[i],i==t-1){if(s>=R(256,5-t))return null}else if(s>255)return null;for(o=O(n),i=0;i<n.length;i++)o+=n[i]*R(256,3-i);return o}(e),null===t))return G;this.host=t}else{if(L(Q,e))return G;for(t="",n=d(e),i=0;i<n.length;i++)t+=le(n[i],re);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return c(he,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;t&&("file"!=this.scheme||1!=t||!ce(e[0],!0))&&e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,i=e.password,r=e.host,a=e.port,s=e.path,o=e.query,l=e.fragment,h=t+":";return null!==r?(h+="//",e.includesCredentials()&&(h+=n+(i?":"+i:"")+"@"),h+=ie(r),null!==a&&(h+=":"+a)):"file"==t&&(h+="//"),h+=e.cannotBeABaseURL?s[0]:s.length?"/"+D(s,"/"):"",null!==o&&(h+="?"+o),null!==l&&(h+="#"+l),h},setHref:function(e){var t=this.parse(e);if(t)throw T(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Be(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+ie(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(g(e)+":",fe)},getUsername:function(){return this.username},setUsername:function(e){var t=d(g(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=le(t[n],oe)}},getPassword:function(){return this.password},setPassword:function(e){var t=d(g(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=le(t[n],oe)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?ie(e):ie(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Ee)},getHostname:function(){var e=this.host;return null===e?"":ie(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Te)},getPort:function(){var e=this.port;return null===e?"":g(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=g(e))?this.port=null:this.parse(e,Ae))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+D(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Le))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=g(e))?this.query=null:("?"==P(e,0)&&(e=B(e,1)),this.query="",this.parse(e,Oe)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=g(e))?("#"==P(e,0)&&(e=B(e,1)),this.fragment="",this.parse(e,Ue)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Fe,ke,Be=function(e){var t=h(this,ze),i=y(arguments.length,1)>1?arguments[1]:void 0,r=b(t,new Ne(e,!1,i));n||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},ze=Be.prototype,Ve=function(e,t){return{get:function(){return M(this)[e]()},set:t&&function(e){return M(this)[t](e)},configurable:!0,enumerable:!0}};n&&(l(ze,"href",Ve("serialize","setHref")),l(ze,"origin",Ve("getOrigin")),l(ze,"protocol",Ve("getProtocol","setProtocol")),l(ze,"username",Ve("getUsername","setUsername")),l(ze,"password",Ve("getPassword","setPassword")),l(ze,"host",Ve("getHost","setHost")),l(ze,"hostname",Ve("getHostname","setHostname")),l(ze,"port",Ve("getPort","setPort")),l(ze,"pathname",Ve("getPathname","setPathname")),l(ze,"search",Ve("getSearch","setSearch")),l(ze,"searchParams",Ve("getSearchParams")),l(ze,"hash",Ve("getHash","setHash"))),o(ze,"toJSON",(function(){return M(this).serialize()}),{enumerable:!0}),o(ze,"toString",(function(){return M(this).serialize()}),{enumerable:!0}),E&&(Fe=E.createObjectURL,ke=E.revokeObjectURL,Fe&&o(Be,"createObjectURL",a(Fe,E)),ke&&o(Be,"revokeObjectURL",a(ke,E))),v(Be,"URL"),t({global:!0,constructor:!0,forced:!i,sham:!n},{URL:Be})})),Rse=F((()=>{Sse()})),Ase=F((()=>{"use strict";var e=we(),t=Bn();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),Cse=F((()=>{IO()})),Pse=F((()=>{"use strict";var e=on(),t=yt(),n=Vi(),i=URLSearchParams.prototype,r=t(i.forEach);e&&!("size"in i)&&n(i,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})})),Dse=F(((e,t)=>{OG(),VG(),zG(),GG(),qG(),WG(),jG(),XG(),YG(),$G(),ZG(),KG(),JG(),QG(),e7(),S7(),I7(),Y7(),J7(),e9(),a9(),u9(),d9(),m9(),g9(),x9(),E9(),T9(),w9(),R9(),A9(),I9(),V9(),z9(),q9(),W9(),h1(),dq(),gq(),vq(),yq(),bq(),Sq(),Aq(),Pq(),Lq(),Oq(),Zq(),Qq(),eW(),nW(),aW(),oW(),lW(),cW(),uW(),dW(),FW(),ZW(),sj(),oj(),lj(),uj(),fj(),pj(),wj(),Mj(),Pj(),Oj(),Uj(),zj(),Wj(),$j(),Zj(),G2(),Kj(),fX(),gX(),yX(),bX(),TX(),wX(),RX(),CX(),DX(),OX(),UX(),FX(),HX(),kX(),VX(),qX(),XX(),YX(),$X(),aY(),oY(),uY(),dY(),fY(),pY(),mY(),gY(),_Y(),PY(),NY(),VY(),qY(),$Y(),ZY(),QY(),t$(),r$(),i$(),l$(),c$(),u$(),f$(),p$(),m$(),v$(),x$(),E$(),_$(),w$(),S$(),A$(),C$(),P$(),I$(),B$(),F$(),H$(),z$(),G$(),W$(),X$(),iK(),sK(),oK(),hK(),dK(),yK(),_K(),TK(),RK(),AK(),CK(),PK(),IK(),DK(),LK(),FK(),kK(),VK(),rJ(),sJ(),qT(),hJ(),fJ(),gJ(),yJ(),bJ(),_J(),SJ(),LJ(),UJ(),FJ(),UD(),KJ(),oQ(),cQ(),uQ(),pQ(),mQ(),bQ(),SQ(),CQ(),NQ(),kQ(),zQ(),jQ(),KQ(),nee(),aee(),oee(),lee(),cee(),uee(),hee(),dee(),fee(),pee(),mee(),gee(),vee(),xee(),jee(),Xee(),Yee(),$ee(),Zee(),Kee(),Jee(),Qee(),ete(),nte(),ite(),ate(),lte(),pte(),gte(),xte(),Ete(),_te(),wte(),Mte(),Rte(),Cte(),Ote(),Ute(),Fte(),kte(),zte(),qte(),jte(),Yte(),ene(),nne(),ine(),une(),fne(),xne(),yne(),Ene(),_ne(),Tne(),Ane(),Wne(),Xne(),nre(),hre(),xre(),wre(),Fre(),Wre(),Xre(),iie(),sie(),oie(),wie(),Iie(),Rse(),Ase(),Cse(),Pse(),t.exports=I_()})),Lse=F(((e,t)=>{var n=function(e){"use strict";var t,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof v?t:v,s=Object.create(a.prototype),o=new P(i||[]);return r(s,"_invoke",{value:T(e,n,o)}),s}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var _={};h(_,s,(function(){return this}));var b=Object.getPrototypeOf,M=b&&b(b(L([])));M&&M!==n&&i.call(M,s)&&(_=M);var w=x.prototype=v.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(r,a,s,o){var l=u(e[r],e,a);if("throw"!==l.type){var h=l.arg,c=h.value;return c&&"object"==typeof c&&i.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(c).then((function(e){h.value=e,s(h)}),(function(e){return n("throw",e,s,o)}))}o(l.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function T(e,t,n){var i=d;return function(r,a){if(i===f)throw new Error("Generator is already running");if(i===m){if("throw"===r)throw a;return D()}for(n.method=r,n.arg=a;;){var s=n.delegate;if(s){var o=A(s,n);if(o){if(o===g)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=f;var l=u(e,t,n);if("normal"===l.type){if(i=n.done?m:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=m,n.method="throw",n.arg=l.arg)}}}function A(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,A(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var a=u(r,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var s=a.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(e){if(e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r<e.length;)if(i.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}return{next:D}}function D(){return{value:t,done:!0}}return y.prototype=x,r(w,"constructor",{value:x,configurable:!0}),r(x,"constructor",{value:y,configurable:!0}),y.displayName=h(x,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,h(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},S(E.prototype),h(E.prototype,o,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,i,r,a){void 0===a&&(a=Promise);var s=new E(c(t,n,i,r),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},S(w),h(w,l,"Generator"),h(w,s,(function(){return this})),h(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},e.values=L,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(R),!e)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(i,r){return o.type="throw",o.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;R(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:L(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),g}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})),Hle=F(((e,t)=>{!function(e,n){"use strict";"function"==typeof define&&define.amd?define(n):"object"==typeof t&&t.exports?t.exports=n():e.log=n()}(e,(function(){"use strict";var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(t,n){for(var r=0;r<i.length;r++){var a=i[r];this[a]=r<t?e:this.methodFactory(a,t,n)}this.log=this.debug}function o(e,n,i){return function(){typeof console!==t&&(s.call(this,n,i),this[e].apply(this,arguments))}}function l(i,s,l){return function(i){return"debug"===i&&(i="log"),typeof console!==t&&("trace"===i&&n?a:void 0!==console[i]?r(console,i):void 0!==console.log?r(console,"log"):e)}(i)||o.apply(this,arguments)}function h(e,n,r){var a,o=this;n=null==n?"WARN":n;var h="loglevel";function c(){var e;if(typeof window!==t&&h){try{e=window.localStorage[h]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,i=n.indexOf(encodeURIComponent(h)+"=");-1!==i&&(e=/^([^;]+)/.exec(n.slice(i))[1])}catch(e){}return void 0===o.levels[e]&&(e=void 0),e}}"string"==typeof e?h+=":"+e:"symbol"==typeof e&&(h=void 0),o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=r||l,o.getLevel=function(){return a},o.setLevel=function(n,r){if("string"==typeof n&&void 0!==o.levels[n.toUpperCase()]&&(n=o.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==r&&function(e){var n=(i[e]||"silent").toUpperCase();if(typeof window!==t&&h){try{return void(window.localStorage[h]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),typeof console===t&&n<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(e){n=e,c()||o.setLevel(e,!1)},o.resetLevel=function(){o.setLevel(n,!1),function(){if(typeof window!==t&&h){try{return void window.localStorage.removeItem(h)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)};var u=c();null==u&&(u=n),o.setLevel(u,!1)}var c=new h,u={};c.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=u[e];return t||(t=u[e]=new h(e,c.getLevel(),c.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return c.noConflict=function(){return typeof window!==t&&window.log===c&&(window.log=d),c},c.getLoggers=function(){return u},c.default=c,c}))})),tR=F(((e,t)=>{"use strict";t.exports=function(e,t,i){var r=e*t,a=n*e,s=a-(a-e),o=e-s,l=n*t,h=l-(l-t),c=t-h,u=o*c-(r-s*h-o*h-s*c);return i?(i[0]=u,i[1]=r,i):[u,r]};var n=+(Math.pow(2,27)+1)})),UF=F(((e,t)=>{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=t[h],f=c(p);d<f?(a=u,(l+=1)<n&&(d=c(u=e[l]))):(a=p,(h+=1)<i&&(f=c(p=t[h]))),l<n&&d<f||h>=i?(r=u,(l+=1)<n&&(d=c(u=e[l]))):(r=p,(h+=1)<i&&(f=c(p=t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,_=x,b=v;l<n&&h<i;)d<f?(r=u,(l+=1)<n&&(d=c(u=e[l]))):(r=p,(h+=1)<i&&(f=c(p=t[h]))),(x=(a=_)-(y=(v=r+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m;for(;l<n;)(x=(a=_)-(y=(v=(r=u)+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m,(l+=1)<n&&(u=e[l]);for(;h<i;)(x=(a=_)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m,(h+=1)<i&&(p=t[h]);return _&&(s[o++]=_),b&&(s[o++]=b),o||(s[o++]=0),s.length=o,s}})),Ece=F(((e,t)=>{"use strict";t.exports=function(e,t,n){var i=e+t,r=i-e,a=t-r,s=e-(i-r);return n?(n[0]=s+a,n[1]=i,n):[s+a,i]}})),FF=F(((e,t)=>{"use strict";var n=tR(),i=Ece();t.exports=function(e,t){var r=e.length;if(1===r){var a=n(e[0],t);return a[0]?a:[a[1]]}var s=new Array(2*r),o=[.1,.1],l=[.1,.1],h=0;n(e[0],t,o),o[0]&&(s[h++]=o[0]);for(var c=1;c<r;++c){n(e[c],t,l);var u=o[1];i(u,l[0],o),o[0]&&(s[h++]=o[0]);var d=l[1],p=o[1],f=d+p,m=p-(f-d);o[1]=f,m&&(s[h++]=m)}return o[1]&&(s[h++]=o[1]),0===h&&(s[h++]=0),s.length=h,s}})),Tce=F(((e,t)=>{"use strict";t.exports=function(e){for(var t=e.length,n=e[e.length-1],i=t,r=t-2;r>=0;--r){var a=n;(l=(o=e[r])-((n=a+o)-a))&&(e[--i]=n,n=l)}var s=0;for(r=i;r<t;++r){var o,l;(l=(o=n)-((n=(a=e[r])+o)-a))&&(e[s++]=l)}return e[s++]=n,e.length=s,e}})),Mce=F(((e,t)=>{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],-t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=-t[h],f=c(p);d<f?(a=u,(l+=1)<n&&(d=c(u=e[l]))):(a=p,(h+=1)<i&&(f=c(p=-t[h]))),l<n&&d<f||h>=i?(r=u,(l+=1)<n&&(d=c(u=e[l]))):(r=p,(h+=1)<i&&(f=c(p=-t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,_=x,b=v;l<n&&h<i;)d<f?(r=u,(l+=1)<n&&(d=c(u=e[l]))):(r=p,(h+=1)<i&&(f=c(p=-t[h]))),(x=(a=_)-(y=(v=r+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m;for(;l<n;)(x=(a=_)-(y=(v=(r=u)+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m,(l+=1)<n&&(u=e[l]);for(;h<i;)(x=(a=_)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),_=b-((m=b+v)-(g=m-b))+(v-g),b=m,(h+=1)<i&&(p=-t[h]);return _&&(s[o++]=_),b&&(s[o++]=b),o||(s[o++]=0),s.length=o,s}})),Rce=F(((e,t)=>{"use strict";var n=tR(),i=UF(),r=FF(),a=Mce();function s(e,t,n,i){return function(n,r,a){var s=e(e(t(r[1],a[0]),t(-a[1],r[0])),e(t(n[1],r[0]),t(-r[1],n[0]))),o=e(t(n[1],a[0]),t(-a[1],n[0])),l=i(s,o);return l[l.length-1]}}function o(e,t,n,i){return function(r,a,s,o){var l=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2])))),h=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2])))),c=i(l,h);return c[c.length-1]}}function l(e,t,n,i){return function(r,a,s,o,l){var h=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),a[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),-s[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),o[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),-l[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-a[3])))),e(e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),o[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),-l[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),r[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-a[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-o[3]))))),c=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-s[3])),e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),o[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-l[3]))),e(e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),r[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),-a[3])),e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-l[3])))),u=i(h,c);return u[u.length-1]}}function h(e){return(3===e?s:4===e?o:l)(i,n,r,a)}var c=h(3),u=h(4),d=[function(){return 0},function(){return 0},function(e,t){return t[0]-e[0]},function(e,t,n){var i,r=(e[1]-n[1])*(t[0]-n[0]),a=(e[0]-n[0])*(t[1]-n[1]),s=r-a;if(r>0){if(a<=0)return s;i=r+a}else{if(!(r<0))return s;if(a>=0)return s;i=-(r+a)}var o=33306690738754716e-32*i;return s>=o||s<=-o?s:c(e,t,n)},function(e,t,n,i){var r=e[0]-i[0],a=t[0]-i[0],s=n[0]-i[0],o=e[1]-i[1],l=t[1]-i[1],h=n[1]-i[1],c=e[2]-i[2],d=t[2]-i[2],p=n[2]-i[2],f=a*h,m=s*l,g=s*o,v=r*h,y=r*l,x=a*o,_=c*(f-m)+d*(g-v)+p*(y-x),b=7771561172376103e-31*((Math.abs(f)+Math.abs(m))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(d)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return _>b||-_>b?_:u(e,t,n,i)}];function p(e){var t=d[e.length];return t||(t=d[e.length]=h(e.length)),t.apply(void 0,e)}function f(e,t,n,i,r,a,s){return function(t,n,o,l,h){switch(arguments.length){case 0:case 1:return 0;case 2:return i(t,n);case 3:return r(t,n,o);case 4:return a(t,n,o,l);case 5:return s(t,n,o,l,h)}for(var c=new Array(arguments.length),u=0;u<arguments.length;++u)c[u]=arguments[u];return e(c)}}!function(){for(;d.length<=5;)d.push(h(d.length));t.exports=f.apply(void 0,[p].concat(d));for(var e=0;e<=5;++e)t.exports[e]=d[e]}()})),Cce=F(((e,t)=>{"use strict";t.exports=function(e,t,i,r){var a=n(e,i,r),s=n(t,i,r);if(a>0&&s>0||a<0&&s<0)return!1;var o=n(i,e,t),l=n(r,e,t);return!(o>0&&l>0||o<0&&l<0)&&(0!==a||0!==s||0!==o||0!==l||function(e,t,n,i){for(var r=0;r<2;++r){var a=e[r],s=t[r],o=Math.min(a,s),l=Math.max(a,s),h=n[r],c=i[r],u=Math.min(h,c);if(Math.max(h,c)<o||l<u)return!1}return!0}(e,t,i,r))};var n=Rce()[3]})),Ice=F(((e,t)=>{"use strict";t.exports=function(e,t,o,l){if(!s(e,t,o,l))return[[0],[0],[0]];var h=i([o[1]],[-l[1]]),c=i([-o[0]],[l[0]]),u=i(i(r(c,e[1]),r(c,-t[1])),i(r(h,e[0]),r(h,-t[0]))),d=i(n(-e[0],t[1]),n(e[1],t[0])),p=i(n(-o[0],l[1]),n(o[1],l[0])),f=i(i(r(p,e[0]),r(p,-t[0])),i(r(d,-o[0]),r(d,l[0]))),m=i(i(r(p,e[1]),r(p,-t[1])),i(r(d,-o[1]),r(d,l[1])));return[a(f),a(m),a(u)]};var n=tR(),i=UF(),r=FF(),a=Tce(),s=Cce()})),Lce=F(((e,t)=>{t.exports=function(e){var t=0,n=e.length;switch(n){case 1:t=e[0];break;case 2:t=e[0]+e[1];break;case 3:t=e[0]+e[1]+e[2];break;case 4:t=e[0]+e[1]+e[2]+e[3];break;default:for(var i=0;i<n;i++)t+=e[i]}return t}})),Nce=F(((e,t)=>{var n=Ice(),i=Lce();function r(e,t){return e[0]===t[0]&&e[1]===t[1]}t.exports=function(e,t){for(var c={},u=e.length,d=[],p=0;p<u;p++){var f=e[p],m=e[(p+1)%u];h(f,o),h(m,l);for(var g=0;g<u;g++)if(p!==g){var v=e[g],y=e[(g+1)%u];if(h(v,a),h(y,s),!(r(a,o)||r(a,l)||r(s,o)||r(s,l))){var x=n(o,l,a,s),_=x[2];if(1!==_.length||_[0]){var b=i(x[2]);if(x[0]=i(x[0])/b,x[1]=i(x[1])/b,x.pop(),!(r(x,o)||r(x,l)||r(x,a)||r(x,s))){var M=x+"",w=!c[M];w&&(c[M]=!0);var S=w;t&&(S=t(x,p,f,m,g,v,y,w)),S&&d.push(x)}}}}}return d};var a=[0,0],s=[0,0],o=[0,0],l=[0,0];function h(e,t){Array.isArray(e)?(t[0]=e[0],t[1]=e[1]):(t[0]=e.x,t[1]=e.y)}})),hue=F(((e,t)=>{function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){var n=this;function i(){n.off(e,i),t.apply(this,arguments)}return this._callbacks=this._callbacks||{},i.fn=t,this.on(e,i),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[e];if(!n)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var i,r=0;r<n.length;r++)if((i=n[r])===t||i.fn===t){n.splice(r,1);break}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks[e];if(n)for(var i=0,r=(n=n.slice(0)).length;i<r;++i)n[i].apply(this,t);return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}})),pue=F(((e,t)=>{var n=hue();function i(){n.call(this)}i.prototype=new n,t.exports=i,i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function r(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",r),!e._isStdio&&(!t||!1!==t.end)&&(n.on("end",s),n.on("close",o));var a=!1;function s(){a||(a=!0,e.end())}function o(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(h(),!this.hasListeners("error"))throw e}function h(){n.off("data",i),e.off("drain",r),n.off("end",s),n.off("close",o),n.off("error",l),e.off("error",l),n.off("end",h),n.off("close",h),e.off("end",h),e.off("close",h)}return n.on("error",l),e.on("error",l),n.on("end",h),n.on("close",h),e.on("end",h),e.on("close",h),e.emit("pipe",n),e}})),mue=F(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=Math.imul,t=Math.clz32;function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n,i=0;i<t.length;i++)(n=t[i]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function o(){return(o=s()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&a(r,n.prototype),r}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){function n(){return o(e,arguments,r(this).constructor)}if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},l(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){var t=s();return function(){var n,i=r(e);if(t){var a=r(this).constructor;n=Reflect.construct(i,arguments,a)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,n)}}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,a=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(a.push(i.value),!t||a.length!==t);s=!0);}catch(e){o=!0,r=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw r}}return a}}(e,t)||d(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var f=function(e){var t=Math.abs,r=Math.max,s=Math.floor;function o(e,t){var n;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=l.call(this,e)).sign=t,Object.setPrototypeOf(h(n),o.prototype),e>o.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return n}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(o,e);var l=c(o);return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(o,[{key:"toDebugString",value:function(){var e,t=["BigInt["],n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=d(e))){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}(this);try{for(n.s();!(e=n.n()).done;){var i=e.value;t.push((i&&(i>>>0).toString(16))+", ")}}catch(e){n.e(e)}finally{n.f()}return t.push("]"),t.join("")}},{key:"toString",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10;if(2>e||36<e)throw new RangeError("toString() radix argument must be between 2 and 36");return 0===this.length?"0":e&e-1?o.__toStringGeneric(this,e,!1):o.__toStringBasePowerOfTwo(this,e)}},{key:"valueOf",value:function(){throw new Error("Convert JSBI instances to native numbers using `toNumber`.")}},{key:"__copy",value:function(){for(var e=new o(this.length,this.sign),t=0;t<this.length;t++)e[t]=this[t];return e}},{key:"__trim",value:function(){for(var e=this.length,t=this[e-1];0===t;)t=this[--e-1],this.pop();return 0===e&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var e=0;e<this.length;e++)this[e]=0}},{key:"__clzmsd",value:function(){return o.__clz30(this.__digit(this.length-1))}},{key:"__inplaceMultiplyAdd",value:function(e,t,n){n>this.length&&(n=this.length);for(var i=32767&e,r=e>>>15,a=0,s=t,l=0;l<n;l++){var h=this.__digit(l),c=32767&h,u=h>>>15,d=o.__imul(c,i),p=o.__imul(c,r),f=o.__imul(u,i),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(u,r)+(p>>>15)+(f>>>15),this.__setDigit(l,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,n){for(var i,r=0,a=0;a<n;a++)r=(i=this.__halfDigit(t+a)+e.__halfDigit(a)+r)>>>15,this.__setHalfDigit(t+a,32767&i);return r}},{key:"__inplaceSub",value:function(e,t,n){var i=0;if(1&t){t>>=1;for(var r=this.__digit(t),a=32767&r,s=0;s<n-1>>>1;s++){var o=e.__digit(s),l=(r>>>15)-(32767&o)-i;i=1&l>>>15,this.__setDigit(t+s,(32767&l)<<15|32767&a),i=1&(a=(32767&(r=this.__digit(t+s+1)))-(o>>>15)-i)>>>15}var h=e.__digit(s),c=(r>>>15)-(32767&h)-i;if(i=1&c>>>15,this.__setDigit(t+s,(32767&c)<<15|32767&a),t+s+1>=this.length)throw new RangeError("out of bounds");!(1&n)&&(i=1&(a=(32767&(r=this.__digit(t+s+1)))-(h>>>15)-i)>>>15,this.__setDigit(t+e.length,1073709056&r|32767&a))}else{t>>=1;for(var u=0;u<e.length-1;u++){var d=this.__digit(t+u),p=e.__digit(u),f=(32767&d)-(32767&p)-i,m=(d>>>15)-(p>>>15)-(i=1&f>>>15);i=1&m>>>15,this.__setDigit(t+u,(32767&m)<<15|32767&f)}var g=this.__digit(t+u),v=e.__digit(u),y=(32767&g)-(32767&v)-i;i=1&y>>>15;var x=0;!(1&n)&&(i=1&(x=(g>>>15)-(v>>>15)-i)>>>15),this.__setDigit(t+u,(32767&x)<<15|32767&y)}return i}},{key:"__inplaceRightShift",value:function(e){if(0!==e){for(var t,n=this.__digit(0)>>>e,i=this.length-1,r=0;r<i;r++)t=this.__digit(r+1),this.__setDigit(r,1073741823&t<<30-e|n),n=t>>>e;this.__setDigit(i,n)}}},{key:"__digit",value:function(e){return this[e]}},{key:"__unsignedDigit",value:function(e){return this[e]>>>0}},{key:"__setDigit",value:function(e,t){this[e]=0|t}},{key:"__setDigitGrow",value:function(e,t){this[e]=0|t}},{key:"__halfDigitLength",value:function(){var e=this.length;return 32767>=this.__unsignedDigit(e-1)?2*e-1:2*e}},{key:"__halfDigit",value:function(e){return 32767&this[e>>>1]>>>15*(1&e)}},{key:"__setHalfDigit",value:function(e,t){var n=e>>>1,i=this.__digit(n),r=1&e?32767&i|t<<15:1073709056&i|32767&t;this.__setDigit(n,r)}}],[{key:"BigInt",value:function(e){var t=Number.isFinite;if("number"==typeof e){if(0===e)return o.__zero();if(o.__isOneDigitInt(e))return 0>e?o.__oneDigit(-e,!0):o.__oneDigit(e,!1);if(!t(e)||s(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return o.__fromDouble(e)}if("string"==typeof e){var i=o.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?o.__oneDigit(1,!1):o.__zero();if("object"===n(e)){if(e.constructor===o)return e;var r=o.__toPrimitive(e);return o.BigInt(r)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(e){var t=e.length;if(0===t)return 0;if(1===t){var n=e.__unsignedDigit(0);return e.sign?-n:n}var i=e.__digit(t-1),r=o.__clz30(i),a=30*t-r;if(1024<a)return e.sign?-1/0:1/0;var s=a-1,l=i,h=t-1,c=r+3,u=32===c?0:l<<c;u>>>=12;var d=c-12,p=12<=c?0:l<<20+c,f=20+c;for(0<d&&0<h&&(h--,u|=(l=e.__digit(h))>>>30-d,p=l<<d+2,f=d+2);0<f&&0<h;)h--,l=e.__digit(h),p|=30<=f?l<<f-30:l>>>30-f,f-=30;var m=o.__decideRounding(e,f,h,l);if((1===m||0===m&&1==(1&p))&&0==(p=p+1>>>0)&&++u>>>20!=0&&(u=0,1023<++s))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,o.__kBitConversionInts[1]=g|s|u,o.__kBitConversionInts[0]=p,o.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(e){if(0===e.length)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:"bitwiseNot",value:function(e){return e.sign?o.__absoluteSubOne(e).__trim():o.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return o.__oneDigit(1,!1);if(0===e.length)return e;if(1===e.length&&1===e.__digit(0))return!e.sign||1&t.__digit(0)?e:o.unaryMinus(e);if(1<t.length)throw new RangeError("BigInt too big");var n=t.__unsignedDigit(0);if(1===n)return e;if(n>=o.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var i=1+(0|n/30),r=new o(i,e.sign&&0!=(1&n));r.__initializeDigits();var a=1<<n%30;return r.__setDigit(i-1,a),r}var s=null,l=e;for(1&n&&(s=e),n>>=1;0!==n;n>>=1)l=o.multiply(l,l),1&n&&(s=null===s?l:o.multiply(s,l));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var n=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&n--;var i=new o(n,e.sign!==t.sign);i.__initializeDigits();for(var r=0;r<e.length;r++)o.__multiplyAccumulate(t,e.__digit(r),i,r);return i.__trim()}},{key:"divide",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>o.__absoluteCompare(e,t))return o.__zero();var n,i=e.sign!==t.sign,r=t.__unsignedDigit(0);if(1===t.length&&32767>=r){if(1===r)return i===e.sign?e:o.unaryMinus(e);n=o.__absoluteDivSmall(e,r,null)}else n=o.__absoluteDivLarge(e,t,!0,!1);return n.sign=i,n.__trim()}},{key:"remainder",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>o.__absoluteCompare(e,t))return e;var n=t.__unsignedDigit(0);if(1===t.length&&32767>=n){if(1===n)return o.__zero();var i=o.__absoluteModSmall(e,n);return 0===i?o.__zero():o.__oneDigit(i,e.sign)}var r=o.__absoluteDivLarge(e,t,!1,!0);return r.sign=e.sign,r.__trim()}},{key:"add",value:function(e,t){var n=e.sign;return n===t.sign?o.__absoluteAdd(e,t,n):0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n)}},{key:"subtract",value:function(e,t){var n=e.sign;return n===t.sign?0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n):o.__absoluteAdd(e,t,n)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__rightShiftByAbsolute(e,t):o.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__leftShiftByAbsolute(e,t):o.__rightShiftByAbsolute(e,t)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(e,t){return 0>o.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=o.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0<o.__compareToBigInt(e,t)}},{key:"greaterThanOrEqual",value:function(e,t){return 0<=o.__compareToBigInt(e,t)}},{key:"equal",value:function(e,t){if(e.sign!==t.sign||e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e.__digit(n)!==t.__digit(n))return!1;return!0}},{key:"notEqual",value:function(e,t){return!o.equal(e,t)}},{key:"bitwiseAnd",value:function(e,t){if(!e.sign&&!t.sign)return o.__absoluteAnd(e,t).__trim();if(e.sign&&t.sign){var n=r(e.length,t.length)+1,i=o.__absoluteSubOne(e,n),a=o.__absoluteSubOne(t);return i=o.__absoluteOr(i,a,i),o.__absoluteAddOne(i,!0,i).__trim()}if(e.sign){var s=[t,e];e=s[0],t=s[1]}return o.__absoluteAndNot(e,o.__absoluteSubOne(t)).__trim()}},{key:"bitwiseXor",value:function(e,t){if(!e.sign&&!t.sign)return o.__absoluteXor(e,t).__trim();if(e.sign&&t.sign){var n=r(e.length,t.length),i=o.__absoluteSubOne(e,n),a=o.__absoluteSubOne(t);return o.__absoluteXor(i,a,i).__trim()}var s=r(e.length,t.length)+1;if(e.sign){var l=[t,e];e=l[0],t=l[1]}var h=o.__absoluteSubOne(t,s);return h=o.__absoluteXor(h,e,h),o.__absoluteAddOne(h,!0,h).__trim()}},{key:"bitwiseOr",value:function(e,t){var n=r(e.length,t.length);if(!e.sign&&!t.sign)return o.__absoluteOr(e,t).__trim();if(e.sign&&t.sign){var i=o.__absoluteSubOne(e,n),a=o.__absoluteSubOne(t);return i=o.__absoluteAnd(i,a,i),o.__absoluteAddOne(i,!0,i).__trim()}if(e.sign){var s=[t,e];e=s[0],t=s[1]}var l=o.__absoluteSubOne(t,n);return l=o.__absoluteAndNot(l,e,l),o.__absoluteAddOne(l,!0,l).__trim()}},{key:"asIntN",value:function(e,t){if(0===t.length)return t;if(0>(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length<n)return t;var i=t.__unsignedDigit(n-1),r=1<<(e-1)%30;if(t.length===n&&i<r)return t;if((i&r)!==r)return o.__truncateToNBits(e,t);if(!t.sign)return o.__truncateAndSubFromPowerOfTwo(e,t,!0);if(!(i&r-1)){for(var a=n-2;0<=a;a--)if(0!==t.__digit(a))return o.__truncateAndSubFromPowerOfTwo(e,t,!1);return t.length===n&&i===r?t:o.__truncateToNBits(e,t)}return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}},{key:"asUintN",value:function(e,t){if(0===t.length)return t;if(0>(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(t.sign){if(e>o.__kMaxLengthBits)throw new RangeError("BigInt too big");return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length<n)return t;var i=e%30;if(t.length==n){if(0===i)return t;if(!(t.__digit(n-1)>>>i))return t}return o.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)&&o.__isBigInt(t))return o.add(e,t);if("number"==typeof e&&"number"==typeof t)return e+t;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(e,t){return o.__compare(e,t,0)}},{key:"LE",value:function(e,t){return o.__compare(e,t,1)}},{key:"GT",value:function(e,t){return o.__compare(e,t,2)}},{key:"GE",value:function(e,t){return o.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(o.__isBigInt(e))return o.__isBigInt(t)?o.equal(e,t):o.EQ(t,e);if("number"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("string"==typeof e){if(o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.equal(e,t);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("boolean"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,+e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("symbol"===n(e)){if(o.__isBigInt(t))return!1;if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else{if("object"!==n(e))return e==t;if("object"===n(t)&&t.constructor!==o)return e==t;e=o.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!o.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return o.asIntN(64,o.DataViewGetBigUint64(e,t,n))}},{key:"DataViewGetBigUint64",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=u(n?[4,0]:[0,4],2),r=i[0],a=i[1],s=e.getUint32(t+r,n),l=e.getUint32(t+a,n),h=new o(3,!1);return h.__setDigit(0,1073741823&l),h.__setDigit(1,(268435455&s)<<2|l>>>30),h.__setDigit(2,s>>>28),h.__trim()}},{key:"DataViewSetBigInt64",value:function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]&&arguments[3];o.DataViewSetBigUint64(e,t,n,i)}},{key:"DataViewSetBigUint64",value:function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]&&arguments[3],r=0,a=0;if(0<(n=o.asUintN(64,n)).length&&(a=n.__digit(0),1<n.length)){var s=n.__digit(1);a|=s<<30,r=s>>>2,2<n.length&&(r|=n.__digit(2)<<28)}var l=u(i?[4,0]:[0,4],2),h=l[0],c=l[1];e.setUint32(t+h,r,i),e.setUint32(t+c,a,i)}},{key:"__zero",value:function(){return new o(0,!1)}},{key:"__oneDigit",value:function(e,t){var n=new o(1,t);return n.__setDigit(0,e),n}},{key:"__decideRounding",value:function(e,t,n,i){if(0<t)return-1;var r;if(0>t)r=-t-1;else{if(0===n)return-1;n--,i=e.__digit(n),r=29}var a=1<<r;if(!(i&a))return-1;if(0!=(i&(a-=1)))return 1;for(;0<n;)if(n--,0!==e.__digit(n))return 1;return 0}},{key:"__fromDouble",value:function(e){o.__kBitConversionDouble[0]=e;var t,n=(2047&o.__kBitConversionInts[1]>>>20)-1023,i=1+(0|n/30),r=new o(i,0>e),a=1048575&o.__kBitConversionInts[1]|1048576,s=o.__kBitConversionInts[0],l=n%30,h=0;if(l<20){var c=20-l;h=c+32,t=a>>>c,a=a<<32-c|s>>>c,s<<=32-c}else if(20===l)h=32,t=a,a=s,s=0;else{var u=l-20;h=32-u,t=a<<u|s>>>32-u,a=s<<u,s=0}r.__setDigit(i-1,t);for(var d=i-2;0<=d;d--)0<h?(h-=30,t=a>>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(d,t);return r.__trim()}},{key:"__isWhitespace",value:function(e){return 13>=e&&9<=e||(159>=e?32==e:131071>=e?160==e||5760==e:196607>=e?10>=(e&=131071)||40==e||41==e||47==e||95==e||4096==e:65279==e)}},{key:"__fromString",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=0,i=e.length,r=0;if(r===i)return o.__zero();for(var a=e.charCodeAt(r);o.__isWhitespace(a);){if(++r===i)return o.__zero();a=e.charCodeAt(r)}if(43===a){if(++r===i)return null;a=e.charCodeAt(r),n=1}else if(45===a){if(++r===i)return null;a=e.charCodeAt(r),n=-1}if(0===t){if(t=10,48===a){if(++r===i)return o.__zero();if(88===(a=e.charCodeAt(r))||120===a){if(t=16,++r===i)return null;a=e.charCodeAt(r)}else if(79===a||111===a){if(t=8,++r===i)return null;a=e.charCodeAt(r)}else if(66===a||98===a){if(t=2,++r===i)return null;a=e.charCodeAt(r)}}}else if(16===t&&48===a){if(++r===i)return o.__zero();if(88===(a=e.charCodeAt(r))||120===a){if(++r===i)return null;a=e.charCodeAt(r)}}if(0!==n&&10!==t)return null;for(;48===a;){if(++r===i)return o.__zero();a=e.charCodeAt(r)}var s=i-r,l=o.__kMaxBitsPerChar[t],h=o.__kBitsPerCharTableMultiplier-1;if(s>1073741824/l)return null;var c=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),u=10>t?t:10,d=10<t?t-10:0;if(t&t-1){c.__initializeDigits();var p=!1,f=0;do{for(var m,g=0,v=1;;){if(m=void 0,a-48>>>0<u)m=a-48;else{if(!((32|a)-97>>>0<d)){p=!0;break}m=(32|a)-87}var y=v*t;if(1073741823<y)break;if(v=y,g=g*t+m,f++,++r===i){p=!0;break}a=e.charCodeAt(r)}var x=0|(l*f+(h=30*o.__kBitsPerCharTableMultiplier-1)>>>o.__kBitsPerCharTableShift)/30;c.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var _=[],b=[],M=!1;do{for(var w,S=0,E=0;;){if(w=void 0,a-48>>>0<u)w=a-48;else{if(!((32|a)-97>>>0<d)){M=!0;break}w=(32|a)-87}if(E+=l,S=S<<l|w,++r===i){M=!0;break}if(a=e.charCodeAt(r),30<E+l)break}_.push(S),b.push(E)}while(!M);o.__fillFromParts(c,_,b)}if(r!==i){if(!o.__isWhitespace(a))return null;for(r++;r<i;r++)if(a=e.charCodeAt(r),!o.__isWhitespace(a))return null}return c.sign=-1===n,c.__trim()}},{key:"__fillFromParts",value:function(e,t,n){for(var i=0,r=0,a=0,s=t.length-1;0<=s;s--){var o=t[s],l=n[s];r|=o<<a,30===(a+=l)?(e.__setDigit(i++,r),a=0,r=0):30<a&&(e.__setDigit(i++,1073741823&r),r=o>>>l-(a-=30))}if(0!==r){if(i>=e.length)throw new Error("implementation bug");e.__setDigit(i++,r)}for(;i<e.length;i++)e.__setDigit(i,0)}},{key:"__toStringBasePowerOfTwo",value:function(e,t){var n=e.length,i=t-1,r=i=(15&(i=(51&(i=(85&i>>>1)+(85&i))>>>2)+(51&i))>>>4)+(15&i),a=t-1,s=e.__digit(n-1),l=0|(30*n-o.__clz30(s)+r-1)/r;if(e.sign&&l++,268435456<l)throw new Error("string too long");for(var h=Array(l),c=l-1,u=0,d=0,p=0;p<n-1;p++){var f=e.__digit(p),m=(u|f<<d)&a;h[c--]=o.__kConversionChars[m];var g=r-d;for(u=f>>>g,d=30-g;d>=r;)h[c--]=o.__kConversionChars[u&a],u>>>=r,d-=r}var v=(u|s<<d)&a;for(h[c--]=o.__kConversionChars[v],u=s>>>r-d;0!==u;)h[c--]=o.__kConversionChars[u&a],u>>>=r;if(e.sign&&(h[c--]="-"),-1!==c)throw new Error("implementation bug");return h.join("")}},{key:"__toStringGeneric",value:function(e,t,n){var i=e.length;if(0===i)return"";if(1===i){var r=e.__unsignedDigit(0).toString(t);return!1===n&&e.sign&&(r="-"+r),r}var a,s,l=30*i-o.__clz30(e.__digit(i-1)),h=o.__kMaxBitsPerChar[t]-1,c=l*o.__kBitsPerCharTableMultiplier,u=1+(c=0|(c+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(u,!1)),p=d.__unsignedDigit(0);if(1===d.length&&32767>=p){(a=new o(e.length,!1)).__initializeDigits();for(var f,m=0,g=2*e.length-1;0<=g;g--)f=m<<15|e.__halfDigit(g),a.__setHalfDigit(g,0|f/p),m=0|f%p;s=m.toString(t)}else{var v=o.__absoluteDivLarge(e,d,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=o.__toStringGeneric(y,t,!0)}a.__trim();for(var x=o.__toStringGeneric(a,t,!0);s.length<u;)s="0"+s;return!1===n&&e.sign&&(x="-"+x),x+s}},{key:"__unequalSign",value:function(e){return e?-1:1}},{key:"__absoluteGreater",value:function(e){return e?-1:1}},{key:"__absoluteLess",value:function(e){return e?1:-1}},{key:"__compareToBigInt",value:function(e,t){var n=e.sign;if(n!==t.sign)return o.__unequalSign(n);var i=o.__absoluteCompare(e,t);return 0<i?o.__absoluteGreater(n):0>i?o.__absoluteLess(n):0}},{key:"__compareToNumber",value:function(e,n){if(o.__isOneDigitInt(n)){var i=e.sign,r=0>n;if(i!==r)return o.__unequalSign(i);if(0===e.length){if(r)throw new Error("implementation bug");return 0===n?0:-1}if(1<e.length)return o.__absoluteGreater(i);var a=t(n),s=e.__unsignedDigit(0);return s>a?o.__absoluteGreater(i):s<a?o.__absoluteLess(i):0}return o.__compareToDouble(e,n)}},{key:"__compareToDouble",value:function(e,t){if(t!=t)return t;if(t===1/0)return-1;if(t===-1/0)return 1;var n=e.sign;if(n!==0>t)return o.__unequalSign(n);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;o.__kBitConversionDouble[0]=t;var i=2047&o.__kBitConversionInts[1]>>>20;if(2047==i)throw new Error("implementation bug: handled elsewhere");var r=i-1023;if(0>r)return o.__absoluteGreater(n);var a=e.length,s=e.__digit(a-1),l=o.__clz30(s),h=30*a-l,c=r+1;if(h<c)return o.__absoluteLess(n);if(h>c)return o.__absoluteGreater(n);var u=1048576|1048575&o.__kBitConversionInts[1],d=o.__kBitConversionInts[0],p=29-l;if(p!==(0|(h-1)%30))throw new Error("implementation bug");var f,m=0;if(p<20){var g=20-p;m=g+32,f=u>>>g,u=u<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=u,u=d,d=0;else{var v=p-20;m=32-v,f=u<<v|d>>>32-v,u=d<<v,d=0}if((s>>>=0)>(f>>>=0))return o.__absoluteGreater(n);if(s<f)return o.__absoluteLess(n);for(var y=a-2;0<=y;y--){0<m?(m-=30,f=u>>>2,u=u<<30|d>>>2,d<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return o.__absoluteGreater(n);if(x<f)return o.__absoluteLess(n)}if(0!==u||0!==d){if(0===m)throw new Error("implementation bug");return o.__absoluteLess(n)}return 0}},{key:"__equalToNumber",value:function(e,n){return o.__isOneDigitInt(n)?0===n?0===e.length:1===e.length&&e.sign===0>n&&e.__unsignedDigit(0)===t(n):0===o.__compareToDouble(e,n)}},{key:"__comparisonResultToBool",value:function(e,t){return 0===t?0>e:1===t?0>=e:2===t?0<e:3===t?0<=e:void 0}},{key:"__compare",value:function(e,t,n){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e&&"string"==typeof t)switch(n){case 0:return e<t;case 1:return e<=t;case 2:return e>t;case 3:return e>=t}if(o.__isBigInt(e)&&"string"==typeof t)return null!==(t=o.__fromString(t))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("string"==typeof e&&o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)){if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("number"!=typeof t)throw new Error("implementation bug");return o.__comparisonResultToBool(o.__compareToNumber(e,t),n)}if("number"!=typeof e)throw new Error("implementation bug");if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToNumber(t,e),2^n);if("number"!=typeof t)throw new Error("implementation bug");return 0===n?e<t:1===n?e<=t:2===n?e>t:3===n?e>=t:void 0}},{key:"__absoluteAdd",value:function(e,t,n){if(e.length<t.length)return o.__absoluteAdd(t,e,n);if(0===e.length)return e;if(0===t.length)return e.sign===n?e:o.unaryMinus(e);var i=e.length;(0===e.__clzmsd()||t.length===e.length&&0===t.__clzmsd())&&i++;for(var r,a=new o(i,n),s=0,l=0;l<t.length;l++)s=(r=e.__digit(l)+t.__digit(l)+s)>>>30,a.__setDigit(l,1073741823&r);for(;l<e.length;l++){var h=e.__digit(l)+s;s=h>>>30,a.__setDigit(l,1073741823&h)}return l<a.length&&a.__setDigit(l,s),a.__trim()}},{key:"__absoluteSub",value:function(e,t,n){if(0===e.length)return e;if(0===t.length)return e.sign===n?e:o.unaryMinus(e);for(var i,r=new o(e.length,n),a=0,s=0;s<t.length;s++)a=1&(i=e.__digit(s)-t.__digit(s)-a)>>>30,r.__setDigit(s,1073741823&i);for(;s<e.length;s++){var l=e.__digit(s)-a;a=1&l>>>30,r.__setDigit(s,1073741823&l)}return r.__trim()}},{key:"__absoluteAddOne",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e.length;null===n?n=new o(i,t):n.sign=t;for(var r,a=1,s=0;s<i;s++)a=(r=e.__digit(s)+a)>>>30,n.__setDigit(s,1073741823&r);return 0!==a&&n.__setDigitGrow(i,1),n}},{key:"__absoluteSubOne",value:function(e,t){for(var n,i=e.length,r=new o(t=t||i,!1),a=1,s=0;s<i;s++)a=1&(n=e.__digit(s)-a)>>>30,r.__setDigit(s,1073741823&n);if(0!==a)throw new Error("implementation bug");for(var l=i;l<t;l++)r.__setDigit(l,0);return r}},{key:"__absoluteAnd",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e.length,r=t.length,a=r;if(i<r){a=i;var s=e,l=i;e=t,i=r,t=s,r=l}var h=a;null===n?n=new o(h,!1):h=n.length;for(var c=0;c<a;c++)n.__setDigit(c,e.__digit(c)&t.__digit(c));for(;c<h;c++)n.__setDigit(c,0);return n}},{key:"__absoluteAndNot",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e.length,r=t.length,a=r;i<r&&(a=i);var s=i;null===n?n=new o(s,!1):s=n.length;for(var l=0;l<a;l++)n.__setDigit(l,e.__digit(l)&~t.__digit(l));for(;l<i;l++)n.__setDigit(l,e.__digit(l));for(;l<s;l++)n.__setDigit(l,0);return n}},{key:"__absoluteOr",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e.length,r=t.length,a=r;if(i<r){a=i;var s=e,l=i;e=t,i=r,t=s,r=l}var h=i;null===n?n=new o(h,!1):h=n.length;for(var c=0;c<a;c++)n.__setDigit(c,e.__digit(c)|t.__digit(c));for(;c<i;c++)n.__setDigit(c,e.__digit(c));for(;c<h;c++)n.__setDigit(c,0);return n}},{key:"__absoluteXor",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e.length,r=t.length,a=r;if(i<r){a=i;var s=e,l=i;e=t,i=r,t=s,r=l}var h=i;null===n?n=new o(h,!1):h=n.length;for(var c=0;c<a;c++)n.__setDigit(c,e.__digit(c)^t.__digit(c));for(;c<i;c++)n.__setDigit(c,e.__digit(c));for(;c<h;c++)n.__setDigit(c,0);return n}},{key:"__absoluteCompare",value:function(e,t){var n=e.length-t.length;if(0!=n)return n;for(var i=e.length-1;0<=i&&e.__digit(i)===t.__digit(i);)i--;return 0>i?0:e.__unsignedDigit(i)>t.__unsignedDigit(i)?1:-1}},{key:"__multiplyAccumulate",value:function(e,t,n,i){if(0!==t){for(var r=32767&t,a=t>>>15,s=0,l=0,h=0;h<e.length;h++,i++){var c=n.__digit(i),u=e.__digit(h),d=32767&u,p=u>>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(c+=l+f+s)>>>30,c&=1073741823,s+=(c+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),n.__setDigit(i,1073741823&c)}for(;0!==s||0!==l;i++){var v=n.__digit(i);v+=s+l,l=0,s=v>>>30,n.__setDigit(i,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,n,i,r){for(var a=n,s=0,l=0;l<i;l++){var h=e.__digit(l),c=o.__imul(32767&h,t),u=o.__imul(h>>>15,t),d=c+((32767&u)<<15)+s+a;a=d>>>30,s=u>>>15,r.__setDigit(l,1073741823&d)}if(r.length>i)for(r.__setDigit(i++,a+s);i<r.length;)r.__setDigit(i++,0);else if(a+s!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;null===n&&(n=new o(e.length,!1));for(var i=0,r=2*e.length-1;0<=r;r-=2){var a=(i<<15|e.__halfDigit(r))>>>0,s=0|a/t,l=0|(a=((i=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;i=0|a%t,n.__setDigit(r>>>1,s<<15|l)}return n}},{key:"__absoluteModSmall",value:function(e,t){for(var n=0,i=2*e.length-1;0<=i;i--)n=0|((n<<15|e.__halfDigit(i))>>>0)%t;return n}},{key:"__absoluteDivLarge",value:function(e,t,n,i){var r=t.__halfDigitLength(),a=t.length,s=e.__halfDigitLength()-r,l=null;n&&(l=new o(s+2>>>1,!1)).__initializeDigits();var h=new o(r+2>>>1,!1);h.__initializeDigits();var c=o.__clz15(t.__halfDigit(r-1));0<c&&(t=o.__specialLeftShift(t,c,0));for(var u=o.__specialLeftShift(e,c,1),d=t.__halfDigit(r-1),p=0,f=s;0<=f;f--){var m=32767,g=u.__halfDigit(f+r);if(g!==d){var v=(g<<15|u.__halfDigit(f+r-1))>>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),_=u.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|_)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var b=u.__inplaceSub(h,f,r+1);0!==b&&(b=u.__inplaceAdd(t,f,r),u.__setHalfDigit(f+r,32767&u.__halfDigit(f+r)+b),m--),n&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(i)return u.__inplaceRightShift(c),n?{quotient:l,remainder:u}:u;if(n)return l;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return o.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,n){var i=e.length,r=new o(i+n,!1);if(0===t){for(var a=0;a<i;a++)r.__setDigit(a,e.__digit(a));return 0<n&&r.__setDigit(i,0),r}for(var s,l=0,h=0;h<i;h++)s=e.__digit(h),r.__setDigit(h,1073741823&s<<t|l),l=s>>>30-t;return 0<n&&r.__setDigit(i,l),r}},{key:"__leftShiftByAbsolute",value:function(e,t){var n=o.__toShiftAmount(t);if(0>n)throw new RangeError("BigInt too big");var i=0|n/30,r=n%30,a=e.length,s=0!==r&&e.__digit(a-1)>>>30-r!=0,l=a+i+(s?1:0),h=new o(l,e.sign);if(0===r){for(var c=0;c<i;c++)h.__setDigit(c,0);for(;c<l;c++)h.__setDigit(c,e.__digit(c-i))}else{for(var u=0,d=0;d<i;d++)h.__setDigit(d,0);for(var p,f=0;f<a;f++)p=e.__digit(f),h.__setDigit(f+i,1073741823&p<<r|u),u=p>>>30-r;if(s)h.__setDigit(a+i,u);else if(0!==u)throw new Error("implementation bug")}return h.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var n=e.length,i=e.sign,r=o.__toShiftAmount(t);if(0>r)return o.__rightShiftByMaximum(i);var a=0|r/30,s=r%30,l=n-a;if(0>=l)return o.__rightShiftByMaximum(i);var h=!1;if(i)if(e.__digit(a)&(1<<s)-1)h=!0;else for(var c=0;c<a;c++)if(0!==e.__digit(c)){h=!0;break}h&&0===s&&!~e.__digit(n-1)&&l++;var u=new o(l,i);if(0===s){u.__setDigit(l-1,0);for(var d=a;d<n;d++)u.__setDigit(d-a,e.__digit(d))}else{for(var p,f=e.__digit(a)>>>s,m=n-a-1,g=0;g<m;g++)p=e.__digit(g+a+1),u.__setDigit(g,1073741823&p<<30-s|f),f=p>>>s;u.__setDigit(m,f)}return h&&(u=o.__absoluteAddOne(u,!0,u)),u.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?o.__oneDigit(1,!0):o.__zero()}},{key:"__toShiftAmount",value:function(e){if(1<e.length)return-1;var t=e.__unsignedDigit(0);return t>o.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==n(e)||e.constructor===o)return e;if("undefined"!=typeof Symbol&&"symbol"===n(Symbol.toPrimitive)){var i=e[Symbol.toPrimitive];if(i){var r=i(t);if("object"!==n(r))return r;throw new TypeError("Cannot convert object to primitive value")}}var a=e.valueOf;if(a){var s=a.call(e);if("object"!==n(s))return s}var l=e.toString;if(l){var h=l.call(e);if("object"!==n(h))return h}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(e){return o.__isBigInt(e)?e:+e}},{key:"__isBigInt",value:function(e){return"object"===n(e)&&null!==e&&e.constructor===o}},{key:"__truncateToNBits",value:function(e,t){for(var n=0|(e+29)/30,i=new o(n,t.sign),r=n-1,a=0;a<r;a++)i.__setDigit(a,t.__digit(a));var s=t.__digit(r);if(e%30!=0){var l=32-e%30;s=s<<l>>>l}return i.__setDigit(r,s),i.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(e,t,n){for(var i,r=Math.min,a=0|(e+29)/30,s=new o(a,n),l=0,h=a-1,c=0,u=r(h,t.length);l<u;l++)c=1&(i=0-t.__digit(l)-c)>>>30,s.__setDigit(l,1073741823&i);for(;l<h;l++)s.__setDigit(l,0|1073741823&-c);var d,p=h<t.length?t.__digit(h):0,f=e%30;if(0===f)d=0-p-c,d&=1073741823;else{var m=32-f,g=1<<32-m;d=g-(p=p<<m>>>m)-c,d&=g-1}return s.__setDigit(h,d),s.__trim()}},{key:"__digitPow",value:function(e,t){for(var n=1;0<t;)1&t&&(n*=e),t>>>=1,e*=e;return n}},{key:"__isOneDigitInt",value:function(e){return(1073741823&e)===e}}]),o}(l(Array));return f.__kMaxLength=33554432,f.__kMaxLengthBits=f.__kMaxLength<<5,f.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],f.__kBitsPerCharTableShift=5,f.__kBitsPerCharTableMultiplier=1<<f.__kBitsPerCharTableShift,f.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],f.__kBitConversionBuffer=new ArrayBuffer(8),f.__kBitConversionDouble=new Float64Array(f.__kBitConversionBuffer),f.__kBitConversionInts=new Int32Array(f.__kBitConversionBuffer),f.__clz30=t?function(e){return t(e)-2}:function(e){var t=Math.LN2,n=Math.log;return 0===e?30:0|29-(0|n(e>>>0)/t)},f.__imul=e||function(e,t){return 0|e*t},f},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).JSBI=i()})),Ll=F(((e,t)=>{(function(){var n,i="Expected a function",r="__lodash_hash_undefined__",a="__lodash_placeholder__",s=32,o=128,l=1/0,h=9007199254740991,c=NaN,u=4294967295,d=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",256]],p="[object Arguments]",f="[object Array]",m="[object Boolean]",g="[object Date]",v="[object Error]",y="[object Function]",x="[object GeneratorFunction]",_="[object Map]",b="[object Number]",M="[object Object]",w="[object Promise]",S="[object RegExp]",E="[object Set]",T="[object String]",A="[object Symbol]",C="[object WeakMap]",R="[object ArrayBuffer]",P="[object DataView]",L="[object Float32Array]",D="[object Float64Array]",I="[object Int8Array]",O="[object Int16Array]",U="[object Int32Array]",N="[object Uint8Array]",F="[object Uint8ClampedArray]",k="[object Uint16Array]",B="[object Uint32Array]",z=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,H=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,j=/[&<>"']/g,W=RegExp(G.source),X=RegExp(j.source),q=/<%-([\s\S]+?)%>/g,Y=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,J=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q=/[\\^$.*+?()[\]{}|]/g,ee=RegExp(Q.source),te=/^\s+/,ne=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,re=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,oe=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ce=/\w*$/,ue=/^[-+]0x[0-9a-f]+$/i,de=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,fe=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",_e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",be="\\u2700-\\u27bf",Me="a-z\\xdf-\\xf6\\xf8-\\xff",we="A-Z\\xc0-\\xd6\\xd8-\\xde",Se="\\ufe0e\\ufe0f",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Te="["+xe+"]",Ae="["+Ee+"]",Ce="["+_e+"]",Re="\\d+",Pe="["+be+"]",Le="["+Me+"]",De="[^"+xe+Ee+Re+be+Me+we+"]",Ie="\\ud83c[\\udffb-\\udfff]",Oe="[^"+xe+"]",Ue="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe="["+we+"]",ke="\\u200d",Be="(?:"+Le+"|"+De+")",ze="(?:"+Fe+"|"+De+")",Ve="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",He="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Ge="(?:"+Ce+"|"+Ie+")?",je="["+Se+"]?",We=je+Ge+"(?:"+ke+"(?:"+[Oe,Ue,Ne].join("|")+")"+je+Ge+")*",Xe="(?:"+[Pe,Ue,Ne].join("|")+")"+We,qe="(?:"+[Oe+Ce+"?",Ce,Ue,Ne,Te].join("|")+")",Ye=RegExp("['\u2019]","g"),$e=RegExp(Ce,"g"),Ke=RegExp(Ie+"(?="+Ie+")|"+qe+We,"g"),Ze=RegExp([Fe+"?"+Le+"+"+Ve+"(?="+[Ae,Fe,"$"].join("|")+")",ze+"+"+He+"(?="+[Ae,Fe+Be,"$"].join("|")+")",Fe+"?"+Be+"+"+Ve,Fe+"+"+He,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Re,Xe].join("|"),"g"),Je=RegExp("["+ke+xe+_e+Se+"]"),Qe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],tt=-1,nt={};nt[L]=nt[D]=nt[I]=nt[O]=nt[U]=nt[N]=nt[F]=nt[k]=nt[B]=!0,nt[p]=nt[f]=nt[R]=nt[m]=nt[P]=nt[g]=nt[v]=nt[y]=nt[_]=nt[b]=nt[M]=nt[S]=nt[E]=nt[T]=nt[C]=!1;var it={};it[p]=it[f]=it[R]=it[P]=it[m]=it[g]=it[L]=it[D]=it[I]=it[O]=it[U]=it[_]=it[b]=it[M]=it[S]=it[E]=it[T]=it[A]=it[N]=it[F]=it[k]=it[B]=!0,it[v]=it[y]=it[C]=!1;var rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,st=parseInt,ot="object"==typeof global&&global&&global.Object===Object&&global,lt="object"==typeof self&&self&&self.Object===Object&&self,ht=ot||lt||Function("return this")(),ct="object"==typeof e&&e&&!e.nodeType&&e,ut=ct&&"object"==typeof t&&t&&!t.nodeType&&t,dt=ut&&ut.exports===ct,pt=dt&&ot.process,ft=function(){try{return ut&&ut.require&&ut.require("util").types||pt&&pt.binding&&pt.binding("util")}catch(e){}}(),mt=ft&&ft.isArrayBuffer,gt=ft&&ft.isDate,vt=ft&&ft.isMap,yt=ft&&ft.isRegExp,xt=ft&&ft.isSet,_t=ft&&ft.isTypedArray;function bt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Mt(e,t,n,i){for(var r=-1,a=null==e?0:e.length;++r<a;){var s=e[r];t(i,s,n(s),e)}return i}function wt(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););return e}function St(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Et(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(!t(e[n],n,e))return!1;return!0}function Tt(e,t){for(var n=-1,i=null==e?0:e.length,r=0,a=[];++n<i;){var s=e[n];t(s,n,e)&&(a[r++]=s)}return a}function At(e,t){return!(null==e||!e.length)&&Ft(e,t,0)>-1}function Ct(e,t,n){for(var i=-1,r=null==e?0:e.length;++i<r;)if(n(t,e[i]))return!0;return!1}function Rt(e,t){for(var n=-1,i=null==e?0:e.length,r=Array(i);++n<i;)r[n]=t(e[n],n,e);return r}function Pt(e,t){for(var n=-1,i=t.length,r=e.length;++n<i;)e[r+n]=t[n];return e}function Lt(e,t,n,i){var r=-1,a=null==e?0:e.length;for(i&&a&&(n=e[++r]);++r<a;)n=t(n,e[r],r,e);return n}function Dt(e,t,n,i){var r=null==e?0:e.length;for(i&&r&&(n=e[--r]);r--;)n=t(n,e[r],r,e);return n}function It(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}var Ot=Vt("length");function Ut(e,t,n){var i;return n(e,(function(e,n,r){if(t(e,n,r))return i=n,!1})),i}function Nt(e,t,n,i){for(var r=e.length,a=n+(i?1:-1);i?a--:++a<r;)if(t(e[a],a,e))return a;return-1}function Ft(e,t,n){return t==t?function(e,t,n){for(var i=n-1,r=e.length;++i<r;)if(e[i]===t)return i;return-1}(e,t,n):Nt(e,Bt,n)}function kt(e,t,n,i){for(var r=n-1,a=e.length;++r<a;)if(i(e[r],t))return r;return-1}function Bt(e){return e!=e}function zt(e,t){var n=null==e?0:e.length;return n?jt(e,t)/n:c}function Vt(e){return function(t){return null==t?n:t[e]}}function Ht(e){return function(t){return null==e?n:e[t]}}function Gt(e,t,n,i,r){return r(e,(function(e,r,a){n=i?(i=!1,e):t(n,e,r,a)})),n}function jt(e,t){for(var i,r=-1,a=e.length;++r<a;){var s=t(e[r]);s!==n&&(i=i===n?s:i+s)}return i}function Wt(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}function Xt(e){return e&&e.slice(0,hn(e)+1).replace(te,"")}function qt(e){return function(t){return e(t)}}function Yt(e,t){return Rt(t,(function(t){return e[t]}))}function $t(e,t){return e.has(t)}function Kt(e,t){for(var n=-1,i=e.length;++n<i&&Ft(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&Ft(t,e[n],0)>-1;);return n}var Jt=Ht({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),Qt=Ht({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function en(e){return"\\"+rt[e]}function tn(e){return Je.test(e)}function nn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function rn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,i=e.length,r=0,s=[];++n<i;){var o=e[n];(o===t||o===a)&&(e[n]=a,s[r++]=n)}return s}function sn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function on(e){return tn(e)?function(e){for(var t=Ke.lastIndex=0;Ke.test(e);)++t;return t}(e):Ot(e)}function ln(e){return tn(e)?function(e){return e.match(Ke)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&ne.test(e.charAt(t)););return t}var cn=Ht({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),un=function e(t){var ne,xe=(t=null==t?ht:un.defaults(ht.Object(),t,un.pick(ht,et))).Array,_e=t.Date,be=t.Error,Me=t.Function,we=t.Math,Se=t.Object,Ee=t.RegExp,Te=t.String,Ae=t.TypeError,Ce=xe.prototype,Re=Me.prototype,Pe=Se.prototype,Le=t["__core-js_shared__"],De=Re.toString,Ie=Pe.hasOwnProperty,Oe=0,Ue=(ne=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"",Ne=Pe.toString,Fe=De.call(Se),ke=ht._,Be=Ee("^"+De.call(Ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:n,Ve=t.Symbol,He=t.Uint8Array,Ge=ze?ze.allocUnsafe:n,je=rn(Se.getPrototypeOf,Se),We=Se.create,Xe=Pe.propertyIsEnumerable,qe=Ce.splice,Ke=Ve?Ve.isConcatSpreadable:n,Je=Ve?Ve.iterator:n,rt=Ve?Ve.toStringTag:n,ot=function(){try{var e=oa(Se,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=_e&&_e.now!==ht.Date.now&&_e.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,pt=we.ceil,ft=we.floor,Ot=Se.getOwnPropertySymbols,Ht=ze?ze.isBuffer:n,dn=t.isFinite,pn=Ce.join,fn=rn(Se.keys,Se),mn=we.max,gn=we.min,vn=_e.now,yn=t.parseInt,xn=we.random,_n=Ce.reverse,bn=oa(t,"DataView"),Mn=oa(t,"Map"),wn=oa(t,"Promise"),Sn=oa(t,"Set"),En=oa(t,"WeakMap"),Tn=oa(Se,"create"),An=En&&new En,Cn={},Rn=Ia(bn),Pn=Ia(Mn),Ln=Ia(wn),Dn=Ia(Sn),In=Ia(En),On=Ve?Ve.prototype:n,Un=On?On.valueOf:n,Nn=On?On.toString:n;function Fn(e){if(Ks(e)&&!Bs(e)&&!(e instanceof Vn)){if(e instanceof zn)return e;if(Ie.call(e,"__wrapped__"))return Oa(e)}return new zn(e)}var kn=function(){function e(){}return function(t){if(!$s(t))return{};if(We)return We(t);e.prototype=t;var i=new e;return e.prototype=n,i}}();function Bn(){}function zn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Vn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=u,this.__views__=[]}function Hn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new jn;++t<n;)this.add(e[t])}function Xn(e){var t=this.__data__=new Gn(e);this.size=t.size}function qn(e,t){var n=Bs(e),i=!n&&ks(e),r=!n&&!i&&Gs(e),a=!n&&!i&&!r&&ro(e),s=n||i||r||a,o=s?Wt(e.length,Te):[],l=o.length;for(var h in e)(t||Ie.call(e,h))&&(!s||!("length"==h||r&&("offset"==h||"parent"==h)||a&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||fa(h,l)))&&o.push(h);return o}function Yn(e){var t=e.length;return t?e[ji(0,t-1)]:n}function $n(e,t){return Pa(Er(e),ri(t,0,e.length))}function Kn(e){return Pa(Er(e))}function Zn(e,t,i){(i!==n&&!Us(e[t],i)||i===n&&!(t in e))&&ni(e,t,i)}function Jn(e,t,i){var r=e[t];(!Ie.call(e,t)||!Us(r,i)||i===n&&!(t in e))&&ni(e,t,i)}function Qn(e,t){for(var n=e.length;n--;)if(Us(e[n][0],t))return n;return-1}function ei(e,t,n,i){return hi(e,(function(e,r,a){t(i,e,n(e),a)})),i}function ti(e,t){return e&&Tr(t,Ao(t),e)}function ni(e,t,n){"__proto__"==t&&ot?ot(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ii(e,t){for(var i=-1,r=t.length,a=xe(r),s=null==e;++i<r;)a[i]=s?n:Mo(e,t[i]);return a}function ri(e,t,i){return e==e&&(i!==n&&(e=e<=i?e:i),t!==n&&(e=e>=t?e:t)),e}function ai(e,t,i,r,a,s){var o,l=1&t,h=2&t,c=4&t;if(i&&(o=a?i(e,r,a,s):i(e)),o!==n)return o;if(!$s(e))return e;var u=Bs(e);if(u){if(o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Ie.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Er(e,o)}else{var d=ca(e),f=d==y||d==x;if(Gs(e))return xr(e,l);if(d==M||d==p||f&&!a){if(o=h||f?{}:da(e),!l)return h?function(e,t){return Tr(e,ha(e),t)}(e,function(e,t){return e&&Tr(t,Co(t),e)}(o,e)):function(e,t){return Tr(e,la(e),t)}(e,ti(o,e))}else{if(!it[d])return a?e:{};o=function(e,t,n){var i=e.constructor;switch(t){case R:return _r(e);case m:case g:return new i(+e);case P:return function(e,t){var n=t?_r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case L:case D:case I:case O:case U:case N:case F:case k:case B:return br(e,n);case _:return new i;case b:case T:return new i(e);case S:return function(e){var t=new e.constructor(e.source,ce.exec(e));return t.lastIndex=e.lastIndex,t}(e);case E:return new i;case A:return function(e){return Un?Se(Un.call(e)):{}}(e)}}(e,d,l)}}s||(s=new Xn);var v=s.get(e);if(v)return v;s.set(e,o),to(e)?e.forEach((function(n){o.add(ai(n,t,i,n,e,s))})):Zs(e)&&e.forEach((function(n,r){o.set(r,ai(n,t,i,r,e,s))}));var w=u?n:(c?h?ea:Qr:h?Co:Ao)(e);return wt(w||e,(function(n,r){w&&(n=e[r=n]),Jn(o,r,ai(n,t,i,r,e,s))})),o}function si(e,t,i){var r=i.length;if(null==e)return!r;for(e=Se(e);r--;){var a=i[r],s=t[a],o=e[a];if(o===n&&!(a in e)||!s(o))return!1}return!0}function oi(e,t,r){if("function"!=typeof e)throw new Ae(i);return Ta((function(){e.apply(n,r)}),t)}function li(e,t,n,i){var r=-1,a=At,s=!0,o=e.length,l=[],h=t.length;if(!o)return l;n&&(t=Rt(t,qt(n))),i?(a=Ct,s=!1):t.length>=200&&(a=$t,s=!1,t=new Wn(t));e:for(;++r<o;){var c=e[r],u=null==n?c:n(c);if(c=i||0!==c?c:0,s&&u==u){for(var d=h;d--;)if(t[d]===u)continue e;l.push(c)}else a(t,u,i)||l.push(c)}return l}Fn.templateSettings={escape:q,evaluate:Y,interpolate:$,variable:"",imports:{_:Fn}},Fn.prototype=Bn.prototype,Fn.prototype.constructor=Fn,zn.prototype=kn(Bn.prototype),zn.prototype.constructor=zn,Vn.prototype=kn(Bn.prototype),Vn.prototype.constructor=Vn,Hn.prototype.clear=function(){this.__data__=Tn?Tn(null):{},this.size=0},Hn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hn.prototype.get=function(e){var t=this.__data__;if(Tn){var i=t[e];return i===r?n:i}return Ie.call(t,e)?t[e]:n},Hn.prototype.has=function(e){var t=this.__data__;return Tn?t[e]!==n:Ie.call(t,e)},Hn.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Tn&&t===n?r:t,this},Gn.prototype.clear=function(){this.__data__=[],this.size=0},Gn.prototype.delete=function(e){var t=this.__data__,n=Qn(t,e);return!(n<0)&&(n==t.length-1?t.pop():qe.call(t,n,1),--this.size,!0)},Gn.prototype.get=function(e){var t=this.__data__,i=Qn(t,e);return i<0?n:t[i][1]},Gn.prototype.has=function(e){return Qn(this.__data__,e)>-1},Gn.prototype.set=function(e,t){var n=this.__data__,i=Qn(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this},jn.prototype.clear=function(){this.size=0,this.__data__={hash:new Hn,map:new(Mn||Gn),string:new Hn}},jn.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},jn.prototype.get=function(e){return aa(this,e).get(e)},jn.prototype.has=function(e){return aa(this,e).has(e)},jn.prototype.set=function(e,t){var n=aa(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,r),this},Wn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.clear=function(){this.__data__=new Gn,this.size=0},Xn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Xn.prototype.get=function(e){return this.__data__.get(e)},Xn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Gn){var i=n.__data__;if(!Mn||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new jn(i)}return n.set(e,t),this.size=n.size,this};var hi=Rr(vi),ci=Rr(yi,!0);function ui(e,t){var n=!0;return hi(e,(function(e,i,r){return n=!!t(e,i,r)})),n}function di(e,t,i){for(var r=-1,a=e.length;++r<a;){var s=e[r],o=t(s);if(null!=o&&(l===n?o==o&&!io(o):i(o,l)))var l=o,h=s}return h}function pi(e,t){var n=[];return hi(e,(function(e,i,r){t(e,i,r)&&n.push(e)})),n}function fi(e,t,n,i,r){var a=-1,s=e.length;for(n||(n=pa),r||(r=[]);++a<s;){var o=e[a];t>0&&n(o)?t>1?fi(o,t-1,n,i,r):Pt(r,o):i||(r[r.length]=o)}return r}var mi=Pr(),gi=Pr(!0);function vi(e,t){return e&&mi(e,t,Ao)}function yi(e,t){return e&&gi(e,t,Ao)}function xi(e,t){return Tt(t,(function(t){return Xs(e[t])}))}function _i(e,t){for(var i=0,r=(t=mr(t,e)).length;null!=e&&i<r;)e=e[Da(t[i++])];return i&&i==r?e:n}function bi(e,t,n){var i=t(e);return Bs(e)?i:Pt(i,n(e))}function Mi(e){return null==e?e===n?"[object Undefined]":"[object Null]":rt&&rt in Se(e)?function(e){var t=Ie.call(e,rt),i=e[rt];try{e[rt]=n;var r=!0}catch(e){}var a=Ne.call(e);return r&&(t?e[rt]=i:delete e[rt]),a}(e):function(e){return Ne.call(e)}(e)}function wi(e,t){return e>t}function Si(e,t){return null!=e&&Ie.call(e,t)}function Ei(e,t){return null!=e&&t in Se(e)}function Ti(e,t,i){for(var r=i?Ct:At,a=e[0].length,s=e.length,o=s,l=xe(s),h=1/0,c=[];o--;){var u=e[o];o&&t&&(u=Rt(u,qt(t))),h=gn(u.length,h),l[o]=!i&&(t||a>=120&&u.length>=120)?new Wn(o&&u):n}u=e[0];var d=-1,p=l[0];e:for(;++d<a&&c.length<h;){var f=u[d],m=t?t(f):f;if(f=i||0!==f?f:0,!(p?$t(p,m):r(c,m,i))){for(o=s;--o;){var g=l[o];if(!(g?$t(g,m):r(e[o],m,i)))continue e}p&&p.push(m),c.push(f)}}return c}function Ai(e,t,i){var r=null==(e=wa(e,t=mr(t,e)))?e:e[Da(Wa(t))];return null==r?n:bt(r,e,i)}function Ci(e){return Ks(e)&&Mi(e)==p}function Ri(e,t,i,r,a){return e===t||(null==e||null==t||!Ks(e)&&!Ks(t)?e!=e&&t!=t:function(e,t,i,r,a,s){var o=Bs(e),l=Bs(t),h=o?f:ca(e),c=l?f:ca(t),u=(h=h==p?M:h)==M,d=(c=c==p?M:c)==M,y=h==c;if(y&&Gs(e)){if(!Gs(t))return!1;o=!0,u=!1}if(y&&!u)return s||(s=new Xn),o||ro(e)?Zr(e,t,i,r,a,s):function(e,t,n,i,r,a,s){switch(n){case P:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case R:return!(e.byteLength!=t.byteLength||!a(new He(e),new He(t)));case m:case g:case b:return Us(+e,+t);case v:return e.name==t.name&&e.message==t.message;case S:case T:return e==t+"";case _:var o=nn;case E:var l=1&i;if(o||(o=sn),e.size!=t.size&&!l)return!1;var h=s.get(e);if(h)return h==t;i|=2,s.set(e,t);var c=Zr(o(e),o(t),i,r,a,s);return s.delete(e),c;case A:if(Un)return Un.call(e)==Un.call(t)}return!1}(e,t,h,i,r,a,s);if(!(1&i)){var x=u&&Ie.call(e,"__wrapped__"),w=d&&Ie.call(t,"__wrapped__");if(x||w){var C=x?e.value():e,L=w?t.value():t;return s||(s=new Xn),a(C,L,i,r,s)}}return!!y&&(s||(s=new Xn),function(e,t,i,r,a,s){var o=1&i,l=Qr(e),h=l.length;if(h!=Qr(t).length&&!o)return!1;for(var c=h;c--;){var u=l[c];if(!(o?u in t:Ie.call(t,u)))return!1}var d=s.get(e),p=s.get(t);if(d&&p)return d==t&&p==e;var f=!0;s.set(e,t),s.set(t,e);for(var m=o;++c<h;){var g=e[u=l[c]],v=t[u];if(r)var y=o?r(v,g,u,t,e,s):r(g,v,u,e,t,s);if(!(y===n?g===v||a(g,v,i,r,s):y)){f=!1;break}m||(m="constructor"==u)}if(f&&!m){var x=e.constructor,_=t.constructor;x!=_&&"constructor"in e&&"constructor"in t&&!("function"==typeof x&&x instanceof x&&"function"==typeof _&&_ instanceof _)&&(f=!1)}return s.delete(e),s.delete(t),f}(e,t,i,r,a,s))}(e,t,i,r,Ri,a))}function Pi(e,t,i,r){var a=i.length,s=a,o=!r;if(null==e)return!s;for(e=Se(e);a--;){var l=i[a];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++a<s;){var h=(l=i[a])[0],c=e[h],u=l[1];if(o&&l[2]){if(c===n&&!(h in e))return!1}else{var d=new Xn;if(r)var p=r(c,u,h,e,t,d);if(!(p===n?Ri(u,c,3,r,d):p))return!1}}return!0}function Li(e){return!(!$s(e)||function(e){return!!Ue&&Ue in e}(e))&&(Xs(e)?Be:pe).test(Ia(e))}function Di(e){return"function"==typeof e?e:null==e?Qo:"object"==typeof e?Bs(e)?Fi(e[0],e[1]):Ni(e):ll(e)}function Ii(e){if(!xa(e))return fn(e);var t=[];for(var n in Se(e))Ie.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Oi(e,t){return e<t}function Ui(e,t){var n=-1,i=Vs(e)?xe(e.length):[];return hi(e,(function(e,r,a){i[++n]=t(e,r,a)})),i}function Ni(e){var t=sa(e);return 1==t.length&&t[0][2]?ba(t[0][0],t[0][1]):function(n){return n===e||Pi(n,e,t)}}function Fi(e,t){return ga(e)&&_a(t)?ba(Da(e),t):function(i){var r=Mo(i,e);return r===n&&r===t?wo(i,e):Ri(t,r,3)}}function ki(e,t,i,r,a){e!==t&&mi(t,(function(s,o){if(a||(a=new Xn),$s(s))!function(e,t,i,r,a,s,o){var l=Sa(e,i),h=Sa(t,i),c=o.get(h);if(c)Zn(e,i,c);else{var u=s?s(l,h,i+"",e,t,o):n,d=u===n;if(d){var p=Bs(h),f=!p&&Gs(h),m=!p&&!f&&ro(h);u=h,p||f||m?Bs(l)?u=l:Hs(l)?u=Er(l):f?(d=!1,u=xr(h,!0)):m?(d=!1,u=br(h,!0)):u=[]:Qs(h)||ks(h)?(u=l,ks(l)?u=po(l):(!$s(l)||Xs(l))&&(u=da(h))):d=!1}d&&(o.set(h,u),a(u,h,r,s,o),o.delete(h)),Zn(e,i,u)}}(e,t,o,i,ki,r,a);else{var l=r?r(Sa(e,o),s,o+"",e,t,a):n;l===n&&(l=s),Zn(e,o,l)}}),Co)}function Bi(e,t){var i=e.length;if(i)return fa(t+=t<0?i:0,i)?e[t]:n}function zi(e,t,n){t=t.length?Rt(t,(function(e){return Bs(e)?function(t){return _i(t,1===e.length?e[0]:e)}:e})):[Qo];var i=-1;return t=Rt(t,qt(ra())),function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(Ui(e,(function(e,n,r){return{criteria:Rt(t,(function(t){return t(e)})),index:++i,value:e}})),(function(e,t){return function(e,t,n){for(var i=-1,r=e.criteria,a=t.criteria,s=r.length,o=n.length;++i<s;){var l=Mr(r[i],a[i]);if(l)return i>=o?l:l*("desc"==n[i]?-1:1)}return e.index-t.index}(e,t,n)}))}function Vi(e,t,n){for(var i=-1,r=t.length,a={};++i<r;){var s=t[i],o=_i(e,s);n(o,s)&&$i(a,mr(s,e),o)}return a}function Hi(e,t,n,i){var r=i?kt:Ft,a=-1,s=t.length,o=e;for(e===t&&(t=Er(t)),n&&(o=Rt(e,qt(n)));++a<s;)for(var l=0,h=t[a],c=n?n(h):h;(l=r(o,c,l,i))>-1;)o!==e&&qe.call(o,l,1),qe.call(e,l,1);return e}function Gi(e,t){for(var n=e?t.length:0,i=n-1;n--;){var r=t[n];if(n==i||r!==a){var a=r;fa(r)?qe.call(e,r,1):or(e,r)}}return e}function ji(e,t){return e+ft(xn()*(t-e+1))}function Wi(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=ft(t/2))&&(e+=e)}while(t);return n}function Xi(e,t){return Aa(Ma(e,t,Qo),e+"")}function qi(e){return Yn(No(e))}function Yi(e,t){var n=No(e);return Pa(n,ri(t,0,n.length))}function $i(e,t,i,r){if(!$s(e))return e;for(var a=-1,s=(t=mr(t,e)).length,o=s-1,l=e;null!=l&&++a<s;){var h=Da(t[a]),c=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(a!=o){var u=l[h];(c=r?r(u,h,l):n)===n&&(c=$s(u)?u:fa(t[a+1])?[]:{})}Jn(l,h,c),l=l[h]}return e}var Ki=An?function(e,t){return An.set(e,t),e}:Qo,Zi=ot?function(e,t){return ot(e,"toString",{configurable:!0,enumerable:!1,value:Ko(t),writable:!0})}:Qo;function Ji(e){return Pa(No(e))}function Qi(e,t,n){var i=-1,r=e.length;t<0&&(t=-t>r?0:r+t),(n=n>r?r:n)<0&&(n+=r),r=t>n?0:n-t>>>0,t>>>=0;for(var a=xe(r);++i<r;)a[i]=e[i+t];return a}function er(e,t){var n;return hi(e,(function(e,i,r){return!(n=t(e,i,r))})),!!n}function tr(e,t,n){var i=0,r=null==e?i:e.length;if("number"==typeof t&&t==t&&r<=2147483647){for(;i<r;){var a=i+r>>>1,s=e[a];null!==s&&!io(s)&&(n?s<=t:s<t)?i=a+1:r=a}return r}return nr(e,t,Qo,n)}function nr(e,t,i,r){var a=0,s=null==e?0:e.length;if(0===s)return 0;for(var o=(t=i(t))!=t,l=null===t,h=io(t),c=t===n;a<s;){var u=ft((a+s)/2),d=i(e[u]),p=d!==n,f=null===d,m=d==d,g=io(d);if(o)var v=r||m;else v=c?m&&(r||p):l?m&&p&&(r||!f):h?m&&p&&!f&&(r||!g):!f&&!g&&(r?d<=t:d<t);v?a=u+1:s=u}return gn(s,4294967294)}function ir(e,t){for(var n=-1,i=e.length,r=0,a=[];++n<i;){var s=e[n],o=t?t(s):s;if(!n||!Us(o,l)){var l=o;a[r++]=0===s?0:s}}return a}function rr(e){return"number"==typeof e?e:io(e)?c:+e}function ar(e){if("string"==typeof e)return e;if(Bs(e))return Rt(e,ar)+"";if(io(e))return Nn?Nn.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}function sr(e,t,n){var i=-1,r=At,a=e.length,s=!0,o=[],l=o;if(n)s=!1,r=Ct;else if(a>=200){var h=t?null:Wr(e);if(h)return sn(h);s=!1,r=$t,l=new Wn}else l=t?[]:o;e:for(;++i<a;){var c=e[i],u=t?t(c):c;if(c=n||0!==c?c:0,s&&u==u){for(var d=l.length;d--;)if(l[d]===u)continue e;t&&l.push(u),o.push(c)}else r(l,u,n)||(l!==o&&l.push(u),o.push(c))}return o}function or(e,t){return null==(e=wa(e,t=mr(t,e)))||delete e[Da(Wa(t))]}function lr(e,t,n,i){return $i(e,t,n(_i(e,t)),i)}function hr(e,t,n,i){for(var r=e.length,a=i?r:-1;(i?a--:++a<r)&&t(e[a],a,e););return n?Qi(e,i?0:a,i?a+1:r):Qi(e,i?a+1:0,i?r:a)}function cr(e,t){var n=e;return n instanceof Vn&&(n=n.value()),Lt(t,(function(e,t){return t.func.apply(t.thisArg,Pt([e],t.args))}),n)}function ur(e,t,n){var i=e.length;if(i<2)return i?sr(e[0]):[];for(var r=-1,a=xe(i);++r<i;)for(var s=e[r],o=-1;++o<i;)o!=r&&(a[r]=li(a[r]||s,e[o],t,n));return sr(fi(a,1),t,n)}function dr(e,t,i){for(var r=-1,a=e.length,s=t.length,o={};++r<a;){var l=r<s?t[r]:n;i(o,e[r],l)}return o}function pr(e){return Hs(e)?e:[]}function fr(e){return"function"==typeof e?e:Qo}function mr(e,t){return Bs(e)?e:ga(e,t)?[e]:La(fo(e))}var gr=Xi;function vr(e,t,i){var r=e.length;return i=i===n?r:i,!t&&i>=r?e:Qi(e,t,i)}var yr=lt||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,i=Ge?Ge(n):new e.constructor(n);return e.copy(i),i}function _r(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function br(e,t){var n=t?_r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Mr(e,t){if(e!==t){var i=e!==n,r=null===e,a=e==e,s=io(e),o=t!==n,l=null===t,h=t==t,c=io(t);if(!l&&!c&&!s&&e>t||s&&o&&h&&!l&&!c||r&&o&&h||!i&&h||!a)return 1;if(!r&&!s&&!c&&e<t||c&&i&&a&&!r&&!s||l&&i&&a||!o&&a||!h)return-1}return 0}function wr(e,t,n,i){for(var r=-1,a=e.length,s=n.length,o=-1,l=t.length,h=mn(a-s,0),c=xe(l+h),u=!i;++o<l;)c[o]=t[o];for(;++r<s;)(u||r<a)&&(c[n[r]]=e[r]);for(;h--;)c[o++]=e[r++];return c}function Sr(e,t,n,i){for(var r=-1,a=e.length,s=-1,o=n.length,l=-1,h=t.length,c=mn(a-o,0),u=xe(c+h),d=!i;++r<c;)u[r]=e[r];for(var p=r;++l<h;)u[p+l]=t[l];for(;++s<o;)(d||r<a)&&(u[p+n[s]]=e[r++]);return u}function Er(e,t){var n=-1,i=e.length;for(t||(t=xe(i));++n<i;)t[n]=e[n];return t}function Tr(e,t,i,r){var a=!i;i||(i={});for(var s=-1,o=t.length;++s<o;){var l=t[s],h=r?r(i[l],e[l],l,i,e):n;h===n&&(h=e[l]),a?ni(i,l,h):Jn(i,l,h)}return i}function Ar(e,t){return function(n,i){var r=Bs(n)?Mt:ei,a=t?t():{};return r(n,e,ra(i,2),a)}}function Cr(e){return Xi((function(t,i){var r=-1,a=i.length,s=a>1?i[a-1]:n,o=a>2?i[2]:n;for(s=e.length>3&&"function"==typeof s?(a--,s):n,o&&ma(i[0],i[1],o)&&(s=a<3?n:s,a=1),t=Se(t);++r<a;){var l=i[r];l&&e(t,l,r,s)}return t}))}function Rr(e,t){return function(n,i){if(null==n)return n;if(!Vs(n))return e(n,i);for(var r=n.length,a=t?r:-1,s=Se(n);(t?a--:++a<r)&&!1!==i(s[a],a,s););return n}}function Pr(e){return function(t,n,i){for(var r=-1,a=Se(t),s=i(t),o=s.length;o--;){var l=s[e?o:++r];if(!1===n(a[l],l,a))break}return t}}function Lr(e){return function(t){var i=tn(t=fo(t))?ln(t):n,r=i?i[0]:t.charAt(0),a=i?vr(i,1).join(""):t.slice(1);return r[e]()+a}}function Dr(e){return function(t){return Lt(qo(Bo(t).replace(Ye,"")),e,"")}}function Ir(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=kn(e.prototype),i=e.apply(n,t);return $s(i)?i:n}}function Or(e){return function(t,i,r){var a=Se(t);if(!Vs(t)){var s=ra(i,3);t=Ao(t),i=function(e){return s(a[e],e,a)}}var o=e(t,i,r);return o>-1?a[s?t[o]:o]:n}}function Ur(e){return Jr((function(t){var r=t.length,a=r,s=zn.prototype.thru;for(e&&t.reverse();a--;){var o=t[a];if("function"!=typeof o)throw new Ae(i);if(s&&!l&&"wrapper"==na(o))var l=new zn([],!0)}for(a=l?a:r;++a<r;){var h=na(o=t[a]),c="wrapper"==h?ta(o):n;l=c&&va(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[na(c[0])].apply(l,c[3]):1==o.length&&va(o)?l[h]():l.thru(o)}return function(){var e=arguments,n=e[0];if(l&&1==e.length&&Bs(n))return l.plant(n).value();for(var i=0,a=r?t[i].apply(this,e):n;++i<r;)a=t[i].call(this,a);return a}}))}function Nr(e,t,i,r,a,s,l,h,c,u){var d=t&o,p=1&t,f=2&t,m=24&t,g=512&t,v=f?n:Ir(e);return function o(){for(var y=arguments.length,x=xe(y),_=y;_--;)x[_]=arguments[_];if(m)var b=ia(o),M=function(e,t){for(var n=e.length,i=0;n--;)e[n]===t&&++i;return i}(x,b);if(r&&(x=wr(x,r,a,m)),s&&(x=Sr(x,s,l,m)),y-=M,m&&y<u){var w=an(x,b);return Gr(e,t,Nr,o.placeholder,i,x,w,h,c,u-y)}var S=p?i:this,E=f?S[e]:e;return y=x.length,h?x=function(e,t){for(var i=e.length,r=gn(t.length,i),a=Er(e);r--;){var s=t[r];e[r]=fa(s,i)?a[s]:n}return e}(x,h):g&&y>1&&x.reverse(),d&&c<y&&(x.length=c),this&&this!==ht&&this instanceof o&&(E=v||Ir(E)),E.apply(S,x)}}function Fr(e,t){return function(n,i){return function(e,t,n,i){return vi(e,(function(e,r,a){t(i,n(e),r,a)})),i}(n,e,t(i),{})}}function kr(e,t){return function(i,r){var a;if(i===n&&r===n)return t;if(i!==n&&(a=i),r!==n){if(a===n)return r;"string"==typeof i||"string"==typeof r?(i=ar(i),r=ar(r)):(i=rr(i),r=rr(r)),a=e(i,r)}return a}}function Br(e){return Jr((function(t){return t=Rt(t,qt(ra())),Xi((function(n){var i=this;return e(t,(function(e){return bt(e,i,n)}))}))}))}function zr(e,t){var i=(t=t===n?" ":ar(t)).length;if(i<2)return i?Wi(t,e):t;var r=Wi(t,pt(e/on(t)));return tn(t)?vr(ln(r),0,e).join(""):r.slice(0,e)}function Vr(e){return function(t,i,r){return r&&"number"!=typeof r&&ma(t,i,r)&&(i=r=n),t=lo(t),i===n?(i=t,t=0):i=lo(i),function(e,t,n,i){for(var r=-1,a=mn(pt((t-e)/(n||1)),0),s=xe(a);a--;)s[i?a:++r]=e,e+=n;return s}(t,i,r=r===n?t<i?1:-1:lo(r),e)}}function Hr(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=uo(t),n=uo(n)),e(t,n)}}function Gr(e,t,i,r,a,o,l,h,c,u){var d=8&t;t|=d?s:64,4&(t&=~(d?64:s))||(t&=-4);var p=[e,t,a,d?o:n,d?l:n,d?n:o,d?n:l,h,c,u],f=i.apply(n,p);return va(e)&&Ea(f,p),f.placeholder=r,Ca(f,e,t)}function jr(e){var t=we[e];return function(e,n){if(e=uo(e),(n=null==n?0:gn(ho(n),292))&&dn(e)){var i=(fo(e)+"e").split("e");return+((i=(fo(t(i[0]+"e"+(+i[1]+n)))+"e").split("e"))[0]+"e"+(+i[1]-n))}return t(e)}}var Wr=Sn&&1/sn(new Sn([,-0]))[1]==l?function(e){return new Sn(e)}:rl;function Xr(e){return function(t){var n=ca(t);return n==_?nn(t):n==E?function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}(t):function(e,t){return Rt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function qr(e,t,r,l,h,c,u,d){var p=2&t;if(!p&&"function"!=typeof e)throw new Ae(i);var f=l?l.length:0;if(f||(t&=-97,l=h=n),u=u===n?u:mn(ho(u),0),d=d===n?d:ho(d),f-=h?h.length:0,64&t){var m=l,g=h;l=h=n}var v=p?n:ta(e),y=[e,t,r,l,h,m,g,c,u,d];if(v&&function(e,t){var n=e[1],i=t[1],r=n|i,s=r<131,l=i==o&&8==n||i==o&&256==n&&e[7].length<=t[8]||384==i&&t[7].length<=t[8]&&8==n;if(!s&&!l)return e;1&i&&(e[2]=t[2],r|=1&n?0:4);var h=t[3];if(h){var c=e[3];e[3]=c?wr(c,h,t[4]):h,e[4]=c?an(e[3],a):t[4]}(h=t[5])&&(c=e[5],e[5]=c?Sr(c,h,t[6]):h,e[6]=c?an(e[5],a):t[6]),(h=t[7])&&(e[7]=h),i&o&&(e[8]=null==e[8]?t[8]:gn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=r}(y,v),e=y[0],t=y[1],r=y[2],l=y[3],h=y[4],!(d=y[9]=y[9]===n?p?0:e.length:mn(y[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)x=8==t||16==t?function(e,t,i){var r=Ir(e);return function a(){for(var s=arguments.length,o=xe(s),l=s,h=ia(a);l--;)o[l]=arguments[l];var c=s<3&&o[0]!==h&&o[s-1]!==h?[]:an(o,h);return(s-=c.length)<i?Gr(e,t,Nr,a.placeholder,n,o,c,n,n,i-s):bt(this&&this!==ht&&this instanceof a?r:e,this,o)}}(e,t,d):t!=s&&33!=t||h.length?Nr.apply(n,y):function(e,t,n,i){var r=1&t,a=Ir(e);return function t(){for(var s=-1,o=arguments.length,l=-1,h=i.length,c=xe(h+o),u=this&&this!==ht&&this instanceof t?a:e;++l<h;)c[l]=i[l];for(;o--;)c[l++]=arguments[++s];return bt(u,r?n:this,c)}}(e,t,r,l);else var x=function(e,t,n){var i=1&t,r=Ir(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(i?n:this,arguments)}}(e,t,r);return Ca((v?Ki:Ea)(x,y),e,t)}function Yr(e,t,i,r){return e===n||Us(e,Pe[i])&&!Ie.call(r,i)?t:e}function $r(e,t,i,r,a,s){return $s(e)&&$s(t)&&(s.set(t,e),ki(e,t,n,$r,s),s.delete(t)),e}function Kr(e){return Qs(e)?n:e}function Zr(e,t,i,r,a,s){var o=1&i,l=e.length,h=t.length;if(l!=h&&!(o&&h>l))return!1;var c=s.get(e),u=s.get(t);if(c&&u)return c==t&&u==e;var d=-1,p=!0,f=2&i?new Wn:n;for(s.set(e,t),s.set(t,e);++d<l;){var m=e[d],g=t[d];if(r)var v=o?r(g,m,d,t,e,s):r(m,g,d,e,t,s);if(v!==n){if(v)continue;p=!1;break}if(f){if(!It(t,(function(e,t){if(!$t(f,t)&&(m===e||a(m,e,i,r,s)))return f.push(t)}))){p=!1;break}}else if(m!==g&&!a(m,g,i,r,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function Jr(e){return Aa(Ma(e,n,za),e+"")}function Qr(e){return bi(e,Ao,la)}function ea(e){return bi(e,Co,ha)}var ta=An?function(e){return An.get(e)}:rl;function na(e){for(var t=e.name+"",n=Cn[t],i=Ie.call(Cn,t)?n.length:0;i--;){var r=n[i],a=r.func;if(null==a||a==e)return r.name}return t}function ia(e){return(Ie.call(Fn,"placeholder")?Fn:e).placeholder}function ra(){var e=Fn.iteratee||el;return e=e===el?Di:e,arguments.length?e(arguments[0],arguments[1]):e}function aa(e,t){var n=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function sa(e){for(var t=Ao(e),n=t.length;n--;){var i=t[n],r=e[i];t[n]=[i,r,_a(r)]}return t}function oa(e,t){var i=function(e,t){return null==e?n:e[t]}(e,t);return Li(i)?i:n}var la=Ot?function(e){return null==e?[]:(e=Se(e),Tt(Ot(e),(function(t){return Xe.call(e,t)})))}:ul,ha=Ot?function(e){for(var t=[];e;)Pt(t,la(e)),e=je(e);return t}:ul,ca=Mi;function ua(e,t,n){for(var i=-1,r=(t=mr(t,e)).length,a=!1;++i<r;){var s=Da(t[i]);if(!(a=null!=e&&n(e,s)))break;e=e[s]}return a||++i!=r?a:!!(r=null==e?0:e.length)&&Ys(r)&&fa(s,r)&&(Bs(e)||ks(e))}function da(e){return"function"!=typeof e.constructor||xa(e)?{}:kn(je(e))}function pa(e){return Bs(e)||ks(e)||!!(Ke&&e&&e[Ke])}function fa(e,t){var n=typeof e;return!!(t=null==t?h:t)&&("number"==n||"symbol"!=n&&me.test(e))&&e>-1&&e%1==0&&e<t}function ma(e,t,n){if(!$s(n))return!1;var i=typeof t;return!!("number"==i?Vs(n)&&fa(t,n.length):"string"==i&&t in n)&&Us(n[t],e)}function ga(e,t){if(Bs(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!io(e))||Z.test(e)||!K.test(e)||null!=t&&e in Se(t)}function va(e){var t=na(e),n=Fn[t];if("function"!=typeof n||!(t in Vn.prototype))return!1;if(e===n)return!0;var i=ta(n);return!!i&&e===i[0]}(bn&&ca(new bn(new ArrayBuffer(1)))!=P||Mn&&ca(new Mn)!=_||wn&&ca(wn.resolve())!=w||Sn&&ca(new Sn)!=E||En&&ca(new En)!=C)&&(ca=function(e){var t=Mi(e),i=t==M?e.constructor:n,r=i?Ia(i):"";if(r)switch(r){case Rn:return P;case Pn:return _;case Ln:return w;case Dn:return E;case In:return C}return t});var ya=Le?Xs:dl;function xa(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Pe)}function _a(e){return e==e&&!$s(e)}function ba(e,t){return function(i){return null!=i&&i[e]===t&&(t!==n||e in Se(i))}}function Ma(e,t,i){return t=mn(t===n?e.length-1:t,0),function(){for(var n=arguments,r=-1,a=mn(n.length-t,0),s=xe(a);++r<a;)s[r]=n[t+r];r=-1;for(var o=xe(t+1);++r<t;)o[r]=n[r];return o[t]=i(s),bt(e,this,o)}}function wa(e,t){return t.length<2?e:_i(e,Qi(t,0,-1))}function Sa(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ea=Ra(Ki),Ta=ut||function(e,t){return ht.setTimeout(e,t)},Aa=Ra(Zi);function Ca(e,t,n){var i=t+"";return Aa(e,function(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return wt(d,(function(n){var i="_."+n[0];t&n[1]&&!At(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(re);return t?t[1].split(ae):[]}(i),n)))}function Ra(e){var t=0,i=0;return function(){var r=vn(),a=16-(r-i);if(i=r,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Pa(e,t){var i=-1,r=e.length,a=r-1;for(t=t===n?r:t;++i<t;){var s=ji(i,a),o=e[s];e[s]=e[i],e[i]=o}return e.length=t,e}var La=function(e){var t=Rs((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(J,(function(e,n,i,r){t.push(i?r.replace(le,"$1"):n||e)})),t}),(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}();function Da(e){if("string"==typeof e||io(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Ia(e){if(null!=e){try{return De.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Oa(e){if(e instanceof Vn)return e.clone();var t=new zn(e.__wrapped__,e.__chain__);return t.__actions__=Er(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ua=Xi((function(e,t){return Hs(e)?li(e,fi(t,1,Hs,!0)):[]})),Na=Xi((function(e,t){var i=Wa(t);return Hs(i)&&(i=n),Hs(e)?li(e,fi(t,1,Hs,!0),ra(i,2)):[]})),Fa=Xi((function(e,t){var i=Wa(t);return Hs(i)&&(i=n),Hs(e)?li(e,fi(t,1,Hs,!0),n,i):[]}));function ka(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=null==n?0:ho(n);return r<0&&(r=mn(i+r,0)),Nt(e,ra(t,3),r)}function Ba(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var a=r-1;return i!==n&&(a=ho(i),a=i<0?mn(r+a,0):gn(a,r-1)),Nt(e,ra(t,3),a,!0)}function za(e){return null!=e&&e.length?fi(e,1):[]}function Va(e){return e&&e.length?e[0]:n}var Ha=Xi((function(e){var t=Rt(e,pr);return t.length&&t[0]===e[0]?Ti(t):[]})),Ga=Xi((function(e){var t=Wa(e),i=Rt(e,pr);return t===Wa(i)?t=n:i.pop(),i.length&&i[0]===e[0]?Ti(i,ra(t,2)):[]})),ja=Xi((function(e){var t=Wa(e),i=Rt(e,pr);return(t="function"==typeof t?t:n)&&i.pop(),i.length&&i[0]===e[0]?Ti(i,n,t):[]}));function Wa(e){var t=null==e?0:e.length;return t?e[t-1]:n}var Xa=Xi(qa);function qa(e,t){return e&&e.length&&t&&t.length?Hi(e,t):e}var Ya=Jr((function(e,t){var n=null==e?0:e.length,i=ii(e,t);return Gi(e,Rt(t,(function(e){return fa(e,n)?+e:e})).sort(Mr)),i}));function $a(e){return null==e?e:_n.call(e)}var Ka=Xi((function(e){return sr(fi(e,1,Hs,!0))})),Za=Xi((function(e){var t=Wa(e);return Hs(t)&&(t=n),sr(fi(e,1,Hs,!0),ra(t,2))})),Ja=Xi((function(e){var t=Wa(e);return t="function"==typeof t?t:n,sr(fi(e,1,Hs,!0),n,t)}));function Qa(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(Hs(e))return t=mn(e.length,t),!0})),Wt(t,(function(t){return Rt(e,Vt(t))}))}function es(e,t){if(!e||!e.length)return[];var i=Qa(e);return null==t?i:Rt(i,(function(e){return bt(t,n,e)}))}var ts=Xi((function(e,t){return Hs(e)?li(e,t):[]})),ns=Xi((function(e){return ur(Tt(e,Hs))})),is=Xi((function(e){var t=Wa(e);return Hs(t)&&(t=n),ur(Tt(e,Hs),ra(t,2))})),rs=Xi((function(e){var t=Wa(e);return t="function"==typeof t?t:n,ur(Tt(e,Hs),n,t)})),as=Xi(Qa),ss=Xi((function(e){var t=e.length,i=t>1?e[t-1]:n;return i="function"==typeof i?(e.pop(),i):n,es(e,i)}));function os(e){var t=Fn(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=Jr((function(e){var t=e.length,i=t?e[0]:0,r=this.__wrapped__,a=function(t){return ii(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Vn&&fa(i)?((r=r.slice(i,+i+(t?1:0))).__actions__.push({func:ls,args:[a],thisArg:n}),new zn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(n),e}))):this.thru(a)})),cs=Ar((function(e,t,n){Ie.call(e,n)?++e[n]:ni(e,n,1)})),us=Or(ka),ds=Or(Ba);function ps(e,t){return(Bs(e)?wt:hi)(e,ra(t,3))}function fs(e,t){return(Bs(e)?St:ci)(e,ra(t,3))}var ms=Ar((function(e,t,n){Ie.call(e,n)?e[n].push(t):ni(e,n,[t])})),gs=Xi((function(e,t,n){var i=-1,r="function"==typeof t,a=Vs(e)?xe(e.length):[];return hi(e,(function(e){a[++i]=r?bt(t,e,n):Ai(e,t,n)})),a})),vs=Ar((function(e,t,n){ni(e,n,t)}));function ys(e,t){return(Bs(e)?Rt:Ui)(e,ra(t,3))}var xs=Ar((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),_s=Xi((function(e,t){if(null==e)return[];var n=t.length;return n>1&&ma(e,t[0],t[1])?t=[]:n>2&&ma(t[0],t[1],t[2])&&(t=[t[0]]),zi(e,fi(t,1),[])})),bs=ct||function(){return ht.Date.now()};function Ms(e,t,i){return t=i?n:t,t=e&&null==t?e.length:t,qr(e,o,n,n,n,n,t)}function ws(e,t){var r;if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Ss=Xi((function(e,t,n){var i=1;if(n.length){var r=an(n,ia(Ss));i|=s}return qr(e,i,t,n,r)})),Es=Xi((function(e,t,n){var i=3;if(n.length){var r=an(n,ia(Es));i|=s}return qr(t,i,e,n,r)}));function Ts(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(i);function m(t){var i=a,r=s;return a=s=n,u=t,l=e.apply(r,i)}function g(e){var i=e-c;return c===n||i>=t||i<0||p&&e-u>=o}function v(){var e=bs();if(g(e))return y(e);h=Ta(v,function(e){var n=t-(e-c);return p?gn(n,o-(e-u)):n}(e))}function y(e){return h=n,f&&a?m(e):(a=s=n,l)}function x(){var e=bs(),i=g(e);if(a=arguments,s=this,c=e,i){if(h===n)return function(e){return u=e,h=Ta(v,t),d?m(e):l}(c);if(p)return yr(h),h=Ta(v,t),m(c)}return h===n&&(h=Ta(v,t)),l}return t=uo(t)||0,$s(r)&&(d=!!r.leading,o=(p="maxWait"in r)?mn(uo(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),x.cancel=function(){h!==n&&yr(h),u=0,a=c=s=h=n},x.flush=function(){return h===n?l:y(bs())},x}var As=Xi((function(e,t){return oi(e,1,t)})),Cs=Xi((function(e,t,n){return oi(e,uo(t)||0,n)}));function Rs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(i);var n=function(){var i=arguments,r=t?t.apply(this,i):i[0],a=n.cache;if(a.has(r))return a.get(r);var s=e.apply(this,i);return n.cache=a.set(r,s)||a,s};return n.cache=new(Rs.Cache||jn),n}function Ps(e){if("function"!=typeof e)throw new Ae(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Rs.Cache=jn;var Ls=gr((function(e,t){var n=(t=1==t.length&&Bs(t[0])?Rt(t[0],qt(ra())):Rt(fi(t,1),qt(ra()))).length;return Xi((function(i){for(var r=-1,a=gn(i.length,n);++r<a;)i[r]=t[r].call(this,i[r]);return bt(e,this,i)}))})),Ds=Xi((function(e,t){var i=an(t,ia(Ds));return qr(e,s,n,t,i)})),Is=Xi((function(e,t){var i=an(t,ia(Is));return qr(e,64,n,t,i)})),Os=Jr((function(e,t){return qr(e,256,n,n,n,t)}));function Us(e,t){return e===t||e!=e&&t!=t}var Ns=Hr(wi),Fs=Hr((function(e,t){return e>=t})),ks=Ci(function(){return arguments}())?Ci:function(e){return Ks(e)&&Ie.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?qt(mt):function(e){return Ks(e)&&Mi(e)==R};function Vs(e){return null!=e&&Ys(e.length)&&!Xs(e)}function Hs(e){return Ks(e)&&Vs(e)}var Gs=Ht||dl,js=gt?qt(gt):function(e){return Ks(e)&&Mi(e)==g};function Ws(e){if(!Ks(e))return!1;var t=Mi(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!$s(e))return!1;var t=Mi(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function qs(e){return"number"==typeof e&&e==ho(e)}function Ys(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function $s(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ks(e){return null!=e&&"object"==typeof e}var Zs=vt?qt(vt):function(e){return Ks(e)&&ca(e)==_};function Js(e){return"number"==typeof e||Ks(e)&&Mi(e)==b}function Qs(e){if(!Ks(e)||Mi(e)!=M)return!1;var t=je(e);if(null===t)return!0;var n=Ie.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&De.call(n)==Fe}var eo=yt?qt(yt):function(e){return Ks(e)&&Mi(e)==S},to=xt?qt(xt):function(e){return Ks(e)&&ca(e)==E};function no(e){return"string"==typeof e||!Bs(e)&&Ks(e)&&Mi(e)==T}function io(e){return"symbol"==typeof e||Ks(e)&&Mi(e)==A}var ro=_t?qt(_t):function(e){return Ks(e)&&Ys(e.length)&&!!nt[Mi(e)]},ao=Hr(Oi),so=Hr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Vs(e))return no(e)?ln(e):Er(e);if(Je&&e[Je])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Je]());var t=ca(e);return(t==_?nn:t==E?sn:No)(e)}function lo(e){return e?(e=uo(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=lo(e),n=t%1;return t==t?n?t-n:t:0}function co(e){return e?ri(ho(e),0,u):0}function uo(e){if("number"==typeof e)return e;if(io(e))return c;if($s(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=$s(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Xt(e);var n=de.test(e);return n||fe.test(e)?st(e.slice(2),n?2:8):ue.test(e)?c:+e}function po(e){return Tr(e,Co(e))}function fo(e){return null==e?"":ar(e)}var mo=Cr((function(e,t){if(xa(t)||Vs(t))Tr(t,Ao(t),e);else for(var n in t)Ie.call(t,n)&&Jn(e,n,t[n])})),go=Cr((function(e,t){Tr(t,Co(t),e)})),vo=Cr((function(e,t,n,i){Tr(t,Co(t),e,i)})),yo=Cr((function(e,t,n,i){Tr(t,Ao(t),e,i)})),xo=Jr(ii),_o=Xi((function(e,t){e=Se(e);var i=-1,r=t.length,a=r>2?t[2]:n;for(a&&ma(t[0],t[1],a)&&(r=1);++i<r;)for(var s=t[i],o=Co(s),l=-1,h=o.length;++l<h;){var c=o[l],u=e[c];(u===n||Us(u,Pe[c])&&!Ie.call(e,c))&&(e[c]=s[c])}return e})),bo=Xi((function(e){return e.push(n,$r),bt(Po,n,e)}));function Mo(e,t,i){var r=null==e?n:_i(e,t);return r===n?i:r}function wo(e,t){return null!=e&&ua(e,t,Ei)}var So=Fr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),e[t]=n}),Ko(Qo)),Eo=Fr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),Ie.call(e,t)?e[t].push(n):e[t]=[n]}),ra),To=Xi(Ai);function Ao(e){return Vs(e)?qn(e):Ii(e)}function Co(e){return Vs(e)?qn(e,!0):function(e){if(!$s(e))return function(e){var t=[];if(null!=e)for(var n in Se(e))t.push(n);return t}(e);var t=xa(e),n=[];for(var i in e)"constructor"==i&&(t||!Ie.call(e,i))||n.push(i);return n}(e)}var Ro=Cr((function(e,t,n){ki(e,t,n)})),Po=Cr((function(e,t,n,i){ki(e,t,n,i)})),Lo=Jr((function(e,t){var n={};if(null==e)return n;var i=!1;t=Rt(t,(function(t){return t=mr(t,e),i||(i=t.length>1),t})),Tr(e,ea(e),n),i&&(n=ai(n,7,Kr));for(var r=t.length;r--;)or(n,t[r]);return n})),Do=Jr((function(e,t){return null==e?{}:function(e,t){return Vi(e,t,(function(t,n){return wo(e,n)}))}(e,t)}));function Io(e,t){if(null==e)return{};var n=Rt(ea(e),(function(e){return[e]}));return t=ra(t),Vi(e,n,(function(e,n){return t(e,n[0])}))}var Oo=Xr(Ao),Uo=Xr(Co);function No(e){return null==e?[]:Yt(e,Ao(e))}var Fo=Dr((function(e,t,n){return t=t.toLowerCase(),e+(n?ko(t):t)}));function ko(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,Jt).replace($e,"")}var zo=Dr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Vo=Dr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ho=Lr("toLowerCase"),Go=Dr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),jo=Dr((function(e,t,n){return e+(n?" ":"")+Xo(t)})),Wo=Dr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xo=Lr("toUpperCase");function qo(e,t,i){return e=fo(e),(t=i?n:t)===n?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var Yo=Xi((function(e,t){try{return bt(e,n,t)}catch(e){return Ws(e)?e:new be(e)}})),$o=Jr((function(e,t){return wt(t,(function(t){t=Da(t),ni(e,t,Ss(e[t],e))})),e}));function Ko(e){return function(){return e}}var Zo=Ur(),Jo=Ur(!0);function Qo(e){return e}function el(e){return Di("function"==typeof e?e:ai(e,1))}var tl=Xi((function(e,t){return function(n){return Ai(n,e,t)}})),nl=Xi((function(e,t){return function(n){return Ai(e,n,t)}}));function il(e,t,n){var i=Ao(t),r=xi(t,i);null==n&&(!$s(t)||!r.length&&i.length)&&(n=t,t=e,e=this,r=xi(t,Ao(t)));var a=!($s(n)&&"chain"in n&&!n.chain),s=Xs(e);return wt(r,(function(n){var i=t[n];e[n]=i,s&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=Er(this.__actions__)).push({func:i,args:arguments,thisArg:e}),n.__chain__=t,n}return i.apply(e,Pt([this.value()],arguments))})})),e}function rl(){}var al=Br(Rt),sl=Br(Et),ol=Br(It);function ll(e){return ga(e)?Vt(Da(e)):function(e){return function(t){return _i(t,e)}}(e)}var hl=Vr(),cl=Vr(!0);function ul(){return[]}function dl(){return!1}var pl=kr((function(e,t){return e+t}),0),fl=jr("ceil"),ml=kr((function(e,t){return e/t}),1),gl=jr("floor"),vl=kr((function(e,t){return e*t}),1),yl=jr("round"),xl=kr((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=Ms,Fn.assign=mo,Fn.assignIn=go,Fn.assignInWith=vo,Fn.assignWith=yo,Fn.at=xo,Fn.before=ws,Fn.bind=Ss,Fn.bindAll=$o,Fn.bindKey=Es,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Fn.chain=os,Fn.chunk=function(e,t,i){t=(i?ma(e,t,i):t===n)?1:mn(ho(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,o=xe(pt(r/t));a<r;)o[s++]=Qi(e,a,a+=t);return o},Fn.compact=function(e){for(var t=-1,n=null==e?0:e.length,i=0,r=[];++t<n;){var a=e[t];a&&(r[i++]=a)}return r},Fn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=xe(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return Pt(Bs(n)?Er(n):[n],fi(t,1))},Fn.cond=function(e){var t=null==e?0:e.length,n=ra();return e=t?Rt(e,(function(e){if("function"!=typeof e[1])throw new Ae(i);return[n(e[0]),e[1]]})):[],Xi((function(n){for(var i=-1;++i<t;){var r=e[i];if(bt(r[0],this,n))return bt(r[1],this,n)}}))},Fn.conforms=function(e){return function(e){var t=Ao(e);return function(n){return si(n,e,t)}}(ai(e,1))},Fn.constant=Ko,Fn.countBy=cs,Fn.create=function(e,t){var n=kn(e);return null==t?n:ti(n,t)},Fn.curry=function e(t,i,r){var a=qr(t,8,n,n,n,n,n,i=r?n:i);return a.placeholder=e.placeholder,a},Fn.curryRight=function e(t,i,r){var a=qr(t,16,n,n,n,n,n,i=r?n:i);return a.placeholder=e.placeholder,a},Fn.debounce=Ts,Fn.defaults=_o,Fn.defaultsDeep=bo,Fn.defer=As,Fn.delay=Cs,Fn.difference=Ua,Fn.differenceBy=Na,Fn.differenceWith=Fa,Fn.drop=function(e,t,i){var r=null==e?0:e.length;return r?Qi(e,(t=i||t===n?1:ho(t))<0?0:t,r):[]},Fn.dropRight=function(e,t,i){var r=null==e?0:e.length;return r?Qi(e,0,(t=r-(t=i||t===n?1:ho(t)))<0?0:t):[]},Fn.dropRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0,!0):[]},Fn.dropWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0):[]},Fn.fill=function(e,t,i,r){var a=null==e?0:e.length;return a?(i&&"number"!=typeof i&&ma(e,t,i)&&(i=0,r=a),function(e,t,i,r){var a=e.length;for((i=ho(i))<0&&(i=-i>a?0:a+i),(r=r===n||r>a?a:ho(r))<0&&(r+=a),r=i>r?0:co(r);i<r;)e[i++]=t;return e}(e,t,i,r)):[]},Fn.filter=function(e,t){return(Bs(e)?Tt:pi)(e,ra(t,3))},Fn.flatMap=function(e,t){return fi(ys(e,t),1)},Fn.flatMapDeep=function(e,t){return fi(ys(e,t),l)},Fn.flatMapDepth=function(e,t,i){return i=i===n?1:ho(i),fi(ys(e,t),i)},Fn.flatten=za,Fn.flattenDeep=function(e){return null!=e&&e.length?fi(e,l):[]},Fn.flattenDepth=function(e,t){return null!=e&&e.length?fi(e,t=t===n?1:ho(t)):[]},Fn.flip=function(e){return qr(e,512)},Fn.flow=Zo,Fn.flowRight=Jo,Fn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,i={};++t<n;){var r=e[t];i[r[0]]=r[1]}return i},Fn.functions=function(e){return null==e?[]:xi(e,Ao(e))},Fn.functionsIn=function(e){return null==e?[]:xi(e,Co(e))},Fn.groupBy=ms,Fn.initial=function(e){return null!=e&&e.length?Qi(e,0,-1):[]},Fn.intersection=Ha,Fn.intersectionBy=Ga,Fn.intersectionWith=ja,Fn.invert=So,Fn.invertBy=Eo,Fn.invokeMap=gs,Fn.iteratee=el,Fn.keyBy=vs,Fn.keys=Ao,Fn.keysIn=Co,Fn.map=ys,Fn.mapKeys=function(e,t){var n={};return t=ra(t,3),vi(e,(function(e,i,r){ni(n,t(e,i,r),e)})),n},Fn.mapValues=function(e,t){var n={};return t=ra(t,3),vi(e,(function(e,i,r){ni(n,i,t(e,i,r))})),n},Fn.matches=function(e){return Ni(ai(e,1))},Fn.matchesProperty=function(e,t){return Fi(e,ai(t,1))},Fn.memoize=Rs,Fn.merge=Ro,Fn.mergeWith=Po,Fn.method=tl,Fn.methodOf=nl,Fn.mixin=il,Fn.negate=Ps,Fn.nthArg=function(e){return e=ho(e),Xi((function(t){return Bi(t,e)}))},Fn.omit=Lo,Fn.omitBy=function(e,t){return Io(e,Ps(ra(t)))},Fn.once=function(e){return ws(2,e)},Fn.orderBy=function(e,t,i,r){return null==e?[]:(Bs(t)||(t=null==t?[]:[t]),Bs(i=r?n:i)||(i=null==i?[]:[i]),zi(e,t,i))},Fn.over=al,Fn.overArgs=Ls,Fn.overEvery=sl,Fn.overSome=ol,Fn.partial=Ds,Fn.partialRight=Is,Fn.partition=xs,Fn.pick=Do,Fn.pickBy=Io,Fn.property=ll,Fn.propertyOf=function(e){return function(t){return null==e?n:_i(e,t)}},Fn.pull=Xa,Fn.pullAll=qa,Fn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Hi(e,t,ra(n,2)):e},Fn.pullAllWith=function(e,t,i){return e&&e.length&&t&&t.length?Hi(e,t,n,i):e},Fn.pullAt=Ya,Fn.range=hl,Fn.rangeRight=cl,Fn.rearg=Os,Fn.reject=function(e,t){return(Bs(e)?Tt:pi)(e,Ps(ra(t,3)))},Fn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,r=[],a=e.length;for(t=ra(t,3);++i<a;){var s=e[i];t(s,i,e)&&(n.push(s),r.push(i))}return Gi(e,r),n},Fn.rest=function(e,t){if("function"!=typeof e)throw new Ae(i);return Xi(e,t=t===n?t:ho(t))},Fn.reverse=$a,Fn.sampleSize=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),(Bs(e)?$n:Yi)(e,t)},Fn.set=function(e,t,n){return null==e?e:$i(e,t,n)},Fn.setWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:$i(e,t,i,r)},Fn.shuffle=function(e){return(Bs(e)?Kn:Ji)(e)},Fn.slice=function(e,t,i){var r=null==e?0:e.length;return r?(i&&"number"!=typeof i&&ma(e,t,i)?(t=0,i=r):(t=null==t?0:ho(t),i=i===n?r:ho(i)),Qi(e,t,i)):[]},Fn.sortBy=_s,Fn.sortedUniq=function(e){return e&&e.length?ir(e):[]},Fn.sortedUniqBy=function(e,t){return e&&e.length?ir(e,ra(t,2)):[]},Fn.split=function(e,t,i){return i&&"number"!=typeof i&&ma(e,t,i)&&(t=i=n),(i=i===n?u:i>>>0)?(e=fo(e))&&("string"==typeof t||null!=t&&!eo(t))&&!(t=ar(t))&&tn(e)?vr(ln(e),0,i):e.split(t,i):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ae(i);return t=null==t?0:mn(ho(t),0),Xi((function(n){var i=n[t],r=vr(n,0,t);return i&&Pt(r,i),bt(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?Qi(e,1,t):[]},Fn.take=function(e,t,i){return e&&e.length?Qi(e,0,(t=i||t===n?1:ho(t))<0?0:t):[]},Fn.takeRight=function(e,t,i){var r=null==e?0:e.length;return r?Qi(e,(t=r-(t=i||t===n?1:ho(t)))<0?0:t,r):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,ra(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var r=!0,a=!0;if("function"!=typeof e)throw new Ae(i);return $s(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),Ts(e,t,{leading:r,maxWait:t,trailing:a})},Fn.thru=ls,Fn.toArray=oo,Fn.toPairs=Oo,Fn.toPairsIn=Uo,Fn.toPath=function(e){return Bs(e)?Rt(e,Da):io(e)?[e]:Er(La(fo(e)))},Fn.toPlainObject=po,Fn.transform=function(e,t,n){var i=Bs(e),r=i||Gs(e)||ro(e);if(t=ra(t,4),null==n){var a=e&&e.constructor;n=r?i?new a:[]:$s(e)&&Xs(a)?kn(je(e)):{}}return(r?wt:vi)(e,(function(e,i,r){return t(n,e,i,r)})),n},Fn.unary=function(e){return Ms(e,1)},Fn.union=Ka,Fn.unionBy=Za,Fn.unionWith=Ja,Fn.uniq=function(e){return e&&e.length?sr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?sr(e,ra(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?sr(e,n,t):[]},Fn.unset=function(e,t){return null==e||or(e,t)},Fn.unzip=Qa,Fn.unzipWith=es,Fn.update=function(e,t,n){return null==e?e:lr(e,t,fr(n))},Fn.updateWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:lr(e,t,fr(i),r)},Fn.values=No,Fn.valuesIn=function(e){return null==e?[]:Yt(e,Co(e))},Fn.without=ts,Fn.words=qo,Fn.wrap=function(e,t){return Ds(fr(t),e)},Fn.xor=ns,Fn.xorBy=is,Fn.xorWith=rs,Fn.zip=as,Fn.zipObject=function(e,t){return dr(e||[],t||[],Jn)},Fn.zipObjectDeep=function(e,t){return dr(e||[],t||[],$i)},Fn.zipWith=ss,Fn.entries=Oo,Fn.entriesIn=Uo,Fn.extend=go,Fn.extendWith=vo,il(Fn,Fn),Fn.add=pl,Fn.attempt=Yo,Fn.camelCase=Fo,Fn.capitalize=ko,Fn.ceil=fl,Fn.clamp=function(e,t,i){return i===n&&(i=t,t=n),i!==n&&(i=(i=uo(i))==i?i:0),t!==n&&(t=(t=uo(t))==t?t:0),ri(uo(e),t,i)},Fn.clone=function(e){return ai(e,4)},Fn.cloneDeep=function(e){return ai(e,5)},Fn.cloneDeepWith=function(e,t){return ai(e,5,t="function"==typeof t?t:n)},Fn.cloneWith=function(e,t){return ai(e,4,t="function"==typeof t?t:n)},Fn.conformsTo=function(e,t){return null==t||si(e,t,Ao(t))},Fn.deburr=Bo,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=ml,Fn.endsWith=function(e,t,i){e=fo(e),t=ar(t);var r=e.length,a=i=i===n?r:ri(ho(i),0,r);return(i-=t.length)>=0&&e.slice(i,a)==t},Fn.eq=Us,Fn.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(j,Qt):e},Fn.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Fn.every=function(e,t,i){var r=Bs(e)?Et:ui;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Fn.find=us,Fn.findIndex=ka,Fn.findKey=function(e,t){return Ut(e,ra(t,3),vi)},Fn.findLast=ds,Fn.findLastIndex=Ba,Fn.findLastKey=function(e,t){return Ut(e,ra(t,3),yi)},Fn.floor=gl,Fn.forEach=ps,Fn.forEachRight=fs,Fn.forIn=function(e,t){return null==e?e:mi(e,ra(t,3),Co)},Fn.forInRight=function(e,t){return null==e?e:gi(e,ra(t,3),Co)},Fn.forOwn=function(e,t){return e&&vi(e,ra(t,3))},Fn.forOwnRight=function(e,t){return e&&yi(e,ra(t,3))},Fn.get=Mo,Fn.gt=Ns,Fn.gte=Fs,Fn.has=function(e,t){return null!=e&&ua(e,t,Si)},Fn.hasIn=wo,Fn.head=Va,Fn.identity=Qo,Fn.includes=function(e,t,n,i){e=Vs(e)?e:No(e),n=n&&!i?ho(n):0;var r=e.length;return n<0&&(n=mn(r+n,0)),no(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&Ft(e,t,n)>-1},Fn.indexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=null==n?0:ho(n);return r<0&&(r=mn(i+r,0)),Ft(e,t,r)},Fn.inRange=function(e,t,i){return t=lo(t),i===n?(i=t,t=0):i=lo(i),function(e,t,n){return e>=gn(t,n)&&e<mn(t,n)}(e=uo(e),t,i)},Fn.invoke=To,Fn.isArguments=ks,Fn.isArray=Bs,Fn.isArrayBuffer=zs,Fn.isArrayLike=Vs,Fn.isArrayLikeObject=Hs,Fn.isBoolean=function(e){return!0===e||!1===e||Ks(e)&&Mi(e)==m},Fn.isBuffer=Gs,Fn.isDate=js,Fn.isElement=function(e){return Ks(e)&&1===e.nodeType&&!Qs(e)},Fn.isEmpty=function(e){if(null==e)return!0;if(Vs(e)&&(Bs(e)||"string"==typeof e||"function"==typeof e.splice||Gs(e)||ro(e)||ks(e)))return!e.length;var t=ca(e);if(t==_||t==E)return!e.size;if(xa(e))return!Ii(e).length;for(var n in e)if(Ie.call(e,n))return!1;return!0},Fn.isEqual=function(e,t){return Ri(e,t)},Fn.isEqualWith=function(e,t,i){var r=(i="function"==typeof i?i:n)?i(e,t):n;return r===n?Ri(e,t,n,i):!!r},Fn.isError=Ws,Fn.isFinite=function(e){return"number"==typeof e&&dn(e)},Fn.isFunction=Xs,Fn.isInteger=qs,Fn.isLength=Ys,Fn.isMap=Zs,Fn.isMatch=function(e,t){return e===t||Pi(e,t,sa(t))},Fn.isMatchWith=function(e,t,i){return i="function"==typeof i?i:n,Pi(e,t,sa(t),i)},Fn.isNaN=function(e){return Js(e)&&e!=+e},Fn.isNative=function(e){if(ya(e))throw new be("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Li(e)},Fn.isNil=function(e){return null==e},Fn.isNull=function(e){return null===e},Fn.isNumber=Js,Fn.isObject=$s,Fn.isObjectLike=Ks,Fn.isPlainObject=Qs,Fn.isRegExp=eo,Fn.isSafeInteger=function(e){return qs(e)&&e>=-h&&e<=h},Fn.isSet=to,Fn.isString=no,Fn.isSymbol=io,Fn.isTypedArray=ro,Fn.isUndefined=function(e){return e===n},Fn.isWeakMap=function(e){return Ks(e)&&ca(e)==C},Fn.isWeakSet=function(e){return Ks(e)&&"[object WeakSet]"==Mi(e)},Fn.join=function(e,t){return null==e?"":pn.call(e,t)},Fn.kebabCase=zo,Fn.last=Wa,Fn.lastIndexOf=function(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var a=r;return i!==n&&(a=(a=ho(i))<0?mn(r+a,0):gn(a,r-1)),t==t?function(e,t,n){for(var i=n+1;i--;)if(e[i]===t)return i;return i}(e,t,a):Nt(e,Bt,a,!0)},Fn.lowerCase=Vo,Fn.lowerFirst=Ho,Fn.lt=ao,Fn.lte=so,Fn.max=function(e){return e&&e.length?di(e,Qo,wi):n},Fn.maxBy=function(e,t){return e&&e.length?di(e,ra(t,2),wi):n},Fn.mean=function(e){return zt(e,Qo)},Fn.meanBy=function(e,t){return zt(e,ra(t,2))},Fn.min=function(e){return e&&e.length?di(e,Qo,Oi):n},Fn.minBy=function(e,t){return e&&e.length?di(e,ra(t,2),Oi):n},Fn.stubArray=ul,Fn.stubFalse=dl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=vl,Fn.nth=function(e,t){return e&&e.length?Bi(e,ho(t)):n},Fn.noConflict=function(){return ht._===this&&(ht._=ke),this},Fn.noop=rl,Fn.now=bs,Fn.pad=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;if(!t||i>=t)return e;var r=(t-i)/2;return zr(ft(r),n)+e+zr(pt(r),n)},Fn.padEnd=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;return t&&i<t?e+zr(t-i,n):e},Fn.padStart=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;return t&&i<t?zr(t-i,n)+e:e},Fn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),yn(fo(e).replace(te,""),t||0)},Fn.random=function(e,t,i){if(i&&"boolean"!=typeof i&&ma(e,t,i)&&(t=i=n),i===n&&("boolean"==typeof t?(i=t,t=n):"boolean"==typeof e&&(i=e,e=n)),e===n&&t===n?(e=0,t=1):(e=lo(e),t===n?(t=e,e=0):t=lo(t)),e>t){var r=e;e=t,t=r}if(i||e%1||t%1){var a=xn();return gn(e+a*(t-e+at("1e-"+((a+"").length-1))),t)}return ji(e,t)},Fn.reduce=function(e,t,n){var i=Bs(e)?Lt:Gt,r=arguments.length<3;return i(e,ra(t,4),n,r,hi)},Fn.reduceRight=function(e,t,n){var i=Bs(e)?Dt:Gt,r=arguments.length<3;return i(e,ra(t,4),n,r,ci)},Fn.repeat=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),Wi(fo(e),t)},Fn.replace=function(){var e=arguments,t=fo(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,i){var r=-1,a=(t=mr(t,e)).length;for(a||(a=1,e=n);++r<a;){var s=null==e?n:e[Da(t[r])];s===n&&(r=a,s=i),e=Xs(s)?s.call(e):s}return e},Fn.round=yl,Fn.runInContext=e,Fn.sample=function(e){return(Bs(e)?Yn:qi)(e)},Fn.size=function(e){if(null==e)return 0;if(Vs(e))return no(e)?on(e):e.length;var t=ca(e);return t==_||t==E?e.size:Ii(e).length},Fn.snakeCase=Go,Fn.some=function(e,t,i){var r=Bs(e)?It:er;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Fn.sortedIndex=function(e,t){return tr(e,t)},Fn.sortedIndexBy=function(e,t,n){return nr(e,t,ra(n,2))},Fn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var i=tr(e,t);if(i<n&&Us(e[i],t))return i}return-1},Fn.sortedLastIndex=function(e,t){return tr(e,t,!0)},Fn.sortedLastIndexBy=function(e,t,n){return nr(e,t,ra(n,2),!0)},Fn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=tr(e,t,!0)-1;if(Us(e[n],t))return n}return-1},Fn.startCase=jo,Fn.startsWith=function(e,t,n){return e=fo(e),n=null==n?0:ri(ho(n),0,e.length),t=ar(t),e.slice(n,n+t.length)==t},Fn.subtract=xl,Fn.sum=function(e){return e&&e.length?jt(e,Qo):0},Fn.sumBy=function(e,t){return e&&e.length?jt(e,ra(t,2)):0},Fn.template=function(e,t,i){var r=Fn.templateSettings;i&&ma(e,t,i)&&(t=n),e=fo(e),t=vo({},t,r,Yr);var a,s,o=vo({},t.imports,r.imports,Yr),l=Ao(o),h=Yt(o,l),c=0,u=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+u.source+"|"+(u===$?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),f="//# sourceURL="+(Ie.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++tt+"]")+"\n";e.replace(p,(function(t,n,i,r,o,l){return i||(i=r),d+=e.slice(c,l).replace(ye,en),n&&(a=!0,d+="' +\n__e("+n+") +\n'"),o&&(s=!0,d+="';\n"+o+";\n__p += '"),i&&(d+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),c=l+t.length,t})),d+="';\n";var m=Ie.call(t,"variable")&&t.variable;if(m){if(oe.test(m))throw new be("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(z,""):d).replace(V,"$1").replace(H,"$1;"),d="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Yo((function(){return Me(l,f+"return "+d).apply(n,h)}));if(g.source=d,Ws(g))throw g;return g},Fn.times=function(e,t){if((e=ho(e))<1||e>h)return[];var n=u,i=gn(e,u);t=ra(t),e-=u;for(var r=Wt(i,t);++n<e;)t(n);return r},Fn.toFinite=lo,Fn.toInteger=ho,Fn.toLength=co,Fn.toLower=function(e){return fo(e).toLowerCase()},Fn.toNumber=uo,Fn.toSafeInteger=function(e){return e?ri(ho(e),-h,h):0===e?e:0},Fn.toString=fo,Fn.toUpper=function(e){return fo(e).toUpperCase()},Fn.trim=function(e,t,i){if((e=fo(e))&&(i||t===n))return Xt(e);if(!e||!(t=ar(t)))return e;var r=ln(e),a=ln(t);return vr(r,Kt(r,a),Zt(r,a)+1).join("")},Fn.trimEnd=function(e,t,i){if((e=fo(e))&&(i||t===n))return e.slice(0,hn(e)+1);if(!e||!(t=ar(t)))return e;var r=ln(e);return vr(r,0,Zt(r,ln(t))+1).join("")},Fn.trimStart=function(e,t,i){if((e=fo(e))&&(i||t===n))return e.replace(te,"");if(!e||!(t=ar(t)))return e;var r=ln(e);return vr(r,Kt(r,ln(t))).join("")},Fn.truncate=function(e,t){var i=30,r="...";if($s(t)){var a="separator"in t?t.separator:a;i="length"in t?ho(t.length):i,r="omission"in t?ar(t.omission):r}var s=(e=fo(e)).length;if(tn(e)){var o=ln(e);s=o.length}if(i>=s)return e;var l=i-on(r);if(l<1)return r;var h=o?vr(o,0,l).join(""):e.slice(0,l);if(a===n)return h+r;if(o&&(l+=h.length-l),eo(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Ee(a.source,fo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===n?l:d)}}else if(e.indexOf(ar(a),l)!=l){var p=h.lastIndexOf(a);p>-1&&(h=h.slice(0,p))}return h+r},Fn.unescape=function(e){return(e=fo(e))&&W.test(e)?e.replace(G,cn):e},Fn.uniqueId=function(e){var t=++Oe;return fo(e)+t},Fn.upperCase=Wo,Fn.upperFirst=Xo,Fn.each=ps,Fn.eachRight=fs,Fn.first=Va,il(Fn,function(){var e={};return vi(Fn,(function(t,n){Ie.call(Fn.prototype,n)||(e[n]=t)})),e}(),{chain:!1}),Fn.VERSION="4.17.21",wt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),wt(["drop","take"],(function(e,t){Vn.prototype[e]=function(i){i=i===n?1:mn(ho(i),0);var r=this.__filtered__&&!t?new Vn(this):this.clone();return r.__filtered__?r.__takeCount__=gn(i,r.__takeCount__):r.__views__.push({size:gn(i,u),type:e+(r.__dir__<0?"Right":"")}),r},Vn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),wt(["filter","map","takeWhile"],(function(e,t){var n=t+1,i=1==n||3==n;Vn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ra(e,3),type:n}),t.__filtered__=t.__filtered__||i,t}})),wt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Vn.prototype[e]=function(){return this[n](1).value()[0]}})),wt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Vn.prototype[e]=function(){return this.__filtered__?new Vn(this):this[n](1)}})),Vn.prototype.compact=function(){return this.filter(Qo)},Vn.prototype.find=function(e){return this.filter(e).head()},Vn.prototype.findLast=function(e){return this.reverse().find(e)},Vn.prototype.invokeMap=Xi((function(e,t){return"function"==typeof e?new Vn(this):this.map((function(n){return Ai(n,e,t)}))})),Vn.prototype.reject=function(e){return this.filter(Ps(ra(e)))},Vn.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Vn(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==n&&(i=(t=ho(t))<0?i.dropRight(-t):i.take(t-e)),i)},Vn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Vn.prototype.toArray=function(){return this.take(u)},vi(Vn.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),a=Fn[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);a&&(Fn.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,l=t instanceof Vn,h=o[0],c=l||Bs(t),u=function(e){var t=a.apply(Fn,Pt([e],o));return r&&d?t[0]:t};c&&i&&"function"==typeof h&&1!=h.length&&(l=c=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&c){t=m?t:new Vn(this);var g=e.apply(t,o);return g.__actions__.push({func:ls,args:[u],thisArg:n}),new zn(g,d)}return f&&m?e.apply(this,o):(g=this.thru(u),f?r?g.value()[0]:g.value():g)})})),wt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var r=this.value();return t.apply(Bs(r)?r:[],e)}return this[n]((function(n){return t.apply(Bs(n)?n:[],e)}))}})),vi(Vn.prototype,(function(e,t){var n=Fn[t];if(n){var i=n.name+"";Ie.call(Cn,i)||(Cn[i]=[]),Cn[i].push({name:t,func:n})}})),Cn[Nr(n,2).name]=[{name:"wrapper",func:n}],Vn.prototype.clone=function(){var e=new Vn(this.__wrapped__);return e.__actions__=Er(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Er(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Er(this.__views__),e},Vn.prototype.reverse=function(){if(this.__filtered__){var e=new Vn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Vn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Bs(e),i=t<0,r=n?e.length:0,a=function(e,t,n){for(var i=-1,r=n.length;++i<r;){var a=n[i],s=a.size;switch(a.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=gn(t,e+s);break;case"takeRight":e=mn(e,t-s)}}return{start:e,end:t}}(0,r,this.__views__),s=a.start,o=a.end,l=o-s,h=i?o:s-1,c=this.__iteratees__,u=c.length,d=0,p=gn(l,this.__takeCount__);if(!n||!i&&r==l&&p==l)return cr(e,this.__actions__);var f=[];e:for(;l--&&d<p;){for(var m=-1,g=e[h+=t];++m<u;){var v=c[m],y=v.iteratee,x=v.type,_=y(g);if(2==x)g=_;else if(!_){if(1==x)continue e;break e}}f[d++]=g}return f},Fn.prototype.at=hs,Fn.prototype.chain=function(){return os(this)},Fn.prototype.commit=function(){return new zn(this.value(),this.__chain__)},Fn.prototype.next=function(){this.__values__===n&&(this.__values__=oo(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,i=this;i instanceof Bn;){var r=Oa(i);r.__index__=0,r.__values__=n,t?a.__wrapped__=r:t=r;var a=r;i=i.__wrapped__}return a.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Vn){var t=e;return this.__actions__.length&&(t=new Vn(this)),(t=t.reverse()).__actions__.push({func:ls,args:[$a],thisArg:n}),new zn(t,this.__chain__)}return this.thru($a)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,Je&&(Fn.prototype[Je]=function(){return this}),Fn}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ht._=un,define((function(){return un}))):ut?((ut.exports=un)._=un,ct._=un):ht._=un}).call(e)})),Tue=F(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,i,r,a,s){!function e(n,i,r,a,s){for(;a>r;){if(a-r>600){var o=a-r+1,l=i-r+1,h=Math.log(o),c=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*c*(o-c)/o)*(l-o/2<0?-1:1);e(n,i,Math.max(r,Math.floor(i-l*c/o+u)),Math.min(a,Math.floor(i+(o-l)*c/o+u)),s)}var d=n[i],p=r,f=a;for(t(n,r,i),s(n[a],d)>0&&t(n,r,a);p<f;){for(t(n,p,f),p++,f--;s(n[p],d)<0;)p++;for(;s(n[f],d)>0;)f--}0===s(n[r],d)?t(n,r,f):t(n,++f,a),f<=i&&(r=f+1),i<=f&&(a=f-1)}}(e,i,r||0,a||e.length-1,s||n)}function t(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function n(e,t){return e<t?-1:e>t?1:0}var i=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t,n){if(!n)return t.indexOf(e);for(var i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function a(e,t){s(e,0,e.children.length,t,e)}function s(e,t,n,i,r){r||(r=f(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var a=t;a<n;a++){var s=e.children[a];o(r,e.leaf?i(s):s)}return r}function o(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function l(e,t){return e.minX-t.minX}function h(e,t){return e.minY-t.minY}function c(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function u(e){return e.maxX-e.minX+(e.maxY-e.minY)}function d(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,n,i,r,a){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var o=n+Math.ceil((i-n)/r/2)*r;e(t,o,n,i,a),s.push(n,o,o,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(e){var t=this.data,n=[];if(!p(e,t))return n;for(var i=this.toBBox,r=[];t;){for(var a=0;a<t.children.length;a++){var s=t.children[a],o=t.leaf?i(s):s;p(e,o)&&(t.leaf?n.push(s):d(e,o)?this._all(s,n):r.push(s))}t=r.pop()}return n},i.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var n=[];t;){for(var i=0;i<t.children.length;i++){var r=t.children[i],a=t.leaf?this.toBBox(r):r;if(p(e,a)){if(t.leaf||d(e,a))return!0;n.push(r)}}t=n.pop()}return!1},i.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},i.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},i.prototype.clear=function(){return this.data=f([]),this},i.prototype.remove=function(e,t){if(!e)return this;for(var n,i,a,s=this.data,o=this.toBBox(e),l=[],h=[];s||l.length;){if(s||(s=l.pop(),i=l[l.length-1],n=h.pop(),a=!0),s.leaf){var c=r(e,s.children,t);if(-1!==c)return s.children.splice(c,1),l.push(s),this._condense(l),this}a||s.leaf||!d(s,o)?i?(n++,s=i.children[n],a=!1):s=null:(l.push(s),h.push(n),n=0,i=s,s=s.children[0])}return this},i.prototype.toBBox=function(e){return e},i.prototype.compareMinX=function(e,t){return e.minX-t.minX},i.prototype.compareMinY=function(e,t){return e.minY-t.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(e){return this.data=e,this},i.prototype._all=function(e,t){for(var n=[];e;)e.leaf?t.push.apply(t,e.children):n.push.apply(n,e.children),e=n.pop();return t},i.prototype._build=function(e,t,n,i){var r,s=n-t+1,o=this._maxEntries;if(s<=o)return a(r=f(e.slice(t,n+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,i-1))),(r=f([])).leaf=!1,r.height=i;var l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));m(e,t,n,h,this.compareMinX);for(var c=t;c<=n;c+=h){var u=Math.min(c+h-1,n);m(e,c,u,l,this.compareMinY);for(var d=c;d<=u;d+=l){var p=Math.min(d+l-1,u);r.children.push(this._build(e,d,p,i-1))}}return a(r,this.toBBox),r},i.prototype._chooseSubtree=function(e,t,n,i){for(;i.push(t),!t.leaf&&i.length-1!==n;){for(var r=1/0,a=1/0,s=void 0,o=0;o<t.children.length;o++){var l=t.children[o],h=c(l),u=(d=e,p=l,(Math.max(p.maxX,d.maxX)-Math.min(p.minX,d.minX))*(Math.max(p.maxY,d.maxY)-Math.min(p.minY,d.minY))-h);u<a?(a=u,r=h<r?h:r,s=l):u===a&&h<r&&(r=h,s=l)}t=s||t.children[0]}var d,p;return t},i.prototype._insert=function(e,t,n){var i=n?e:this.toBBox(e),r=[],a=this._chooseSubtree(i,this.data,t,r);for(a.children.push(e),o(a,i);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)},i.prototype._split=function(e,t){var n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),o=f(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,a(n,this.toBBox),a(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)},i.prototype._splitRoot=function(e,t){this.data=f([e,t]),this.data.height=e.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(e,t,n){for(var i,r,a,o,l,h,u,d=1/0,p=1/0,f=t;f<=n-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,n,this.toBBox),v=(r=m,a=g,o=Math.max(r.minX,a.minX),l=Math.max(r.minY,a.minY),h=Math.min(r.maxX,a.maxX),u=Math.min(r.maxY,a.maxY),Math.max(0,h-o)*Math.max(0,u-l)),y=c(m)+c(g);v<d?(d=v,i=f,p=y<p?y:p):v===d&&y<p&&(p=y,i=f)}return i||n-t},i.prototype._chooseSplitAxis=function(e,t,n){var i=e.leaf?this.compareMinX:l,r=e.leaf?this.compareMinY:h;this._allDistMargin(e,t,n,i)<this._allDistMargin(e,t,n,r)&&e.children.sort(i)},i.prototype._allDistMargin=function(e,t,n,i){e.children.sort(i);for(var r=this.toBBox,a=s(e,0,t,r),l=s(e,n-t,n,r),h=u(a)+u(l),c=t;c<n-t;c++){var d=e.children[c];o(a,e.leaf?r(d):d),h+=u(a)}for(var p=n-t-1;p>=t;p--){var f=e.children[p];o(l,e.leaf?r(f):f),h+=u(l)}return h},i.prototype._adjustParentBBoxes=function(e,t,n){for(var i=n;i>=0;i--)o(t[i],e)},i.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},i},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).RBush=i()})),wue=F(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=function(e,n){if(void 0===e&&(e=[]),void 0===n&&(n=t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};function t(e,t){return e<t?-1:e>t?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,n=this.compare,i=t[e];e>0;){var r=e-1>>1,a=t[r];if(n(i,a)>=0)break;t[e]=a,e=r}t[e]=i},e.prototype._down=function(e){for(var t=this.data,n=this.compare,i=this.length>>1,r=t[e];e<i;){var a=1+(e<<1),s=t[a],o=a+1;if(o<this.length&&n(t[o],s)<0&&(a=o,s=t[o]),n(s,r)>=0)break;t[e]=s,e=a}t[e]=r},e},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).TinyQueue=i()})),Sue=F(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=(i-n)/2,l=0,h=o-1;l<o;h=l++){var c=t[n+2*l+0],u=t[n+2*l+1],d=t[n+2*h+0],p=t[n+2*h+1];u>a!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),Aue=F(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=i-n,l=0,h=o-1;l<o;h=l++){var c=t[l+n][0],u=t[l+n][1],d=t[h+n][0],p=t[h+n][1];u>a!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),Iue=F(((e,t)=>{var n=Sue(),i=Aue();t.exports=function(e,t,r,a){return t.length>0&&Array.isArray(t[0])?i(e,t,r,a):n(e,t,r,a)},t.exports.nested=i,t.exports.flat=n})),Lue=F(((e,t)=>{var n,i;n=e,i=function(e){"use strict";function t(e,t,n,i,r){let a,s,o,l,h=t[0],c=i[0],u=0,d=0;c>h==c>-h?(a=h,h=t[++u]):(a=c,c=i[++d]);let p=0;if(u<e&&d<n)for(c>h==c>-h?(o=a-((s=h+a)-h),h=t[++u]):(o=a-((s=c+a)-c),c=i[++d]),a=s,0!==o&&(r[p++]=o);u<e&&d<n;)c>h==c>-h?(o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u]):(o=a-((s=a+c)-(l=s-a))+(c-l),c=i[++d]),a=s,0!==o&&(r[p++]=o);for(;u<e;)o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u],a=s,0!==o&&(r[p++]=o);for(;d<n;)o=a-((s=a+c)-(l=s-a))+(c-l),c=i[++d],a=s,0!==o&&(r[p++]=o);return 0===a&&0!==p||(r[p++]=a),p}function n(e){return new Float64Array(e)}let i=n(4),r=n(8),a=n(12),s=n(16),o=n(4);e.orient2d=function(e,n,l,h,c,u){let d=(n-u)*(l-c),p=(e-c)*(h-u),f=d-p;if(0===d||0===p||d>0!=p>0)return f;let m=Math.abs(d+p);return Math.abs(f)>=33306690738754716e-32*m?f:-function(e,n,l,h,c,u,d){let p,f,m,g,v,y,x,_,b,M,w,S,E,T,A,C,R,P,L=e-c,D=l-c,I=n-u,O=h-u;v=(A=(_=L-(x=(y=134217729*L)-(y-L)))*(M=O-(b=(y=134217729*O)-(y-O)))-((T=L*O)-x*b-_*b-x*M))-(w=A-(R=(_=I-(x=(y=134217729*I)-(y-I)))*(M=D-(b=(y=134217729*D)-(y-D)))-((C=I*D)-x*b-_*b-x*M))),i[0]=A-(w+v)+(v-R),v=(E=T-((S=T+w)-(v=S-T))+(w-v))-(w=E-C),i[1]=E-(w+v)+(v-C),v=(P=S+w)-S,i[2]=S-(P-v)+(w-v),i[3]=P;let U=function(e,t){let n=t[0];for(let i=1;i<4;i++)n+=t[i];return n}(0,i),N=22204460492503146e-32*d;if(U>=N||-U>=N||(p=e-(L+(v=e-L))+(v-c),m=l-(D+(v=l-D))+(v-c),f=n-(I+(v=n-I))+(v-u),g=h-(O+(v=h-O))+(v-u),0===p&&0===f&&0===m&&0===g)||(N=11093356479670487e-47*d+33306690738754706e-32*Math.abs(U),(U+=L*g+O*p-(I*m+D*f))>=N||-U>=N))return U;v=(A=(_=p-(x=(y=134217729*p)-(y-p)))*(M=O-(b=(y=134217729*O)-(y-O)))-((T=p*O)-x*b-_*b-x*M))-(w=A-(R=(_=f-(x=(y=134217729*f)-(y-f)))*(M=D-(b=(y=134217729*D)-(y-D)))-((C=f*D)-x*b-_*b-x*M))),o[0]=A-(w+v)+(v-R),v=(E=T-((S=T+w)-(v=S-T))+(w-v))-(w=E-C),o[1]=E-(w+v)+(v-C),v=(P=S+w)-S,o[2]=S-(P-v)+(w-v),o[3]=P;let F=t(4,i,4,o,r);v=(A=(_=L-(x=(y=134217729*L)-(y-L)))*(M=g-(b=(y=134217729*g)-(y-g)))-((T=L*g)-x*b-_*b-x*M))-(w=A-(R=(_=I-(x=(y=134217729*I)-(y-I)))*(M=m-(b=(y=134217729*m)-(y-m)))-((C=I*m)-x*b-_*b-x*M))),o[0]=A-(w+v)+(v-R),v=(E=T-((S=T+w)-(v=S-T))+(w-v))-(w=E-C),o[1]=E-(w+v)+(v-C),v=(P=S+w)-S,o[2]=S-(P-v)+(w-v),o[3]=P;let k=t(F,r,4,o,a);v=(A=(_=p-(x=(y=134217729*p)-(y-p)))*(M=g-(b=(y=134217729*g)-(y-g)))-((T=p*g)-x*b-_*b-x*M))-(w=A-(R=(_=f-(x=(y=134217729*f)-(y-f)))*(M=m-(b=(y=134217729*m)-(y-m)))-((C=f*m)-x*b-_*b-x*M))),o[0]=A-(w+v)+(v-R),v=(E=T-((S=T+w)-(v=S-T))+(w-v))-(w=E-C),o[1]=E-(w+v)+(v-C),v=(P=S+w)-S,o[2]=S-(P-v)+(w-v),o[3]=P;let B=t(k,a,4,o,s);return s[B-1]}(e,n,l,h,c,u,m)},e.orient2dfast=function(e,t,n,i,r,a){return(t-a)*(n-r)-(e-r)*(i-a)},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof e&&void 0!==t?i(e):"function"==typeof define&&define.amd?define(["exports"],i):i((n=n||self).predicates={})})),Hue=F(((e,t)=>{"use strict";var n=Tue(),i=wue(),r=Iue(),a=Lue().orient2d;function s(e,t,i){t=Math.max(0,void 0===t?2:t),i=i||0;var a=function(e){for(var t=e[0],n=e[0],i=e[0],a=e[0],s=0;s<e.length;s++){var o=e[s];o[0]<t[0]&&(t=o),o[0]>i[0]&&(i=o),o[1]<n[1]&&(n=o),o[1]>a[1]&&(a=o)}var l=[t,n,i,a],h=l.slice();for(s=0;s<e.length;s++)r(e[s],l)||h.push(e[s]);return function(e){e.sort(x);for(var t=[],n=0;n<e.length;n++){for(;t.length>=2&&d(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var i=[],r=e.length-1;r>=0;r--){for(;i.length>=2&&d(i[i.length-2],i[i.length-1],e[r])<=0;)i.pop();i.push(e[r])}return i.pop(),t.pop(),t.concat(i)}(h)}(e),s=new n(16);s.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},s.compareMinX=function(e,t){return e[0]-t[0]},s.compareMinY=function(e,t){return e[1]-t[1]},s.load(e);for(var l,h=[],c=0;c<a.length;c++){var u=a[c];s.remove(u),l=m(u,l),h.push(l)}var p=new n(16);for(c=0;c<h.length;c++)p.insert(f(h[c]));for(var v=t*t,y=i*i;h.length;){var _=h.shift(),b=_.p,M=_.next.p,w=g(b,M);if(!(w<y)){var S=w/v;(u=o(s,_.prev.p,b,M,_.next.next.p,S,p))&&Math.min(g(u,b),g(u,M))<=S&&(h.push(_),h.push(m(u,_)),s.remove(u),p.remove(_),p.insert(f(_)),p.insert(f(_.next)))}}_=l;var E=[];do{E.push(_.p),_=_.next}while(_!==l);return E.push(_.p),E}function o(e,t,n,r,a,s,o){for(var c=new i([],l),d=e.data;d;){for(var p=0;p<d.children.length;p++){var f=d.children[p],m=d.leaf?v(f,n,r):h(n,r,f);m>s||c.push({node:f,dist:m})}for(;c.length&&!c.peek().node.children;){var g=c.pop(),y=g.node,x=v(y,t,n),_=v(y,r,a);if(g.dist<x&&g.dist<_&&u(n,y,o)&&u(r,y,o))return y}(d=c.pop())&&(d=d.node)}return null}function l(e,t){return e.dist-t.dist}function h(e,t,n){if(c(e,n)||c(t,n))return 0;var i=y(e[0],e[1],t[0],t[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=y(e[0],e[1],t[0],t[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var a=y(e[0],e[1],t[0],t[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===a)return 0;var s=y(e[0],e[1],t[0],t[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(i,r,a,s)}function c(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function u(e,t,n){for(var i=Math.min(e[0],t[0]),r=Math.min(e[1],t[1]),a=Math.max(e[0],t[0]),s=Math.max(e[1],t[1]),o=n.search({minX:i,minY:r,maxX:a,maxY:s}),l=0;l<o.length;l++)if(p(o[l].p,o[l].next.p,e,t))return!1;return!0}function d(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function p(e,t,n,i){return e!==i&&t!==n&&d(e,t,n)>0!=d(e,t,i)>0&&d(n,i,e)>0!=d(n,i,t)>0}function f(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function g(e,t){var n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function v(e,t,n){var i=t[0],r=t[1],a=n[0]-i,s=n[1]-r;if(0!==a||0!==s){var o=((e[0]-i)*a+(e[1]-r)*s)/(a*a+s*s);o>1?(i=n[0],r=n[1]):o>0&&(i+=a*o,r+=s*o)}return(a=e[0]-i)*a+(s=e[1]-r)*s}function y(e,t,n,i,r,a,s,o){var l,h,c,u,d=n-e,p=i-t,f=s-r,m=o-a,g=e-r,v=t-a,y=d*d+p*p,x=d*f+p*m,_=f*f+m*m,b=d*g+p*v,M=f*g+m*v,w=y*_-x*x,S=w,E=w;0===w?(h=0,S=1,u=M,E=_):(u=y*M-x*b,(h=x*M-_*b)<0?(h=0,u=M,E=_):h>S&&(h=S,u=M+x,E=_)),u<0?(u=0,-b<0?h=0:-b>y?h=S:(h=-b,S=y)):u>E&&(u=E,-b+x<0?h=0:-b+x>y?h=S:(h=-b+x,S=y));var T=(1-(c=0===u?0:u/E))*r+c*s-((1-(l=0===h?0:h/S))*e+l*n),A=(1-c)*a+c*o-((1-l)*t+l*i);return T*T+A*A}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),t.exports=s,t.exports.default=s})),ahe=F(((e,t)=>{t.exports=function(){var e,t=0,n=!1;function i(t,n){return e.list.push({type:t,data:n?JSON.parse(JSON.stringify(n)):void 0}),e}return e={list:[],segmentId:function(){return t++},checkIntersection:function(e,t){return i("check",{seg1:e,seg2:t})},segmentChop:function(e,t){return i("div_seg",{seg:e,pt:t}),i("chop",{seg:e,pt:t})},statusRemove:function(e){return i("pop_seg",{seg:e})},segmentUpdate:function(e){return i("seg_update",{seg:e})},segmentNew:function(e,t){return i("new_seg",{seg:e,primary:t})},segmentRemove:function(e){return i("rem_seg",{seg:e})},tempStatus:function(e,t,n){return i("temp_status",{seg:e,above:t,below:n})},rewind:function(e){return i("rewind",{seg:e})},status:function(e,t,n){return i("status",{seg:e,above:t,below:n})},vert:function(t){return t===n?e:(n=t,i("vert",{x:t}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),i("log",{txt:e})},reset:function(){return i("reset")},selected:function(e){return i("selected",{segs:e})},chainStart:function(e){return i("chain_start",{seg:e})},chainRemoveHead:function(e,t){return i("chain_rem_head",{index:e,pt:t})},chainRemoveTail:function(e,t){return i("chain_rem_tail",{index:e,pt:t})},chainNew:function(e,t){return i("chain_new",{pt1:e,pt2:t})},chainMatch:function(e){return i("chain_match",{index:e})},chainClose:function(e){return i("chain_close",{index:e})},chainAddHead:function(e,t){return i("chain_add_head",{index:e,pt:t})},chainAddTail:function(e,t){return i("chain_add_tail",{index:e,pt:t})},chainConnect:function(e,t){return i("chain_con",{index1:e,index2:t})},chainReverse:function(e){return i("chain_rev",{index:e})},chainJoin:function(e,t){return i("chain_join",{index1:e,index2:t})},done:function(){return i("done")}}}})),lhe=F(((e,t)=>{t.exports=function(e){"number"!=typeof e&&(e=1e-10);var t={epsilon:function(t){return"number"==typeof t&&(e=t),e},pointAboveOrOnLine:function(t,n,i){var r=n[0],a=n[1],s=i[0],o=i[1],l=t[0];return(s-r)*(t[1]-a)-(o-a)*(l-r)>=-e},pointBetween:function(t,n,i){var r=t[1]-n[1],a=i[0]-n[0],s=t[0]-n[0],o=i[1]-n[1],l=s*a+r*o;return!(l<e)&&!(l-(a*a+o*o)>-e)},pointsSameX:function(t,n){return Math.abs(t[0]-n[0])<e},pointsSameY:function(t,n){return Math.abs(t[1]-n[1])<e},pointsSame:function(e,n){return t.pointsSameX(e,n)&&t.pointsSameY(e,n)},pointsCompare:function(e,n){return t.pointsSameX(e,n)?t.pointsSameY(e,n)?0:e[1]<n[1]?-1:1:e[0]<n[0]?-1:1},pointsCollinear:function(t,n,i){var r=t[0]-n[0],a=t[1]-n[1],s=n[0]-i[0],o=n[1]-i[1];return Math.abs(r*o-s*a)<e},linesIntersect:function(t,n,i,r){var a=n[0]-t[0],s=n[1]-t[1],o=r[0]-i[0],l=r[1]-i[1],h=a*l-s*o;if(Math.abs(h)<e)return!1;var c=t[0]-i[0],u=t[1]-i[1],d=(o*u-l*c)/h,p=(a*u-s*c)/h,f={alongA:0,alongB:0,pt:[t[0]+d*a,t[1]+d*s]};return f.alongA=d<=-e?-2:d<e?-1:d-1<=-e?0:d-1<e?1:2,f.alongB=p<=-e?-2:p<e?-1:p-1<=-e?0:p-1<e?1:2,f},pointInsideRegion:function(t,n){for(var i=t[0],r=t[1],a=n[n.length-1][0],s=n[n.length-1][1],o=!1,l=0;l<n.length;l++){var h=n[l][0],c=n[l][1];c-r>e!=s-r>e&&(a-h)*(r-c)/(s-c)+h-i>e&&(o=!o),a=h,s=c}return o}};return t}})),uhe=F(((e,t)=>{t.exports={create:function(){var e={root:{root:!0,next:null},exists:function(t){return!(null===t||t===e.root)},isEmpty:function(){return null===e.root.next},getHead:function(){return e.root.next},insertBefore:function(t,n){for(var i=e.root,r=e.root.next;null!==r;){if(n(r))return t.prev=r.prev,t.next=r,r.prev.next=t,void(r.prev=t);i=r,r=r.next}i.next=t,t.prev=i,t.next=null},findTransition:function(t){for(var n=e.root,i=e.root.next;null!==i&&!t(i);)n=i,i=i.next;return{before:n===e.root?null:n,after:i,insert:function(e){return e.prev=n,e.next=i,n.next=e,null!==i&&(i.prev=e),e}}}};return e},node:function(e){return e.prev=null,e.next=null,e.remove=function(){e.prev.next=e.next,e.next&&(e.next.prev=e.prev),e.prev=null,e.next=null},e}}})),dhe=F(((e,t)=>{var n=uhe();t.exports=function(e,t,i){function r(e,t){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:null,below:null},otherFill:null}}function a(e,t,n){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:n.myFill.above,below:n.myFill.below},otherFill:null}}var s=n.create();function o(e,n){s.insertBefore(e,(function(i){var r=function(e,n,i,r,a,s){var o=t.pointsCompare(n,a);return 0!==o?o:t.pointsSame(i,s)?0:e!==r?e?1:-1:t.pointAboveOrOnLine(i,r?a:s,r?s:a)?1:-1}(e.isStart,e.pt,n,i.isStart,i.pt,i.other.pt);return r<0}))}function l(e,t){var i=function(e,t){var i=n.node({isStart:!0,pt:e.start,seg:e,primary:t,other:null,status:null});return o(i,e.end),i}(e,t);return function(e,t,i){var r=n.node({isStart:!1,pt:t.end,seg:t,primary:i,other:e,status:null});e.other=r,o(r,e.pt)}(i,e,t),i}function h(e,t){var n=a(t,e.seg.end,e.seg);return function(e,t){i&&i.segmentChop(e.seg,t),e.other.remove(),e.seg.end=t,e.other.pt=t,o(e.other,e.pt)}(e,t),l(n,e.primary)}function c(r,a){var o=n.create();function l(e){return o.findTransition((function(n){var i=function(e,n){var i=e.seg.start,r=e.seg.end,a=n.seg.start,s=n.seg.end;return t.pointsCollinear(i,a,s)?t.pointsCollinear(r,a,s)||t.pointAboveOrOnLine(r,a,s)?1:-1:t.pointAboveOrOnLine(i,a,s)?1:-1}(e,n.ev);return i>0}))}function c(e,n){var r=e.seg,a=n.seg,s=r.start,o=r.end,l=a.start,c=a.end;i&&i.checkIntersection(r,a);var u=t.linesIntersect(s,o,l,c);if(!1===u){if(!t.pointsCollinear(s,o,l)||t.pointsSame(s,c)||t.pointsSame(o,l))return!1;var d=t.pointsSame(s,l),p=t.pointsSame(o,c);if(d&&p)return n;var f=!d&&t.pointBetween(s,l,c),m=!p&&t.pointBetween(o,l,c);if(d)return m?h(n,o):h(e,c),n;f&&(p||(m?h(n,o):h(e,c)),h(n,s))}else 0===u.alongA&&(-1===u.alongB?h(e,l):0===u.alongB?h(e,u.pt):1===u.alongB&&h(e,c)),0===u.alongB&&(-1===u.alongA?h(n,s):0===u.alongA?h(n,u.pt):1===u.alongA&&h(n,o));return!1}for(var u=[];!s.isEmpty();){var d=s.getHead();if(i&&i.vert(d.pt[0]),d.isStart){let t=function(){if(f){var e=c(d,f);if(e)return e}return!!m&&c(d,m)};i&&i.segmentNew(d.seg,d.primary);var p=l(d),f=p.before?p.before.ev:null,m=p.after?p.after.ev:null;i&&i.tempStatus(d.seg,!!f&&f.seg,!!m&&m.seg);var g,v=t();if(v)e?(g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(v.seg.myFill.above=!v.seg.myFill.above):v.seg.otherFill=d.seg.myFill,i&&i.segmentUpdate(v.seg),d.other.remove(),d.remove();if(s.getHead()!==d){i&&i.rewind(d.seg);continue}if(e)g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=m?m.seg.myFill.above:r,d.seg.myFill.above=g?!d.seg.myFill.below:d.seg.myFill.below;else if(null===d.seg.otherFill){var y;y=m?d.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:d.primary?a:r,d.seg.otherFill={above:y,below:y}}i&&i.status(d.seg,!!f&&f.seg,!!m&&m.seg),d.other.status=p.insert(n.node({ev:d}))}else{var x=d.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(o.exists(x.prev)&&o.exists(x.next)&&c(x.prev.ev,x.next.ev),i&&i.statusRemove(x.ev.seg),x.remove(),!d.primary){var _=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=_}u.push(d.seg)}s.getHead().remove()}return i&&i.done(),u}return e?{addRegion:function(e){for(var n,i=e[e.length-1],a=0;a<e.length;a++){n=i,i=e[a];var s=t.pointsCompare(n,i);0!==s&&l(r(s<0?n:i,s<0?i:n),!0)}},calculate:function(e){return c(e,!1)}}:{calculate:function(e,t,n,i){return e.forEach((function(e){l(a(e.start,e.end,e),!0)})),n.forEach((function(e){l(a(e.start,e.end,e),!1)})),c(t,i)}}}})),phe=F(((e,t)=>{t.exports=function(e,t,n){var i=[],r=[];return e.forEach((function(e){var a=e.start,s=e.end;if(t.pointsSame(a,s))console.warn("PolyBool: Warning: Zero-length segment detected; your epsilon is probably too small or too large");else{n&&n.chainStart(e);for(var o={index:0,matches_head:!1,matches_pt1:!1},l={index:0,matches_head:!1,matches_pt1:!1},h=o,c=0;c<i.length;c++){var u=(g=i[c])[0],d=(g[1],g[g.length-1]);if(g[g.length-2],t.pointsSame(u,a)){if(S(c,!0,!0))break}else if(t.pointsSame(u,s)){if(S(c,!0,!1))break}else if(t.pointsSame(d,a)){if(S(c,!1,!0))break}else if(t.pointsSame(d,s)&&S(c,!1,!1))break}if(h===o)return i.push([a,s]),void(n&&n.chainNew(a,s));if(h===l){n&&n.chainMatch(o.index);var p=o.index,f=o.matches_pt1?s:a,m=o.matches_head,g=i[p],v=m?g[0]:g[g.length-1],y=m?g[1]:g[g.length-2],x=m?g[g.length-1]:g[0],_=m?g[g.length-2]:g[1];return t.pointsCollinear(y,v,f)&&(m?(n&&n.chainRemoveHead(o.index,f),g.shift()):(n&&n.chainRemoveTail(o.index,f),g.pop()),v=y),t.pointsSame(x,f)?(i.splice(p,1),t.pointsCollinear(_,x,v)&&(m?(n&&n.chainRemoveTail(o.index,v),g.pop()):(n&&n.chainRemoveHead(o.index,v),g.shift())),n&&n.chainClose(o.index),void r.push(g)):void(m?(n&&n.chainAddHead(o.index,f),g.unshift(f)):(n&&n.chainAddTail(o.index,f),g.push(f)))}var b=o.index,M=l.index;n&&n.chainConnect(b,M);var w=i[b].length<i[M].length;o.matches_head?l.matches_head?w?(E(b),T(b,M)):(E(M),T(M,b)):T(M,b):l.matches_head?T(b,M):w?(E(b),T(M,b)):(E(M),T(b,M))}function S(e,t,n){return h.index=e,h.matches_head=t,h.matches_pt1=n,h===o?(h=l,!1):(h=null,!0)}function E(e){n&&n.chainReverse(e),i[e].reverse()}function T(e,r){var a=i[e],s=i[r],o=a[a.length-1],l=a[a.length-2],h=s[0],c=s[1];t.pointsCollinear(l,o,h)&&(n&&n.chainRemoveTail(e,o),a.pop(),o=l),t.pointsCollinear(o,h,c)&&(n&&n.chainRemoveHead(r,h),s.shift()),n&&n.chainJoin(e,r),i[e]=a.concat(s),i.splice(r,1)}})),r}})),ghe=F(((e,t)=>{function n(e,t,n){var i=[];return e.forEach((function(e){var r=(e.myFill.above?8:0)+(e.myFill.below?4:0)+(e.otherFill&&e.otherFill.above?2:0)+(e.otherFill&&e.otherFill.below?1:0);0!==t[r]&&i.push({id:n?n.segmentId():-1,start:e.start,end:e.end,myFill:{above:1===t[r],below:2===t[r]},otherFill:null})})),n&&n.selected(i),i}var i={union:function(e,t){return n(e,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],t)},intersect:function(e,t){return n(e,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],t)},difference:function(e,t){return n(e,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],t)},differenceRev:function(e,t){return n(e,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],t)},xor:function(e,t){return n(e,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],t)}};t.exports=i})),xhe=F(((e,t)=>{var n={toPolygon:function(e,t){function n(t){if(t.length<=0)return e.segments({inverted:!1,regions:[]});function n(t){var n=t.slice(0,t.length-1);return e.segments({inverted:!1,regions:[n]})}for(var i=n(t[0]),r=1;r<t.length;r++)i=e.selectDifference(e.combine(i,n(t[r])));return i}if("Polygon"===t.type)return e.polygon(n(t.coordinates));if("MultiPolygon"===t.type){for(var i=e.segments({inverted:!1,regions:[]}),r=0;r<t.coordinates.length;r++)i=e.selectUnion(e.combine(i,n(t.coordinates[r])));return e.polygon(i)}throw new Error("PolyBool: Cannot convert GeoJSON object to PolyBool polygon")},fromPolygon:function(e,t,n){function i(e,n){return t.pointInsideRegion([.5*(e[0][0]+e[1][0]),.5*(e[0][1]+e[1][1])],n)}function r(e){return{region:e,children:[]}}n=e.polygon(e.segments(n));var a=r(null);function s(e,t){for(var n=0;n<e.children.length;n++)if(i(t,(o=e.children[n]).region))return void s(o,t);var a=r(t);for(n=0;n<e.children.length;n++){var o;i((o=e.children[n]).region,t)&&(a.children.push(o),e.children.splice(n,1),n--)}e.children.push(a)}for(var o=0;o<n.regions.length;o++){var l=n.regions[o];l.length<3||s(a,l)}function h(e,t){for(var n=0,i=e[e.length-1][0],r=e[e.length-1][1],a=[],s=0;s<e.length;s++){var o=e[s][0],l=e[s][1];a.push([o,l]),n+=l*i-o*r,i=o,r=l}return n<0!==t&&a.reverse(),a.push([a[0][0],a[0][1]]),a}var c=[];function u(e){var t=[h(e.region,!1)];c.push(t);for(var n=0;n<e.children.length;n++)t.push(d(e.children[n]))}function d(e){for(var t=0;t<e.children.length;t++)u(e.children[t]);return h(e.region,!0)}for(o=0;o<a.children.length;o++)u(a.children[o]);return c.length<=0?{type:"Polygon",coordinates:[]}:1==c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}};t.exports=n})),_he=F(((e,t)=>{var n,i=ahe(),r=lhe(),a=dhe(),s=phe(),o=ghe(),l=xhe(),h=!1,c=r();function u(e,t,i){var r=n.segments(e),a=n.segments(t),s=i(n.combine(r,a));return n.polygon(s)}n={buildLog:function(e){return!0===e?h=i():!1===e&&(h=!1),!1!==h&&h.list},epsilon:function(e){return c.epsilon(e)},segments:function(e){var t=a(!0,c,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:a(!1,c,h).calculate(e.segments,e.inverted,t.segments,t.inverted),inverted1:e.inverted,inverted2:t.inverted}},selectUnion:function(e){return{segments:o.union(e.combined,h),inverted:e.inverted1||e.inverted2}},selectIntersect:function(e){return{segments:o.intersect(e.combined,h),inverted:e.inverted1&&e.inverted2}},selectDifference:function(e){return{segments:o.difference(e.combined,h),inverted:e.inverted1&&!e.inverted2}},selectDifferenceRev:function(e){return{segments:o.differenceRev(e.combined,h),inverted:!e.inverted1&&e.inverted2}},selectXor:function(e){return{segments:o.xor(e.combined,h),inverted:e.inverted1!==e.inverted2}},polygon:function(e){return{regions:s(e.segments,c,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return l.toPolygon(n,e)},polygonToGeoJSON:function(e){return l.fromPolygon(n,c,e)},union:function(e,t){return u(e,t,n.selectUnion)},intersect:function(e,t){return u(e,t,n.selectIntersect)},difference:function(e,t){return u(e,t,n.selectDifference)},differenceRev:function(e,t){return u(e,t,n.selectDifferenceRev)},xor:function(e,t){return u(e,t,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),t.exports=n})),efe=F(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function n(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}var i=function(e,t){this.next=null,this.key=e,this.data=t,this.left=null,this.right=null};function r(e,t){return e>t?1:e<t?-1:0}function a(e,t,n){for(var r=new i(null,null),a=r,s=r;;){var o=n(e,t.key);if(o<0){if(null===t.left)break;if(n(e,t.left.key)<0){var l=t.left;if(t.left=l.right,l.right=t,null===(t=l).left)break}s.left=t,s=t,t=t.left}else{if(!(o>0))break;if(null===t.right)break;if(n(e,t.right.key)>0&&(l=t.right,t.right=l.left,l.left=t,null===(t=l).right))break;a.right=t,a=t,t=t.right}}return a.right=t.left,s.left=t.right,t.left=r.right,t.right=r.left,t}function s(e,t,n,r){var s=new i(e,t);if(null===n)return s.left=s.right=null,s;var o=r(e,(n=a(e,n,r)).key);return o<0?(s.left=n.left,s.right=n,n.left=null):o>=0&&(s.right=n.right,s.left=n,n.right=null),s}function o(e,t,n){var i=null,r=null;if(t){var s=n((t=a(e,t,n)).key,e);0===s?(i=t.left,r=t.right):s<0?(r=t.right,t.right=null,i=t):(i=t.left,t.left=null,r=t)}return{left:i,right:r}}function l(e,t,n,i,r){if(e){i(t+(n?"\u2514\u2500\u2500 ":"\u251c\u2500\u2500 ")+r(e)+"\n");var a=t+(n?" ":"\u2502 ");e.left&&l(e.left,a,!1,i,r),e.right&&l(e.right,a,!0,i,r)}}var h=function(){function e(e){void 0===e&&(e=r),this._root=null,this._size=0,this._comparator=e}return e.prototype.insert=function(e,t){return this._size++,this._root=s(e,t,this._root,this._comparator)},e.prototype.add=function(e,t){var n=new i(e,t);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,s=a(e,this._root,r),o=r(e,s.key);return 0===o?this._root=s:(o<0?(n.left=s.left,n.right=s,s.left=null):o>0&&(n.right=s.right,n.left=s,s.right=null),this._size++,this._root=n),this._root},e.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},e.prototype._remove=function(e,t,n){var i;return null===t?null:0===n(e,(t=a(e,t,n)).key)?(null===t.left?i=t.right:(i=a(e,t.left,n)).right=t.right,this._size--,i):t},e.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=a(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},e.prototype.findStatic=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return t;t=i<0?t.left:t.right}return null},e.prototype.find=function(e){return this._root&&(this._root=a(e,this._root,this._comparator),0!==this._comparator(e,this._root.key))?null:this._root},e.prototype.contains=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return!0;t=i<0?t.left:t.right}return!1},e.prototype.forEach=function(e,t){for(var n=this._root,i=[],r=!1;!r;)null!==n?(i.push(n),n=n.left):0!==i.length?(n=i.pop(),e.call(t,n),n=n.right):r=!0;return this},e.prototype.range=function(e,t,n,i){for(var r=[],a=this._comparator,s=this._root;0!==r.length||s;)if(s)r.push(s),s=s.left;else{if(a((s=r.pop()).key,t)>0)break;if(a(s.key,e)>=0&&n.call(i,s))return this;s=s.right}return this},e.prototype.keys=function(){var e=[];return this.forEach((function(t){var n=t.key;return e.push(n)})),e},e.prototype.values=function(){var e=[];return this.forEach((function(t){var n=t.data;return e.push(n)})),e},e.prototype.min=function(){return this._root?this.minNode(this._root).key:null},e.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},e.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},e.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},e.prototype.at=function(e){for(var t=this._root,n=!1,i=0,r=[];!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right}else n=!0;return null},e.prototype.next=function(e){var t=this._root,n=null;if(e.right){for(n=e.right;n.left;)n=n.left;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?(n=t,t=t.left):t=t.right}return n},e.prototype.prev=function(e){var t=this._root,n=null;if(null!==e.left){for(n=e.left;n.right;)n=n.right;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?t=t.left:(n=t,t=t.right)}return n},e.prototype.clear=function(){return this._root=null,this._size=0,this},e.prototype.toList=function(){return function(e){for(var t=e,n=[],r=!1,a=new i(null,null),s=a;!r;)t?(n.push(t),t=t.left):n.length>0?t=(t=s=s.next=n.pop()).right:r=!0;return s.next=null,a.next}(this._root)},e.prototype.load=function(e,t,n){void 0===t&&(t=[]),void 0===n&&(n=!1);var r=e.length,a=this._comparator;if(n&&d(e,t,0,r-1,a),null===this._root)this._root=c(e,t,0,r),this._size=r;else{var s=function(e,t,n){for(var r=new i(null,null),a=r,s=e,o=t;null!==s&&null!==o;)n(s.key,o.key)<0?(a.next=s,s=s.next):(a.next=o,o=o.next),a=a.next;return null!==s?a.next=s:null!==o&&(a.next=o),r.next}(this.toList(),function(e,t){for(var n=new i(null,null),r=n,a=0;a<e.length;a++)r=r.next=new i(e[a],t[a]);return r.next=null,n.next}(e,t),a);r=this._size+r,this._root=u({head:s},0,r)}return this},e.prototype.isEmpty=function(){return null===this._root},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){void 0===e&&(e=function(e){return String(e.key)});var t=[];return l(this._root,"",!0,(function(e){return t.push(e)}),e),t.join("")},e.prototype.update=function(e,t,n){var i=this._comparator,r=o(e,this._root,i),l=r.left,h=r.right;i(e,t)<0?h=s(t,n,h,i):l=s(t,n,l,i),this._root=function(e,t,n){return null===t?e:(null===e||((t=a(e.key,t,n)).left=e),t)}(l,h,i)},e.prototype.split=function(e){return o(e,this._root,this._comparator)},e}();function c(e,t,n,r){var a=r-n;if(a>0){var s=n+Math.floor(a/2),o=e[s],l=t[s],h=new i(o,l);return h.left=c(e,t,n,s),h.right=c(e,t,s+1,r),h}return null}function u(e,t,n){var i=n-t;if(i>0){var r=t+Math.floor(i/2),a=u(e,t,r),s=e.head;return s.left=a,e.head=e.head.next,s.right=u(e,r+1,n),s}return null}function d(e,t,n,i,r){if(!(n>=i)){for(var a=e[n+i>>1],s=n-1,o=i+1;;){do{s++}while(r(e[s],a)<0);do{o--}while(r(e[o],a)>0);if(s>=o)break;var l=e[s];e[s]=e[o],e[o]=l,l=t[s],t[s]=t[o],t[o]=l}d(e,t,n,o,r),d(e,t,o+1,i,r)}}var p=function(e,t){return e.ll.x<=t.x&&t.x<=e.ur.x&&e.ll.y<=t.y&&t.y<=e.ur.y},f=function(e,t){if(t.ur.x<e.ll.x||e.ur.x<t.ll.x||t.ur.y<e.ll.y||e.ur.y<t.ll.y)return null;var n=e.ll.x<t.ll.x?t.ll.x:e.ll.x,i=e.ur.x<t.ur.x?e.ur.x:t.ur.x;return{ll:{x:n,y:e.ll.y<t.ll.y?t.ll.y:e.ll.y},ur:{x:i,y:e.ur.y<t.ur.y?e.ur.y:t.ur.y}}},m=Number.EPSILON;void 0===m&&(m=Math.pow(2,-52));var g=m*m,v=function(e,t){if(-m<e&&e<m&&-m<t&&t<m)return 0;var n=e-t;return n*n<g*e*t?0:e<t?-1:1},y=function(){function t(){e(this,t),this.reset()}return n(t,[{key:"reset",value:function(){this.xRounder=new x,this.yRounder=new x}},{key:"round",value:function(e,t){return{x:this.xRounder.round(e),y:this.yRounder.round(t)}}}]),t}(),x=function(){function t(){e(this,t),this.tree=new h,this.round(0)}return n(t,[{key:"round",value:function(e){var t=this.tree.add(e),n=this.tree.prev(t);if(null!==n&&0===v(t.key,n.key))return this.tree.remove(e),n.key;var i=this.tree.next(t);return null!==i&&0===v(t.key,i.key)?(this.tree.remove(e),i.key):e}}]),t}(),_=new y,b=function(e,t){return e.x*t.y-e.y*t.x},M=function(e,t){return e.x*t.x+e.y*t.y},w=function(e,t,n){var i={x:t.x-e.x,y:t.y-e.y},r={x:n.x-e.x,y:n.y-e.y},a=b(i,r);return v(a,0)},S=function(e){return Math.sqrt(M(e,e))},E=function(e,t,n){var i={x:t.x-e.x,y:t.y-e.y},r={x:n.x-e.x,y:n.y-e.y};return b(r,i)/S(r)/S(i)},T=function(e,t,n){var i={x:t.x-e.x,y:t.y-e.y},r={x:n.x-e.x,y:n.y-e.y};return M(r,i)/S(r)/S(i)},A=function(e,t,n){return 0===t.y?null:{x:e.x+t.x/t.y*(n-e.y),y:n}},C=function(e,t,n){return 0===t.x?null:{x:n,y:e.y+t.y/t.x*(n-e.x)}},R=function(){function t(n,i){e(this,t),void 0===n.events?n.events=[this]:n.events.push(this),this.point=n,this.isLeft=i}return n(t,null,[{key:"compare",value:function(e,n){var i=t.comparePoints(e.point,n.point);return 0!==i?i:(e.point!==n.point&&e.link(n),e.isLeft!==n.isLeft?e.isLeft?1:-1:L.compare(e.segment,n.segment))}},{key:"comparePoints",value:function(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0}}]),n(t,[{key:"link",value:function(e){if(e.point===this.point)throw new Error("Tried to link already linked events");for(var t=e.point.events,n=0,i=t.length;n<i;n++){var r=t[n];this.point.events.push(r),r.point=this.point}this.checkForConsuming()}},{key:"checkForConsuming",value:function(){for(var e=this.point.events.length,t=0;t<e;t++){var n=this.point.events[t];if(void 0===n.segment.consumedBy)for(var i=t+1;i<e;i++){var r=this.point.events[i];void 0===r.consumedBy&&n.otherSE.point.events===r.otherSE.point.events&&n.segment.consume(r.segment)}}}},{key:"getAvailableLinkedEvents",value:function(){for(var e=[],t=0,n=this.point.events.length;t<n;t++){var i=this.point.events[t];i!==this&&!i.segment.ringOut&&i.segment.isInResult()&&e.push(i)}return e}},{key:"getLeftmostComparator",value:function(e){var t=this,n=new Map,i=function(i){var r=i.otherSE;n.set(i,{sine:E(t.point,e.point,r.point),cosine:T(t.point,e.point,r.point)})};return function(e,t){n.has(e)||i(e),n.has(t)||i(t);var r=n.get(e),a=r.sine,s=r.cosine,o=n.get(t),l=o.sine,h=o.cosine;return a>=0&&l>=0?s<h?1:s>h?-1:0:a<0&&l<0?s<h?-1:s>h?1:0:l<a?-1:l>a?1:0}}}]),t}(),P=0,L=function(){function t(n,i,r,a){e(this,t),this.id=++P,this.leftSE=n,n.segment=this,n.otherSE=i,this.rightSE=i,i.segment=this,i.otherSE=n,this.rings=r,this.windings=a}return n(t,null,[{key:"compare",value:function(e,t){var n=e.leftSE.point.x,i=t.leftSE.point.x,r=e.rightSE.point.x,a=t.rightSE.point.x;if(a<n)return 1;if(r<i)return-1;var s=e.leftSE.point.y,o=t.leftSE.point.y,l=e.rightSE.point.y,h=t.rightSE.point.y;if(n<i){if(o<s&&o<l)return 1;if(o>s&&o>l)return-1;var c=e.comparePoint(t.leftSE.point);if(c<0)return 1;if(c>0)return-1;var u=t.comparePoint(e.rightSE.point);return 0!==u?u:-1}if(n>i){if(s<o&&s<h)return-1;if(s>o&&s>h)return 1;var d=t.comparePoint(e.leftSE.point);if(0!==d)return d;var p=e.comparePoint(t.rightSE.point);return p<0?1:p>0?-1:1}if(s<o)return-1;if(s>o)return 1;if(r<a){var f=t.comparePoint(e.rightSE.point);if(0!==f)return f}if(r>a){var m=e.comparePoint(t.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(r!==a){var g=l-s,v=r-n,y=h-o,x=a-i;if(g>v&&y<x)return 1;if(g<v&&y>x)return-1}return r>a?1:r<a||l<h?-1:l>h?1:e.id<t.id?-1:e.id>t.id?1:0}}]),n(t,[{key:"replaceRightSE",value:function(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e<t?e:t},ur:{x:this.rightSE.point.x,y:e>t?e:t}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}},{key:"comparePoint",value:function(e){if(this.isAnEndpoint(e))return 0;var t=this.leftSE.point,n=this.rightSE.point,i=this.vector();if(t.x===n.x)return e.x===t.x?0:e.x<t.x?1:-1;var r=(e.y-t.y)/i.y,a=t.x+r*i.x;if(e.x===a)return 0;var s=(e.x-t.x)/i.x,o=t.y+s*i.y;return e.y===o?0:e.y<o?-1:1}},{key:"getIntersection",value:function(e){var t=this.bbox(),n=e.bbox(),i=f(t,n);if(null===i)return null;var r=this.leftSE.point,a=this.rightSE.point,s=e.leftSE.point,o=e.rightSE.point,l=p(t,s)&&0===this.comparePoint(s),h=p(n,r)&&0===e.comparePoint(r),c=p(t,o)&&0===this.comparePoint(o),u=p(n,a)&&0===e.comparePoint(a);if(h&&l)return u&&!c?a:!u&&c?o:null;if(h)return c&&r.x===o.x&&r.y===o.y?null:r;if(l)return u&&a.x===s.x&&a.y===s.y?null:s;if(u&&c)return null;if(u)return a;if(c)return o;var d=function(e,t,n,i){if(0===t.x)return C(n,i,e.x);if(0===i.x)return C(e,t,n.x);if(0===t.y)return A(n,i,e.y);if(0===i.y)return A(e,t,n.y);var r=b(t,i);if(0==r)return null;var a={x:n.x-e.x,y:n.y-e.y},s=b(a,t)/r,o=b(a,i)/r;return{x:(e.x+o*t.x+(n.x+s*i.x))/2,y:(e.y+o*t.y+(n.y+s*i.y))/2}}(r,this.vector(),s,e.vector());return null!==d&&p(i,d)?_.round(d.x,d.y):null}},{key:"split",value:function(e){var n=[],i=void 0!==e.events,r=new R(e,!0),a=new R(e,!1),s=this.rightSE;this.replaceRightSE(a),n.push(a),n.push(r);var o=new t(r,s,this.rings.slice(),this.windings.slice());return R.comparePoints(o.leftSE.point,o.rightSE.point)>0&&o.swapEvents(),R.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),a.checkForConsuming()),n}},{key:"swapEvents",value:function(){var e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var t=0,n=this.windings.length;t<n;t++)this.windings[t]*=-1}},{key:"consume",value:function(e){for(var n=this,i=e;n.consumedBy;)n=n.consumedBy;for(;i.consumedBy;)i=i.consumedBy;var r=t.compare(n,i);if(0!==r){if(r>0){var a=n;n=i,i=a}if(n.prev===i){var s=n;n=i,i=s}for(var o=0,l=i.rings.length;o<l;o++){var h=i.rings[o],c=i.windings[o],u=n.rings.indexOf(h);-1===u?(n.rings.push(h),n.windings.push(c)):n.windings[u]+=c}i.rings=null,i.windings=null,i.consumedBy=n,i.leftSE.consumedBy=n.leftSE,i.rightSE.consumedBy=n.rightSE}}},{key:"prevInResult",value:function(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}},{key:"beforeState",value:function(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){var e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}},{key:"afterState",value:function(){if(void 0!==this._afterState)return this._afterState;var e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};for(var t=this._afterState.rings,n=this._afterState.windings,i=this._afterState.multiPolys,r=0,a=this.rings.length;r<a;r++){var s=this.rings[r],o=this.windings[r],l=t.indexOf(s);-1===l?(t.push(s),n.push(o)):n[l]+=o}for(var h=[],c=[],u=0,d=t.length;u<d;u++)if(0!==n[u]){var p=t[u],f=p.poly;if(-1===c.indexOf(f))if(p.isExterior)h.push(f);else{-1===c.indexOf(f)&&c.push(f);var m=h.indexOf(p.poly);-1!==m&&h.splice(m,1)}}for(var g=0,v=h.length;g<v;g++){var y=h[g].multiPoly;-1===i.indexOf(y)&&i.push(y)}return this._afterState}},{key:"isInResult",value:function(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;var e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(V.type){case"union":var n=0===e.length,i=0===t.length;this._isInResult=n!==i;break;case"intersection":var r,a;e.length<t.length?(r=e.length,a=t.length):(r=t.length,a=e.length),this._isInResult=a===V.numMultiPolys&&r<a;break;case"xor":var s=Math.abs(e.length-t.length);this._isInResult=s%2==1;break;case"difference":var o=function(e){return 1===e.length&&e[0].isSubject};this._isInResult=o(e)!==o(t);break;default:throw new Error("Unrecognized operation type found ".concat(V.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,n,i){var r,a,s,o=R.comparePoints(e,n);if(o<0)r=e,a=n,s=1;else{if(!(o>0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=n,a=e,s=-1}return new t(new R(r,!0),new R(a,!1),[i],[s])}}]),t}(),D=function(){function t(n,i,r){if(e(this,t),!Array.isArray(n)||0===n.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=i,this.isExterior=r,this.segments=[],"number"!=typeof n[0][0]||"number"!=typeof n[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var a=_.round(n[0][0],n[0][1]);this.bbox={ll:{x:a.x,y:a.y},ur:{x:a.x,y:a.y}};for(var s=a,o=1,l=n.length;o<l;o++){if("number"!=typeof n[o][0]||"number"!=typeof n[o][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var h=_.round(n[o][0],n[o][1]);h.x===s.x&&h.y===s.y||(this.segments.push(L.fromRing(s,h,this)),h.x<this.bbox.ll.x&&(this.bbox.ll.x=h.x),h.y<this.bbox.ll.y&&(this.bbox.ll.y=h.y),h.x>this.bbox.ur.x&&(this.bbox.ur.x=h.x),h.y>this.bbox.ur.y&&(this.bbox.ur.y=h.y),s=h)}(a.x!==s.x||a.y!==s.y)&&this.segments.push(L.fromRing(s,a,this))}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.segments.length;t<n;t++){var i=this.segments[t];e.push(i.leftSE),e.push(i.rightSE)}return e}}]),t}(),I=function(){function t(n,i){if(e(this,t),!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new D(n[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(var r=1,a=n.length;r<a;r++){var s=new D(n[r],this,!1);s.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),t=0,n=this.interiorRings.length;t<n;t++)for(var i=this.interiorRings[t].getSweepEvents(),r=0,a=i.length;r<a;r++)e.push(i[r]);return e}}]),t}(),O=function(){function t(n,i){if(e(this,t),!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof n[0][0][0]&&(n=[n])}catch(e){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(var r=0,a=n.length;r<a;r++){var s=new I(n[r],this);s.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.polys.length;t<n;t++)for(var i=this.polys[t].getSweepEvents(),r=0,a=i.length;r<a;r++)e.push(i[r]);return e}}]),t}(),U=function(){function t(n){e(this,t),this.events=n;for(var i=0,r=n.length;i<r;i++)n[i].segment.ringOut=this;this.poly=null}return n(t,null,[{key:"factory",value:function(e){for(var n=[],i=0,r=e.length;i<r;i++){var a=e[i];if(a.isInResult()&&!a.ringOut){for(var s=null,o=a.leftSE,l=a.rightSE,h=[o],c=o.point,u=[];s=o,o=l,h.push(o),o.point!==c;)for(;;){var d=o.getAvailableLinkedEvents();if(0===d.length){var p=h[0].point,f=h[h.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(p.x,",")+" ".concat(p.y,"]. Last matching segment found ends at")+" [".concat(f.x,", ").concat(f.y,"]."))}if(1===d.length){l=d[0].otherSE;break}for(var m=null,g=0,v=u.length;g<v;g++)if(u[g].point===o.point){m=g;break}if(null===m){u.push({index:h.length,point:o.point});var y=o.getLeftmostComparator(s);l=d.sort(y)[0].otherSE;break}var x=u.splice(m)[0],_=h.splice(x.index);_.unshift(_[0].otherSE),n.push(new t(_.reverse()))}n.push(new t(h))}}return n}}]),n(t,[{key:"getGeom",value:function(){for(var e=this.events[0].point,t=[e],n=1,i=this.events.length-1;n<i;n++){var r=this.events[n].point,a=this.events[n+1].point;0!==w(r,e,a)&&(t.push(r),e=r)}if(1===t.length)return null;var s=t[0],o=t[1];0===w(s,e,o)&&t.shift(),t.push(t[0]);for(var l=this.isExteriorRing()?1:-1,h=this.isExteriorRing()?0:t.length-1,c=this.isExteriorRing()?t.length:-1,u=[],d=h;d!=c;d+=l)u.push([t[d].x,t[d].y]);return u}},{key:"isExteriorRing",value:function(){if(void 0===this._isExteriorRing){var e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var e=this.events[0],t=1,n=this.events.length;t<n;t++){var i=this.events[t];R.compare(e,i)>0&&(e=i)}for(var r=e.segment.prevInResult(),a=r?r.prevInResult():null;;){if(!r)return null;if(!a)return r.ringOut;if(a.ringOut!==r.ringOut)return a.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=a.prevInResult(),a=r?r.prevInResult():null}}}]),t}(),N=function(){function t(n){e(this,t),this.exteriorRing=n,n.poly=this,this.interiorRings=[]}return n(t,[{key:"addInterior",value:function(e){this.interiorRings.push(e),e.poly=this}},{key:"getGeom",value:function(){var e=[this.exteriorRing.getGeom()];if(null===e[0])return null;for(var t=0,n=this.interiorRings.length;t<n;t++){var i=this.interiorRings[t].getGeom();null!==i&&e.push(i)}return e}}]),t}(),F=function(){function t(n){e(this,t),this.rings=n,this.polys=this._composePolys(n)}return n(t,[{key:"getGeom",value:function(){for(var e=[],t=0,n=this.polys.length;t<n;t++){var i=this.polys[t].getGeom();null!==i&&e.push(i)}return e}},{key:"_composePolys",value:function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new N(r));else{var a=r.enclosingRing();a.poly||t.push(new N(a)),a.poly.addInterior(r)}}return t}}]),t}(),k=function(){function t(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L.compare;e(this,t),this.queue=n,this.tree=new h(i),this.segments=[]}return n(t,[{key:"process",value:function(e){var t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),n;var i=e.isLeft?this.tree.insert(t):this.tree.find(t);if(!i)throw new Error("Unable to find segment #".concat(t.id," ")+"[".concat(t.leftSE.point.x,", ").concat(t.leftSE.point.y,"] -> ")+"[".concat(t.rightSE.point.x,", ").concat(t.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var r=i,a=i,s=void 0,o=void 0;void 0===s;)null===(r=this.tree.prev(r))?s=null:void 0===r.key.consumedBy&&(s=r.key);for(;void 0===o;)null===(a=this.tree.next(a))?o=null:void 0===a.key.consumedBy&&(o=a.key);if(e.isLeft){var l=null;if(s){var h=s.getIntersection(t);if(null!==h&&(t.isAnEndpoint(h)||(l=h),!s.isAnEndpoint(h)))for(var c=this._splitSafely(s,h),u=0,d=c.length;u<d;u++)n.push(c[u])}var p=null;if(o){var f=o.getIntersection(t);if(null!==f&&(t.isAnEndpoint(f)||(p=f),!o.isAnEndpoint(f)))for(var m=this._splitSafely(o,f),g=0,v=m.length;g<v;g++)n.push(m[g])}if(null!==l||null!==p){var y;y=null===l?p:null===p||R.comparePoints(l,p)<=0?l:p,this.queue.remove(t.rightSE),n.push(t.rightSE);for(var x=t.split(y),_=0,b=x.length;_<b;_++)n.push(x[_])}n.length>0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=s)}else{if(s&&o){var M=s.getIntersection(o);if(null!==M){if(!s.isAnEndpoint(M))for(var w=this._splitSafely(s,M),S=0,E=w.length;S<E;S++)n.push(w[S]);if(!o.isAnEndpoint(M))for(var T=this._splitSafely(o,M),A=0,C=T.length;A<C;A++)n.push(T[A])}}this.tree.remove(t)}return n}},{key:"_splitSafely",value:function(e,t){this.tree.remove(e);var n=e.rightSE;this.queue.remove(n);var i=e.split(t);return i.push(n),void 0===e.consumedBy&&this.tree.insert(e),i}}]),t}(),B="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,z="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6,V=new(function(){function t(){e(this,t)}return n(t,[{key:"run",value:function(e,t,n){V.type=e,_.reset();for(var i=[new O(t,!0)],r=0,a=n.length;r<a;r++)i.push(new O(n[r],!1));if(V.numMultiPolys=i.length,"difference"===V.type)for(var s=i[0],o=1;o<i.length;)null!==f(i[o].bbox,s.bbox)?o++:i.splice(o,1);if("intersection"===V.type)for(var l=0,c=i.length;l<c;l++)for(var u=i[l],d=l+1,p=i.length;d<p;d++)if(null===f(u.bbox,i[d].bbox))return[];for(var m=new h(R.compare),g=0,v=i.length;g<v;g++)for(var y=i[g].getSweepEvents(),x=0,b=y.length;x<b;x++)if(m.insert(y[x]),m.size>B)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var M=new k(m),w=m.size,S=m.pop();S;){var E=S.key;if(m.size===w){var T=E.segment;throw new Error("Unable to pop() ".concat(E.isLeft?"left":"right"," SweepEvent ")+"[".concat(E.point.x,", ").concat(E.point.y,"] from segment #").concat(T.id," ")+"[".concat(T.leftSE.point.x,", ").concat(T.leftSE.point.y,"] -> ")+"[".concat(T.rightSE.point.x,", ").concat(T.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(m.size>B)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(M.segments.length>z)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var A=M.process(E),C=0,P=A.length;C<P;C++){var L=A[C];void 0===L.consumedBy&&m.insert(L)}w=m.size,S=m.pop()}_.reset();var D=U.factory(M.segments);return new F(D).getGeom()}}]),t}()),H={union:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return V.run("union",e,n)},intersection:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return V.run("intersection",e,n)},xor:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return V.run("xor",e,n)},difference:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return V.run("difference",e,n)}};return H},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n="undefined"!=typeof globalThis?globalThis:n||self).polygonClipping=i()}));!function(){if("undefined"!=typeof document&&!document.getElementById("5ec274ee70024ede89d5541aaf1b42e45324939c247a17641fa6e017fd2fdb3e")){var e=document.createElement("style");e.id="5ec274ee70024ede89d5541aaf1b42e45324939c247a17641fa6e017fd2fdb3e",e.textContent='@import"https://at.alicdn.com/t/c/font_2809422_kipm6ycaet.css";@import"https://at.alicdn.com/t/c/font_2802048_dc945363jlf.css";.axesRenderer{width:100px;height:100px;position:absolute;display:block;bottom:1px;left:10px;background:#ffffff00}.overview-map{width:200px;height:200px;top:10px;left:10px;position:absolute;z-index:1;border:1px #50505090 solid;background-color:#80808030}.statsOutput{position:absolute;opacity:.6;top:1px;left:1px}#navCube{position:absolute;bottom:10px;right:10px;z-index:1;pointer-events:none;cursor:pointer}#navCube:hover{opacity:1}.css3d-navcube .navcube-plane{backface-visibility:hidden;z-index:1;transition:all .2s}.css3d-navcube .navcube-plane.outer{opacity:.7;background:linear-gradient(-45deg,transparent 15px,#efefef 0) bottom right,linear-gradient(-135deg,transparent 15px,#efefef 0) top right,linear-gradient(135deg,transparent 15px,#efefef 0) top left,linear-gradient(45deg,transparent 15px,#efefef 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane.inner{margin:2px;font-size:30px;text-align:center;line-height:100px;background:linear-gradient(-45deg,transparent 14px,#2c7be5 0) bottom right,linear-gradient(-135deg,transparent 14px,#2c7be5 0) top right,linear-gradient(135deg,transparent 14px,#2c7be5 0) top left,linear-gradient(45deg,transparent 14px,#2c7be5 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane:hover{opacity:1!important}.css3d-navcube .navcube-edge{opacity:0;z-index:2;transition:all .2s}.css3d-navcube .navcube-edge:hover{opacity:1!important}.css3d-navcube .navcube-corner{opacity:.7;backface-visibility:hidden;box-sizing:content-box;transform-origin:50% 33%;top:4px;z-index:3;transition:all .2s}.css3d-navcube .navcube-corner-plane{opacity:0;backface-visibility:hidden;transform-origin:bottom;top:-6.5px;z-index:3;transition:all .2s}.css3d-navcube .highlight{opacity:1}#viewCube{width:150px;height:150px;position:absolute;bottom:10px;right:10px;z-index:1}.progress-bar{z-index:3;bottom:20%;left:25%;position:absolute;color:#ffffffa0;width:50%;user-select:none;font-size:14px}.progress-bar.hidden{display:none}.progress-bar .progress-bar-item{width:100%;text-align:center;padding:2px}.pop-panel{z-index:99999999;top:calc(70% - 100px);left:calc(90% - 160px);position:absolute;background:#ffffff;color:#333;border-radius:4px;width:160px;box-shadow:0 12px 48px 16px #00000008,0 9px 28px #0000000d,0 6px 16px -8px #00000014}.pop-panel .pop-panel-header{font-size:16px;font-weight:bolder;padding:16px 24px 8px;color:#333;border-bottom:1px solid #EFEFEF;cursor:move;user-select:none}.pop-panel .pop-panel-body{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:16px 24px}.pop-panel .pop-panel-body .pop-panel-item{display:inline-block;cursor:pointer;margin-right:16px;font-size:16px}.pop-panel .pop-panel-body .pop-panel-item .gemini-viewer-icon{font-size:24px}.pop-panel .pop-panel-body .pop-panel-item:last-child{margin-right:0}.pop-panel .pop-panel-body .pop-panel-item:hover,.pop-panel .pop-panel-body .pop-panel-item.active{color:#2c7be5}.pop-panel .pop-panel-body .pop-panel-item.disable{color:#999;cursor:not-allowed}.model-layout-switch-bar{position:absolute;bottom:0;width:100%;height:24px;background:#ffffff;opacity:.7;display:flex;font-size:14px;line-height:1;overflow-x:scroll;overflow-y:hidden;z-index:1}.model-layout-switch-bar .model-layout-switch-bar-content{white-space:nowrap}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item{position:relative;display:inline-block;padding:3px 10px 0;color:#000;height:22px;cursor:pointer;transform:translate(0)}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:before{content:"";position:absolute;inset:0;z-index:-1;background:#fff;border:1px solid #000;border-top:0px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:hover{color:#8080f0}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:nth-child(n+2){margin-left:-1px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate{color:#fff!important}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate:before{background:#212830!important}.model-layout-switch-bar.hidden{display:none}.model-layout-switch-bar::-webkit-scrollbar{display:none}.follow-tooltip{z-index:99999999;position:absolute;left:-500px;padding:6px;background:rgba(25,25,25,.3);color:#fffc;font-size:12px;border-radius:2px}.context-menu{position:absolute;box-sizing:border-box;background-color:#fff;width:200px;padding:2px;border-radius:2px;box-shadow:0 4px 8px #0003,0 6px 20px #00000030;cursor:pointer;z-index:2}.context-menu ul{list-style:none;padding:0}.context-menu ul:last-child li{border-bottom:0px}.context-menu li{height:2rem;padding:.5rem;box-sizing:border-box}.context-menu li:hover{background-color:#d3d3d3}.context-menu li.disabled{color:#ccc;cursor:not-allowed}.context-menu li:last-child{border-bottom:1px solid #000}.toolbar{position:absolute;display:flex;box-sizing:border-box;height:68px;left:50%;bottom:40px;padding:8px 20px;border:rgba(153,153,153,.8) 1px solid;border-radius:4px;background:rgba(255,255,255,.8);transform:translate(-50%);align-items:center;z-index:10;user-select:none}.toolbar .toolbar-group{display:flex;padding:0 2px;box-sizing:border-box}.toolbar .toolbar-group-division{width:1px;background-color:#999c;height:60%}.toolbar .toolbar-menu{display:flex;box-sizing:border-box;flex-direction:column;word-break:break-word;width:50px;height:50px;padding:3px 1px;margin:0 2px;transition:all .3s;cursor:pointer;color:#666;border-radius:4px}.toolbar .toolbar-menu.active{color:#2c7be5}.toolbar .toolbar-menu .icon{width:24px;height:24px;margin:auto;font-size:24px;line-height:normal}.toolbar .toolbar-menu span{display:block;width:100%;margin:auto;font-size:12px;text-align:center;user-select:none}.toolbar .toolbar-menu-active{color:#2c7be5;background-color:#fffc}.toolbar .toolbar-parent-menu{position:relative}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu{display:block}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu-list{background:rgba(255,255,255,.8)}.toolbar .toolbar-parent-menu:after{content:"";position:absolute;box-sizing:border-box;width:0;height:0;right:2px;top:2px;border-width:4px;border-style:solid;border-top-color:#666;border-right-color:#666;border-bottom-color:transparent;border-left-color:transparent;border-radius:1px}.toolbar .toolbar-sub-menu{display:none;position:absolute;min-width:50px;bottom:100%}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list{margin-bottom:2px;border-radius:4px}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list .toolbar-menu{margin:0}.bottom-bar{position:absolute;bottom:0;right:0;display:flex;color:#666;z-index:3;overflow:hidden;user-select:none}.bottom-bar i{font-size:18px;padding:3px;align-self:center;opacity:.4;cursor:pointer;line-height:1}.bottom-bar i:hover,.bottom-bar i.active{color:#2c7be5;opacity:1}.bottom-bar .fps{width:4rem}.bottom-bar span{align-self:center;padding:4px;font-size:14px}#gemini-viewer-threejs-statistics-tooltip,#gemini-viewer-threejs-tips-tooltip,#gemini-viewer-threejs-cameraInfo-tooltip{position:absolute;right:5px;bottom:30px;background:#666666;color:#fff;padding:8px 8px 5px;font-size:.8rem;border-radius:4px;z-index:3;opacity:.9;user-select:none}#gemini-viewer-threejs-statistics-tooltip p,#gemini-viewer-threejs-tips-tooltip p,#gemini-viewer-threejs-cameraInfo-tooltip p{padding-bottom:3px;margin:3px}#gemini-viewer-threejs-statistics-tooltip p span,#gemini-viewer-threejs-tips-tooltip p span,#gemini-viewer-threejs-cameraInfo-tooltip p span{float:left;margin-right:10px}.gemini-spinner{display:flex;flex-flow:row nowrap;align-items:center;justify-content:space-between;width:2em;position:absolute;pointer-events:none;top:50%;left:50%;transform:translate(-50%,-50%);font-size:14px}.gemini-spinner.hidden{display:none}.gemini-spinner span{width:.3em;height:1em;background-color:#3cefff}.gemini-spinner span:nth-of-type(1){animation:grow 1s -.45s ease-in-out infinite}.gemini-spinner span:nth-of-type(2){animation:grow 1s -.3s ease-in-out infinite}.gemini-spinner span:nth-of-type(3){animation:grow 1s -.15s ease-in-out infinite}.gemini-spinner span:nth-of-type(4){animation:grow 1s ease-in-out infinite}@keyframes grow{0%,to{transform:scaleY(1)}50%{transform:scaleY(2)}}.anchor{position:absolute;top:0;left:0;opacity:0;width:20px;height:20px;transform:translate(-50%,-50%);pointer-events:none;user-select:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAADjRJREFUeF7tXQnQttUYvq4Zxr5MqBgaihRlKakUU7SYSBQljUhaxijtso2MTCrRn8YoldKIUlIIJRplSyKyqzGyJDSDLGHmMtfvvOb19n7fe7Zn+/7nnnnn+/7/O8t9zrne+5xzn3sh1hCS9GUA20UO9xqS20eWHXQxDpr7BOZHAMyfrBEA8+dllAAJX65BFB0lwCgBxjPAHAyMW8C4BQxCghczOW4B4xYwbgHjFjDqAWYxMJ4BxjNA8fY6iAbGM8B4BhjPAGvKGUDSYwA8FcAmAJ4EYOPw8/6R4upvAH4I4Efh580AbiJ5W2T9wRRbEWcASTuFBX/a1KLfq/Iq/HsKDN8NgLiych+tNzdYAEh6JoAXAdgtLHrrkwfAkuEyAJeTvL4LBkr7HBQAJK0fFtwLH/u0WzpHsfWvMRAMCJK3xlbqutwgACDplVMLf++uJ21B//+aAsL5PecVvQaApB0BHA3AP4dIVwE4maR/9pJ6CYBwij8GwOt7OWvpTJ0O4KQ+3iJ6BwBJXnQvvq9yK4l8hTQIDIbeUG8AsALEfeyi9mpb6AUAJL0bwBtjZ3CFlDuR5LFdj6VzAEi6EMCeXU9ER/1fRHKvjvpe3W1nAJC0NoDPAnhGwxNwF4DbZz6/m/q3u183fNaZ+n3yfw9smL8bALyA5B0N9zO3+U4AIMmL/gUAazU0aKtor/CH5M9K+pD0BAC7hI9Vzk3QnQB2JmkwtEqtA0DS7gAuqTxKn7C96F8EcBXJP1Zuf3Vzkh4WdBI7ADAYat9U9iD5ySZ4X6rNVgEg6TAA76s4wKsBnBa+6X6saY0k+bHJkuFQAM+r2PHhJE+t2N6yTbUGAEkHADiz0sBu8sKTPKdSe0XNSHpNAIKfoGvQgSQ/VKOhRW20AoDwcvfNRcxE/P034Rvvxf97RPnWiki6XwCBJcKjKnS8ZRsvjI0DILzg3VI4IX5gsahf1Ud16vTYghr7DQEMpQ9XGzT9stgoACQ9BMD3Cw9LlhyvI3ljIYharS5pMwAfALBlQcc+3G5K8k8FbXR3BpDkE+1LCpj3+/o+JH2XHxxJsg7ho8FwJZf/S0n65tQINSYBJH0QwEEFXJ9F0gfHwZMkH+heWzCQM0geXFB/yaqNAEDS8QDeUsDwsSRPLKjfu6qS/NbhN49cehfJt+ZWXqpedQCEV70SY8ltSX619kD70J6kbQBcV8DLTrWNS5oAgBc/y4KHZHV+Cia7saqSlNm4tZxV1dFVJzwYc7w/c3BPJPnTzLqDqiZpQwA/yWT6kJpGJdUAEO6/Ft05+vFdSX4mc0IGWU3SCwF8OoN5Xw23qaUPqQkAf/NzbPiOJPnejIkYfBVJRwA4JWMgp5M8JKPePapUAUDBwa+x602NyWmjjYLrcpUDYS0A5Bz87Ky5C8l/tDHRs31IesTUdnUbyd93xMd9g+1CalzCKgfCYgAEp42PJE6edftbtaXeDWrZ59ryJiz6owHcZ4bnuwH8CoD3WFsqfall/r4BIPXtYF+SRc4nNQBwMYA9EgFwCsmjEuskFZe0c7A1tAuZXcpyyC5edvmy7Z4tmBojSe8BcGRiB5eQfGlinf8rXgSA8NL340Tk+knX3/5GXK0l+U3ehievLpmYOXXPBXAqSdsiVKdwi7IUSHlKtiTdqOTFsBQAhwNIPcE3ouaVZN9/q0q9+H6bb4Jsg2BrneNJOoZAVcpUFx9BMtvKqhQAKVE3PFn+9mxd25hD0tMB+PHJLuNtkF3BDyb5nZqdBaOSr4dYB7FNF4W1zQZAppXP/rXNuCS9HMDHYmercrm9SX68ZpvBvOzsxDazrYdKAJD64nc1SVvTViNJbwdwXLUG8xo6juQ78qrOryXJ1s0phqbZL4UlALClj2PwxNJuJG3gUYXCKf/zVRorb+RZJC26q5AkB8Bw5JFYupnkprGFp8tlASBD8/dbAOuRrGK6XeFZNWeuFtV5HMlfLCoU8/dgcv5LAI+MKR/KZGkGcwHg+6rvrbF0Acl9YgsvVy5c8+z1k3JdqtH1ojasDfWj1j8XFYz5uySbkr0ipmwocxTJ5HeFXAD4TvyqBOaq2blL8jaya0LfbRY9geSba3SY4UdxHslk3UcuAL4NwFavsbRODefHgifUWD5Ly1lP4GtusbIoOM/aiTWWbiS5eWzhSblkAEiy6PVeF6u3vpbkc1IZm1e+59/+Ccvnktyv0ni/AuDZkW1ZK/hYkta0RlMOAGySlKIXr6L5G8C3f3rSn1/j7SBDM2gP4yR7zBwApKp/Nybp94IiknQBgL2LGmmvctZ+PMuepI1CuNpYzpPVwjkAsJbKzpAxdBfJB8UUXK6MJLfxawDFbZXyElnf9gXrRZZdtpikvwCIDVJxDsn9U/rNAYBdtWJ17j8n6QALRSRpXwDnFTXSfuUqyiFJDnDx+Ej2ryeZ5IrGEEc/sv3VxbYA8IDICteRjD3ELNlkBRezSHarFnsbSavLi0jStQC2jWzkrwC+FVl2dTEDINdGPaafi0m+LKbggi2gSR5L2VuqftEr3aRRSZ8AUGT0sdwAmwZAsfWqpAcDaMw7tqnVB3ALyVjRvZz0y7W2jhpa0wAoFoOSbL/XiPVQ1AzlF7qbpA0+i0iSjVzeWdTIMpWbBsABJM8qYV6SM378oKSNDuuuXWptLMlexY2Fi2kaAMUeP5K2BvC1DhexpOvNSy2Lm1aAjQAoWd7Fddd4AIxbQKHDydC3gPEQuFhKLFti6IfA8RpYDoBBXwNHRVA5ABpXBNm2P4X8DhCbgLGWKjjVPCplPE2VPZpkitncXD4SVcF2VklKX5fzGGRdc2yI91qPQQ4112oQ5QqoKL4BmIfEx6AbSPqtJppyAGBPYKdxi6Faz8F+DrXnrgNPDoFuJblBDUYTn4PPJ+mX02jKAYDTnJwQ3QOwYWnM/vBNSAFeAnuNFE1+l5/HRchVkBI36U0kk0LR5QAgNbbNYSRXlU5z0xqxUv5m6tcyCXPM4ZTQ8cma1xwAOAiU/eZjkzNfSdK++sW0BhqF2vYyNiycnW7WT3W7TwZAEMc2e35Kwoo+vEYWjwFIgZpm4c5O8oeEOf4eyeR8BbkASL2WVfOi7bkUqOkYkur1nOV9lQsA5/M9KQGdZ5MsCZb8v64kbQXgcwAemtB/G0V9/96+VuAISX5GTzHwPIbkyakDzQVAqm+ADTq8P9VyDrXPnKVQn2izWgEjgnOoz1kpQTeTfQI8eVkACOeArt3DHSjRWUT6QNW2uDC3/XYPD0yOASL+C701NkCE3wRSE0E1ESLGV8yuAkVUue9Pi7DBhIgJUqAvQaIch/+iFmMG2AFzz9p5DQYVJCoAINVP0NWqOIvObvwhcIStZ5uOHeAI3zZ0KXYBnzOGnKwiyf6A0/1mHwIDAByBs2+BIq2qPrABIHjhz2wqrP0gA0UGEPQ1VKyB4Ouif+Y6ldox03kMrGRpNJ/BIEPFBgD4abi3waKDZ7HtCV6ckMLuUgCfAuCUbQZBoxSCWQ8zWHQAQU64eN8gdmg7J2BwNbO7mT8T+wK7nv3ZH5L+2RqF3IKOC5jk1RuypMc+FC05nqIzwKTVjLBxk6qXk9yttdnuYUeSHA/Qip9UygoLN9tJFQAEKZBrvbpiEkSmrmBBQslia+sJrzUBYL11btKoRq6GqQvSZvmM+D8T9vqZNCpIASeNyk0bt2ITRs6575ckkOxn2rip80DOgXB19TFx5EIZVCVP0HQv1baACgfCSRMrNoFkYcJIz0+Vg1+jAAhbgS1TrdbMpWTjxtyO2qpXwZztRJK2yK5K1SXAlCS4MCRtymV4xSSULEgQOZk7J63aK3cil6vXGACCJEjxIprH5xnOAdRVbsHSCZfkEDE26z6ooK1kb5+UvpoGwNoh0uVaKUzNlPWTs0Oh31jQRutVg3rXvoGpCSGneb0TgCOt3tHUABoFQJAC9iNMil03Z7AOhGzzr1Wpdu9NTdxS7YZXPTt0HJoQUHup5rYgeUOTY2gcAAEEuwO4pMJAbIhhIJxWO/NYKW/BmMOL7k+NZBZ7kGzcIbYVAAQQOJ9fdn67mQWyMYZBcE7pwtWoH8y4vPDJjhlL9H84yRSXsOxhtAaAAIIDbFSRze09K14dJMIVtUzOY3kLptu7hG98SoavRV1Uy66yqCP/vVUABBDkGJMuGouTUvmw6Dy/lzV1aApZPPx66XzEPtylJHVaNAb/PTv/X0zj88q0DoAAApuSebFSHB9SxugAy84AbjAU5SoIMfu96M48Xhz4eolB+IFnu5IcwCmTM122EwAEENgY48MJVjq5Y7wLwO0zH+fimfyf2103fNaZ+n3yf7Gx+nP5s/XRfiQ7iYfcGQAmsyXJOX9LFCW5E9+HemeQPLhLRjoHQJAGqV5GXc5Zrb6z073WYqCTQ+BSzAezMnsd71hzgD1s6yoAJ5P0z86pFxJgehYk2ajkmAYPiF1Nug96J5E8vSsGenMLWDQBQZ1qEBgMK4G86F783uU96J0EmJEG3g6GvC30StwPRgLMMirJzie+i9t8OjZjaVeSww9Xzm9sHcT5XTER22+vJcAcIFiBNAGCtXF9Iiu2Jgvv6B6DoEEBYGZ7sErZEsGA2KSj2b7Z33QvPMmkGL0d8XuPbgcLgDlnBYet23TqU3ursGh3WJzJx2HZenGVKwHTigDAnK3C7/GWCk8OPye/xya8dAJGJ6ryN9yf1b+nZuYuWZi26q5IAMybvJAhNfbcUCXpY1uLWNLPCID5szcCoARVfaw7SoD5qzJKgFEC9PH7Wp+nUQKMEiAlpN14Bqj/Hey2xVECjBJglABzMDAeAsdDYLeiua3exy1g3ALGLWDcAlY7dMTQGnML+A8qtnUcTFYqYAAAAABJRU5ErkJggg==) no-repeat center center;background-size:100% 100%;background-blend-mode:lighten;filter:invert(61%) sepia(87%) saturate(845%) hue-rotate(120deg) brightness(94%) contrast(101%);transition:opacity .5s ease-in-out}.anchor.active{opacity:1}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}\n',document.head.appendChild(e)}}();var zxe=fetch;window.fetch=(...e)=>Promise.resolve(zxe(...e));var TXt=wi(oV(),1),wXt=wi(Dse(),1),MXt=wi(Lse(),1),pt={};l_(pt,{ACESFilmicToneMapping:()=>Soe,AddEquation:()=>Us,AddOperation:()=>_oe,AdditiveAnimationBlendMode:()=>CB,AdditiveBlending:()=>Ou,AlphaFormat:()=>Loe,AlwaysDepth:()=>moe,AlwaysStencilFunc:()=>joe,AmbientLight:()=>Lo,AmbientLightProbe:()=>VU,AnimationAction:()=>hS,AnimationClip:()=>pa,AnimationLoader:()=>LU,AnimationMixer:()=>YU,AnimationObjectGroup:()=>XU,AnimationUtils:()=>Vtt,ArcCurve:()=>tp,ArrayCamera:()=>GM,ArrowHelper:()=>Rl,Audio:()=>cS,AudioAnalyser:()=>WU,AudioContext:()=>iy,AudioListener:()=>GU,AudioLoader:()=>HU,AxesHelper:()=>oB,BackSide:()=>ri,BasicDepthPacking:()=>qoe,BasicShadowMap:()=>I$e,Bone:()=>Ao,BooleanKeyframeTrack:()=>Xu,Box2:()=>si,Box3:()=>lt,Box3Helper:()=>sB,BoxBufferGeometry:()=>lB,BoxGeometry:()=>Qi,BoxHelper:()=>cy,BufferAttribute:()=>Ct,BufferGeometry:()=>et,BufferGeometryLoader:()=>lS,ByteType:()=>Aoe,Cache:()=>pp,Camera:()=>Fu,CameraHelper:()=>ly,CanvasTexture:()=>AU,CapsuleBufferGeometry:()=>cB,CapsuleGeometry:()=>rp,CatmullRomCurve3:()=>XM,CineonToneMapping:()=>Moe,CircleBufferGeometry:()=>uB,CircleGeometry:()=>ip,ClampToEdgeWrapping:()=>Or,Clock:()=>Oo,Color:()=>Ie,ColorKeyframeTrack:()=>ey,ColorManagement:()=>Mo,CompressedArrayTexture:()=>RU,CompressedTexture:()=>jx,CompressedTextureLoader:()=>OU,ConeBufferGeometry:()=>hB,ConeGeometry:()=>sp,CubeCamera:()=>VM,CubeReflectionMapping:()=>Jh,CubeRefractionMapping:()=>Qh,CubeTexture:()=>ep,CubeTextureLoader:()=>ty,CubeUVReflectionMapping:()=>tv,CubicBezierCurve:()=>Xx,CubicBezierCurve3:()=>YM,CubicInterpolant:()=>nS,CullFaceBack:()=>IN,CullFaceFront:()=>aoe,CullFaceFrontBack:()=>P$e,CullFaceNone:()=>soe,Curve:()=>Vs,CurvePath:()=>ZM,CustomBlending:()=>$u,CustomToneMapping:()=>Roe,CylinderBufferGeometry:()=>dB,CylinderGeometry:()=>Po,Cylindrical:()=>QU,Data3DTexture:()=>zx,DataArrayTexture:()=>Gg,DataTexture:()=>Ro,DataTextureLoader:()=>gp,DataUtils:()=>iv,DecrementStencilOp:()=>k$e,DecrementWrapStencilOp:()=>z$e,DefaultLoadingManager:()=>ma,DepthFormat:()=>Kh,DepthStencilFormat:()=>Uu,DepthTexture:()=>td,DirectionalLight:()=>ji,DirectionalLightHelper:()=>oy,DiscreteInterpolant:()=>rS,DisplayP3ColorSpace:()=>DB,DodecahedronBufferGeometry:()=>fB,DodecahedronGeometry:()=>ap,DoubleSide:()=>tr,DstAlphaFactor:()=>Qg,DstColorFactor:()=>ev,DynamicCopyUsage:()=>rZe,DynamicDrawUsage:()=>K$e,DynamicReadUsage:()=>eZe,EdgesGeometry:()=>ja,EllipseCurve:()=>Gu,EqualDepth:()=>voe,EqualStencilFunc:()=>j$e,EquirectangularReflectionMapping:()=>Jf,EquirectangularRefractionMapping:()=>Bx,Euler:()=>rn,EventDispatcher:()=>qa,ExtrudeBufferGeometry:()=>pB,ExtrudeGeometry:()=>qu,FileLoader:()=>rr,Float16BufferAttribute:()=>mU,Float32BufferAttribute:()=>tt,Float64BufferAttribute:()=>gU,FloatType:()=>Bs,Fog:()=>xc,FogExp2:()=>jg,FramebufferTexture:()=>SU,FrontSide:()=>Tr,Frustum:()=>ps,GLBufferAttribute:()=>KU,GLSL1:()=>sZe,GLSL3:()=>sU,GreaterDepth:()=>yoe,GreaterEqualDepth:()=>xoe,GreaterEqualStencilFunc:()=>Z$e,GreaterStencilFunc:()=>Y$e,GridHelper:()=>ay,Group:()=>Nt,HalfFloatType:()=>Ga,HemisphereLight:()=>ad,HemisphereLightHelper:()=>rB,HemisphereLightProbe:()=>kU,IcosahedronBufferGeometry:()=>mB,IcosahedronGeometry:()=>lp,ImageBitmapLoader:()=>ry,ImageLoader:()=>mp,ImageUtils:()=>Vx,IncrementStencilOp:()=>H$e,IncrementWrapStencilOp:()=>V$e,InstancedBufferAttribute:()=>zu,InstancedBufferGeometry:()=>oS,InstancedInterleavedBuffer:()=>ZU,InstancedMesh:()=>Ar,Int16BufferAttribute:()=>fU,Int32BufferAttribute:()=>pU,Int8BufferAttribute:()=>uU,IntType:()=>Poe,InterleavedBuffer:()=>Vu,InterleavedBufferAttribute:()=>ha,Interpolant:()=>ju,InterpolateDiscrete:()=>Bu,InterpolateLinear:()=>vc,InterpolateSmooth:()=>BM,InvertStencilOp:()=>G$e,KeepStencilOp:()=>FM,KeyframeTrack:()=>Xa,LOD:()=>jM,LatheBufferGeometry:()=>gB,LatheGeometry:()=>nd,Layers:()=>qg,LessDepth:()=>goe,LessEqualDepth:()=>HM,LessEqualStencilFunc:()=>X$e,LessStencilFunc:()=>W$e,Light:()=>Do,LightProbe:()=>$g,Line:()=>sn,Line3:()=>qs,LineBasicMaterial:()=>Jt,LineCurve:()=>Yg,LineCurve3:()=>$M,LineDashedMaterial:()=>fp,LineLoop:()=>Xg,LineSegments:()=>Dn,LinearEncoding:()=>IB,LinearFilter:()=>Vn,LinearInterpolant:()=>Qx,LinearMipMapLinearFilter:()=>U$e,LinearMipMapNearestFilter:()=>N$e,LinearMipmapLinearFilter:()=>Hs,LinearMipmapNearestFilter:()=>vp,LinearSRGBColorSpace:()=>ks,LinearToneMapping:()=>Toe,Loader:()=>nr,LoaderUtils:()=>ts,LoadingManager:()=>Tc,LoopOnce:()=>Voe,LoopPingPong:()=>Goe,LoopRepeat:()=>zoe,LuminanceAlphaFormat:()=>Ooe,LuminanceFormat:()=>mS,MOUSE:()=>fS,Material:()=>Rn,MaterialLoader:()=>Zg,MathUtils:()=>Yt,Matrix3:()=>Wt,Matrix4:()=>Ae,MaxEquation:()=>NN,Mesh:()=>Ge,MeshBasicMaterial:()=>Pt,MeshDepthMaterial:()=>ku,MeshDistanceMaterial:()=>qx,MeshLambertMaterial:()=>_c,MeshMatcapMaterial:()=>tS,MeshNormalMaterial:()=>sd,MeshPhongMaterial:()=>es,MeshPhysicalMaterial:()=>Io,MeshStandardMaterial:()=>id,MeshToonMaterial:()=>eS,MinEquation:()=>ON,MirroredRepeatWrapping:()=>Nu,MixOperation:()=>boe,MultiplyBlending:()=>LN,MultiplyOperation:()=>dy,NearestFilter:()=>cr,NearestMipMapLinearFilter:()=>O$e,NearestMipMapNearestFilter:()=>L$e,NearestMipmapLinearFilter:()=>Du,NearestMipmapNearestFilter:()=>ed,NeverDepth:()=>poe,NeverStencilFunc:()=>q$e,NoBlending:()=>yr,NoColorSpace:()=>mc,NoToneMapping:()=>fc,NormalAnimationBlendMode:()=>vS,NormalBlending:()=>Zf,NotEqualDepth:()=>Eoe,NotEqualStencilFunc:()=>$$e,NumberKeyframeTrack:()=>Ml,Object3D:()=>Tt,ObjectLoader:()=>FU,ObjectSpaceNormalMap:()=>Woe,OctahedronBufferGeometry:()=>vB,OctahedronGeometry:()=>rd,OneFactor:()=>Jg,OneMinusDstAlphaFactor:()=>hoe,OneMinusDstColorFactor:()=>doe,OneMinusSrcAlphaFactor:()=>AB,OneMinusSrcColorFactor:()=>uoe,OrthographicCamera:()=>dr,PCFShadowMap:()=>RB,PCFSoftShadowMap:()=>Kg,PMREMGenerator:()=>Hu,Path:()=>Ec,PerspectiveCamera:()=>bn,Plane:()=>er,PlaneBufferGeometry:()=>xB,PlaneGeometry:()=>Ur,PlaneHelper:()=>aB,PointLight:()=>Sl,PointLightHelper:()=>nB,Points:()=>or,PointsMaterial:()=>Br,PolarGridHelper:()=>iB,PolyhedronBufferGeometry:()=>yB,PolyhedronGeometry:()=>wl,PositionalAudio:()=>qU,PropertyBinding:()=>ln,PropertyMixer:()=>uS,QuadraticBezierCurve:()=>Yx,QuadraticBezierCurve3:()=>$x,Quaternion:()=>En,QuaternionKeyframeTrack:()=>zs,QuaternionLinearInterpolant:()=>iS,RED_GREEN_RGTC2_Format:()=>rU,RED_RGTC1_Format:()=>koe,REVISION:()=>dS,RGBADepthPacking:()=>rv,RGBAFormat:()=>Ji,RGBAIntegerFormat:()=>Foe,RGBA_ASTC_10x10_Format:()=>QN,RGBA_ASTC_10x5_Format:()=>ZN,RGBA_ASTC_10x6_Format:()=>KN,RGBA_ASTC_10x8_Format:()=>JN,RGBA_ASTC_12x10_Format:()=>eU,RGBA_ASTC_12x12_Format:()=>tU,RGBA_ASTC_4x4_Format:()=>zN,RGBA_ASTC_5x4_Format:()=>GN,RGBA_ASTC_5x5_Format:()=>qN,RGBA_ASTC_6x5_Format:()=>WN,RGBA_ASTC_6x6_Format:()=>jN,RGBA_ASTC_8x5_Format:()=>XN,RGBA_ASTC_8x6_Format:()=>YN,RGBA_ASTC_8x8_Format:()=>$N,RGBA_BPTC_Format:()=>UM,RGBA_ETC2_EAC_Format:()=>VN,RGBA_PVRTC_2BPPV1_Format:()=>HN,RGBA_PVRTC_4BPPV1_Format:()=>FN,RGBA_S3TC_DXT1_Format:()=>LM,RGBA_S3TC_DXT3_Format:()=>OM,RGBA_S3TC_DXT5_Format:()=>NM,RGB_ETC1_Format:()=>Hoe,RGB_ETC2_Format:()=>kN,RGB_PVRTC_2BPPV1_Format:()=>BN,RGB_PVRTC_4BPPV1_Format:()=>UN,RGB_S3TC_DXT1_Format:()=>DM,RGFormat:()=>Uoe,RGIntegerFormat:()=>Boe,RawShaderMaterial:()=>QM,Ray:()=>Wa,Raycaster:()=>Gs,RectAreaLight:()=>sS,RedFormat:()=>gS,RedIntegerFormat:()=>Noe,ReinhardToneMapping:()=>woe,RepeatWrapping:()=>Nr,ReplaceStencilOp:()=>F$e,ReverseSubtractEquation:()=>loe,RingBufferGeometry:()=>EB,RingGeometry:()=>cp,SIGNED_RED_GREEN_RGTC2_Format:()=>iU,SIGNED_RED_RGTC1_Format:()=>nU,SRGBColorSpace:()=>St,Scene:()=>ii,ShaderChunk:()=>Pn,ShaderLib:()=>_l,ShaderMaterial:()=>It,ShadowMaterial:()=>JM,Shape:()=>Fs,ShapeBufferGeometry:()=>bB,ShapeGeometry:()=>bc,ShapePath:()=>uy,ShapeUtils:()=>Wi,ShortType:()=>Coe,Skeleton:()=>Co,SkeletonHelper:()=>tB,SkinnedMesh:()=>yc,Source:()=>Tl,Sphere:()=>hr,SphereBufferGeometry:()=>_B,SphereGeometry:()=>da,Spherical:()=>od,SphericalHarmonics3:()=>aS,SplineCurve:()=>np,SpotLight:()=>wc,SpotLightHelper:()=>eB,Sprite:()=>WM,SpriteMaterial:()=>Wx,SrcAlphaFactor:()=>hy,SrcAlphaSaturateFactor:()=>foe,SrcColorFactor:()=>coe,StaticCopyUsage:()=>nZe,StaticDrawUsage:()=>Hx,StaticReadUsage:()=>Q$e,StereoCamera:()=>zU,StreamCopyUsage:()=>iZe,StreamDrawUsage:()=>J$e,StreamReadUsage:()=>tZe,StringKeyframeTrack:()=>Yu,SubtractEquation:()=>ooe,SubtractiveBlending:()=>DN,TOUCH:()=>C$e,TangentSpaceNormalMap:()=>cd,TetrahedronBufferGeometry:()=>TB,TetrahedronGeometry:()=>up,Texture:()=>ur,TextureLoader:()=>Ai,TorusBufferGeometry:()=>wB,TorusGeometry:()=>Wu,TorusKnotBufferGeometry:()=>MB,TorusKnotGeometry:()=>hp,Triangle:()=>Rr,TriangleFanDrawMode:()=>nv,TriangleStripDrawMode:()=>py,TrianglesDrawMode:()=>PB,TubeBufferGeometry:()=>SB,TubeGeometry:()=>dp,TwoPassDoubleSide:()=>D$e,UVMapping:()=>pS,Uint16BufferAttribute:()=>Qf,Uint32BufferAttribute:()=>Gx,Uint8BufferAttribute:()=>hU,Uint8ClampedBufferAttribute:()=>dU,Uniform:()=>sy,UniformsGroup:()=>$U,UniformsLib:()=>gt,UniformsUtils:()=>Lr,UnsignedByteType:()=>gc,UnsignedInt248Type:()=>Lu,UnsignedIntType:()=>Zh,UnsignedShort4444Type:()=>Ioe,UnsignedShort5551Type:()=>Doe,UnsignedShortType:()=>fy,VSMShadowMap:()=>dc,Vector2:()=>Q,Vector3:()=>M,Vector4:()=>Mn,VectorKeyframeTrack:()=>fa,VideoTexture:()=>MU,WebGL1Renderer:()=>qM,WebGL3DRenderTarget:()=>lU,WebGLArrayRenderTarget:()=>oU,WebGLCubeRenderTarget:()=>zM,WebGLMultipleRenderTargets:()=>cU,WebGLRenderTarget:()=>Sn,WebGLRenderer:()=>ms,WebGLUtils:()=>rle,WireframeGeometry:()=>KM,WrapAroundEnding:()=>Fx,ZeroCurvatureEnding:()=>Xf,ZeroFactor:()=>ld,ZeroSlopeEnding:()=>Yf,ZeroStencilOp:()=>B$e,_SRGBAFormat:()=>kM,sRGBEncoding:()=>pc});var dS="152",fS={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},C$e={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},soe=0,IN=1,aoe=2,P$e=3,I$e=0,RB=1,Kg=2,dc=3,Tr=0,ri=1,tr=2,D$e=2,yr=0,Zf=1,Ou=2,DN=3,LN=4,$u=5,Us=100,ooe=101,loe=102,ON=103,NN=104,ld=200,Jg=201,coe=202,uoe=203,hy=204,AB=205,Qg=206,hoe=207,ev=208,doe=209,foe=210,poe=0,moe=1,goe=2,HM=3,voe=4,xoe=5,yoe=6,Eoe=7,dy=0,boe=1,_oe=2,fc=0,Toe=1,woe=2,Moe=3,Soe=4,Roe=5,pS=300,Jh=301,Qh=302,Jf=303,Bx=304,tv=306,Nr=1e3,Or=1001,Nu=1002,cr=1003,ed=1004,L$e=1004,Du=1005,O$e=1005,Vn=1006,vp=1007,N$e=1007,Hs=1008,U$e=1008,gc=1009,Aoe=1010,Coe=1011,fy=1012,Poe=1013,Zh=1014,Bs=1015,Ga=1016,Ioe=1017,Doe=1018,Lu=1020,Loe=1021,Ji=1023,mS=1024,Ooe=1025,Kh=1026,Uu=1027,gS=1028,Noe=1029,Uoe=1030,Boe=1031,Foe=1033,DM=33776,LM=33777,OM=33778,NM=33779,UN=35840,BN=35841,FN=35842,HN=35843,Hoe=36196,kN=37492,VN=37496,zN=37808,GN=37809,qN=37810,WN=37811,jN=37812,XN=37813,YN=37814,$N=37815,ZN=37816,KN=37817,JN=37818,QN=37819,eU=37820,tU=37821,UM=36492,koe=36283,nU=36284,rU=36285,iU=36286,Voe=2200,zoe=2201,Goe=2202,Bu=2300,vc=2301,BM=2302,Xf=2400,Yf=2401,Fx=2402,vS=2500,CB=2501,PB=0,py=1,nv=2,IB=3e3,pc=3001,qoe=3200,rv=3201,cd=0,Woe=1,mc="",St="srgb",ks="srgb-linear",DB="display-p3",B$e=0,FM=7680,F$e=7681,H$e=7682,k$e=7683,V$e=34055,z$e=34056,G$e=5386,q$e=512,W$e=513,j$e=514,X$e=515,Y$e=516,$$e=517,Z$e=518,joe=519,Hx=35044,K$e=35048,J$e=35040,Q$e=35045,eZe=35049,tZe=35041,nZe=35046,rZe=35050,iZe=35042,sZe="100",sU="300 es",kM=1035,qa=class{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e);e.target=null}}},ds=["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"],Ose=1234567,Kf=Math.PI/180,zg=180/Math.PI;function za(){let e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(ds[255&e]+ds[e>>8&255]+ds[e>>16&255]+ds[e>>24&255]+"-"+ds[255&t]+ds[t>>8&255]+"-"+ds[t>>16&15|64]+ds[t>>24&255]+"-"+ds[63&n|128]+ds[n>>8&255]+"-"+ds[n>>16&255]+ds[n>>24&255]+ds[255&i]+ds[i>>8&255]+ds[i>>16&255]+ds[i>>24&255]).toLowerCase()}function pi(e,t,n){return Math.max(t,Math.min(n,e))}function LB(e,t){return(e%t+t)%t}function aZe(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function oZe(e,t,n){return e!==t?(n-e)/(t-e):0}function Dx(e,t,n){return(1-n)*e+n*t}function lZe(e,t,n,i){return Dx(e,t,1-Math.exp(-n*i))}function cZe(e,t=1){return t-Math.abs(LB(e,2*t)-t)}function uZe(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)}function hZe(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function dZe(e,t){return e+Math.floor(Math.random()*(t-e+1))}function fZe(e,t){return e+Math.random()*(t-e)}function pZe(e){return e*(.5-Math.random())}function mZe(e){void 0!==e&&(Ose=e);let t=Ose+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function gZe(e){return e*Kf}function vZe(e){return e*zg}function aU(e){return 0==(e&e-1)&&0!==e}function Xoe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Yoe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function xZe(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),h=a((t+i)/2),c=s((t+i)/2),u=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Va(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function In(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var Yt={DEG2RAD:Kf,RAD2DEG:zg,generateUUID:za,clamp:pi,euclideanModulo:LB,mapLinear:aZe,inverseLerp:oZe,lerp:Dx,damp:lZe,pingpong:cZe,smoothstep:uZe,smootherstep:hZe,randInt:dZe,randFloat:fZe,randFloatSpread:pZe,seededRandom:mZe,degToRad:gZe,radToDeg:vZe,isPowerOfTwo:aU,ceilPowerOfTwo:Xoe,floorPowerOfTwo:Yoe,setQuaternionFromProperEuler:xZe,normalize:In,denormalize:Va},Q=class{constructor(e=0,t=0){Q.prototype.isVector2=!0,this.x=e,this.y=t}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 new 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 new 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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){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(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(pi(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),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Wt=class{constructor(){Wt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,r,a,s,o,l){let h=this.elements;return h[0]=e,h[1]=i,h[2]=s,h[3]=t,h[4]=r,h[5]=o,h[6]=n,h[7]=a,h[8]=l,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,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],h=n[4],c=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],_=i[2],b=i[5],M=i[8];return r[0]=a*f+s*v+o*_,r[3]=a*m+s*y+o*b,r[6]=a*g+s*x+o*M,r[1]=l*f+h*v+c*_,r[4]=l*m+h*y+c*b,r[7]=l*g+h*x+c*M,r[2]=u*f+d*v+p*_,r[5]=u*m+d*y+p*b,r[8]=u*g+d*x+p*M,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],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*s*l-n*r*h+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*r,d=l*r-a*o,p=t*c+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-h*n)*f,e[2]=(s*n-i*a)*f,e[3]=u*f,e[4]=(h*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,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,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(tN.makeScale(e,t)),this}rotate(e){return this.premultiply(tN.makeRotation(-e)),this}translate(e,t){return this.premultiply(tN.makeTranslation(e,t)),this}makeTranslation(e,t){return 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 i=0;i<9;i++)if(t[i]!==n[i])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)}},tN=new Wt;function $oe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var yZe={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Bg(e,t){return new yZe[e](t)}function kx(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var Nse={};function Lx(e){e in Nse||(Nse[e]=!0,console.warn(e))}function kg(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function nN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var EZe=(new Wt).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),bZe=(new Wt).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function _Ze(e){return e.convertSRGBToLinear().applyMatrix3(bZe)}function TZe(e){return e.applyMatrix3(EZe).convertLinearToSRGB()}var mg,wZe={[ks]:e=>e,[St]:e=>e.convertSRGBToLinear(),[DB]:_Ze},MZe={[ks]:e=>e,[St]:e=>e.convertLinearToSRGB(),[DB]:TZe},Mo={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return ks},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;let i=wZe[t],r=MZe[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},Vx=class{static getDataURL(e){if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===mg&&(mg=kx("canvas")),mg.width=e.width,mg.height=e.height;let n=mg.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=mg}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=kx("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*kg(r[e]/255);return n.putImageData(i,0,0),t}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(255*kg(t[e]/255)):t[e]=kg(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Tl=class{constructor(e=null){this.isSource=!0,this.uuid=za(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(rN(i[t].image)):e.push(rN(i[t]))}else e=rN(i);n.url=e}return t||(e.images[this.uuid]=n),n}};function rN(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Vx.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var SZe=0,ur=class extends qa{constructor(e=ur.DEFAULT_IMAGE,t=ur.DEFAULT_MAPPING,n=Or,i=Or,r=Vn,a=Hs,s=Ji,o=gc,l=ur.DEFAULT_ANISOTROPY,h=mc){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:SZe++}),this.uuid=za(),this.name="",this.source=new Tl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new Q(0,0),this.repeat=new Q(1,1),this.center=new Q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Wt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(Lx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===pc?St:mc),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let n={metadata:{version:4.5,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!==pS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Nr:e.x=e.x-Math.floor(e.x);break;case Or:e.x=e.x<0?0:1;break;case Nu:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Nr:e.y=e.y-Math.floor(e.y);break;case Or:e.y=e.y<0?0:1;break;case Nu:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Lx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===St?pc:IB}set encoding(e){Lx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===pc?St:mc}};ur.DEFAULT_IMAGE=null,ur.DEFAULT_MAPPING=pS,ur.DEFAULT_ANISOTROPY=1;var Mn=class{constructor(e=0,t=0,n=0,i=1){Mn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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 new 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 new 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=void 0!==e.w?e.w:1,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,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(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,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(s+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+h)/4,v=(l+d)/4,y=(u+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=g/n,r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=g/i,r=y/i):m<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(m),n=v/r,i=y/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-o)*(h-o));return Math.abs(m)<.001&&(m=1),this.x=(p-u)/m,this.y=(l-d)/m,this.z=(h-o)/m,this.w=Math.acos((s+c+f-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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}},Sn=class extends qa{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Mn(0,0,e,t),this.scissorTest=!1,this.viewport=new Mn(0,0,e,t);let i={width:e,height:t,depth:1};void 0!==n.encoding&&(Lx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===pc?St:mc),this.texture=new ur(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Vn,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Tl(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Gg=class extends ur{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=cr,this.minFilter=cr,this.wrapR=Or,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},oU=class extends Sn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Gg(null,e,t,n),this.texture.isRenderTargetTexture=!0}},zx=class extends ur{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=cr,this.minFilter=cr,this.wrapR=Or,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},lU=class extends Sn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new zx(null,e,t,n),this.texture.isRenderTargetTexture=!0}},cU=class extends Sn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;let r=this.texture;this.texture=[];for(let a=0;a<n;a++)this.texture[a]=r.clone(),this.texture[a].isRenderTargetTexture=!0}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 i=0,r=this.texture.length;i<r;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),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.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}},En=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,s){let o=n[i+0],l=n[i+1],h=n[i+2],c=n[i+3],u=r[a+0],d=r[a+1],p=r[a+2],f=r[a+3];if(0===s)return e[t+0]=o,e[t+1]=l,e[t+2]=h,void(e[t+3]=c);if(1===s)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=f);if(c!==f||o!==u||l!==d||h!==p){let e=1-s,t=o*u+l*d+h*p+c*f,n=t>=0?1:-1,i=1-t*t;if(i>Number.EPSILON){let r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}let r=s*n;if(o=o*e+u*r,l=l*e+d*r,h=h*e+p*r,c=c*e+f*r,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=e,l*=e,h*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],h=n[i+3],c=r[a],u=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+h*c+o*d-l*u,e[t+1]=o*p+h*u+l*c-s*d,e[t+2]=l*p+h*d+s*u-o*c,e[t+3]=h*p-s*c-o*u-l*d,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,i){return this._x=e,this._y=t,this._z=n,this._w=i,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){let n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),h=s(i/2),c=s(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],h=t[6],c=t[10],u=n+s+c;if(u>0){let e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(h-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(h-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(pi(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,h=t._w;return this._x=n*h+a*s+i*l-r*o,this._y=i*h+a*o+r*s-n*l,this._z=r*h+a*l+n*o-i*s,this._w=a*h-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);let n=this._x,i=this._y,r=this._z,a=this._w,s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;let o=1-s*s;if(o<=Number.EPSILON){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,s),c=Math.sin((1-t)*h)/l,u=Math.sin(t*h)/l;return this._w=a*c+this._w*u,this._x=n*c+this._x*u,this._y=i*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}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}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}},M=class{constructor(e=0,t=0,n=0){M.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(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 new 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 new 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(Use.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Use.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=o*t+a*i-s*n,h=o*n+s*t-r*i,c=o*i+r*n-a*t,u=-r*t-a*n-s*i;return this.x=l*o+u*-r+h*-s-c*-a,this.y=h*o+u*-a+c*-r-l*-s,this.z=c*o+u*-s+l*-a-h*-r,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,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){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,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return iN.copy(this).projectOnVector(e),this.sub(iN)}reflect(e){return this.sub(iN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(pi(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-Kl(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},iN=new M,Use=new En,lt=class{constructor(e=new M(1/0,1/0,1/0),t=new M(-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(Mu.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Mu.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=Mu.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){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),gg.copy(e.boundingBox),gg.applyMatrix4(e.matrixWorld),this.union(gg);else{let n=e.geometry;if(void 0!==n)if(t&&void 0!==n.attributes&&void 0!==n.attributes.position){let t=n.attributes.position;for(let n=0,i=t.count;n<i;n++)Mu.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(Mu)}else null===n.boundingBox&&n.computeBoundingBox(),gg.copy(n.boundingBox),gg.applyMatrix4(e.matrixWorld),this.union(gg)}let n=e.children;for(let i=0,r=n.length;i<r;i++)this.expandByObject(n[i],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,Mu),Mu.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(Ex),Ww.subVectors(this.max,Ex),vg.subVectors(e.a,Ex),xg.subVectors(e.b,Ex),yg.subVectors(e.c,Ex),Wh.subVectors(xg,vg),jh.subVectors(yg,xg),Bf.subVectors(vg,yg);let t=[0,-Wh.z,Wh.y,0,-jh.z,jh.y,0,-Bf.z,Bf.y,Wh.z,0,-Wh.x,jh.z,0,-jh.x,Bf.z,0,-Bf.x,-Wh.y,Wh.x,0,-jh.y,jh.x,0,-Bf.y,Bf.x,0];return!(!sN(t,vg,xg,yg,Ww)||(t=[1,0,0,0,1,0,0,0,1],!sN(t,vg,xg,yg,Ww)))&&(jw.crossVectors(Wh,jh),t=[jw.x,jw.y,jw.z],sN(t,vg,xg,yg,Ww))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mu).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Mu).length()),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()||(wu[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wu[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wu[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wu[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wu[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wu[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wu[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wu[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wu)),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)}},wu=[new M,new M,new M,new M,new M,new M,new M,new M],Mu=new M,gg=new lt,vg=new M,xg=new M,yg=new M,Wh=new M,jh=new M,Bf=new M,Ex=new M,Ww=new M,jw=new M,Ff=new M;function sN(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){Ff.fromArray(e,a);let s=r.x*Math.abs(Ff.x)+r.y*Math.abs(Ff.y)+r.z*Math.abs(Ff.z),o=t.dot(Ff),l=n.dot(Ff),h=i.dot(Ff);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var RZe=new lt,bx=new M,aN=new M,hr=class{constructor(e=new M,t=-1){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;void 0!==t?n.copy(t):RZe.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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=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;bx.subVectors(e,this.center);let t=bx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(bx,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(aN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(bx.copy(e.center).add(aN)),this.expandByPoint(bx.copy(e.center).sub(aN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Su=new M,oN=new M,Xw=new M,Xh=new M,lN=new M,Yw=new M,cN=new M,Wa=class{constructor(e=new M,t=new M(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,Su)),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=Su.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Su.copy(this.origin).addScaledVector(this.direction,t),Su.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){oN.copy(e).add(t).multiplyScalar(.5),Xw.copy(t).sub(e).normalize(),Xh.copy(this.origin).sub(oN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(Xw),c=Xh.dot(this.direction),u=-Xh.dot(Xw),d=Xh.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(r=h*u-c,a=h*c-u,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+h*a+2*c)+a*(h*r+a+2*u)+d}else a=l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a=-l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a<=-o?(r=Math.max(0,-(-h*l+c)),a=r>0?-l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d):a<=o?(r=0,a=Math.min(Math.max(-l,-u),l),s=a*(a+2*u)+d):(r=Math.max(0,-(h*l+c)),a=r>0?l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d);else a=h>0?-l:l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(oN).addScaledVector(Xw,a),s}intersectSphere(e,t){Su.subVectors(e.center,this.origin);let n=Su.dot(this.direction),i=Su.dot(Su)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?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 null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),c>=0?(s=(e.min.z-u.z)*c,o=(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,o=(e.min.z-u.z)*c),n>o||s>i)||((s>n||n!=n)&&(n=s),(o<i||i!=i)&&(i=o),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,Su)}intersectTriangle(e,t,n,i,r){lN.subVectors(t,e),Yw.subVectors(n,e),cN.crossVectors(lN,Yw);let a,s=this.direction.dot(cN);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}Xh.subVectors(this.origin,e);let o=a*this.direction.dot(Yw.crossVectors(Xh,Yw));if(o<0)return null;let l=a*this.direction.dot(lN.cross(Xh));if(l<0||o+l>s)return null;let h=-a*Xh.dot(cN);return h<0?null:this.at(h/s,r)}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)}},Ae=class{constructor(){Ae.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,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 Ae).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 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){let t=this.elements,n=e.elements,i=1/Eg.setFromMatrixColumn(e,0).length(),r=1/Eg.setFromMatrixColumn(e,1).length(),a=1/Eg.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*h,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*h,t[9]=-s*h,t[2]=-l*h,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=e*c+r,t[5]=a*h,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*h,t[10]=r*c+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(AZe,e,CZe)}lookAt(e,t,n){let i=this.elements;return Ha.subVectors(e,t),0===Ha.lengthSq()&&(Ha.z=1),Ha.normalize(),Yh.crossVectors(n,Ha),0===Yh.lengthSq()&&(1===Math.abs(n.z)?Ha.x+=1e-4:Ha.z+=1e-4,Ha.normalize(),Yh.crossVectors(n,Ha)),Yh.normalize(),$w.crossVectors(Ha,Yh),i[0]=Yh.x,i[4]=$w.x,i[8]=Ha.x,i[1]=Yh.y,i[5]=$w.y,i[9]=Ha.y,i[2]=Yh.z,i[6]=$w.z,i[10]=Ha.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],h=n[1],c=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],_=n[15],b=i[0],M=i[4],w=i[8],S=i[12],E=i[1],T=i[5],A=i[9],C=i[13],R=i[2],P=i[6],L=i[10],D=i[14],I=i[3],O=i[7],U=i[11],N=i[15];return r[0]=a*b+s*E+o*R+l*I,r[4]=a*M+s*T+o*P+l*O,r[8]=a*w+s*A+o*L+l*U,r[12]=a*S+s*C+o*D+l*N,r[1]=h*b+c*E+u*R+d*I,r[5]=h*M+c*T+u*P+d*O,r[9]=h*w+c*A+u*L+d*U,r[13]=h*S+c*C+u*D+d*N,r[2]=p*b+f*E+m*R+g*I,r[6]=p*M+f*T+m*P+g*O,r[10]=p*w+f*A+m*L+g*U,r[14]=p*S+f*C+m*D+g*N,r[3]=v*b+y*E+x*R+_*I,r[7]=v*M+y*T+x*P+_*O,r[11]=v*w+y*A+x*L+_*U,r[15]=v*S+y*C+x*D+_*N,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],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+r*o*c-i*l*c-r*s*u+n*l*u+i*s*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*a*u-i*a*d+i*l*h-r*o*h)+e[11]*(+t*l*c-t*s*d-r*a*c+n*a*d+r*s*h-n*l*h)+e[15]*(-i*s*h-t*o*c+t*s*u+i*a*c-n*a*u+n*o*h)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*u*l+f*o*d-s*m*d-c*o*g+s*u*g,y=p*u*l-h*m*l-p*o*d+a*m*d+h*o*g-a*u*g,x=h*f*l-p*c*l+p*s*d-a*f*d-h*s*g+a*c*g,_=p*c*o-h*f*o-p*s*u+a*f*u+h*s*m-a*c*m,b=t*v+n*y+i*x+r*_;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/b;return e[0]=v*M,e[1]=(f*u*r-c*m*r-f*i*d+n*m*d+c*i*g-n*u*g)*M,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*M,e[3]=(c*o*r-s*u*r-c*i*l+n*u*l+s*i*d-n*o*d)*M,e[4]=y*M,e[5]=(h*m*r-p*u*r+p*i*d-t*m*d-h*i*g+t*u*g)*M,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*M,e[7]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*M,e[8]=x*M,e[9]=(p*c*r-h*f*r-p*n*d+t*f*d+h*n*g-t*c*g)*M,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*M,e[11]=(h*s*r-a*c*r-h*n*l+t*c*l+a*n*d-t*s*d)*M,e[12]=_*M,e[13]=(h*f*i-p*c*i+p*n*u-t*f*u-h*n*m+t*c*m)*M,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*M,e[15]=(a*c*i-h*s*i+h*n*o-t*c*o-a*n*u+t*s*u)*M,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,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],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return 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),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,h=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,h*s+n,h*o-i*a,0,l*o-i*s,h*o+i*a,r*o*o+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,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,h=a+a,c=s+s,u=r*l,d=r*h,p=r*c,f=a*h,m=a*c,g=s*c,v=o*l,y=o*h,x=o*c,_=n.x,b=n.y,M=n.z;return i[0]=(1-(f+g))*_,i[1]=(d+x)*_,i[2]=(p-y)*_,i[3]=0,i[4]=(d-x)*b,i[5]=(1-(u+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(p+y)*M,i[9]=(m-v)*M,i[10]=(1-(u+f))*M,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,r=Eg.set(i[0],i[1],i[2]).length(),a=Eg.set(i[4],i[5],i[6]).length(),s=Eg.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],yl.copy(this);let o=1/r,l=1/a,h=1/s;return yl.elements[0]*=o,yl.elements[1]*=o,yl.elements[2]*=o,yl.elements[4]*=l,yl.elements[5]*=l,yl.elements[6]*=l,yl.elements[8]*=h,yl.elements[9]*=h,yl.elements[10]*=h,t.setFromRotationMatrix(yl),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a){let s=this.elements,o=2*r/(t-e),l=2*r/(n-i),h=(t+e)/(t-e),c=(n+i)/(n-i),u=-(a+r)/(a-r),d=-2*a*r/(a-r);return s[0]=o,s[4]=0,s[8]=h,s[12]=0,s[1]=0,s[5]=l,s[9]=c,s[13]=0,s[2]=0,s[6]=0,s[10]=u,s[14]=d,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,i,r,a){let s=this.elements,o=1/(t-e),l=1/(n-i),h=1/(a-r),c=(t+e)*o,u=(n+i)*l,d=(a+r)*h;return s[0]=2*o,s[4]=0,s[8]=0,s[12]=-c,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-u,s[2]=0,s[6]=0,s[10]=-2*h,s[14]=-d,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])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}},Eg=new M,yl=new Ae,AZe=new M(0,0,0),CZe=new M(1,1,1),Yh=new M,$w=new M,Ha=new M,Bse=new Ae,Fse=new En,rn=class{constructor(e=0,t=0,n=0,i=rn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,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 i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],h=i[9],c=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(pi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-pi(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(pi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-pi(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(pi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-pi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Bse.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bse,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Fse.setFromEuler(this),this.setFromQuaternion(Fse,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],void 0!==e[3]&&(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}};rn.DEFAULT_ORDER="XYZ";var qg=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 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}},PZe=0,Hse=new M,bg=new En,Ru=new Ae,Zw=new M,_x=new M,IZe=new M,DZe=new En,kse=new M(1,0,0),Vse=new M(0,1,0),zse=new M(0,0,1),LZe={type:"added"},Gse={type:"removed"},Tt=class extends qa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:PZe++}),this.uuid=za(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Tt.DEFAULT_UP.clone();let e=new M,t=new rn,n=new En,i=new M(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ae},normalMatrix:{value:new Wt}}),this.matrix=new Ae,this.matrixWorld=new Ae,this.matrixAutoUpdate=Tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new qg,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 bg.setFromAxisAngle(e,t),this.quaternion.multiply(bg),this}rotateOnWorldAxis(e,t){return bg.setFromAxisAngle(e,t),this.quaternion.premultiply(bg),this}rotateX(e){return this.rotateOnAxis(kse,e)}rotateY(e){return this.rotateOnAxis(Vse,e)}rotateZ(e){return this.rotateOnAxis(zse,e)}translateOnAxis(e,t){return Hse.copy(e).applyQuaternion(this.quaternion),this.position.add(Hse.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(kse,e)}translateY(e){return this.translateOnAxis(Vse,e)}translateZ(e){return this.translateOnAxis(zse,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ru.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Zw.copy(e):Zw.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),_x.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ru.lookAt(_x,Zw,this.up):Ru.lookAt(Zw,_x,this.up),this.quaternion.setFromRotationMatrix(Ru),i&&(Ru.extractRotation(i.matrixWorld),bg.setFromRotationMatrix(Ru),this.quaternion.premultiply(bg.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(LZe)):console.error("THREE.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-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Gse)),this}removeFromParent(){let e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(Gse)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ru.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Ru.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ru),this.add(e),e.updateWorldMatrix(!1,!0),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,i=this.children.length;n<i;n++){let i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,r=this.children.length;i<r;i++){let r=this.children[i].getObjectsByProperty(e,t);r.length>0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_x,e,IZe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_x,DZe,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,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?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,i=t.length;n<i;n++){let i=t[n];(!0===i.matrixWorldAutoUpdate||!0===e)&&i.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){let t=a(e.geometries),i=a(e.materials),r=a(e.textures),s=a(e.images),o=a(e.shapes),l=a(e.skeletons),h=a(e.animations),c=a(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}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),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let n=0;n<e.children.length;n++){let t=e.children[n];this.add(t.clone())}return this}};Tt.DEFAULT_UP=new M(0,1,0),Tt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var El=new M,Au=new M,uN=new M,Cu=new M,_g=new M,Tg=new M,qse=new M,hN=new M,dN=new M,fN=new M,Kw=!1,Rr=class{constructor(e=new M,t=new M,n=new M){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),El.subVectors(e,t),i.cross(El);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){El.subVectors(i,t),Au.subVectors(n,t),uN.subVectors(e,t);let a=El.dot(El),s=El.dot(Au),o=El.dot(uN),l=Au.dot(Au),h=Au.dot(uN),c=a*l-s*s;if(0===c)return r.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(a*h-s*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Cu),Cu.x>=0&&Cu.y>=0&&Cu.x+Cu.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===Kw&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Kw=!0),this.getInterpolation(e,t,n,i,r,a,s,o)}static getInterpolation(e,t,n,i,r,a,s,o){return this.getBarycoord(e,t,n,i,Cu),o.setScalar(0),o.addScaledVector(r,Cu.x),o.addScaledVector(a,Cu.y),o.addScaledVector(s,Cu.z),o}static isFrontFacing(e,t,n,i){return El.subVectors(n,t),Au.subVectors(e,t),El.cross(Au).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 El.subVectors(this.c,this.b),Au.subVectors(this.a,this.b),.5*El.cross(Au).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Rr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Rr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===Kw&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Kw=!0),Rr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return Rr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Rr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Rr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;_g.subVectors(a,r),Tg.subVectors(s,r),hN.subVectors(e,r);let o=_g.dot(hN),l=Tg.dot(hN);if(o<=0&&l<=0)return t.copy(r);dN.subVectors(e,a);let h=_g.dot(dN),c=Tg.dot(dN);if(h>=0&&c<=h)return t.copy(a);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return n=o/(o-h),t.copy(r).addScaledVector(_g,n);fN.subVectors(e,s);let d=_g.dot(fN),p=Tg.dot(fN);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(Tg,i);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return qse.subVectors(s,a),i=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(qse,i);let g=1/(m+f+u);return n=f*g,i=u*g,t.copy(r).addScaledVector(_g,n).addScaledVector(Tg,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},OZe=0,Rn=class extends qa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:OZe++}),this.uuid=za(),this.name="",this.type="Material",this.blending=Zf,this.side=Tr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=hy,this.blendDst=AB,this.blendEquation=Us,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=HM,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=joe,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=FM,this.stencilZFail=FM,this.stencilZPass=FM,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.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()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(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.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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Zf&&(n.blending=this.blending),this.side!==Tr&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}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.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(null!==t){let e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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){!0===e&&this.version++}},Zoe={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},bl={h:0,s:0,l:0},Jw={h:0,s:0,l:0};function pN(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}var Ie=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=St){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Mo.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Mo.workingColorSpace){return this.r=e,this.g=t,this.b=n,Mo.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Mo.workingColorSpace){if(e=LB(e,1),t=pi(t,0,1),n=pi(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=pN(r,i,e+1/3),this.g=pN(r,i,e),this.b=pN(r,i,e-1/3)}return Mo.toWorkingColorSpace(this,i),this}setStyle(e,t=St){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=St){let n=Zoe[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),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=kg(e.r),this.g=kg(e.g),this.b=kg(e.b),this}copyLinearToSRGB(e){return this.r=nN(e.r),this.g=nN(e.g),this.b=nN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=St){return Mo.fromWorkingColorSpace(fs.copy(this),e),65536*Math.round(pi(255*fs.r,0,255))+256*Math.round(pi(255*fs.g,0,255))+Math.round(pi(255*fs.b,0,255))}getHexString(e=St){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Mo.workingColorSpace){Mo.fromWorkingColorSpace(fs.copy(this),t);let n,i,r=fs.r,a=fs.g,s=fs.b,o=Math.max(r,a,s),l=Math.min(r,a,s),h=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=h<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+(a<s?6:0);break;case a:n=(s-r)/e+2;break;case s:n=(r-a)/e+4}n/=6}return e.h=n,e.s=i,e.l=h,e}getRGB(e,t=Mo.workingColorSpace){return Mo.fromWorkingColorSpace(fs.copy(this),t),e.r=fs.r,e.g=fs.g,e.b=fs.b,e}getStyle(e=St){Mo.fromWorkingColorSpace(fs.copy(this),e);let t=fs.r,n=fs.g,i=fs.b;return e!==St?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(e,t,n){return this.getHSL(bl),bl.h+=e,bl.s+=t,bl.l+=n,this.setHSL(bl.h,bl.s,bl.l),this}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(bl),e.getHSL(Jw);let n=Dx(bl.h,Jw.h,t),i=Dx(bl.s,Jw.s,t),r=Dx(bl.l,Jw.l,t);return this.setHSL(n,i,r),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,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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}},fs=new Ie;Ie.NAMES=Zoe;var Pt=class extends Rn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(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.combine=dy,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.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}},Iu=NZe();function NZe(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let e=l-127;e<-27?(i[l]=0,i[256|l]=32768,r[l]=24,r[256|l]=24):e<-14?(i[l]=1024>>-e-14,i[256|l]=1024>>-e-14|32768,r[l]=-e-1,r[256|l]=-e-1):e<=15?(i[l]=e+15<<10,i[256|l]=e+15<<10|32768,r[l]=13,r[256|l]=13):e<128?(i[l]=31744,i[256|l]=64512,r[l]=24,r[256|l]=24):(i[l]=31744,i[256|l]=64512,r[l]=13,r[256|l]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let e=l<<13,t=0;for(;!(8388608&e);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,a[l]=e|t}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)s[l]=l<<23;s[31]=1199570944,s[32]=2147483648;for(let l=33;l<63;++l)s[l]=2147483648+(l-32<<23);s[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}function ua(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=pi(e,-65504,65504),Iu.floatView[0]=e;let t=Iu.uint32View[0],n=t>>23&511;return Iu.baseTable[n]+((8388607&t)>>Iu.shiftTable[n])}function Px(e){let t=e>>10;return Iu.uint32View[0]=Iu.mantissaTable[Iu.offsetTable[t]+(1023&e)]+Iu.exponentTable[t],Iu.floatView[0]}var iv={toHalfFloat:ua,fromHalfFloat:Px},Ri=new M,Qw=new Q,Ct=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Hx,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)Qw.fromBufferAttribute(this,t),Qw.applyMatrix3(e),this.setXY(t,Qw.x,Qw.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix3(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix4(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ri.fromBufferAttribute(this,t),Ri.applyNormalMatrix(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ri.fromBufferAttribute(this,t),Ri.transformDirection(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Va(t,this.array)),t}setX(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Va(t,this.array)),t}setY(e,t){return this.normalized&&(t=In(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=Va(t,this.array)),t}setZ(e,t){return this.normalized&&(t=In(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=Va(t,this.array)),t}setW(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array),r=In(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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!==Hx&&(e.usage=this.usage),(0!==this.updateRange.offset||-1!==this.updateRange.count)&&(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}},uU=class extends Ct{constructor(e,t,n){super(new Int8Array(e),t,n)}},hU=class extends Ct{constructor(e,t,n){super(new Uint8Array(e),t,n)}},dU=class extends Ct{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},fU=class extends Ct{constructor(e,t,n){super(new Int16Array(e),t,n)}},Qf=class extends Ct{constructor(e,t,n){super(new Uint16Array(e),t,n)}},pU=class extends Ct{constructor(e,t,n){super(new Int32Array(e),t,n)}},Gx=class extends Ct{constructor(e,t,n){super(new Uint32Array(e),t,n)}},mU=class extends Ct{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Px(this.array[e*this.itemSize]);return this.normalized&&(t=Va(t,this.array)),t}setX(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize]=ua(t),this}getY(e){let t=Px(this.array[e*this.itemSize+1]);return this.normalized&&(t=Va(t,this.array)),t}setY(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize+1]=ua(t),this}getZ(e){let t=Px(this.array[e*this.itemSize+2]);return this.normalized&&(t=Va(t,this.array)),t}setZ(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize+2]=ua(t),this}getW(e){let t=Px(this.array[e*this.itemSize+3]);return this.normalized&&(t=Va(t,this.array)),t}setW(e,t){return this.normalized&&(t=In(t,this.array)),this.array[e*this.itemSize+3]=ua(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array)),this.array[e+0]=ua(t),this.array[e+1]=ua(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array)),this.array[e+0]=ua(t),this.array[e+1]=ua(n),this.array[e+2]=ua(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array),r=In(r,this.array)),this.array[e+0]=ua(t),this.array[e+1]=ua(n),this.array[e+2]=ua(i),this.array[e+3]=ua(r),this}},tt=class extends Ct{constructor(e,t,n){super(new Float32Array(e),t,n)}},gU=class extends Ct{constructor(e,t,n){super(new Float64Array(e),t,n)}},UZe=0,wo=new Ae,mN=new Tt,wg=new M,ka=new lt,Tx=new lt,qi=new M,et=class extends qa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:UZe++}),this.uuid=za(),this.name="",this.type="BufferGeometry",this.index=null,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($oe(e)?Gx:Qf)(e,1):this.index=e,this}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 void 0!==this.attributes[e]}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;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(void 0!==n){let t=(new Wt).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return wo.makeRotationFromQuaternion(e),this.applyMatrix4(wo),this}rotateX(e){return wo.makeRotationX(e),this.applyMatrix4(wo),this}rotateY(e){return wo.makeRotationY(e),this.applyMatrix4(wo),this}rotateZ(e){return wo.makeRotationZ(e),this.applyMatrix4(wo),this}translate(e,t,n){return wo.makeTranslation(e,t,n),this.applyMatrix4(wo),this}scale(e,t,n){return wo.makeScale(e,t,n),this.applyMatrix4(wo),this}lookAt(e){return mN.lookAt(e),mN.updateMatrix(),this.applyMatrix4(mN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wg).negate(),this.translate(wg.x,wg.y,wg.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new tt(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new lt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let e=t[n];ka.setFromBufferAttribute(e),this.morphTargetsRelative?(qi.addVectors(this.boundingBox.min,ka.min),this.boundingBox.expandByPoint(qi),qi.addVectors(this.boundingBox.max,ka.max),this.boundingBox.expandByPoint(qi)):(this.boundingBox.expandByPoint(ka.min),this.boundingBox.expandByPoint(ka.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new hr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new M,1/0);if(e){let n=this.boundingSphere.center;if(ka.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){let n=t[e];Tx.setFromBufferAttribute(n),this.morphTargetsRelative?(qi.addVectors(ka.min,Tx.min),ka.expandByPoint(qi),qi.addVectors(ka.max,Tx.max),ka.expandByPoint(qi)):(ka.expandByPoint(Tx.min),ka.expandByPoint(Tx.max))}ka.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)qi.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(qi));if(t)for(let r=0,a=t.length;r<a;r++){let a=t[r],s=this.morphTargetsRelative;for(let t=0,r=a.count;t<r;t++)qi.fromBufferAttribute(a,t),s&&(wg.fromBufferAttribute(e,t),qi.add(wg)),i=Math.max(i,n.distanceToSquared(qi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.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(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");let n=e.array,i=t.position.array,r=t.normal.array,a=t.uv.array,s=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Ct(new Float32Array(4*s),4));let o=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<s;T++)l[T]=new M,h[T]=new M;let c=new M,u=new M,d=new M,p=new Q,f=new Q,m=new Q,g=new M,v=new M;function y(e,t,n){c.fromArray(i,3*e),u.fromArray(i,3*t),d.fromArray(i,3*n),p.fromArray(a,2*e),f.fromArray(a,2*t),m.fromArray(a,2*n),u.sub(c),d.sub(c),f.sub(p),m.sub(p);let r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),v.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[n].add(g),h[e].add(v),h[t].add(v),h[n].add(v))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let M=0,T=x.length;M<T;++M){let e=x[M],t=e.start;for(let i=t,r=t+e.count;i<r;i+=3)y(n[i+0],n[i+1],n[i+2])}let _=new M,b=new M,w=new M,S=new M;function E(e){w.fromArray(r,3*e),S.copy(w);let t=l[e];_.copy(t),_.sub(w.multiplyScalar(w.dot(t))).normalize(),b.crossVectors(S,t);let n=b.dot(h[e])<0?-1:1;o[4*e]=_.x,o[4*e+1]=_.y,o[4*e+2]=_.z,o[4*e+3]=n}for(let M=0,T=x.length;M<T;++M){let e=x[M],t=e.start;for(let i=t,r=t+e.count;i<r;i+=3)E(n[i+0]),E(n[i+1]),E(n[i+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new Ct(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let i=new M,r=new M,a=new M,s=new M,o=new M,l=new M,h=new M,c=new M;if(e)for(let u=0,d=e.count;u<d;u+=3){let d=e.getX(u+0),p=e.getX(u+1),f=e.getX(u+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),a.fromBufferAttribute(t,f),h.subVectors(a,r),c.subVectors(i,r),h.cross(c),s.fromBufferAttribute(n,d),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),s.add(h),o.add(h),l.add(h),n.setXYZ(d,s.x,s.y,s.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,u=t.count;e<u;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),h.subVectors(a,r),c.subVectors(i,r),h.cross(c),n.setXYZ(e+0,h.x,h.y,h.z),n.setXYZ(e+1,h.x,h.y,h.z),n.setXYZ(e+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)qi.fromBufferAttribute(e,t),qi.normalize(),e.setXYZ(t,qi.x,qi.y,qi.z)}toNonIndexed(){function e(e,t){let n=e.array,i=e.itemSize,r=e.normalized,a=new n.constructor(t.length*i),s=0,o=0;for(let l=0,h=t.length;l<h;l++){s=e.isInterleavedBufferAttribute?t[l]*e.data.stride+e.offset:t[l]*i;for(let e=0;e<i;e++)a[o++]=n[s++]}return new Ct(a,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new et,n=this.index.array,i=this.attributes;for(let s in i){let r=e(i[s],n);t.setAttribute(s,r)}let r=this.morphAttributes;for(let s in r){let i=[],a=r[s];for(let t=0,r=a.length;t<r;t++){let r=e(a[t],n);i.push(r)}t.morphAttributes[s]=i}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let s=0,o=a.length;s<o;s++){let e=a[s];t.addGroup(e.start,e.count,e.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,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),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let o in n){let t=n[o];e.data.attributes[o]=t.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let t=this.morphAttributes[o],n=[];for(let i=0,r=t.length;i<r;i++){let r=t[i];n.push(r.toJSON(e.data))}n.length>0&&(i[o]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),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;null!==n&&this.setIndex(n.clone(t));let i=e.attributes;for(let l in i){let e=i[l];this.setAttribute(l,e.clone(t))}let r=e.morphAttributes;for(let l in r){let e=[],n=r[l];for(let i=0,r=n.length;i<r;i++)e.push(n[i].clone(t));this.morphAttributes[l]=e}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let l=0,h=a.length;l<h;l++){let e=a[l];this.addGroup(e.start,e.count,e.materialIndex)}let s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());let o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Wse=new Ae,hc=new Wa,eM=new hr,jse=new M,Mg=new M,Sg=new M,Rg=new M,gN=new M,tM=new M,nM=new Q,rM=new Q,iM=new Q,Xse=new M,Yse=new M,$se=new M,sM=new M,aM=new M,Ge=class extends Tt{constructor(e=new et,t=new Pt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=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(void 0!==n){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,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let s=this.morphTargetInfluences;if(r&&s){tM.set(0,0,0);for(let n=0,i=r.length;n<i;n++){let i=s[n],o=r[n];0!==i&&(gN.fromBufferAttribute(o,e),a?tM.addScaledVector(gN,i):tM.addScaledVector(gN.sub(t),i))}t.add(tM)}return t}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;void 0!==i&&(null===n.boundingSphere&&n.computeBoundingSphere(),eM.copy(n.boundingSphere),eM.applyMatrix4(r),hc.copy(e.ray).recast(e.near),(!1!==eM.containsPoint(hc.origin)||!(null===hc.intersectSphere(eM,jse)||hc.origin.distanceToSquared(jse)>Kl(e.far-e.near,2)))&&(Wse.copy(r).invert(),hc.copy(e.ray).applyMatrix4(Wse),(null===n.boundingBox||!1!==hc.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t)))}_computeIntersections(e,t){let n,i=this.geometry,r=this.material,a=i.index,s=i.attributes.position,o=i.attributes.uv,l=i.attributes.uv1,h=i.attributes.normal,c=i.groups,u=i.drawRange;if(null!==a)if(Array.isArray(r))for(let d=0,p=c.length;d<p;d++){let i=c[d],s=r[i.materialIndex];for(let r=Math.max(i.start,u.start),c=Math.min(a.count,Math.min(i.start+i.count,u.start+u.count));r<c;r+=3){let c=a.getX(r),u=a.getX(r+1),d=a.getX(r+2);n=oM(this,s,e,hc,o,l,h,c,u,d),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=i.materialIndex,t.push(n))}}else for(let d=Math.max(0,u.start),p=Math.min(a.count,u.start+u.count);d<p;d+=3){let i=a.getX(d),s=a.getX(d+1),c=a.getX(d+2);n=oM(this,r,e,hc,o,l,h,i,s,c),n&&(n.faceIndex=Math.floor(d/3),t.push(n))}else if(void 0!==s)if(Array.isArray(r))for(let d=0,p=c.length;d<p;d++){let i=c[d],a=r[i.materialIndex];for(let r=Math.max(i.start,u.start),c=Math.min(s.count,Math.min(i.start+i.count,u.start+u.count));r<c;r+=3)n=oM(this,a,e,hc,o,l,h,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=i.materialIndex,t.push(n))}else for(let d=Math.max(0,u.start),p=Math.min(s.count,u.start+u.count);d<p;d+=3)n=oM(this,r,e,hc,o,l,h,d,d+1,d+2),n&&(n.faceIndex=Math.floor(d/3),t.push(n))}};function BZe(e,t,n,i,r,a,s,o){let l;if(l=t.side===ri?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,t.side===Tr,o),null===l)return null;aM.copy(o),aM.applyMatrix4(e.matrixWorld);let h=n.ray.origin.distanceTo(aM);return h<n.near||h>n.far?null:{distance:h,point:aM.clone(),object:e}}function oM(e,t,n,i,r,a,s,o,l,h){e.getVertexPosition(o,Mg),e.getVertexPosition(l,Sg),e.getVertexPosition(h,Rg);let c=BZe(e,t,n,i,Mg,Sg,Rg,sM);if(c){r&&(nM.fromBufferAttribute(r,o),rM.fromBufferAttribute(r,l),iM.fromBufferAttribute(r,h),c.uv=Rr.getInterpolation(sM,Mg,Sg,Rg,nM,rM,iM,new Q)),a&&(nM.fromBufferAttribute(a,o),rM.fromBufferAttribute(a,l),iM.fromBufferAttribute(a,h),c.uv1=Rr.getInterpolation(sM,Mg,Sg,Rg,nM,rM,iM,new Q),c.uv2=c.uv1),s&&(Xse.fromBufferAttribute(s,o),Yse.fromBufferAttribute(s,l),$se.fromBufferAttribute(s,h),c.normal=Rr.getInterpolation(sM,Mg,Sg,Rg,Xse,Yse,$se,new M),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new M,materialIndex:0};Rr.getNormal(Mg,Sg,Rg,e.normal),c.face=e}return c}var Qi=class extends et{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],c=[],u=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let y=a/m,x=p/g,_=a/2,b=p/2,w=f/2,S=m+1,E=g+1,T=0,A=0,C=new M;for(let s=0;s<E;s++){let a=s*x-b;for(let o=0;o<S;o++){let u=o*y-_;C[e]=u*i,C[t]=a*r,C[n]=w,l.push(C.x,C.y,C.z),C[e]=0,C[t]=0,C[n]=f>0?1:-1,h.push(C.x,C.y,C.z),c.push(o/m),c.push(1-s/g),T+=1}}for(let s=0;s<g;s++)for(let e=0;e<m;e++){let t=u+e+S*s,n=u+e+S*(s+1),i=u+(e+1)+S*(s+1),r=u+(e+1)+S*s;o.push(t,n,r),o.push(n,i,r),A+=6}s.addGroup(d,A,v),d+=A,u+=T}p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new tt(l,3)),this.setAttribute("normal",new tt(h,3)),this.setAttribute("uv",new tt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Wg(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}}return t}function Ns(e){let t={};for(let n=0;n<e.length;n++){let i=Wg(e[n]);for(let e in i)t[e]=i[e]}return t}function FZe(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Koe(e){return null===e.getRenderTarget()?e.outputColorSpace:ks}var Lr={clone:Wg,merge:Ns},HZe="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",kZe="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",It=class extends Rn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=HZe,this.fragmentShader=kZe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Wg(e.uniforms),this.uniformsGroups=FZe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let n=this.uniforms[i].value;n&&n.isTexture?t.uniforms[i]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[i]={type:"m4",value:n.toArray()}:t.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Fu=class extends Tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ae,this.projectionMatrix=new Ae,this.projectionMatrixInverse=new Ae}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}},bn=class extends Fu{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*zg*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*Kf*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*zg*Math.atan(Math.tan(.5*Kf*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*Kf*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Ag=-90,Cg=1,VM=class extends Tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;let i=new bn(Ag,Cg,e,t);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i);let r=new bn(Ag,Cg,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(-1,0,0),this.add(r);let a=new bn(Ag,Cg,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);let s=new bn(Ag,Cg,e,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(0,-1,0),this.add(s);let o=new bn(Ag,Cg,e,t);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(0,0,1),this.add(o);let l=new bn(Ag,Cg,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();let n=this.renderTarget,[i,r,a,s,o,l]=this.children,h=e.getRenderTarget(),c=e.toneMapping,u=e.xr.enabled;e.toneMapping=fc,e.xr.enabled=!1;let d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,s),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}},ep=class extends ur{constructor(e,t,n,i,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Jh,n,i,r,a,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},zM=class extends Sn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(Lx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===pc?St:mc),this.texture=new ep(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Vn}fromEquirectangularTexture(e,t){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 n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new Qi(5,5,5),s=new It({name:"CubemapFromEquirect",uniforms:Wg(n),vertexShader:i,fragmentShader:r,side:ri,blending:yr});s.uniforms.tEquirect.value=t;let o=new Ge(a,s),l=t.minFilter;return t.minFilter===Hs&&(t.minFilter=Vn),new VM(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}},vN=new M,VZe=new M,zZe=new Wt,er=class{constructor(e=new M(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,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=vN.subVectors(n,t).cross(VZe.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(vN),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||zZe.getNormalMatrix(e),i=this.coplanarPoint(vN).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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)}},Hf=new hr,lM=new M,ps=class{constructor(e=new er,t=new er,n=new er,i=new er,r=new er,a=new er){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[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){let t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],s=n[3],o=n[4],l=n[5],h=n[6],c=n[7],u=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(s-i,c-o,f-u,y-m).normalize(),t[1].setComponents(s+i,c+o,f+u,y+m).normalize(),t[2].setComponents(s+r,c+l,f+d,y+g).normalize(),t[3].setComponents(s-r,c-l,f-d,y-g).normalize(),t[4].setComponents(s-a,c-h,f-p,y-v).normalize(),t[5].setComponents(s+a,c+h,f+p,y+v).normalize(),this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Hf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Hf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hf)}intersectsSprite(e){return Hf.center.set(0,0,0),Hf.radius=.7071067811865476,Hf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hf)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(lM.x=i.normal.x>0?e.max.x:e.min.x,lM.y=i.normal.y>0?e.max.y:e.min.y,lM.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(lM)<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)}};function Joe(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function GZe(e,t){let n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){let e=i.get(t);return void((!e||e.version<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);let a=i.get(t);void 0===a?i.set(t,function(t,i){let r,a=t.array,s=t.usage,o=e.createBuffer();if(e.bindBuffer(i,o),e.bufferData(i,a,s),t.onUploadCallback(),a instanceof Float32Array)r=e.FLOAT;else if(a instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");r=e.HALF_FLOAT}else r=e.UNSIGNED_SHORT;else if(a instanceof Int16Array)r=e.SHORT;else if(a instanceof Uint32Array)r=e.UNSIGNED_INT;else if(a instanceof Int32Array)r=e.INT;else if(a instanceof Int8Array)r=e.BYTE;else if(a instanceof Uint8Array)r=e.UNSIGNED_BYTE;else{if(!(a instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);r=e.UNSIGNED_BYTE}return{buffer:o,type:r,bytesPerElement:a.BYTES_PER_ELEMENT,version:t.version}}(t,r)):a.version<t.version&&(function(t,i,r){let a=i.array,s=i.updateRange;e.bindBuffer(r,t),-1===s.count?e.bufferSubData(r,0,a):(n?e.bufferSubData(r,s.offset*a.BYTES_PER_ELEMENT,a,s.offset,s.count):e.bufferSubData(r,s.offset*a.BYTES_PER_ELEMENT,a.subarray(s.offset,s.offset+s.count)),s.count=-1),i.onUploadCallback()}(a.buffer,t,r),a.version=t.version)}}}var Ur=class extends et{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,a=t/2,s=Math.floor(n),o=Math.floor(i),l=s+1,h=o+1,c=e/s,u=t/o,d=[],p=[],f=[],m=[];for(let g=0;g<h;g++){let e=g*u-a;for(let t=0;t<l;t++){let n=t*c-r;p.push(n,-e,0),f.push(0,0,1),m.push(t/s),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let e=0;e<s;e++){let t=e+l*g,n=e+l*(g+1),i=e+1+l*(g+1),r=e+1+l*g;d.push(t,n,r),d.push(n,i,r)}this.setIndex(d),this.setAttribute("position",new tt(p,3)),this.setAttribute("normal",new tt(f,3)),this.setAttribute("uv",new tt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ur(e.width,e.height,e.widthSegments,e.heightSegments)}},qZe="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",WZe="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",jZe="#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",XZe="#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",YZe="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",$Ze="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",ZZe="vec3 transformed = vec3( position );",KZe="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",JZe="float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",QZe="#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",eKe="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",tKe="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",nKe="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",rKe="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",iKe="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",sKe="#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",aKe="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",oKe="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",lKe="#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",cKe="#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",uKe="#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",hKe="vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",dKe="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",fKe="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",pKe="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",mKe="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",gKe="gl_FragColor = linearToOutputTexel( gl_FragColor );",vKe="vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",xKe="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",yKe="#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",EKe="#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",bKe="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",_Ke="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",TKe="#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",wKe="#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",MKe="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",SKe="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",RKe="#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",AKe="#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",CKe="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",PKe="LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",IKe="varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",DKe="uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",LKe="#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",OKe="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",NKe="varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",UKe="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",BKe="varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",FKe="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif",HKe="struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",kKe="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",VKe="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",zKe="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",GKe="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",qKe="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",WKe="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",jKe="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",XKe="#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",YKe="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",$Ke="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",ZKe="#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",KKe="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",JKe="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",QKe="#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",eJe="#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",tJe="#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",nJe="#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",rJe="float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_NORMALMAP_TANGENTSPACE\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",iJe="#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",sJe="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",aJe="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",oJe="#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",lJe="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",cJe="#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",uJe="#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",hJe="#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",dJe="#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",fJe="#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",pJe="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",mJe="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",gJe="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",vJe="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",xJe="#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",yJe="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",EJe="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",bJe="#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",_Je="#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",TJe="#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",wJe="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",MJe="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",SJe="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",RJe="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",AJe="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",CJe="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",PJe="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",IJe="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",DJe="#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",LJe="#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif",OJe="#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",NJe="#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",UJe="#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",BJe="#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",FJe="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",HJe="varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",kJe="uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",VJe="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",zJe="#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",GJe="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",qJe="uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",WJe="#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",jJe="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",XJe="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",YJe="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",$Je="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",ZJe="uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",KJe="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",JJe="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",QJe="#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",eQe="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",tQe="#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",nQe="#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",rQe="#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",iQe="#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",sQe="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",aQe="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",oQe="#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",lQe="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",cQe="#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",uQe="#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",hQe="#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",dQe="#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",fQe="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",pQe="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",mQe="#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",gQe="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",vQe="uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",xQe="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",Pn={alphamap_fragment:qZe,alphamap_pars_fragment:WZe,alphatest_fragment:jZe,alphatest_pars_fragment:XZe,aomap_fragment:YZe,aomap_pars_fragment:$Ze,begin_vertex:ZZe,beginnormal_vertex:KZe,bsdfs:JZe,iridescence_fragment:QZe,bumpmap_pars_fragment:eKe,clipping_planes_fragment:tKe,clipping_planes_pars_fragment:nKe,clipping_planes_pars_vertex:rKe,clipping_planes_vertex:iKe,color_fragment:sKe,color_pars_fragment:aKe,color_pars_vertex:oKe,color_vertex:lKe,common:cKe,cube_uv_reflection_fragment:uKe,defaultnormal_vertex:hKe,displacementmap_pars_vertex:dKe,displacementmap_vertex:fKe,emissivemap_fragment:pKe,emissivemap_pars_fragment:mKe,encodings_fragment:gKe,encodings_pars_fragment:vKe,envmap_fragment:xKe,envmap_common_pars_fragment:yKe,envmap_pars_fragment:EKe,envmap_pars_vertex:bKe,envmap_physical_pars_fragment:LKe,envmap_vertex:_Ke,fog_vertex:TKe,fog_pars_vertex:wKe,fog_fragment:MKe,fog_pars_fragment:SKe,gradientmap_pars_fragment:RKe,lightmap_fragment:AKe,lightmap_pars_fragment:CKe,lights_lambert_fragment:PKe,lights_lambert_pars_fragment:IKe,lights_pars_begin:DKe,lights_toon_fragment:OKe,lights_toon_pars_fragment:NKe,lights_phong_fragment:UKe,lights_phong_pars_fragment:BKe,lights_physical_fragment:FKe,lights_physical_pars_fragment:HKe,lights_fragment_begin:kKe,lights_fragment_maps:VKe,lights_fragment_end:zKe,logdepthbuf_fragment:GKe,logdepthbuf_pars_fragment:qKe,logdepthbuf_pars_vertex:WKe,logdepthbuf_vertex:jKe,map_fragment:XKe,map_pars_fragment:YKe,map_particle_fragment:$Ke,map_particle_pars_fragment:ZKe,metalnessmap_fragment:KKe,metalnessmap_pars_fragment:JKe,morphcolor_vertex:QKe,morphnormal_vertex:eJe,morphtarget_pars_vertex:tJe,morphtarget_vertex:nJe,normal_fragment_begin:rJe,normal_fragment_maps:iJe,normal_pars_fragment:sJe,normal_pars_vertex:aJe,normal_vertex:oJe,normalmap_pars_fragment:lJe,clearcoat_normal_fragment_begin:cJe,clearcoat_normal_fragment_maps:uJe,clearcoat_pars_fragment:hJe,iridescence_pars_fragment:dJe,output_fragment:fJe,packing:pJe,premultiplied_alpha_fragment:mJe,project_vertex:gJe,dithering_fragment:vJe,dithering_pars_fragment:xJe,roughnessmap_fragment:yJe,roughnessmap_pars_fragment:EJe,shadowmap_pars_fragment:bJe,shadowmap_pars_vertex:_Je,shadowmap_vertex:TJe,shadowmask_pars_fragment:wJe,skinbase_vertex:MJe,skinning_pars_vertex:SJe,skinning_vertex:RJe,skinnormal_vertex:AJe,specularmap_fragment:CJe,specularmap_pars_fragment:PJe,tonemapping_fragment:IJe,tonemapping_pars_fragment:DJe,transmission_fragment:LJe,transmission_pars_fragment:OJe,uv_pars_fragment:NJe,uv_pars_vertex:UJe,uv_vertex:BJe,worldpos_vertex:FJe,background_vert:HJe,background_frag:kJe,backgroundCube_vert:VJe,backgroundCube_frag:zJe,cube_vert:GJe,cube_frag:qJe,depth_vert:WJe,depth_frag:jJe,distanceRGBA_vert:XJe,distanceRGBA_frag:YJe,equirect_vert:$Je,equirect_frag:ZJe,linedashed_vert:KJe,linedashed_frag:JJe,meshbasic_vert:QJe,meshbasic_frag:eQe,meshlambert_vert:tQe,meshlambert_frag:nQe,meshmatcap_vert:rQe,meshmatcap_frag:iQe,meshnormal_vert:sQe,meshnormal_frag:aQe,meshphong_vert:oQe,meshphong_frag:lQe,meshphysical_vert:cQe,meshphysical_frag:uQe,meshtoon_vert:hQe,meshtoon_frag:dQe,points_vert:fQe,points_frag:pQe,shadow_vert:mQe,shadow_frag:gQe,sprite_vert:vQe,sprite_frag:xQe},gt={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Wt},alphaMap:{value:null},alphaMapTransform:{value:new Wt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Wt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Wt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Wt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Wt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Wt},normalScale:{value:new Q(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Wt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Wt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Wt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Wt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Wt}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new Q(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Wt},alphaMap:{value:null},alphaTest:{value:0}}},_l={basic:{uniforms:Ns([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.fog]),vertexShader:Pn.meshbasic_vert,fragmentShader:Pn.meshbasic_frag},lambert:{uniforms:Ns([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Pn.meshlambert_vert,fragmentShader:Pn.meshlambert_frag},phong:{uniforms:Ns([gt.common,gt.specularmap,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,gt.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30}}]),vertexShader:Pn.meshphong_vert,fragmentShader:Pn.meshphong_frag},standard:{uniforms:Ns([gt.common,gt.envmap,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.roughnessmap,gt.metalnessmap,gt.fog,gt.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag},toon:{uniforms:Ns([gt.common,gt.aomap,gt.lightmap,gt.emissivemap,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.gradientmap,gt.fog,gt.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Pn.meshtoon_vert,fragmentShader:Pn.meshtoon_frag},matcap:{uniforms:Ns([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,gt.fog,{matcap:{value:null}}]),vertexShader:Pn.meshmatcap_vert,fragmentShader:Pn.meshmatcap_frag},points:{uniforms:Ns([gt.points,gt.fog]),vertexShader:Pn.points_vert,fragmentShader:Pn.points_frag},dashed:{uniforms:Ns([gt.common,gt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pn.linedashed_vert,fragmentShader:Pn.linedashed_frag},depth:{uniforms:Ns([gt.common,gt.displacementmap]),vertexShader:Pn.depth_vert,fragmentShader:Pn.depth_frag},normal:{uniforms:Ns([gt.common,gt.bumpmap,gt.normalmap,gt.displacementmap,{opacity:{value:1}}]),vertexShader:Pn.meshnormal_vert,fragmentShader:Pn.meshnormal_frag},sprite:{uniforms:Ns([gt.sprite,gt.fog]),vertexShader:Pn.sprite_vert,fragmentShader:Pn.sprite_frag},background:{uniforms:{uvTransform:{value:new Wt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Pn.background_vert,fragmentShader:Pn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Pn.backgroundCube_vert,fragmentShader:Pn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Pn.cube_vert,fragmentShader:Pn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pn.equirect_vert,fragmentShader:Pn.equirect_frag},distanceRGBA:{uniforms:Ns([gt.common,gt.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pn.distanceRGBA_vert,fragmentShader:Pn.distanceRGBA_frag},shadow:{uniforms:Ns([gt.lights,gt.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:Pn.shadow_vert,fragmentShader:Pn.shadow_frag}};_l.physical={uniforms:Ns([_l.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Wt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Wt},clearcoatNormalScale:{value:new Q(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Wt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Wt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Wt},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Wt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Wt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Wt},transmissionSamplerSize:{value:new Q},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Wt},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Wt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Wt}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag};var cM={r:0,b:0,g:0};function yQe(e,t,n,i,r,a,s){let o,l,h=new Ie(0),c=!0===a?0:1,u=null,d=0,p=null;function f(t,n){t.getRGB(cM,Koe(e)),i.buffers.color.setClear(cM.r,cM.g,cM.b,n,s)}return{getClearColor:function(){return h},setClearColor:function(e,t=1){h.set(e),c=t,f(h,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(h,c)},render:function(a,m){let g=!1,v=!0===m.isScene?m.background:null;switch(v&&v.isTexture&&(v=(m.backgroundBlurriness>0?n:t).get(v)),null===v?f(h,c):v&&v.isColor&&(f(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,s),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,s),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===tv)?(void 0===l&&(l=new Ge(new Qi(1,1,1),new It({name:"BackgroundCubeMaterial",uniforms:Wg(_l.backgroundCube.uniforms),vertexShader:_l.backgroundCube.vertexShader,fragmentShader:_l.backgroundCube.fragmentShader,side:ri,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=v,l.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=v.colorSpace!==St,(u!==v||d!==v.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(void 0===o&&(o=new Ge(new Ur(2,2),new It({name:"BackgroundMaterial",uniforms:Wg(_l.background.uniforms),vertexShader:_l.background.vertexShader,fragmentShader:_l.background.fragmentShader,side:Tr,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=v,o.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,o.material.toneMapped=v.colorSpace!==St,!0===v.matrixAutoUpdate&&v.updateMatrix(),o.material.uniforms.uvTransform.value.copy(v.matrix),(u!==v||d!==v.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),o.layers.enableAll(),a.unshift(o,o.geometry,o.material,0,0,null))}}}function EQe(e,t,n,i){let r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),s=i.isWebGL2||null!==a,o={},l=p(null),h=l,c=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){let t=[],n=[],i=[];for(let a=0;a<r;a++)t[a]=0,n[a]=0,i[a]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,object:e,attributes:{},index:null}}function f(){let e=h.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){g(e,0)}function g(n,r){let a=h.newAttributes,s=h.enabledAttributes,o=h.attributeDivisors;a[n]=1,0===s[n]&&(e.enableVertexAttribArray(n),s[n]=1),o[n]!==r&&((i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),o[n]=r)}function v(){let t=h.newAttributes,n=h.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function y(t,n,r,a,s,o){!0!==i.isWebGL2||r!==e.INT&&r!==e.UNSIGNED_INT?e.vertexAttribPointer(t,n,r,a,s,o):e.vertexAttribIPointer(t,n,r,s,o)}function x(){_(),c=!0,h!==l&&(h=l,u(h.object))}function _(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,x,_){let b=!1;if(s){let t=function(t,n,r){let s=!0===r.wireframe,l=o[t.id];void 0===l&&(l={},o[t.id]=l);let h=l[n.id];void 0===h&&(h={},l[n.id]=h);let c=h[s];return void 0===c&&(c=p(i.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),h[s]=c),c}(x,d,l);h!==t&&(h=t,u(h.object)),b=function(e,t,n,i){let r=h.attributes,a=t.attributes,s=0,o=n.getAttributes();for(let l in o)if(o[l].location>=0){let t=r[l],n=a[l];if(void 0===n&&("instanceMatrix"===l&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(n=e.instanceColor)),void 0===t||t.attribute!==n||n&&t.data!==n.data)return!0;s++}return h.attributesNum!==s||h.index!==i}(r,x,d,_),b&&function(e,t,n,i){let r={},a=t.attributes,s=0,o=n.getAttributes();for(let l in o)if(o[l].location>=0){let t=a[l];void 0===t&&("instanceMatrix"===l&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(t=e.instanceColor));let n={};n.attribute=t,t&&t.data&&(n.data=t.data),r[l]=n,s++}h.attributes=r,h.attributesNum=s,h.index=i}(r,x,d,_)}else{let e=!0===l.wireframe;(h.geometry!==x.id||h.program!==d.id||h.wireframe!==e)&&(h.geometry=x.id,h.program=d.id,h.wireframe=e,b=!0)}null!==_&&n.update(_,e.ELEMENT_ARRAY_BUFFER),(b||c)&&(c=!1,function(r,a,s,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();let l=o.attributes,h=s.getAttributes(),c=a.defaultAttributeValues;for(let t in h){let i=h[t];if(i.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){let t=a.normalized,s=a.itemSize,l=n.get(a);if(void 0===l)continue;let h=l.buffer,c=l.type,u=l.bytesPerElement;if(a.isInterleavedBufferAttribute){let n=a.data,l=n.stride,d=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)g(i.location+e,n.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<i.locationSize;e++)m(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,h);for(let e=0;e<i.locationSize;e++)y(i.location+e,s/i.locationSize,c,t,l*u,(d+s/i.locationSize*e)*u)}else{if(a.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)g(i.location+e,a.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let e=0;e<i.locationSize;e++)m(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,h);for(let e=0;e<i.locationSize;e++)y(i.location+e,s/i.locationSize,c,t,s*u,s/i.locationSize*e*u)}}else if(void 0!==c){let n=c[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i.location,n);break;case 3:e.vertexAttrib3fv(i.location,n);break;case 4:e.vertexAttrib4fv(i.location,n);break;default:e.vertexAttrib1fv(i.location,n)}}}}v()}(r,l,d,x),null!==_&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(_).buffer))},reset:x,resetDefaultState:_,dispose:function(){x();for(let e in o){let t=o[e];for(let e in t){let n=t[e];for(let e in n)d(n[e].object),delete n[e];delete t[e]}delete o[e]}},releaseStatesOfGeometry:function(e){if(void 0===o[e.id])return;let t=o[e.id];for(let n in t){let e=t[n];for(let t in e)d(e[t].object),delete e[t];delete t[n]}delete o[e.id]},releaseStatesOfProgram:function(e){for(let t in o){let n=o[t];if(void 0===n[e.id])continue;let i=n[e.id];for(let e in i)d(i[e].object),delete i[e];delete n[e.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:v}}function bQe(e,t,n,i){let r,a=i.isWebGL2;this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r,1)},this.renderInstances=function(i,s,o){if(0===o)return;let l,h;if(a)l=e,h="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[h](r,i,s,o),n.update(s,r,o)}}function _Qe(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,s=void 0!==n.precision?n.precision:"highp",o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);let l=a||t.has("WEBGL_draw_buffers"),h=!0===n.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=u>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function TQe(e){let t=this,n=null,i=0,r=!1,a=!1,s=new er,o=new Wt,l={value:null,needsUpdate:!1};function h(e,n,i,r){let a=null!==e?e.length:0,h=null;if(0!==a){if(h=l.value,!0!==r||null===h){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length<t)&&(h=new Float32Array(t));for(let n=0,l=i;n!==a;++n,l+=4)s.copy(e[n]).applyMatrix4(r,o),s.normal.toArray(h,l),h[l+3]=s.constant}l.value=h,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=h(e,t,0)},this.setState=function(s,o,c){let u=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(!r||null===u||0===u.length||a&&!p)a?h(null):(l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0);else{let e=a?0:i,t=4*e,r=f.clippingState||null;l.value=r,r=h(u,o,t,c);for(let i=0;i!==t;++i)r[i]=n[i];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function wQe(e){let t=new WeakMap;function n(e,t){return t===Jf?e.mapping=Jh:t===Bx&&(e.mapping=Qh),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){let a=r.mapping;if(a===Jf||a===Bx){if(t.has(r))return n(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new zM(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}var dr=class extends Fu{constructor(e=-1,t=1,n=1,i=-1,r=.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=i,this.near=r,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(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,i=(this.top+this.bottom)/2,r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}},Fg=4,Zse=[.125,.215,.35,.446,.526,.582],jf=20,xN=new dr,Kse=new Ie,yN=null,Wf=(1+Math.sqrt(5))/2,Pg=1/Wf,Jse=[new M(1,1,1),new M(-1,1,1),new M(1,1,-1),new M(-1,1,-1),new M(0,Wf,Pg),new M(0,Wf,-Pg),new M(Pg,0,Wf),new M(-Pg,0,Wf),new M(Wf,Pg,0),new M(-Wf,Pg,0)],Hu=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){yN=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=tae(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=eae(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(yN),e.scissorTest=!1,uM(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Jh||e.mapping===Qh?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),yN=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Vn,minFilter:Vn,generateMipmaps:!1,type:Ga,format:Ji,colorSpace:ks,depthBuffer:!1},i=Qse(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Qse(e,t,n);let{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=MQe(i)),this._blurMaterial=SQe(i,e,t)}return i}_compileMaterial(e){let t=new Ge(this._lodPlanes[0],e);this._renderer.compile(t,xN)}_sceneToCubeUV(e,t,n,i){let r=new bn(90,1,t,n),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(Kse),o.toneMapping=fc,o.autoClear=!1;let c=new Pt({name:"PMREM.Background",side:ri,depthWrite:!1,depthTest:!1}),u=new Ge(new Qi,c),d=!1,p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,d=!0):(c.color.copy(Kse),d=!0);for(let f=0;f<6;f++){let t=f%3;0===t?(r.up.set(0,a[f],0),r.lookAt(s[f],0,0)):1===t?(r.up.set(0,0,a[f]),r.lookAt(0,s[f],0)):(r.up.set(0,a[f],0),r.lookAt(0,0,s[f]));let n=this._cubeSize;uM(i,t*n,f>2?n:0,n,n),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Jh||e.mapping===Qh;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=tae()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=eae());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new Ge(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;uM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,xN)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let t=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),n=Jse[(i-1)%Jse.length];this._blur(e,i-1,i,t,n)}t.autoClear=n}_blur(e,t,n,i,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");let h=new Ge(this._lodPlanes[i],l),c=l.uniforms,u=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/(2*jf-1),p=r/d,f=isFinite(r)?1+Math.floor(3*p):jf;f>jf&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${jf}`);let m=[],g=0;for(let x=0;x<jf;++x){let e=x/p,t=Math.exp(-e*e/2);m.push(t),0===x?g+=t:x<f&&(g+=2*t)}for(let x=0;x<m.length;x++)m[x]=m[x]/g;c.envMap.value=e.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===a,s&&(c.poleAxis.value=s);let{_lodMax:v}=this;c.dTheta.value=d,c.mipInt.value=v-n;let y=this._sizeLods[i];uM(t,3*y*(i>v-Fg?i-v+Fg:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,xN)}};function MQe(e){let t=[],n=[],i=[],r=e,a=e-Fg+1+Zse.length;for(let s=0;s<a;s++){let a=Math.pow(2,r);n.push(a);let o=1/a;s>e-Fg?o=Zse[s-e+Fg-1]:0===s&&(o=0),i.push(o);let l=1/(a-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){let t=e%3*2/3-1,n=e>2?0:-1,i=[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];v.set(i,f*p*e),y.set(u,m*p*e);let r=[e,e,e,e,e,e];x.set(r,g*p*e)}let _=new et;_.setAttribute("position",new Ct(v,f)),_.setAttribute("uv",new Ct(y,m)),_.setAttribute("faceIndex",new Ct(x,g)),t.push(_),r>Fg&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function Qse(e,t,n){let i=new Sn(e,t,n);return i.texture.mapping=tv,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function uM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function SQe(e,t,n){let i=new Float32Array(jf),r=new M(0,1,0);return new It({name:"SphericalGaussianBlur",defines:{n:jf,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:OB(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:yr,depthTest:!1,depthWrite:!1})}function eae(){return new It({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:OB(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:yr,depthTest:!1,depthWrite:!1})}function tae(){return new It({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:OB(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:yr,depthTest:!1,depthWrite:!1})}function OB(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function RQe(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=a===Jf||a===Bx,o=a===Jh||a===Qh;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Hu(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{let a=r.image;if(s&&a&&a.height>0||o&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new Hu(e));let a=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function AQe(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){let t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function CQe(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;null!==o.index&&t.remove(o.index);for(let n in o.attributes)t.remove(o.attributes[n]);o.removeEventListener("dispose",s),delete r[o.id];let l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){let n=[],i=e.index,r=e.attributes.position,s=0;if(null!==i){let e=i.array;s=i.version;for(let t=0,i=e.length;t<i;t+=3){let i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{let e=r.array;s=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){let e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}let o=new($oe(n)?Gx:Qf)(n,1);o.version=s;let l=a.get(e);l&&t.remove(l),a.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,n.memory.geometries++),t},update:function(n){let i=n.attributes;for(let a in i)t.update(i[a],e.ARRAY_BUFFER);let r=n.morphAttributes;for(let a in r){let n=r[a];for(let i=0,r=n.length;i<r;i++)t.update(n[i],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){let t=a.get(e);if(t){let n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return a.get(e)}}}function PQe(e,t,n,i){let r,a,s,o=i.isWebGL2;this.setMode=function(e){r=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,i){e.drawElements(r,i,a,t*s),n.update(i,r,1)},this.renderInstances=function(i,l,h){if(0===h)return;let c,u;if(o)c=e,u="drawElementsInstanced";else if(c=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](r,l,a,i*s,h),n.update(l,r,h)}}function IQe(e){let t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function DQe(e,t){return e[0]-t[0]}function LQe(e,t){return Math.abs(t[1])-Math.abs(e[1])}function OQe(e,t,n){let i={},r=new Float32Array(8),a=new WeakMap,s=new Mn,o=[];for(let l=0;l<8;l++)o[l]=[l,0];return{update:function(l,h,c){let u=l.morphTargetInfluences;if(!0===t.isWebGL2){let i=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,r=void 0!==i?i.length:0,o=a.get(h);if(void 0===o||o.count!==r){let e=function(){v.dispose(),a.delete(h),h.removeEventListener("dispose",e)};void 0!==o&&o.texture.dispose();let n=void 0!==h.morphAttributes.position,i=void 0!==h.morphAttributes.normal,l=void 0!==h.morphAttributes.color,c=h.morphAttributes.position||[],u=h.morphAttributes.normal||[],d=h.morphAttributes.color||[],p=0;!0===n&&(p=1),!0===i&&(p=2),!0===l&&(p=3);let f=h.attributes.position.count*p,m=1;f>t.maxTextureSize&&(m=Math.ceil(f/t.maxTextureSize),f=t.maxTextureSize);let g=new Float32Array(f*m*4*r),v=new Gg(g,f,m,r);v.type=Bs,v.needsUpdate=!0;let y=4*p;for(let t=0;t<r;t++){let e=c[t],r=u[t],a=d[t],o=f*m*4*t;for(let t=0;t<e.count;t++){let h=t*y;!0===n&&(s.fromBufferAttribute(e,t),g[o+h+0]=s.x,g[o+h+1]=s.y,g[o+h+2]=s.z,g[o+h+3]=0),!0===i&&(s.fromBufferAttribute(r,t),g[o+h+4]=s.x,g[o+h+5]=s.y,g[o+h+6]=s.z,g[o+h+7]=0),!0===l&&(s.fromBufferAttribute(a,t),g[o+h+8]=s.x,g[o+h+9]=s.y,g[o+h+10]=s.z,g[o+h+11]=4===a.itemSize?s.w:1)}}o={count:r,texture:v,size:new Q(f,m)},a.set(h,o),h.addEventListener("dispose",e)}let l=0;for(let e=0;e<u.length;e++)l+=u[e];let d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(e,"morphTargetBaseInfluence",d),c.getUniforms().setValue(e,"morphTargetInfluences",u),c.getUniforms().setValue(e,"morphTargetsTexture",o.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",o.size)}else{let t=void 0===u?0:u.length,n=i[h.id];if(void 0===n||n.length!==t){n=[];for(let e=0;e<t;e++)n[e]=[e,0];i[h.id]=n}for(let e=0;e<t;e++){let t=n[e];t[0]=e,t[1]=u[e]}n.sort(LQe);for(let e=0;e<8;e++)e<t&&n[e][1]?(o[e][0]=n[e][0],o[e][1]=n[e][1]):(o[e][0]=Number.MAX_SAFE_INTEGER,o[e][1]=0);o.sort(DQe);let a=h.morphAttributes.position,s=h.morphAttributes.normal,l=0;for(let e=0;e<8;e++){let t=o[e],n=t[0],i=t[1];n!==Number.MAX_SAFE_INTEGER&&i?(a&&h.getAttribute("morphTarget"+e)!==a[n]&&h.setAttribute("morphTarget"+e,a[n]),s&&h.getAttribute("morphNormal"+e)!==s[n]&&h.setAttribute("morphNormal"+e,s[n]),r[e]=i,l+=i):(a&&!0===h.hasAttribute("morphTarget"+e)&&h.deleteAttribute("morphTarget"+e),s&&!0===h.hasAttribute("morphNormal"+e)&&h.deleteAttribute("morphNormal"+e),r[e]=0)}let d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(e,"morphTargetBaseInfluence",d),c.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function NQe(e,t,n,i){let r=new WeakMap;function a(e){let t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){let o=i.render.frame,l=s.geometry,h=t.get(s,l);return r.get(h)!==o&&(t.update(h),r.set(h,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER)),h},dispose:function(){r=new WeakMap}}}var Qoe=new ur,ele=new Gg,tle=new zx,nle=new ep,nae=[],rae=[],iae=new Float32Array(16),sae=new Float32Array(9),aae=new Float32Array(4);function sv(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,a=nae[r];if(void 0===a&&(a=new Float32Array(r),nae[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ui(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Bi(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function xS(e,t){let n=rae[t];void 0===n&&(n=new Int32Array(t),rae[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function UQe(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function BQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ui(n,t))return;e.uniform2fv(this.addr,t),Bi(n,t)}}function FQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(Ui(n,t))return;e.uniform3fv(this.addr,t),Bi(n,t)}}function HQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ui(n,t))return;e.uniform4fv(this.addr,t),Bi(n,t)}}function kQe(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ui(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Bi(n,t)}else{if(Ui(n,i))return;aae.set(i),e.uniformMatrix2fv(this.addr,!1,aae),Bi(n,i)}}function VQe(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ui(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Bi(n,t)}else{if(Ui(n,i))return;sae.set(i),e.uniformMatrix3fv(this.addr,!1,sae),Bi(n,i)}}function zQe(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ui(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Bi(n,t)}else{if(Ui(n,i))return;iae.set(i),e.uniformMatrix4fv(this.addr,!1,iae),Bi(n,i)}}function GQe(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function qQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ui(n,t))return;e.uniform2iv(this.addr,t),Bi(n,t)}}function WQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ui(n,t))return;e.uniform3iv(this.addr,t),Bi(n,t)}}function jQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ui(n,t))return;e.uniform4iv(this.addr,t),Bi(n,t)}}function XQe(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function YQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(Ui(n,t))return;e.uniform2uiv(this.addr,t),Bi(n,t)}}function $Qe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(Ui(n,t))return;e.uniform3uiv(this.addr,t),Bi(n,t)}}function ZQe(e,t){let n=this.cache;if(void 0!==t.x)(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(Ui(n,t))return;e.uniform4uiv(this.addr,t),Bi(n,t)}}function KQe(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2D(t||Qoe,r)}function JQe(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||tle,r)}function QQe(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||nle,r)}function eet(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||ele,r)}function tet(e){switch(e){case 5126:return UQe;case 35664:return BQe;case 35665:return FQe;case 35666:return HQe;case 35674:return kQe;case 35675:return VQe;case 35676:return zQe;case 5124:case 35670:return GQe;case 35667:case 35671:return qQe;case 35668:case 35672:return WQe;case 35669:case 35673:return jQe;case 5125:return XQe;case 36294:return YQe;case 36295:return $Qe;case 36296:return ZQe;case 35678:case 36198:case 36298:case 36306:case 35682:return KQe;case 35679:case 36299:case 36307:return JQe;case 35680:case 36300:case 36308:case 36293:return QQe;case 36289:case 36303:case 36311:case 36292:return eet}}function net(e,t){e.uniform1fv(this.addr,t)}function ret(e,t){let n=sv(t,this.size,2);e.uniform2fv(this.addr,n)}function iet(e,t){let n=sv(t,this.size,3);e.uniform3fv(this.addr,n)}function set(e,t){let n=sv(t,this.size,4);e.uniform4fv(this.addr,n)}function aet(e,t){let n=sv(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function oet(e,t){let n=sv(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function cet(e,t){let n=sv(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function uet(e,t){e.uniform1iv(this.addr,t)}function het(e,t){e.uniform2iv(this.addr,t)}function det(e,t){e.uniform3iv(this.addr,t)}function fet(e,t){e.uniform4iv(this.addr,t)}function pet(e,t){e.uniform1uiv(this.addr,t)}function met(e,t){e.uniform2uiv(this.addr,t)}function get(e,t){e.uniform3uiv(this.addr,t)}function vet(e,t){e.uniform4uiv(this.addr,t)}function xet(e,t,n){let i=this.cache,r=t.length,a=xS(n,r);Ui(i,a)||(e.uniform1iv(this.addr,a),Bi(i,a));for(let s=0;s!==r;++s)n.setTexture2D(t[s]||Qoe,a[s])}function yet(e,t,n){let i=this.cache,r=t.length,a=xS(n,r);Ui(i,a)||(e.uniform1iv(this.addr,a),Bi(i,a));for(let s=0;s!==r;++s)n.setTexture3D(t[s]||tle,a[s])}function Eet(e,t,n){let i=this.cache,r=t.length,a=xS(n,r);Ui(i,a)||(e.uniform1iv(this.addr,a),Bi(i,a));for(let s=0;s!==r;++s)n.setTextureCube(t[s]||nle,a[s])}function bet(e,t,n){let i=this.cache,r=t.length,a=xS(n,r);Ui(i,a)||(e.uniform1iv(this.addr,a),Bi(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(t[s]||ele,a[s])}function _et(e){switch(e){case 5126:return net;case 35664:return ret;case 35665:return iet;case 35666:return set;case 35674:return aet;case 35675:return oet;case 35676:return cet;case 5124:case 35670:return uet;case 35667:case 35671:return het;case 35668:case 35672:return det;case 35669:case 35673:return fet;case 5125:return pet;case 36294:return met;case 36295:return get;case 36296:return vet;case 35678:case 36198:case 36298:case 36306:case 35682:return xet;case 35679:case 36299:case 36307:return yet;case 35680:case 36300:case 36308:case 36293:return Eet;case 36289:case 36303:case 36311:case 36292:return bet}}var vU=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=tet(t.type)}},xU=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=_et(t.type)}},yU=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,a=i.length;r!==a;++r){let a=i[r];a.setValue(e,t[a.id],n)}}},EN=/(\w+)(\])?(\[|\.)?/g;function oae(e,t){e.seq.push(t),e.map[t.id]=t}function Tet(e,t,n){let i=e.name,r=i.length;for(EN.lastIndex=0;;){let a=EN.exec(i),s=EN.lastIndex,o=a[1],l="]"===a[2],h=a[3];if(l&&(o|=0),void 0===h||"["===h&&s+2===r){oae(n,void 0===h?new vU(o,e,t):new xU(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new yU(o),oae(n,e)),n=e}}}var Vg=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let n=e.getActiveUniform(t,i);Tet(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){let r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){let a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let r=e[i];r.id in t&&n.push(r)}return n}};function lae(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var wet=0;function Met(e,t){let n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let s=r;s<a;s++){let e=s+1;i.push(`${e===t?">":" "} ${e}: ${n[s]}`)}return i.join("\n")}function Ret(e){switch(e){case ks:return["Linear","( value )"];case St:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function cae(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+Met(e.getShaderSource(t),i)}return r}function Aet(e,t){let n=Ret(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Cet(e,t){let n;switch(t){case Toe:n="Linear";break;case woe:n="Reinhard";break;case Moe:n="OptimizedCineon";break;case Soe:n="ACESFilmic";break;case Roe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Pet(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ix).join("\n")}function Iet(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}function Det(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let i=e.getActiveAttrib(t,r),a=i.name,s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:s}}return n}function Ix(e){return""!==e}function uae(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function hae(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var Let=/^[ \t]*#include +<([\w\d./]+)>/gm;function EU(e){return e.replace(Let,Oet)}function Oet(e,t){let n=Pn[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return EU(n)}var Net=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function dae(e){return e.replace(Net,Uet)}function Uet(e,t,n,i){let r="";for(let a=parseInt(t);a<parseInt(n);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function fae(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Bet(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===RB?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===Kg?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===dc&&(t="SHADOWMAP_TYPE_VSM"),t}function Fet(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Jh:case Qh:t="ENVMAP_TYPE_CUBE";break;case tv:t="ENVMAP_TYPE_CUBE_UV"}return t}function Het(e){let t="ENVMAP_MODE_REFLECTION";return e.envMap&&e.envMapMode===Qh&&(t="ENVMAP_MODE_REFRACTION"),t}function ket(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case dy:t="ENVMAP_BLENDING_MULTIPLY";break;case boe:t="ENVMAP_BLENDING_MIX";break;case _oe:t="ENVMAP_BLENDING_ADD"}return t}function Vet(e){let t=e.envMapCubeUVHeight;if(null===t)return null;let n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function zet(e,t,n,i){let r,a,s=e.getContext(),o=n.defines,l=n.vertexShader,h=n.fragmentShader,c=Bet(n),u=Fet(n),d=Het(n),p=ket(n),f=Vet(n),m=n.isWebGL2?"":Pet(n),g=Iet(o),v=s.createProgram(),y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(r=[g].filter(Ix).join("\n"),r.length>0&&(r+="\n"),a=[m,g].filter(Ix).join("\n"),a.length>0&&(a+="\n")):(r=[fae(n),"#define SHADER_NAME "+n.shaderName,g,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ix).join("\n"),a=[m,fae(n),"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+p:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==fc?"#define TONE_MAPPING":"",n.toneMapping!==fc?Pn.tonemapping_pars_fragment:"",n.toneMapping!==fc?Cet("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Pn.encodings_pars_fragment,Aet("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ix).join("\n")),l=EU(l),l=uae(l,n),l=hae(l,n),h=EU(h),h=uae(h,n),h=hae(h,n),l=dae(l),h=dae(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",r=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,a=["#define varying in",n.glslVersion===sU?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===sU?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+a);let x,_,b=y+r+l,M=y+a+h,w=lae(s,s.VERTEX_SHADER,b),S=lae(s,s.FRAGMENT_SHADER,M);if(s.attachShader(v,w),s.attachShader(v,S),void 0!==n.index0AttributeName?s.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){let t=s.getProgramInfoLog(v).trim(),n=s.getShaderInfoLog(w).trim(),i=s.getShaderInfoLog(S).trim(),o=!0,l=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS))if(o=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(s,v,w,S);else{let e=cae(s,w,"vertex"),n=cae(s,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):(""===n||""===i)&&(l=!1);l&&(this.diagnostics={runnable:o,programLog:t,vertexShader:{log:n,prefix:r},fragmentShader:{log:i,prefix:a}})}return s.deleteShader(w),s.deleteShader(S),this.getUniforms=function(){return void 0===x&&(x=new Vg(s,v)),x},this.getAttributes=function(){return void 0===_&&(_=Det(s,v)),_},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.name=n.shaderName,this.id=wet++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=w,this.fragmentShader=S,this}var Get=0,bU=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,0===n.usedTimes&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new _U(e),t.set(e,n)),n}},_U=class{constructor(e){this.id=Get++,this.code=e,this.usedTimes=0}};function qet(e,t,n,i,r,a,s){let o=new qg,l=new bU,h=[],c=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures,p=r.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return 1===e?"uv1":2===e?"uv2":3===e?"uv3":"uv"}return{getParameters:function(a,o,h,g,v){let y=g.fog,x=v.geometry,_=a.isMeshStandardMaterial?g.environment:null,b=(a.isMeshStandardMaterial?n:t).get(a.envMap||_),M=b&&b.mapping===tv?b.image.height:null,w=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));let S,E,T,A,C=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,R=void 0!==C?C.length:0,P=0;if(void 0!==x.morphAttributes.position&&(P=1),void 0!==x.morphAttributes.normal&&(P=2),void 0!==x.morphAttributes.color&&(P=3),w){let e=_l[w];S=e.vertexShader,E=e.fragmentShader}else S=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let L=e.getRenderTarget(),D=!0===v.isInstancedMesh,I=!!a.map,O=!!a.matcap,U=!!b,N=!!a.aoMap,F=!!a.lightMap,k=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,V=!!a.emissiveMap,H=!!a.metalnessMap,G=!!a.roughnessMap,j=a.clearcoat>0,W=a.iridescence>0,X=a.sheen>0,q=a.transmission>0,Y=j&&!!a.clearcoatMap,$=j&&!!a.clearcoatNormalMap,K=j&&!!a.clearcoatRoughnessMap,Z=W&&!!a.iridescenceMap,J=W&&!!a.iridescenceThicknessMap,Q=X&&!!a.sheenColorMap,ee=X&&!!a.sheenRoughnessMap,te=!!a.specularMap,ne=!!a.specularColorMap,ie=!!a.specularIntensityMap,re=q&&!!a.transmissionMap,ae=q&&!!a.thicknessMap,se=!!a.gradientMap,oe=!!a.alphaMap,le=a.alphaTest>0,he=!!a.extensions,ce=!!x.attributes.uv1,ue=!!x.attributes.uv2,de=!!x.attributes.uv3;return{isWebGL2:c,shaderID:w,shaderName:a.type,vertexShader:S,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:D,instancingColor:D&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:ks,map:I,matcap:O,envMap:U,envMapMode:U&&b.mapping,envMapCubeUVHeight:M,aoMap:N,lightMap:F,bumpMap:k,normalMap:B,displacementMap:d&&z,emissiveMap:V,normalMapObjectSpace:B&&a.normalMapType===Woe,normalMapTangentSpace:B&&a.normalMapType===cd,metalnessMap:H,roughnessMap:G,clearcoat:j,clearcoatMap:Y,clearcoatNormalMap:$,clearcoatRoughnessMap:K,iridescence:W,iridescenceMap:Z,iridescenceThicknessMap:J,sheen:X,sheenColorMap:Q,sheenRoughnessMap:ee,specularMap:te,specularColorMap:ne,specularIntensityMap:ie,transmission:q,transmissionMap:re,thicknessMap:ae,gradientMap:se,opaque:!1===a.transparent&&a.blending===Zf,alphaMap:oe,alphaTest:le,combine:a.combine,mapUv:I&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:F&&m(a.lightMap.channel),bumpMapUv:k&&m(a.bumpMap.channel),normalMapUv:B&&m(a.normalMap.channel),displacementMapUv:z&&m(a.displacementMap.channel),emissiveMapUv:V&&m(a.emissiveMap.channel),metalnessMapUv:H&&m(a.metalnessMap.channel),roughnessMapUv:G&&m(a.roughnessMap.channel),clearcoatMapUv:Y&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:$&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:K&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:J&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:Q&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:ee&&m(a.sheenRoughnessMap.channel),specularMapUv:te&&m(a.specularMap.channel),specularColorMapUv:ne&&m(a.specularColorMap.channel),specularIntensityMapUv:ie&&m(a.specularIntensityMap.channel),transmissionMapUv:re&&m(a.transmissionMap.channel),thicknessMapUv:ae&&m(a.thicknessMap.channel),alphaMapUv:oe&&m(a.alphaMap.channel),vertexTangents:B&&!!x.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:ce,vertexUv2s:ue,vertexUv3s:de,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(I||oe),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:R,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:fc,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===tr,flipSided:a.side===ri,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:he&&!0===a.extensions.derivatives,extensionFragDepth:he&&!0===a.extensions.fragDepth,extensionDrawBuffers:he&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:he&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||i.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=_l[n];t=Lr.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i;for(let e=0,r=h.length;e<r;e++){let t=h[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new zet(e,n,t,a),h.push(i)),i},releaseProgram:function(e){if(0==--e.usedTimes){let t=h.indexOf(e);h[t]=h[h.length-1],h.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:h,dispose:function(){l.dispose()}}}function Wet(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function jet(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function pae(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function mae(){let e=[],t=0,n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n<i;n++){let t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||jet),i.length>1&&i.sort(t||pae),r.length>1&&r.sort(t||pae)}}}function Xet(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new mae,e.set(t,[i])):n>=r.length?(i=new mae,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Yet(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new M,color:new Ie};break;case"SpotLight":n={position:new M,direction:new M,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new M,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":n={direction:new M,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":n={color:new Ie,position:new M,halfWidth:new M,halfHeight:new M}}return e[t.id]=n,n}}}function $et(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var Zet=0;function Ket(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Jet(e,t){let n=new Yet,i=$et(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let l=0;l<9;l++)r.probe.push(new M);let a=new M,s=new Ae,o=new Ae;return{setup:function(a,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;a.sort(Ket);let _=!0===s?Math.PI:1;for(let e=0,t=a.length;e<t;e++){let t=a[e],s=t.color,b=t.intensity,M=t.distance,w=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)o+=s.r*b*_,l+=s.g*b*_,h+=s.b*b*_;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],b);else if(t.isDirectionalLight){let e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*_),t.castShadow){let e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,r.directionalShadow[c]=n,r.directionalShadowMap[c]=w,r.directionalShadowMatrix[c]=t.shadow.matrix,m++}r.directional[c]=e,c++}else if(t.isSpotLight){let e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(s).multiplyScalar(b*_),e.distance=M,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,r.spot[d]=e;let a=t.shadow;if(t.map&&(r.spotLightMap[y]=t.map,y++,a.updateMatrices(t),t.castShadow&&x++),r.spotLightMatrix[d]=a.matrix,t.castShadow){let e=i.get(t);e.shadowBias=a.bias,e.shadowNormalBias=a.normalBias,e.shadowRadius=a.radius,e.shadowMapSize=a.mapSize,r.spotShadow[d]=e,r.spotShadowMap[d]=w,v++}d++}else if(t.isRectAreaLight){let e=n.get(t);e.color.copy(s).multiplyScalar(b),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[p]=e,p++}else if(t.isPointLight){let e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*_),e.distance=t.distance,e.decay=t.decay,t.castShadow){let e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,r.pointShadow[u]=n,r.pointShadowMap[u]=w,r.pointShadowMatrix[u]=t.shadow.matrix,g++}r.point[u]=e,u++}else if(t.isHemisphereLight){let e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(b*_),e.groundColor.copy(t.groundColor).multiplyScalar(b*_),r.hemi[f]=e,f++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=gt.LTC_FLOAT_1,r.rectAreaLTC2=gt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=gt.LTC_HALF_1,r.rectAreaLTC2=gt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=h;let b=r.hash;(b.directionalLength!==c||b.pointLength!==u||b.spotLength!==d||b.rectAreaLength!==p||b.hemiLength!==f||b.numDirectionalShadows!==m||b.numPointShadows!==g||b.numSpotShadows!==v||b.numSpotMaps!==y)&&(r.directional.length=c,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+y-x,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=x,b.directionalLength=c,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=f,b.numDirectionalShadows=m,b.numPointShadows=g,b.numSpotShadows=v,b.numSpotMaps=y,r.version=Zet++)},setupView:function(e,t){let n=0,i=0,l=0,h=0,c=0,u=t.matrixWorldInverse;for(let d=0,p=e.length;d<p;d++){let t=e[d];if(t.isDirectionalLight){let e=r.directional[n];e.direction.setFromMatrixPosition(t.matrixWorld),a.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),n++}else if(t.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(t.matrixWorld),a.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),l++}else if(t.isRectAreaLight){let e=r.rectArea[h];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),o.identity(),s.copy(t.matrixWorld),s.premultiply(u),o.extractRotation(s),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),h++}else if(t.isPointLight){let e=r.point[i];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),i++}else if(t.isHemisphereLight){let e=r.hemi[c];e.direction.setFromMatrixPosition(t.matrixWorld),e.direction.transformDirection(u),c++}}},state:r}}function gae(e,t){let n=new Jet(e,t),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(e){n.setup(i,e)},setupLightsView:function(e){n.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){r.push(e)}}}function Qet(e,t){let n=new WeakMap;return{get:function(i,r=0){let a,s=n.get(i);return void 0===s?(a=new gae(e,t),n.set(i,[a])):r>=s.length?(a=new gae(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}var ku=class extends Rn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qoe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},qx=class extends Rn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},ett="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",ttt="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function ntt(e,t,n){let i=new ps,r=new Q,a=new Q,s=new Mn,o=new ku({depthPacking:rv}),l=new qx,h={},c=n.maxTextureSize,u={[Tr]:ri,[ri]:Tr,[tr]:tr},d=new It({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},radius:{value:4}},vertexShader:ett,fragmentShader:ttt}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new et;f.setAttribute("position",new Ct(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Ge(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=RB;let v=this.type;function y(n,i){let a=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Sn(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,p,m,null)}function x(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,i=h[e];void 0===i&&(i={},h[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=r===dc?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function _(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===dc)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let i=t.update(n),r=n.material;if(Array.isArray(r)){let t=i.groups;for(let l=0,h=t.length;l<h;l++){let h=t[l],c=r[h.materialIndex];if(c&&c.visible){let t=x(n,c,s,o);e.renderBufferDirect(a,null,i,t,n,h)}}}else if(r.visible){let t=x(n,r,s,o);e.renderBufferDirect(a,null,i,t,n,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],r,a,s,o)}this.render=function(t,n,o){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===t.length)return;let l=e.getRenderTarget(),h=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(yr),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);let p=v!==dc&&this.type===dc,f=v===dc&&this.type!==dc;for(let m=0,g=t.length;m<g;m++){let l=t[m],h=l.shadow;if(void 0===h){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);let u=h.getFrameExtents();if(r.multiply(u),a.copy(h.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/u.x),r.x=a.x*u.x,h.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/u.y),r.y=a.y*u.y,h.mapSize.y=a.y)),null===h.map||!0===p||!0===f){let e=this.type!==dc?{minFilter:cr,magFilter:cr}:{};null!==h.map&&h.map.dispose(),h.map=new Sn(r.x,r.y,e),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();let g=h.getViewportCount();for(let e=0;e<g;e++){let t=h.getViewport(e);s.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),d.viewport(s),h.updateMatrices(l,e),i=h.getFrustum(),_(n,o,h.camera,l,this.type)}!0!==h.isPointLightShadow&&this.type===dc&&y(h,o),h.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,h,u)}}function rtt(e,t,n){let i=n.isWebGL2,r=new function(){let t=!1,n=new Mn,i=null,r=new Mn(0,0,0,0);return{setMask:function(n){i!==n&&!t&&(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,s,o){!0===o&&(t*=s,i*=s,a*=s),n.set(t,i,a,s),!1===r.equals(n)&&(e.clearColor(t,i,a,s),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},a=new function(){let t=!1,n=null,i=null,r=null;return{setTest:function(t){t?z(e.DEPTH_TEST):V(e.DEPTH_TEST)},setMask:function(i){n!==i&&!t&&(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case poe:e.depthFunc(e.NEVER);break;case moe:e.depthFunc(e.ALWAYS);break;case goe:e.depthFunc(e.LESS);break;case HM:e.depthFunc(e.LEQUAL);break;case voe:e.depthFunc(e.EQUAL);break;case xoe:e.depthFunc(e.GEQUAL);break;case yoe:e.depthFunc(e.GREATER);break;case Eoe:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},s=new function(){let t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,h=null;return{setTest:function(n){t||(n?z(e.STENCIL_TEST):V(e.STENCIL_TEST))},setMask:function(i){n!==i&&!t&&(e.stencilMask(i),n=i)},setFunc:function(t,n,s){(i!==t||r!==n||a!==s)&&(e.stencilFunc(t,n,s),i=t,r=n,a=s)},setOp:function(t,n,i){(s!==t||o!==n||l!==i)&&(e.stencilOp(t,n,i),s=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,h=null}}},o=new WeakMap,l=new WeakMap,h={},c={},u=new WeakMap,d=[],p=null,f=!1,m=null,g=null,v=null,y=null,x=null,_=null,b=null,M=!1,w=null,S=null,E=null,T=null,A=null,C=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),R=!1,P=0,L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(L)[1]),R=P>=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),R=P>=2);let D=null,I={},O=e.getParameter(e.SCISSOR_BOX),U=e.getParameter(e.VIEWPORT),N=(new Mn).fromArray(O),F=(new Mn).fromArray(U);function k(t,n,r,a){let s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;l<r;l++)!i||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(n+l,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage3D(n,0,e.RGBA,1,1,a,0,e.RGBA,e.UNSIGNED_BYTE,s);return o}let B={};function z(t){!0!==h[t]&&(e.enable(t),h[t]=!0)}function V(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}B[e.TEXTURE_2D]=k(e.TEXTURE_2D,e.TEXTURE_2D,1),B[e.TEXTURE_CUBE_MAP]=k(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(B[e.TEXTURE_2D_ARRAY]=k(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),B[e.TEXTURE_3D]=k(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),r.setClear(0,0,0,1),a.setClear(1),s.setClear(0),z(e.DEPTH_TEST),a.setFunc(HM),W(!1),X(IN),z(e.CULL_FACE),j(yr);let H={[Us]:e.FUNC_ADD,[ooe]:e.FUNC_SUBTRACT,[loe]:e.FUNC_REVERSE_SUBTRACT};if(i)H[ON]=e.MIN,H[NN]=e.MAX;else{let e=t.get("EXT_blend_minmax");null!==e&&(H[ON]=e.MIN_EXT,H[NN]=e.MAX_EXT)}let G={[ld]:e.ZERO,[Jg]:e.ONE,[coe]:e.SRC_COLOR,[hy]:e.SRC_ALPHA,[foe]:e.SRC_ALPHA_SATURATE,[ev]:e.DST_COLOR,[Qg]:e.DST_ALPHA,[uoe]:e.ONE_MINUS_SRC_COLOR,[AB]:e.ONE_MINUS_SRC_ALPHA,[doe]:e.ONE_MINUS_DST_COLOR,[hoe]:e.ONE_MINUS_DST_ALPHA};function j(t,n,i,r,a,s,o,l){if(t!==yr){if(!1===f&&(z(e.BLEND),f=!0),t===$u)a=a||n,s=s||i,o=o||r,(n!==g||a!==x)&&(e.blendEquationSeparate(H[n],H[a]),g=n,x=a),(i!==v||r!==y||s!==_||o!==b)&&(e.blendFuncSeparate(G[i],G[r],G[s],G[o]),v=i,y=r,_=s,b=o),m=t,M=!1;else if(t!==m||l!==M){if((g!==Us||x!==Us)&&(e.blendEquation(e.FUNC_ADD),g=Us,x=Us),l)switch(t){case Zf:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ou:e.blendFunc(e.ONE,e.ONE);break;case DN:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case LN:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case Zf:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ou:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case DN:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case LN:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,_=null,b=null,m=t,M=l}}else!0===f&&(V(e.BLEND),f=!1)}function W(t){w!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),w=t)}function X(t){t!==soe?(z(e.CULL_FACE),t!==S&&(t===IN?e.cullFace(e.BACK):t===aoe?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):V(e.CULL_FACE),S=t}function q(t,n,i){t?(z(e.POLYGON_OFFSET_FILL),(T!==n||A!==i)&&(e.polygonOffset(n,i),T=n,A=i)):V(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:a,stencil:s},enable:z,disable:V,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,i&&(t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(i,r){let a=d,s=!1;if(i)if(a=u.get(r),void 0===a&&(a=[],u.set(r,a)),i.isWebGLMultipleRenderTargets){let t=i.texture;if(a.length!==t.length||a[0]!==e.COLOR_ATTACHMENT0){for(let n=0,i=t.length;n<i;n++)a[n]=e.COLOR_ATTACHMENT0+n;a.length=t.length,s=!0}}else a[0]!==e.COLOR_ATTACHMENT0&&(a[0]=e.COLOR_ATTACHMENT0,s=!0);else a[0]!==e.BACK&&(a[0]=e.BACK,s=!0);s&&(n.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:j,setMaterial:function(t,n){t.side===tr?V(e.CULL_FACE):z(e.CULL_FACE);let i=t.side===ri;n&&(i=!i),W(i),t.blending===Zf&&!1===t.transparent?j(yr):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),r.setMask(t.colorWrite);let o=t.stencilWrite;s.setTest(o),o&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?z(e.SAMPLE_ALPHA_TO_COVERAGE):V(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:W,setCullFace:X,setLineWidth:function(t){t!==E&&(R&&e.lineWidth(t),E=t)},setPolygonOffset:q,setScissorTest:function(t){t?z(e.SCISSOR_TEST):V(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+C-1),D!==t&&(e.activeTexture(t),D=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===D?e.TEXTURE0+C-1:D);let r=I[i];void 0===r&&(r={type:void 0,texture:void 0},I[i]=r),(r.type!==t||r.texture!==n)&&(D!==i&&(e.activeTexture(i),D=i),e.bindTexture(t,n||B[t]),r.type=t,r.texture=n)},unbindTexture:function(){let t=I[D];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let i=l.get(n);void 0===i&&(i=new WeakMap,l.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){let i=l.get(n).get(t);o.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),o.set(n,i))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===N.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),N.copy(t))},viewport:function(t){!1===F.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),F.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===i&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),h={},D=null,I={},c={},u=new WeakMap,d=[],p=null,f=!1,m=null,g=null,v=null,y=null,x=null,_=null,b=null,M=!1,w=null,S=null,E=null,T=null,A=null,N.set(0,0,e.canvas.width,e.canvas.height),F.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),s.reset()}}}function itt(e,t,n,i,r,a,s){let o,l=r.isWebGL2,h=r.maxTextures,c=r.maxCubemapSize,u=r.maxTextureSize,d=r.maxSamples,p=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,g=new WeakMap,v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):kx("canvas")}function x(e,t,n,i){let r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let i=t?Yoe:Math.floor,a=i(r*e.width),s=i(r*e.height);void 0===o&&(o=y(a,s));let l=n?y(a,s):o;return l.width=a,l.height=s,l.getContext("2d").drawImage(e,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+s+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function _(e){return aU(e.width)&&aU(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==cr&&e.minFilter!==Vn}function M(t){e.generateMipmap(t)}function w(n,i,r,a,s=!1){if(!1===l)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;return i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=a===St&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)),(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function S(e,t,n){return!0===b(e,n)||e.isFramebufferTexture&&e.minFilter!==cr&&e.minFilter!==Vn?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===cr||t===ed||t===Du?e.NEAREST:e.LINEAR}function T(e){let t=e.target;t.removeEventListener("dispose",T),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=g.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){let n=t.target;n.removeEventListener("dispose",A),function(t){let n=t.texture,r=i.get(t),a=i.get(n);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let i=0;i<6;i++)e.deleteFramebuffer(r.__webglFramebuffer[i]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[i]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t<r.__webglColorRenderbuffer.length;t++)r.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(r.__webglColorRenderbuffer[t]);r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let o=0,l=n.length;o<l;o++){let t=i.get(n[o]);t.__webglTexture&&(e.deleteTexture(t.__webglTexture),s.memory.textures--),i.remove(n[o])}i.remove(n),i.remove(t)}(n)}function C(t){let n=i.get(t);e.deleteTexture(n.__webglTexture);let r=t.source;delete g.get(r)[n.__cacheKey],s.memory.textures--}let R=0;function P(t,r){let a=i.get(t);if(t.isVideoTexture&&function(e){let t=s.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version){let e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void U(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}let L={[Nr]:e.REPEAT,[Or]:e.CLAMP_TO_EDGE,[Nu]:e.MIRRORED_REPEAT},D={[cr]:e.NEAREST,[ed]:e.NEAREST_MIPMAP_NEAREST,[Du]:e.NEAREST_MIPMAP_LINEAR,[Vn]:e.LINEAR,[vp]:e.LINEAR_MIPMAP_NEAREST,[Hs]:e.LINEAR_MIPMAP_LINEAR};function I(n,a,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,D[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,D[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==Or||a.wrapT!==Or)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==cr&&a.minFilter!==Vn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===cr||a.minFilter!==Du&&a.minFilter!==Hs||a.type===Bs&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===Ga&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function O(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));let r=n.source,a=g.get(r);void 0===a&&(a={},g.set(r,a));let o=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;let r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function U(t,r,s){let o=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(o=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(o=e.TEXTURE_3D);let h=O(t,r),c=r.source;n.bindTexture(o,t.__webglTexture,e.TEXTURE0+s);let d=i.get(c);if(c.version!==d.__version||!0===h){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=function(e){return!l&&(e.wrapS!==Or||e.wrapT!==Or||e.minFilter!==cr&&e.minFilter!==Vn)}(r)&&!1===_(r.image),i=x(r.image,t,!1,u);i=V(r,i);let p=_(i)||l,f=a.convert(r.format,r.colorSpace),m=a.convert(r.type),g=w(r.internalFormat,f,m,r.colorSpace);I(o,r,p);let v,y=r.mipmaps,E=l&&!0!==r.isVideoTexture,T=void 0===d.__version||!0===h,A=S(r,i,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===Bs?e.DEPTH_COMPONENT32F:r.type===Zh?e.DEPTH_COMPONENT24:r.type===Lu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===Bs&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Kh&&g===e.DEPTH_COMPONENT&&r.type!==fy&&r.type!==Zh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Zh,m=a.convert(r.type)),r.format===Uu&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==Lu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Lu,m=a.convert(r.type))),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,g,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,g,i.width,i.height,0,f,m,null));else if(r.isDataTexture)if(y.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t<i;t++)v=y[t],E?n.texSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,m,v.data):n.texImage2D(e.TEXTURE_2D,t,g,v.width,v.height,0,f,m,v.data);r.generateMipmaps=!1}else E?(T&&n.texStorage2D(e.TEXTURE_2D,A,g,i.width,i.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,f,m,i.data)):n.texImage2D(e.TEXTURE_2D,0,g,i.width,i.height,0,f,m,i.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){E&&T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,A,g,y[0].width,y[0].height,i.depth);for(let t=0,a=y.length;t<a;t++)v=y[t],r.format!==Ji?null!==f?E?n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,v.width,v.height,i.depth,f,v.data,0,0):n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,g,v.width,v.height,i.depth,0,v.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,v.width,v.height,i.depth,f,m,v.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,g,v.width,v.height,i.depth,0,f,m,v.data)}else{E&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t<i;t++)v=y[t],r.format!==Ji?null!==f?E?n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,v.data):n.compressedTexImage2D(e.TEXTURE_2D,t,g,v.width,v.height,0,v.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?n.texSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,m,v.data):n.texImage2D(e.TEXTURE_2D,t,g,v.width,v.height,0,f,m,v.data)}else if(r.isDataArrayTexture)E?(T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,A,g,i.width,i.height,i.depth),n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,f,m,i.data)):n.texImage3D(e.TEXTURE_2D_ARRAY,0,g,i.width,i.height,i.depth,0,f,m,i.data);else if(r.isData3DTexture)E?(T&&n.texStorage3D(e.TEXTURE_3D,A,g,i.width,i.height,i.depth),n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,i.width,i.height,i.depth,f,m,i.data)):n.texImage3D(e.TEXTURE_3D,0,g,i.width,i.height,i.depth,0,f,m,i.data);else if(r.isFramebufferTexture){if(T)if(E)n.texStorage2D(e.TEXTURE_2D,A,g,i.width,i.height);else{let t=i.width,r=i.height;for(let i=0;i<A;i++)n.texImage2D(e.TEXTURE_2D,i,g,t,r,0,f,m,null),t>>=1,r>>=1}}else if(y.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t<i;t++)v=y[t],E?n.texSubImage2D(e.TEXTURE_2D,t,0,0,f,m,v):n.texImage2D(e.TEXTURE_2D,t,g,f,m,v);r.generateMipmaps=!1}else E?(T&&n.texStorage2D(e.TEXTURE_2D,A,g,i.width,i.height),n.texSubImage2D(e.TEXTURE_2D,0,0,0,f,m,i)):n.texImage2D(e.TEXTURE_2D,0,g,f,m,i);b(r,p)&&M(o),d.__version=c.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function N(t,r,s,o,l){let h=a.convert(s.format,s.colorSpace),c=a.convert(s.type),u=w(s.internalFormat,h,c,s.colorSpace);i.get(r).__hasExternalTextures||(l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,0,u,r.width,r.height,r.depth,0,h,c,null):n.texImage2D(l,0,u,r.width,r.height,0,h,c,null)),n.bindFramebuffer(e.FRAMEBUFFER,t),z(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0,B(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||z(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Bs?r=e.DEPTH_COMPONENT32F:t.type===Zh&&(r=e.DEPTH_COMPONENT24));let i=B(n);z(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let r=B(n);i&&!1===z(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):z(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r<t.length;r++){let s=t[r],o=a.convert(s.format,s.colorSpace),l=a.convert(s.type),h=w(s.internalFormat,o,l,s.colorSpace),c=B(n);i&&!1===z(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,h,n.width,n.height):z(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,h,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,h,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function k(t){let r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(r.depthTexture).__webglTexture||r.depthTexture.image.width!==r.width||r.depthTexture.image.height!==r.height)&&(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),P(r.depthTexture,0);let a=i.get(r.depthTexture).__webglTexture,s=B(r);if(r.depthTexture.format===Kh)z(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Uu)throw new Error("Unknown depthTexture format");z(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=e.createRenderbuffer(),F(r.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),F(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(e.FRAMEBUFFER,null)}function B(e){return Math.min(d,e.samples)}function z(e){let n=i.get(e);return l&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function V(e,n){let i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||e.format===kM||i!==ks&&i!==mc&&(i===St?!1===l?!0===t.has("EXT_sRGB")&&r===Ji?(e.format=kM,e.minFilter=Vn,e.generateMipmaps=!1):n=Vx.sRGBToLinear(n):(r!==Ji||a!==gc)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){let e=R;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=P,this.setTexture2DArray=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?U(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?U(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){let s=i.get(t);t.version>0&&s.__version!==t.version?function(t,r,s){if(6!==r.image.length)return;let o=O(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=i.get(h);if(h.version!==u.__version||!0===o){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=V(r,d[e]);let p,f=d[0],m=_(f)||l,g=a.convert(r.format,r.colorSpace),v=a.convert(r.type),y=w(r.internalFormat,g,v,r.colorSpace),E=l&&!0!==r.isVideoTexture,T=void 0===u.__version||!0===o,A=S(r,f,m);if(I(e.TEXTURE_CUBE_MAP,r,m),t){E&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,f.width,f.height);for(let t=0;t<6;t++){p=d[t].mipmaps;for(let i=0;i<p.length;i++){let a=p[i];r.format!==Ji?null!==g?E?n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,g,a.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,y,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,g,v,a.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,y,a.width,a.height,0,g,v,a.data)}}}else{p=r.mipmaps,E&&T&&(p.length>0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,g,v,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,d[t].width,d[t].height,0,g,v,d[t].data);for(let i=0;i<p.length;i++){let r=p[i].image[t].image;E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,y,r.width,r.height,0,g,v,r.data)}}else{E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,d[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,g,v,d[t]);for(let i=0;i<p.length;i++){let r=p[i];E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,g,v,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,y,g,v,r.image[t])}}}b(r,m)&&M(e.TEXTURE_CUBE_MAP),u.__version=h.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(s,t,r):n.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+r)},this.rebindTextures=function(t,n,r){let a=i.get(t);void 0!==n&&N(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==r&&k(t)},this.setupRenderTarget=function(t){let o=t.texture,h=i.get(t),c=i.get(o);t.addEventListener("dispose",A),!0!==t.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=e.createTexture()),c.__version=o.version,s.memory.textures++);let u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=_(t)||l;if(u){h.__webglFramebuffer=[];for(let t=0;t<6;t++)h.__webglFramebuffer[t]=e.createFramebuffer()}else{if(h.__webglFramebuffer=e.createFramebuffer(),d)if(r.drawBuffers){let n=t.texture;for(let t=0,r=n.length;t<r;t++){let r=i.get(n[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&t.samples>0&&!1===z(t)){let i=d?o:[o];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let n=0;n<i.length;n++){let r=i[n];h.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,h.__webglColorRenderbuffer[n]);let s=a.convert(r.format,r.colorSpace),o=a.convert(r.type),l=w(r.internalFormat,s,o,r.colorSpace,!0===t.isXRRenderTarget),c=B(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,c,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,h.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(h.__webglDepthRenderbuffer=e.createRenderbuffer(),F(h.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),I(e.TEXTURE_CUBE_MAP,o,p);for(let n=0;n<6;n++)N(h.__webglFramebuffer[n],t,o,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n);b(o,p)&&M(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){let r=t.texture;for(let a=0,s=r.length;a<s;a++){let s=r[a],o=i.get(s);n.bindTexture(e.TEXTURE_2D,o.__webglTexture),I(e.TEXTURE_2D,s,p),N(h.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+a,e.TEXTURE_2D),b(s,p)&&M(e.TEXTURE_2D)}n.unbindTexture()}else{let i=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l?i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(i,c.__webglTexture),I(i,o,p),N(h.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0,i),b(o,p)&&M(i),n.unbindTexture()}t.depthBuffer&&k(t)},this.updateRenderTargetMipmap=function(t){let r=_(t)||l,a=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let s=0,o=a.length;s<o;s++){let o=a[s];if(b(o,r)){let r=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=i.get(o).__webglTexture;n.bindTexture(r,a),M(r),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(l&&t.samples>0&&!1===z(t)){let r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n<r.length;n++){l.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&l.push(h);let d=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;if(!1===d&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),u&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[n]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[h]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[h])),u){let t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),f&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,l)}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,c.__webglColorRenderbuffer[t]);let a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=k,this.setupFrameBufferTexture=N,this.useMultisampledRTT=z}function rle(e,t,n){let i=n.isWebGL2;return{convert:function(n,r=mc){let a;if(n===gc)return e.UNSIGNED_BYTE;if(n===Ioe)return e.UNSIGNED_SHORT_4_4_4_4;if(n===Doe)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Aoe)return e.BYTE;if(n===Coe)return e.SHORT;if(n===fy)return e.UNSIGNED_SHORT;if(n===Poe)return e.INT;if(n===Zh)return e.UNSIGNED_INT;if(n===Bs)return e.FLOAT;if(n===Ga)return i?e.HALF_FLOAT:(a=t.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(n===Loe)return e.ALPHA;if(n===Ji)return e.RGBA;if(n===mS)return e.LUMINANCE;if(n===Ooe)return e.LUMINANCE_ALPHA;if(n===Kh)return e.DEPTH_COMPONENT;if(n===Uu)return e.DEPTH_STENCIL;if(n===kM)return a=t.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(n===gS)return e.RED;if(n===Noe)return e.RED_INTEGER;if(n===Uoe)return e.RG;if(n===Boe)return e.RG_INTEGER;if(n===Foe)return e.RGBA_INTEGER;if(n===DM||n===LM||n===OM||n===NM)if(r===St){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===DM)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===LM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===OM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===NM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===DM)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===LM)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===OM)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===NM)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===UN||n===BN||n===FN||n===HN){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(n===UN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===BN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===FN)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===HN)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Hoe)return a=t.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===kN||n===VN){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(n===kN)return r===St?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===VN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(n===zN||n===GN||n===qN||n===WN||n===jN||n===XN||n===YN||n===$N||n===ZN||n===KN||n===JN||n===QN||n===eU||n===tU){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(n===zN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===GN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===WN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===jN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===XN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===YN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===$N)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ZN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===KN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===JN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===QN)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===eU)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===tU)return r===St?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===UM){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===UM)return r===St?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(n===koe||n===nU||n===rU||n===iU){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===UM)return a.COMPRESSED_RED_RGTC1_EXT;if(n===nU)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===rU)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===iU)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Lu?i?e.UNSIGNED_INT_24_8:(a=t.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}var GM=class extends bn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Nt=class extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}},stt={type:"move"},Ox=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Nt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Nt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Nt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&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}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null,s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){a=!0;for(let a of e.hand.values()){let e=t.getJointPose(a,n),i=this._getHandJoint(l,a);null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=null!==e}let i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position),o=.02,h=.005;l.inputState.pinching&&s>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(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));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(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,this.dispatchEvent(stt)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new Nt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},td=class extends ur{constructor(e,t,n,i,r,a,s,o,l,h){if((h=void 0!==h?h:Kh)!==Kh&&h!==Uu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===Kh&&(n=Zh),void 0===n&&h===Uu&&(n=Lu),super(null,i,r,a,s,o,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:cr,this.minFilter=void 0!==o?o:cr,this.flipY=!1,this.generateMipmaps=!1}},TU=class extends qa{constructor(e,t){super();let n=this,i=null,r=1,a=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,_=new Map,b=new bn;b.layers.enable(1),b.viewport=new Mn;let w=new bn;w.layers.enable(2),w.viewport=new Mn;let S=[b,w],E=new GM;E.layers.enable(1),E.layers.enable(2);let T=null,A=null;function C(e){let t=y.indexOf(e.inputSource);if(-1===t)return;let n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){i.removeEventListener("select",C),i.removeEventListener("selectstart",C),i.removeEventListener("selectend",C),i.removeEventListener("squeeze",C),i.removeEventListener("squeezestart",C),i.removeEventListener("squeezeend",C),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",P);for(let e=0;e<v.length;e++){let t=y[e];null!==t&&(y[e]=null,v[e].disconnect(t))}T=null,A=null,e.setRenderTarget(m),d=null,u=null,c=null,i=null,g=null,U.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function P(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],i=y.indexOf(n);i>=0&&(y[i]=null,v[i].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],i=y.indexOf(n);if(-1===i){for(let e=0;e<v.length;e++){if(e>=y.length){y.push(n),i=e;break}if(null===y[e]){y[e]=n,i=e;break}}if(-1===i)break}let r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new Ox,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new Ox,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new Ox,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(h){return $e(this,null,(function*(){if(i=h,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",C),i.addEventListener("selectstart",C),i.addEventListener("selectend",C),i.addEventListener("squeeze",C),i.addEventListener("squeezestart",C),i.addEventListener("squeezeend",C),i.addEventListener("end",R),i.addEventListener("inputsourceschange",P),!0!==f.xrCompatible&&(yield t.makeXRCompatible()),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){let n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new Sn(d.framebufferWidth,d.framebufferHeight,{format:Ji,type:gc,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?Uu:Kh,a=f.stencil?Lu:Zh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(i,t),u=c.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new Sn(u.textureWidth,u.textureHeight,{format:Ji,type:gc,depthTexture:new td(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=yield i.requestReferenceSpace(s),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};let L=new M,D=new M;function I(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;E.near=w.near=b.near=e.near,E.far=w.far=b.far=e.far,(T!==E.near||A!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,A=E.far);let t=e.parent,n=E.cameras;I(E,t);for(let i=0;i<n.length;i++)I(n[i],t);2===n.length?function(e,t,n){L.setFromMatrixPosition(t.matrixWorld),D.setFromMatrixPosition(n.matrixWorld);let i=L.distanceTo(D),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(a[8]+1)/a[0],d=s*c,p=s*u,f=i/(-c+u),m=f*-c;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=s+f,v=o+f,y=d-m,x=p+(i-m),_=l*o/v*g,b=h*o/v*g;e.projectionMatrix.makePerspective(y,x,_,b,g,v),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(E,b,w):E.projectionMatrix.copy(b.projectionMatrix),function(e,t,n){null===n?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);let i=e.children;for(let r=0,a=i.length;r<a;r++)i[r].updateMatrixWorld(!0);e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*zg*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,E,t)},this.getCamera=function(){return E},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(e){o=e,null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.getPlanes=function(){return x};let O=null,U=new Joe;U.setAnimationLoop((function(t,i){if(h=i.getViewerPose(l||a),p=i,null!==h){let t=h.views;null!==d&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let n=!1;t.length!==E.cameras.length&&(E.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){let r=t[i],a=null;if(null!==d)a=d.getViewport(r);else{let t=c.getViewSubImage(u,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(g,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}let s=S[i];void 0===s&&(s=new bn,s.layers.enable(i),s.viewport=new Mn,S[i]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===i&&(E.matrix.copy(s.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),!0===n&&E.cameras.push(s)}}for(let e=0;e<v.length;e++){let t=y[e],n=v[e];null!==t&&void 0!==n&&n.update(t,i,l||a)}if(O&&O(t,i),i.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:i.detectedPlanes});let e=null;for(let t of x)i.detectedPlanes.has(t)||(null===e&&(e=[]),e.push(t));if(null!==e)for(let t of e)x.delete(t),_.delete(t),n.dispatchEvent({type:"planeremoved",data:t});for(let t of i.detectedPlanes)if(x.has(t)){let e=_.get(t);t.lastChangedTime>e&&(_.set(t,t.lastChangedTime),n.dispatchEvent({type:"planechanged",data:t}))}else x.add(t),_.set(t,i.lastChangedTime),n.dispatchEvent({type:"planeadded",data:t})}p=null})),this.setAnimationLoop=function(e){O=e},this.dispose=function(){}}};function att(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(i,r){i.opacity.value=r.opacity,r.color&&i.diffuse.value.copy(r.color),r.emissive&&i.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(i.map.value=r.map,n(r.map,i.mapTransform)),r.alphaMap&&(i.alphaMap.value=r.alphaMap,n(r.alphaMap,i.alphaMapTransform)),r.bumpMap&&(i.bumpMap.value=r.bumpMap,n(r.bumpMap,i.bumpMapTransform),i.bumpScale.value=r.bumpScale,r.side===ri&&(i.bumpScale.value*=-1)),r.normalMap&&(i.normalMap.value=r.normalMap,n(r.normalMap,i.normalMapTransform),i.normalScale.value.copy(r.normalScale),r.side===ri&&i.normalScale.value.negate()),r.displacementMap&&(i.displacementMap.value=r.displacementMap,n(r.displacementMap,i.displacementMapTransform),i.displacementScale.value=r.displacementScale,i.displacementBias.value=r.displacementBias),r.emissiveMap&&(i.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,i.emissiveMapTransform)),r.specularMap&&(i.specularMap.value=r.specularMap,n(r.specularMap,i.specularMapTransform)),r.alphaTest>0&&(i.alphaTest.value=r.alphaTest);let a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;let t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Koe(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform)),t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===ri&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){let i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function ott(e,t,n,i){let r={},a={},s=[],o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){let i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{let e=Array.isArray(i)?i:[i],r=[];for(let t=0;t<e.length;t++)r.push(e[t].clone());n[t]=r}return!0}if("number"==typeof i){if(n[t]!==i)return n[t]=i,!0}else{let e=Array.isArray(n[t])?n[t]:[n[t]],r=Array.isArray(i)?i:[i];for(let t=0;t<e.length;t++){let n=e[t];if(!1===n.equals(r[t]))return n.copy(r[t]),!0}}return!1}function h(e){let t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){let n=t.target;n.removeEventListener("dispose",c);let i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){let n=t.program;i.uniformBlockBinding(e,n)},update:function(n,u){let d=r[n.id];void 0===d&&(function(e){let t=e.uniforms,n=0,i=0;for(let r=0,a=t.length;r<a;r++){let e=t[r],a={boundary:0,storage:0},s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,n=s.length;t<n;t++){let e=h(s[t]);a.boundary+=e.boundary,a.storage+=e.storage}e.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=n,r>0&&(i=n%16,0!==i&&16-i-a.boundary<0&&(n+=16-i,e.__offset=n)),n+=a.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),d=function(t){let n=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;let i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=d,n.addEventListener("dispose",c));let p=u.program;i.updateUBOMapping(n,p);let f=t.render.frame;a[n.id]!==f&&(function(t){let n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let r=0,s=i.length;r<s;r++){let t=i[r];if(!0===l(t,r,a)){let n=t.__offset,i=Array.isArray(t.value)?t.value:[t.value],r=0;for(let a=0;a<i.length;a++){let s=i[a],o=h(s);"number"==typeof s?(t.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,n+r,t.__data)):s.isMatrix3?(t.__data[0]=s.elements[0],t.__data[1]=s.elements[1],t.__data[2]=s.elements[2],t.__data[3]=s.elements[0],t.__data[4]=s.elements[3],t.__data[5]=s.elements[4],t.__data[6]=s.elements[5],t.__data[7]=s.elements[0],t.__data[8]=s.elements[6],t.__data[9]=s.elements[7],t.__data[10]=s.elements[8],t.__data[11]=s.elements[0]):(s.toArray(t.__data,r),r+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,n,t.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=f)},dispose:function(){for(let t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}function ltt(){let e=kx("canvas");return e.style.display="block",e}var ms=class{constructor(e={}){let t,{canvas:n=ltt(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0,t=null!==i?i.getContextAttributes().alpha:s;let d=null,p=null,f=[],m=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=St,this.useLegacyLights=!0,this.toneMapping=fc,this.toneMappingExposure=1;let g=this,v=!1,y=0,x=0,_=null,b=-1,w=null,S=new Mn,E=new Mn,T=null,A=n.width,C=n.height,R=1,P=null,L=null,D=new Mn(0,0,A,C),I=new Mn(0,0,A,C),O=!1,U=new ps,N=!1,F=!1,k=null,B=new Ae,z=new M,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return null===_?R:1}let G,j,W,X,q,Y,$,K,Z,J,Q,ee,te,ne,ie,re,ae,se,oe,le,he,ce,ue,de,pe=i;function fe(e,t){for(let i=0;i<e.length;i++){let r=e[i],a=n.getContext(r,t);if(null!==a)return a}return null}try{let e={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${dS}`),n.addEventListener("webglcontextlost",ve,!1),n.addEventListener("webglcontextrestored",ye,!1),n.addEventListener("webglcontextcreationerror",xe,!1),null===pe){let t=["webgl2","webgl","experimental-webgl"];if(!0===g.isWebGL1Renderer&&t.shift(),pe=fe(t,e),null===pe)throw fe(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===pe.getShaderPrecisionFormat&&(pe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function me(){G=new AQe(pe),j=new _Qe(pe,G,e),G.init(j),ce=new rle(pe,G,j),W=new rtt(pe,G,j),X=new IQe(pe),q=new Wet,Y=new itt(pe,G,W,q,j,ce,X),$=new wQe(g),K=new RQe(g),Z=new GZe(pe,j),ue=new EQe(pe,G,Z,j),J=new CQe(pe,Z,X,ue),Q=new NQe(pe,J,Z,X),oe=new OQe(pe,j,Y),re=new TQe(q),ee=new qet(g,$,K,G,j,ue,re),te=new att(g,q),ne=new Xet,ie=new Qet(G,j),se=new yQe(g,$,K,W,Q,t,l),ae=new ntt(g,Q,j),de=new ott(pe,X,j,W),le=new bQe(pe,G,X,j),he=new PQe(pe,G,X,j),X.programs=ee.programs,g.capabilities=j,g.extensions=G,g.properties=q,g.renderLists=ne,g.shadowMap=ae,g.state=W,g.info=X}me();let ge=new TU(g,pe);function ve(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;let e=X.autoReset,t=ae.enabled,n=ae.autoUpdate,i=ae.needsUpdate,r=ae.type;me(),X.autoReset=e,ae.enabled=t,ae.autoUpdate=n,ae.needsUpdate=i,ae.type=r}function xe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function _e(e){let t=e.target;t.removeEventListener("dispose",_e),function(e){(function(e){let t=q.get(e).programs;void 0!==t&&(t.forEach((function(e){ee.releaseProgram(e)})),e.isShaderMaterial&&ee.releaseShaderCache(e))})(e),q.remove(e)}(t)}this.xr=ge,this.getContext=function(){return pe},this.getContextAttributes=function(){return pe.getContextAttributes()},this.forceContextLoss=function(){let e=G.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=G.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(e){void 0!==e&&(R=e,this.setSize(A,C,!1))},this.getSize=function(e){return e.set(A,C)},this.setSize=function(e,t,i=!0){ge.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(A=e,C=t,n.width=Math.floor(e*R),n.height=Math.floor(t*R),!0===i&&(n.style.width=e+"px",n.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(A*R,C*R).floor()},this.setDrawingBufferSize=function(e,t,i){A=e,C=t,R=i,n.width=Math.floor(e*i),n.height=Math.floor(t*i),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(S)},this.getViewport=function(e){return e.copy(D)},this.setViewport=function(e,t,n,i){e.isVector4?D.set(e.x,e.y,e.z,e.w):D.set(e,t,n,i),W.viewport(S.copy(D).multiplyScalar(R).floor())},this.getScissor=function(e){return e.copy(I)},this.setScissor=function(e,t,n,i){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,i),W.scissor(E.copy(I).multiplyScalar(R).floor())},this.getScissorTest=function(){return O},this.setScissorTest=function(e){W.setScissorTest(O=e)},this.setOpaqueSort=function(e){P=e},this.setTransparentSort=function(e){L=e},this.getClearColor=function(e){return e.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor.apply(se,arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha.apply(se,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;e&&(i|=pe.COLOR_BUFFER_BIT),t&&(i|=pe.DEPTH_BUFFER_BIT),n&&(i|=pe.STENCIL_BUFFER_BIT),pe.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",ve,!1),n.removeEventListener("webglcontextrestored",ye,!1),n.removeEventListener("webglcontextcreationerror",xe,!1),ne.dispose(),ie.dispose(),q.dispose(),$.dispose(),K.dispose(),Q.dispose(),ue.dispose(),de.dispose(),ee.dispose(),ge.dispose(),ge.removeEventListener("sessionstart",Me),ge.removeEventListener("sessionend",we),k&&(k.dispose(),k=null),Se.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=V);let s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=V),Y.resetTextureUnits();let a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===_?g.outputColorSpace:!0===_.isXRRenderTarget?_.texture.colorSpace:ks,l=(i.isMeshStandardMaterial?K:$).get(i.envMap||s),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!i.normalMap&&!!n.attributes.tangent,u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,f=!!n.morphAttributes.color,m=i.toneMapped?g.toneMapping:fc,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,x=q.get(i),M=p.state.lights;if(!0===N&&(!0===F||e!==w)){let t=e===w&&i.id===b;re.setState(i,e,t)}let S=!1;i.version===x.__version?(x.needsLights&&x.lightsStateVersion!==M.state.version||x.outputColorSpace!==o||r.isInstancedMesh&&!1===x.instancing||!r.isInstancedMesh&&!0===x.instancing||r.isSkinnedMesh&&!1===x.skinning||!r.isSkinnedMesh&&!0===x.skinning||x.envMap!==l||!0===i.fog&&x.fog!==a||void 0!==x.numClippingPlanes&&(x.numClippingPlanes!==re.numPlanes||x.numIntersection!==re.numIntersection)||x.vertexAlphas!==h||x.vertexTangents!==c||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==f||x.toneMapping!==m||!0===j.isWebGL2&&x.morphTargetsCount!==y)&&(S=!0):(S=!0,x.__version=i.version);let E=x.currentProgram;!0===S&&(E=Pe(i,t,r));let T=!1,A=!1,P=!1,L=E.getUniforms(),D=x.uniforms;if(W.useProgram(E.program)&&(T=!0,A=!0,P=!0),i.id!==b&&(b=i.id,A=!0),T||w!==e){if(L.setValue(pe,"projectionMatrix",e.projectionMatrix),j.logarithmicDepthBuffer&&L.setValue(pe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),w!==e&&(w=e,A=!0,P=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){let t=L.map.cameraPosition;void 0!==t&&t.setValue(pe,z.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&L.setValue(pe,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&L.setValue(pe,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){L.setOptional(pe,r,"bindMatrix"),L.setOptional(pe,r,"bindMatrixInverse");let e=r.skeleton;e&&(j.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),L.setValue(pe,"boneTexture",e.boneTexture,Y),L.setValue(pe,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let I=n.morphAttributes;if((void 0!==I.position||void 0!==I.normal||void 0!==I.color&&!0===j.isWebGL2)&&oe.update(r,n,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,L.setValue(pe,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(D.envMap.value=l,D.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(L.setValue(pe,"toneMappingExposure",g.toneMappingExposure),x.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(D,P),a&&!0===i.fog&&te.refreshFogUniforms(D,a),te.refreshMaterialUniforms(D,i,R,C,k),Vg.upload(pe,x.uniformsList,D,Y)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Vg.upload(pe,x.uniformsList,D,Y),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&L.setValue(pe,"center",r.center),L.setValue(pe,"modelViewMatrix",r.modelViewMatrix),L.setValue(pe,"normalMatrix",r.normalMatrix),L.setValue(pe,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){let e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(j.isWebGL2){let n=e[t];de.update(n,E),de.bind(n,E)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return E}(e,t,n,i,r);W.setMaterial(i,s);let l=n.index,h=1;!0===i.wireframe&&(l=J.getWireframeAttribute(n),h=2);let c=n.drawRange,u=n.attributes.position,d=c.start*h,f=(c.start+c.count)*h;null!==a&&(d=Math.max(d,a.start*h),f=Math.min(f,(a.start+a.count)*h)),null!==l?(d=Math.max(d,0),f=Math.min(f,l.count)):null!=u&&(d=Math.max(d,0),f=Math.min(f,u.count));let m=f-d;if(m<0||m===1/0)return;ue.setup(r,i,o,n,l);let v,y=le;if(null!==l&&(v=Z.get(l),y=he,y.setIndex(v)),r.isMesh)!0===i.wireframe?(W.setLineWidth(i.wireframeLinewidth*H()),y.setMode(pe.LINES)):y.setMode(pe.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),W.setLineWidth(e*H()),r.isLineSegments?y.setMode(pe.LINES):r.isLineLoop?y.setMode(pe.LINE_LOOP):y.setMode(pe.LINE_STRIP)}else r.isPoints?y.setMode(pe.POINTS):r.isSprite&&y.setMode(pe.TRIANGLES);if(r.isInstancedMesh)y.renderInstances(d,m,r.count);else if(n.isInstancedBufferGeometry){let e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);y.renderInstances(d,m,t)}else y.render(d,m)},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===tr&&!1===e.forceSinglePass?(e.side=ri,e.needsUpdate=!0,Pe(e,t,n),e.side=Tr,e.needsUpdate=!0,Pe(e,t,n),e.side=tr):Pe(e,t,n)}p=ie.get(e),p.init(),m.push(p),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(p.pushLight(e),e.castShadow&&p.pushShadow(e))})),p.setupLights(g.useLegacyLights),e.traverse((function(t){let i=t.material;if(i)if(Array.isArray(i))for(let r=0;r<i.length;r++)n(i[r],e,t);else n(i,e,t)})),m.pop(),p=null};let be=null;function Me(){Se.stop()}function we(){Se.start()}let Se=new Joe;function Ee(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)p.pushLight(e),e.castShadow&&p.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||U.intersectsSprite(e)){i&&z.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);let t=Q.update(e),r=e.material;r.visible&&d.push(e,t,r,n,z.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||U.intersectsObject(e))){e.isSkinnedMesh&&e.skeleton.frame!==X.render.frame&&(e.skeleton.update(),e.skeleton.frame=X.render.frame);let t=Q.update(e),r=e.material;if(i&&(null===t.boundingSphere&&t.computeBoundingSphere(),z.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(B)),Array.isArray(r)){let i=t.groups;for(let a=0,s=i.length;a<s;a++){let s=i[a],o=r[s.materialIndex];o&&o.visible&&d.push(e,t,o,n,z.z,s)}}else r.visible&&d.push(e,t,r,n,z.z,null)}let r=e.children;for(let a=0,s=r.length;a<s;a++)Ee(r[a],t,n,i)}function Te(e,t,n,i){let r=e.opaque,a=e.transmissive,s=e.transparent;p.setupLightsView(n),!0===N&&re.setGlobalState(g.clippingPlanes,n),a.length>0&&function(e,t,n,i){if(null===k){let e=j.isWebGL2;k=new Sn(1024,1024,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?Ga:gc,minFilter:Hs,samples:e&&!0===o?4:0})}let r=g.getRenderTarget();g.setRenderTarget(k),g.clear();let a=g.toneMapping;g.toneMapping=fc,Ce(e,n,i),Y.updateMultisampleRenderTarget(k),Y.updateRenderTargetMipmap(k);let s=!1;for(let o=0,l=t.length;o<l;o++){let e=t[o],r=e.object,a=e.geometry,l=e.material,h=e.group;if(l.side===tr&&r.layers.test(i.layers)){let e=l.side;l.side=ri,l.needsUpdate=!0,Re(r,n,i,a,l,h),l.side=e,l.needsUpdate=!0,s=!0}}!0===s&&(Y.updateMultisampleRenderTarget(k),Y.updateRenderTargetMipmap(k)),g.setRenderTarget(r),g.toneMapping=a}(r,a,t,n),i&&W.viewport(S.copy(i)),r.length>0&&Ce(r,t,n),a.length>0&&Ce(a,t,n),s.length>0&&Ce(s,t,n),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Ce(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){let a=e[r],s=a.object,o=a.geometry,l=null===i?a.material:i,h=a.group;s.layers.test(n.layers)&&Re(s,t,n,o,l,h)}}function Re(e,t,n,i,r,a){e.onBeforeRender(g,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(g,t,n,i,e,a),!0===r.transparent&&r.side===tr&&!1===r.forceSinglePass?(r.side=ri,r.needsUpdate=!0,g.renderBufferDirect(n,t,i,r,e,a),r.side=Tr,r.needsUpdate=!0,g.renderBufferDirect(n,t,i,r,e,a),r.side=tr):g.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(g,t,n,i,r,a)}function Pe(e,t,n){!0!==t.isScene&&(t=V);let i=q.get(e),r=p.state.lights,a=p.state.shadowsArray,s=r.state.version,o=ee.getParameters(e,r.state,a,t,n),l=ee.getProgramCacheKey(o),h=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?K:$).get(e.envMap||i.environment),void 0===h&&(e.addEventListener("dispose",_e),h=new Map,i.programs=h);let c=h.get(l);if(void 0!==c){if(i.currentProgram===c&&i.lightsStateVersion===s)return Le(e,o),c}else o.uniforms=ee.getUniforms(e),e.onBuild(n,o,g),e.onBeforeCompile(o,g),c=ee.acquireProgram(o,l),h.set(l,c),i.uniforms=o.uniforms;let u=i.uniforms;(!e.isShaderMaterial&&!e.isRawShaderMaterial||!0===e.clipping)&&(u.clippingPlanes=re.uniform),Le(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=s,i.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);let d=c.getUniforms(),f=Vg.seqWithValue(d.seq,u);return i.currentProgram=c,i.uniformsList=f,c}function Le(e,t){let n=q.get(e);n.outputColorSpace=t.outputColorSpace,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Se.setAnimationLoop((function(e){be&&be(e)})),"undefined"!=typeof self&&Se.setContext(self),this.setAnimationLoop=function(e){be=e,ge.setAnimationLoop(e),null===e?Se.stop():Se.start()},ge.addEventListener("sessionstart",Me),ge.addEventListener("sessionend",we),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===v)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===ge.enabled&&!0===ge.isPresenting&&(!0===ge.cameraAutoUpdate&&ge.updateCamera(t),t=ge.getCamera()),!0===e.isScene&&e.onBeforeRender(g,e,t,_),p=ie.get(e,m.length),p.init(),m.push(p),B.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),U.setFromProjectionMatrix(B),F=this.localClippingEnabled,N=re.init(this.clippingPlanes,F),d=ne.get(e,f.length),d.init(),f.push(d),Ee(e,t,0,g.sortObjects),d.finish(),!0===g.sortObjects&&d.sort(P,L),!0===N&&re.beginShadows();let n=p.state.shadowsArray;if(ae.render(n,e,t),!0===N&&re.endShadows(),!0===this.info.autoReset&&this.info.reset(),se.render(d,e),p.setupLights(g.useLegacyLights),t.isArrayCamera){let n=t.cameras;for(let t=0,i=n.length;t<i;t++){let i=n[t];Te(d,e,i,i.viewport)}}else Te(d,e,t);null!==_&&(Y.updateMultisampleRenderTarget(_),Y.updateRenderTargetMipmap(_)),!0===e.isScene&&e.onAfterRender(g,e,t),ue.resetDefaultState(),b=-1,w=null,m.pop(),p=m.length>0?m[m.length-1]:null,f.pop(),d=f.length>0?f[f.length-1]:null},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return _},this.setRenderTargetTextures=function(e,t,n){q.get(e.texture).__webglTexture=t,q.get(e.depthTexture).__webglTexture=n;let i=q.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===G.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){let n=q.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){_=e,y=t,x=n;let i=!0,r=null,a=!1,s=!1;if(e){let n=q.get(e);void 0!==n.__useDefaultFramebuffer?(W.bindFramebuffer(pe.FRAMEBUFFER,null),i=!1):void 0===n.__webglFramebuffer?Y.setupRenderTarget(e):n.__hasExternalTextures&&Y.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture);let o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);let l=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],a=!0):r=j.isWebGL2&&e.samples>0&&!1===Y.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:l,S.copy(e.viewport),E.copy(e.scissor),T=e.scissorTest}else S.copy(D).multiplyScalar(R).floor(),E.copy(I).multiplyScalar(R).floor(),T=O;if(W.bindFramebuffer(pe.FRAMEBUFFER,r)&&j.drawBuffers&&i&&W.drawBuffers(e,r),W.viewport(S),W.scissor(E),W.setScissorTest(T),a){let i=q.get(e.texture);pe.framebufferTexture2D(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,pe.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){let i=q.get(e.texture),r=t||0;pe.framebufferTextureLayer(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){W.bindFramebuffer(pe.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==Ji&&ce.convert(o)!==pe.getParameter(pe.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===Ga&&(G.has("EXT_color_buffer_half_float")||j.isWebGL2&&G.has("EXT_color_buffer_float"));if(!(l===gc||ce.convert(l)===pe.getParameter(pe.IMPLEMENTATION_COLOR_READ_TYPE)||l===Bs&&(j.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&pe.readPixels(t,n,i,r,ce.convert(o),ce.convert(l),a)}finally{let e=null!==_?q.get(_).__webglFramebuffer:null;W.bindFramebuffer(pe.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);Y.setTexture2D(t,0),pe.copyTexSubImage2D(pe.TEXTURE_2D,n,0,0,e.x,e.y,r,a),W.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){let r=t.image.width,a=t.image.height,s=ce.convert(n.format),o=ce.convert(n.type);Y.setTexture2D(n,0),pe.pixelStorei(pe.UNPACK_FLIP_Y_WEBGL,n.flipY),pe.pixelStorei(pe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),pe.pixelStorei(pe.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?pe.texSubImage2D(pe.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?pe.compressedTexSubImage2D(pe.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):pe.texSubImage2D(pe.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&pe.generateMipmap(pe.TEXTURE_2D),W.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(g.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");let a,s=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,l=e.max.z-e.min.z+1,h=ce.convert(i.format),c=ce.convert(i.type);if(i.isData3DTexture)Y.setTexture3D(i,0),a=pe.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Y.setTexture2DArray(i,0),a=pe.TEXTURE_2D_ARRAY}pe.pixelStorei(pe.UNPACK_FLIP_Y_WEBGL,i.flipY),pe.pixelStorei(pe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),pe.pixelStorei(pe.UNPACK_ALIGNMENT,i.unpackAlignment);let u=pe.getParameter(pe.UNPACK_ROW_LENGTH),d=pe.getParameter(pe.UNPACK_IMAGE_HEIGHT),p=pe.getParameter(pe.UNPACK_SKIP_PIXELS),f=pe.getParameter(pe.UNPACK_SKIP_ROWS),m=pe.getParameter(pe.UNPACK_SKIP_IMAGES),v=n.isCompressedTexture?n.mipmaps[0]:n.image;pe.pixelStorei(pe.UNPACK_ROW_LENGTH,v.width),pe.pixelStorei(pe.UNPACK_IMAGE_HEIGHT,v.height),pe.pixelStorei(pe.UNPACK_SKIP_PIXELS,e.min.x),pe.pixelStorei(pe.UNPACK_SKIP_ROWS,e.min.y),pe.pixelStorei(pe.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?pe.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,v.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),pe.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,v.data)):pe.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,v),pe.pixelStorei(pe.UNPACK_ROW_LENGTH,u),pe.pixelStorei(pe.UNPACK_IMAGE_HEIGHT,d),pe.pixelStorei(pe.UNPACK_SKIP_PIXELS,p),pe.pixelStorei(pe.UNPACK_SKIP_ROWS,f),pe.pixelStorei(pe.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&pe.generateMipmap(a),W.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Y.setTextureCube(e,0):e.isData3DTexture?Y.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Y.setTexture2DArray(e,0):Y.setTexture2D(e,0),W.unbindTexture()},this.resetState=function(){y=0,x=0,_=null,W.reset(),ue.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===St?pc:IB}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===pc?St:ks}},qM=class extends ms{};qM.prototype.isWebGL1Renderer=!0;var Ig,jg=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ie(e),this.density=t}clone(){return new jg(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},xc=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ie(e),this.near=t,this.far=n}clone(){return new xc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ii=class extends Tt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},Vu=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Hx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=za()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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 i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=za()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=za()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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}}},Os=new M,ha=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}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++)Os.fromBufferAttribute(this,t),Os.applyMatrix4(e),this.setXYZ(t,Os.x,Os.y,Os.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Os.fromBufferAttribute(this,t),Os.applyNormalMatrix(e),this.setXYZ(t,Os.x,Os.y,Os.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Os.fromBufferAttribute(this,t),Os.transformDirection(e),this.setXYZ(t,Os.x,Os.y,Os.z);return this}setX(e,t){return this.normalized&&(t=In(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=In(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=In(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=In(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=Va(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Va(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Va(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Va(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=In(t,this.array),n=In(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=In(t,this.array),n=In(n,this.array),i=In(i,this.array),r=In(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.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 Ct(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ha(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.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}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Wx=class extends Rn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ie(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}},wx=new M,Dg=new M,Lg=new M,Og=new Q,Mx=new Q,ile=new Ae,hM=new M,Sx=new M,dM=new M,vae=new Q,bN=new Q,xae=new Q,WM=class extends Tt{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Ig){Ig=new et;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new Vu(e,5);Ig.setIndex([0,1,2,0,2,3]),Ig.setAttribute("position",new ha(t,3,0,!1)),Ig.setAttribute("uv",new ha(t,2,3,!1))}this.geometry=Ig,this.material=void 0!==e?e:new Wx,this.center=new Q(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Dg.setFromMatrixScale(this.matrixWorld),ile.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Lg.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Dg.multiplyScalar(-Lg.z);let n,i,r=this.material.rotation;0!==r&&(i=Math.cos(r),n=Math.sin(r));let a=this.center;fM(hM.set(-.5,-.5,0),Lg,a,Dg,n,i),fM(Sx.set(.5,-.5,0),Lg,a,Dg,n,i),fM(dM.set(.5,.5,0),Lg,a,Dg,n,i),vae.set(0,0),bN.set(1,0),xae.set(1,1);let s=e.ray.intersectTriangle(hM,Sx,dM,!1,wx);if(null===s&&(fM(Sx.set(-.5,.5,0),Lg,a,Dg,n,i),bN.set(0,1),s=e.ray.intersectTriangle(hM,dM,Sx,!1,wx),null===s))return;let o=e.ray.origin.distanceTo(wx);o<e.near||o>e.far||t.push({distance:o,point:wx.clone(),uv:Rr.getInterpolation(wx,hM,Sx,dM,vae,bN,xae,new Q),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}};function fM(e,t,n,i,r,a){Og.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Mx.x=a*Og.x-r*Og.y,Mx.y=r*Og.x+a*Og.y):Mx.copy(Og),e.copy(t),e.x+=Mx.x,e.y+=Mx.y,e.applyMatrix4(ile)}var pM=new M,yae=new M,jM=class extends Tt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,i=t.length;n<i;n++){let e=t[n];this.addLevel(e.object.clone(),e.distance,e.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let i,r=this.levels;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let i=t[n].distance;if(t[n].object.visible&&(i-=i*t[n].hysteresis),e<i)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){pM.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(pM);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){pM.setFromMatrixPosition(e.matrixWorld),yae.setFromMatrixPosition(this.matrixWorld);let n,i,r=pM.distanceTo(yae)/e.zoom;for(t[0].object.visible=!0,n=1,i=t.length;n<i;n++){let e=t[n].distance;if(t[n].object.visible&&(e-=e*t[n].hysteresis),!(r>=e))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;n<i;n++)t[n].object.visible=!1}}toJSON(e){let t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let i=0,r=n.length;i<r;i++){let e=n[i];t.object.levels.push({object:e.object.uuid,distance:e.distance,hysteresis:e.hysteresis})}return t}},Eae=new M,bae=new Mn,_ae=new Mn,ctt=new M,Tae=new Ae,Ng=new M,yc=class extends Ge{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ae,this.bindMatrixInverse=new Ae,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;null===this.boundingBox&&(this.boundingBox=new lt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)Ng.fromBufferAttribute(t,n),this.applyBoneTransform(n,Ng),this.boundingBox.expandByPoint(Ng)}computeBoundingSphere(){let e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new hr),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)Ng.fromBufferAttribute(t,n),this.applyBoneTransform(n,Ng),this.boundingSphere.expandByPoint(Ng)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Mn,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;bae.fromBufferAttribute(i.attributes.skinIndex,e),_ae.fromBufferAttribute(i.attributes.skinWeight,e),Eae.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let e=_ae.getComponent(r);if(0!==e){let i=bae.getComponent(r);Tae.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(ctt.copy(Eae).applyMatrix4(Tae),e)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}},Ao=class extends Tt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ro=class extends ur{constructor(e=null,t=1,n=1,i,r,a,s,o,l=cr,h=cr,c,u){super(null,a,s,o,l,h,i,r,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},wae=new Ae,utt=new Ae,Co=class{constructor(e=[],t=[]){this.uuid=za(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Ae)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new Ae;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){let i=e[r]?e[r].matrixWorld:utt;wae.multiplyMatrices(i,t[r]),wae.toArray(n,16*r)}null!==i&&(i.needsUpdate=!0)}clone(){return new Co(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=Xoe(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Ro(t,e,e,Ji,Bs);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let i=e.bones[n],r=t[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new Ao),this.bones.push(r),this.boneInverses.push((new Ae).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let r=t[i];e.bones.push(r.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}},zu=class extends Ct{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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}},Ug=new Ae,Mae=new Ae,mM=[],Sae=new lt,htt=new Ae,Rx=new Ge,Ax=new hr,Ar=class extends Ge{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new zu(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,htt)}computeBoundingBox(){let e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new lt),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ug),Sae.copy(e.boundingBox).applyMatrix4(Ug),this.boundingBox.union(Sae)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new hr),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ug),Ax.copy(e.boundingSphere).applyMatrix4(Ug),this.boundingSphere.union(Ax)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){let n=this.matrixWorld,i=this.count;if(Rx.geometry=this.geometry,Rx.material=this.material,void 0!==Rx.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Ax.copy(this.boundingSphere),Ax.applyMatrix4(n),!1!==e.ray.intersectsSphere(Ax)))for(let r=0;r<i;r++){this.getMatrixAt(r,Ug),Mae.multiplyMatrices(n,Ug),Rx.matrixWorld=Mae,Rx.raycast(e,mM);for(let e=0,n=mM.length;e<n;e++){let n=mM[e];n.instanceId=r,n.object=this,t.push(n)}mM.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new zu(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},Jt=class extends Rn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(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}},Rae=new M,Aae=new M,Cae=new Ae,_N=new Wa,gM=new hr,sn=class extends Tt{constructor(e=new et,t=new Jt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)Rae.fromBufferAttribute(t,e-1),Aae.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Rae.distanceTo(Aae);e.setAttribute("lineDistance",new tt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),gM.copy(n.boundingSphere),gM.applyMatrix4(i),gM.radius+=r,!1===e.ray.intersectsSphere(gM))return;Cae.copy(i).invert(),_N.copy(e.ray).applyMatrix4(Cae);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=new M,h=new M,c=new M,u=new M,d=this.isLineSegments?2:1,p=n.index,f=n.attributes.position;if(null!==p)for(let m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count)-1;m<g;m+=d){let n=p.getX(m),i=p.getX(m+1);if(l.fromBufferAttribute(f,n),h.fromBufferAttribute(f,i),_N.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);r<e.near||r>e.far||t.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count)-1;m<g;m+=d){if(l.fromBufferAttribute(f,m),h.fromBufferAttribute(f,m+1),_N.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(u);n<e.near||n>e.far||t.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){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}}}}},Pae=new M,Iae=new M,Dn=class extends sn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)Pae.fromBufferAttribute(t,e),Iae.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Pae.distanceTo(Iae);e.setAttribute("lineDistance",new tt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Xg=class extends sn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Br=class extends Rn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ie(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}},Dae=new Ae,wU=new Wa,vM=new hr,xM=new M,or=class extends Tt{constructor(e=new et,t=new Br){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),vM.copy(n.boundingSphere),vM.applyMatrix4(i),vM.radius+=r,!1===e.ray.intersectsSphere(vM))return;Dae.copy(i).invert(),wU.copy(e.ray).applyMatrix4(Dae);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=n.index,h=n.attributes.position;if(null!==l)for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c<u;c++){let n=l.getX(c);xM.fromBufferAttribute(h,n),Lae(xM,n,o,i,e,t,this)}else for(let c=Math.max(0,a.start),u=Math.min(h.count,a.start+a.count);c<u;c++)xM.fromBufferAttribute(h,c),Lae(xM,c,o,i,e,t,this)}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){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}}}}};function Lae(e,t,n,i,r,a,s){let o=wU.distanceSqToPoint(e);if(o<n){let n=new M;wU.closestPointToPoint(e,n),n.applyMatrix4(i);let l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:s})}}var MU=class extends ur{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:Vn,this.magFilter=void 0!==r?r:Vn,this.generateMipmaps=!1;let h=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){h.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e==0&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},SU=class extends ur{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=cr,this.minFilter=cr,this.generateMipmaps=!1,this.needsUpdate=!0}},jx=class extends ur{constructor(e,t,n,i,r,a,s,o,l,h,c,u){super(null,a,s,o,l,h,i,r,c,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},RU=class extends jx{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Or}},AU=class extends ur{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Vs=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t,n=[],i=this.getPoint(0),r=0;n.push(0);for(let a=1;a<=e;a++)t=this.getPoint(a/e),r+=t.distanceTo(i),n.push(r),i=t;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];let s,o=0,l=a-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),s=i[r]-n,s<0)o=r+1;else{if(!(s>0)){l=r;break}l=r-1}if(r=l,i[r]===n)return r/(a-1);let h=i[r];return(r+(n-h)/(i[r+1]-h))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new Q:new M);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new M,i=[],r=[],a=[],s=new M,o=new Ae;for(let d=0;d<=e;d++){let t=d/e;i[d]=this.getTangentAt(t,new M)}r[0]=new M,a[0]=new M;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),c=Math.abs(i[0].y),u=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),u<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),a[d]=a[d-1].clone(),s.crossVectors(i[d-1],i[d]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(pi(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(o.makeRotationAxis(s,e))}a[d].crossVectors(i[d],r[d])}if(!0===t){let t=Math.acos(pi(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Gu=class extends Vs{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){let n=t||new Q,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=a?0:i),!0===this.aClockwise&&!a&&(r===i?r=-i:r-=i);let s=this.aStartAngle+e*r,o=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=o-this.aX,i=l-this.aY;o=n*e-i*t+this.aX,l=n*t+i*e+this.aY}return n.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},tp=class extends Gu{constructor(e,t,n,i,r,a){super(e,t,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function NB(){let e=0,t=0,n=0,i=0;function r(r,a,s,o){e=r,t=s,n=-3*r+3*a-2*s-o,i=2*r-2*a+s+o}return{initCatmullRom:function(e,t,n,i,a){r(t,n,a*(n-e),a*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,a,s,o){let l=(t-e)/a-(n-e)/(a+s)+(n-t)/s,h=(n-t)/s-(i-t)/(s+o)+(i-n)/o;l*=s,h*=s,r(t,n,l,h)},calc:function(r){let a=r*r;return e+t*r+n*a+i*(a*r)}}}var yM=new M,TN=new NB,wN=new NB,MN=new NB,XM=class extends Vs{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new M){let n,i,r=t,a=this.points,s=a.length,o=(s-(this.closed?0:1))*e,l=Math.floor(o),h=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===h&&l===s-1&&(l=s-2,h=1),this.closed||l>0?n=a[(l-1)%s]:(yM.subVectors(a[0],a[1]).add(a[0]),n=yM);let c=a[l%s],u=a[(l+1)%s];if(this.closed||l+2<s?i=a[(l+2)%s]:(yM.subVectors(a[s-1],a[s-2]).add(a[s-1]),i=yM),"centripetal"===this.curveType||"chordal"===this.curveType){let e="chordal"===this.curveType?.5:.25,t=Math.pow(n.distanceToSquared(c),e),r=Math.pow(c.distanceToSquared(u),e),a=Math.pow(u.distanceToSquared(i),e);r<1e-4&&(r=1),t<1e-4&&(t=r),a<1e-4&&(a=r),TN.initNonuniformCatmullRom(n.x,c.x,u.x,i.x,t,r,a),wN.initNonuniformCatmullRom(n.y,c.y,u.y,i.y,t,r,a),MN.initNonuniformCatmullRom(n.z,c.z,u.z,i.z,t,r,a)}else"catmullrom"===this.curveType&&(TN.initCatmullRom(n.x,c.x,u.x,i.x,this.tension),wN.initCatmullRom(n.y,c.y,u.y,i.y,this.tension),MN.initCatmullRom(n.z,c.z,u.z,i.z,this.tension));return r.set(TN.calc(h),wN.calc(h),MN.calc(h)),r}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push((new M).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Oae(e,t,n,i,r){let a=.5*(i-t),s=.5*(r-n),o=e*e;return(2*n-2*i+a+s)*(e*o)+(-3*n+3*i-2*a-s)*o+a*e+n}function dtt(e,t){let n=1-e;return n*n*t}function ftt(e,t){return 2*(1-e)*e*t}function ptt(e,t){return e*e*t}function Nx(e,t,n,i){return dtt(e,t)+ftt(e,n)+ptt(e,i)}function mtt(e,t){let n=1-e;return n*n*n*t}function gtt(e,t){let n=1-e;return 3*n*n*e*t}function vtt(e,t){return 3*(1-e)*e*e*t}function xtt(e,t){return e*e*e*t}function Ux(e,t,n,i,r){return mtt(e,t)+gtt(e,n)+vtt(e,i)+xtt(e,r)}var Xx=class extends Vs{constructor(e=new Q,t=new Q,n=new Q,i=new Q){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Q){let n=t,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(Ux(e,i.x,r.x,a.x,s.x),Ux(e,i.y,r.y,a.y,s.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},YM=class extends Vs{constructor(e=new M,t=new M,n=new M,i=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new M){let n=t,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(Ux(e,i.x,r.x,a.x,s.x),Ux(e,i.y,r.y,a.y,s.y),Ux(e,i.z,r.z,a.z,s.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Yg=class extends Vs{constructor(e=new Q,t=new Q){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Q){let n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},$M=class extends Vs{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){let n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new M){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Yx=class extends Vs{constructor(e=new Q,t=new Q,n=new Q){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Q){let n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(Nx(e,i.x,r.x,a.x),Nx(e,i.y,r.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},$x=class extends Vs{constructor(e=new M,t=new M,n=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new M){let n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(Nx(e,i.x,r.x,a.x),Nx(e,i.y,r.y,a.y),Nx(e,i.z,r.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},np=class extends Vs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Q){let n=t,i=this.points,r=(i.length-1)*e,a=Math.floor(r),s=r-a,o=i[0===a?a:a-1],l=i[a],h=i[a>i.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(Oae(s,o.x,l.x,h.x,c.x),Oae(s,o.y,l.y,h.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push((new Q).fromArray(n))}return this}},UB=Object.freeze({__proto__:null,ArcCurve:tp,CatmullRomCurve3:XM,CubicBezierCurve:Xx,CubicBezierCurve3:YM,EllipseCurve:Gu,LineCurve:Yg,LineCurve3:$M,QuadraticBezierCurve:Yx,QuadraticBezierCurve3:$x,SplineCurve:np}),ZM=class extends Vs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Yg(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t,n=[];for(let i=0,r=this.curves;i<r.length;i++){let a=r[i],s=a.isEllipseCurve?2*e:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(s);for(let e=0;e<o.length;e++){let i=o[e];t&&t.equals(i)||(n.push(i),t=i)}}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push((new UB[n.type]).fromJSON(n))}return this}},Ec=class extends ZM{constructor(e){super(),this.type="Path",this.currentPoint=new Q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new Yg(this.currentPoint.clone(),new Q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let r=new Yx(this.currentPoint.clone(),new Q(e,t),new Q(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,a){let s=new Xx(this.currentPoint.clone(),new Q(e,t),new Q(n,i),new Q(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new np(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,a){let s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+s,t+o,n,i,r,a),this}absarc(e,t,n,i,r,a){return this.absellipse(e,t,n,n,i,r,a),this}ellipse(e,t,n,i,r,a,s,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,n,i,r,a,s,o),this}absellipse(e,t,n,i,r,a,s,o){let l=new Gu(e,t,n,i,r,a,s,o);if(this.curves.length>0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},nd=class extends et{constructor(e=[new Q(0,-.5),new Q(.5,0),new Q(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=pi(i,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new M,u=new Q,d=new M,p=new M,f=new M,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let r=n+v*h*i,d=Math.sin(r),p=Math.cos(r);for(let n=0;n<=e.length-1;n++){c.x=e[n].x*d,c.y=e[n].y,c.z=e[n].x*p,a.push(c.x,c.y,c.z),u.x=v/t,u.y=n/(e.length-1),s.push(u.x,u.y);let i=o[3*n+0]*d,r=o[3*n+1],h=o[3*n+0]*p;l.push(i,r,h)}}for(let v=0;v<t;v++)for(let t=0;t<e.length-1;t++){let n=t+v*e.length,i=n,a=n+e.length,s=n+e.length+1,o=n+1;r.push(i,a,o),r.push(s,o,a)}this.setIndex(r),this.setAttribute("position",new tt(a,3)),this.setAttribute("uv",new tt(s,2)),this.setAttribute("normal",new tt(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nd(e.points,e.segments,e.phiStart,e.phiLength)}},rp=class extends nd{constructor(e=1,t=1,n=4,i=8){let r=new Ec;r.absarc(0,-t/2,e,1.5*Math.PI,0),r.absarc(0,t/2,e,0,.5*Math.PI),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new rp(e.radius,e.length,e.capSegments,e.radialSegments)}},ip=class extends et{constructor(e=1,t=32,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);let r=[],a=[],s=[],o=[],l=new M,h=new Q;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let c=0,u=3;c<=t;c++,u+=3){let r=n+c/t*i;l.x=e*Math.cos(r),l.y=e*Math.sin(r),a.push(l.x,l.y,l.z),s.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,o.push(h.x,h.y)}for(let c=1;c<=t;c++)r.push(c,c+1,0);this.setIndex(r),this.setAttribute("position",new tt(a,3)),this.setAttribute("normal",new tt(s,3)),this.setAttribute("uv",new tt(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ip(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Po=class extends et{constructor(e=1,t=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};let l=this;i=Math.floor(i),r=Math.floor(r);let h=[],c=[],u=[],d=[],p=0,f=[],m=n/2,g=0;function v(n){let r=p,a=new Q,f=new M,v=0,y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)c.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;let _=p;for(let e=0;e<=i;e++){let t=e/i*o+s,n=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*n,c.push(f.x,f.y,f.z),u.push(0,x,0),a.x=.5*n+.5,a.y=.5*r*x+.5,d.push(a.x,a.y),p++}for(let e=0;e<i;e++){let t=r+e,i=_+e;!0===n?h.push(i,i+1,t):h.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}(function(){let a=new M,v=new M,y=0,x=(t-e)/n;for(let l=0;l<=r;l++){let h=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=i;e++){let t=e/i,r=t*o+s,l=Math.sin(r),f=Math.cos(r);v.x=y*l,v.y=-g*n+m,v.z=y*f,c.push(v.x,v.y,v.z),a.set(l,x,f).normalize(),u.push(a.x,a.y,a.z),d.push(t,1-g),h.push(p++)}f.push(h)}for(let e=0;e<i;e++)for(let t=0;t<r;t++){let n=f[t][e],i=f[t+1][e],r=f[t+1][e+1],a=f[t][e+1];h.push(n,i,a),h.push(i,r,a),y+=6}l.addGroup(g,y,0),g+=y})(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new tt(c,3)),this.setAttribute("normal",new tt(u,3)),this.setAttribute("uv",new tt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Po(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},sp=class extends Po{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new sp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},wl=class extends et{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let r=[],a=[];function s(e,t,n,i){let r=i+1,a=[];for(let s=0;s<=r;s++){a[s]=[];let i=e.clone().lerp(n,s/r),o=t.clone().lerp(n,s/r),l=r-s;for(let e=0;e<=l;e++)a[s][e]=0===e&&s===r?i:i.clone().lerp(o,e/l)}for(let s=0;s<r;s++)for(let e=0;e<2*(r-s)-1;e++){let t=Math.floor(e/2);e%2==0?(o(a[s][t+1]),o(a[s+1][t]),o(a[s][t])):(o(a[s][t+1]),o(a[s+1][t+1]),o(a[s+1][t]))}}function o(e){r.push(e.x,e.y,e.z)}function l(t,n){let i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function h(e,t,n,i){i<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=i/2/Math.PI+.5)}function c(e){return Math.atan2(e.z,-e.x)}function u(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(function(e){let n=new M,i=new M,r=new M;for(let a=0;a<t.length;a+=3)l(t[a+0],n),l(t[a+1],i),l(t[a+2],r),s(n,i,r,e)})(i),function(e){let t=new M;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){let e=new M;for(let t=0;t<r.length;t+=3){e.x=r[t+0],e.y=r[t+1],e.z=r[t+2];let n=c(e)/2/Math.PI+.5,i=u(e)/Math.PI+.5;a.push(n,1-i)}(function(){let e=new M,t=new M,n=new M,i=new M,s=new Q,o=new Q,l=new Q;for(let u=0,d=0;u<r.length;u+=9,d+=6){e.set(r[u+0],r[u+1],r[u+2]),t.set(r[u+3],r[u+4],r[u+5]),n.set(r[u+6],r[u+7],r[u+8]),s.set(a[d+0],a[d+1]),o.set(a[d+2],a[d+3]),l.set(a[d+4],a[d+5]),i.copy(e).add(t).add(n).divideScalar(3);let p=c(i);h(s,d+0,e,p),h(o,d+2,t,p),h(l,d+4,n,p)}})(),function(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],i=a[e+4],r=Math.max(t,n,i),s=Math.min(t,n,i);r>.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new tt(r,3)),this.setAttribute("normal",new tt(r.slice(),3)),this.setAttribute("uv",new tt(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wl(e.vertices,e.indices,e.radius,e.details)}},ap=class extends wl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ap(e.radius,e.detail)}},EM=new M,bM=new M,SN=new M,_M=new Rr,ja=class extends et{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){let n=Math.pow(10,4),i=Math.cos(Kf*t),r=e.getIndex(),a=e.getAttribute("position"),s=r?r.count:a.count,o=[0,0,0],l=["a","b","c"],h=new Array(3),c={},u=[];for(let e=0;e<s;e+=3){r?(o[0]=r.getX(e),o[1]=r.getX(e+1),o[2]=r.getX(e+2)):(o[0]=e,o[1]=e+1,o[2]=e+2);let{a:t,b:s,c:d}=_M;if(t.fromBufferAttribute(a,o[0]),s.fromBufferAttribute(a,o[1]),d.fromBufferAttribute(a,o[2]),_M.getNormal(SN),h[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,h[1]=`${Math.round(s.x*n)},${Math.round(s.y*n)},${Math.round(s.z*n)}`,h[2]=`${Math.round(d.x*n)},${Math.round(d.y*n)},${Math.round(d.z*n)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=h[e],r=h[t],a=_M[l[e]],s=_M[l[t]],d=`${n}_${r}`,p=`${r}_${n}`;p in c&&c[p]?(SN.dot(c[p].normal)<=i&&(u.push(a.x,a.y,a.z),u.push(s.x,s.y,s.z)),c[p]=null):d in c||(c[d]={index0:o[e],index1:o[t],normal:SN.clone()})}}for(let e in c)if(c[e]){let{index0:t,index1:n}=c[e];EM.fromBufferAttribute(a,t),bM.fromBufferAttribute(a,n),u.push(EM.x,EM.y,EM.z),u.push(bM.x,bM.y,bM.z)}this.setAttribute("position",new tt(u,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fs=class extends Ec{constructor(e){super(e),this.uuid=za(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push((new Ec).fromJSON(n))}return this}},ytt={triangulate:function(e,t,n=2){let i,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*n:e.length,d=sle(e,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=wtt(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(let t=n;t<u;t+=n)o=e[t],l=e[t+1],o<i&&(i=o),l<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return Zx(d,p,n,i,r,h,0),p}};function sle(e,t,n,i,r){let a,s;if(r===Ntt(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Nae(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Nae(a,e[a],e[a+1],s);return s&&yS(s,s.next)&&(Jx(s),s=s.next),s}function op(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!yS(i,i.next)&&0!==ni(i.prev,i,i.next))i=i.next;else{if(Jx(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Zx(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Ctt(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?btt(e,i,r,a):Ett(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Jx(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Zx(e=_tt(op(e),t,n),t,n,i,r,a,2):2===s&&Ttt(e,t,n,i,r,a):Zx(op(e),t,n,i,r,a,1);break}}function Ett(e){let t=e.prev,n=e,i=e.next;if(ni(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Hg(r,o,a,l,s,h,f.x,f.y)&&ni(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function btt(e,t,n,i){let r=e.prev,a=e,s=e.next;if(ni(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=CU(p,f,t,n,i),y=CU(m,g,t,n,i),x=e.prevZ,_=e.nextZ;for(;x&&x.z>=v&&_&&_.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Hg(o,c,l,u,h,d,x.x,x.y)&&ni(x.prev,x,x.next)>=0||(x=x.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&Hg(o,c,l,u,h,d,_.x,_.y)&&ni(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Hg(o,c,l,u,h,d,x.x,x.y)&&ni(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&Hg(o,c,l,u,h,d,_.x,_.y)&&ni(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function _tt(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!yS(r,a)&&ale(r,i,i.next,a)&&Kx(r,a)&&Kx(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Jx(i),Jx(i.next),i=e=a),i=i.next}while(i!==e);return op(i)}function Ttt(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Dtt(s,e)){let o=ole(s,e);return s=op(s,s.next),o=op(o,o.next),Zx(s,t,n,i,r,a,0),void Zx(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function wtt(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r<a;r++)s=t[r]*i,o=r<a-1?t[r+1]*i:e.length,l=sle(e,s,o,i,!1),l===l.next&&(l.steiner=!0),h.push(Itt(l));for(h.sort(Mtt),r=0;r<h.length;r++)n=Stt(h[r],n);return n}function Mtt(e,t){return e.x-t.x}function Stt(e,t){let n=Rtt(e,t);if(!n)return t;let i=ole(n,e);return op(i,i.next),op(n,n.next)}function Rtt(e,t){let n,i=t,r=-1/0,a=e.x,s=e.y;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x<i.next.x?i:i.next,e===a))return n}i=i.next}while(i!==t);if(!n)return null;let o,l=n,h=n.x,c=n.y,u=1/0;i=n;do{a>=i.x&&i.x>=h&&a!==i.x&&Hg(s<c?a:r,s,h,c,s<c?r:a,s,i.x,i.y)&&(o=Math.abs(s-i.y)/(a-i.x),Kx(i,e)&&(o<u||o===u&&(i.x>n.x||i.x===n.x&&Att(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function Att(e,t){return ni(e.prev,e,t.prev)<0&&ni(t.next,e,e.next)<0}function Ctt(e,t,n,i){let r=e;do{0===r.z&&(r.z=CU(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Ptt(r)}function Ptt(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t<h&&(o++,i=i.nextZ,i);t++);for(l=h;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function CU(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Itt(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 Hg(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Dtt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Ltt(e,t)&&(Kx(e,t)&&Kx(t,e)&&Ott(e,t)&&(ni(e.prev,e,t.prev)||ni(e,t.prev,t))||yS(e,t)&&ni(e.prev,e,e.next)>0&&ni(t.prev,t,t.next)>0)}function ni(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function yS(e,t){return e.x===t.x&&e.y===t.y}function ale(e,t,n,i){let r=wM(ni(e,t,n)),a=wM(ni(e,t,i)),s=wM(ni(n,i,e)),o=wM(ni(n,i,t));return!!(r!==a&&s!==o||0===r&&TM(e,n,t)||0===a&&TM(e,i,t)||0===s&&TM(n,e,i)||0===o&&TM(n,t,i))}function TM(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 wM(e){return e>0?1:e<0?-1:0}function Ltt(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&&ale(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Kx(e,t){return ni(e.prev,e,e.next)<0?ni(e,t,e.next)>=0&&ni(e,e.prev,t)>=0:ni(e,t,e.prev)<0||ni(e,e.next,t)<0}function Ott(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function ole(e,t){let n=new PU(e.i,e.x,e.y),i=new PU(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Nae(e,t,n,i){let r=new PU(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Jx(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 PU(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ntt(e,t,n,i){let r=0;for(let a=t,s=n-i;a<n;a+=i)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}var Wi=class{static area(e){let t=e.length,n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return.5*n}static isClockWise(e){return Wi.area(e)<0}static triangulateShape(e,t){let n=[],i=[],r=[];Uae(e),Bae(n,e);let a=e.length;t.forEach(Uae);for(let o=0;o<t.length;o++)i.push(a),a+=t[o].length,Bae(n,t[o]);let s=ytt.triangulate(n,i);for(let o=0;o<s.length;o+=3)r.push(s.slice(o,o+3));return r}};function Uae(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Bae(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var qu=class extends et{constructor(e=new Fs([new Q(.5,.5),new Q(-.5,.5),new Q(-.5,-.5),new Q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,i=[],r=[];for(let s=0,o=e.length;s<o;s++)a(e[s]);function a(e){let a,s,o,l,h,c=[],u=void 0!==t.curveSegments?t.curveSegments:12,d=void 0!==t.steps?t.steps:1,p=void 0!==t.depth?t.depth:1,f=void 0===t.bevelEnabled||t.bevelEnabled,m=void 0!==t.bevelThickness?t.bevelThickness:.2,g=void 0!==t.bevelSize?t.bevelSize:m-.1,v=void 0!==t.bevelOffset?t.bevelOffset:0,y=void 0!==t.bevelSegments?t.bevelSegments:3,x=t.extrudePath,_=void 0!==t.UVGenerator?t.UVGenerator:Utt,b=!1;x&&(a=x.getSpacedPoints(d),b=!0,f=!1,s=x.computeFrenetFrames(d,!1),o=new M,l=new M,h=new M),f||(y=0,m=0,g=0,v=0);let w=e.extractPoints(u),S=w.shape,E=w.holes;if(!Wi.isClockWise(S)){S=S.reverse();for(let e=0,t=E.length;e<t;e++){let t=E[e];Wi.isClockWise(t)&&(E[e]=t.reverse())}}let T=Wi.triangulateShape(S,E),A=S;for(let t=0,n=E.length;t<n;t++){let e=E[t];S=S.concat(e)}function C(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}let R=S.length,P=T.length;function L(e,t,n){let i,r,a,s=e.x-t.x,o=e.y-t.y,l=n.x-e.x,h=n.y-e.y,c=s*s+o*o,u=s*h-o*l;if(Math.abs(u)>Number.EPSILON){let u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=t.x-o/u,f=t.y+s/u,m=((n.x-h/d-p)*h-(n.y+l/d-f)*l)/(s*h-o*l);i=p+s*m-e.x,r=f+o*m-e.y;let g=i*i+r*r;if(g<=2)return new Q(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new Q(i/a,r/a)}let D=[];for(let t=0,n=A.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),D[t]=L(A[t],A[i],A[r]);let I,O=[],U=D.concat();for(let t=0,n=E.length;t<n;t++){let e=E[t];I=[];for(let t=0,n=e.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),I[t]=L(e[t],e[i],e[r]);O.push(I),U=U.concat(I)}for(let t=0;t<y;t++){let e=t/y,n=m*Math.cos(e*Math.PI/2),i=g*Math.sin(e*Math.PI/2)+v;for(let t=0,r=A.length;t<r;t++){let e=C(A[t],D[t],i);k(e.x,e.y,-n)}for(let t=0,r=E.length;t<r;t++){let e=E[t];I=O[t];for(let t=0,r=e.length;t<r;t++){let r=C(e[t],I[t],i);k(r.x,r.y,-n)}}}let N=g+v;for(let t=0;t<R;t++){let e=f?C(S[t],U[t],N):S[t];b?(l.copy(s.normals[0]).multiplyScalar(e.x),o.copy(s.binormals[0]).multiplyScalar(e.y),h.copy(a[0]).add(l).add(o),k(h.x,h.y,h.z)):k(e.x,e.y,0)}for(let t=1;t<=d;t++)for(let e=0;e<R;e++){let n=f?C(S[e],U[e],N):S[e];b?(l.copy(s.normals[t]).multiplyScalar(n.x),o.copy(s.binormals[t]).multiplyScalar(n.y),h.copy(a[t]).add(l).add(o),k(h.x,h.y,h.z)):k(n.x,n.y,p/d*t)}for(let t=y-1;t>=0;t--){let e=t/y,n=m*Math.cos(e*Math.PI/2),i=g*Math.sin(e*Math.PI/2)+v;for(let t=0,r=A.length;t<r;t++){let e=C(A[t],D[t],i);k(e.x,e.y,p+n)}for(let t=0,r=E.length;t<r;t++){let e=E[t];I=O[t];for(let t=0,r=e.length;t<r;t++){let r=C(e[t],I[t],i);b?k(r.x,r.y+a[d-1].y,a[d-1].x+n):k(r.x,r.y,p+n)}}}function F(e,t){let n=e.length;for(;--n>=0;){let i=n,r=n-1;r<0&&(r=e.length-1);for(let e=0,n=d+2*y;e<n;e++){let n=R*e,a=R*(e+1);z(t+i+n,t+r+n,t+r+a,t+i+a)}}}function k(e,t,n){c.push(e),c.push(t),c.push(n)}function B(e,t,r){V(e),V(t),V(r);let a=i.length/3,s=_.generateTopUV(n,i,a-3,a-2,a-1);H(s[0]),H(s[1]),H(s[2])}function z(e,t,r,a){V(e),V(t),V(a),V(t),V(r),V(a);let s=i.length/3,o=_.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);H(o[0]),H(o[1]),H(o[3]),H(o[1]),H(o[2]),H(o[3])}function V(e){i.push(c[3*e+0]),i.push(c[3*e+1]),i.push(c[3*e+2])}function H(e){r.push(e.x),r.push(e.y)}(function(){let e=i.length/3;if(f){let e=0,t=R*e;for(let n=0;n<P;n++){let e=T[n];B(e[2]+t,e[1]+t,e[0]+t)}e=d+2*y,t=R*e;for(let n=0;n<P;n++){let e=T[n];B(e[0]+t,e[1]+t,e[2]+t)}}else{for(let e=0;e<P;e++){let t=T[e];B(t[2],t[1],t[0])}for(let e=0;e<P;e++){let t=T[e];B(t[0]+R*d,t[1]+R*d,t[2]+R*d)}}n.addGroup(e,i.length/3-e,0)})(),function(){let e=i.length/3,t=0;F(A,t),t+=A.length;for(let n=0,i=E.length;n<i;n++){let e=E[n];F(e,t),t+=e.length}n.addGroup(e,i.length/3-e,1)}()}this.setAttribute("position",new tt(i,3)),this.setAttribute("uv",new tt(r,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return Btt(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){let n=[];for(let r=0,a=e.shapes.length;r<a;r++){let i=t[e.shapes[r]];n.push(i)}let i=e.options.extrudePath;return void 0!==i&&(e.options.extrudePath=(new UB[i.type]).fromJSON(i)),new qu(n,e.options)}},Utt={generateTopUV:function(e,t,n,i,r){let a=t[3*n],s=t[3*n+1],o=t[3*i],l=t[3*i+1],h=t[3*r],c=t[3*r+1];return[new Q(a,s),new Q(o,l),new Q(h,c)]},generateSideWallUV:function(e,t,n,i,r,a){let s=t[3*n],o=t[3*n+1],l=t[3*n+2],h=t[3*i],c=t[3*i+1],u=t[3*i+2],d=t[3*r],p=t[3*r+1],f=t[3*r+2],m=t[3*a],g=t[3*a+1],v=t[3*a+2];return Math.abs(o-c)<Math.abs(s-h)?[new Q(s,1-l),new Q(h,1-u),new Q(d,1-f),new Q(m,1-v)]:[new Q(o,1-l),new Q(c,1-u),new Q(p,1-f),new Q(g,1-v)]}};function Btt(e,t,n){if(n.shapes=[],Array.isArray(e))for(let i=0,r=e.length;i<r;i++){let t=e[i];n.shapes.push(t.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON()),n}var lp=class extends wl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lp(e.radius,e.detail)}},rd=class extends wl{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rd(e.radius,e.detail)}},cp=class extends et{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);let s=[],o=[],l=[],h=[],c=e,u=(t-e)/(i=Math.max(1,i)),d=new M,p=new Q;for(let f=0;f<=i;f++){for(let e=0;e<=n;e++){let i=r+e/n*a;d.x=c*Math.cos(i),d.y=c*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}c+=u}for(let f=0;f<i;f++){let e=f*(n+1);for(let t=0;t<n;t++){let i=t+e,r=i,a=i+n+1,o=i+n+2,l=i+1;s.push(r,a,l),s.push(a,o,l)}}this.setIndex(s),this.setAttribute("position",new tt(o,3)),this.setAttribute("normal",new tt(l,3)),this.setAttribute("uv",new tt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cp(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},bc=class extends et{constructor(e=new Fs([new Q(0,.5),new Q(-.5,-.5),new Q(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let n=[],i=[],r=[],a=[],s=0,o=0;if(!1===Array.isArray(e))l(e);else for(let h=0;h<e.length;h++)l(e[h]),this.addGroup(s,o,h),s+=o,o=0;function l(e){let s=i.length/3,l=e.extractPoints(t),h=l.shape,c=l.holes;!1===Wi.isClockWise(h)&&(h=h.reverse());for(let t=0,n=c.length;t<n;t++){let e=c[t];!0===Wi.isClockWise(e)&&(c[t]=e.reverse())}let u=Wi.triangulateShape(h,c);for(let t=0,n=c.length;t<n;t++){let e=c[t];h=h.concat(e)}for(let t=0,n=h.length;t<n;t++){let e=h[t];i.push(e.x,e.y,0),r.push(0,0,1),a.push(e.x,e.y)}for(let t=0,i=u.length;t<i;t++){let e=u[t],i=e[0]+s,r=e[1]+s,a=e[2]+s;n.push(i,r,a),o+=3}}this.setIndex(n),this.setAttribute("position",new tt(i,3)),this.setAttribute("normal",new tt(r,3)),this.setAttribute("uv",new tt(a,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return Ftt(this.parameters.shapes,e)}static fromJSON(e,t){let n=[];for(let i=0,r=e.shapes.length;i<r;i++){let r=t[e.shapes[i]];n.push(r)}return new bc(n,e.curveSegments)}};function Ftt(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++){let i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}var da=class extends et{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:s},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let o=Math.min(a+s,Math.PI),l=0,h=[],c=new M,u=new M,d=[],p=[],f=[],m=[];for(let g=0;g<=n;g++){let d=[],v=g/n,y=0;0===g&&0===a?y=.5/t:g===n&&o===Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){let o=n/t;c.x=-e*Math.cos(i+o*r)*Math.sin(a+v*s),c.y=e*Math.cos(a+v*s),c.z=e*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(o+y,1-v),d.push(l++)}h.push(d)}for(let g=0;g<n;g++)for(let e=0;e<t;e++){let t=h[g][e+1],i=h[g][e],r=h[g+1][e],s=h[g+1][e+1];(0!==g||a>0)&&d.push(t,i,s),(g!==n-1||o<Math.PI)&&d.push(i,r,s)}this.setIndex(d),this.setAttribute("position",new tt(p,3)),this.setAttribute("normal",new tt(f,3)),this.setAttribute("uv",new tt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new da(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},up=class extends wl{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new up(e.radius,e.detail)}},Wu=class extends et{constructor(e=1,t=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);let a=[],s=[],o=[],l=[],h=new M,c=new M,u=new M;for(let d=0;d<=n;d++)for(let a=0;a<=i;a++){let p=a/i*r,f=d/n*Math.PI*2;c.x=(e+t*Math.cos(f))*Math.cos(p),c.y=(e+t*Math.cos(f))*Math.sin(p),c.z=t*Math.sin(f),s.push(c.x,c.y,c.z),h.x=e*Math.cos(p),h.y=e*Math.sin(p),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(a/i),l.push(d/n)}for(let d=1;d<=n;d++)for(let e=1;e<=i;e++){let t=(i+1)*d+e-1,n=(i+1)*(d-1)+e-1,r=(i+1)*(d-1)+e,s=(i+1)*d+e;a.push(t,n,s),a.push(n,r,s)}this.setIndex(a),this.setAttribute("position",new tt(s,3)),this.setAttribute("normal",new tt(o,3)),this.setAttribute("uv",new tt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wu(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},hp=class extends et{constructor(e=1,t=.4,n=64,i=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:a},n=Math.floor(n),i=Math.floor(i);let s=[],o=[],l=[],h=[],c=new M,u=new M,d=new M,p=new M,f=new M,m=new M,g=new M;for(let y=0;y<=n;++y){let s=y/n*r*Math.PI*2;v(s,r,a,e,d),v(s+.01,r,a,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=i;++e){let r=e/i*Math.PI*2,a=-t*Math.cos(r),s=t*Math.sin(r);c.x=d.x+(a*g.x+s*f.x),c.y=d.y+(a*g.y+s*f.y),c.z=d.z+(a*g.z+s*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(y/n),h.push(e/i)}}for(let y=1;y<=n;y++)for(let e=1;e<=i;e++){let t=(i+1)*(y-1)+(e-1),n=(i+1)*y+(e-1),r=(i+1)*y+e,a=(i+1)*(y-1)+e;s.push(t,n,a),s.push(n,r,a)}function v(e,t,n,i,r){let a=Math.cos(e),s=Math.sin(e),o=n/t*e,l=Math.cos(o);r.x=i*(2+l)*.5*a,r.y=i*(2+l)*s*.5,r.z=i*Math.sin(o)*.5}this.setIndex(s),this.setAttribute("position",new tt(o,3)),this.setAttribute("normal",new tt(l,3)),this.setAttribute("uv",new tt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hp(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},dp=class extends et{constructor(e=new $x(new M(-1,-1,0),new M(-1,1,0),new M(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};let a=e.computeFrenetFrames(t,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let s=new M,o=new M,l=new Q,h=new M,c=[],u=[],d=[],p=[];function f(r){h=e.getPointAt(r/t,h);let l=a.normals[r],d=a.binormals[r];for(let e=0;e<=i;e++){let t=e/i*Math.PI*2,r=Math.sin(t),a=-Math.cos(t);o.x=a*l.x+r*d.x,o.y=a*l.y+r*d.y,o.z=a*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=h.x+n*o.x,s.y=h.y+n*o.y,s.z=h.z+n*o.z,c.push(s.x,s.y,s.z)}}(function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=i;n++)l.x=e/t,l.y=n/i,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=i;t++){let n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),a=(i+1)*e+t,s=(i+1)*(e-1)+t;p.push(n,r,s),p.push(r,a,s)}}()})(),this.setIndex(p),this.setAttribute("position",new tt(c,3)),this.setAttribute("normal",new tt(u,3)),this.setAttribute("uv",new tt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new dp((new UB[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},KM=class extends et{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){let t=[],n=new Set,i=new M,r=new M;if(null!==e.index){let a=e.attributes.position,s=e.index,o=e.groups;0===o.length&&(o=[{start:0,count:s.count,materialIndex:0}]);for(let e=0,l=o.length;e<l;++e){let l=o[e],h=l.start;for(let e=h,o=h+l.count;e<o;e+=3)for(let l=0;l<3;l++){let o=s.getX(e+l),h=s.getX(e+(l+1)%3);i.fromBufferAttribute(a,o),r.fromBufferAttribute(a,h),!0===Fae(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{let a=e.attributes.position;for(let e=0,s=a.count/3;e<s;e++)for(let o=0;o<3;o++){let s=3*e+o,l=3*e+(o+1)%3;i.fromBufferAttribute(a,s),r.fromBufferAttribute(a,l),!0===Fae(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new tt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function Fae(e,t,n){let i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var Hae=Object.freeze({__proto__:null,BoxGeometry:Qi,CapsuleGeometry:rp,CircleGeometry:ip,ConeGeometry:sp,CylinderGeometry:Po,DodecahedronGeometry:ap,EdgesGeometry:ja,ExtrudeGeometry:qu,IcosahedronGeometry:lp,LatheGeometry:nd,OctahedronGeometry:rd,PlaneGeometry:Ur,PolyhedronGeometry:wl,RingGeometry:cp,ShapeGeometry:bc,SphereGeometry:da,TetrahedronGeometry:up,TorusGeometry:Wu,TorusKnotGeometry:hp,TubeGeometry:dp,WireframeGeometry:KM}),JM=class extends Rn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ie(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}},QM=class extends It{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},id=class extends Rn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ie(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 Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.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.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}},Io=class extends id{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return pi(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 Ie(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 Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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 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.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.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}},es=class extends Rn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ie(16777215),this.specular=new Ie(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=dy,this.reflectivity=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.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.flatShading=e.flatShading,this.fog=e.fog,this}},eS=class extends Rn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ie(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(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}},sd=class extends Rn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(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}},_c=class extends Rn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=dy,this.reflectivity=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.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.flatShading=e.flatShading,this.fog=e.fog,this}},tS=class extends Rn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ie(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cd,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.flatShading=e.flatShading,this.fog=e.fog,this}},fp=class extends Jt{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 So(e,t,n){return BB(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function $f(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function BB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function lle(e){let t=e.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n}function IU(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function FB(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}function Htt(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let l=0;l<a.tracks.length;++l){let e=a.tracks[l],t=e.getValueSize(),o=[],h=[];for(let a=0;a<e.times.length;++a){let s=e.times[a]*r;if(!(s<n||s>=i)){o.push(e.times[a]);for(let n=0;n<t;++n)h.push(e.values[a*t+n])}}0!==o.length&&(e.times=$f(o,e.times.constructor),e.values=$f(h,e.values.constructor),s.push(e))}a.tracks=s;let o=1/0;for(let l=0;l<a.tracks.length;++l)o>a.tracks[l].times[0]&&(o=a.tracks[l].times[0]);for(let l=0;l<a.tracks.length;++l)a.tracks[l].shift(-1*o);return a.resetDuration(),a}function ktt(e,t=0,n=e,i=30){i<=0&&(i=30);let r=n.tracks.length,a=t/i;for(let s=0;s<r;++s){let t=n.tracks[s],i=t.ValueTypeName;if("bool"===i||"string"===i)continue;let r=e.tracks.find((function(e){return e.name===t.name&&e.ValueTypeName===i}));if(void 0===r)continue;let o=0,l=t.getValueSize();t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let h=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);let u,d=t.times.length-1;if(a<=t.times[0]){let e=o,n=l-o;u=So(t.values,e,n)}else if(a>=t.times[d]){let e=d*l+o,n=e+l-o;u=So(t.values,e,n)}else{let e=t.createInterpolant(),n=o,i=l-o;e.evaluate(a),u=So(e.resultBuffer,n,i)}"quaternion"===i&&(new En).fromArray(u).normalize().conjugate().toArray(u);let p=r.times.length;for(let e=0;e<p;++e){let t=e*c+h;if("quaternion"===i)En.multiplyQuaternionsFlat(r.values,t,u,0,r.values,t);else{let e=c-2*h;for(let n=0;n<e;++n)r.values[t+n]-=u[n]}}}return e.blendMode=CB,e}var Vtt={arraySlice:So,convertArray:$f,isTypedArray:BB,getKeyframeOrder:lle,sortedArray:IU,flattenJSON:FB,subclip:Htt,makeClipAdditive:ktt},ju=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let a=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}a=t.length;break n}if(e>=r)break e;{let s=t[1];e<s&&(n=2,r=s);for(let a=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}a=n,n=0}}for(;n<a;){let i=n+a>>>1;e<t[i]?a=i:n=i+1}if(i=t[n],r=t[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},nS=class extends ju{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Xf,endingEnd:Xf}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,a=e+1,s=i[r],o=i[a];if(void 0===s)switch(this.getSettings_().endingStart){case Yf:r=e,s=2*t-n;break;case Fx:r=i.length-2,s=t+i[r]-i[r+1];break;default:r=e,s=n}if(void 0===o)switch(this.getSettings_().endingEnd){case Yf:a=e,o=2*n-t;break;case Fx:a=1,o=n+i[1]-i[0];break;default:a=e-1,o=t}let l=.5*(n-t),h=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(o-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let _=0;_!==s;++_)r[_]=g*a[h+_]+v*a[l+_]+y*a[o+_]+x*a[c+_];return r}},Qx=class extends ju{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=(n-t)/(i-t),c=1-h;for(let u=0;u!==s;++u)r[u]=a[l+u]*c+a[o+u]*h;return r}},rS=class extends ju{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Xa=class{constructor(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=$f(t,this.TimeBufferType),this.values=$f(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t,n=e.constructor;if(n.toJSON!==this.toJSON)t=n.toJSON(e);else{t={name:e.name,times:$f(e.times,Array),values:$f(e.values,Array)};let n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new rS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Qx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new nS(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bu:t=this.InterpolantFactoryMethodDiscrete;break;case vc:t=this.InterpolantFactoryMethodLinear;break;case BM:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){let t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bu;case this.InterpolantFactoryMethodLinear:return vc;case this.InterpolantFactoryMethodSmooth:return BM}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==a&&n[a]>t;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let e=this.getValueSize();this.times=So(n,r,a),this.values=So(this.values,r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let s=0;s!==r;s++){let t=n[s];if("number"==typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,t),e=!1;break}if(null!==a&&a>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,t,a),e=!1;break}a=t}if(void 0!==i&&BB(i))for(let s=0,o=i.length;s!==o;++s){let t=i[s];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,t),e=!1;break}}return e}optimize(){let e=So(this.times),t=So(this.values),n=this.getValueSize(),i=this.getInterpolation()===BM,r=e.length-1,a=1;for(let s=1;s<r;++s){let r=!1,o=e[s];if(o!==e[s+1]&&(1!==s||o!==e[0]))if(i)r=!0;else{let e=s*n,i=e-n,a=e+n;for(let s=0;s!==n;++s){let n=t[e+s];if(n!==t[i+s]||n!==t[a+s]){r=!0;break}}}if(r){if(s!==a){e[a]=e[s];let i=s*n,r=a*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++a}}if(r>0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=So(e,0,a),this.values=So(t,0,a*n)):(this.times=e,this.values=t),this}clone(){let e=So(this.times,0),t=So(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};Xa.prototype.TimeBufferType=Float32Array,Xa.prototype.ValueBufferType=Float32Array,Xa.prototype.DefaultInterpolation=vc;var Xu=class extends Xa{};Xu.prototype.ValueTypeName="bool",Xu.prototype.ValueBufferType=Array,Xu.prototype.DefaultInterpolation=Bu,Xu.prototype.InterpolantFactoryMethodLinear=void 0,Xu.prototype.InterpolantFactoryMethodSmooth=void 0;var ey=class extends Xa{};ey.prototype.ValueTypeName="color";var Ml=class extends Xa{};Ml.prototype.ValueTypeName="number";var iS=class extends ju{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let h=l+s;l!==h;l+=4)En.slerpFlat(r,0,a,l-s,a,l,o);return r}},zs=class extends Xa{InterpolantFactoryMethodLinear(e){return new iS(this.times,this.values,this.getValueSize(),e)}};zs.prototype.ValueTypeName="quaternion",zs.prototype.DefaultInterpolation=vc,zs.prototype.InterpolantFactoryMethodSmooth=void 0;var Yu=class extends Xa{};Yu.prototype.ValueTypeName="string",Yu.prototype.ValueBufferType=Array,Yu.prototype.DefaultInterpolation=Bu,Yu.prototype.InterpolantFactoryMethodLinear=void 0,Yu.prototype.InterpolantFactoryMethodSmooth=void 0;var fa=class extends Xa{};fa.prototype.ValueTypeName="vector";var pa=class{constructor(e,t=-1,n,i=vS){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=za(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,s=n.length;a!==s;++a)t.push(Gtt(n[a]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(Xa.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let s=0;s<r;s++){let e=[],o=[];e.push((s+r-1)%r,s,(s+1)%r),o.push(0,1,0);let l=lle(e);e=IU(e,1,l),o=IU(o,1,l),!i&&0===e[0]&&(e.push(r),o.push(o[0])),a.push(new Ml(".morphTargetInfluences["+t[s].name+"]",e,o).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let s=0,o=e.length;s<o;s++){let t=e[s],n=t.name.match(r);if(n&&n.length>1){let e=n[1],r=i[e];r||(i[e]=r=[]),r.push(t)}}let a=[];for(let s in i)a.push(this.CreateFromMorphTargetSequence(s,i[s],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];FB(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let e=l[h].keys;if(e&&0!==e.length)if(e[0].morphTargets){let t,n={};for(t=0;t<e.length;t++)if(e[t].morphTargets)for(let i=0;i<e[t].morphTargets.length;i++)n[e[t].morphTargets[i]]=-1;for(let r in n){let n=[],a=[];for(let i=0;i!==e[t].morphTargets.length;++i){let i=e[t];n.push(i.time),a.push(i.morphTarget===r?1:0)}i.push(new Ml(".morphTargetInfluence["+r+"]",n,a))}o=n.length*a}else{let r=".bones["+t[h].name+"]";n(fa,r+".position",e,"pos",i),n(zs,r+".quaternion",e,"rot",i),n(fa,r+".scale",e,"scl",i)}}return 0===i.length?null:new this(r,o,i,s)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){let n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function ztt(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ml;case"vector":case"vector2":case"vector3":case"vector4":return fa;case"color":return ey;case"quaternion":return zs;case"bool":case"boolean":return Xu;case"string":return Yu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Gtt(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ztt(e.type);if(void 0===e.times){let t=[],n=[];FB(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var MM,pp={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},Tc=class{constructor(e,t,n){let i,r=this,a=!1,s=0,o=0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===a&&void 0!==r.onStart&&r.onStart(e,s,o),a=!0},this.itemEnd=function(e){s++,void 0!==r.onProgress&&r.onProgress(e,s,o),s===o&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){let t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){let n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}},ma=new Tc,nr=class{constructor(e){this.manager=void 0!==e?e:ma,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise((function(i,r){n.load(e,i,t,r)}))}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}},Pu={},DU=class extends Error{constructor(e,t){super(e),this.response=t}},rr=class extends nr{constructor(e){super(e)}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=pp.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Pu[e])return void Pu[e].push({onLoad:t,onProgress:n,onError:i});Pu[e]=[],Pu[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;let n=Pu[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a,o=0,l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e<t;e++){let t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}}))}()}});return new Response(l)}throw new DU(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{pp.add(e,t);let n=Pu[e];delete Pu[e];for(let e=0,i=n.length;e<i;e++){let i=n[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{let n=Pu[e];if(void 0===n)throw this.manager.itemError(e),t;delete Pu[e];for(let e=0,i=n.length;e<i;e++){let i=n[e];i.onError&&i.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},LU=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new rr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){let t=[];for(let n=0;n<e.length;n++){let i=pa.parse(e[n]);t.push(i)}return t}},OU=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=[],s=new jx,o=new rr(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function h(h){o.load(e[h],(function(e){let n=r.parse(e,!0);a[h]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(s.minFilter=Vn),s.image=a,s.format=n.format,s.needsUpdate=!0,t&&t(s))}),n,i)}if(Array.isArray(e))for(let c=0,u=e.length;c<u;++c)h(c);else o.load(e,(function(e){let n=r.parse(e,!0);if(n.isCubemap){let e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)a[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),a[t].format=n.format,a[t].width=n.width,a[t].height=n.height}s.image=a}else s.image.width=n.width,s.image.height=n.height,s.mipmaps=n.mipmaps;1===n.mipmapCount&&(s.minFilter=Vn),s.format=n.format,s.needsUpdate=!0,t&&t(s)}),n,i);return s}},mp=class extends nr{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=pp.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;let s=kx("img");function o(){h(),pp.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){h(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}},ty=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=new ep,a=new mp(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let s=0;function o(n){a.load(e[n],(function(e){r.images[n]=e,s++,6===s&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(let l=0;l<e.length;++l)o(l);return r}},gp=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Ro,s=new rr(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let n=r.parse(e);n&&(void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:Or,a.wrapT=void 0!==n.wrapT?n.wrapT:Or,a.magFilter=void 0!==n.magFilter?n.magFilter:Vn,a.minFilter=void 0!==n.minFilter?n.minFilter:Vn,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace?a.colorSpace=n.colorSpace:void 0!==n.encoding&&(a.encoding=n.encoding),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=Hs),1===n.mipmapCount&&(a.minFilter=Vn),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n))}),n,i),a}},Ai=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=new ur,a=new mp(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}},Do=class extends Tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}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,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}},ad=class extends Do{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ie(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},RN=new Ae,kae=new M,Vae=new M,ny=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Q(512,512),this.map=null,this.mapPass=null,this.matrix=new Ae,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ps,this._frameExtents=new Q(1,1),this._viewportCount=1,this._viewports=[new Mn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;kae.setFromMatrixPosition(e.matrixWorld),t.position.copy(kae),Vae.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Vae),t.updateMatrixWorld(),RN.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(RN),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(RN)}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.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){let e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},NU=class extends ny{constructor(){super(new bn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=2*zg*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},wc=class extends Do{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new NU}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}},zae=new Ae,Cx=new M,AN=new M,UU=class extends ny{constructor(){super(new bn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Q(4,2),this._viewportCount=6,this._viewports=[new Mn(2,1,1,1),new Mn(0,1,1,1),new Mn(3,1,1,1),new Mn(1,1,1,1),new Mn(3,0,1,1),new Mn(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Cx.setFromMatrixPosition(e.matrixWorld),n.position.copy(Cx),AN.copy(n.position),AN.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(AN),n.updateMatrixWorld(),i.makeTranslation(-Cx.x,-Cx.y,-Cx.z),zae.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zae)}},Sl=class extends Do{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new UU}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}},BU=class extends ny{constructor(){super(new dr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ji=class extends Do{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new BU}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Lo=class extends Do{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},sS=class extends Do{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}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}},aS=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new M)}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,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*i*1.092548),t.addScaledVector(a[5],i*r*1.092548),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],n*r*1.092548),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){let n=e.x,i=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*i),t.addScaledVector(a[2],1.023328*r),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*i),t.addScaledVector(a[5],.858086*i*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],.858086*n*r),t.addScaledVector(a[8],.429043*(n*n-i*i)),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 i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){let n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}},$g=class extends Do{constructor(e=new aS,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Zg=class extends nr{constructor(e){super(e),this.textures={}}load(e,t,n,i){let r=this,a=new rr(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){let t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}let i=Zg.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new Ie).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(i.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let r in e.uniforms){let t=e.uniforms[r];switch(i.uniforms[r]={},t.type){case"t":i.uniforms[r].value=n(t.value);break;case"c":i.uniforms[r].value=(new Ie).setHex(t.value);break;case"v2":i.uniforms[r].value=(new Q).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new M).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new Mn).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new Wt).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new Ae).fromArray(t.value);break;default:i.uniforms[r].value=t.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let r in e.extensions)i.extensions[r]=e.extensions[r];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Q).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Q).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:JM,SpriteMaterial:Wx,RawShaderMaterial:QM,ShaderMaterial:It,PointsMaterial:Br,MeshPhysicalMaterial:Io,MeshStandardMaterial:id,MeshPhongMaterial:es,MeshToonMaterial:eS,MeshNormalMaterial:sd,MeshLambertMaterial:_c,MeshDepthMaterial:ku,MeshDistanceMaterial:qx,MeshBasicMaterial:Pt,MeshMatcapMaterial:tS,LineDashedMaterial:fp,LineBasicMaterial:Jt,Material:Rn}[e]}},ts=class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},oS=class extends et{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},lS=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new rr(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){let t={},n={};function i(e,i){if(void 0!==t[i])return t[i];let r=e.interleavedBuffers[i],a=function(e,t){if(void 0!==n[t])return n[t];let i=e.arrayBuffers[t],r=new Uint32Array(i).buffer;return n[t]=r,r}(e,r.buffer),s=Bg(r.type,a),o=new Vu(s,r.stride);return o.uuid=r.uuid,t[i]=o,o}let r=e.isInstancedBufferGeometry?new oS:new et,a=e.data.index;if(void 0!==a){let e=Bg(a.type,a.array);r.setIndex(new Ct(e,1))}let s=e.data.attributes;for(let c in s){let t,n=s[c];if(n.isInterleavedBufferAttribute){let r=i(e.data,n.data);t=new ha(r,n.itemSize,n.offset,n.normalized)}else{let e=Bg(n.type,n.array);t=new(n.isInstancedBufferAttribute?zu:Ct)(e,n.itemSize,n.normalized)}void 0!==n.name&&(t.name=n.name),void 0!==n.usage&&t.setUsage(n.usage),void 0!==n.updateRange&&(t.updateRange.offset=n.updateRange.offset,t.updateRange.count=n.updateRange.count),r.setAttribute(c,t)}let o=e.data.morphAttributes;if(o)for(let c in o){let t=o[c],n=[];for(let r=0,a=t.length;r<a;r++){let a,s=t[r];if(s.isInterleavedBufferAttribute){let t=i(e.data,s.data);a=new ha(t,s.itemSize,s.offset,s.normalized)}else{let e=Bg(s.type,s.array);a=new Ct(e,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),n.push(a)}r.morphAttributes[c]=n}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let c=0,u=l.length;c!==u;++c){let e=l[c];r.addGroup(e.start,e.count,e.materialIndex)}let h=e.data.boundingSphere;if(void 0!==h){let e=new M;void 0!==h.center&&e.fromArray(h.center),r.boundingSphere=new hr(e,h.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}},FU=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===this.path?ts.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let s=new rr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){let a=null;try{a=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}let s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+e)),void console.error("THREE.ObjectLoader: Can't load "+e);r.parse(a,t)}),n,i)}loadAsync(e,t){return $e(this,null,(function*(){let n=""===this.path?ts.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;let i=new rr(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);let r=yield i.loadAsync(e,t),a=JSON.parse(r),s=a.metadata;if(void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return yield this.parseAsync(a)}))}parse(e,t){let n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),s=this.parseTextures(e.textures,a),o=this.parseMaterials(e.materials,s),l=this.parseObject(e.object,r,o,s,n),h=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,h),void 0!==t){let e=!1;for(let t in a)if(a[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}parseAsync(e){return $e(this,null,(function*(){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,r),s=this.parseMaterials(e.materials,a),o=this.parseObject(e.object,i,s,a,t),l=this.parseSkeletons(e.skeletons,o);return this.bindSkeletons(o,l),o}))}parseShapes(e){let t={};if(void 0!==e)for(let n=0,i=e.length;n<i;n++){let i=(new Fs).fromJSON(e[n]);t[i.uuid]=i}return t}parseSkeletons(e,t){let n={},i={};if(t.traverse((function(e){e.isBone&&(i[e.uuid]=e)})),void 0!==e)for(let r=0,a=e.length;r<a;r++){let t=(new Co).fromJSON(e[r],i);n[t.uuid]=t}return n}parseGeometries(e,t){let n={};if(void 0!==e){let i=new lS;for(let r=0,a=e.length;r<a;r++){let a,s=e[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(s);break;default:s.type in Hae?a=Hae[s.type].fromJSON(s,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${s.type}"`)}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.userData&&(a.userData=s.userData),n[s.uuid]=a}}return n}parseMaterials(e,t){let n={},i={};if(void 0!==e){let r=new Zg;r.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];void 0===n[a.uuid]&&(n[a.uuid]=r.parse(a)),i[a.uuid]=n[a.uuid]}}return i}parseAnimations(e){let t={};if(void 0!==e)for(let n=0;n<e.length;n++){let i=e[n],r=pa.parse(i);t[r.uuid]=r}return t}parseImages(e,t){let n,i=this,r={};function a(e){if("string"==typeof e){let t=e;return function(e){return i.manager.itemStart(e),n.load(e,(function(){i.manager.itemEnd(e)}),void 0,(function(){i.manager.itemError(e),i.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:i.resourcePath+t)}return e.data?{data:Bg(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){let i=new Tc(t);n=new mp(i),n.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.url;if(Array.isArray(i)){let e=[];for(let t=0,n=i.length;t<n;t++){let n=a(i[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new Ro(n.data,n.width,n.height)))}r[n.uuid]=new Tl(e)}else{let e=a(n.url);r[n.uuid]=new Tl(e)}}}return r}parseImagesAsync(e){return $e(this,null,(function*(){let t,n=this,i={};function r(e){return $e(this,null,(function*(){if("string"==typeof e){let i=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:n.resourcePath+i;return yield t.loadAsync(r)}return e.data?{data:Bg(e.type,e.data),width:e.width,height:e.height}:null}))}if(void 0!==e&&e.length>0){t=new mp(this.manager),t.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){let n=e[t],a=n.url;if(Array.isArray(a)){let e=[];for(let t=0,n=a.length;t<n;t++){let n=a[t],i=yield r(n);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new Ro(i.data,i.width,i.height)))}i[n.uuid]=new Tl(e)}else{let e=yield r(n.url);i[n.uuid]=new Tl(e)}}}return i}))}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}let i={};if(void 0!==e)for(let r=0,a=e.length;r<a;r++){let a=e[r];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===t[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let s,o=t[a.image],l=o.data;Array.isArray(l)?(s=new ep,6===l.length&&(s.needsUpdate=!0)):(s=l&&l.data?new Ro:new ur,l&&(s.needsUpdate=!0)),s.source=o,s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.mapping&&(s.mapping=n(a.mapping,qtt)),void 0!==a.channel&&(s.channel=a.channel),void 0!==a.offset&&s.offset.fromArray(a.offset),void 0!==a.repeat&&s.repeat.fromArray(a.repeat),void 0!==a.center&&s.center.fromArray(a.center),void 0!==a.rotation&&(s.rotation=a.rotation),void 0!==a.wrap&&(s.wrapS=n(a.wrap[0],Gae),s.wrapT=n(a.wrap[1],Gae)),void 0!==a.format&&(s.format=a.format),void 0!==a.internalFormat&&(s.internalFormat=a.internalFormat),void 0!==a.type&&(s.type=a.type),void 0!==a.colorSpace&&(s.colorSpace=a.colorSpace),void 0!==a.encoding&&(s.encoding=a.encoding),void 0!==a.minFilter&&(s.minFilter=n(a.minFilter,qae)),void 0!==a.magFilter&&(s.magFilter=n(a.magFilter,qae)),void 0!==a.anisotropy&&(s.anisotropy=a.anisotropy),void 0!==a.flipY&&(s.flipY=a.flipY),void 0!==a.generateMipmaps&&(s.generateMipmaps=a.generateMipmaps),void 0!==a.premultiplyAlpha&&(s.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(s.unpackAlignment=a.unpackAlignment),void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}return i}parseObject(e,t,n,i,r){let a,s,o;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function h(e){if(void 0!==e){if(Array.isArray(e)){let t=[];for(let i=0,r=e.length;i<r;i++){let r=e[i];void 0===n[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),t.push(n[r])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function c(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":a=new ii,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new Ie(e.background):a.background=c(e.background)),void 0!==e.environment&&(a.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new xc(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new jg(e.fog.color,e.fog.density))),void 0!==e.backgroundBlurriness&&(a.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(a.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":a=new bn(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new dr(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Lo(e.color,e.intensity);break;case"DirectionalLight":a=new ji(e.color,e.intensity);break;case"PointLight":a=new Sl(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new sS(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new wc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new ad(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new $g).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),o=h(e.material),a=new yc(s,o),void 0!==e.bindMode&&(a.bindMode=e.bindMode),void 0!==e.bindMatrix&&a.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(a.skeleton=e.skeleton);break;case"Mesh":s=l(e.geometry),o=h(e.material),a=new Ge(s,o);break;case"InstancedMesh":s=l(e.geometry),o=h(e.material);let t=e.count,n=e.instanceMatrix,i=e.instanceColor;a=new Ar(s,o,t),a.instanceMatrix=new zu(new Float32Array(n.array),16),void 0!==i&&(a.instanceColor=new zu(new Float32Array(i.array),i.itemSize));break;case"LOD":a=new jM;break;case"Line":a=new sn(l(e.geometry),h(e.material));break;case"LineLoop":a=new Xg(l(e.geometry),h(e.material));break;case"LineSegments":a=new Dn(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new or(l(e.geometry),h(e.material));break;case"Sprite":a=new WM(h(e.material));break;case"Group":a=new Nt;break;case"Bone":a=new Ao;break;default:a=new Tt}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children){let s=e.children;for(let e=0;e<s.length;e++)a.add(this.parseObject(s[e],t,n,i,r))}if(void 0!==e.animations){let t=e.animations;for(let e=0;e<t.length;e++){let n=t[e];a.animations.push(r[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(a.autoUpdate=e.autoUpdate);let t=e.levels;for(let e=0;e<t.length;e++){let n=t[e],i=a.getObjectByProperty("uuid",n.object);void 0!==i&&a.addLevel(i,n.distance,n.hysteresis)}}return a}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){let n=t[e.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}},qtt={UVMapping:pS,CubeReflectionMapping:Jh,CubeRefractionMapping:Qh,EquirectangularReflectionMapping:Jf,EquirectangularRefractionMapping:Bx,CubeUVReflectionMapping:tv},Gae={RepeatWrapping:Nr,ClampToEdgeWrapping:Or,MirroredRepeatWrapping:Nu},qae={NearestFilter:cr,NearestMipmapNearestFilter:ed,NearestMipmapLinearFilter:Du,LinearFilter:Vn,LinearMipmapNearestFilter:vp,LinearMipmapLinearFilter:Hs},ry=class extends nr{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=pp.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;let s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){pp.add(e,n),t&&t(n),r.manager.itemEnd(e)})).catch((function(t){i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}},iy=class{static getContext(){return void 0===MM&&(MM=new(window.AudioContext||window.webkitAudioContext)),MM}static setContext(e){MM=e}},HU=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new rr(this.manager);function s(t){i?i(t):console.error(t),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){try{let n=e.slice(0);iy.getContext().decodeAudioData(n,(function(e){t(e)}),s)}catch(e){s(e)}}),n,i)}},kU=class extends $g{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;let i=(new Ie).set(e),r=(new Ie).set(t),a=new M(i.r,i.g,i.b),s=new M(r.r,r.g,r.b),o=Math.sqrt(Math.PI),l=o*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(s).multiplyScalar(o),this.sh.coefficients[1].copy(a).sub(s).multiplyScalar(l)}},VU=class extends $g{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;let n=(new Ie).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}},Wae=new Ae,jae=new Ae,kf=new Ae,zU=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new bn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new bn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,kf.copy(e.projectionMatrix);let n,i,r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(Kf*t.fov*.5)/t.zoom;jae.elements[12]=-r,Wae.elements[12]=r,n=-s*t.aspect+a,i=s*t.aspect+a,kf.elements[0]=2*t.near/(i-n),kf.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy(kf),n=-s*t.aspect-a,i=s*t.aspect-a,kf.elements[0]=2*t.near/(i-n),kf.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy(kf)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(jae),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Wae)}},Oo=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Xae(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Xae();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Xae(){return("undefined"==typeof performance?Date:performance).now()}var Vf=new M,Yae=new En,Wtt=new M,zf=new M,GU=class extends Tt{constructor(){super(),this.type="AudioListener",this.context=iy.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Oo}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Vf,Yae,Wtt),zf.set(0,0,-1).applyQuaternion(Yae),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Vf.x,e),t.positionY.linearRampToValueAtTime(Vf.y,e),t.positionZ.linearRampToValueAtTime(Vf.z,e),t.forwardX.linearRampToValueAtTime(zf.x,e),t.forwardY.linearRampToValueAtTime(zf.y,e),t.forwardZ.linearRampToValueAtTime(zf.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Vf.x,Vf.y,Vf.z),t.setOrientation(zf.x,zf.y,zf.z,n.x,n.y,n.z)}},cS=class extends Tt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Gf=new M,$ae=new En,jtt=new M,qf=new M,qU=class extends cS{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Gf,$ae,jtt),qf.set(0,0,1).applyQuaternion($ae);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Gf.x,e),t.positionY.linearRampToValueAtTime(Gf.y,e),t.positionZ.linearRampToValueAtTime(Gf.z,e),t.orientationX.linearRampToValueAtTime(qf.x,e),t.orientationY.linearRampToValueAtTime(qf.y,e),t.orientationZ.linearRampToValueAtTime(qf.z,e)}else t.setPosition(Gf.x,Gf.y,Gf.z),t.setOrientation(qf.x,qf.y,qf.z)}},WU=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},uS=class{constructor(e,t,n){let i,r,a;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,a=this.cumulativeWeight;if(0===a){for(let e=0;e!==i;++e)n[r+e]=n[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(n,r,0,e,i)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let e=t*this._origIndex;this._mixBufferRegion(n,i,e,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(n[o]!==n[o+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){En.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;En.multiplyQuaternionsFlat(e,a,e,t,e,n),En.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}},HB="\\[\\]\\.:\\/",Xtt=new RegExp("["+HB+"]","g"),kB="[^"+HB+"]",Ytt="[^"+HB.replace("\\.","")+"]",$tt=/((?:WC+[\/:])*)/.source.replace("WC",kB),Ztt=/(WCOD+)?/.source.replace("WCOD",Ytt),Ktt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",kB),Jtt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",kB),Qtt=new RegExp("^"+$tt+Ztt+Ktt+Jtt+"$"),ent=["material","materials","bones","map"],jU=class{constructor(e,t,n){let i=n||ln.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].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()}},ln=class{constructor(e,t,n){this.path=t,this.parsedPath=n||ln.parseTrackName(t),this.node=ln.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ln.Composite(e,t,n):new ln(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Xtt,"")}static parseTrackName(e){let t=Qtt.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==ent.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i<e.length;i++){let r=e[i];if(r.name===t||r.uuid===t)return r;let a=n(r.children);if(a)return a}return null},i=n(e.children);if(i)return i}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 i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_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 i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=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 e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,r=t.propertyIndex;if(e||(e=ln.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}let a=e[i];if(void 0===a){let n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",e)}let s=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ln.Composite=jU,ln.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ln.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ln.prototype.GetterByBindingType=[ln.prototype._getValue_direct,ln.prototype._getValue_array,ln.prototype._getValue_arrayElement,ln.prototype._getValue_toArray],ln.prototype.SetterByBindingTypeAndVersioning=[[ln.prototype._setValue_direct,ln.prototype._setValue_direct_setNeedsUpdate,ln.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ln.prototype._setValue_array,ln.prototype._setValue_array_setNeedsUpdate,ln.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ln.prototype._setValue_arrayElement,ln.prototype._setValue_arrayElement_setNeedsUpdate,ln.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ln.prototype._setValue_fromArray,ln.prototype._setValue_fromArray_setNeedsUpdate,ln.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var XU=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=za(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e,t=this._objects,n=this._indicesByUUID,i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length,o=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){let c=arguments[h],u=c.uuid,d=n[u];if(void 0===d){d=o++,n[u]=d,t.push(c);for(let e=0,t=s;e!==t;++e)a[e].push(new ln(c,i[e],r[e]))}else if(d<l){e=t[d];let o=--l,h=t[o];n[h.uuid]=d,t[d]=h,n[u]=o,t[o]=c;for(let e=0,t=s;e!==t;++e){let t=a[e],n=t[o],s=t[d];t[d]=n,void 0===s&&(s=new ln(c,i[e],r[e])),t[o]=s}}else t[d]!==e&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_;for(let a=0,s=arguments.length;a!==s;++a){let s=arguments[a],o=s.uuid,l=t[o];if(void 0!==l&&l>=r){let a=r++,h=e[a];t[h.uuid]=l,e[l]=h,t[o]=a,e[a]=s;for(let e=0,t=i;e!==t;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s].uuid,l=t[o];if(void 0!==l)if(delete t[o],l<r){let s=--r,o=e[s],h=--a,c=e[h];t[o.uuid]=l,e[l]=o,t[c.uuid]=s,e[s]=c,e.pop();for(let e=0,t=i;e!==t;++e){let t=n[e],i=t[s],r=t[h];t[l]=i,t[s]=r,t.pop()}}else{let r=--a,s=e[r];r>0&&(t[s.uuid]=l),e[l]=s,e.pop();for(let e=0,t=i;e!==t;++e){let t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let u=h,d=o.length;u!==d;++u){let n=o[u];c[u]=new ln(n,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}},hS=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,a=r.length,s=new Array(a),o={endingStart:Xf,endingEnd:Xf};for(let l=0;l!==a;++l){let e=r[l].createInterpolant(null);s[l]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=zoe,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(this.blendMode===CB)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=n===Goe;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(n===Voe){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=Yf,i.endingEnd=Yf):(i.endingStart=e?this.zeroSlopeAtStart?Yf:Xf:Fx,i.endingEnd=t?this.zeroSlopeAtEnd?Yf:Xf:Fx)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}},tnt=new Float32Array(1),YU=class extends qa{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==r;++c){let e=i[c],r=e.name,l=h[r];if(void 0!==l)++l.referenceCount,a[c]=l;else{if(l=a[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}let i=t&&t._propertyBindings[c].binding.parsedPath;l=new uS(ln.create(n,r,i),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),a[c]=l}s[c].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,a=r[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{let t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,a=this._actionsByClip,s=a[r],o=s.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null,delete s.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let e=t[n];0==--e.referenceCount&&this._removeInactiveBinding(e)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,a=i[t];void 0===a&&(a={},i[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,s=a[i],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete s[r],0===Object.keys(s).length&&delete a[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return void 0===n&&(n=new Qx(new Float32Array(2),new Float32Array(2),1,tnt),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,a="string"==typeof e?pa.findByName(i,e):e,s=null!==a?a.uuid:e,o=this._actionsByClip[s],l=null;if(void 0===n&&(n=null!==a?a.blendMode:vS),void 0!==o){let e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===n)return e;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;let h=new hS(this,a,t,n);return this._bindAction(h,l),this._addInactiveAction(h,s,r),h}existingAction(e,t){let n=t||this._root,i=n.uuid,r="string"==typeof e?pa.findByName(n,e):e,a=r?r.uuid:e,s=this._actionsByClip[a];return void 0!==s&&s.actionByRoot[i]||null}stopAllAction(){let e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)s[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){let e=r.knownActions;for(let n=0,i=e.length;n!==i;++n){let i=e[n];this._deactivateAction(i);let r=i._cacheIndex,a=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,a._cacheIndex=r,t[r]=a,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let r in n){let e=n[r].actionByRoot[t];void 0!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}let i=this._bindingsByRootAndName[t];if(void 0!==i)for(let r in i){let e=i[r];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(e,t){let n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},sy=class{constructor(e){this.value=e}clone(){return new sy(void 0===this.value.clone?this.value:this.value.clone())}},nnt=0,$U=class extends qa{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:nnt++}),this.name="",this.usage=Hx,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++)this.uniforms.push(t[n].clone());return this}clone(){return(new this.constructor).copy(this)}},ZU=class extends Vu{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}},KU=class{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Gs=class{constructor(e,t,n=0,i=1/0){this.ray=new Wa(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new qg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return JU(e,this,n,t),n.sort(Zae),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)JU(e[i],this,n,t);return n.sort(Zae),n}};function Zae(e,t){return e.distance-t.distance}function JU(e,t,n,i){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===i){let i=e.children;for(let e=0,r=i.length;e<r;e++)JU(i[e],t,n,!0)}}var od=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(pi(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},QU=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}},Kae=new Q,si=class{constructor(e=new Q(1/0,1/0),t=new Q(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),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=Kae.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}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}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))}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)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kae).distanceTo(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}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)}},Jae=new M,SM=new M,qs=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Jae.subVectors(e,this.start),SM.subVectors(this.end,this.start);let n=SM.dot(SM),i=SM.dot(Jae)/n;return t&&(i=pi(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},Qae=new M,eB=class extends Tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new et,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,s=1,o=32;a<o;a++,s++){let e=a/o*Math.PI*2,t=s/o*Math.PI*2;i.push(Math.cos(e),Math.sin(e),1,Math.cos(t),Math.sin(t),1)}n.setAttribute("position",new tt(i,3));let r=new Jt({fog:!1,toneMapped:!1});this.cone=new Dn(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Qae.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Qae),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},$h=new M,RM=new Ae,CN=new Ae,tB=class extends Dn{constructor(e){let t=cle(e),n=new et,i=[],r=[],a=new Ie(0,0,1),s=new Ie(0,1,0);for(let o=0;o<t.length;o++){let e=t[o];e.parent&&e.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(a.r,a.g,a.b),r.push(s.r,s.g,s.b))}n.setAttribute("position",new tt(i,3)),n.setAttribute("color",new tt(r,3)),super(n,new Jt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,n=this.geometry,i=n.getAttribute("position");CN.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){let e=t[r];e.parent&&e.parent.isBone&&(RM.multiplyMatrices(CN,e.matrixWorld),$h.setFromMatrixPosition(RM),i.setXYZ(a,$h.x,$h.y,$h.z),RM.multiplyMatrices(CN,e.parent.matrixWorld),$h.setFromMatrixPosition(RM),i.setXYZ(a+1,$h.x,$h.y,$h.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function cle(e){let t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,cle(e.children[n]));return t}var nB=class extends Ge{constructor(e,t,n){super(new da(t,4,2),new Pt({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},rnt=new M,eoe=new Ie,toe=new Ie,rB=class extends Tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let i=new rd(t);i.rotateY(.5*Math.PI),this.material=new Pt({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);let r=i.getAttribute("position"),a=new Float32Array(3*r.count);i.setAttribute("color",new Ct(a,3)),this.add(new Ge(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");eoe.copy(this.light.color),toe.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let i=e<n/2?eoe:toe;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(rnt.setFromMatrixPosition(this.light.matrixWorld).negate())}},ay=class extends Dn{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ie(n),i=new Ie(i);let r=t/2,a=e/t,s=e/2,o=[],l=[];for(let c=0,u=0,d=-s;c<=t;c++,d+=a){o.push(-s,0,d,s,0,d),o.push(d,0,-s,d,0,s);let e=c===r?n:i;e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3}let h=new et;h.setAttribute("position",new tt(o,3)),h.setAttribute("color",new tt(l,3)),super(h,new Jt({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},iB=class extends Dn{constructor(e=10,t=16,n=8,i=64,r=4473924,a=8947848){r=new Ie(r),a=new Ie(a);let s=[],o=[];if(t>1)for(let h=0;h<t;h++){let n=h/t*(2*Math.PI),i=Math.sin(n)*e,l=Math.cos(n)*e;s.push(0,0,0),s.push(i,0,l);let c=1&h?r:a;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let h=0;h<n;h++){let t=1&h?r:a,l=e-e/n*h;for(let e=0;e<i;e++){let n=e/i*(2*Math.PI),r=Math.sin(n)*l,a=Math.cos(n)*l;s.push(r,0,a),o.push(t.r,t.g,t.b),n=(e+1)/i*(2*Math.PI),r=Math.sin(n)*l,a=Math.cos(n)*l,s.push(r,0,a),o.push(t.r,t.g,t.b)}}let l=new et;l.setAttribute("position",new tt(s,3)),l.setAttribute("color",new tt(o,3)),super(l,new Jt({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},noe=new M,AM=new M,roe=new M,oy=class extends Tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===t&&(t=1);let i=new et;i.setAttribute("position",new tt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let r=new Jt({fog:!1,toneMapped:!1});this.lightPlane=new sn(i,r),this.add(this.lightPlane),i=new et,i.setAttribute("position",new tt([0,0,0,0,0,1],3)),this.targetLine=new sn(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),noe.setFromMatrixPosition(this.light.matrixWorld),AM.setFromMatrixPosition(this.light.target.matrixWorld),roe.subVectors(AM,noe),this.lightPlane.lookAt(AM),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(AM),this.targetLine.scale.z=roe.length()}},CM=new M,fi=new Fu,ly=class extends Dn{constructor(e){let t=new et,n=new Jt({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={};function s(e,t){o(e),o(t)}function o(e){i.push(0,0,0),r.push(0,0,0),void 0===a[e]&&(a[e]=[]),a[e].push(i.length/3-1)}s("n1","n2"),s("n2","n4"),s("n4","n3"),s("n3","n1"),s("f1","f2"),s("f2","f4"),s("f4","f3"),s("f3","f1"),s("n1","f1"),s("n2","f2"),s("n3","f3"),s("n4","f4"),s("p","n1"),s("p","n2"),s("p","n3"),s("p","n4"),s("u1","u2"),s("u2","u3"),s("u3","u1"),s("c","t"),s("p","c"),s("cn1","cn2"),s("cn3","cn4"),s("cf1","cf2"),s("cf3","cf4"),t.setAttribute("position",new tt(i,3)),t.setAttribute("color",new tt(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let l=new Ie(16755200),h=new Ie(16711680),c=new Ie(43775),u=new Ie(16777215),d=new Ie(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,n,i,r){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap;fi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),xi("c",t,e,fi,0,0,-1),xi("t",t,e,fi,0,0,1),xi("n1",t,e,fi,-1,-1,-1),xi("n2",t,e,fi,1,-1,-1),xi("n3",t,e,fi,-1,1,-1),xi("n4",t,e,fi,1,1,-1),xi("f1",t,e,fi,-1,-1,1),xi("f2",t,e,fi,1,-1,1),xi("f3",t,e,fi,-1,1,1),xi("f4",t,e,fi,1,1,1),xi("u1",t,e,fi,.7,1.1,-1),xi("u2",t,e,fi,-.7,1.1,-1),xi("u3",t,e,fi,0,2,-1),xi("cf1",t,e,fi,-1,0,1),xi("cf2",t,e,fi,1,0,1),xi("cf3",t,e,fi,0,-1,1),xi("cf4",t,e,fi,0,1,1),xi("cn1",t,e,fi,-1,0,-1),xi("cn2",t,e,fi,1,0,-1),xi("cn3",t,e,fi,0,-1,-1),xi("cn4",t,e,fi,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function xi(e,t,n,i,r,a,s){CM.set(r,a,s).unproject(i);let o=t[e];if(void 0!==o){let e=n.getAttribute("position");for(let t=0,n=o.length;t<n;t++)e.setXYZ(o[t],CM.x,CM.y,CM.z)}}var IM,PN,PM=new lt,cy=class extends Dn{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new et;r.setIndex(new Ct(n,1)),r.setAttribute("position",new Ct(i,3)),super(r,new Jt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&PM.setFromObject(this.object),PM.isEmpty())return;let t=PM.min,n=PM.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},sB=class extends Dn{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new et;i.setIndex(new Ct(n,1)),i.setAttribute("position",new tt([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Jt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},aB=class extends sn{constructor(e,t=1,n=16776960){let i=n,r=new et;r.setAttribute("position",new tt([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Jt({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=new et;a.setAttribute("position",new tt([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),this.add(new Ge(a,new Pt({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},ioe=new M,Rl=class extends Tt{constructor(e=new M(0,0,1),t=new M(0,0,0),n=1,i=16776960,r=.2*n,a=.2*r){super(),this.type="ArrowHelper",void 0===IM&&((IM=new et).setAttribute("position",new tt([0,0,0,0,1,0],3)),(PN=new Po(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new sn(IM,new Jt({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ge(PN,new Pt({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ioe.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ioe,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},oB=class extends Dn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new et;n.setAttribute("position",new tt(t,3)),n.setAttribute("color",new tt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Jt({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new Ie,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},uy=class{constructor(){this.type="ShapePath",this.color=new Ie,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ec,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){let n=t.length,i=!1;for(let r=n-1,a=0;a<n;r=a++){let n=t[r],s=t[a],o=s.x-n.x,l=s.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.y<n.y||e.y>s.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i}let n=Wi.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,a,s,o=[];if(1===i.length)return a=i[0],s=new Fs,s.curves=a.curves,o.push(s),o;let l=!n(i[0].getPoints());l=e?!l:l;let h,c,u=[],d=[],p=[],f=0;d[f]=void 0,p[f]=[];for(let m=0,g=i.length;m<g;m++)a=i[m],h=a.getPoints(),r=n(h),r=e?!r:r,r?(!l&&d[f]&&f++,d[f]={s:new Fs,p:h},d[f].s.curves=a.curves,l&&f++,p[f]=[]):p[f].push({h:a,p:h[0]});if(!d[0])return function(e){let t=[];for(let n=0,i=e.length;n<i;n++){let i=e[n],r=new Fs;r.curves=i.curves,t.push(r)}return t}(i);if(d.length>1){let e=!1,n=0;for(let t=0,i=d.length;t<i;t++)u[t]=[];for(let i=0,r=d.length;i<r;i++){let r=p[i];for(let a=0;a<r.length;a++){let s=r[a],o=!0;for(let r=0;r<d.length;r++)t(s.p,d[r].p)&&(i!==r&&n++,o?(o=!1,u[r].push(s)):e=!0);o&&u[i].push(s)}}n>0&&!1===e&&(p=u)}for(let m=0,g=d.length;m<g;m++){s=d[m].s,o.push(s),c=p[m];for(let e=0,t=c.length;e<t;e++)s.holes.push(c[e].h)}return o}},lB=class extends Qi{constructor(e,t,n,i,r,a){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,n,i,r,a)}},cB=class extends rp{constructor(e,t,n,i){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,n,i)}},uB=class extends ip{constructor(e,t,n,i){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,n,i)}},hB=class extends sp{constructor(e,t,n,i,r,a,s){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,n,i,r,a,s)}},dB=class extends Po{constructor(e,t,n,i,r,a,s,o){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,n,i,r,a,s,o)}},fB=class extends ap{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}},pB=class extends qu{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}},mB=class extends lp{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}},gB=class extends nd{constructor(e,t,n,i){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,n,i)}},vB=class extends rd{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}},xB=class extends Ur{constructor(e,t,n,i){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,n,i)}},yB=class extends wl{constructor(e,t,n,i){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,n,i)}},EB=class extends cp{constructor(e,t,n,i,r,a){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,n,i,r,a)}},bB=class extends bc{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}},_B=class extends da{constructor(e,t,n,i,r,a,s){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,n,i,r,a,s)}},TB=class extends up{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}},wB=class extends Wu{constructor(e,t,n,i,r){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,n,i,r)}},MB=class extends hp{constructor(e,t,n,i,r,a){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,n,i,r,a)}},SB=class extends dp{constructor(e,t,n,i,r){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,n,i,r)}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:dS}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=dS);var Mc=new hr,ule=new M,hle=new M,dle=new M,fle=new M;function ES(e,t,n,i,r,a,s){if(ule.fromBufferAttribute(t,i).applyMatrix4(e.matrixWorld),hle.fromBufferAttribute(t,r).applyMatrix4(e.matrixWorld),n.ray.distanceSqToSegment(ule,hle,fle,dle)>a)return!1;let o=n.ray.origin.distanceTo(fle);return!(o<n.near||o>n.far)&&(s.push({distance:o,point:dle.clone(),index:i,object:e}),!0)}sn.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Mc.copy(n.boundingSphere),Mc.applyMatrix4(i),Mc.radius+=r,!1===e.ray.intersectsSphere(Mc))return;let s=r*r,o=this.isLineSegments?2:1,l=n.index,h=n.attributes.position,c=t.length;if(null!==l){let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r<n.length;r++){let a=n[r];if(Mc.copy(a.boundingSphere),Mc.applyMatrix4(i),!1!==e.ray.intersectsSphere(Mc))for(let n=a.indexStart,i=a.indexStart+a.indexCount;n<i;n+=o)if(ES(this,h,e,l.getX(n),l.getX(n+1),s,t)&&(t[t.length-1].index=n,t.length-c>=1))return}else for(let i=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count)-1;i<r;i+=o)if(ES(this,h,e,l.getX(i),l.getX(i+1),s,t)&&(t[t.length-1].index=i,t.length-c>=1))return}else{let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r<n.length;r++){let a=n[r];if(Mc.copy(a.boundingSphere),Mc.applyMatrix4(i),!1!==e.ray.intersectsSphere(Mc))for(let n=a.positionStart,i=a.positionStart+a.positionCount;n<i;n+=o)if(ES(this,h,e,n,n+1,s,t)&&t.length-c>=1)return}else for(let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count)-1;i<r;i+=o)if(ES(this,h,e,i,i+1,s,t)&&t.length-c>=1)return}};var ple=Math.pow(2,-24),xp=class{constructor(){}};function Uo(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function VB(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){let r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function zB(e,t){t.set(e)}function GB(e,t,n){let i,r;for(let a=0;a<3;a++){let s=a+3;i=e[a],r=t[a],n[a]=i<r?i:r,i=e[s],r=t[s],n[s]=i>r?i:r}}function my(e,t,n){for(let i=0;i<3;i++){let r=t[e+2*i],a=t[e+2*i+1],s=r-a,o=r+a;s<n[i]&&(n[i]=s),o>n[i+3]&&(n[i+3]=o)}}function av(e){let t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function ant(e,t){if(!e.index){let n,i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;n=i>65535?new Uint32Array(new r(4*i)):new Uint16Array(new r(2*i)),e.setIndex(new Ct(n,1));for(let e=0;e<i;e++)n[e]=e}}function ont(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],n=new Set;for(let r of e.groups)n.add(r.start),n.add(r.start+r.count);let i=Array.from(n.values()).sort(((e,t)=>e-t));for(let r=0;r<i.length-1;r++){let e=i[r],n=i[r+1];t.push({offset:e/3,count:(n-e)/3})}return t}function WB(e,t,n,i,r=null){let a=1/0,s=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=null!==r;for(let y=6*t,x=6*(t+n);y<x;y+=6){let t=e[y+0],n=e[y+1],i=t-n,r=t+n;i<a&&(a=i),r>l&&(l=r),v&&t<u&&(u=t),v&&t>f&&(f=t);let x=e[y+2],_=e[y+3],b=x-_,M=x+_;b<s&&(s=b),M>h&&(h=M),v&&x<d&&(d=x),v&&x>m&&(m=x);let w=e[y+4],S=e[y+5],E=w-S,T=w+S;E<o&&(o=E),T>c&&(c=T),v&&w<p&&(p=w),v&&w>g&&(g=w)}i[0]=a,i[1]=s,i[2]=o,i[3]=l,i[4]=h,i[5]=c,v&&(r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g)}function lnt(e,t,n,i){let r=1/0,a=1/0,s=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=6*t,u=6*(t+n);c<u;c+=6){let t=e[c+0];t<r&&(r=t),t>o&&(o=t);let n=e[c+2];n<a&&(a=n),n>l&&(l=n);let i=e[c+4];i<s&&(s=i),i>h&&(h=i)}i[0]=r,i[1]=a,i[2]=s,i[3]=o,i[4]=l,i[5]=h}function cnt(e,t,n,i,r){let a=n,s=n+i-1,o=r.pos,l=2*r.axis;for(;;){for(;a<=s&&t[6*a+l]<o;)a++;for(;a<=s&&t[6*s+l]>=o;)s--;if(!(a<s))return a;for(let n=0;n<3;n++){let i=e[3*a+n];e[3*a+n]=e[3*s+n],e[3*s+n]=i;let r=t[6*a+2*n+0];t[6*a+2*n+0]=t[6*s+2*n+0],t[6*s+2*n+0]=r;let o=t[6*a+2*n+1];t[6*a+2*n+1]=t[6*s+2*n+1],t[6*s+2*n+1]=o}a++,s--}}var Zu=32,unt=(e,t)=>e.candidate-t.candidate,ud=new Array(Zu).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),bS=new Float32Array(6);function hnt(e,t,n,i,r,a){let s=-1,o=0;if(0===a)s=VB(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=VB(e),-1!==s&&(o=dnt(n,i,r,s));else if(2===a){let a=av(e),l=1.25*r,h=6*i,c=6*(i+r);for(let e=0;e<3;e++){let i=t[e],u=(t[e+3]-i)/Zu;if(r<Zu/4){let t=[...ud];t.length=r;let i=0;for(let r=h;r<c;r+=6,i++){let a=t[i];a.candidate=n[r+2*e],a.count=0;let{bounds:s,leftCacheBounds:o,rightCacheBounds:l}=a;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0,s[e]=1/0,s[e+3]=-1/0;my(r,n,s)}t.sort(unt);let u=r;for(let e=0;e<u;e++){let n=t[e];for(;e+1<u&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),u--}for(let r=h;r<c;r+=6){let i=n[r+2*e];for(let e=0;e<u;e++){let a=t[e];i>=a.candidate?my(r,n,a.rightCacheBounds):(my(r,n,a.leftCacheBounds),a.count++)}}for(let n=0;n<u;n++){let i=t[n],h=i.count,c=r-i.count,u=i.leftCacheBounds,d=i.rightCacheBounds,p=0;0!==h&&(p=av(u)/a);let f=0;0!==c&&(f=av(d)/a);let m=1+1.25*(p*h+f*c);m<l&&(s=e,l=m,o=i.candidate)}}else{for(let e=0;e<Zu;e++){let t=ud[e];t.count=0,t.candidate=i+u+e*u;let n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let r=h;r<c;r+=6){let t=~~((n[r+2*e]-i)/u);t>=Zu&&(t=Zu-1);let a=ud[t];a.count++,my(r,n,a.bounds)}let t=ud[Zu-1];zB(t.bounds,t.rightCacheBounds);for(let e=Zu-2;e>=0;e--){let t=ud[e],n=ud[e+1];GB(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let n=0;n<Zu-1;n++){let t=ud[n],i=t.count,h=t.bounds,c=ud[n+1].rightCacheBounds;0!==i&&(0===d?zB(h,bS):GB(h,bS,bS)),d+=i;let u=0,p=0;0!==d&&(u=av(bS)/a);let f=r-d;0!==f&&(p=av(c)/a);let m=1+1.25*(u*d+p*f);m<l&&(s=e,l=m,o=t.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:s,pos:o}}function dnt(e,t,n,i){let r=0;for(let a=t,s=t+n;a<s;a++)r+=e[6*a+2*i];return r/n}function fnt(e,t){let n=e.attributes.position,i=e.index.array,r=i.length/3,a=new Float32Array(6*r),s=n.normalized,o=n.array,l=n.offset||0,h=3;n.isInterleavedBufferAttribute&&(h=n.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<r;u++){let e,r,d,p=3*u,f=6*u;s?(e=i[p+0],r=i[p+1],d=i[p+2]):(e=i[p+0]*h+l,r=i[p+1]*h+l,d=i[p+2]*h+l);for(let i=0;i<3;i++){let l,h,u;s?(l=n[c[i]](e),h=n[c[i]](r),u=n[c[i]](d)):(l=o[e+i],h=o[r+i],u=o[d+i]);let p=l;h<p&&(p=h),u<p&&(p=u);let m=l;h>m&&(m=h),u>m&&(m=u);let g=(m-p)/2,v=2*i;a[f+v+0]=p+g,a[f+v+1]=g+(Math.abs(p)+g)*ple,p<t[i]&&(t[i]=p),m>t[i+3]&&(t[i+3]=m)}}return a}function pnt(e,t){function n(e){d&&d(e/p)}function i(t,r,d,p=null,m=0){if(!f&&m>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=c||m>=l)return n(r+d),t.offset=r,t.count=d,t;let g=hnt(t.boundingData,p,s,r,d,u);if(-1===g.axis)return n(r+d),t.offset=r,t.count=d,t;let v=cnt(o,s,r,d,g);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=g.axis;let e=new xp,n=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),WB(s,n,o,e.boundingData,a),i(e,n,o,a,m+1);let l=new xp,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),WB(s,h,c,l.boundingData,a),i(l,h,c,a,m+1)}return t}ant(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=fnt(e,r),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=ont(e);if(1===g.length){let e=g[0],t=new xp;t.boundingData=r,lnt(s,e.offset,e.count,a),i(t,e.offset,e.count,a),m.push(t)}else for(let v of g){let e=new xp;e.boundingData=new Float32Array(6),WB(s,v.offset,v.count,e.boundingData,a),i(e,v.offset,v.count,a),m.push(e)}return m}function vle(e,t){let n,i,r,a=pnt(e,t),s=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<a.length;c++){let e=a[c],t=new o(32*l(e));n=new Float32Array(t),i=new Uint32Array(t),r=new Uint16Array(t),h(0,e),s.push(t)}return s;function l(e){return e.count?1:1+l(e.left)+l(e.right)}function h(e,t){let a=e/4,s=e/2,o=!!t.count,l=t.boundingData;for(let i=0;i<6;i++)n[a+i]=l[i];if(o){let n=t.offset,o=t.count;return i[a+6]=n,r[s+14]=o,r[s+15]=65535,e+32}{let n,r=t.left,s=t.right,o=t.splitAxis;if(n=h(e+32,r),n/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[a+6]=n/4,n=h(n,s),i[a+7]=o,n}}}var ga=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,a=e.length;r<a;r++){let a=e[r][t];n=a<n?a:n,i=a>i?a:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,a=t.length;r<a;r++){let a=t[r],s=e.dot(a);n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};ga.prototype.setFromBox=function(){let e=new M;return function(t,n){let i=n.min,r=n.max,a=1/0,s=-1/0;for(let o=0;o<=1;o++)for(let n=0;n<=1;n++)for(let l=0;l<=1;l++){e.x=i.x*o+r.x*(1-o),e.y=i.y*n+r.y*(1-n),e.z=i.z*l+r.z*(1-l);let h=t.dot(e);a=Math.min(h,a),s=Math.max(h,s)}this.min=a,this.max=s}}();var bbt=function(){let e=new ga;return function(t,n){let i=t.points,r=t.satAxes,a=t.satBounds,s=n.points,o=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let t=a[h],n=r[h];if(e.setFromPoints(n,s),t.isSeparated(e))return!1}for(let h=0;h<3;h++){let t=l[h],n=o[h];if(e.setFromPoints(n,i),t.isSeparated(e))return!1}}}(),mnt=function(){let e=new M,t=new M,n=new M;return function(i,r,a){let s=i.start,o=e,l=r.start,h=t;n.subVectors(s,l),e.subVectors(i.end,i.start),t.subVectors(r.end,r.start);let c,u,d=n.dot(h),p=h.dot(o),f=h.dot(h),m=n.dot(o),g=o.dot(o)*f-p*p;c=0!==g?(d*p-m*f)/g:0,u=(d+c*p)/f,a.x=c,a.y=u}}(),gy=function(){let e=new Q,t=new M,n=new M;return function(i,r,a,s){mnt(i,r,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,a),void r.at(l,s);if(o>=0&&o<=1)return l<0?r.at(0,s):r.at(1,s),void i.closestPointToPoint(s,!0,a);if(l>=0&&l<=1)return o<0?i.at(0,a):i.at(1,a),void r.closestPointToPoint(a,!0,s);{let e,h;e=o<0?i.start:i.end,h=l<0?r.start:r.end;let c=t,u=n;return i.closestPointToPoint(h,!0,t),r.closestPointToPoint(e,!0,n),c.distanceToSquared(h)<=u.distanceToSquared(e)?(a.copy(c),void s.copy(h)):(a.copy(e),void s.copy(u))}}}(),xle=function(){let e=new M,t=new M,n=new er,i=new qs;return function(r,a){let{radius:s,center:o}=r,{a:l,b:h,c:c}=a;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s||(i.start=l,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s)||(i.start=h,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s))return!0;let u=a.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=s){let e=u.projectPoint(o,t);if(a.containsPoint(e))return!0}return!1}}(),gnt=1e-15;function ov(e){return Math.abs(e)<gnt}var va=class extends Rr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new M)),this.satBounds=new Array(4).fill().map((()=>new ga)),this.points=[this.a,this.b,this.c],this.sphere=new hr,this.plane=new er,this.needsUpdate=!0}intersectsSphere(e){return xle(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,a=this.satBounds,s=r[0],o=a[0];this.getNormal(s),o.setFromPoints(s,i);let l=r[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);let c=r[2],u=a[2];c.subVectors(t,n),u.setFromPoints(c,i);let d=r[3],p=a[3];d.subVectors(n,e),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(s,e),this.needsUpdate=!1}};va.prototype.closestPointToSegment=function(){let e=new M,t=new M,n=new qs;return function(i,r=null,a=null){let s,{start:o,end:l}=i,h=this.points,c=1/0;for(let u=0;u<3;u++){let o=(u+1)%3;n.start.copy(h[u]),n.end.copy(h[o]),gy(n,i,e,t),s=e.distanceToSquared(t),s<c&&(c=s,r&&r.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),s=o.distanceToSquared(e),s<c&&(c=s,r&&r.copy(e),a&&a.copy(o)),this.closestPointToPoint(l,e),s=l.distanceToSquared(e),s<c&&(c=s,r&&r.copy(e),a&&a.copy(l)),Math.sqrt(c)}}(),va.prototype.intersectsTriangle=function(){let e=new va,t=new Array(3),n=new Array(3),i=new ga,r=new ga,a=new M,s=new M,o=new M,l=new M,h=new qs,c=new qs,u=new qs;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let m=this.plane,g=d.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let e=this.satBounds,s=this.satAxes;n[0]=d.a,n[1]=d.b,n[2]=d.c;for(let t=0;t<4;t++){let r=e[t],a=s[t];if(i.setFromPoints(a,n),r.isSeparated(i))return!1}let o=d.satBounds,l=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let n=0;n<4;n++){let e=o[n],r=l[n];if(i.setFromPoints(r,t),e.isSeparated(i))return!1}for(let h=0;h<4;h++){let e=s[h];for(let s=0;s<4;s++){let o=l[s];if(a.crossVectors(e,o),i.setFromPoints(a,t),r.setFromPoints(a,n),i.isSeparated(r))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}{let e=this.points,t=!1,n=0;for(let o=0;o<3;o++){let i=e[o],r=e[(o+1)%3];h.start.copy(i),h.end.copy(r),h.delta(s);let a=t?c.start:c.end,l=ov(g.distanceToPoint(i));if(ov(g.normal.dot(s))&&l){c.copy(h),n=2;break}if((g.intersectLine(h,a)||l)&&!ov(a.distanceTo(r))){if(n++,t)break;t=!0}}if(1===n&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(2!==n)return!1;let i=d.points,r=!1,a=0;for(let s=0;s<3;s++){let e=i[s],t=i[(s+1)%3];h.start.copy(e),h.end.copy(t),h.delta(o);let n=r?u.start:u.end,l=ov(m.distanceToPoint(e));if(ov(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,n)||l)&&!ov(n.distanceTo(t))){if(a++,r)break;r=!0}}if(1===a&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(2!==a)return!1;if(c.delta(s),u.delta(o),s.dot(o)<0){let e=u.start;u.start=u.end,u.end=e}let f=c.start.dot(s),v=c.end.dot(s),y=u.start.dot(s),x=u.end.dot(s);return(f===x||y===v||v<y!==f<x)&&(p&&(l.subVectors(c.start,u.start),l.dot(s)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(s)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}(),va.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),va.prototype.distanceToTriangle=function(){let e=new M,t=new M,n=["a","b","c"],i=new qs,r=new qs;return function(a,s=null,o=null){let l=s||o?i:null;if(this.intersectsTriangle(a,l))return(s||o)&&(s&&l.getCenter(s),o&&l.getCenter(o)),0;let h=1/0;for(let t=0;t<3;t++){let i,r=n[t],l=a[r];this.closestPointToPoint(l,e),i=l.distanceToSquared(e),i<h&&(h=i,s&&s.copy(e),o&&o.copy(l));let c=this[r];a.closestPointToPoint(c,e),i=c.distanceToSquared(e),i<h&&(h=i,s&&s.copy(c),o&&o.copy(e))}for(let c=0;c<3;c++){let l=n[c],u=n[(c+1)%3];i.set(this[l],this[u]);for(let c=0;c<3;c++){let l=n[c],u=n[(c+1)%3];r.set(a[l],a[u]),gy(i,r,e,t);let d=e.distanceToSquared(t);d<h&&(h=d,s&&s.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var xa=class{constructor(e,t,n){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new Ae,this.invMatrix=new Ae,this.points=new Array(8).fill().map((()=>new M)),this.satAxes=new Array(3).fill().map((()=>new M)),this.satBounds=new Array(3).fill().map((()=>new ga)),this.alignedSatBounds=new Array(3).fill().map((()=>new ga)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};xa.prototype.update=function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=i[1*l|2*r|4*a];s.x=l?n.x:t.x,s.y=r?n.y:t.y,s.z=a?n.z:t.z,s.applyMatrix4(e)}let r=this.satBounds,a=this.satAxes,s=i[0];for(let l=0;l<3;l++){let e=a[l],t=r[l],n=i[1<<l];e.subVectors(s,n),t.setFromPoints(e,i)}let o=this.alignedSatBounds;o[0].setFromPointsField(i,"x"),o[1].setFromPointsField(i,"y"),o[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},xa.prototype.intersectsBox=function(){let e=new ga;return function(t){this.needsUpdate&&this.update();let n=t.min,i=t.max,r=this.satBounds,a=this.satAxes,s=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,s[0].isSeparated(e)||(e.min=n.y,e.max=i.y,s[1].isSeparated(e))||(e.min=n.z,e.max=i.z,s[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let n=a[o],i=r[o];if(e.setFromBox(n,t),i.isSeparated(e))return!1}return!0}}(),xa.prototype.intersectsTriangle=function(){let e=new va,t=new Array(3),n=new ga,i=new ga,r=new M;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let s=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let e=0;e<3;e++){let i=s[e],r=o[e];if(n.setFromPoints(r,t),i.isSeparated(n))return!1}let l=a.satBounds,h=a.satAxes,c=this.points;for(let e=0;e<3;e++){let t=l[e],i=h[e];if(n.setFromPoints(i,c),t.isSeparated(n))return!1}for(let e=0;e<3;e++){let a=o[e];for(let e=0;e<4;e++){let s=h[e];if(r.crossVectors(a,s),n.setFromPoints(r,t),i.setFromPoints(r,c),n.isSeparated(i))return!1}}return!0}}(),xa.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},xa.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),xa.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map((()=>new qs)),n=new Array(12).fill().map((()=>new qs)),i=new M,r=new M;return function(a,s=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;let h=s*s,c=a.min,u=a.max,d=this.points,p=1/0;for(let e=0;e<8;e++){let t=d[e];r.copy(t).clamp(c,u);let n=t.distanceToSquared(r);if(n<p&&(p=n,o&&o.copy(t),l&&l.copy(r),n<h))return Math.sqrt(n)}let f=0;for(let i=0;i<3;i++)for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=(i+1)%3,o=(i+2)%3,l=1<<i|r<<s|a<<o,h=d[r<<s|a<<o],p=d[l];t[f].set(h,p);let m=e[i],g=e[s],v=e[o],y=n[f],x=y.start,_=y.end;x[m]=c[m],x[g]=r?c[g]:u[g],x[v]=a?c[v]:u[g],_[m]=u[m],_[g]=r?c[g]:u[g],_[v]=a?c[v]:u[g],f++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){r.x=e?u.x:c.x,r.y=t?u.y:c.y,r.z=n?u.z:c.z,this.closestPointToPoint(r,i);let a=r.distanceToSquared(i);if(a<p&&(p=a,o&&o.copy(i),l&&l.copy(r),a<h))return Math.sqrt(a)}for(let e=0;e<12;e++){let a=t[e];for(let e=0;e<12;e++){let t=n[e];gy(a,t,i,r);let s=i.distanceToSquared(r);if(s<p&&(p=s,o&&o.copy(i),l&&l.copy(r),s<h))return Math.sqrt(s)}}return Math.sqrt(p)}}();var TS=new M,wS=new M,MS=new M,yle=new Q,Ele=new Q,ble=new Q,_le=new M;function vnt(e,t,n,i,r,a){let s;return s=a===ri?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,a!==tr,r),null===s?null:{distance:e.origin.distanceTo(r),point:r.clone()}}function xnt(e,t,n,i,r,a,s){TS.fromBufferAttribute(t,i),wS.fromBufferAttribute(t,r),MS.fromBufferAttribute(t,a);let o=vnt(e,TS,wS,MS,_le,s);if(o){n&&(yle.fromBufferAttribute(n,i),Ele.fromBufferAttribute(n,r),ble.fromBufferAttribute(n,a),o.uv=Rr.getUV(_le,TS,wS,MS,yle,Ele,ble,new Q));let e={a:i,b:r,c:a,normal:new M,materialIndex:0};Rr.getNormal(TS,wS,MS,e.normal),o.face=e,o.faceIndex=i}return o}function XB(e,t,n,i,r){let a=3*i,s=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),h=xnt(n,e.attributes.position,e.attributes.uv,s,o,l,t);return h?(h.faceIndex=i,r&&r.push(h),h):null}function Tle(e,t,n,i,r,a){for(let s=i,o=i+r;s<o;s++)XB(e,t,n,s,a)}function wle(e,t,n,i,r){let a=1/0,s=null;for(let o=i,l=i+r;o<l;o++){let i=XB(e,t,n,o);i&&i.distance<a&&(s=i,a=i.distance)}return s}function YB(e,t,n){return null===e||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e.distance<n.near||e.distance>n.far)?null:e}function Bo(e,t,n,i){let r=e.a,a=e.b,s=e.c,o=t,l=t+1,h=t+2;n&&(o=n.getX(t),l=n.getX(t+1),h=n.getX(t+2)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l),s.x=i.getX(h),s.y=i.getY(h),s.z=i.getZ(h)}function $B(e,t,n,i,r,a,s){let o=n.index,l=n.attributes.position;for(let h=e,c=t+e;h<c;h++)if(Bo(s,3*h,o,l),s.needsUpdate=!0,i(s,h,r,a))return!0;return!1}var lv=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Ku(e,t){return 65535===t[e+15]}function yp(e,t){return t[e+6]}function cv(e,t){return t[e+14]}function uv(e){return e+8}function hv(e,t){return t[e+6]}function Mle(e,t){return t[e+7]}var dv=new lt,RS=new M,Ent=["x","y","z"];function AS(e,t,n,i,r){let a=2*e,s=fv,o=hd,l=dd;if(Ku(a,o))Tle(t,n,i,yp(e,l),cv(a,o),r);else{let a=uv(e);PS(a,s,i,RS)&&AS(a,t,n,i,r);let o=hv(e,l);PS(o,s,i,RS)&&AS(o,t,n,i,r)}}function CS(e,t,n,i){let r=2*e,a=fv,s=hd,o=dd;if(Ku(r,s))return wle(t,n,i,yp(e,o),cv(r,s));{let r,s,l=Mle(e,o),h=Ent[l],c=i.direction[h]>=0;c?(r=uv(e),s=hv(e,o)):(r=hv(e,o),s=uv(e));let u=PS(r,a,i,RS)?CS(r,t,n,i):null;if(u){let e=u.point[h];if(c?e<=a[s+l]:e>=a[s+l+3])return u}let d=PS(s,a,i,RS)?CS(s,t,n,i):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var Sle=function(){let e,t,n=[],i=new lv((()=>new lt));return function(...a){e=i.getPrimitive(),t=i.getPrimitive(),n.push(e,t);let s=r(...a);i.releasePrimitive(e),i.releasePrimitive(t),n.pop(),n.pop();let o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),s};function r(n,i,a,s,o=null,l=0,h=0){function c(e){let t=2*e,n=hd,i=dd;for(;!Ku(t,n);)t=2*(e=uv(e));return yp(e,i)}function u(e){let t=2*e,n=hd,i=dd;for(;!Ku(t,n);)t=2*(e=hv(e,i));return yp(e,i)+cv(t,n)}let d=2*n,p=fv,f=hd,m=dd;if(Ku(d,f)){let t=yp(n,m),i=cv(d,f);return Uo(n,p,e),s(t,i,!1,h,l+n,e)}{let d,g,v,y,x=uv(n),_=hv(n,m),b=x,M=_;if(o&&(v=e,y=t,Uo(b,p,v),Uo(M,p,y),d=o(v),g=o(y),g<d)){b=_,M=x;let e=d;d=g,g=e,v=y}v||(v=e,Uo(b,p,v));let w,S=a(v,Ku(2*b,f),d,h+1,l+b);if(2===S){let e=c(b);w=s(e,u(b)-e,!0,h+1,l+b,v)}else w=S&&r(b,i,a,s,o,l,h+1);if(w)return!0;y=t,Uo(M,p,y);let E,T=a(y,Ku(2*M,f),g,h+1,l+M);if(2===T){let e=c(M);E=s(e,u(M)-e,!0,h+1,l+M,y)}else E=T&&r(M,i,a,s,o,l,h+1);return!!E}}}(),Rle=function(){let e=new va,t=new va,n=new Ae,i=new xa,r=new xa;return function a(s,o,l,h,c=null){let u=2*s,d=fv,p=hd,f=dd;if(null===c&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,h),c=i),!Ku(u,p)){let e=s+8,t=f[s+6];return Uo(e,d,dv),!!(c.intersectsBox(dv)&&a(e,o,l,h,c)||(Uo(t,d,dv),c.intersectsBox(dv)&&a(t,o,l,h,c)))}{let i=o,a=i.index,c=i.attributes.position,m=l.index,g=l.attributes.position,v=yp(s,f),y=cv(u,p);if(n.copy(h).invert(),l.boundsTree)return Uo(s,d,r),r.matrix.copy(n),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:e=>r.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(h),e.b.applyMatrix4(h),e.c.applyMatrix4(h),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);n<i;n+=3)if(Bo(t,n,a,c),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});for(let r=3*v,s=y+3*v;r<s;r+=3){Bo(e,r,a,c),e.a.applyMatrix4(n),e.b.applyMatrix4(n),e.c.applyMatrix4(n),e.needsUpdate=!0;for(let n=0,i=m.count;n<i;n+=3)if(Bo(t,n,m,g),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function PS(e,t,n,i){return Uo(e,t,dv),n.intersectBox(dv,i)}var SS,fv,hd,dd,ZB=[];function pv(e){SS&&ZB.push(SS),SS=e,fv=new Float32Array(e),hd=new Uint16Array(e),dd=new Uint32Array(e)}function vy(){SS=null,fv=null,hd=null,dd=null,ZB.length&&pv(ZB.pop())}var KB=Symbol("skip tree generation"),JB=new lt,QB=new lt,mv=new Ae,Ep=new xa,xy=new xa,yy=new M,IS=new M,bnt=new M,_nt=new M,Tnt=new M,Ale=new lt,Sc=new lv((()=>new va)),Al=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Al.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=yn({cloneBuffers:!0},t);let n,i=e.geometry,r=e._roots,a=i.getIndex();return n=t.cloneBuffers?{roots:r.map((e=>e.slice())),index:a.array.slice()}:{roots:r,index:a.array},n}static deserialize(e,t,n={}){if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Al.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n=yn({setIndex:!0},n);let{index:i,roots:r}=e,a=new Al(t,Qr(yn({},n),{[KB]:!0}));if(a._roots=r,n.setIndex){let n=t.getIndex();if(null===n){let n=new Ct(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[KB]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[KB]||(this._roots=vle(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new lt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t,n,i,r,a=this.geometry,s=a.index.array,o=a.attributes.position,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)t=h[u],n=new Uint32Array(t),i=new Uint16Array(t),r=new Float32Array(t),c(0,l),l+=t.byteLength;function c(t,a,l=!1){let h=2*t;if(65535===i[h+15]){let e=n[t+6],a=1/0,l=1/0,c=1/0,u=-1/0,d=-1/0,p=-1/0;for(let t=3*e,n=3*(e+i[h+14]);t<n;t++){let e=s[t],n=o.getX(e),i=o.getY(e),r=o.getZ(e);n<a&&(a=n),n>u&&(u=n),i<l&&(l=i),i>d&&(d=i),r<c&&(c=r),r>p&&(p=r)}return(r[t+0]!==a||r[t+1]!==l||r[t+2]!==c||r[t+3]!==u||r[t+4]!==d||r[t+5]!==p)&&(r[t+0]=a,r[t+1]=l,r[t+2]=c,r[t+3]=u,r[t+4]=d,r[t+5]=p,!0)}{let i=t+8,s=n[t+6],o=i+a,h=s+a,u=l,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);let f=u||p,m=!1;(u||d)&&(m=c(i,a,u));let g=!1;f&&(g=c(s,a,u));let v=m||g;if(v)for(let e=0;e<3;e++){let n=i+e,a=s+e,o=r[n],l=r[n+3],h=r[a],c=r[a+3];r[t+e]=o<h?o:h,r[t+e+3]=l>c?l:c}return v}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(a,s=0){let o=2*a,l=65535===r[o+15];if(l){let t=i[a+6],h=r[o+14];e(s,l,new Float32Array(n,4*a,6),t,h)}else{let r=a+8,o=i[a+6],h=i[a+7];e(s,l,new Float32Array(n,4*a,6),h)||(t(r,s+1),t(o,s+1))}}(0)}raycast(e,t=Tr){let n=this._roots,i=this.geometry,r=[],a=t.isMaterial,s=Array.isArray(t),o=i.groups,l=a?t.side:t;for(let h=0,c=n.length;h<c;h++){let a=s?t[o[h].materialIndex].side:l,c=r.length;if(pv(n[h]),AS(0,i,a,e,r),vy(),s){let e=o[h].materialIndex;for(let t=c,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e,t=Tr){let n=this._roots,i=this.geometry,r=t.isMaterial,a=Array.isArray(t),s=null,o=i.groups,l=r?t.side:t;for(let h=0,c=n.length;h<c;h++){let r=a?t[o[h].materialIndex].side:l;pv(n[h]);let c=CS(0,i,r,e);vy(),null!=c&&(null==s||c.distance<s.distance)&&(s=c,a&&(c.face.materialIndex=o[h].materialIndex))}return s}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let r of this._roots)if(pv(r),i=Rle(0,n,e,t),vy(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let e=t;t=(t,n,i,r)=>{let a=3*n;return e(t,a,a+1,a+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=Sc.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:s,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let e=o;o=(t,n,a,s,o)=>!!e(t,n,a,s,o)||$B(t,n,i,l,a,s,r)}else o||(o=l?(e,t,n,a)=>$B(e,t,i,l,n,a,r):(e,t,n)=>n);let h=!1,c=0;for(let u of this._roots){if(pv(u),h=Sle(0,i,s,o,a,c),vy(),h)break;c+=u.byteLength}return Sc.releasePrimitive(r),h}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n,a=this.geometry.index,s=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;mv.copy(t).invert();let h=Sc.getPrimitive(),c=Sc.getPrimitive();if(r){let e=function(e,n,i,u,d,p,f,m){for(let g=i,v=i+u;g<v;g++){Bo(c,3*g,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Bo(h,3*t,a,s),h.needsUpdate=!0,r(h,c,t,g,d,p,f,m))return!0}return!1};if(i){let t=i;i=function(n,i,r,a,s,o,l,h){return!!t(n,i,r,a,s,o,l,h)||e(n,i,r,a,s,o,l,h)}}else i=e}e.getBoundingBox(QB),QB.applyMatrix4(t);let u=this.shapecast({intersectsBounds:e=>QB.intersectsBox(e),intersectsRange:(t,n,r,a,s,o)=>(JB.copy(o),JB.applyMatrix4(mv),e.shapecast({intersectsBounds:e=>JB.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>i(t,n,e,r,a,s,l,h)}))});return Sc.releasePrimitive(h),Sc.releasePrimitive(c),u}intersectsBox(e,t){return Ep.set(e.min,e.max,t),Ep.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Ep.intersectsBox(e),intersectsTriangle:e=>Ep.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ep.set(e.boundingBox.min,e.boundingBox.max,t),Ep.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=Sc.getPrimitive(),d=Sc.getPrimitive(),p=IS,f=bnt,m=null,g=null;i&&(m=_nt,g=Tnt);let v=1/0,y=null,x=null;return mv.copy(t).invert(),xy.matrix.copy(mv),this.shapecast({boundsTraverseOrder:e=>Ep.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<a&&(t&&(xy.min.copy(e.min),xy.max.copy(e.max),xy.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>xy.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<a,intersectsRange:(e,a)=>{for(let s=3*e,_=3*(e+a);s<_;s+=3){Bo(d,s,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*n,t=3*(n+i);e<t;e+=3){Bo(u,e,l,o),u.needsUpdate=!0;let t=u.distanceToTriangle(d,p,m);if(t<v&&(f.copy(p),g&&g.copy(m),v=t,y=e/3,x=s/3),t<r)return!0}}}});for(let e=0,a=c?c.count:h.count;e<a;e+=3){Bo(d,e,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*n,a=3*(n+i);t<a;t+=3){Bo(u,t,l,o),u.needsUpdate=!0;let n=u.distanceToTriangle(d,p,m);if(n<v&&(f.copy(p),g&&g.copy(m),v=n,y=t/3,x=e/3),n<r)return!0}}}}),Sc.releasePrimitive(u),Sc.releasePrimitive(d),v===1/0?null:(n.point?n.point.copy(f):n.point=f.clone(),n.distance=v,n.faceIndex=y,i&&(i.point?i.point.copy(g):i.point=g.clone(),i.point.applyMatrix4(mv),f.applyMatrix4(mv),i.distance=f.sub(i.point).length(),i.faceIndex=x),n)}closestPointToPoint(e,t={},n=0,i=1/0){let r=n*n,a=i*i,s=1/0,o=null;if(this.shapecast({boundsTraverseOrder:t=>(yy.copy(e).clamp(t.min,t.max),yy.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<s&&n<a,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,yy);let i=e.distanceToSquared(yy);return i<s&&(IS.copy(yy),s=i,o=n),i<r}}),s===1/0)return null;let l=Math.sqrt(s);return t.point?t.point.copy(IS):t.point=IS.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach((t=>{Uo(0,new Float32Array(t),Ale),e.union(Ale)})),e}},eF=new Wa,Cle=new Ae,wnt=Ge.prototype.raycast;function tF(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;Cle.copy(this.matrixWorld).invert(),eF.copy(e.ray).applyMatrix4(Cle);let n=this.geometry.boundsTree;if(!0===e.firstHitOnly){let i=YB(n.raycastFirst(eF,this.material),this,e);i&&t.push(i)}else{let i=n.raycast(eF,this.material);for(let n=0,r=i.length;n<r;n++){let r=YB(i[n],this,e);r&&t.push(r)}}}else wnt.call(this,e,t)}var Ple=new Ae,gv=new Wa,nF=new hr,fd=new M,pd=new M,md=new M,rF=new M,iF=new M,sF=new M,DS=new M,LS=new M,OS=new M,NS=new Q,US=new Q,BS=new Q,aF=new M,FS=new M;function Mnt(e,t,n,i,r,a,s,o){let l;if(l=t.side===ri?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,t.side!==tr,o),null===l)return null;FS.copy(o),FS.applyMatrix4(e.matrixWorld);let h=n.ray.origin.distanceTo(FS);return h<n.near||h>n.far?null:{distance:h,point:FS.clone(),object:e}}function HS(e,t,n,i,r,a,s,o,l,h,c,u){fd.fromBufferAttribute(r,h),pd.fromBufferAttribute(r,c),md.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){DS.set(0,0,0),LS.set(0,0,0),OS.set(0,0,0);for(let e=0,t=a.length;e<t;e++){let t=d[e],n=a[e];0!==t&&(rF.fromBufferAttribute(n,h),iF.fromBufferAttribute(n,c),sF.fromBufferAttribute(n,u),s?(DS.addScaledVector(rF,t),LS.addScaledVector(iF,t),OS.addScaledVector(sF,t)):(DS.addScaledVector(rF.sub(fd),t),LS.addScaledVector(iF.sub(pd),t),OS.addScaledVector(sF.sub(md),t)))}fd.add(DS),pd.add(LS),md.add(OS)}e.isSkinnedMesh&&(e.boneTransform(h,fd),e.boneTransform(c,pd),e.boneTransform(u,md));let p=Mnt(e,t,n,i,fd,pd,md,aF);if(p){o&&(NS.fromBufferAttribute(o,h),US.fromBufferAttribute(o,c),BS.fromBufferAttribute(o,u),p.uv=Rr.getUV(aF,fd,pd,md,NS,US,BS,new Q)),l&&(NS.fromBufferAttribute(l,h),US.fromBufferAttribute(l,c),BS.fromBufferAttribute(l,u),p.uv2=Rr.getUV(aF,fd,pd,md,NS,US,BS,new Q));let e={a:h,b:c,c:u,normal:new M,materialIndex:0};Rr.getNormal(fd,pd,md,e.normal),p.face=e}return p}Ge.prototype.raycast=function(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i||(null===n.boundingSphere&&n.computeBoundingSphere(),nF.copy(n.boundingSphere),nF.applyMatrix4(r),!1===e.ray.intersectsSphere(nF))||(Ple.copy(r).invert(),gv.copy(e.ray).applyMatrix4(Ple),null!==n.boundingBox&&!1===gv.intersectsBox(n.boundingBox)))return;let a,s=n.index,o=n.attributes.position,l=n.morphAttributes.position,h=n.morphTargetsRelative,c=n.attributes.uv,u=n.attributes.uv2,d=n.groups,p=n.drawRange,f=t.length;if(null!==s)if(Array.isArray(i))for(let m=0,g=d.length;m<g;m++){let n=d[m],r=i[n.materialIndex];for(let i=Math.max(n.start,p.start),d=Math.min(s.count,Math.min(n.start+n.count,p.start+p.count));i<d;i+=3){let d=s.getX(i),p=s.getX(i+1),m=s.getX(i+2);if(a=HS(this,r,e,gv,o,l,h,c,u,d,p,m),a&&(a.faceIndex=Math.floor(i/3),a.face.materialIndex=n.materialIndex,t.push(a)),t.length-f>=1)return}}else for(let m=Math.max(0,p.start),g=Math.min(s.count,p.start+p.count);m<g;m+=3){let n=s.getX(m),r=s.getX(m+1),d=s.getX(m+2);if(a=HS(this,i,e,gv,o,l,h,c,u,n,r,d),a&&(a.faceIndex=Math.floor(m/3),t.push(a)),t.length-f>=1)return}else if(void 0!==o)if(Array.isArray(i))for(let m=0,g=d.length;m<g;m++){let n=d[m],r=i[n.materialIndex];for(let i=Math.max(n.start,p.start),s=Math.min(o.count,Math.min(n.start+n.count,p.start+p.count));i<s;i+=3)if(a=HS(this,r,e,gv,o,l,h,c,u,i,i+1,i+2),a&&(a.faceIndex=Math.floor(i/3),a.face.materialIndex=n.materialIndex,t.push(a)),t.length-f>=1)return}else for(let m=Math.max(0,p.start),g=Math.min(o.count,p.start+p.count);m<g;m+=3)if(a=HS(this,i,e,gv,o,l,h,c,u,m,m+1,m+2),a&&(a.faceIndex=Math.floor(m/3),t.push(a)),t.length-f>=1)return},Ge.prototype.raycast=tF;var kS=new hr,VS=new M;function Ile(e,t,n,i,r,a){let s=i.ray.distanceSqToPoint(e);if(s<n){let n=new M;i.ray.closestPointToPoint(e,n);let o=i.ray.origin.distanceTo(n);if(o<i.near||o>i.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}or.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),kS.copy(n.boundingSphere),kS.applyMatrix4(i),kS.radius+=r,!1===e.ray.intersectsSphere(kS))return;let s=r*r,o=n.index,l=n.attributes.position,h=t.length;if(null!==o)for(let c=Math.max(0,a.start),u=Math.min(o.count,a.start+a.count);c<u;c++){let n=o.getX(c);if(VS.fromBufferAttribute(l,n).applyMatrix4(i),Ile(VS,n,s,e,t,this),t.length-h>=1)return}else for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c<u;c++)if(VS.fromBufferAttribute(l,c).applyMatrix4(i),Ile(VS,c,s,e,t,this),t.length-h>=1)return};var oF=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},Ey=class{constructor(){this.id=0,this.v1=new gd,this.v2=new gd,this.v3=new gd,this.normalModel=new M,this.vertexNormalsModel=[new M,new M,new M],this.vertexNormalsLength=0,this.color=new Ie,this.material=null,this.uvs=[new Q,new Q,new Q],this.z=0,this.renderOrder=0}},gd=class{constructor(){this.position=new M,this.positionWorld=new M,this.positionScreen=new Mn,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},by=class{constructor(){this.id=0,this.v1=new gd,this.v2=new gd,this.vertexColors=[new Ie,new Ie],this.material=null,this.z=0,this.renderOrder=0}},_y=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new Q,this.material=null,this.renderOrder=0}},zS=class{constructor(){let e,t,n,i,r,a,s,o,l,h,c,u=0,d=0,p=0,f=0,m=0,g={objects:[],lights:[],elements:[]},v=new M,y=new Mn,x=new lt(new M(-1,-1,-1),new M(1,1,1)),_=new lt,b=new Array(3),w=new Ae,S=new Ae,E=new Ae,T=new ps,A=[],C=[],R=[],P=[],L=[],D=new function(){let e=[],t=[],l=[],h=null,u=new Wt;function m(e){let t=e.position,n=e.positionWorld,i=e.positionScreen;n.copy(t).applyMatrix4(c),i.copy(n).applyMatrix4(S);let r=1/i.w;i.x*=r,i.y*=r,i.z*=r,e.visible=i.x>=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function M(e,t,n){return!0===e.visible||!0===t.visible||!0===n.visible||(b[0]=e.positionScreen,b[1]=t.positionScreen,b[2]=n.positionScreen,x.intersectsBox(_.setFromPoints(b)))}function w(e,t,n){return(n.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(n.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}return{setObject:function(n){h=n,u.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:M,checkBackfaceCulling:w,pushVertex:function(e,t,r){n=function(){if(i===d){let e=new gd;return C.push(e),d++,i++,e}return C[i++]}(),n.position.set(e,t,r),m(n)},pushNormal:function(t,n,i){e.push(t,n,i)},pushColor:function(e,n,i){t.push(e,n,i)},pushUv:function(e,t){l.push(e,t)},pushLine:function(e,n){let i=C[e],r=C[n];i.positionScreen.copy(i.position).applyMatrix4(E),r.positionScreen.copy(r.position).applyMatrix4(E),!0===function(e,t){let n=0,i=1,r=e.z+e.w,a=t.z+t.w,s=-e.z+e.w,o=-t.z+t.w;return r>=0&&a>=0&&s>=0&&o>=0||!(r<0&&a<0||s<0&&o<0)&&(r<0?n=Math.max(n,r/(r-a)):a<0&&(i=Math.min(i,r/(r-a))),s<0?n=Math.max(n,s/(s-o)):o<0&&(i=Math.min(i,s/(s-o))),!(i<n)&&(e.lerp(t,n),t.lerp(e,1-i),!0))}(i.positionScreen,r.positionScreen)&&(i.positionScreen.multiplyScalar(1/i.positionScreen.w),r.positionScreen.multiplyScalar(1/r.positionScreen.w),s=function(){if(o===f){let e=new by;return P.push(e),f++,o++,e}return P[o++]}(),s.id=h.id,s.v1.copy(i),s.v2.copy(r),s.z=Math.max(i.positionScreen.z,r.positionScreen.z),s.renderOrder=h.renderOrder,s.material=h.material,h.material.vertexColors&&(s.vertexColors[0].fromArray(t,3*e),s.vertexColors[1].fromArray(t,3*n)),g.elements.push(s))},pushTriangle:function(n,i,s,o){let c=C[n],d=C[i],f=C[s];if(!1!==M(c,d,f)&&(o.side===tr||!0===w(c,d,f))){r=function(){if(a===p){let e=new Ey;return R.push(e),p++,a++,e}return R[a++]}(),r.id=h.id,r.v1.copy(c),r.v2.copy(d),r.v3.copy(f),r.z=(c.positionScreen.z+d.positionScreen.z+f.positionScreen.z)/3,r.renderOrder=h.renderOrder,v.subVectors(f.position,d.position),y.subVectors(c.position,d.position),v.cross(y),r.normalModel.copy(v),r.normalModel.applyMatrix3(u).normalize();for(let t=0;t<3;t++){let n=r.vertexNormalsModel[t];n.fromArray(e,3*arguments[t]),n.applyMatrix3(u).normalize(),r.uvs[t].fromArray(l,2*arguments[t])}r.vertexNormalsLength=3,r.material=o,o.vertexColors&&r.color.fromArray(t,3*n),g.elements.push(r)}}}};function I(e){if(!1===e.visible)return;if(e.isLight)g.lights.push(e);else if(e.isMesh||e.isLine||e.isPoints){if(!1===e.material.visible||!0===e.frustumCulled&&!1===T.intersectsObject(e))return;O(e)}else if(e.isSprite){if(!1===e.material.visible||!0===e.frustumCulled&&!1===T.intersectsSprite(e))return;O(e)}let t=e.children;for(let n=0,i=t.length;n<i;n++)I(t[n])}function O(n){e=function(){if(t===u){let e=new oF;return A.push(e),u++,t++,e}return A[t++]}(),e.id=n.id,e.object=n,v.setFromMatrixPosition(n.matrixWorld),v.applyMatrix4(S),e.z=v.z,e.renderOrder=n.renderOrder,g.objects.push(e)}function U(e,t,n){let i=1/e.w;e.z*=i,e.z>=-1&&e.z<=1&&(l=function(){if(h===m){let e=new _y;return L.push(e),m++,h++,e}return L[h++]}(),l.id=t.id,l.x=e.x*i,l.y=e.y*i,l.z=e.z,l.renderOrder=t.renderOrder,l.object=t,l.rotation=t.rotation,l.scale.x=t.scale.x*Math.abs(l.x-(e.x+n.projectionMatrix.elements[0])/(e.w+n.projectionMatrix.elements[12])),l.scale.y=t.scale.y*Math.abs(l.y-(e.y+n.projectionMatrix.elements[5])/(e.w+n.projectionMatrix.elements[13])),l.material=t.material,g.elements.push(l))}function N(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(e,n,r,s){a=0,o=0,h=0,g.elements.length=0,!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),w.copy(n.matrixWorldInverse),S.multiplyMatrices(n.projectionMatrix,w),T.setFromProjectionMatrix(S),t=0,g.objects.length=0,g.lights.length=0,I(e),!0===r&&g.objects.sort(N);let l=g.objects;for(let t=0,a=l.length;t<a;t++){let e=l[t].object,r=e.geometry;if(D.setObject(e),c=e.matrixWorld,i=0,e.isMesh){let t=e.material,n=Array.isArray(t),i=r.attributes,a=r.groups;if(void 0===i.position)continue;let s=i.position.array;for(let o=0,l=s.length;o<l;o+=3){let t=s[o],n=s[o+1],i=s[o+2],a=r.morphAttributes.position;if(void 0!==a){let l=r.morphTargetsRelative,h=e.morphTargetInfluences;for(let e=0,r=a.length;e<r;e++){let r=h[e];if(0===r)continue;let c=a[e];l?(t+=c.getX(o/3)*r,n+=c.getY(o/3)*r,i+=c.getZ(o/3)*r):(t+=(c.getX(o/3)-s[o])*r,n+=(c.getY(o/3)-s[o+1])*r,i+=(c.getZ(o/3)-s[o+2])*r)}}D.pushVertex(t,n,i)}if(void 0!==i.normal){let e=i.normal.array;for(let t=0,n=e.length;t<n;t+=3)D.pushNormal(e[t],e[t+1],e[t+2])}if(void 0!==i.color){let e=i.color.array;for(let t=0,n=e.length;t<n;t+=3)D.pushColor(e[t],e[t+1],e[t+2])}if(void 0!==i.uv){let e=i.uv.array;for(let t=0,n=e.length;t<n;t+=2)D.pushUv(e[t],e[t+1])}if(null!==r.index){let i=r.index.array;if(a.length>0)for(let r=0;r<a.length;r++){let s=a[r];if(t=!0===n?e.material[s.materialIndex]:e.material,void 0!==t)for(let e=s.start,n=s.start+s.count;e<n;e+=3)D.pushTriangle(i[e],i[e+1],i[e+2],t)}else for(let e=0,n=i.length;e<n;e+=3)D.pushTriangle(i[e],i[e+1],i[e+2],t)}else if(a.length>0)for(let r=0;r<a.length;r++){let i=a[r];if(t=!0===n?e.material[i.materialIndex]:e.material,void 0!==t)for(let e=i.start,n=i.start+i.count;e<n;e+=3)D.pushTriangle(e,e+1,e+2,t)}else for(let e=0,r=s.length/3;e<r;e+=3)D.pushTriangle(e,e+1,e+2,t)}else if(e.isLine){E.multiplyMatrices(S,c);let t=r.attributes;if(void 0!==t.position){let n=t.position.array;for(let e=0,t=n.length;e<t;e+=3)D.pushVertex(n[e],n[e+1],n[e+2]);if(void 0!==t.color){let e=t.color.array;for(let t=0,n=e.length;t<n;t+=3)D.pushColor(e[t],e[t+1],e[t+2])}if(null!==r.index){let e=r.index.array;for(let t=0,n=e.length;t<n;t+=2)D.pushLine(e[t],e[t+1])}else{let t=e.isLineSegments?2:1;for(let e=0,i=n.length/3-1;e<i;e+=t)D.pushLine(e,e+1)}}}else if(e.isPoints){E.multiplyMatrices(S,c);let t=r.attributes;if(void 0!==t.position){let i=t.position.array;for(let t=0,r=i.length;t<r;t+=3)y.set(i[t],i[t+1],i[t+2],1),y.applyMatrix4(E),U(y,e,n)}}else e.isSprite&&(e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),y.set(c.elements[12],c.elements[13],c.elements[14],1),y.applyMatrix4(S),U(y,e,n))}return!0===s&&g.elements.sort(N),g}}},Dle=class extends Tt{constructor(e){super(),this.isSVGObject=!0,this.node=e}},Lle=class{constructor(){let e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m=0,g=null,v=1,y=this,x=new si,_=new si,b=new Ie,w=new Ie,S=new Ie,E=new Ie,T=new Ie,A=new M,C=new M,R=new M,P=new Wt,L=new Ae,D=new Ae,I=[],O=new zS,U=document.createElementNS("http://www.w3.org/2000/svg","svg");function N(){for(m=0;U.childNodes.length>0;)U.removeChild(U.childNodes[0])}function F(e){return null!==g?e.toFixed(g):e}function k(e,t,n){let i=t.scale.x*a,r=t.scale.y*s;n.isPointsMaterial&&(i*=n.size,r*=n.size);let o="M"+F(e.x-.5*i)+","+F(e.y-.5*r)+"h"+F(i)+"v"+F(r)+"h"+F(-i)+"z",l="";(n.isSpriteMaterial||n.isPointsMaterial)&&(l="fill:"+n.color.getStyle()+";fill-opacity:"+n.opacity),H(l,o)}function B(e,t,n){let i="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y);if(n.isLineBasicMaterial){let e="fill:none;stroke:"+n.color.getStyle()+";stroke-opacity:"+n.opacity+";stroke-width:"+n.linewidth+";stroke-linecap:"+n.linecap;n.isLineDashedMaterial&&(e=e+";stroke-dasharray:"+n.dashSize+","+n.gapSize),H(e,i)}}function z(e,t,i,r,a){y.info.render.vertices+=3,y.info.render.faces++;let s="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y)+"L"+F(i.positionScreen.x)+","+F(i.positionScreen.y)+"z",o="";a.isMeshBasicMaterial?(b.copy(a.color),a.vertexColors&&b.multiply(r.color)):a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial?(w.copy(a.color),a.vertexColors&&w.multiply(r.color),b.copy(S),C.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),function(e,t,n,i){for(let r=0,a=e.length;r<a;r++){let a=e[r],s=a.color;if(a.isDirectionalLight){let e=A.setFromMatrixPosition(a.matrixWorld).normalize(),t=n.dot(e);if(t<=0)continue;t*=a.intensity,i.r+=s.r*t,i.g+=s.g*t,i.b+=s.b*t}else if(a.isPointLight){let e=A.setFromMatrixPosition(a.matrixWorld),r=n.dot(A.subVectors(e,t).normalize());if(r<=0||(r*=0==a.distance?1:1-Math.min(t.distanceTo(e)/a.distance,1),0==r))continue;r*=a.intensity,i.r+=s.r*r,i.g+=s.g*r,i.b+=s.b*r}}}(n,C,r.normalModel,b),b.multiply(w).add(a.emissive)):a.isMeshNormalMaterial&&(R.copy(r.normalModel).applyMatrix3(P).normalize(),b.setRGB(R.x,R.y,R.z).multiplyScalar(.5).addScalar(.5)),o=a.wireframe?"fill:none;stroke:"+b.getStyle()+";stroke-opacity:"+a.opacity+";stroke-width:"+a.wireframeLinewidth+";stroke-linecap:"+a.wireframeLinecap+";stroke-linejoin:"+a.wireframeLinejoin:"fill:"+b.getStyle()+";fill-opacity:"+a.opacity,H(o,s)}function V(e,t,n){let i=t.x-e.x,r=t.y-e.y,a=i*i+r*r;if(0===a)return;let s=n/Math.sqrt(a);i*=s,r*=s,t.x+=i,t.y+=r,e.x-=i,e.y-=r}function H(e,t){d===e?u+=t:(G(),d=e,u=t)}function G(){var e;u&&(e=m++,null==I[e]&&(I[e]=document.createElementNS("http://www.w3.org/2000/svg","path"),0==v&&I[e].setAttribute("shape-rendering","crispEdges")),c=I[e],c.setAttribute("d",u),c.setAttribute("style",d),U.appendChild(c)),u="",d=""}this.domElement=U,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.overdraw=.5,this.info={render:{vertices:0,faces:0}},this.setQuality=function(e){switch(e){case"high":v=1;break;case"low":v=0}},this.setClearColor=function(e,t){p=e,f=t},this.setPixelRatio=function(){},this.setSize=function(e,t){i=e,r=t,a=i/2,s=r/2,U.setAttribute("viewBox",-a+" "+-s+" "+i+" "+r),U.setAttribute("width",i),U.setAttribute("height",r),x.min.set(-a,-s),x.max.set(a,s)},this.getSize=function(){return{width:i,height:r}},this.setPrecision=function(e){g=e},this.clear=function(){if(N(),"number"==typeof p){let e=Snt(p);U.style.backgroundColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${f})`}else U.style.backgroundColor=p.getStyle()},this.render=function(i,r){if(!(r instanceof Fu))return void console.error("THREE.SVGRenderer.render: camera is not an instance of Camera.");let c=i.background;c&&c.isColor?(N(),U.style.backgroundColor=c.getStyle()):!0===this.autoClear&&this.clear(),y.info.render.vertices=0,y.info.render.faces=0,L.copy(r.matrixWorldInverse),D.multiplyMatrices(r.projectionMatrix,L),e=O.projectScene(i,r,this.sortObjects,this.sortElements),t=e.elements,n=e.lights,P.getNormalMatrix(r.matrixWorldInverse),function(e){S.setRGB(0,0,0),E.setRGB(0,0,0),T.setRGB(0,0,0);for(let t=0,n=e.length;t<n;t++){let n=e[t],i=n.color;n.isAmbientLight?(S.r+=i.r,S.g+=i.g,S.b+=i.b):n.isDirectionalLight?(E.r+=i.r,E.g+=i.g,E.b+=i.b):n.isPointLight&&(T.r+=i.r,T.g+=i.g,T.b+=i.b)}}(n),u="",d="";for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.material;if(void 0!==i&&0!==i.opacity)if(_.makeEmpty(),n instanceof _y)o=n,o.x*=a,o.y*=-s,k(o,n,i);else if(n instanceof by)o=n.v1,l=n.v2,o.positionScreen.x*=a,o.positionScreen.y*=-s,l.positionScreen.x*=a,l.positionScreen.y*=-s,_.setFromPoints([o.positionScreen,l.positionScreen]),!0===x.intersectsBox(_)&&B(o,l,i);else if(n instanceof Ey){if(o=n.v1,l=n.v2,h=n.v3,o.positionScreen.z<-1||o.positionScreen.z>1||l.positionScreen.z<-1||l.positionScreen.z>1||h.positionScreen.z<-1||h.positionScreen.z>1)continue;o.positionScreen.x*=a,o.positionScreen.y*=-s,l.positionScreen.x*=a,l.positionScreen.y*=-s,h.positionScreen.x*=a,h.positionScreen.y*=-s,this.overdraw>0&&(V(o.positionScreen,l.positionScreen,this.overdraw),V(l.positionScreen,h.positionScreen,this.overdraw),V(h.positionScreen,o.positionScreen,this.overdraw)),_.setFromPoints([o.positionScreen,l.positionScreen,h.positionScreen]),!0===x.intersectsBox(_)&&z(o,l,h,n,i)}}G(),i.traverseVisible((function(e){if(e.isSVGObject){if(A.setFromMatrixPosition(e.matrixWorld),A.applyMatrix4(D),A.z<-1||A.z>1)return;let t=A.x*a,n=-A.y*s,i=e.node;i.setAttribute("transform",`translate(${t}, ${n}) rotate(${e.rotation.z})`),U.appendChild(i)}}))}}};function Snt(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var xv=class extends Tt{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 Q(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}},vv=new M,Ole=new Ae,Nle=new Ae,Ule=new M,Ble=new M,Rc=class{constructor(e={}){let t,n,i,r,a=this,s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,t,n){if(e.isCSS2DObject){vv.setFromMatrixPosition(e.matrixWorld),vv.applyMatrix4(Nle);let l=!0===e.visible&&vv.z>=-1&&vv.z<=1&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(a,t,n);let s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(vv.x*i+i)+"px,"+(-vv.y*r+r)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(a,t,n)}let c={distanceToCameraSquared:h(n,e)};s.objects.set(e,c)}for(let i=0,r=e.children.length;i<r;i++)l(e.children[i],t,n)}function h(e,t){return Ule.setFromMatrixPosition(e.matrixWorld),Ble.setFromMatrixPosition(t.matrixWorld),Ule.distanceToSquared(Ble)}o.style.overflow="hidden",this.domElement=o,this.getSize=function(){return{width:t,height:n}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),Ole.copy(t.matrixWorldInverse),Nle.multiplyMatrices(t.projectionMatrix,Ole),l(e,e,t),function(e){let t=function(e){let t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){return e.renderOrder!==t.renderOrder?t.renderOrder-e.renderOrder:s.objects.get(e).distanceToCameraSquared-s.objects.get(t).distanceToCameraSquared})),n=t.length;for(let i=0,r=t.length;i<r;i++)t[i].element.style.zIndex=n-i}(e)},this.setSize=function(e,a){t=e,n=a,i=t/2,r=n/2,o.style.width=e+"px",o.style.height=a+"px"}}},yv=class extends Tt{constructor(e=!0,t=!1){super(),this.name="COORDINATE_AXES",this.AXIS_LENGTH=1,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255;let n=new M(0,0,0),i=new M(1,0,0),r=new M(0,1,0),a=new Rl(i,n,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new Rl(r,n,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new M(0,0,1),t=new Rl(e,n,this.AXIS_LENGTH,this.AXIS_COLOR_Z,0,0);this.add(t)}e&&this.addTexts(t)}addTexts(e=!1){let t=this.createText("X","#ff0000"),n=this.createText("Y","#00ff00");if(t.position.set(this.AXIS_LENGTH+.1,0,0),n.position.set(.1,this.AXIS_LENGTH,.1),this.add(t,n),!e){let e=this.createText("Z","#0000ff");e.position.set(0,0,this.AXIS_LENGTH+.1),this.add(e)}}createText(e,t,n=14){let i=document.createElement("div");i.innerHTML=e;let r=i.style;return r.color=t,r.width=`${n}px`,r.height=`${n}px`,r.textAlign="center",r.top="0px",r.left="0px",new xv(i)}},vd=class{constructor(e,t,n=!1){this.ignoreZAxis=!1,this.height=100,this.width=100,this.container=e,this.hostCamera=t,this.width=e.clientWidth||this.width,this.height=e.clientHeight||this.height,this.ignoreZAxis=n,this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){this.renderer=new ms({antialias:!0,alpha:!0}),this.renderer.setSize(this.width,this.height),this.container.appendChild(this.renderer.domElement),this.css2dRenderer=new Rc,this.css2dRenderer.setSize(this.width,this.height),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",this.container.appendChild(this.css2dRenderer.domElement)}initScene(){this.scene=new ii,this.camera=new dr(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new yv(!0,this.ignoreZAxis),this.scene.add(this.coordinateAxes)}setHostCamera(e){this.hostCamera=e}render(){var e;!this.scene||!this.camera||(this.renderer&&(this.update(),this.renderer.render(this.scene,this.camera)),null==(e=this.css2dRenderer)||e.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}update(){if(!this.hostCamera)return;let e=this.hostCamera;if(e){let t=new M;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){if(!this.camera||!e)return;e.normalize();let n=.3;this.camera.position.set(2*-e.x+n,2*-e.y+n,2*-e.z+n),this.camera.lookAt(n,n,n),this.camera.up=t}dispose(){!this.scene||!this.camera||!this.coordinateAxes||(this.scene.clear(),this.scene=void 0,this.css2dRenderer&&(this.container.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.renderer&&(this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.hostCamera=void 0,this.camera=void 0,this.coordinateAxes=void 0)}},GS=class{constructor(e){this.isCanceled=!1;let t=new Promise(((e,t)=>{this.cancelReject=t}));this.promise=Promise.race([t,e])}cancel(){this.cancelReject&&this.cancelReject({type:"cancel"})}},Rnt=wi(Hle(),1),$=Rnt;$.setLevel("warn");var kle=e=>{try{$.setLevel(e)}catch(e){$.setLevel("error"),$.error(e)}},lF=class{static isTouchScreenDevice(){return"ontouchstart"in window}static printDeviceInfo(){let e=navigator.userAgent,t=/(?:Android)/.test(e),n=/(?:Firefox)/.test(e),i=/(?:Chrome|CriOS)/.test(e),r=/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||n&&/(?:Tablet)/.test(e),a=/(?:iPhone)/.test(e)&&!r,s=!a&&!t,o=lF.isTouchScreenDevice();t&&$.debug("[DI] is android"),n&&$.debug("[DI] is fireFox"),i&&$.debug("[DI] is chrome"),r&&$.debug("[DI] is tablet"),a&&$.debug("[DI] is iPhone"),s&&$.debug("[DI] is PC"),o&&$.debug("[DI] is touch device")}static creatReactNativeCanvas(e){let t=e.drawingBufferWidth||e.width||0,n=e.drawingBufferHeight||e.height||0;return{style:{},width:t,height:n,clientWidth:Math.ceil(t/(window.devicePixelRatio||1)),clientHeight:Math.ceil(n/(window.devicePixelRatio||1)),addEventListener:()=>{},removeEventListener:()=>{}}}},tn=lF;tn.isMobile=/mobile/i.test(navigator.userAgent),tn.isBrowser="undefined"!=typeof document,tn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var it=class{static isFullScreen(){return!(!document.fullscreenElement&&!document.mozFullScreenElement)}static fullScreen(e=document.documentElement){(e.requestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen||e.msRequestFullscreen).call(e)}static exitFullscreen(){(document.exitFullscreen||document.mozCancelFullscreen||document.webkitExitFullscreen||document.msExitFullscreen).call(document)}static joinStrings(...e){return e.join("")}static numberToString(e){let t=2;return Math.abs(e)<1e-6?t=2:Math.abs(e)<1e-5?t=7:Math.abs(e)<1e-4?t=6:Math.abs(e)<.001?t=5:Math.abs(e)<.01?t=4:Math.abs(e)<.1&&(t=3),e.toFixed(t)}static hexToBase64(e){return btoa((e.match(/\w{2}/g)||[]).map((function(e){return String.fromCharCode(parseInt(e,16))})).join(""))}static vectorToString(e){return e instanceof M?`(${this.numberToString(e.x)}, ${this.numberToString(e.y)}, ${this.numberToString(e.z)})`:`(${this.numberToString(e.x)}, ${this.numberToString(e.y)})`}static arrayToVector2(e){return e?e instanceof Q?e:Array.isArray(e)&&e.length>=2?new Q(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof M?e:Array.isArray(e)&&e.length>=2?new M(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof rn?e:Array.isArray(e)&&e.length>=3?new rn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof M)return e;if(e instanceof Q)return new M(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new M(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new M(t.x,t.y,t.z||0):void 0}static isVectorValid(e){let t=e&&!isNaN(e.x)&&!isNaN(e.y)&&isFinite(e.x)&&isFinite(e.y);return t&&e instanceof M&&(t=!isNaN(e.z)&&isFinite(e.z)),t}static isBoxValid(e){return e&&!e.isEmpty()&&this.isVectorValid(e.min)&&this.isVectorValid(e.max)}static isMatrixValid(e){let t=e&&e.elements;if(!t||t.length<16)return!1;for(let n=0;n<16;++n){let e=t[n];if(Number.isNaN(e))return!1}return!0}static guid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}static expandBoxByScale(e,t){let n=new M;e.getCenter(n);let i=(e.max.x-e.min.x)*t,r=(e.max.y-e.min.y)*t,a=(e.max.z-e.min.z)*t,s=new M(n.x-i/2,n.y-r/2,n.z-a/2),o=new M(n.x+i/2,n.y+r/2,n.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let n=new M;e.getCenter(n);let i=e.max.x-e.min.x,r=e.max.y-e.min.y,a=e.max.z-e.min.z;i<t&&(e.min.setX(n.x-t/2),e.max.setX(n.x+t/2)),r<t&&(e.min.setY(n.y-t/2),e.max.setY(n.y+t/2)),a<t&&(e.min.setZ(n.z-t/2),e.max.setZ(n.z+t/2))}static generateRandomInt(e,t){return Math.floor(Math.random()*(t-e+1))+e}static roundNumber(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static convertDecimalToHex(e){return null==e?"#ffffff":`#${e.toString(16).padStart(6,"0")}`}static canvasToImage(e){let t=e.toDataURL(),n=new Image;return n.src=t,new Promise((e=>{n.onload=function(){e(n)}}))}static renderingContextToImage(e,t,n="image/png",i=.8){if(t){let r=Math.max(t.min.x,0),a=Math.max(t.min.y,0),s=Math.max(t.max.x-r,0),o=Math.max(t.max.y-a,0),l=e.getImageData(r,a,s,o),h=document.createElement("canvas");return h.width=s,h.height=o,h.getContext("2d").putImageData(l,0,0),h.toDataURL(n,i)}return e.canvas.toDataURL(n,i)}static printMemory(e){if(tn.isBrowser){let t=performance.memory;if(!t)return void $.warn("[CommonUtils] performance.memory is not available in this browser");let n=(t.jsHeapSizeLimit/1048576).toFixed(2),i=(t.totalJSHeapSize/1048576).toFixed(2),r=(t.usedJSHeapSize/1048576).toFixed(2);$.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${n}M , totalJSHeapSize: ${i}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(tn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),n=e.getParameter(t.UNMASKED_RENDERER_WEBGL);$.info("[CommonUtils] gpu:",n)}}static sleep(e){return $e(this,null,(function*(){let t;return new Promise((n=>{t=setTimeout((()=>{n("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return $e(this,null,(function*(){let n=this.twinklingObjectIds;n[e.id]||(n[e.id]=!0,e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,delete n[e.id])}))}};it.twinklingObjectIds={};var WS=(e,t,n)=>{let{default:i,active:r}=t;n?(e.remove(i),e.add(r||i)):(r&&e.remove(r),e.add(i))},nn=class{static getScreenPointByEvent(e,t){let n=new Q,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.clientX-i,n.y=e.clientY-r,n}static getScreenPointByTouchEvent(e,t){let n=new Q,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.touches[0].clientX-i,n.y=e.touches[0].clientY-r,n}static worldPosition2ScreenPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=e.clone(),s=new Q;return a.project(t),s.x=Math.round((.5+a.x/2)*i),s.y=Math.round((.5-a.y/2)*r),s}static screenPoint2worldPosition(e,t,n){let i=nn.screenPoint2NdcPoint(e,t,n);return new M(i.x,i.y,1).unproject(t)}static screenPoint2NdcPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=new Q;return a.x=e.x/i*2-1,a.y=-e.y/r*2+1,a}static worldCoordinate2NormalizedScreenCoordinate(e,t,n){let i=new M;e instanceof Q?i.set(e.x,e.y,0):i.set(e.x,e.y,e.z);let r=nn.worldPosition2ScreenPoint(i,t,n);return r.x/=n.clientWidth,r.y/=n.clientHeight,r}},Ac=class{static createCSS2DObject(e){let t=new xv(e);return e.dataset.objectId=t.id.toString(),t}static createDefaultHotpoint(e=12){let t=document.createElement("div"),n=t.style;return n.width=`${e}px`,n.height=`${e}px`,n.opacity="0.8",n.cursor="pointer",n.top=-e/2+"px",n.left=-e/2+"px",n.backgroundColor="#ffffff",n.border="2px solid #00DAB7",n.borderRadius="50%",this.createCSS2DObject(t)}static createHotpoint(e){if(e){let t=document.createElement("div"),n=t.style;return n.top="0px",n.left="0px",t.innerHTML=e,this.createCSS2DObject(t)}return this.createDefaultHotpoint()}static createLabel(e,t=""){let n=document.createElement("div");if(n.innerHTML=e,t)n.classList.add(t);else{let e=n.style;e.padding="5px 9px",e.color="#ffffffdd",e.fontSize="12px",e.position="absolute",e.backgroundColor="rgba(0, 0, 0, 0.3)",e.borderRadius="12px",e.cursor="pointer",e.top="0px",e.left="0px"}return this.createCSS2DObject(n)}static tryFindObjectId(e){if(null!=e.dataset.objectId)return parseInt(e.dataset.objectId);let t=e.parentElement;return!t||t instanceof HTMLBodyElement?void 0:this.tryFindObjectId(t)}},Ev={unit:"file",decimalPrecision:99,camera:{near:.1,far:3e4},mouse:{sensitivity:3},keyboard:{sensitivity:3}},Vle={"Precision from file":99,"0(1)":0,"0.1(1/2)":1,"0.01(1/4)":2,"0.001(1/8)":3,"0.0001(1/16)":4,"0.00001(1/32)":5,"0.000001(1/64)":6},Cc=(e,t)=>e.toFixed(t===Vle["Precision from file"]?2:t),Xi=class{constructor(){this.map=new Map}addEventListener(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}dispatchEvent(e,t={}){let n=this.map.get(e);n&&[...n].forEach((e=>e(t)))}hasEventListener(e){return!!this.map.get(e)}removeEventListener(e,t){if(!e)return void this.map.clear();if(!t)return void this.map.delete(e);let n=this.map.get(e);n&&n.delete(t)}clearEventListeners(e){this.map.delete(e)}clearAllEventListener(){this.map.clear()}},gs=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:gs.MESH_EDGEBREAKER_ENCODING,quantization:[16,8,8,8,8],exportUvs:!0,exportNormals:!0,exportColor:!1},t),void 0===DracoEncoderModule)throw new Error("THREE.DRACOExporter: required the draco_encoder to work.");let n,i,r=e.geometry,a=DracoEncoderModule(),s=new a.Encoder;if(!0===e.isMesh){n=new a.MeshBuilder,i=new a.Mesh;let e=r.getAttribute("position");n.AddFloatAttributeToMesh(i,a.POSITION,e.count,e.itemSize,e.array);let s=r.getIndex();if(null!==s)n.AddFacesToMesh(i,s.count/3,s.array);else{let t=new(e.count>65535?Uint32Array:Uint16Array)(e.count);for(let e=0;e<t.length;e++)t[e]=e;n.AddFacesToMesh(i,e.count,t)}if(!0===t.exportNormals){let e=r.getAttribute("normal");void 0!==e&&n.AddFloatAttributeToMesh(i,a.NORMAL,e.count,e.itemSize,e.array)}if(!0===t.exportUvs){let e=r.getAttribute("uv");void 0!==e&&n.AddFloatAttributeToMesh(i,a.TEX_COORD,e.count,e.itemSize,e.array)}if(!0===t.exportColor){let e=r.getAttribute("color");if(void 0!==e){let t=zle(e);n.AddFloatAttributeToMesh(i,a.COLOR,e.count,e.itemSize,t)}}}else{if(!0!==e.isPoints)throw new Error("DRACOExporter: Unsupported object type.");{n=new a.PointCloudBuilder,i=new a.PointCloud;let e=r.getAttribute("position");if(n.AddFloatAttribute(i,a.POSITION,e.count,e.itemSize,e.array),!0===t.exportColor){let e=r.getAttribute("color");if(void 0!==e){let t=zle(e);n.AddFloatAttribute(i,a.COLOR,e.count,e.itemSize,t)}}}}let o,l=new a.DracoInt8Array,h=void 0!==t.encodeSpeed?t.encodeSpeed:5,c=void 0!==t.decodeSpeed?t.decodeSpeed:5;if(s.SetSpeedOptions(h,c),void 0!==t.encoderMethod&&s.SetEncodingMethod(t.encoderMethod),void 0!==t.quantization)for(let d=0;d<5;d++)void 0!==t.quantization[d]&&s.SetAttributeQuantization(d,t.quantization[d]);if(o=!0===e.isMesh?s.EncodeMeshToDracoBuffer(i,l):s.EncodePointCloudToDracoBuffer(i,!0,l),a.destroy(i),0===o)throw new Error("THREE.DRACOExporter: Draco encoding failed.");let u=new Int8Array(new ArrayBuffer(o));for(let d=0;d<o;d++)u[d]=l.GetValue(d);return a.destroy(l),a.destroy(s),a.destroy(n),u}};function zle(e){let t=new Ie,n=e.count,i=e.itemSize,r=new Float32Array(n*i);for(let a=0,s=n;a<s;a++)t.fromBufferAttribute(e,a).convertLinearToSRGB(),r[a*i]=t.r,r[a*i+1]=t.g,r[a*i+2]=t.b,4===i&&(r[a*i+3]=e.getW(a));return r}gs.MESH_EDGEBREAKER_ENCODING=1,gs.MESH_SEQUENTIAL_ENCODING=0,gs.POINT_CLOUD=0,gs.TRIANGULAR_MESH=1,gs.INVALID=-1,gs.POSITION=0,gs.NORMAL=1,gs.COLOR=2,gs.TEX_COORD=3,gs.GENERIC=4;var Gle={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},bv=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new dF(e)})),this.register((function(e){return new fF(e)})),this.register((function(e){return new gF(e)})),this.register((function(e){return new vF(e)})),this.register((function(e){return new xF(e)})),this.register((function(e){return new yF(e)})),this.register((function(e){return new pF(e)})),this.register((function(e){return new mF(e)})),this.register((function(e){return new EF(e)})),this.register((function(e){return new bF(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r=new hF,a=[];for(let s=0,o=this.pluginCallbacks.length;s<o;s++)a.push(this.pluginCallbacks[s](r));r.setPlugins(a),r.write(e,t,i).catch(n)}parseAsync(e,t){let n=this;return new Promise((function(i,r){n.parse(e,i,r,t)}))}},Zn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},cF="KHR_mesh_quantization",Ya={};Ya[cr]=Zn.NEAREST,Ya[ed]=Zn.NEAREST_MIPMAP_NEAREST,Ya[Du]=Zn.NEAREST_MIPMAP_LINEAR,Ya[Vn]=Zn.LINEAR,Ya[vp]=Zn.LINEAR_MIPMAP_NEAREST,Ya[Hs]=Zn.LINEAR_MIPMAP_LINEAR,Ya[Or]=Zn.CLAMP_TO_EDGE,Ya[Nr]=Zn.REPEAT,Ya[Nu]=Zn.MIRRORED_REPEAT;var qle={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Ant=new Ie,Wle=12,Cnt=1179937895,Pnt=2,jle=8,Int=1313821514,Dnt=5130562;function Ty(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Lnt(e){return(new TextEncoder).encode(e).buffer}function Ont(e){return Ty(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Nnt(e,t,n){let i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+n;r++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=Yt.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}function $le(e){return 4*Math.ceil(e/4)}function uF(e,t=0){let n=$le(e.byteLength);if(n!==e.byteLength){let i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<n;r++)i[r]=t;return i.buffer}return e}function Xle(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Yle(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}var hF=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t){return $e(this,arguments,(function*(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),yield Promise.all(this.pending);let i=this,r=i.buffers,a=i.json;n=i.options;let s=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(s),c=Object.keys(o);if(h.length>0&&(a.extensionsUsed=h),c.length>0&&(a.extensionsRequired=c),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=l.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let n=uF(e.result),i=new DataView(new ArrayBuffer(jle));i.setUint32(0,n.byteLength,!0),i.setUint32(4,Dnt,!0);let r=uF(Lnt(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(jle));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Int,!0);let o=new ArrayBuffer(Wle),l=new DataView(o);l.setUint32(0,Cnt,!0),l.setUint32(4,Pnt,!0);let h=Wle+s.byteLength+r.byteLength+i.byteLength+n.byteLength;l.setUint32(8,h,!0);let c=new Blob([o,s,r,i,n],{type:"application/octet-stream"}),u=new FileReader;u.readAsArrayBuffer(c),u.onloadend=function(){t(u.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}))}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,i=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new M;for(let n=0,i=e.count;n<i;n++)if(Math.abs(t.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new M;for(let r=0,a=n.count;r<a;r++)i.fromBufferAttribute(n,r),0===i.x&&0===i.y&&0===i.z?i.setX(1):i.normalize(),n.setXYZ(r,i.x,i.y,i.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,i={};(0!==t.offset.x||0!==t.offset.y)&&(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.colorSpace===St?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");let i=e?e.image:null,r=t?t.image:null,a=Math.max(i?i.width:0,r?r.width:0),s=Math.max(i?i.height:0,r?r.height:0),o=Xle();o.width=a,o.height=s;let l=o.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,a,s);let h=l.getImageData(0,0,a,s);if(i){l.drawImage(i,0,0,a,s);let t=n(e),r=l.getImageData(0,0,a,s).data;for(let e=2;e<r.length;e+=4)h.data[e]=256*t(r[e]/256)}if(r){l.drawImage(r,0,0,a,s);let e=n(t),i=l.getImageData(0,0,a,s).data;for(let t=1;t<i.length;t+=4)h.data[t]=256*e(i[t]/256)}l.putImageData(h,0,0);let c=(e||t).clone();return c.source=new Tl(o),c.colorSpace=mc,c.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),c}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,r){let a,s=this.json;switch(s.bufferViews||(s.bufferViews=[]),t){case Zn.BYTE:case Zn.UNSIGNED_BYTE:a=1;break;case Zn.SHORT:case Zn.UNSIGNED_SHORT:a=2;break;default:a=4}let o=$le(i*e.itemSize*a),l=new DataView(new ArrayBuffer(o)),h=0;for(let u=n;u<n+i;u++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[u*e.itemSize+n]:(0===n?i=e.getX(u):1===n?i=e.getY(u):2===n?i=e.getZ(u):3===n&&(i=e.getW(u)),!0===e.normalized&&(i=Yt.normalize(i,e.array))),t===Zn.FLOAT?l.setFloat32(h,i,!0):t===Zn.INT?l.setInt32(h,i,!0):t===Zn.UNSIGNED_INT?l.setUint32(h,i,!0):t===Zn.SHORT?l.setInt16(h,i,!0):t===Zn.UNSIGNED_SHORT?l.setUint16(h,i,!0):t===Zn.BYTE?l.setInt8(h,i):t===Zn.UNSIGNED_BYTE&&l.setUint8(h,i),h+=a}let c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==r&&(c.target=r),r===Zn.ARRAY_BUFFER&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,s.bufferViews.push(c),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let e=uF(r.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(a)-1)}}))}processAccessor(e,t,n,i){let r,a=this.json;if(e.array.constructor===Float32Array)r=Zn.FLOAT;else if(e.array.constructor===Int32Array)r=Zn.INT;else if(e.array.constructor===Uint32Array)r=Zn.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=Zn.SHORT;else if(e.array.constructor===Uint16Array)r=Zn.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=Zn.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");r=Zn.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;let s,o=Nnt(e,n,i);void 0!==t&&(s=e===t.index?Zn.ELEMENT_ARRAY_BUFFER:Zn.ARRAY_BUFFER);let l=this.processBufferView(e,r,n,i,s),h={bufferView:l.id,byteOffset:l.byteOffset,componentType:r,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let r=this,a=r.cache,s=r.json,o=r.options,l=r.pending;a.images.has(e)||a.images.set(e,{});let h=a.images.get(e),c=i+":flipY/"+n.toString();if(void 0!==h[c])return h[c];s.images||(s.images=[]);let u={mimeType:i},d=Xle();d.width=Math.min(e.width,o.maxTextureSize),d.height=Math.min(e.height,o.maxTextureSize);let p=d.getContext("2d");if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==e.data){t!==Ji&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,d.width,d.height);!0===o.binary?l.push(Yle(d,i).then((e=>r.processBufferViewImage(e))).then((e=>{u.bufferView=e}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(Yle(d,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{u.uri=e})));let f=s.images.push(u)-1;return h[c]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:Ya[e.magFilter],minFilter:Ya[e.minFilter],wrapS:Ya[e.wrapS],wrapT:Ya[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");let r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(r.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,r)}));let a=n.textures.push(r)-1;return t.textures.set(e,a),a}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=e.color.toArray().concat([e.opacity]);if(Ty(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===tr&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));let a=n.materials.push(i)-1;return t.materials.set(e,a),a}processMesh(e){let t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,x=e.material.length;y<x;y++)i.push(e.material[y].uuid);else i.push(e.material.uuid);let r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);let a,s=e.geometry;a=e.isLineSegments?Zn.LINES:e.isLineLoop?Zn.LINE_LOOP:e.isLine?Zn.LINE_STRIP:e.isPoints?Zn.POINTS:e.material.wireframe?Zn.LINES:Zn.TRIANGLES;let o={},l={},h=[],c=[],u={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0!==d&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let y in s.attributes){if("morph"===y.slice(0,5))continue;let e=s.attributes[y];if(y=u[y]||y.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y)||(y="_"+y),t.attributes.has(this.getUID(e))){l[y]=t.attributes.get(this.getUID(e));continue}p=null;let n=e.array;"JOINTS_0"===y&&!(n instanceof Uint16Array)&&!(n instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new Ct(new Uint16Array(n),e.itemSize,e.normalized));let i=this.processAccessor(p||e,s);null!==i&&(y.startsWith("_")||this.detectMeshQuantization(y,e),l[y]=i,t.attributes.set(this.getUID(e),i))}if(void 0!==d&&s.setAttribute("normal",d),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){let n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let a=0;a<e.morphTargetInfluences.length;++a){let o={},l=!1;for(let e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}let n=s.morphAttributes[e][a],i=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(n,!0))){o[i]=t.attributes.get(this.getUID(n,!0));continue}let h=n.clone();if(!s.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let i=0;i<n.itemSize;i++)0===i&&h.setX(e,n.getX(e)-r.getX(e)),1===i&&h.setY(e,n.getY(e)-r.getY(e)),2===i&&h.setZ(e,n.getZ(e)-r.getZ(e)),3===i&&h.setW(e,n.getW(e)-r.getW(e));o[i]=this.processAccessor(h,s),t.attributes.set(this.getUID(r,!0),o[i])}c.push(o),n.push(e.morphTargetInfluences[a]),void 0!==e.morphTargetDictionary&&i.push(r[a])}o.weights=n,i.length>0&&(o.extras={},o.extras.targetNames=i)}let f=Array.isArray(e.material);if(f&&0===s.groups.length)return null;let m=f?e.material:[e.material],g=f?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,x=g.length;y<x;y++){let e={mode:a,attributes:l};if(this.serializeUserData(s,e),c.length>0&&(e.targets=c),null!==s.index){let n=this.getUID(s.index);(void 0!==g[y].start||void 0!==g[y].count)&&(n+=":"+g[y].start+":"+g[y].count),t.attributes.has(n)?e.indices=t.attributes.get(n):(e.indices=this.processAccessor(s.index,s,g[y].start,g[y].count),t.attributes.set(n,e.indices)),null===e.indices&&delete e.indices}let n=this.processMaterial(m[g[y].materialIndex]);null!==n&&(e.material=n),h.push(e)}o.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let v=n.meshes.push(o)-1;return t.meshes.set(r,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[cF])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let i=e.split("_",1)[0];Gle[i]&&Gle[i].includes(n)&&(this.extensionsUsed[cF]=!0,this.extensionsRequired[cF]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:Yt.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let r=(e=bv.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],s=[];for(let o=0;o<r.length;++o){let e=r[o],n=ln.parseTrackName(e.name),l=ln.findNode(t,n.nodeName),h=qle[n.propertyName];if("bones"===n.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(n.objectIndex):void 0),!l||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',e.name),null;let c,u=1,d=e.values.length/e.times.length;h===qle.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(c="CUBICSPLINE",d/=3):c=e.getInterpolation()===Bu?"STEP":"LINEAR",s.push({input:this.processAccessor(new Ct(e.times,u)),output:this.processAccessor(new Ct(e.values,d)),interpolation:c}),a.push({sampler:s.length-1,target:{node:i.get(l),path:h}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:s,channels:a}),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],r=e.skeleton;if(void 0===r)return null;let a=e.skeleton.bones[0];if(void 0===a)return null;let s=[],o=new Float32Array(16*r.bones.length),l=new Ae;for(let h=0;h<r.bones.length;++h)s.push(n.get(r.bones[h])),l.copy(r.boneInverses[h]),l.multiply(e.bindMatrix).toArray(o,16*h);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new Ct(o,16)),joints:s,skeleton:n.get(a)}),i.skin=t.skins.length-1}processNode(e){let t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);let r={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();Ty(t,[0,0,0,1])||(r.rotation=t),Ty(n,[0,0,0])||(r.translation=n),Ty(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ont(e.matrix)&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let i=0,r=e.children.length;i<r;i++){let r=e.children[i];if(r.visible||!1===n.onlyVisible){let e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));let a=t.nodes.push(r)-1;return i.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);let r=[];for(let a=0,s=e.children.length;a<s;a++){let t=e.children[a];if(t.visible||!1===n.onlyVisible){let e=this.processNode(t);null!==e&&r.push(e)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){let t=new ii;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));let n=[];for(let i=0;i<e.length;i++)e[i]instanceof ii?this.processScene(e[i]):n.push(e[i]);n.length>0&&this.processObjects(n);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},dF=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);let n=this.writer,i=n.json,r=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type="directional":e.isPointLight?(a.type="point",e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);let s=i.extensions[this.name].lights;s.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}},fF=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},pF=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},mF=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},gF=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},vF=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},xF=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},yF=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Ant)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},EF=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),r.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),r.sheenColorTexture=t}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},bF=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}};bv.Utils={insertKeyframe:function(e,t){let n,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+i),s=e.createInterpolant(new e.ValueBufferType(i));if(0===e.times.length){r[0]=t;for(let e=0;e<i;e++)a[e]=0;n=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;r[0]=t,r.set(e.times,1),a.set(s.evaluate(t),0),a.set(e.values,i),n=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),a.set(e.values,0),a.set(s.evaluate(t),e.values.length),n=r.length-1}else for(let o=0;o<e.times.length;o++){if(Math.abs(e.times[o]-t)<.001)return o;if(e.times[o]<t&&e.times[o+1]>t){r.set(e.times.slice(0,o+1),0),r[o+1]=t,r.set(e.times.slice(o+1),o+2),a.set(e.values.slice(0,(o+1)*i),0),a.set(s.evaluate(t),(o+1)*i),a.set(e.values.slice((o+1)*i),(o+2)*i),n=o+1;break}}return e.times=r,e.values=a,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},r=e.tracks;for(let a=0;a<r.length;++a){let e=r[a],s=ln.parseTrackName(e.name),o=ln.findNode(t,s.nodeName);if("morphTargetInfluences"!==s.propertyName||void 0===s.propertyIndex){n.push(e);continue}if(e.createInterpolant!==e.InterpolantFactoryMethodDiscrete&&e.createInterpolant!==e.InterpolantFactoryMethodLinear){if(e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),e=e.clone(),e.setInterpolation(vc)}let l,h=o.morphTargetInfluences.length,c=o.morphTargetDictionary[s.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+s.propertyIndex);if(void 0===i[o.uuid]){l=e.clone();let t=new l.ValueBufferType(h*l.times.length);for(let e=0;e<l.times.length;e++)t[e*h+c]=l.values[e];l.name=(s.nodeName||"")+".morphTargetInfluences",l.values=t,i[o.uuid]=l,n.push(l);continue}let u=e.createInterpolant(new e.ValueBufferType(1));l=i[o.uuid];for(let t=0;t<l.times.length;t++)l.values[t*h+c]=u.evaluate(l.times[t]);for(let t=0;t<e.times.length;t++){let n=this.insertKeyframe(l,e.times[t]);l.values[n*h+c]=e.values[t]}}return e.tracks=n,e}};var jS=class{parse(e){let t="",n=0,i=0,r=0,a=new M,s=new Ie,o=new M,l=new Q,h=[];return e.traverse((function(e){!0===e.isMesh&&function(e){let s=0,c=0,u=0,d=e.geometry,p=new Wt,f=d.getAttribute("position"),m=d.getAttribute("normal"),g=d.getAttribute("uv"),v=d.getIndex();if(t+="o "+e.name+"\n",e.material&&e.material.name&&(t+="usemtl "+e.material.name+"\n"),void 0!==f)for(let n=0,i=f.count;n<i;n++,s++)a.fromBufferAttribute(f,n),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z+"\n";if(void 0!==g)for(let n=0,i=g.count;n<i;n++,u++)l.fromBufferAttribute(g,n),t+="vt "+l.x+" "+l.y+"\n";if(void 0!==m){p.getNormalMatrix(e.matrixWorld);for(let e=0,n=m.count;e<n;e++,c++)o.fromBufferAttribute(m,e),o.applyMatrix3(p).normalize(),t+="vn "+o.x+" "+o.y+" "+o.z+"\n"}if(null!==v)for(let a=0,o=v.count;a<o;a+=3){for(let e=0;e<3;e++){let t=v.getX(a+e)+1;h[e]=n+t+(m||g?"/"+(g?i+t:"")+(m?"/"+(r+t):""):"")}t+="f "+h.join(" ")+"\n"}else for(let a=0,o=f.count;a<o;a+=3){for(let e=0;e<3;e++){let t=a+e+1;h[e]=n+t+(m||g?"/"+(g?i+t:"")+(m?"/"+(r+t):""):"")}t+="f "+h.join(" ")+"\n"}n+=s,i+=u,r+=c}(e),!0===e.isLine&&function(e){let i=0,r=e.geometry,s=e.type,o=r.getAttribute("position");if(t+="o "+e.name+"\n",void 0!==o)for(let n=0,l=o.count;n<l;n++,i++)a.fromBufferAttribute(o,n),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z+"\n";if("Line"===s){t+="l ";for(let e=1,i=o.count;e<=i;e++)t+=n+e+" ";t+="\n"}if("LineSegments"===s)for(let a=1,l=a+1,h=o.count;a<h;a+=2,l=a+1)t+="l "+(n+a)+" "+(n+l)+"\n";n+=i}(e),!0===e.isPoints&&function(e){let i=0,r=e.geometry,o=r.getAttribute("position"),l=r.getAttribute("color");if(t+="o "+e.name+"\n",void 0!==o){for(let n=0,r=o.count;n<r;n++,i++)a.fromBufferAttribute(o,n),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z,void 0!==l&&(s.fromBufferAttribute(l,n).convertLinearToSRGB(),t+=" "+s.r+" "+s.g+" "+s.b),t+="\n";t+="p ";for(let e=1,i=o.count;e<=i;e++)t+=n+e+" ";t+="\n"}n+=i}(e)})),t}},Gr=class{static exportToGltf(e,t){Gr.exportToGltfOrGlb(e,t,{binary:!1})}static exportToGlb(e,t){Gr.exportToGltfOrGlb(e,t,{binary:!0})}static exportToGltfOrGlb(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");let i=new bv;n=Object.assign({},{binary:!0,onlyVisible:!1,includeCustomExtensions:!1},n),i.parse(e,(e=>{if(n.binary){t=Gr.addExtention(t,Gr.EXTENSION_GLB);let n=e;Gr.saveArrayBuffer(n,t)}else t=Gr.addExtention(t,Gr.EXTENSION_GLTF),Gr.saveJson(e,t)}),(e=>console.log(e)),n)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=Gr.addExtention(t,Gr.EXTENSION_OBJ);let n=(new jS).parse(e);Gr.saveString(n,t)}static exportToDraco(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");t=Gr.addExtention(t,Gr.EXTENSION_DRACO);let i=new gs;n=Object.assign({},{encodeSpeed:5},n);let r=i.parse(e,n);Gr.saveArrayBuffer(r,t)}static exportToThreeJsJson(e,t){let n=e.toJSON();t.toLowerCase().endsWith(Gr.EXTENSION_JSON)||(t+=Gr.EXTENSION_JSON),Gr.saveJson(n,t)}static save(e,t){let n=Gr.downloadLink;n||(n=document.createElement("a"),n.style.display="none",document.body.appendChild(n),Gr.downloadLink=n),n.href=URL.createObjectURL(e),n.download=t,n.click()}static saveArrayBuffer(e,t){Gr.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){Gr.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){Gr.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){Gr.save(new Blob([e],{type:"text/csv"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},bp=Gr;bp.EXTENSION_GLTF=".gltf",bp.EXTENSION_GLB=".glb",bp.EXTENSION_OBJ=".obj",bp.EXTENSION_DRACO=".drc",bp.EXTENSION_JSON=".json";var XS=class{constructor(){this.prevTime=(performance||Date).now(),this.beginTime=(performance||Date).now(),this.frames=0,this.fps=Number.NaN}begin(){this.beginTime=(performance||Date).now()}end(){this.frames++;let e=(performance||Date).now();return e>=this.prevTime+1e3&&(this.fps=Math.round(1e3*this.frames/(e-this.prevTime)),this.frames=0,this.prevTime=e),e}update(){this.beginTime=this.end()}},RF={exports:{}};function ZS(e,t,n){n=n||2;var i,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*n:e.length,d=tce(e,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=knt(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(var f=n;f<u;f+=n)(o=e[f])<i&&(i=o),(l=e[f+1])<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=0!==(h=Math.max(a-i,s-r))?32767/h:0}return wy(d,p,n,i,r,h,0),p}function tce(e,t,n,i,r){var a,s;if(r===SF(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Zle(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Zle(a,e[a],e[a+1],s);return s&&KS(s,s.next)&&(Sy(s),s=s.next),s}function _p(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!KS(i,i.next)&&0!==ai(i.prev,i,i.next))i=i.next;else{if(Sy(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function wy(e,t,n,i,r,a,s){if(e){!s&&a&&Wnt(e,i,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Bnt(e,i,r,a):Unt(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Sy(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?wy(e=Fnt(_p(e),t,n),t,n,i,r,a,2):2===s&&Hnt(e,t,n,i,r,a):wy(_p(e),t,n,i,r,a,1);break}}}function Unt(e){var t=e.prev,n=e,i=e.next;if(ai(t,n,i)>=0)return!1;for(var r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&_v(r,o,a,l,s,h,f.x,f.y)&&ai(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Bnt(e,t,n,i){var r=e.prev,a=e,s=e.next;if(ai(r,a,s)>=0)return!1;for(var o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=wF(p,f,t,n,i),y=wF(m,g,t,n,i),x=e.prevZ,_=e.nextZ;x&&x.z>=v&&_&&_.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&_v(o,c,l,u,h,d,x.x,x.y)&&ai(x.prev,x,x.next)>=0||(x=x.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&_v(o,c,l,u,h,d,_.x,_.y)&&ai(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&_v(o,c,l,u,h,d,x.x,x.y)&&ai(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&_v(o,c,l,u,h,d,_.x,_.y)&&ai(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Fnt(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!KS(r,a)&&nce(r,i,i.next,a)&&My(r,a)&&My(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Sy(i),Sy(i.next),i=e=a),i=i.next}while(i!==e);return _p(i)}function Hnt(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&Ynt(s,o)){var l=rce(s,o);return s=_p(s,s.next),l=_p(l,l.next),wy(s,t,n,i,r,a,0),void wy(l,t,n,i,r,a,0)}o=o.next}s=s.next}while(s!==e)}function knt(e,t,n,i){var r,a,s,o=[];for(r=0,a=t.length;r<a;r++)(s=tce(e,t[r]*i,r<a-1?t[r+1]*i:e.length,i,!1))===s.next&&(s.steiner=!0),o.push(Xnt(s));for(o.sort(Vnt),r=0;r<o.length;r++)n=znt(o[r],n);return n}function Vnt(e,t){return e.x-t.x}function znt(e,t){var n=Gnt(e,t);if(!n)return t;var i=rce(n,e);return _p(i,i.next),_p(n,n.next)}function Gnt(e,t){var n,i=t,r=e.x,a=e.y,s=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var o=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=r&&o>s&&(s=o,n=i.x<i.next.x?i:i.next,o===r))return n}i=i.next}while(i!==t);if(!n)return null;var l,h=n,c=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=c&&r!==i.x&&_v(a<u?r:s,a,c,u,a<u?s:r,a,i.x,i.y)&&(l=Math.abs(a-i.y)/(r-i.x),My(i,e)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&qnt(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}function qnt(e,t){return ai(e.prev,e,t.prev)<0&&ai(t.next,e,e.next)<0}function Wnt(e,t,n,i){var r=e;do{0===r.z&&(r.z=wF(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,jnt(r)}function jnt(e){var t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t<h&&(o++,i=i.nextZ);t++);for(l=h;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function wF(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Xnt(e){var 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 _v(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Ynt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!$nt(e,t)&&(My(e,t)&&My(t,e)&&Znt(e,t)&&(ai(e.prev,e,t.prev)||ai(e,t.prev,t))||KS(e,t)&&ai(e.prev,e,e.next)>0&&ai(t.prev,t,t.next)>0)}function ai(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function KS(e,t){return e.x===t.x&&e.y===t.y}function nce(e,t,n,i){var r=$S(ai(e,t,n)),a=$S(ai(e,t,i)),s=$S(ai(n,i,e)),o=$S(ai(n,i,t));return!!(r!==a&&s!==o||0===r&&YS(e,n,t)||0===a&&YS(e,i,t)||0===s&&YS(n,e,i)||0===o&&YS(n,t,i))}function YS(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 $S(e){return e>0?1:e<0?-1:0}function $nt(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&nce(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function My(e,t){return ai(e.prev,e,e.next)<0?ai(e,t,e.next)>=0&&ai(e,e.prev,t)>=0:ai(e,t,e.prev)<0||ai(e,e.next,t)<0}function Znt(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function rce(e,t){var n=new MF(e.i,e.x,e.y),i=new MF(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Zle(e,t,n,i){var r=new MF(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Sy(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 MF(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function SF(e,t,n,i){for(var r=0,a=t,s=n-i;a<n;a+=i)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}RF.exports=ZS,RF.exports.default=ZS,ZS.deviation=function(e,t,n,i){var r=t&&t.length,a=r?t[0]*n:e.length,s=Math.abs(SF(e,0,a,n));if(r)for(var o=0,l=t.length;o<l;o++){var h=t[o]*n,c=o<l-1?t[o+1]*n:e.length;s-=Math.abs(SF(e,h,c,n))}var u=0;for(o=0;o<i.length;o+=3){var d=i[o]*n,p=i[o+1]*n,f=i[o+2]*n;u+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},ZS.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},i=0,r=0;r<e.length;r++){for(var a=0;a<e[r].length;a++)for(var s=0;s<t;s++)n.vertices.push(e[r][a][s]);r>0&&(i+=e[r-1].length,n.holes.push(i))}return n};var TTt=RF.exports;function Kle(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Knt(e,t){var n=t[0],i=t[1],r=t[2],a=Math.sqrt(n*n+i*i+r*r)||1;return e[0]=n/a,e[1]=i/a,e[2]=r/a,e}function Jnt(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function Qnt(e,t){function n(e,t,n,i){e[0]=t,e[1]=n,e[2]=i}for(var i=[],r=[],a=[],s=[],o=[],l=[],h=e.length,c=new Float32Array(t.length),u=0;u<h;){var d=3*e[u],p=3*e[u+1],f=3*e[u+2];n(i,t[d],t[d+1],t[d+2]),n(r,t[p],t[p+1],t[p+2]),n(a,t[f],t[f+1],t[f+2]),Kle(o,a,r),Kle(s,i,r),Jnt(l,o,s);for(var m=0;m<3;m++)c[d+m]+=l[m],c[p+m]+=l[m],c[f+m]+=l[m];u+=3}for(var g=0,v=c.length;g<v;)n(l,c[g],c[g+1],c[g+2]),Knt(l,l),c[g]=l[0]||0,c[g+1]=l[1]||0,c[g+2]=l[2]||0,g+=3;return c}function ert(e){if(1===e.length)return{position:e[0].position,normal:e[0].normal,uv:e[0].uv,indices:e[0].indices,results:e};for(var t=0,n=0,i=0,r=e.length;i<r;i++){var a=e[i],s=a.position,o=a.indices;t+=s.length,n+=o.length}for(var l={position:new Float32Array(t),normal:new Float32Array(t),uv:new Float32Array(t/3*2),indices:new Uint32Array(n),results:e},h=0,c=0,u=0,d=0,p=0,f=e.length;p<f;p++){var m=e[p],g=m.position,v=m.indices,y=m.normal,x=m.uv;l.position.set(g,h),l.normal.set(y,h),l.uv.set(x,d);for(var _=0,b=v.length;_<b;){var M=v[_]+c;l.indices[u]=M,u++,_++}d+=x.length,h+=g.length,c+=g.length/3}return l}function trt(e){return 180*e/Math.PI}function Jle(e){return e/180*Math.PI}function nrt(e,t,n,i,r,a){var s=3*n,o=3*i,l=3*r,h=3*a,c=t[s],u=t[s+1],d=t[s+2],p=t[o],f=t[o+1],m=t[o+2],g=t[l],v=t[l+1],y=t[l+2],x=t[h],_=t[h+1],b=t[h+2];Math.abs(u-f)<Math.abs(c-p)?(e.push(c,1-d),e.push(p,1-m),e.push(g,1-y),e.push(x,1-b)):(e.push(u,1-d),e.push(f,1-m),e.push(v,1-y),e.push(_,1-b))}function ice(e,t){t=Object.assign({},{depth:2,lineWidth:1},t);var n=ert(e.map((function(e){var n=srt(e,t);return n.line=e,rrt(n,t),irt(n,t),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.index),n.uv=new Float32Array(n.uvs),n.normal=Qnt(n.indices,n.position),n})));return n.lines=e,n}function rrt(e,t){for(var n=t.depth,i=[],r=[],a=[],s=e.leftPoints,o=e.rightPoints,l=0,h=s.length;l<h;){var c=3*l,u=s[l],d=u[0],p=u[1],f=u[2];i[c]=d,i[c+1]=p,i[c+2]=n+f;var m=o[l],g=m[0],v=m[1],y=m[2],x=3*h+c;i[x]=g,i[x+1]=v,i[x+2]=n+y;var _=2*h*3+c;i[_]=d,i[_+1]=p,i[_+2]=f;var b=2*h*3+3*h+c;i[b]=g,i[b+1]=v,i[b+2]=y,l++}for(l=0,h=i.length;l<h;){var M=i[l],w=i[l+1];a.push(M,w),l+=3}for(l=0,h=s.length;l<h-1;){var S=l,E=l+1,T=S+h,A=E+h;r.push(S,T,E),r.push(T,A,E);var C=l+2*h,R=C+1,P=C+h,L=R+h;r.push(C,P,R),r.push(P,L,R),l++}e.index=r,e.points=i,e.uvs=a}function irt(e,t){var n=e.points,i=e.index,r=e.leftPoints,a=e.rightPoints,s=e.uvs,o=t.depth,l=[r,a];function h(e,t){var r=n.length/3;n.push(e[0],e[1],o+e[2],t[0],t[1],o+t[2],e[0],e[1],e[2],t[0],t[1],t[2]);var a=r+2,l=r+3,h=r,c=r+1;i.push(a,h,l,h,c,l),nrt(s,n,a,l,h,c)}for(var c=0,u=l.length;c<u;c++){var d=l[c];c>0&&(d=(d=d.map((function(e){return e}))).reverse());for(var p=0,f=d.length-1;p<f;)h(d[p],d[p+1]),p++}for(var m=r.length,g=[a[0],r[0],r[m-1],a[m-1]],v=0;v<g.length;v+=2)h(g[v],g[v+1])}var _F={x:0,y:0},TF={x:0,y:0};function srt(e,t){for(var n=0,i=t.lineWidth/2,r=[],a=[],s=[],o=e.length,l=0;l<o-1;){var h=e[l],c=e[l+1],u=c[1]-h[1],d=c[0]-h[0],p=0,f=trt(Math.atan(u/d));if(n=f,0===l)p=f,p-=90;else{var m=e[l-1];_F.x=m[0]-h[0],_F.y=m[1]-h[1],TF.x=c[0]-h[0],TF.y=c[1]-h[1],p=f-art(_F,TF)/2}var g=Qle(Jle(p),i,h),v=g[0],y=g[1];r.push(v,y),ece(v,h,c)?(a.push(v),s.push(y)):(a.push(y),s.push(v)),l++}var x=n,_=Jle(x-=90),b=e[o-2],M=e[o-1],w=Qle(_,i,M),S=w[0],E=w[1];return r.push(S,E),ece(S,b,M)?(a.push(S),s.push(E)):(a.push(E),s.push(S)),{offsetPoints:r,leftPoints:a,rightPoints:s}}function Qle(e,t,n){var i=n[0],r=n[1],a=n[2]||0,s=[i+Math.cos(e)*t,r+Math.sin(e)*t,a],o=e+=Math.PI;return[s,[i+Math.cos(o)*t,r+Math.sin(o)*t,a]]}var art=function(e,t){var n=e.x,i=e.y,r=t.x,a=t.y,s=n*r+i*a,o=n*a-i*r;return(Math.atan2(o,s)/Math.PI*180+360)%360};function ece(e,t,n){var i=t[0],r=t[1],a=n[0],s=n[1];return(r-s)*e[0]+(a-i)*e[1]+i*s-a*r>0}var AF=1e-15,wt=class{static roundNumber(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static floorNumber(e,t){return Math.floor(e*Math.pow(10,t))/Math.pow(10,t)}static areNumbersEqual(e,t,n=1e-7){return Math.abs(e-t)<n*Math.max(1,Math.abs(e),Math.abs(t))}static areVector2sEqual(e,t,n=1e-7){return wt.areNumbersEqual(e.x,t.x,n)&&wt.areNumbersEqual(e.y,t.y,n)}static areVector3sEqual(e,t,n=1e-7){return wt.areNumbersEqual(e.x,t.x,n)&&wt.areNumbersEqual(e.y,t.y,n)&&wt.areNumbersEqual(e.z,t.z,n)}static areNumbersClose(e,t,n=1e-9,i=1e-12){return Math.abs(e-t)<=Math.max(n*Math.max(Math.abs(e),Math.abs(t)),i)}static areVector2sClose(e,t,n=1e-9,i=1e-12){return this.areNumbersClose(e.x,t.x,n,i)&&this.areNumbersClose(e.y,t.y,n,i)}static areVectorsClose(e,t,n=1e-9,i=1e-12){return this.areNumbersClose(e.x,t.x,n,i)&&this.areNumbersClose(e.y,t.y,n,i)&&this.areNumbersClose(e.z,t.z,n,i)}static getArcAngleSpanInRadian(e,t){let n=2*Math.PI;return wt.areNumbersClose(e,t,AF)?0:(e%=n,wt.areNumbersClose(e,t%n,AF)?n:(wt.areNumbersClose(t,n,AF)&&(t%=n),t<e&&(t+=n),t-e))}static getIntegerPartLength(e){return(e=Math.abs(e))<1?0:Math.ceil(Math.log10(Math.abs(e)+1))}static getRelativeEps(e,t=1e-7){let n=wt.getIntegerPartLength(e);return Math.max(Math.pow(10,n)*t,t)}static getVector2RelativeEps(e,t=1e-7){return Math.min(wt.getRelativeEps(e.x,t),wt.getRelativeEps(e.y,t))}static getControlPointByTwoPoints(e,t){let n=(new Q).subVectors(t,e),i=n.angle(),r=n.length(),a=Yt.degToRad(45),s=r/2/Math.cos(a);return new Q(e.x+s*Math.cos(a-i),e.y-s*Math.sin(a-i))}},CF=1e7,sce=new si,ace=new si,oce=new M,lce=new M,cce=new M,xd=new Rr,xt=class{static geometryEquals(e,t){return e===t||e.type===t.type&&e.name===t.name&&e.morphTargetsRelative===t.morphTargetsRelative&&this.equals(e.boundingBox,t.boundingBox)&&this.equals(e.boundingSphere,t.boundingSphere)&&this.attributesEqual(e.attributes,t.attributes)&&this.bufferAttributeEqual(e.index,t.index)}static equals(e,t){return e===t||!e&&!t||!(!e||!t)&&e.equals(t)}static attributesEqual(e,t){if(e===t)return!0;let n=Object.keys(e).sort(),i=Object.keys(t).sort();if(n.length!==i.length)return!1;for(let r=0;r<n.length;++r){if(n[r]!==i[r])return!1;let a=e[n[r]],s=t[i[r]];if(!this.bufferAttributeEqual(a,s))return!1}return!0}static bufferAttributeEqual(e,t){if(e===t)return!0;if(!e||!t||e.name!==t.name||e.itemSize!==t.itemSize||e.count!==t.count||e.normalized!==t.normalized)return!1;if(e.array&&t.array){if(e.array.length!==t.array.length)return!1;for(let n=0;n<e.array.length;++n)if(e.array[n]!==t.array[n])return!1}else if(e.array||t.array)return!1;let n=e.data,i=t.data;if(n&&i){if(n.length!==i.length)return!1;for(let e=0;e<n.length;++e)if(n[e]!==i[e])return!1}else if(n||i)return!1;return!0}static tryConvertInterleavedBufferAttributes(e){!e||!e.attributes||Object.keys(e.attributes).forEach((t=>{let n=e.attributes[t];if(n instanceof ha){let i=n.clone();e.attributes[t]=i}}))}static isPointInPolygon(e,t,n=!1){let i=e.x,r=e.y,a=!1,s=t.length;for(let o=0,l=s-1;o<s;l=o++){let e=t[o].x,s=t[o].y,h=t[l].x,c=t[l].y,u=s>r!=c>r;n&&(u=s>=r!=c>=r),u&&i<(h-e)*(r-s)/(c-s)+e&&(a=!a)}return a}static caculateGeometryCenter(e){if(!e.hasAttribute("position"))return null;let t=e.getAttribute("position");if(0===t.count)return null;let n=new M,i=t.itemSize,r=t.array,a=[0,0,0];for(let s=0;s<t.count;s++)for(let e=0;e<i;e++)a[e]+=r[s*i+e];for(let s=0;s<i;s++)n.setComponent(s,a[s]/t.count);return n}static isConvex(e){let t=e.length,n=0,i=0,r=new Q,a=new Q;for(let s=0;s<t;++s){let o=e[s],l=e[(s+1)%t],h=e[(s+2)%t];if(r.subVectors(l,o),a.subVectors(h,l),i=r.cross(a),0!=i){if(i>0&&n<0||i<0&&n>0)return!1;n=i}}return!0}static areLineSegmentsIntersecting(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=r.clone().sub(n),o=i.clone().sub(n),l=a.clone().sub(n),h=s.cross(o).dot(l.cross(o)),c=n.clone().sub(r),u=a.clone().sub(r),d=i.clone().sub(r),p=c.cross(u).dot(d.cross(u));return h<0&&p<0}static getLineSegmentsIntersectingPoint(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=oce.subVectors(i,n).normalize(),o=lce.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=cce.subVectors(r,n),h=s.clone().cross(o),c=l.clone().cross(o),u=l.clone().dot(h);if(u>=1e-5||u<=-1e-5)return null;let d=h.lengthSq();if(wt.areNumbersEqual(0,d))return;let p=c.clone().dot(h)/d,f=n.clone().add(s.multiplyScalar(p));return f.equals(n)||f.equals(i)?null:f}static isPointOnLineSegment(e,t,n=.001){let{start:i,end:r}=t,a=oce.subVectors(i,r).length(),s=lce.subVectors(e,i).length(),o=cce.subVectors(e,r).length();return Math.abs(a-(s+o))<=n}static isPointOnLineSegments(e,t,n=.001){let i=!1;for(let r=0;r<t.length-1;r+=2){let a=t[r],s=t[r+1];if(i=this.isPointOnLineSegment(e,{start:a,end:s},n),i)break}return i}static checkAndRebasePositionsOnRTC(e,t){if(0===e.length)return!1;let n=e[0]instanceof M;e.forEach((e=>{n?t.add(e):(t.x+=e.x,t.y+=e.y)})),t.divideScalar(e.length);let i=!1;if(xt.shouldRebasePositionOnRTC(t)){i=!0;for(let i=0;i<e.length;i++){let r=e[i].x-t.x,a=e[i].y-t.y;e[i]=n?new M(r,a,e[i].z-t.z):new Q(r,a)}}else t.setScalar(0);return i}static shouldRebasePositionOnRTC(e){return Math.abs(e.x)>CF||Math.abs(e.y)>CF||e instanceof M&&Math.abs(e.z)>CF}static calculateSurfaceArea(e){let t=0,n=e.getAttribute("position"),i=e.index;if(i)for(let r=0;r<i.count;r+=3)xd.a.fromBufferAttribute(n,i.getX(r)),xd.b.fromBufferAttribute(n,i.getX(r+1)),xd.c.fromBufferAttribute(n,i.getX(r+2)),t+=xd.getArea();else for(let r=0;r<n.count;r+=3)xd.a.fromBufferAttribute(n,r),xd.b.fromBufferAttribute(n,r+1),xd.c.fromBufferAttribute(n,r+2),t+=xd.getArea();return t}static convertLineStripToLine(e,t=!1){let n=e.getIndex();if(!n)return;let i=n.array.constructor,r=n.count,a=r;r>2&&(a=t?2*r:2*r-2);let s=new i(a),o=0;for(let l=0;l<r;l++){let e=n.getX(l);s[o++]=e,l>0&&l<r-1&&(s[o++]=e)}t&&(s[o++]=n.getX(r-1),s[o++]=n.getX(0)),e.setIndex(s)}static convertGeometryWithIndexedToNonIndexed(e){if(!e.index)return e;let t=new et,n=e.index;for(let i in e.attributes)t.setAttribute(i,xt.createGeometryAttributeByIndex(e.attributes[i],n));return t}static createGeometryAttributeByIndex(e,t){let n=t.count,i=e.itemSize,r=new(0,e.array.constructor)(n*i);for(let a=0;a<n;a++){let n=t.getX(a)*i;for(let t=0;t<i;t++)r[a*i+t]=e.array[n+t]}return new Ct(r,i,e.normalized)}static getLineEndPointsByIndex(e,t){var n,i,r;let a=t=>{let n=e.geometry.attributes.position.array;return e.localToWorld(new M(n[3*t],n[3*t+1],n[3*t+2]))};e.updateWorldMatrix(!0,!1);let s=(null==(n=e.geometry.getIndex())?void 0:n.array)||[],o=null!=(i=s[t])?i:t,l=null!=(r=s[t+1])?r:t+1;return[a(o),a(l)]}static arePolygonsIntersect(e,t){if(0===e.length||0===t.length||(sce.setFromPoints(e),ace.setFromPoints(t),!sce.intersectsBox(ace)))return!1;for(let n=0;n<e.length;){if(this.isPointInPolygon(e[n],t,!0))return!0;n<e.length-1&&wt.areVector2sEqual(e[n+1],e[n])&&++n,++n}return!1}static getLineLineIntersectionPoint(e,t,n,i,r=.001){let a=t.clone().sub(e).normalize(),s=i.clone().sub(n).normalize();if(Math.abs(a.dot(s))>1-r)return;let o=t.y-e.y,l=e.x-t.x,h=o*e.x+l*e.y,c=i.y-n.y,u=n.x-i.x,d=c*n.x+u*n.y,p=o*u-c*l;return Math.abs(p)<r?void 0:new Q((u*h-l*d)/p,(o*d-c*h)/p)}static getOffsetPoint(e,t,n){let i=t.x-e.x,r=t.y-e.y,a=n/Math.sqrt(i*i+r*r);return new Q(-a*r,a*i)}static convertSimpleWidthLineToMeshGeometry(e,t){let n,i,r,a=!1,s=!1,o=[],l=[],h=new Q,c=new Q,u=new Q,d=new Q,p=[],f=t/2;for(let y=0,x=e.length-1;y<x;y++)a=!y,s=y===e.length-2,n=this.getOffsetPoint(e[y],e[y+1],f),h=new Q(e[y].x+n.x,e[y].y+n.y),c=new Q(e[y+1].x+n.x,e[y+1].y+n.y),u=new Q(e[y].x-n.x,e[y].y-n.y),d=new Q(e[y+1].x-n.x,e[y+1].y-n.y),a||(i=this.getLineLineIntersectionPoint(o[0],o[1],h,c),void 0!==i?p.unshift(i):p.unshift(h),r=this.getLineLineIntersectionPoint(l[0],l[1],u,d),void 0!==r?p.push(r):p.push(u)),a&&(p.unshift(h),p.push(u)),s&&(p.unshift(c),p.push(d)),s||(o=[h,c],l=[u,d]);if(p.length<3)return;let m=Wi.triangulateShape(p,[]),g=[];for(let y=0;y<m.length;y++)g.push(...m[y]);let v=(new et).setFromPoints(p);return v.setIndex(g),v}static convertWidthLineToMeshGeometry(e,t){if(e.length<2)return;let n=[];e.forEach((e=>{n.push([e.x,e.y])}));try{let{indices:e,position:i}=ice([n],{lineWidth:t,depth:1}),r=new et;return r.setAttribute("position",new tt(i,3)),r.setIndex(Array.from(e)),r}catch(e){return}}static releaseGeometryManually(e){e.index=null,e.attributes={}}static getAdjacentNonRepeatPoints(e,t=1e-7){let n=[],i=e.length;for(let r=0;r<i-1;r++)wt.areVector3sEqual(e[r],e[r+1],t)||n.push(e[r]);return n.push(e[i-1]),n}static mergeBBoxes(e){let t=[...e];if(t.length<2)return t;let n=[],i=[];for(let r=0;r<t.length;r++){let e=t[r];if(!i.includes(r)){for(let n=0;n<t.length;n++){let r=t[n];e.equals(r)||e.intersectsBox(r)&&(e.union(r),i.push(n))}n.push(e)}}return n}},mr=!1,CTt=!1,Pc=10,ya=11,$r=12,Tv="gemini-viewer-iconfont",PTt="keydown",ITt="keyup",yd="mousemove",PF="mouseup",IF="mousedown",DTt="Escape",LTt="Enter",OTt="axis-section-plane",NTt="axis-section-plane-control",UTt="section-plane",BTt="section-plane-control",FTt="section-box",DF="plane-section-boxface",uce=-1e3,wv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(wv||{}),hce=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(hce||{}),vs=class{static createGroundGrid(e,t,n){e=e||this.DEFAULT_WIDTH,t=t||this.DEFAULT_WIDTH_SEGS;let i=new ay(e,t);n?i.position.set(n.x,n.y,n.z):i.position.y=0;let r=i.material;return Array.isArray(r)||(r.opacity=this.DEFAULT_MAT_PARAMS.opacity,r.transparent=this.DEFAULT_MAT_PARAMS.transparent),i.name=this.GROUND_GRID_NAME,i.layers.enableAll(),i.layers.disable(12),i.matrixAutoUpdate=!1,i.updateMatrix(),i}static createGrassGround(e,t,n,i,r){return $e(this,null,(function*(){return t=t||this.DEFAULT_WIDTH,n=n||this.DEFAULT_HEIGHT,new Promise((a=>{(new Ai).load(e||"images/terrain/grass.jpg",(e=>{e.wrapS=e.wrapT=Nr,e.repeat.set(i||this.DEFAULT_WIDTH_SEGS/5,r||this.DEFAULT_HEIGHT_SETS/5),e.anisotropy=16,e.encoding=pc;let s=new _c({map:e});s.side=Tr;let o=new Ge(new Ur(t,n),s);return o.rotation.x=-Math.PI/2,o.position.y=0,o.receiveShadow=!0,o.name=this.GRASS_GROUND_NAME,o.layers.enableAll(),o.layers.disable(12),o.matrixAutoUpdate=!1,o.updateMatrix(),a(o)}))}))}))}};vs.GROUND_GRID_NAME="GROUND_GRID",vs.GRASS_GROUND_NAME="GRASS_GROUND",vs.DEFAULT_WIDTH=1e3,vs.DEFAULT_HEIGHT=1e3,vs.DEFAULT_WIDTH_SEGS=100,vs.DEFAULT_HEIGHT_SETS=100,vs.DEFAULT_MAT_PARAMS={color:12829635,transparent:!0,opacity:.5,wireframeLinewidth:.5};var dce={NavCube:{front:"Front",back:"Back",top:"Top",bottom:"Bottom",left:"Left",right:"Right"},ContextMenu:{viewFitAll:"View Fit All",hideAll:"Hide All",showAll:"Show All",xRayAll:"X-Ray",xRayNone:"X-Ray None",selectNone:"Select None",resetView:"Reset View",viewFitEntity:"View Fit",hideEntity:"Hide",hideOthers:"Hide Others",xRayEntity:"X-Ray",xRayOthers:"X-Ray Others",select:"Select",deselect:"Undo Select",showSectionPlane:"Show Section Plane",showSectionBox:"Show Section Box",showAxisSection:"Show Axis Section",hideSectionPlane:"Hide Section Plane",hideSectionBox:"Hide Section Box",hideAxisSection:"Hide Axis Section",undoSection:"Undo Section"},ProgressBar:{Loading:"Loading",Comparing:"Comparing"},Toolbar:{homeView:"Home",orthoView:"Ortho View",measurement:"Measure",distanceMeasurement:"Distance",areaMeasurement:"Area",angleMeasurement:"Angle",coordinateMeasurement:"Coordinate",clearMeasurement:"Clear",markupVisibility:"Markup Visibility",markup:"Markup",markupArrow:"Arrow",markupRect:"Rect",markupCloudRect:"CloudRect",markupPolyLine:"PolyLine",markupCloudLine:"CloudLine",markupEllipse:"Ellipse",markupCircle:"Circle",markupDot:"Dot",markupText:"Text",markupX:"X",markupStroke:"Stroke Style",markupLineWidth:"Line Width",markupLineWidth2:"Line Width 2",markupLineWidth5:"Line Width 5",markupLineWidth10:"Line Width 10",markupFontSize:"Font Size",markupFontSize14:"14",markupFontSize18:"18",markupFontSize24:"24",clearMarkup:"Clear Markup",quitMarkup:"Quit markup",section:"Section",axisSection:"Axis Section",pickSectionPlane:"Pick Section Plane",sectionBox:"Section Box",bimTree:"BIM Tree",viewpoint:"Viewpoint",annotation:"Annotation",property:"Property",settings:"Settings",compared:"Compared",quitCompare:"Quit compare",fullscreen:"Full Screen",layers:"Layers",zoomToRectangle:"Zoom",screenshot:"Screenshot"},Tooltip:{measure:"Pick a point to continue, pressing ESC to exit",areaMeasurement:"Pick a point to continue, pressing ESC to exit, right click to finish",section:"Click to pick a section plane",boxSelect:"Box select an area to confirm the screenshot range",pickMarkup:"Click on a markup to confirm the screenshot range"},PopPanel:{reset:"Reset"}},fce={NavCube:{front:"\u524d",back:"\u540e",top:"\u4e0a",bottom:"\u4e0b",left:"\u5de6",right:"\u53f3"},ContextMenu:{viewFitAll:"\u7f29\u653e\u89c6\u53e3\u5230\u6240\u6709\u6a21\u578b",hideAll:"\u5168\u90e8\u9690\u85cf",showAll:"\u5168\u90e8\u663e\u793a",xRayAll:"\u5168\u90e8\u5e94\u7528 X \u5149\u6a21\u5f0f",xRayNone:"\u6e05\u9664 X \u5149\u6a21\u5f0f",selectNone:"\u6e05\u7a7a\u9009\u62e9",resetView:"\u91cd\u7f6e\u89c6\u56fe",viewFitEntity:"\u7f29\u653e\u89c6\u53e3\u5230\u5b9e\u4f53",hideEntity:"\u9690\u85cf",hideOthers:"\u9690\u85cf\u5176\u4ed6 (\u9694\u79bb)",xRayEntity:"\u5e94\u7528 X \u5149\u6a21\u5f0f",xRayOthers:"\u5bf9\u5176\u4ed6\u5b9e\u4f53\u5e94\u7528 X \u5149\u6a21\u5f0f",select:"\u9009\u62e9",deselect:"\u53d6\u6d88\u9009\u62e9",showSectionPlane:"\u663e\u793a\u5256\u5207\u9762",showSectionBox:"\u663e\u793a\u5256\u5207\u76d2",showAxisSection:"\u663e\u793a\u8f74\u5411\u5256\u5207",hideSectionPlane:"\u9690\u85cf\u5256\u5207\u9762",hideSectionBox:"\u9690\u85cf\u5256\u5207\u76d2",hideAxisSection:"\u9690\u85cf\u8f74\u5411\u5256\u5207",undoSection:"\u53d6\u6d88\u5256\u5207"},ProgressBar:{Loading:"\u6b63\u5728\u52a0\u8f7d",Comparing:"\u6b63\u5728\u5bf9\u6bd4"},Toolbar:{homeView:"\u4e3b\u89c6\u56fe",orthoView:"\u6b63\u4ea4\u89c6\u56fe",measurement:"\u6d4b\u91cf",distanceMeasurement:"\u8ddd\u79bb\u6d4b\u91cf",areaMeasurement:"\u9762\u79ef\u6d4b\u91cf",angleMeasurement:"\u89d2\u5ea6\u6d4b\u91cf",coordinateMeasurement:"\u5750\u6807\u6d4b\u91cf",clearMeasurement:"\u6e05\u9664\u6d4b\u91cf",markupVisibility:"\u6279\u6ce8\u663e\u9690",markup:"\u6279\u6ce8",markupArrow:"\u7bad\u5934",markupRect:"\u77e9\u5f62\u6846",markupCloudRect:"\u4e91\u7ebf\u6846",markupPolyLine:"\u591a\u6bb5\u7ebf",markupCloudLine:"\u4e91\u7ebf",markupEllipse:"\u692d\u5706",markupCircle:"\u5706",markupDot:"\u70b9",markupText:"\u6587\u5b57",markupX:"\u53c9\u53f7",markupStroke:"\u753b\u7b14\u989c\u8272",markupLineWidth:"\u7ebf\u5bbd",markupLineWidth2:"\u7ebf\u5bbd 2",markupLineWidth5:"\u7ebf\u5bbd 5",markupLineWidth10:"\u7ebf\u5bbd 10",markupFontSize:"\u5b57\u53f7",markupFontSize14:"14",markupFontSize18:"18",markupFontSize24:"24",clearMarkup:"\u6e05\u9664\u6279\u6ce8",quitMarkup:"\u9000\u51fa\u6279\u6ce8",section:"\u5256\u5207",axisSection:"\u8f74\u5411\u5256\u5207",pickSectionPlane:"\u9762\u5256\u5207",sectionBox:"\u5256\u5207\u76d2",bimTree:"BIM\u6811",viewpoint:"\u89c6\u70b9",annotation:"\u6279\u6ce8",property:"\u5c5e\u6027",settings:"\u8bbe\u7f6e",compared:"\u56fe\u7eb8\u5bf9\u6bd4",quitCompare:"\u9000\u51fa\u56fe\u7eb8\u5bf9\u6bd4",fullscreen:"\u5168\u5c4f",layers:"\u56fe\u5c42",zoomToRectangle:"\u6846\u9009\u653e\u5927",screenshot:"\u622a\u5c4f"},Tooltip:{measure:"\u70b9\u51fb\u7ee7\u7eed\u6d4b\u91cf, ESC \u53d6\u6d88\u6d4b\u91cf",areaMeasurement:"\u70b9\u51fb\u7ee7\u7eed\u6d4b\u91cf, ESC \u53d6\u6d88\u6d4b\u91cf\uff0c\u53f3\u952e\u5b8c\u6210\u6d4b\u91cf",section:"\u70b9\u51fb\u786e\u5b9a\u5256\u5207\u9762",boxSelect:"\u6846\u9009\u4e00\u4e2a\u533a\u57df\u4ee5\u786e\u5b9a\u622a\u56fe\u8303\u56f4",pickMarkup:"\u70b9\u51fb\u4e00\u4e2a\u6279\u6ce8\u4ee5\u786e\u5b9a\u622a\u56fe\u8303\u56f4"},PopPanel:{reset:"\u91cd\u7f6e"}},yi=class{static materialEquals(e,t){if(e===t)return!0;if(e.type!==t.type)return!1;if(e instanceof Rn&&t instanceof Rn){let n=e,i=t;return e.alphaTest===t.alphaTest&&e.opacity===t.opacity&&e.side===t.side&&e.visible===t.visible&&e.name===t.name&&e.transparent===t.transparent&&this.colorEquals(n.color,i.color)&&this.colorEquals(n.emissive,i.emissive)&&n.roughness===i.roughness&&n.metalness===i.metalness&&n.alphaMap===i.alphaMap&&n.uniforms===i.uniforms&&n.defines===i.defines&&n.vertexShader===i.vertexShader&&n.fragmentShader===i.fragmentShader&&n.clippingPlanes===i.clippingPlanes&&n.map===i.map&&n.clipIntersection===i.clipIntersection}return!1}static materialsEquals(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let n=0;n<e.length;++n)if(!this.materialEquals(e[n],t[n]))return!1;return!0}return e instanceof Rn&&t instanceof Rn&&this.materialEquals(e,t)}static colorEquals(e,t){return e===t||e instanceof Ie&&t instanceof Ie&&e.equals(t)}static clonedHighlightMaterials(e,t={}){if(!e||!e.material)return;let n=e.material;if(Array.isArray(n)&&n.length>0){let e=[];return n.forEach((n=>{e.push(this.clonedHighlightMaterial(n,t))})),e}if(n instanceof Rn)return this.clonedHighlightMaterial(n,t);console.warn(`[MaterialUtils] Invalid material: ${n}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:n,highlightColor:i=new Ie(583902),opacity:r=.7}=t,a=e.clone();return this.setMaterialColor(a,i),a.opacity=r,a.transparent=!0,void 0!==n&&(a.depthTest=n,a.side=tr),a}static cloneMaterial(e){if(!e)return e;if(Array.isArray(e)){let t=[];return e.forEach((e=>{t.push(e.clone())})),t}return e.clone()}static getMaterialColor(e){let t=new Ie(16777215);return e instanceof Br||e instanceof Jt||e instanceof Pt?t=e.color:e instanceof It&&e.uniforms.u_color&&(t=e.uniforms.u_color.value),t}static setMaterialColor(e,t){var n,i,r;let a=e;null==(n=a.color)||n.set(t),null==(i=a.emissive)||i.set(t),null!=(r=a.uniforms)&&r.u_color&&a.uniforms.u_color.value.set(t)}static cloneMaterials(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e))n.push(t.get(e));else{let i=e.clone();t.set(e,i),n.push(i)}}))):e&&(t.has(e)?n=t.get(e):(n=e.clone(),t.set(e,n))),n})(e.material))}))}};function Fo(e,t=!1){let n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),a={},s={},o=e[0].morphTargetsRelative,l=new et,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(n!==(null!==u.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let e in u.attributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(u.attributes[e]),d++}if(d!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let e in u.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===s[e]&&(s[e]=[]),s[e].push(u.morphAttributes[e])}if(t){let e;if(n)e=u.index.count;else{if(void 0===u.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=u.attributes.position.count}l.addGroup(h,e,c),h+=e}}if(n){let t=0,n=[];for(let i=0;i<e.length;++i){let r=e[i].index;for(let e=0;e<r.count;++e)n.push(r.getX(e)+t);t+=e[i].attributes.position.count}l.setIndex(n)}for(let c in a){let e=pce(a[c]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,e)}for(let c in s){let e=s[c][0].length;if(0===e)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let t=0;t<e;++t){let e=[];for(let i=0;i<s[c].length;++i)e.push(s[c][i][t]);let n=pce(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(n)}}return l}function pce(e){let t,n,i,r=0;for(let o=0;o<e.length;++o){let a=e[o];if(a.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=a.itemSize),n!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=a.normalized),i!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=a.array.length}let a=new t(r),s=0;for(let o=0;o<e.length;++o)a.set(e[o].array,s),s+=e[o].array.length;return new Ct(a,n,i)}function mce(e,t=1e-4){t=Math.max(t,Number.EPSILON);let n={},i=e.getIndex(),r=e.getAttribute("position"),a=i?i.count:r.count,s=0,o=Object.keys(e.attributes),l={},h={},c=[],u=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"];for(let g=0,v=o.length;g<v;g++){let t=o[g],n=e.attributes[t];l[t]=new Ct(new n.array.constructor(n.count*n.itemSize),n.itemSize,n.normalized);let i=e.morphAttributes[t];i&&(h[t]=new Ct(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized))}let p=Math.log10(1/t),f=Math.pow(10,p);for(let g=0;g<a;g++){let t=i?i.getX(g):g,r="";for(let n=0,i=o.length;n<i;n++){let i=o[n],a=e.getAttribute(i),s=a.itemSize;for(let e=0;e<s;e++)r+=~~(a[u[e]](t)*f)+","}if(r in n)c.push(n[r]);else{for(let n=0,i=o.length;n<i;n++){let i=o[n],r=e.getAttribute(i),a=e.morphAttributes[i],c=r.itemSize,p=l[i],f=h[i];for(let e=0;e<c;e++){let n=u[e],i=d[e];if(p[i](s,r[n](t)),a)for(let e=0,r=a.length;e<r;e++)f[e][i](s,a[e][n](t))}}n[r]=s,c.push(s),s++}}let m=e.clone();for(let g in e.attributes){let e=l[g];if(m.setAttribute(g,new Ct(e.array.slice(0,s*e.itemSize),e.itemSize,e.normalized)),g in h)for(let t=0;t<h[g].length;t++){let e=h[g][t];m.morphAttributes[g][t]=new Ct(e.array.slice(0,s*e.itemSize),e.itemSize,e.normalized)}}return m.setIndex(c),m}function LF(e,t){if(t===PB)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===nv||t===py){let n=e.getIndex();if(null===n){let t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}let i=n.count-2,r=[];if(t===nv)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let a=e.clone();return a.setIndex(r),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function Ry(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),i=new Worker(n);return URL.revokeObjectURL(n),i}function OF(){return Ry('var Ic=Object.defineProperty,Uc=Object.defineProperties;var Dc=Object.getOwnPropertyDescriptors;var Ro=Object.getOwnPropertySymbols;var Nc=Object.prototype.hasOwnProperty,Fc=Object.prototype.propertyIsEnumerable;var Co=(i,t,e)=>t in i?Ic(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ki=(i,t)=>{for(var e in t||(t={}))Nc.call(t,e)&&Co(i,e,t[e]);if(Ro)for(var e of Ro(t))Fc.call(t,e)&&Co(i,e,t[e]);return i},Po=(i,t)=>Uc(i,Dc(t));var ao="152";var Oc=0,Lo=1,Bc=2;var $a=1,zc=2,rn=3,He=0,le=1,ze=2;var xn=0,hi=1,Io=2,Uo=3,Do=4,kc=5,ai=100,Vc=101,Hc=102,No=103,Fo=104,Gc=200,Wc=201,Xc=202,qc=203,Ka=204,ja=205,Yc=206,Zc=207,Jc=208,$c=209,Kc=210,jc=0,Qc=1,tl=2,Rr=3,el=4,nl=5,il=6,sl=7,Qa=0,rl=1,ol=2,on=0,al=1,cl=2,ll=3,hl=4,ul=5,tc=300,pi=301,mi=302,Cr=303,Pr=304,Ns=306,Lr=1e3,ke=1001,Ir=1002,de=1003,Oo=1004;var js=1005;var Le=1006,fl=1007;var ki=1008;var On=1009,dl=1010,pl=1011,ec=1012,ml=1013,In=1014,Un=1015,Vi=1016,gl=1017,_l=1018,ui=1020,xl=1021,Ve=1023,yl=1024,vl=1025,Dn=1026,gi=1027,Ml=1028,Sl=1029,bl=1030,El=1031,wl=1033,Qs=33776,tr=33777,er=33778,nr=33779,Bo=35840,zo=35841,ko=35842,Vo=35843,Tl=36196,Ho=37492,Go=37496,Wo=37808,Xo=37809,qo=37810,Yo=37811,Zo=37812,Jo=37813,$o=37814,Ko=37815,jo=37816,Qo=37817,ta=37818,ea=37819,na=37820,ia=37821,ir=36492,Al=36283,sa=36284,ra=36285,oa=36286;var Ms=2300,Ss=2301,sr=2302,aa=2400,ca=2401,la=2402;var nc=3e3,Nn=3001,Rl=3200,Cl=3201,Pl=0,Ll=1,Fn="",Et="srgb",Je="srgb-linear",ic="display-p3";var rr=7680;var Il=519,ha=35044;var ua="300 es",Ur=1035,yn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let s=this._listeners[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}},ae=["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"];var or=Math.PI/180,Dr=180/Math.PI;function Wi(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ae[i&255]+ae[i>>8&255]+ae[i>>16&255]+ae[i>>24&255]+"-"+ae[t&255]+ae[t>>8&255]+"-"+ae[t>>16&15|64]+ae[t>>24&255]+"-"+ae[e&63|128]+ae[e>>8&255]+"-"+ae[e>>16&255]+ae[e>>24&255]+ae[n&255]+ae[n>>8&255]+ae[n>>16&255]+ae[n>>24&255]).toLowerCase()}function pe(i,t,e){return Math.max(t,Math.min(e,i))}function Ul(i,t){return(i%t+t)%t}function ar(i,t,e){return(1-e)*i+e*t}function fa(i){return(i&i-1)===0&&i!==0}function Dl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function ji(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ee(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Dt=class{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ct=class{constructor(){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],f=n[2],p=n[5],g=n[8],x=s[0],m=s[3],u=s[6],v=s[1],_=s[4],w=s[7],M=s[2],b=s[5],R=s[8];return r[0]=a*x+o*v+c*M,r[3]=a*m+o*_+c*b,r[6]=a*u+o*w+c*R,r[1]=l*x+h*v+d*M,r[4]=l*m+h*_+d*b,r[7]=l*u+h*w+d*R,r[2]=f*x+p*v+g*M,r[5]=f*m+p*_+g*b,r[8]=f*u+p*w+g*R,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=h*a-o*l,f=o*c-h*r,p=l*r-a*c,g=e*d+n*f+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return t[0]=d*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=f*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=p*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(cr.makeScale(t,e)),this}rotate(t){return this.premultiply(cr.makeRotation(-t)),this}translate(t,e){return this.premultiply(cr.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},cr=new Ct;function sc(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function bs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}var da={};function Bi(i){i in da||(da[i]=!0,console.warn(i))}function fi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function lr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Nl=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Fl=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function Ol(i){return i.convertSRGBToLinear().applyMatrix3(Fl)}function Bl(i){return i.applyMatrix3(Nl).convertLinearToSRGB()}var zl={[Je]:i=>i,[Et]:i=>i.convertSRGBToLinear(),[ic]:Ol},kl={[Je]:i=>i,[Et]:i=>i.convertLinearToSRGB(),[ic]:Bl},Ne={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Je},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=zl[t],s=kl[e];if(n===void 0||s===void 0)throw new Error(`Unsupported color space conversion, "${t}" to "${e}".`);return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)}},Xn,Es=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Xn===void 0&&(Xn=bs("canvas")),Xn.width=t.width,Xn.height=t.height;let n=Xn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Xn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&t instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap){let e=bs("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=fi(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(fi(e[n]/255)*255):e[n]=fi(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},ws=class{constructor(t=null){this.isSource=!0,this.uuid=Wi(),this.data=t,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(hr(s[a].image)):r.push(hr(s[a]))}else r=hr(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function hr(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?Es.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Vl=0,me=class extends yn{constructor(t=me.DEFAULT_IMAGE,e=me.DEFAULT_MAPPING,n=ke,s=ke,r=Le,a=ki,o=Ve,c=On,l=me.DEFAULT_ANISOTROPY,h=Fn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Vl++}),this.uuid=Wi(),this.name="",this.source=new ws(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Dt(0,0),this.repeat=new Dt(1,1),this.center=new Dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof h=="string"?this.colorSpace=h:(Bi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Nn?Et:Fn),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==tc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Lr:t.x=t.x-Math.floor(t.x);break;case ke:t.x=t.x<0?0:1;break;case Ir:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Lr:t.y=t.y-Math.floor(t.y);break;case ke:t.y=t.y<0?0:1;break;case Ir:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Bi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Et?Nn:nc}set encoding(t){Bi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Nn?Et:Fn}};me.DEFAULT_IMAGE=null;me.DEFAULT_MAPPING=tc;me.DEFAULT_ANISOTROPY=1;var $t=class{constructor(t=0,e=0,n=0,s=1){$t.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,c=t.elements,l=c[0],h=c[4],d=c[8],f=c[1],p=c[5],g=c[9],x=c[2],m=c[6],u=c[10];if(Math.abs(h-f)<.01&&Math.abs(d-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+f)<.1&&Math.abs(d+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+u-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let _=(l+1)/2,w=(p+1)/2,M=(u+1)/2,b=(h+f)/4,R=(d+x)/4,I=(g+m)/4;return _>w&&_>M?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=b/n,r=R/n):w>M?w<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(w),n=b/s,r=I/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=R/r,s=I/r),this.set(n,s,r,e),this}let v=Math.sqrt((m-g)*(m-g)+(d-x)*(d-x)+(f-h)*(f-h));return Math.abs(v)<.001&&(v=1),this.x=(m-g)/v,this.y=(d-x)/v,this.z=(f-h)/v,this.w=Math.acos((l+p+u-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}},cn=class extends yn{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new $t(0,0,t,e),this.scissorTest=!1,this.viewport=new $t(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(Bi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Nn?Et:Fn),this.texture=new me(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Le,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new ws(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ts=class extends me{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=de,this.minFilter=de,this.wrapR=ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Nr=class extends me{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=de,this.minFilter=de,this.wrapR=ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var vn=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],f=r[a+0],p=r[a+1],g=r[a+2],x=r[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d;return}if(o===1){t[e+0]=f,t[e+1]=p,t[e+2]=g,t[e+3]=x;return}if(d!==x||c!==f||l!==p||h!==g){let m=1-o,u=c*f+l*p+h*g+d*x,v=u>=0?1:-1,_=1-u*u;if(_>Number.EPSILON){let M=Math.sqrt(_),b=Math.atan2(M,u*v);m=Math.sin(m*b)/M,o=Math.sin(o*b)/M}let w=o*v;if(c=c*m+f*w,l=l*m+p*w,h=h*m+g*w,d=d*m+x*w,m===1-o){let M=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=M,l*=M,h*=M,d*=M}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],f=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*d+c*p-l*f,t[e+1]=c*g+h*f+l*d-o*p,t[e+2]=l*g+h*p+o*f-c*d,t[e+3]=h*g-o*d-c*f-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),f=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=f*h*d+l*p*g,this._y=l*p*d-f*h*g,this._z=l*h*g+f*p*d,this._w=l*h*d-f*p*g;break;case"YXZ":this._x=f*h*d+l*p*g,this._y=l*p*d-f*h*g,this._z=l*h*g-f*p*d,this._w=l*h*d+f*p*g;break;case"ZXY":this._x=f*h*d-l*p*g,this._y=l*p*d+f*h*g,this._z=l*h*g+f*p*d,this._w=l*h*d-f*p*g;break;case"ZYX":this._x=f*h*d-l*p*g,this._y=l*p*d+f*h*g,this._z=l*h*g-f*p*d,this._w=l*h*d+f*p*g;break;case"YZX":this._x=f*h*d+l*p*g,this._y=l*p*d+f*h*g,this._z=l*h*g-f*p*d,this._w=l*h*d-f*p*g;break;case"XZY":this._x=f*h*d-l*p*g,this._y=l*p*d-f*h*g,this._z=l*h*g+f*p*d,this._w=l*h*d+f*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],d=e[10],f=n+o+d;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>d){let p=2*Math.sqrt(1+n-o-d);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>d){let p=2*Math.sqrt(1+o-n-d);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(pe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*s+e*this._y,this._z=p*r+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),d=Math.sin((1-e)*h)/l,f=Math.sin(e*h)/l;return this._w=a*d+this._w*f,this._x=n*d+this._x*f,this._y=s*d+this._y*f,this._z=r*d+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),s=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(s),n*Math.sin(r),n*Math.cos(r),e*Math.sin(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},P=class{constructor(t=0,e=0,n=0){P.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(pa.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(pa.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=c*e+a*s-o*n,h=c*n+o*e-r*s,d=c*s+r*n-a*e,f=-r*e-a*n-o*s;return this.x=l*c+f*-r+h*-o-d*-a,this.y=h*c+f*-a+d*-r-l*-o,this.z=d*c+f*-o+l*-a-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ur.copy(this).projectOnVector(t),this.sub(ur)}reflect(t){return this.sub(ur.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(pe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ur=new P,pa=new vn,ge=class{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Qe.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Qe.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Qe.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){if(t.updateWorldMatrix(!1,!1),t.boundingBox!==void 0)t.boundingBox===null&&t.computeBoundingBox(),qn.copy(t.boundingBox),qn.applyMatrix4(t.matrixWorld),this.union(qn);else{let s=t.geometry;if(s!==void 0)if(e&&s.attributes!==void 0&&s.attributes.position!==void 0){let r=s.attributes.position;for(let a=0,o=r.count;a<o;a++)Qe.fromBufferAttribute(r,a).applyMatrix4(t.matrixWorld),this.expandByPoint(Qe)}else s.boundingBox===null&&s.computeBoundingBox(),qn.copy(s.boundingBox),qn.applyMatrix4(t.matrixWorld),this.union(qn)}let n=t.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Qe),Qe.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ui),Qi.subVectors(this.max,Ui),Yn.subVectors(t.a,Ui),Zn.subVectors(t.b,Ui),Jn.subVectors(t.c,Ui),dn.subVectors(Zn,Yn),pn.subVectors(Jn,Zn),An.subVectors(Yn,Jn);let e=[0,-dn.z,dn.y,0,-pn.z,pn.y,0,-An.z,An.y,dn.z,0,-dn.x,pn.z,0,-pn.x,An.z,0,-An.x,-dn.y,dn.x,0,-pn.y,pn.x,0,-An.y,An.x,0];return!fr(e,Yn,Zn,Jn,Qi)||(e=[1,0,0,0,1,0,0,0,1],!fr(e,Yn,Zn,Jn,Qi))?!1:(ts.crossVectors(dn,pn),e=[ts.x,ts.y,ts.z],fr(e,Yn,Zn,Jn,Qi))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Qe).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Qe).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(je),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},je=[new P,new P,new P,new P,new P,new P,new P,new P],Qe=new P,qn=new ge,Yn=new P,Zn=new P,Jn=new P,dn=new P,pn=new P,An=new P,Ui=new P,Qi=new P,ts=new P,Rn=new P;function fr(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Rn.fromArray(i,r);let o=s.x*Math.abs(Rn.x)+s.y*Math.abs(Rn.y)+s.z*Math.abs(Rn.z),c=t.dot(Rn),l=e.dot(Rn),h=n.dot(Rn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Hl=new ge,Di=new P,dr=new P,Bn=class{constructor(t=new P,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):Hl.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Di.subVectors(t,this.center);let e=Di.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Di,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(dr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Di.copy(t.center).add(dr)),this.expandByPoint(Di.copy(t.center).sub(dr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},tn=new P,pr=new P,es=new P,mn=new P,mr=new P,ns=new P,gr=new P,Fr=class{constructor(t=new P,e=new P(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,tn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=tn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(tn.copy(this.origin).addScaledVector(this.direction,e),tn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){pr.copy(t).add(e).multiplyScalar(.5),es.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(pr);let r=t.distanceTo(e)*.5,a=-this.direction.dot(es),o=mn.dot(this.direction),c=-mn.dot(es),l=mn.lengthSq(),h=Math.abs(1-a*a),d,f,p,g;if(h>0)if(d=a*c-o,f=a*o-c,g=r*h,d>=0)if(f>=-g)if(f<=g){let x=1/h;d*=x,f*=x,p=d*(d+a*f+2*o)+f*(a*d+f+2*c)+l}else f=r,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*c)+l;else f=-r,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*c)+l;else f<=-g?(d=Math.max(0,-(-a*r+o)),f=d>0?-r:Math.min(Math.max(-r,-c),r),p=-d*d+f*(f+2*c)+l):f<=g?(d=0,f=Math.min(Math.max(-r,-c),r),p=f*(f+2*c)+l):(d=Math.max(0,-(a*r+o)),f=d>0?r:Math.min(Math.max(-r,-c),r),p=-d*d+f*(f+2*c)+l);else f=a>0?-r:r,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(pr).addScaledVector(es,f),p}intersectSphere(t,e){tn.subVectors(t.center,this.origin);let n=tn.dot(this.direction),s=tn.dot(tn)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,s=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,s=(t.min.x-f.x)*l),h>=0?(r=(t.min.y-f.y)*h,a=(t.max.y-f.y)*h):(r=(t.max.y-f.y)*h,a=(t.min.y-f.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(t.min.z-f.z)*d,c=(t.max.z-f.z)*d):(o=(t.max.z-f.z)*d,c=(t.min.z-f.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,tn)!==null}intersectTriangle(t,e,n,s,r){mr.subVectors(e,t),ns.subVectors(n,t),gr.crossVectors(mr,ns);let a=this.direction.dot(gr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;mn.subVectors(this.origin,t);let c=o*this.direction.dot(ns.crossVectors(mn,ns));if(c<0)return null;let l=o*this.direction.dot(mr.cross(mn));if(l<0||c+l>a)return null;let h=-o*mn.dot(gr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gt=class{constructor(){Gt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,n,s,r,a,o,c,l,h,d,f,p,g,x,m){let u=this.elements;return u[0]=t,u[4]=e,u[8]=n,u[12]=s,u[1]=r,u[5]=a,u[9]=o,u[13]=c,u[2]=l,u[6]=h,u[10]=d,u[14]=f,u[3]=p,u[7]=g,u[11]=x,u[15]=m,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 Gt().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,s=1/$n.setFromMatrixColumn(t,0).length(),r=1/$n.setFromMatrixColumn(t,1).length(),a=1/$n.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let f=a*h,p=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=p+g*l,e[5]=f-x*l,e[9]=-o*c,e[2]=x-f*l,e[6]=g+p*l,e[10]=a*c}else if(t.order==="YXZ"){let f=c*h,p=c*d,g=l*h,x=l*d;e[0]=f+x*o,e[4]=g*o-p,e[8]=a*l,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=x+f*o,e[10]=a*c}else if(t.order==="ZXY"){let f=c*h,p=c*d,g=l*h,x=l*d;e[0]=f-x*o,e[4]=-a*d,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=x-f*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let f=a*h,p=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=g*l-p,e[8]=f*l+x,e[1]=c*d,e[5]=x*l+f,e[9]=p*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let f=a*c,p=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-f*d,e[8]=g*d+p,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=p*d+g,e[10]=f-x*d}else if(t.order==="XZY"){let f=a*c,p=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=f*d+x,e[5]=a*h,e[9]=p*d-g,e[2]=g*d-p,e[6]=o*h,e[10]=x*d+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Gl,t,Wl)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),gn.crossVectors(n,we),gn.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),gn.crossVectors(n,we)),gn.normalize(),is.crossVectors(we,gn),s[0]=gn.x,s[4]=is.x,s[8]=we.x,s[1]=gn.y,s[5]=is.y,s[9]=we.y,s[2]=gn.z,s[6]=is.z,s[10]=we.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],f=n[9],p=n[13],g=n[2],x=n[6],m=n[10],u=n[14],v=n[3],_=n[7],w=n[11],M=n[15],b=s[0],R=s[4],I=s[8],y=s[12],T=s[1],O=s[5],z=s[9],U=s[13],N=s[2],B=s[6],$=s[10],W=s[14],X=s[3],Z=s[7],Q=s[11],ut=s[15];return r[0]=a*b+o*T+c*N+l*X,r[4]=a*R+o*O+c*B+l*Z,r[8]=a*I+o*z+c*$+l*Q,r[12]=a*y+o*U+c*W+l*ut,r[1]=h*b+d*T+f*N+p*X,r[5]=h*R+d*O+f*B+p*Z,r[9]=h*I+d*z+f*$+p*Q,r[13]=h*y+d*U+f*W+p*ut,r[2]=g*b+x*T+m*N+u*X,r[6]=g*R+x*O+m*B+u*Z,r[10]=g*I+x*z+m*$+u*Q,r[14]=g*y+x*U+m*W+u*ut,r[3]=v*b+_*T+w*N+M*X,r[7]=v*R+_*O+w*B+M*Z,r[11]=v*I+_*z+w*$+M*Q,r[15]=v*y+_*U+w*W+M*ut,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],d=t[6],f=t[10],p=t[14],g=t[3],x=t[7],m=t[11],u=t[15];return g*(+r*c*d-s*l*d-r*o*f+n*l*f+s*o*p-n*c*p)+x*(+e*c*p-e*l*f+r*a*f-s*a*p+s*l*h-r*c*h)+m*(+e*l*d-e*o*p-r*a*d+n*a*p+r*o*h-n*l*h)+u*(-s*o*h-e*c*d+e*o*f+s*a*d-n*a*f+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=t[9],f=t[10],p=t[11],g=t[12],x=t[13],m=t[14],u=t[15],v=d*m*l-x*f*l+x*c*p-o*m*p-d*c*u+o*f*u,_=g*f*l-h*m*l-g*c*p+a*m*p+h*c*u-a*f*u,w=h*x*l-g*d*l+g*o*p-a*x*p-h*o*u+a*d*u,M=g*d*c-h*x*c-g*o*f+a*x*f+h*o*m-a*d*m,b=e*v+n*_+s*w+r*M;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/b;return t[0]=v*R,t[1]=(x*f*r-d*m*r-x*s*p+n*m*p+d*s*u-n*f*u)*R,t[2]=(o*m*r-x*c*r+x*s*l-n*m*l-o*s*u+n*c*u)*R,t[3]=(d*c*r-o*f*r-d*s*l+n*f*l+o*s*p-n*c*p)*R,t[4]=_*R,t[5]=(h*m*r-g*f*r+g*s*p-e*m*p-h*s*u+e*f*u)*R,t[6]=(g*c*r-a*m*r-g*s*l+e*m*l+a*s*u-e*c*u)*R,t[7]=(a*f*r-h*c*r+h*s*l-e*f*l-a*s*p+e*c*p)*R,t[8]=w*R,t[9]=(g*d*r-h*x*r-g*n*p+e*x*p+h*n*u-e*d*u)*R,t[10]=(a*x*r-g*o*r+g*n*l-e*x*l-a*n*u+e*o*u)*R,t[11]=(h*o*r-a*d*r-h*n*l+e*d*l+a*n*p-e*o*p)*R,t[12]=M*R,t[13]=(h*x*s-g*d*s+g*n*f-e*x*f-h*n*m+e*d*m)*R,t[14]=(g*o*s-a*x*s-g*n*c+e*x*c+a*n*m-e*o*m)*R,t[15]=(a*d*s-h*o*s+h*n*c-e*d*c-a*n*f+e*o*f)*R,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,d=o+o,f=r*l,p=r*h,g=r*d,x=a*h,m=a*d,u=o*d,v=c*l,_=c*h,w=c*d,M=n.x,b=n.y,R=n.z;return s[0]=(1-(x+u))*M,s[1]=(p+w)*M,s[2]=(g-_)*M,s[3]=0,s[4]=(p-w)*b,s[5]=(1-(f+u))*b,s[6]=(m+v)*b,s[7]=0,s[8]=(g+_)*R,s[9]=(m-v)*R,s[10]=(1-(f+x))*R,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=$n.set(s[0],s[1],s[2]).length(),a=$n.set(s[4],s[5],s[6]).length(),o=$n.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Fe.copy(this);let l=1/r,h=1/a,d=1/o;return Fe.elements[0]*=l,Fe.elements[1]*=l,Fe.elements[2]*=l,Fe.elements[4]*=h,Fe.elements[5]*=h,Fe.elements[6]*=h,Fe.elements[8]*=d,Fe.elements[9]*=d,Fe.elements[10]*=d,e.setFromRotationMatrix(Fe),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a){let o=this.elements,c=2*r/(e-t),l=2*r/(n-s),h=(e+t)/(e-t),d=(n+s)/(n-s),f=-(a+r)/(a-r),p=-2*a*r/(a-r);return o[0]=c,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=l,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,s,r,a){let o=this.elements,c=1/(e-t),l=1/(n-s),h=1/(a-r),d=(e+t)*c,f=(n+s)*l,p=(a+r)*h;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*h,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},$n=new P,Fe=new Gt,Gl=new P(0,0,0),Wl=new P(1,1,1),gn=new P,is=new P,we=new P,ma=new Gt,ga=new vn,_i=class{constructor(t=0,e=0,n=0,s=_i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],f=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(pe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-pe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(pe(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-pe(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(pe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-pe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return ma.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ma,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ga.setFromEuler(this),this.setFromQuaternion(ga,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};_i.DEFAULT_ORDER="XYZ";var As=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},Xl=0,_a=new P,Kn=new vn,en=new Gt,ss=new P,Ni=new P,ql=new P,Yl=new vn,xa=new P(1,0,0),ya=new P(0,1,0),va=new P(0,0,1),Zl={type:"added"},Ma={type:"removed"},xe=class extends yn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Xl++}),this.uuid=Wi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xe.DEFAULT_UP.clone();let t=new P,e=new _i,n=new vn,s=new P(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Gt},normalMatrix:{value:new Ct}}),this.matrix=new Gt,this.matrixWorld=new Gt,this.matrixAutoUpdate=xe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=xe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new As,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(t,e){return Kn.setFromAxisAngle(t,e),this.quaternion.premultiply(Kn),this}rotateX(t){return this.rotateOnAxis(xa,t)}rotateY(t){return this.rotateOnAxis(ya,t)}rotateZ(t){return this.rotateOnAxis(va,t)}translateOnAxis(t,e){return _a.copy(t).applyQuaternion(this.quaternion),this.position.add(_a.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(xa,t)}translateY(t){return this.translateOnAxis(ya,t)}translateZ(t){return this.translateOnAxis(va,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(en.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ss.copy(t):ss.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ni.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?en.lookAt(Ni,ss,this.up):en.lookAt(ss,Ni,this.up),this.quaternion.setFromRotationMatrix(en),s&&(en.extractRotation(s.matrixWorld),Kn.setFromRotationMatrix(en),this.quaternion.premultiply(Kn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can\'t be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Zl)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ma)),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){let e=this.children[t];e.parent=null,e.dispatchEvent(Ma)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),en.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),en.multiply(t.parent.matrixWorld)),t.applyMatrix4(en),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e){let n=[];this[t]===e&&n.push(this);for(let s=0,r=this.children.length;s<r;s++){let a=this.children[s].getObjectsByProperty(t,e);a.length>0&&(n=n.concat(a))}return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,t,ql),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,Yl,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++){let r=e[n];(r.matrixWorldAutoUpdate===!0||t===!0)&&r.updateMatrixWorld(t)}}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++){let o=s[r];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let d=c[l];r(t.shapes,d)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){let o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),d=a(t.shapes),f=a(t.skeletons),p=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}};xe.DEFAULT_UP=new P(0,1,0);xe.DEFAULT_MATRIX_AUTO_UPDATE=!0;xe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Oe=new P,nn=new P,_r=new P,sn=new P,jn=new P,Qn=new P,Sa=new P,xr=new P,yr=new P,vr=new P,rs=!1,se=class{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Oe.subVectors(t,e),s.cross(Oe);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){Oe.subVectors(s,e),nn.subVectors(n,e),_r.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot(nn),c=Oe.dot(_r),l=nn.dot(nn),h=nn.dot(_r),d=a*l-o*o;if(d===0)return r.set(-2,-1,-1);let f=1/d,p=(l*c-o*h)*f,g=(a*h-o*c)*f;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,sn),sn.x>=0&&sn.y>=0&&sn.x+sn.y<=1}static getUV(t,e,n,s,r,a,o,c){return rs===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),rs=!0),this.getInterpolation(t,e,n,s,r,a,o,c)}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,sn),c.setScalar(0),c.addScaledVector(r,sn.x),c.addScaledVector(a,sn.y),c.addScaledVector(o,sn.z),c}static isFrontFacing(t,e,n,s){return Oe.subVectors(n,e),nn.subVectors(t,e),Oe.cross(nn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Oe.subVectors(this.c,this.b),nn.subVectors(this.a,this.b),Oe.cross(nn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return se.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return se.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,s,r){return rs===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),rs=!0),se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}getInterpolation(t,e,n,s,r){return se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return se.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return se.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;jn.subVectors(s,n),Qn.subVectors(r,n),xr.subVectors(t,n);let c=jn.dot(xr),l=Qn.dot(xr);if(c<=0&&l<=0)return e.copy(n);yr.subVectors(t,s);let h=jn.dot(yr),d=Qn.dot(yr);if(h>=0&&d<=h)return e.copy(s);let f=c*d-h*l;if(f<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(jn,a);vr.subVectors(t,r);let p=jn.dot(vr),g=Qn.dot(vr);if(g>=0&&p<=g)return e.copy(r);let x=p*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(Qn,o);let m=h*g-p*d;if(m<=0&&d-h>=0&&p-g>=0)return Sa.subVectors(r,s),o=(d-h)/(d-h+(p-g)),e.copy(s).addScaledVector(Sa,o);let u=1/(m+x+f);return a=x*u,o=f*u,e.copy(n).addScaledVector(jn,a).addScaledVector(Qn,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Jl=0,xi=class extends yn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jl++}),this.uuid=Wi(),this.name="",this.type="Material",this.blending=hi,this.side=He,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Ka,this.blendDst=ja,this.blendEquation=ai,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Rr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Il,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rr,this.stencilZFail=rr,this.stencilZPass=rr,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter \'${e}\' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: \'${e}\' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.5,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&&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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==hi&&(n.blending=this.blending),this.side!==He&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==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.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),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=this.flatShading),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 s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},rc={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},Be={h:0,s:0,l:0},os={h:0,s:0,l:0};function Mr(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var Ht=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,e===void 0&&n===void 0?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Et){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Ne.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=Ne.workingColorSpace){return this.r=t,this.g=e,this.b=n,Ne.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=Ne.workingColorSpace){if(t=Ul(t,1),e=pe(e,0,1),n=pe(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Mr(a,r,t+1/3),this.g=Mr(a,r,t),this.b=Mr(a,r,t-1/3)}return Ne.toWorkingColorSpace(this,s),this}setStyle(t,e=Et){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\\w+)\\(([^\\)]*)\\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\\#([A-Fa-f\\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Et){let n=rc[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=fi(t.r),this.g=fi(t.g),this.b=fi(t.b),this}copyLinearToSRGB(t){return this.r=lr(t.r),this.g=lr(t.g),this.b=lr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Et){return Ne.fromWorkingColorSpace(ce.copy(this),t),Math.round(pe(ce.r*255,0,255))*65536+Math.round(pe(ce.g*255,0,255))*256+Math.round(pe(ce.b*255,0,255))}getHexString(t=Et){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ne.workingColorSpace){Ne.fromWorkingColorSpace(ce.copy(this),e);let n=ce.r,s=ce.g,r=ce.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Ne.workingColorSpace){return Ne.fromWorkingColorSpace(ce.copy(this),e),t.r=ce.r,t.g=ce.g,t.b=ce.b,t}getStyle(t=Et){Ne.fromWorkingColorSpace(ce.copy(this),t);let e=ce.r,n=ce.g,s=ce.b;return t!==Et?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(Be),Be.h+=t,Be.s+=e,Be.l+=n,this.setHSL(Be.h,Be.s,Be.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Be),t.getHSL(os);let n=ar(Be.h,os.h,e),s=ar(Be.s,os.s,e),r=ar(Be.l,os.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},ce=new Ht;Ht.NAMES=rc;var Rs=class extends xi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ht(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.combine=Qa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};var Zt=new P,as=new Dt,Kt=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=ha,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)as.fromBufferAttribute(this,e),as.applyMatrix3(t),this.setXY(e,as.x,as.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix3(t),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Zt.fromBufferAttribute(this,e),Zt.applyMatrix4(t),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Zt.fromBufferAttribute(this,e),Zt.applyNormalMatrix(t),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Zt.fromBufferAttribute(this,e),Zt.transformDirection(t),this.setXYZ(e,Zt.x,Zt.y,Zt.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ji(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ji(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ji(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ji(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array),s=Ee(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array),s=Ee(s,this.array),r=Ee(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==ha&&(t.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(t.updateRange=this.updateRange),t}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}};var Cs=class extends Kt{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var Ps=class extends Kt{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var an=class extends Kt{constructor(t,e,n){super(new Float32Array(t),e,n)}};var $l=0,Pe=new Gt,Sr=new xe,ti=new P,Te=new ge,Fi=new ge,ie=new P,Ge=class extends yn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$l++}),this.uuid=Wi(),this.name="",this.type="BufferGeometry",this.index=null,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(t){return Array.isArray(t)?this.index=new(sc(t)?Ps:Cs)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ct().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Pe.makeRotationFromQuaternion(t),this.applyMatrix4(Pe),this}rotateX(t){return Pe.makeRotationX(t),this.applyMatrix4(Pe),this}rotateY(t){return Pe.makeRotationY(t),this.applyMatrix4(Pe),this}rotateZ(t){return Pe.makeRotationZ(t),this.applyMatrix4(Pe),this}translate(t,e,n){return Pe.makeTranslation(t,e,n),this.applyMatrix4(Pe),this}scale(t,e,n){return Pe.makeScale(t,e,n),this.applyMatrix4(Pe),this}lookAt(t){return Sr.lookAt(t),Sr.updateMatrix(),this.applyMatrix4(Sr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ti).negate(),this.translate(ti.x,ti.y,ti.z),this}setFromPoints(t){let e=[];for(let n=0,s=t.length;n<s;n++){let r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new an(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ge);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error(\'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".\',this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];Te.setFromBufferAttribute(r),this.morphTargetsRelative?(ie.addVectors(this.boundingBox.min,Te.min),this.boundingBox.expandByPoint(ie),ie.addVectors(this.boundingBox.max,Te.max),this.boundingBox.expandByPoint(ie)):(this.boundingBox.expandByPoint(Te.min),this.boundingBox.expandByPoint(Te.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(\'THREE.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 Bn);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error(\'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".\',this),this.boundingSphere.set(new P,1/0);return}if(t){let n=this.boundingSphere.center;if(Te.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];Fi.setFromBufferAttribute(o),this.morphTargetsRelative?(ie.addVectors(Te.min,Fi.min),Te.expandByPoint(ie),ie.addVectors(Te.max,Fi.max),Te.expandByPoint(ie)):(Te.expandByPoint(Fi.min),Te.expandByPoint(Fi.max))}Te.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)ie.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(ie));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)ie.fromBufferAttribute(o,l),c&&(ti.fromBufferAttribute(t,l),ie.add(ti)),s=Math.max(s,n.distanceToSquared(ie))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error(\'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.\',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.array,s=e.position.array,r=e.normal.array,a=e.uv.array,o=s.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Kt(new Float32Array(4*o),4));let c=this.getAttribute("tangent").array,l=[],h=[];for(let T=0;T<o;T++)l[T]=new P,h[T]=new P;let d=new P,f=new P,p=new P,g=new Dt,x=new Dt,m=new Dt,u=new P,v=new P;function _(T,O,z){d.fromArray(s,T*3),f.fromArray(s,O*3),p.fromArray(s,z*3),g.fromArray(a,T*2),x.fromArray(a,O*2),m.fromArray(a,z*2),f.sub(d),p.sub(d),x.sub(g),m.sub(g);let U=1/(x.x*m.y-m.x*x.y);isFinite(U)&&(u.copy(f).multiplyScalar(m.y).addScaledVector(p,-x.y).multiplyScalar(U),v.copy(p).multiplyScalar(x.x).addScaledVector(f,-m.x).multiplyScalar(U),l[T].add(u),l[O].add(u),l[z].add(u),h[T].add(v),h[O].add(v),h[z].add(v))}let w=this.groups;w.length===0&&(w=[{start:0,count:n.length}]);for(let T=0,O=w.length;T<O;++T){let z=w[T],U=z.start,N=z.count;for(let B=U,$=U+N;B<$;B+=3)_(n[B+0],n[B+1],n[B+2])}let M=new P,b=new P,R=new P,I=new P;function y(T){R.fromArray(r,T*3),I.copy(R);let O=l[T];M.copy(O),M.sub(R.multiplyScalar(R.dot(O))).normalize(),b.crossVectors(I,O);let U=b.dot(h[T])<0?-1:1;c[T*4]=M.x,c[T*4+1]=M.y,c[T*4+2]=M.z,c[T*4+3]=U}for(let T=0,O=w.length;T<O;++T){let z=w[T],U=z.start,N=z.count;for(let B=U,$=U+N;B<$;B+=3)y(n[B+0]),y(n[B+1]),y(n[B+2])}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Kt(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let s=new P,r=new P,a=new P,o=new P,c=new P,l=new P,h=new P,d=new P;if(t)for(let f=0,p=t.count;f<p;f+=3){let g=t.getX(f+0),x=t.getX(f+1),m=t.getX(f+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,p=e.count;f<p;f+=3)s.fromBufferAttribute(e,f+0),r.fromBufferAttribute(e,f+1),a.fromBufferAttribute(e,f+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ie.fromBufferAttribute(t,e),ie.normalize(),t.setXYZ(e,ie.x,ie.y,ie.z)}toNonIndexed(){function t(o,c){let l=o.array,h=o.itemSize,d=o.normalized,f=new l.constructor(c.length*h),p=0,g=0;for(let x=0,m=c.length;x<m;x++){o.isInterleavedBufferAttribute?p=c[x]*o.data.stride+o.offset:p=c[x]*h;for(let u=0;u<h;u++)f[g++]=l[p++]}return new Kt(f,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new Ge,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=t(c,n);e.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){let f=l[h],p=t(f,n);c.push(p)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,f=l.length;d<f;d++){let p=l[d];h.push(p.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],d=r[l];for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let l=0,h=a.length;l<h;l++){let d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},ba=new Gt,qe=new Fr,cs=new Bn,Ea=new P,ei=new P,ni=new P,ii=new P,br=new P,ls=new P,hs=new Dt,us=new Dt,fs=new Dt,wa=new P,Ta=new P,Aa=new P,ds=new P,ps=new P,Ze=class extends xe{constructor(t=new Ge,e=new Rs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let o=this.morphTargetInfluences;if(r&&o){ls.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],d=r[c];h!==0&&(br.fromBufferAttribute(d,t),a?ls.addScaledVector(br,h):ls.addScaledVector(br.sub(e),h))}e.add(ls)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),cs.copy(n.boundingSphere),cs.applyMatrix4(r),qe.copy(t.ray).recast(t.near),!(cs.containsPoint(qe.origin)===!1&&(qe.intersectSphere(cs,Ea)===null||qe.origin.distanceToSquared(Ea)>(t.far-t.near)**2))&&(ba.copy(r).invert(),qe.copy(t.ray).applyMatrix4(ba),!(n.boundingBox!==null&&qe.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e)))}_computeIntersections(t,e){let n,s=this.geometry,r=this.material,a=s.index,o=s.attributes.position,c=s.attributes.uv,l=s.attributes.uv1,h=s.attributes.normal,d=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(r))for(let p=0,g=d.length;p<g;p++){let x=d[p],m=r[x.materialIndex],u=Math.max(x.start,f.start),v=Math.min(a.count,Math.min(x.start+x.count,f.start+f.count));for(let _=u,w=v;_<w;_+=3){let M=a.getX(_),b=a.getX(_+1),R=a.getX(_+2);n=ms(this,m,t,qe,c,l,h,M,b,R),n&&(n.faceIndex=Math.floor(_/3),n.face.materialIndex=x.materialIndex,e.push(n))}}else{let p=Math.max(0,f.start),g=Math.min(a.count,f.start+f.count);for(let x=p,m=g;x<m;x+=3){let u=a.getX(x),v=a.getX(x+1),_=a.getX(x+2);n=ms(this,r,t,qe,c,l,h,u,v,_),n&&(n.faceIndex=Math.floor(x/3),e.push(n))}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,g=d.length;p<g;p++){let x=d[p],m=r[x.materialIndex],u=Math.max(x.start,f.start),v=Math.min(o.count,Math.min(x.start+x.count,f.start+f.count));for(let _=u,w=v;_<w;_+=3){let M=_,b=_+1,R=_+2;n=ms(this,m,t,qe,c,l,h,M,b,R),n&&(n.faceIndex=Math.floor(_/3),n.face.materialIndex=x.materialIndex,e.push(n))}}else{let p=Math.max(0,f.start),g=Math.min(o.count,f.start+f.count);for(let x=p,m=g;x<m;x+=3){let u=x,v=x+1,_=x+2;n=ms(this,r,t,qe,c,l,h,u,v,_),n&&(n.faceIndex=Math.floor(x/3),e.push(n))}}}};function Kl(i,t,e,n,s,r,a,o){let c;if(t.side===le?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===He,o),c===null)return null;ps.copy(o),ps.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(ps);return l<e.near||l>e.far?null:{distance:l,point:ps.clone(),object:i}}function ms(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,ei),i.getVertexPosition(c,ni),i.getVertexPosition(l,ii);let h=Kl(i,t,e,n,ei,ni,ii,ds);if(h){s&&(hs.fromBufferAttribute(s,o),us.fromBufferAttribute(s,c),fs.fromBufferAttribute(s,l),h.uv=se.getInterpolation(ds,ei,ni,ii,hs,us,fs,new Dt)),r&&(hs.fromBufferAttribute(r,o),us.fromBufferAttribute(r,c),fs.fromBufferAttribute(r,l),h.uv1=se.getInterpolation(ds,ei,ni,ii,hs,us,fs,new Dt),h.uv2=h.uv1),a&&(wa.fromBufferAttribute(a,o),Ta.fromBufferAttribute(a,c),Aa.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ds,ei,ni,ii,wa,Ta,Aa,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new P,materialIndex:0};se.getNormal(ei,ni,ii,d.normal),h.face=d}return h}var zn=class extends Ge{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],f=0,p=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new an(l,3)),this.setAttribute("normal",new an(h,3)),this.setAttribute("uv",new an(d,2));function g(x,m,u,v,_,w,M,b,R,I,y){let T=w/R,O=M/I,z=w/2,U=M/2,N=b/2,B=R+1,$=I+1,W=0,X=0,Z=new P;for(let Q=0;Q<$;Q++){let ut=Q*O-U;for(let at=0;at<B;at++){let V=at*T-z;Z[x]=V*v,Z[m]=ut*_,Z[u]=N,l.push(Z.x,Z.y,Z.z),Z[x]=0,Z[m]=0,Z[u]=b>0?1:-1,h.push(Z.x,Z.y,Z.z),d.push(at/R),d.push(1-Q/I),W+=1}}for(let Q=0;Q<I;Q++)for(let ut=0;ut<R;ut++){let at=f+ut+B*Q,V=f+ut+B*(Q+1),J=f+(ut+1)+B*(Q+1),it=f+(ut+1)+B*Q;c.push(at,V,it),c.push(V,J,it),X+=6}o.addGroup(p,X,y),p+=X,f+=W}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function yi(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function fe(i){let t={};for(let e=0;e<i.length;e++){let n=yi(i[e]);for(let s in n)t[s]=n[s]}return t}function jl(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function oc(i){return i.getRenderTarget()===null?i.outputColorSpace:Je}var Ql={clone:yi,merge:fe},th=`void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}`,eh=`void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}`,ln=class extends xi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=th,this.fragmentShader=eh,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=yi(t.uniforms),this.uniformsGroups=jl(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Ls=class extends xe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Ae=class extends Ls{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Dr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(or*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(or*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(or*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},si=-90,ri=1,Or=class extends xe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n;let s=new Ae(si,ri,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(1,0,0),this.add(s);let r=new Ae(si,ri,t,e);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(-1,0,0),this.add(r);let a=new Ae(si,ri,t,e);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);let o=new Ae(si,ri,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(0,-1,0),this.add(o);let c=new Ae(si,ri,t,e);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,1),this.add(c);let l=new Ae(si,ri,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(t,e){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget,[s,r,a,o,c,l]=this.children,h=t.getRenderTarget(),d=t.toneMapping,f=t.xr.enabled;t.toneMapping=on,t.xr.enabled=!1;let p=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,s),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,c),n.texture.generateMipmaps=p,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.toneMapping=d,t.xr.enabled=f,n.texture.needsPMREMUpdate=!0}},Is=class extends me{constructor(t,e,n,s,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:pi,super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},Br=class extends cn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];e.encoding!==void 0&&(Bi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Nn?Et:Fn),this.texture=new Is(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Le}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t`,fragmentShader:`\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t`},s=new zn(5,5,5),r=new ln({name:"CubemapFromEquirect",uniforms:yi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:le,blending:xn});r.uniforms.tEquirect.value=e;let a=new Ze(s,r),o=e.minFilter;return e.minFilter===ki&&(e.minFilter=Le),new Or(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,s){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},Er=new P,nh=new P,ih=new Ct,Re=class{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=Er.subVectors(n,e).cross(nh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Er),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||ih.getNormalMatrix(t),s=this.coplanarPoint(Er).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Cn=new Bn,gs=new P,Us=class{constructor(t=new Re,e=new Re,n=new Re,s=new Re,r=new Re,a=new Re){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){let e=this.planes,n=t.elements,s=n[0],r=n[1],a=n[2],o=n[3],c=n[4],l=n[5],h=n[6],d=n[7],f=n[8],p=n[9],g=n[10],x=n[11],m=n[12],u=n[13],v=n[14],_=n[15];return e[0].setComponents(o-s,d-c,x-f,_-m).normalize(),e[1].setComponents(o+s,d+c,x+f,_+m).normalize(),e[2].setComponents(o+r,d+l,x+p,_+u).normalize(),e[3].setComponents(o-r,d-l,x-p,_-u).normalize(),e[4].setComponents(o-a,d-h,x-g,_-v).normalize(),e[5].setComponents(o+a,d+h,x+g,_+v).normalize(),this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Cn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Cn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Cn)}intersectsSprite(t){return Cn.center.set(0,0,0),Cn.radius=.7071067811865476,Cn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Cn)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(gs.x=s.normal.x>0?t.max.x:t.min.x,gs.y=s.normal.y>0?t.max.y:t.min.y,gs.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(gs)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function ac(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function sh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,f=l.usage,p=i.createBuffer();i.bindBuffer(h,p),i.bufferData(h,d,f),l.onUploadCallback();let g;if(d instanceof Float32Array)g=i.FLOAT;else if(d instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(e)g=i.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=i.UNSIGNED_SHORT;else if(d instanceof Int16Array)g=i.SHORT;else if(d instanceof Uint32Array)g=i.UNSIGNED_INT;else if(d instanceof Int32Array)g=i.INT;else if(d instanceof Int8Array)g=i.BYTE;else if(d instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:p,type:g,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,d){let f=h.array,p=h.updateRange;i.bindBuffer(d,l),p.count===-1?i.bufferSubData(d,0,f):(e?i.bufferSubData(d,p.offset*f.BYTES_PER_ELEMENT,f,p.offset,p.count):i.bufferSubData(d,p.offset*f.BYTES_PER_ELEMENT,f.subarray(p.offset,p.offset+p.count)),p.count=-1),h.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);let h=n.get(l);h&&(i.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){let f=n.get(l);(!f||f.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);let d=n.get(l);d===void 0?n.set(l,s(l,h)):d.version<l.version&&(r(d.buffer,l,h),d.version=l.version)}return{get:a,remove:o,update:c}}var Hi=class extends Ge{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,d=t/o,f=e/c,p=[],g=[],x=[],m=[];for(let u=0;u<h;u++){let v=u*f-a;for(let _=0;_<l;_++){let w=_*d-r;g.push(w,-v,0),x.push(0,0,1),m.push(_/o),m.push(1-u/c)}}for(let u=0;u<c;u++)for(let v=0;v<o;v++){let _=v+l*u,w=v+l*(u+1),M=v+1+l*(u+1),b=v+1+l*u;p.push(_,w,b),p.push(w,M,b)}this.setIndex(p),this.setAttribute("position",new an(g,3)),this.setAttribute("normal",new an(x,3)),this.setAttribute("uv",new an(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hi(t.width,t.height,t.widthSegments,t.heightSegments)}},rh=`#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif`,oh=`#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,ah=`#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif`,ch=`#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif`,lh=`#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif`,hh=`#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif`,uh="vec3 transformed = vec3( position );",fh=`vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif`,dh=`float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated`,ph=`#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif`,mh=`#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif`,gh=`#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif`,_h=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,xh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,yh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,vh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,Mh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Sh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,bh=`#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif`,Eh=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,wh=`#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif`,Th=`vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif`,Ah=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Rh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,Ch=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,Ph=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Lh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ih=`vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}`,Uh=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif`,Dh=`#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif`,Nh=`#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif`,Fh=`#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif`,Oh=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif`,Bh=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,zh=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,kh=`#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,Vh=`#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif`,Hh=`#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}`,Gh=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,Wh=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,Xh=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,qh=`varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert`,Yh=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif`,Zh=`#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif`,Jh=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,$h=`varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon`,Kh=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,jh=`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong`,Qh=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif`,tu=`struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,eu=`\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,nu=`#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,iu=`#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif`,su=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,ru=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,ou=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,au=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,cu=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,lu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,hu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,uu=`#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,fu=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,du=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,pu=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif`,mu=`#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif`,gu=`#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif`,_u=`#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif`,xu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_NORMALMAP_TANGENTSPACE\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;`,yu=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,vu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Mu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Su=`#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif`,bu=`#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif`,Eu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,wu=`#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,Tu=`#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif`,Au=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Ru=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cu=`vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}`,Pu=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Lu=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,Iu=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,Uu=`#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif`,Du=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,Nu=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,Fu=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif`,Ou=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif`,Bu=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif`,zu=`float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}`,ku=`#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,Vu=`#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif`,Hu=`#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,Gu=`#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif`,Wu=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,Xu=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,qu=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,Yu=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,Zu=`#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif`,Ju=`#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif`,$u=`#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,Ku=`#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,ju=`#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,Qu=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif`,tf=`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,ef=`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,nf=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,sf=`#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,rf=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,of=`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,af=`#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}`,cf=`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}`,lf=`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}`,hf=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,uf=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}`,ff=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,df=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,pf=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,mf=`#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}`,gf=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,_f=`#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,xf=`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,yf=`#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}`,vf=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Mf=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}`,Sf=`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}`,bf=`#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,Ef=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,wf=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}`,Tf=`#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Af=`#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,Rf=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Cf=`uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}`,Pf=`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,Lf=`#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,If=`uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}`,Uf=`uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,Df=`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}`,Tt={alphamap_fragment:rh,alphamap_pars_fragment:oh,alphatest_fragment:ah,alphatest_pars_fragment:ch,aomap_fragment:lh,aomap_pars_fragment:hh,begin_vertex:uh,beginnormal_vertex:fh,bsdfs:dh,iridescence_fragment:ph,bumpmap_pars_fragment:mh,clipping_planes_fragment:gh,clipping_planes_pars_fragment:_h,clipping_planes_pars_vertex:xh,clipping_planes_vertex:yh,color_fragment:vh,color_pars_fragment:Mh,color_pars_vertex:Sh,color_vertex:bh,common:Eh,cube_uv_reflection_fragment:wh,defaultnormal_vertex:Th,displacementmap_pars_vertex:Ah,displacementmap_vertex:Rh,emissivemap_fragment:Ch,emissivemap_pars_fragment:Ph,encodings_fragment:Lh,encodings_pars_fragment:Ih,envmap_fragment:Uh,envmap_common_pars_fragment:Dh,envmap_pars_fragment:Nh,envmap_pars_vertex:Fh,envmap_physical_pars_fragment:Zh,envmap_vertex:Oh,fog_vertex:Bh,fog_pars_vertex:zh,fog_fragment:kh,fog_pars_fragment:Vh,gradientmap_pars_fragment:Hh,lightmap_fragment:Gh,lightmap_pars_fragment:Wh,lights_lambert_fragment:Xh,lights_lambert_pars_fragment:qh,lights_pars_begin:Yh,lights_toon_fragment:Jh,lights_toon_pars_fragment:$h,lights_phong_fragment:Kh,lights_phong_pars_fragment:jh,lights_physical_fragment:Qh,lights_physical_pars_fragment:tu,lights_fragment_begin:eu,lights_fragment_maps:nu,lights_fragment_end:iu,logdepthbuf_fragment:su,logdepthbuf_pars_fragment:ru,logdepthbuf_pars_vertex:ou,logdepthbuf_vertex:au,map_fragment:cu,map_pars_fragment:lu,map_particle_fragment:hu,map_particle_pars_fragment:uu,metalnessmap_fragment:fu,metalnessmap_pars_fragment:du,morphcolor_vertex:pu,morphnormal_vertex:mu,morphtarget_pars_vertex:gu,morphtarget_vertex:_u,normal_fragment_begin:xu,normal_fragment_maps:yu,normal_pars_fragment:vu,normal_pars_vertex:Mu,normal_vertex:Su,normalmap_pars_fragment:bu,clearcoat_normal_fragment_begin:Eu,clearcoat_normal_fragment_maps:wu,clearcoat_pars_fragment:Tu,iridescence_pars_fragment:Au,output_fragment:Ru,packing:Cu,premultiplied_alpha_fragment:Pu,project_vertex:Lu,dithering_fragment:Iu,dithering_pars_fragment:Uu,roughnessmap_fragment:Du,roughnessmap_pars_fragment:Nu,shadowmap_pars_fragment:Fu,shadowmap_pars_vertex:Ou,shadowmap_vertex:Bu,shadowmask_pars_fragment:zu,skinbase_vertex:ku,skinning_pars_vertex:Vu,skinning_vertex:Hu,skinnormal_vertex:Gu,specularmap_fragment:Wu,specularmap_pars_fragment:Xu,tonemapping_fragment:qu,tonemapping_pars_fragment:Yu,transmission_fragment:Zu,transmission_pars_fragment:Ju,uv_pars_fragment:$u,uv_pars_vertex:Ku,uv_vertex:ju,worldpos_vertex:Qu,background_vert:tf,background_frag:ef,backgroundCube_vert:nf,backgroundCube_frag:sf,cube_vert:rf,cube_frag:of,depth_vert:af,depth_frag:cf,distanceRGBA_vert:lf,distanceRGBA_frag:hf,equirect_vert:uf,equirect_frag:ff,linedashed_vert:df,linedashed_frag:pf,meshbasic_vert:mf,meshbasic_frag:gf,meshlambert_vert:_f,meshlambert_frag:xf,meshmatcap_vert:yf,meshmatcap_frag:vf,meshnormal_vert:Mf,meshnormal_frag:Sf,meshphong_vert:bf,meshphong_frag:Ef,meshphysical_vert:wf,meshphysical_frag:Tf,meshtoon_vert:Af,meshtoon_frag:Rf,points_vert:Cf,points_frag:Pf,shadow_vert:Lf,shadow_frag:If,sprite_vert:Uf,sprite_frag:Df},et={common:{diffuse:{value:new Ht(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ht(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ht(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new Ht(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaTest:{value:0}}},Ye={basic:{uniforms:fe([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:Tt.meshbasic_vert,fragmentShader:Tt.meshbasic_frag},lambert:{uniforms:fe([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new Ht(0)}}]),vertexShader:Tt.meshlambert_vert,fragmentShader:Tt.meshlambert_frag},phong:{uniforms:fe([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new Ht(0)},specular:{value:new Ht(1118481)},shininess:{value:30}}]),vertexShader:Tt.meshphong_vert,fragmentShader:Tt.meshphong_frag},standard:{uniforms:fe([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new Ht(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag},toon:{uniforms:fe([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new Ht(0)}}]),vertexShader:Tt.meshtoon_vert,fragmentShader:Tt.meshtoon_frag},matcap:{uniforms:fe([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:Tt.meshmatcap_vert,fragmentShader:Tt.meshmatcap_frag},points:{uniforms:fe([et.points,et.fog]),vertexShader:Tt.points_vert,fragmentShader:Tt.points_frag},dashed:{uniforms:fe([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tt.linedashed_vert,fragmentShader:Tt.linedashed_frag},depth:{uniforms:fe([et.common,et.displacementmap]),vertexShader:Tt.depth_vert,fragmentShader:Tt.depth_frag},normal:{uniforms:fe([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:Tt.meshnormal_vert,fragmentShader:Tt.meshnormal_frag},sprite:{uniforms:fe([et.sprite,et.fog]),vertexShader:Tt.sprite_vert,fragmentShader:Tt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Tt.background_vert,fragmentShader:Tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Tt.backgroundCube_vert,fragmentShader:Tt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Tt.cube_vert,fragmentShader:Tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tt.equirect_vert,fragmentShader:Tt.equirect_frag},distanceRGBA:{uniforms:fe([et.common,et.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tt.distanceRGBA_vert,fragmentShader:Tt.distanceRGBA_frag},shadow:{uniforms:fe([et.lights,et.fog,{color:{value:new Ht(0)},opacity:{value:1}}]),vertexShader:Tt.shadow_vert,fragmentShader:Tt.shadow_frag}};Ye.physical={uniforms:fe([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new Ht(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new Ht(0)},specularColor:{value:new Ht(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag};var _s={r:0,b:0,g:0};function Nf(i,t,e,n,s,r,a){let o=new Ht(0),c=r===!0?0:1,l,h,d=null,f=0,p=null;function g(m,u){let v=!1,_=u.isScene===!0?u.background:null;switch(_&&_.isTexture&&(_=(u.backgroundBlurriness>0?e:t).get(_)),_===null?x(o,c):_&&_.isColor&&(x(_,1),v=!0),i.xr.getEnvironmentBlendMode()){case"opaque":v=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),v=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),v=!0;break}(i.autoClear||v)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),_&&(_.isCubeTexture||_.mapping===Ns)?(h===void 0&&(h=new Ze(new zn(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:yi(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.backgroundCube.fragmentShader,side:le,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(b,R,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=u.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=u.backgroundIntensity,h.material.toneMapped=_.colorSpace!==Et,(d!==_||f!==_.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,d=_,f=_.version,p=i.toneMapping),h.layers.enableAll(),m.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ze(new Hi(2,2),new ln({name:"BackgroundMaterial",uniforms:yi(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:He,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=u.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Et,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||p!==i.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,p=i.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null))}function x(m,u){m.getRGB(_s,oc(i)),n.buffers.color.setClear(_s.r,_s.g,_s.b,u,a)}return{getClearColor:function(){return o},setClearColor:function(m,u=1){o.set(m),c=u,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(m){c=m,x(o,c)},render:g}}function Ff(i,t,e,n){let s=i.getParameter(i.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||r!==null,o={},c=m(null),l=c,h=!1;function d(N,B,$,W,X){let Z=!1;if(a){let Q=x(W,$,B);l!==Q&&(l=Q,p(l.object)),Z=u(N,W,$,X),Z&&v(N,W,$,X)}else{let Q=B.wireframe===!0;(l.geometry!==W.id||l.program!==$.id||l.wireframe!==Q)&&(l.geometry=W.id,l.program=$.id,l.wireframe=Q,Z=!0)}X!==null&&e.update(X,i.ELEMENT_ARRAY_BUFFER),(Z||h)&&(h=!1,I(N,B,$,W),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(X).buffer))}function f(){return n.isWebGL2?i.createVertexArray():r.createVertexArrayOES()}function p(N){return n.isWebGL2?i.bindVertexArray(N):r.bindVertexArrayOES(N)}function g(N){return n.isWebGL2?i.deleteVertexArray(N):r.deleteVertexArrayOES(N)}function x(N,B,$){let W=$.wireframe===!0,X=o[N.id];X===void 0&&(X={},o[N.id]=X);let Z=X[B.id];Z===void 0&&(Z={},X[B.id]=Z);let Q=Z[W];return Q===void 0&&(Q=m(f()),Z[W]=Q),Q}function m(N){let B=[],$=[],W=[];for(let X=0;X<s;X++)B[X]=0,$[X]=0,W[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:$,attributeDivisors:W,object:N,attributes:{},index:null}}function u(N,B,$,W){let X=l.attributes,Z=B.attributes,Q=0,ut=$.getAttributes();for(let at in ut)if(ut[at].location>=0){let J=X[at],it=Z[at];if(it===void 0&&(at==="instanceMatrix"&&N.instanceMatrix&&(it=N.instanceMatrix),at==="instanceColor"&&N.instanceColor&&(it=N.instanceColor)),J===void 0||J.attribute!==it||it&&J.data!==it.data)return!0;Q++}return l.attributesNum!==Q||l.index!==W}function v(N,B,$,W){let X={},Z=B.attributes,Q=0,ut=$.getAttributes();for(let at in ut)if(ut[at].location>=0){let J=Z[at];J===void 0&&(at==="instanceMatrix"&&N.instanceMatrix&&(J=N.instanceMatrix),at==="instanceColor"&&N.instanceColor&&(J=N.instanceColor));let it={};it.attribute=J,J&&J.data&&(it.data=J.data),X[at]=it,Q++}l.attributes=X,l.attributesNum=Q,l.index=W}function _(){let N=l.newAttributes;for(let B=0,$=N.length;B<$;B++)N[B]=0}function w(N){M(N,0)}function M(N,B){let $=l.newAttributes,W=l.enabledAttributes,X=l.attributeDivisors;$[N]=1,W[N]===0&&(i.enableVertexAttribArray(N),W[N]=1),X[N]!==B&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,B),X[N]=B)}function b(){let N=l.newAttributes,B=l.enabledAttributes;for(let $=0,W=B.length;$<W;$++)B[$]!==N[$]&&(i.disableVertexAttribArray($),B[$]=0)}function R(N,B,$,W,X,Z){n.isWebGL2===!0&&($===i.INT||$===i.UNSIGNED_INT)?i.vertexAttribIPointer(N,B,$,X,Z):i.vertexAttribPointer(N,B,$,W,X,Z)}function I(N,B,$,W){if(n.isWebGL2===!1&&(N.isInstancedMesh||W.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;_();let X=W.attributes,Z=$.getAttributes(),Q=B.defaultAttributeValues;for(let ut in Z){let at=Z[ut];if(at.location>=0){let V=X[ut];if(V===void 0&&(ut==="instanceMatrix"&&N.instanceMatrix&&(V=N.instanceMatrix),ut==="instanceColor"&&N.instanceColor&&(V=N.instanceColor)),V!==void 0){let J=V.normalized,it=V.itemSize,rt=e.get(V);if(rt===void 0)continue;let L=rt.buffer,bt=rt.type,Mt=rt.bytesPerElement;if(V.isInterleavedBufferAttribute){let nt=V.data,yt=nt.stride,Ft=V.offset;if(nt.isInstancedInterleavedBuffer){for(let pt=0;pt<at.locationSize;pt++)M(at.location+pt,nt.meshPerAttribute);N.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let pt=0;pt<at.locationSize;pt++)w(at.location+pt);i.bindBuffer(i.ARRAY_BUFFER,L);for(let pt=0;pt<at.locationSize;pt++)R(at.location+pt,it/at.locationSize,bt,J,yt*Mt,(Ft+it/at.locationSize*pt)*Mt)}else{if(V.isInstancedBufferAttribute){for(let nt=0;nt<at.locationSize;nt++)M(at.location+nt,V.meshPerAttribute);N.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=V.meshPerAttribute*V.count)}else for(let nt=0;nt<at.locationSize;nt++)w(at.location+nt);i.bindBuffer(i.ARRAY_BUFFER,L);for(let nt=0;nt<at.locationSize;nt++)R(at.location+nt,it/at.locationSize,bt,J,it*Mt,it/at.locationSize*nt*Mt)}}else if(Q!==void 0){let J=Q[ut];if(J!==void 0)switch(J.length){case 2:i.vertexAttrib2fv(at.location,J);break;case 3:i.vertexAttrib3fv(at.location,J);break;case 4:i.vertexAttrib4fv(at.location,J);break;default:i.vertexAttrib1fv(at.location,J)}}}}b()}function y(){z();for(let N in o){let B=o[N];for(let $ in B){let W=B[$];for(let X in W)g(W[X].object),delete W[X];delete B[$]}delete o[N]}}function T(N){if(o[N.id]===void 0)return;let B=o[N.id];for(let $ in B){let W=B[$];for(let X in W)g(W[X].object),delete W[X];delete B[$]}delete o[N.id]}function O(N){for(let B in o){let $=o[B];if($[N.id]===void 0)continue;let W=$[N.id];for(let X in W)g(W[X].object),delete W[X];delete $[N.id]}}function z(){U(),h=!0,l!==c&&(l=c,p(l.object))}function U(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:d,reset:z,resetDefaultState:U,dispose:y,releaseStatesOfGeometry:T,releaseStatesOfProgram:O,initAttributes:_,enableAttribute:w,disableUnusedAttributes:b}}function Of(i,t,e,n){let s=n.isWebGL2,r;function a(l){r=l}function o(l,h){i.drawArrays(r,l,h),e.update(h,r,1)}function c(l,h,d){if(d===0)return;let f,p;if(s)f=i,p="drawArraysInstanced";else if(f=t.get("ANGLE_instanced_arrays"),p="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[p](r,l,h,d),e.update(h,r,d)}this.setMode=a,this.render=o,this.renderInstances=c}function Bf(i,t,e){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");n=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=typeof WebGL2RenderingContext!="undefined"&&i.constructor.name==="WebGL2RenderingContext",o=e.precision!==void 0?e.precision:"highp",c=r(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);let l=a||t.has("WEBGL_draw_buffers"),h=e.logarithmicDepthBuffer===!0,d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),f=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),x=i.getParameter(i.MAX_VERTEX_ATTRIBS),m=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),u=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),_=f>0,w=a||t.has("OES_texture_float"),M=_&&w,b=a?i.getParameter(i.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:s,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:m,maxVaryings:u,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:w,floatVertexTextures:M,maxSamples:b}}function zf(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Re,o=new Ct,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let p=d.length!==0||f||n!==0||s;return s=f,n=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,f){e=h(d,f,0)},this.setState=function(d,f,p){let g=d.clippingPlanes,x=d.clipIntersection,m=d.clipShadows,u=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{let v=r?0:n,_=v*4,w=u.clippingState||null;c.value=w,w=h(g,f,_,p);for(let M=0;M!==_;++M)w[M]=e[M];u.clippingState=w,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,f,p,g){let x=d!==null?d.length:0,m=null;if(x!==0){if(m=c.value,g!==!0||m===null){let u=p+x*4,v=f.matrixWorldInverse;o.getNormalMatrix(v),(m===null||m.length<u)&&(m=new Float32Array(u));for(let _=0,w=p;_!==x;++_,w+=4)a.copy(d[_]).applyMatrix4(v,o),a.normal.toArray(m,w),m[w+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,m}}function kf(i){let t=new WeakMap;function e(a,o){return o===Cr?a.mapping=pi:o===Pr&&(a.mapping=mi),a}function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){let o=a.mapping;if(o===Cr||o===Pr)if(t.has(a)){let c=t.get(a).texture;return e(c,a.mapping)}else{let c=a.image;if(c&&c.height>0){let l=new Br(c.height/2);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",s),e(l.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var zr=class extends Ls{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},ci=4,Ra=[.125,.215,.35,.446,.526,.582],Ln=20,wr=new zr,Ca=new Ht,Tr=null,Pn=(1+Math.sqrt(5))/2,oi=1/Pn,Pa=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Pn,oi),new P(0,Pn,-oi),new P(oi,0,Pn),new P(-oi,0,Pn),new P(Pn,oi,0),new P(-Pn,oi,0)],Ds=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){Tr=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ua(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ia(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Tr),t.scissorTest=!1,xs(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===pi||t.mapping===mi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Tr=this._renderer.getRenderTarget();let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Le,minFilter:Le,generateMipmaps:!1,type:Vi,format:Ve,colorSpace:Je,depthBuffer:!1},s=La(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=La(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vf(r)),this._blurMaterial=Hf(r,t,e)}return s}_compileMaterial(t){let e=new Ze(this._lodPlanes[0],t);this._renderer.compile(e,wr)}_sceneToCubeUV(t,e,n,s){let o=new Ae(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(Ca),h.toneMapping=on,h.autoClear=!1;let p=new Rs({name:"PMREM.Background",side:le,depthWrite:!1,depthTest:!1}),g=new Ze(new zn,p),x=!1,m=t.background;m?m.isColor&&(p.color.copy(m),t.background=null,x=!0):(p.color.copy(Ca),x=!0);for(let u=0;u<6;u++){let v=u%3;v===0?(o.up.set(0,c[u],0),o.lookAt(l[u],0,0)):v===1?(o.up.set(0,0,c[u]),o.lookAt(0,l[u],0)):(o.up.set(0,c[u],0),o.lookAt(0,0,l[u]));let _=this._cubeSize;xs(s,v*_,u>2?_:0,_,_),h.setRenderTarget(s),x&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=f,h.autoClear=d,t.background=m}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===pi||t.mapping===mi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ua()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ia());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ze(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;xs(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,wr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let s=1;s<this._lodPlanes.length;s++){let r=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Pa[(s-1)%Pa.length];this._blur(t,s-1,s,r,a)}e.autoClear=n}_blur(t,e,n,s,r){let a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){let c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,d=new Ze(this._lodPlanes[s],l),f=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Ln-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Ln;m>Ln&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ln}`);let u=[],v=0;for(let R=0;R<Ln;++R){let I=R/x,y=Math.exp(-I*I/2);u.push(y),R===0?v+=y:R<m&&(v+=2*y)}for(let R=0;R<u.length;R++)u[R]=u[R]/v;f.envMap.value=t.texture,f.samples.value=m,f.weights.value=u,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);let{_lodMax:_}=this;f.dTheta.value=g,f.mipInt.value=_-n;let w=this._sizeLods[s],M=3*w*(s>_-ci?s-_+ci:0),b=4*(this._cubeSize-w);xs(e,M,b,3*w,2*w),c.setRenderTarget(e),c.render(d,wr)}};function Vf(i){let t=[],e=[],n=[],s=i,r=i-ci+1+Ra.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let c=1/o;a>i-ci?c=Ra[a-i+ci-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,d=1+l,f=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,g=6,x=3,m=2,u=1,v=new Float32Array(x*g*p),_=new Float32Array(m*g*p),w=new Float32Array(u*g*p);for(let b=0;b<p;b++){let R=b%3*2/3-1,I=b>2?0:-1,y=[R,I,0,R+2/3,I,0,R+2/3,I+1,0,R,I,0,R+2/3,I+1,0,R,I+1,0];v.set(y,x*g*b),_.set(f,m*g*b);let T=[b,b,b,b,b,b];w.set(T,u*g*b)}let M=new Ge;M.setAttribute("position",new Kt(v,x)),M.setAttribute("uv",new Kt(_,m)),M.setAttribute("faceIndex",new Kt(w,u)),t.push(M),s>ci&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function La(i,t,e){let n=new cn(i,t,e);return n.texture.mapping=Ns,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function xs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function Hf(i,t,e){let n=new Float32Array(Ln),s=new P(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Ln,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:co(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues\' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t`,blending:xn,depthTest:!1,depthWrite:!1})}function Ia(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:co(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t`,blending:xn,depthTest:!1,depthWrite:!1})}function Ua(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:co(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t`,blending:xn,depthTest:!1,depthWrite:!1})}function co(){return`\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t`}function Gf(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Cr||c===Pr,h=c===pi||c===mi;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return e===null&&(e=new Ds(i)),d=l?e.fromEquirectangular(o,d):e.fromCubemap(o,d),t.set(o,d),d.texture}else{if(t.has(o))return t.get(o).texture;{let d=o.image;if(l&&d&&d.height>0||h&&d&&s(d)){e===null&&(e=new Ds(i));let f=l?e.fromEquirectangular(o):e.fromCubemap(o);return t.set(o,f),o.addEventListener("dispose",r),f.texture}else return null}}}return o}function s(o){let c=0,l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function Wf(i){let t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(n){n.isWebGL2?e("EXT_color_buffer_float"):(e("WEBGL_depth_texture"),e("OES_texture_float"),e("OES_texture_half_float"),e("OES_texture_half_float_linear"),e("OES_standard_derivatives"),e("OES_element_index_uint"),e("OES_vertex_array_object"),e("ANGLE_instanced_arrays")),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture")},get:function(n){let s=e(n);return s===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function Xf(i,t,e,n){let s={},r=new WeakMap;function a(d){let f=d.target;f.index!==null&&t.remove(f.index);for(let g in f.attributes)t.remove(f.attributes[g]);f.removeEventListener("dispose",a),delete s[f.id];let p=r.get(f);p&&(t.remove(p),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function o(d,f){return s[f.id]===!0||(f.addEventListener("dispose",a),s[f.id]=!0,e.memory.geometries++),f}function c(d){let f=d.attributes;for(let g in f)t.update(f[g],i.ARRAY_BUFFER);let p=d.morphAttributes;for(let g in p){let x=p[g];for(let m=0,u=x.length;m<u;m++)t.update(x[m],i.ARRAY_BUFFER)}}function l(d){let f=[],p=d.index,g=d.attributes.position,x=0;if(p!==null){let v=p.array;x=p.version;for(let _=0,w=v.length;_<w;_+=3){let M=v[_+0],b=v[_+1],R=v[_+2];f.push(M,b,b,R,R,M)}}else{let v=g.array;x=g.version;for(let _=0,w=v.length/3-1;_<w;_+=3){let M=_+0,b=_+1,R=_+2;f.push(M,b,b,R,R,M)}}let m=new(sc(f)?Ps:Cs)(f,1);m.version=x;let u=r.get(d);u&&t.remove(u),r.set(d,m)}function h(d){let f=r.get(d);if(f){let p=d.index;p!==null&&f.version<p.version&&l(d)}else l(d);return r.get(d)}return{get:o,update:c,getWireframeAttribute:h}}function qf(i,t,e,n){let s=n.isWebGL2,r;function a(f){r=f}let o,c;function l(f){o=f.type,c=f.bytesPerElement}function h(f,p){i.drawElements(r,p,o,f*c),e.update(p,r,1)}function d(f,p,g){if(g===0)return;let x,m;if(s)x=i,m="drawElementsInstanced";else if(x=t.get("ANGLE_instanced_arrays"),m="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[m](r,p,o,f*c,g),e.update(p,r,g)}this.setMode=a,this.setIndex=l,this.render=h,this.renderInstances=d}function Yf(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function Zf(i,t){return i[0]-t[0]}function Jf(i,t){return Math.abs(t[1])-Math.abs(i[1])}function $f(i,t,e){let n={},s=new Float32Array(8),r=new WeakMap,a=new $t,o=[];for(let l=0;l<8;l++)o[l]=[l,0];function c(l,h,d){let f=l.morphTargetInfluences;if(t.isWebGL2===!0){let p=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,g=p!==void 0?p.length:0,x=r.get(h);if(x===void 0||x.count!==g){let N=function(){z.dispose(),r.delete(h),h.removeEventListener("dispose",N)};x!==void 0&&x.texture.dispose();let v=h.morphAttributes.position!==void 0,_=h.morphAttributes.normal!==void 0,w=h.morphAttributes.color!==void 0,M=h.morphAttributes.position||[],b=h.morphAttributes.normal||[],R=h.morphAttributes.color||[],I=0;v===!0&&(I=1),_===!0&&(I=2),w===!0&&(I=3);let y=h.attributes.position.count*I,T=1;y>t.maxTextureSize&&(T=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);let O=new Float32Array(y*T*4*g),z=new Ts(O,y,T,g);z.type=Un,z.needsUpdate=!0;let U=I*4;for(let B=0;B<g;B++){let $=M[B],W=b[B],X=R[B],Z=y*T*4*B;for(let Q=0;Q<$.count;Q++){let ut=Q*U;v===!0&&(a.fromBufferAttribute($,Q),O[Z+ut+0]=a.x,O[Z+ut+1]=a.y,O[Z+ut+2]=a.z,O[Z+ut+3]=0),_===!0&&(a.fromBufferAttribute(W,Q),O[Z+ut+4]=a.x,O[Z+ut+5]=a.y,O[Z+ut+6]=a.z,O[Z+ut+7]=0),w===!0&&(a.fromBufferAttribute(X,Q),O[Z+ut+8]=a.x,O[Z+ut+9]=a.y,O[Z+ut+10]=a.z,O[Z+ut+11]=X.itemSize===4?a.w:1)}}x={count:g,texture:z,size:new Dt(y,T)},r.set(h,x),h.addEventListener("dispose",N)}let m=0;for(let v=0;v<f.length;v++)m+=f[v];let u=h.morphTargetsRelative?1:1-m;d.getUniforms().setValue(i,"morphTargetBaseInfluence",u),d.getUniforms().setValue(i,"morphTargetInfluences",f),d.getUniforms().setValue(i,"morphTargetsTexture",x.texture,e),d.getUniforms().setValue(i,"morphTargetsTextureSize",x.size)}else{let p=f===void 0?0:f.length,g=n[h.id];if(g===void 0||g.length!==p){g=[];for(let _=0;_<p;_++)g[_]=[_,0];n[h.id]=g}for(let _=0;_<p;_++){let w=g[_];w[0]=_,w[1]=f[_]}g.sort(Jf);for(let _=0;_<8;_++)_<p&&g[_][1]?(o[_][0]=g[_][0],o[_][1]=g[_][1]):(o[_][0]=Number.MAX_SAFE_INTEGER,o[_][1]=0);o.sort(Zf);let x=h.morphAttributes.position,m=h.morphAttributes.normal,u=0;for(let _=0;_<8;_++){let w=o[_],M=w[0],b=w[1];M!==Number.MAX_SAFE_INTEGER&&b?(x&&h.getAttribute("morphTarget"+_)!==x[M]&&h.setAttribute("morphTarget"+_,x[M]),m&&h.getAttribute("morphNormal"+_)!==m[M]&&h.setAttribute("morphNormal"+_,m[M]),s[_]=b,u+=b):(x&&h.hasAttribute("morphTarget"+_)===!0&&h.deleteAttribute("morphTarget"+_),m&&h.hasAttribute("morphNormal"+_)===!0&&h.deleteAttribute("morphNormal"+_),s[_]=0)}let v=h.morphTargetsRelative?1:1-u;d.getUniforms().setValue(i,"morphTargetBaseInfluence",v),d.getUniforms().setValue(i,"morphTargetInfluences",s)}}return{update:c}}function Kf(i,t,e,n){let s=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,d=t.get(c,h);return s.get(d)!==l&&(t.update(d),s.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER)),d}function a(){s=new WeakMap}function o(c){let l=c.target;l.removeEventListener("dispose",o),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:r,dispose:a}}var cc=new me,lc=new Ts,hc=new Nr,uc=new Is,Da=[],Na=[],Fa=new Float32Array(16),Oa=new Float32Array(9),Ba=new Float32Array(4);function Mi(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=Da[s];if(r===void 0&&(r=new Float32Array(s),Da[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function jt(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Qt(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Fs(i,t){let e=Na[t];e===void 0&&(e=new Int32Array(t),Na[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function jf(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Qf(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(jt(e,t))return;i.uniform2fv(this.addr,t),Qt(e,t)}}function td(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(jt(e,t))return;i.uniform3fv(this.addr,t),Qt(e,t)}}function ed(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(jt(e,t))return;i.uniform4fv(this.addr,t),Qt(e,t)}}function nd(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(jt(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Qt(e,t)}else{if(jt(e,n))return;Ba.set(n),i.uniformMatrix2fv(this.addr,!1,Ba),Qt(e,n)}}function id(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(jt(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Qt(e,t)}else{if(jt(e,n))return;Oa.set(n),i.uniformMatrix3fv(this.addr,!1,Oa),Qt(e,n)}}function sd(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(jt(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Qt(e,t)}else{if(jt(e,n))return;Fa.set(n),i.uniformMatrix4fv(this.addr,!1,Fa),Qt(e,n)}}function rd(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function od(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(jt(e,t))return;i.uniform2iv(this.addr,t),Qt(e,t)}}function ad(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(jt(e,t))return;i.uniform3iv(this.addr,t),Qt(e,t)}}function cd(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(jt(e,t))return;i.uniform4iv(this.addr,t),Qt(e,t)}}function ld(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function hd(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(jt(e,t))return;i.uniform2uiv(this.addr,t),Qt(e,t)}}function ud(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(jt(e,t))return;i.uniform3uiv(this.addr,t),Qt(e,t)}}function fd(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(jt(e,t))return;i.uniform4uiv(this.addr,t),Qt(e,t)}}function dd(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2D(t||cc,s)}function pd(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||hc,s)}function md(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||uc,s)}function gd(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||lc,s)}function _d(i){switch(i){case 5126:return jf;case 35664:return Qf;case 35665:return td;case 35666:return ed;case 35674:return nd;case 35675:return id;case 35676:return sd;case 5124:case 35670:return rd;case 35667:case 35671:return od;case 35668:case 35672:return ad;case 35669:case 35673:return cd;case 5125:return ld;case 36294:return hd;case 36295:return ud;case 36296:return fd;case 35678:case 36198:case 36298:case 36306:case 35682:return dd;case 35679:case 36299:case 36307:return pd;case 35680:case 36300:case 36308:case 36293:return md;case 36289:case 36303:case 36311:case 36292:return gd}}function xd(i,t){i.uniform1fv(this.addr,t)}function yd(i,t){let e=Mi(t,this.size,2);i.uniform2fv(this.addr,e)}function vd(i,t){let e=Mi(t,this.size,3);i.uniform3fv(this.addr,e)}function Md(i,t){let e=Mi(t,this.size,4);i.uniform4fv(this.addr,e)}function Sd(i,t){let e=Mi(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function bd(i,t){let e=Mi(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Ed(i,t){let e=Mi(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function wd(i,t){i.uniform1iv(this.addr,t)}function Td(i,t){i.uniform2iv(this.addr,t)}function Ad(i,t){i.uniform3iv(this.addr,t)}function Rd(i,t){i.uniform4iv(this.addr,t)}function Cd(i,t){i.uniform1uiv(this.addr,t)}function Pd(i,t){i.uniform2uiv(this.addr,t)}function Ld(i,t){i.uniform3uiv(this.addr,t)}function Id(i,t){i.uniform4uiv(this.addr,t)}function Ud(i,t,e){let n=this.cache,s=t.length,r=Fs(e,s);jt(n,r)||(i.uniform1iv(this.addr,r),Qt(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||cc,r[a])}function Dd(i,t,e){let n=this.cache,s=t.length,r=Fs(e,s);jt(n,r)||(i.uniform1iv(this.addr,r),Qt(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||hc,r[a])}function Nd(i,t,e){let n=this.cache,s=t.length,r=Fs(e,s);jt(n,r)||(i.uniform1iv(this.addr,r),Qt(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||uc,r[a])}function Fd(i,t,e){let n=this.cache,s=t.length,r=Fs(e,s);jt(n,r)||(i.uniform1iv(this.addr,r),Qt(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||lc,r[a])}function Od(i){switch(i){case 5126:return xd;case 35664:return yd;case 35665:return vd;case 35666:return Md;case 35674:return Sd;case 35675:return bd;case 35676:return Ed;case 5124:case 35670:return wd;case 35667:case 35671:return Td;case 35668:case 35672:return Ad;case 35669:case 35673:return Rd;case 5125:return Cd;case 36294:return Pd;case 36295:return Ld;case 36296:return Id;case 35678:case 36198:case 36298:case 36306:case 35682:return Ud;case 35679:case 36299:case 36307:return Dd;case 35680:case 36300:case 36308:case 36293:return Nd;case 36289:case 36303:case 36311:case 36292:return Fd}}var kr=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=_d(e.type)}},Vr=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=Od(e.type)}},Hr=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(t,e[o.id],n)}}},Ar=/(\\w+)(\\])?(\\[|\\.)?/g;function za(i,t){i.seq.push(t),i.map[t.id]=t}function Bd(i,t,e){let n=i.name,s=n.length;for(Ar.lastIndex=0;;){let r=Ar.exec(n),a=Ar.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){za(e,l===void 0?new kr(o,i,t):new Vr(o,i,t));break}else{let d=e.map[o];d===void 0&&(d=new Hr(o),za(e,d)),e=d}}}var di=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);Bd(r,a,this)}}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){let o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let a=t[s];a.id in e&&n.push(a)}return n}};function ka(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var zd=0;function kd(i,t){let e=i.split(`\n`),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`\n`)}function Vd(i){switch(i){case Je:return["Linear","( value )"];case Et:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Va(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\\d+)/.exec(s);if(r){let a=parseInt(r[1]);return e.toUpperCase()+`\n\n`+s+`\n\n`+kd(i.getShaderSource(t),a)}else return s}function Hd(i,t){let e=Vd(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function Gd(i,t){let e;switch(t){case al:e="Linear";break;case cl:e="Reinhard";break;case ll:e="OptimizedCineon";break;case hl:e="ACESFilmic";break;case ul:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function Wd(i){return[i.extensionDerivatives||i.envMapCubeUVHeight||i.bumpMap||i.normalMapTangentSpace||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Oi).join(`\n`)}function Xd(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function qd(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(t,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function Oi(i){return i!==""}function Ha(i,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ga(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var Yd=/^[ \\t]*#include +<([\\w\\d./]+)>/gm;function Gr(i){return i.replace(Yd,Zd)}function Zd(i,t){let e=Tt[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return Gr(e)}var Jd=/#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;function Wa(i){return i.replace(Jd,$d)}function $d(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\\[\\s*i\\s*\\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Xa(i){let t="precision "+i.precision+` float;\nprecision `+i.precision+" int;";return i.precision==="highp"?t+=`\n#define HIGH_PRECISION`:i.precision==="mediump"?t+=`\n#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`\n#define LOW_PRECISION`),t}function Kd(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===$a?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===zc?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===rn&&(t="SHADOWMAP_TYPE_VSM"),t}function jd(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case pi:case mi:t="ENVMAP_TYPE_CUBE";break;case Ns:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Qd(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case mi:t="ENVMAP_MODE_REFRACTION";break}return t}function tp(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Qa:t="ENVMAP_BLENDING_MULTIPLY";break;case rl:t="ENVMAP_BLENDING_MIX";break;case ol:t="ENVMAP_BLENDING_ADD";break}return t}function ep(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function np(i,t,e,n){let s=i.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,c=Kd(e),l=jd(e),h=Qd(e),d=tp(e),f=ep(e),p=e.isWebGL2?"":Wd(e),g=Xd(r),x=s.createProgram(),m,u,v=e.glslVersion?"#version "+e.glslVersion+`\n`:"";e.isRawShaderMaterial?(m=[g].filter(Oi).join(`\n`),m.length>0&&(m+=`\n`),u=[p,g].filter(Oi).join(`\n`),u.length>0&&(u+=`\n`)):(m=[Xa(e),"#define SHADER_NAME "+e.shaderName,g,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`\n`].filter(Oi).join(`\n`),u=[p,Xa(e),"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==on?"#define TONE_MAPPING":"",e.toneMapping!==on?Tt.tonemapping_pars_fragment:"",e.toneMapping!==on?Gd("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Tt.encodings_pars_fragment,Hd("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(Oi).join(`\n`)),a=Gr(a),a=Ha(a,e),a=Ga(a,e),o=Gr(o),o=Ha(o,e),o=Ga(o,e),a=Wa(a),o=Wa(o),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es\n`,m=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`\n`)+`\n`+m,u=["#define varying in",e.glslVersion===ua?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===ua?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`\n`)+`\n`+u);let _=v+m+a,w=v+u+o,M=ka(s,s.VERTEX_SHADER,_),b=ka(s,s.FRAGMENT_SHADER,w);if(s.attachShader(x,M),s.attachShader(x,b),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x),i.debug.checkShaderErrors){let y=s.getProgramInfoLog(x).trim(),T=s.getShaderInfoLog(M).trim(),O=s.getShaderInfoLog(b).trim(),z=!0,U=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,M,b);else{let N=Va(s,M,"vertex"),B=Va(s,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`\n\nProgram Info Log: `+y+`\n`+N+`\n`+B)}else y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",y):(T===""||O==="")&&(U=!1);U&&(this.diagnostics={runnable:z,programLog:y,vertexShader:{log:T,prefix:m},fragmentShader:{log:O,prefix:u}})}s.deleteShader(M),s.deleteShader(b);let R;this.getUniforms=function(){return R===void 0&&(R=new di(s,x)),R};let I;return this.getAttributes=function(){return I===void 0&&(I=qd(s,x)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.name=e.shaderName,this.id=zd++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=b,this}var ip=0,Wr=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Xr(t),e.set(t,n)),n}},Xr=class{constructor(t){this.id=ip++,this.code=t,this.usedTimes=0}};function sp(i,t,e,n,s,r,a){let o=new As,c=new Wr,l=[],h=s.isWebGL2,d=s.logarithmicDepthBuffer,f=s.vertexTextures,p=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(y){return y===1?"uv1":y===2?"uv2":y===3?"uv3":"uv"}function m(y,T,O,z,U){let N=z.fog,B=U.geometry,$=y.isMeshStandardMaterial?z.environment:null,W=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),X=W&&W.mapping===Ns?W.image.height:null,Z=g[y.type];y.precision!==null&&(p=s.getMaxPrecision(y.precision),p!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",p,"instead."));let Q=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ut=Q!==void 0?Q.length:0,at=0;B.morphAttributes.position!==void 0&&(at=1),B.morphAttributes.normal!==void 0&&(at=2),B.morphAttributes.color!==void 0&&(at=3);let V,J,it,rt;if(Z){let kt=Ye[Z];V=kt.vertexShader,J=kt.fragmentShader}else V=y.vertexShader,J=y.fragmentShader,c.update(y),it=c.getVertexShaderID(y),rt=c.getFragmentShaderID(y);let L=i.getRenderTarget(),bt=U.isInstancedMesh===!0,Mt=!!y.map,nt=!!y.matcap,yt=!!W,Ft=!!y.aoMap,pt=!!y.lightMap,Pt=!!y.bumpMap,te=!!y.normalMap,re=!!y.displacementMap,ee=!!y.emissiveMap,Jt=!!y.metalnessMap,Ot=!!y.roughnessMap,Wt=y.clearcoat>0,_e=y.iridescence>0,A=y.sheen>0,S=y.transmission>0,k=Wt&&!!y.clearcoatMap,j=Wt&&!!y.clearcoatNormalMap,tt=Wt&&!!y.clearcoatRoughnessMap,st=_e&&!!y.iridescenceMap,vt=_e&&!!y.iridescenceThicknessMap,lt=A&&!!y.sheenColorMap,q=A&&!!y.sheenRoughnessMap,ft=!!y.specularMap,mt=!!y.specularColorMap,_t=!!y.specularIntensityMap,ct=S&&!!y.transmissionMap,dt=S&&!!y.thicknessMap,It=!!y.gradientMap,Bt=!!y.alphaMap,Xt=y.alphaTest>0,C=!!y.extensions,H=!!B.attributes.uv1,K=!!B.attributes.uv2,ot=!!B.attributes.uv3;return{isWebGL2:h,shaderID:Z,shaderName:y.type,vertexShader:V,fragmentShader:J,defines:y.defines,customVertexShaderID:it,customFragmentShaderID:rt,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:p,instancing:bt,instancingColor:bt&&U.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:L===null?i.outputColorSpace:L.isXRRenderTarget===!0?L.texture.colorSpace:Je,map:Mt,matcap:nt,envMap:yt,envMapMode:yt&&W.mapping,envMapCubeUVHeight:X,aoMap:Ft,lightMap:pt,bumpMap:Pt,normalMap:te,displacementMap:f&&re,emissiveMap:ee,normalMapObjectSpace:te&&y.normalMapType===Ll,normalMapTangentSpace:te&&y.normalMapType===Pl,metalnessMap:Jt,roughnessMap:Ot,clearcoat:Wt,clearcoatMap:k,clearcoatNormalMap:j,clearcoatRoughnessMap:tt,iridescence:_e,iridescenceMap:st,iridescenceThicknessMap:vt,sheen:A,sheenColorMap:lt,sheenRoughnessMap:q,specularMap:ft,specularColorMap:mt,specularIntensityMap:_t,transmission:S,transmissionMap:ct,thicknessMap:dt,gradientMap:It,opaque:y.transparent===!1&&y.blending===hi,alphaMap:Bt,alphaTest:Xt,combine:y.combine,mapUv:Mt&&x(y.map.channel),aoMapUv:Ft&&x(y.aoMap.channel),lightMapUv:pt&&x(y.lightMap.channel),bumpMapUv:Pt&&x(y.bumpMap.channel),normalMapUv:te&&x(y.normalMap.channel),displacementMapUv:re&&x(y.displacementMap.channel),emissiveMapUv:ee&&x(y.emissiveMap.channel),metalnessMapUv:Jt&&x(y.metalnessMap.channel),roughnessMapUv:Ot&&x(y.roughnessMap.channel),clearcoatMapUv:k&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:j&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:vt&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:q&&x(y.sheenRoughnessMap.channel),specularMapUv:ft&&x(y.specularMap.channel),specularColorMapUv:mt&&x(y.specularColorMap.channel),specularIntensityMapUv:_t&&x(y.specularIntensityMap.channel),transmissionMapUv:ct&&x(y.transmissionMap.channel),thicknessMapUv:dt&&x(y.thicknessMap.channel),alphaMapUv:Bt&&x(y.alphaMap.channel),vertexTangents:te&&!!B.attributes.tangent,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUv1s:H,vertexUv2s:K,vertexUv3s:ot,pointsUvs:U.isPoints===!0&&!!B.attributes.uv&&(Mt||Bt),fog:!!N,useFog:y.fog===!0,fogExp2:N&&N.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:U.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:at,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&O.length>0,shadowMapType:i.shadowMap.type,toneMapping:y.toneMapped?i.toneMapping:on,useLegacyLights:i.useLegacyLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===ze,flipSided:y.side===le,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:C&&y.extensions.derivatives===!0,extensionFragDepth:C&&y.extensions.fragDepth===!0,extensionDrawBuffers:C&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:C&&y.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:y.customProgramCacheKey()}}function u(y){let T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(let O in y.defines)T.push(O),T.push(y.defines[O]);return y.isRawShaderMaterial===!1&&(v(T,y),_(T,y),T.push(i.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function v(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function _(y,T){o.disableAll(),T.isWebGL2&&o.enable(0),T.supportsVertexTextures&&o.enable(1),T.instancing&&o.enable(2),T.instancingColor&&o.enable(3),T.matcap&&o.enable(4),T.envMap&&o.enable(5),T.normalMapObjectSpace&&o.enable(6),T.normalMapTangentSpace&&o.enable(7),T.clearcoat&&o.enable(8),T.iridescence&&o.enable(9),T.alphaTest&&o.enable(10),T.vertexColors&&o.enable(11),T.vertexAlphas&&o.enable(12),T.vertexUv1s&&o.enable(13),T.vertexUv2s&&o.enable(14),T.vertexUv3s&&o.enable(15),T.vertexTangents&&o.enable(16),y.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.skinning&&o.enable(4),T.morphTargets&&o.enable(5),T.morphNormals&&o.enable(6),T.morphColors&&o.enable(7),T.premultipliedAlpha&&o.enable(8),T.shadowMapEnabled&&o.enable(9),T.useLegacyLights&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),y.push(o.mask)}function w(y){let T=g[y.type],O;if(T){let z=Ye[T];O=Ql.clone(z.uniforms)}else O=y.uniforms;return O}function M(y,T){let O;for(let z=0,U=l.length;z<U;z++){let N=l[z];if(N.cacheKey===T){O=N,++O.usedTimes;break}}return O===void 0&&(O=new np(i,T,y,r),l.push(O)),O}function b(y){if(--y.usedTimes===0){let T=l.indexOf(y);l[T]=l[l.length-1],l.pop(),y.destroy()}}function R(y){c.remove(y)}function I(){c.dispose()}return{getParameters:m,getProgramCacheKey:u,getUniforms:w,acquireProgram:M,releaseProgram:b,releaseShaderCache:R,programs:l,dispose:I}}function rp(){let i=new WeakMap;function t(r){let a=i.get(r);return a===void 0&&(a={},i.set(r,a)),a}function e(r){i.delete(r)}function n(r,a,o){i.get(r)[a]=o}function s(){i=new WeakMap}return{get:t,remove:e,update:n,dispose:s}}function op(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function qa(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Ya(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(d,f,p,g,x,m){let u=i[t];return u===void 0?(u={id:d.id,object:d,geometry:f,material:p,groupOrder:g,renderOrder:d.renderOrder,z:x,group:m},i[t]=u):(u.id=d.id,u.object=d,u.geometry=f,u.material=p,u.groupOrder=g,u.renderOrder=d.renderOrder,u.z=x,u.group=m),t++,u}function o(d,f,p,g,x,m){let u=a(d,f,p,g,x,m);p.transmission>0?n.push(u):p.transparent===!0?s.push(u):e.push(u)}function c(d,f,p,g,x,m){let u=a(d,f,p,g,x,m);p.transmission>0?n.unshift(u):p.transparent===!0?s.unshift(u):e.unshift(u)}function l(d,f){e.length>1&&e.sort(d||op),n.length>1&&n.sort(f||qa),s.length>1&&s.sort(f||qa)}function h(){for(let d=t,f=i.length;d<f;d++){let p=i[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function ap(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new Ya,i.set(n,[a])):s>=r.length?(a=new Ya,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function cp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new Ht};break;case"SpotLight":e={position:new P,direction:new P,color:new Ht,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new Ht,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new Ht,groundColor:new Ht};break;case"RectAreaLight":e={color:new Ht,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function lp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var hp=0;function up(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function fp(i,t){let e=new cp,n=lp(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let h=0;h<9;h++)s.probe.push(new P);let r=new P,a=new Gt,o=new Gt;function c(h,d){let f=0,p=0,g=0;for(let O=0;O<9;O++)s.probe[O].set(0,0,0);let x=0,m=0,u=0,v=0,_=0,w=0,M=0,b=0,R=0,I=0;h.sort(up);let y=d===!0?Math.PI:1;for(let O=0,z=h.length;O<z;O++){let U=h[O],N=U.color,B=U.intensity,$=U.distance,W=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)f+=N.r*B*y,p+=N.g*B*y,g+=N.b*B*y;else if(U.isLightProbe)for(let X=0;X<9;X++)s.probe[X].addScaledVector(U.sh.coefficients[X],B);else if(U.isDirectionalLight){let X=e.get(U);if(X.color.copy(U.color).multiplyScalar(U.intensity*y),U.castShadow){let Z=U.shadow,Q=n.get(U);Q.shadowBias=Z.bias,Q.shadowNormalBias=Z.normalBias,Q.shadowRadius=Z.radius,Q.shadowMapSize=Z.mapSize,s.directionalShadow[x]=Q,s.directionalShadowMap[x]=W,s.directionalShadowMatrix[x]=U.shadow.matrix,w++}s.directional[x]=X,x++}else if(U.isSpotLight){let X=e.get(U);X.position.setFromMatrixPosition(U.matrixWorld),X.color.copy(N).multiplyScalar(B*y),X.distance=$,X.coneCos=Math.cos(U.angle),X.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),X.decay=U.decay,s.spot[u]=X;let Z=U.shadow;if(U.map&&(s.spotLightMap[R]=U.map,R++,Z.updateMatrices(U),U.castShadow&&I++),s.spotLightMatrix[u]=Z.matrix,U.castShadow){let Q=n.get(U);Q.shadowBias=Z.bias,Q.shadowNormalBias=Z.normalBias,Q.shadowRadius=Z.radius,Q.shadowMapSize=Z.mapSize,s.spotShadow[u]=Q,s.spotShadowMap[u]=W,b++}u++}else if(U.isRectAreaLight){let X=e.get(U);X.color.copy(N).multiplyScalar(B),X.halfWidth.set(U.width*.5,0,0),X.halfHeight.set(0,U.height*.5,0),s.rectArea[v]=X,v++}else if(U.isPointLight){let X=e.get(U);if(X.color.copy(U.color).multiplyScalar(U.intensity*y),X.distance=U.distance,X.decay=U.decay,U.castShadow){let Z=U.shadow,Q=n.get(U);Q.shadowBias=Z.bias,Q.shadowNormalBias=Z.normalBias,Q.shadowRadius=Z.radius,Q.shadowMapSize=Z.mapSize,Q.shadowCameraNear=Z.camera.near,Q.shadowCameraFar=Z.camera.far,s.pointShadow[m]=Q,s.pointShadowMap[m]=W,s.pointShadowMatrix[m]=U.shadow.matrix,M++}s.point[m]=X,m++}else if(U.isHemisphereLight){let X=e.get(U);X.skyColor.copy(U.color).multiplyScalar(B*y),X.groundColor.copy(U.groundColor).multiplyScalar(B*y),s.hemi[_]=X,_++}}v>0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=et.LTC_FLOAT_1,s.rectAreaLTC2=et.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=et.LTC_HALF_1,s.rectAreaLTC2=et.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=f,s.ambient[1]=p,s.ambient[2]=g;let T=s.hash;(T.directionalLength!==x||T.pointLength!==m||T.spotLength!==u||T.rectAreaLength!==v||T.hemiLength!==_||T.numDirectionalShadows!==w||T.numPointShadows!==M||T.numSpotShadows!==b||T.numSpotMaps!==R)&&(s.directional.length=x,s.spot.length=u,s.rectArea.length=v,s.point.length=m,s.hemi.length=_,s.directionalShadow.length=w,s.directionalShadowMap.length=w,s.pointShadow.length=M,s.pointShadowMap.length=M,s.spotShadow.length=b,s.spotShadowMap.length=b,s.directionalShadowMatrix.length=w,s.pointShadowMatrix.length=M,s.spotLightMatrix.length=b+R-I,s.spotLightMap.length=R,s.numSpotLightShadowsWithMaps=I,T.directionalLength=x,T.pointLength=m,T.spotLength=u,T.rectAreaLength=v,T.hemiLength=_,T.numDirectionalShadows=w,T.numPointShadows=M,T.numSpotShadows=b,T.numSpotMaps=R,s.version=hp++)}function l(h,d){let f=0,p=0,g=0,x=0,m=0,u=d.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){let w=h[v];if(w.isDirectionalLight){let M=s.directional[f];M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(u),f++}else if(w.isSpotLight){let M=s.spot[g];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(u),M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(u),g++}else if(w.isRectAreaLight){let M=s.rectArea[x];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(u),o.identity(),a.copy(w.matrixWorld),a.premultiply(u),o.extractRotation(a),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(w.isPointLight){let M=s.point[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(u),p++}else if(w.isHemisphereLight){let M=s.hemi[m];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(u),m++}}}return{setup:c,setupView:l,state:s}}function Za(i,t){let e=new fp(i,t),n=[],s=[];function r(){n.length=0,s.length=0}function a(d){n.push(d)}function o(d){s.push(d)}function c(d){e.setup(n,d)}function l(d){e.setupView(n,d)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function dp(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new Za(i,t),e.set(r,[c])):a>=o.length?(c=new Za(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var qr=class extends xi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Rl,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Yr=class extends xi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},pp=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,mp=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`;function gp(i,t,e){let n=new Us,s=new Dt,r=new Dt,a=new $t,o=new qr({depthPacking:Cl}),c=new Yr,l={},h=e.maxTextureSize,d={[He]:le,[le]:He,[ze]:ze},f=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:pp,fragmentShader:mp}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ze(g,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$a;let u=this.type;this.render=function(M,b,R){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||M.length===0)return;let I=i.getRenderTarget(),y=i.getActiveCubeFace(),T=i.getActiveMipmapLevel(),O=i.state;O.setBlending(xn),O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);let z=u!==rn&&this.type===rn,U=u===rn&&this.type!==rn;for(let N=0,B=M.length;N<B;N++){let $=M[N],W=$.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",$,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;s.copy(W.mapSize);let X=W.getFrameExtents();if(s.multiply(X),r.copy(W.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/X.x),s.x=r.x*X.x,W.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/X.y),s.y=r.y*X.y,W.mapSize.y=r.y)),W.map===null||z===!0||U===!0){let Q=this.type!==rn?{minFilter:de,magFilter:de}:{};W.map!==null&&W.map.dispose(),W.map=new cn(s.x,s.y,Q),W.map.texture.name=$.name+".shadowMap",W.camera.updateProjectionMatrix()}i.setRenderTarget(W.map),i.clear();let Z=W.getViewportCount();for(let Q=0;Q<Z;Q++){let ut=W.getViewport(Q);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),O.viewport(a),W.updateMatrices($,Q),n=W.getFrustum(),w(b,R,W.camera,$,this.type)}W.isPointLightShadow!==!0&&this.type===rn&&v(W,R),W.needsUpdate=!1}u=this.type,m.needsUpdate=!1,i.setRenderTarget(I,y,T)};function v(M,b){let R=t.update(x);f.defines.VSM_SAMPLES!==M.blurSamples&&(f.defines.VSM_SAMPLES=M.blurSamples,p.defines.VSM_SAMPLES=M.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new cn(s.x,s.y)),f.uniforms.shadow_pass.value=M.map.texture,f.uniforms.resolution.value=M.mapSize,f.uniforms.radius.value=M.radius,i.setRenderTarget(M.mapPass),i.clear(),i.renderBufferDirect(b,null,R,f,x,null),p.uniforms.shadow_pass.value=M.mapPass.texture,p.uniforms.resolution.value=M.mapSize,p.uniforms.radius.value=M.radius,i.setRenderTarget(M.map),i.clear(),i.renderBufferDirect(b,null,R,p,x,null)}function _(M,b,R,I){let y=null,T=R.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(T!==void 0)y=T;else if(y=R.isPointLight===!0?c:o,i.localClippingEnabled&&b.clipShadows===!0&&Array.isArray(b.clippingPlanes)&&b.clippingPlanes.length!==0||b.displacementMap&&b.displacementScale!==0||b.alphaMap&&b.alphaTest>0||b.map&&b.alphaTest>0){let O=y.uuid,z=b.uuid,U=l[O];U===void 0&&(U={},l[O]=U);let N=U[z];N===void 0&&(N=y.clone(),U[z]=N),y=N}if(y.visible=b.visible,y.wireframe=b.wireframe,I===rn?y.side=b.shadowSide!==null?b.shadowSide:b.side:y.side=b.shadowSide!==null?b.shadowSide:d[b.side],y.alphaMap=b.alphaMap,y.alphaTest=b.alphaTest,y.map=b.map,y.clipShadows=b.clipShadows,y.clippingPlanes=b.clippingPlanes,y.clipIntersection=b.clipIntersection,y.displacementMap=b.displacementMap,y.displacementScale=b.displacementScale,y.displacementBias=b.displacementBias,y.wireframeLinewidth=b.wireframeLinewidth,y.linewidth=b.linewidth,R.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let O=i.properties.get(y);O.light=R}return y}function w(M,b,R,I,y){if(M.visible===!1)return;if(M.layers.test(b.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&y===rn)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,M.matrixWorld);let z=t.update(M),U=M.material;if(Array.isArray(U)){let N=z.groups;for(let B=0,$=N.length;B<$;B++){let W=N[B],X=U[W.materialIndex];if(X&&X.visible){let Z=_(M,X,I,y);i.renderBufferDirect(R,null,z,Z,M,W)}}}else if(U.visible){let N=_(M,U,I,y);i.renderBufferDirect(R,null,z,N,M,null)}}let O=M.children;for(let z=0,U=O.length;z<U;z++)w(O[z],b,R,I,y)}}function _p(i,t,e){let n=e.isWebGL2;function s(){let C=!1,H=new $t,K=null,ot=new $t(0,0,0,0);return{setMask:function(ht){K!==ht&&!C&&(i.colorMask(ht,ht,ht,ht),K=ht)},setLocked:function(ht){C=ht},setClear:function(ht,kt,Vt,oe,fn){fn===!0&&(ht*=oe,kt*=oe,Vt*=oe),H.set(ht,kt,Vt,oe),ot.equals(H)===!1&&(i.clearColor(ht,kt,Vt,oe),ot.copy(H))},reset:function(){C=!1,K=null,ot.set(-1,0,0,0)}}}function r(){let C=!1,H=null,K=null,ot=null;return{setTest:function(ht){ht?L(i.DEPTH_TEST):bt(i.DEPTH_TEST)},setMask:function(ht){H!==ht&&!C&&(i.depthMask(ht),H=ht)},setFunc:function(ht){if(K!==ht){switch(ht){case jc:i.depthFunc(i.NEVER);break;case Qc:i.depthFunc(i.ALWAYS);break;case tl:i.depthFunc(i.LESS);break;case Rr:i.depthFunc(i.LEQUAL);break;case el:i.depthFunc(i.EQUAL);break;case nl:i.depthFunc(i.GEQUAL);break;case il:i.depthFunc(i.GREATER);break;case sl:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}K=ht}},setLocked:function(ht){C=ht},setClear:function(ht){ot!==ht&&(i.clearDepth(ht),ot=ht)},reset:function(){C=!1,H=null,K=null,ot=null}}}function a(){let C=!1,H=null,K=null,ot=null,ht=null,kt=null,Vt=null,oe=null,fn=null;return{setTest:function(qt){C||(qt?L(i.STENCIL_TEST):bt(i.STENCIL_TEST))},setMask:function(qt){H!==qt&&!C&&(i.stencilMask(qt),H=qt)},setFunc:function(qt,Ce,Xe){(K!==qt||ot!==Ce||ht!==Xe)&&(i.stencilFunc(qt,Ce,Xe),K=qt,ot=Ce,ht=Xe)},setOp:function(qt,Ce,Xe){(kt!==qt||Vt!==Ce||oe!==Xe)&&(i.stencilOp(qt,Ce,Xe),kt=qt,Vt=Ce,oe=Xe)},setLocked:function(qt){C=qt},setClear:function(qt){fn!==qt&&(i.clearStencil(qt),fn=qt)},reset:function(){C=!1,H=null,K=null,ot=null,ht=null,kt=null,Vt=null,oe=null,fn=null}}}let o=new s,c=new r,l=new a,h=new WeakMap,d=new WeakMap,f={},p={},g=new WeakMap,x=[],m=null,u=!1,v=null,_=null,w=null,M=null,b=null,R=null,I=null,y=!1,T=null,O=null,z=null,U=null,N=null,B=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),$=!1,W=0,X=i.getParameter(i.VERSION);X.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\\d)/.exec(X)[1]),$=W>=1):X.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\\d)/.exec(X)[1]),$=W>=2);let Z=null,Q={},ut=i.getParameter(i.SCISSOR_BOX),at=i.getParameter(i.VIEWPORT),V=new $t().fromArray(ut),J=new $t().fromArray(at);function it(C,H,K,ot){let ht=new Uint8Array(4),kt=i.createTexture();i.bindTexture(C,kt),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Vt=0;Vt<K;Vt++)n&&(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)?i.texImage3D(H,0,i.RGBA,1,1,ot,0,i.RGBA,i.UNSIGNED_BYTE,ht):i.texImage2D(H+Vt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ht);return kt}let rt={};rt[i.TEXTURE_2D]=it(i.TEXTURE_2D,i.TEXTURE_2D,1),rt[i.TEXTURE_CUBE_MAP]=it(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(rt[i.TEXTURE_2D_ARRAY]=it(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),rt[i.TEXTURE_3D]=it(i.TEXTURE_3D,i.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),l.setClear(0),L(i.DEPTH_TEST),c.setFunc(Rr),re(!1),ee(Lo),L(i.CULL_FACE),Pt(xn);function L(C){f[C]!==!0&&(i.enable(C),f[C]=!0)}function bt(C){f[C]!==!1&&(i.disable(C),f[C]=!1)}function Mt(C,H){return p[C]!==H?(i.bindFramebuffer(C,H),p[C]=H,n&&(C===i.DRAW_FRAMEBUFFER&&(p[i.FRAMEBUFFER]=H),C===i.FRAMEBUFFER&&(p[i.DRAW_FRAMEBUFFER]=H)),!0):!1}function nt(C,H){let K=x,ot=!1;if(C)if(K=g.get(H),K===void 0&&(K=[],g.set(H,K)),C.isWebGLMultipleRenderTargets){let ht=C.texture;if(K.length!==ht.length||K[0]!==i.COLOR_ATTACHMENT0){for(let kt=0,Vt=ht.length;kt<Vt;kt++)K[kt]=i.COLOR_ATTACHMENT0+kt;K.length=ht.length,ot=!0}}else K[0]!==i.COLOR_ATTACHMENT0&&(K[0]=i.COLOR_ATTACHMENT0,ot=!0);else K[0]!==i.BACK&&(K[0]=i.BACK,ot=!0);ot&&(e.isWebGL2?i.drawBuffers(K):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(K))}function yt(C){return m!==C?(i.useProgram(C),m=C,!0):!1}let Ft={[ai]:i.FUNC_ADD,[Vc]:i.FUNC_SUBTRACT,[Hc]:i.FUNC_REVERSE_SUBTRACT};if(n)Ft[No]=i.MIN,Ft[Fo]=i.MAX;else{let C=t.get("EXT_blend_minmax");C!==null&&(Ft[No]=C.MIN_EXT,Ft[Fo]=C.MAX_EXT)}let pt={[Gc]:i.ZERO,[Wc]:i.ONE,[Xc]:i.SRC_COLOR,[Ka]:i.SRC_ALPHA,[Kc]:i.SRC_ALPHA_SATURATE,[Jc]:i.DST_COLOR,[Yc]:i.DST_ALPHA,[qc]:i.ONE_MINUS_SRC_COLOR,[ja]:i.ONE_MINUS_SRC_ALPHA,[$c]:i.ONE_MINUS_DST_COLOR,[Zc]:i.ONE_MINUS_DST_ALPHA};function Pt(C,H,K,ot,ht,kt,Vt,oe){if(C===xn){u===!0&&(bt(i.BLEND),u=!1);return}if(u===!1&&(L(i.BLEND),u=!0),C!==kc){if(C!==v||oe!==y){if((_!==ai||b!==ai)&&(i.blendEquation(i.FUNC_ADD),_=ai,b=ai),oe)switch(C){case hi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Io:i.blendFunc(i.ONE,i.ONE);break;case Uo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Do:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}else switch(C){case hi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Io:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Uo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Do:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}w=null,M=null,R=null,I=null,v=C,y=oe}return}ht=ht||H,kt=kt||K,Vt=Vt||ot,(H!==_||ht!==b)&&(i.blendEquationSeparate(Ft[H],Ft[ht]),_=H,b=ht),(K!==w||ot!==M||kt!==R||Vt!==I)&&(i.blendFuncSeparate(pt[K],pt[ot],pt[kt],pt[Vt]),w=K,M=ot,R=kt,I=Vt),v=C,y=!1}function te(C,H){C.side===ze?bt(i.CULL_FACE):L(i.CULL_FACE);let K=C.side===le;H&&(K=!K),re(K),C.blending===hi&&C.transparent===!1?Pt(xn):Pt(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.premultipliedAlpha),c.setFunc(C.depthFunc),c.setTest(C.depthTest),c.setMask(C.depthWrite),o.setMask(C.colorWrite);let ot=C.stencilWrite;l.setTest(ot),ot&&(l.setMask(C.stencilWriteMask),l.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),l.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),Ot(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?L(i.SAMPLE_ALPHA_TO_COVERAGE):bt(i.SAMPLE_ALPHA_TO_COVERAGE)}function re(C){T!==C&&(C?i.frontFace(i.CW):i.frontFace(i.CCW),T=C)}function ee(C){C!==Oc?(L(i.CULL_FACE),C!==O&&(C===Lo?i.cullFace(i.BACK):C===Bc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):bt(i.CULL_FACE),O=C}function Jt(C){C!==z&&($&&i.lineWidth(C),z=C)}function Ot(C,H,K){C?(L(i.POLYGON_OFFSET_FILL),(U!==H||N!==K)&&(i.polygonOffset(H,K),U=H,N=K)):bt(i.POLYGON_OFFSET_FILL)}function Wt(C){C?L(i.SCISSOR_TEST):bt(i.SCISSOR_TEST)}function _e(C){C===void 0&&(C=i.TEXTURE0+B-1),Z!==C&&(i.activeTexture(C),Z=C)}function A(C,H,K){K===void 0&&(Z===null?K=i.TEXTURE0+B-1:K=Z);let ot=Q[K];ot===void 0&&(ot={type:void 0,texture:void 0},Q[K]=ot),(ot.type!==C||ot.texture!==H)&&(Z!==K&&(i.activeTexture(K),Z=K),i.bindTexture(C,H||rt[C]),ot.type=C,ot.texture=H)}function S(){let C=Q[Z];C!==void 0&&C.type!==void 0&&(i.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function k(){try{i.compressedTexImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function j(){try{i.compressedTexImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function tt(){try{i.texSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function st(){try{i.texSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function vt(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function lt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function q(){try{i.texStorage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ft(){try{i.texStorage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function mt(){try{i.texImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function _t(){try{i.texImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ct(C){V.equals(C)===!1&&(i.scissor(C.x,C.y,C.z,C.w),V.copy(C))}function dt(C){J.equals(C)===!1&&(i.viewport(C.x,C.y,C.z,C.w),J.copy(C))}function It(C,H){let K=d.get(H);K===void 0&&(K=new WeakMap,d.set(H,K));let ot=K.get(C);ot===void 0&&(ot=i.getUniformBlockIndex(H,C.name),K.set(C,ot))}function Bt(C,H){let ot=d.get(H).get(C);h.get(H)!==ot&&(i.uniformBlockBinding(H,ot,C.__bindingPointIndex),h.set(H,ot))}function Xt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),n===!0&&(i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),f={},Z=null,Q={},p={},g=new WeakMap,x=[],m=null,u=!1,v=null,_=null,w=null,M=null,b=null,R=null,I=null,y=!1,T=null,O=null,z=null,U=null,N=null,V.set(0,0,i.canvas.width,i.canvas.height),J.set(0,0,i.canvas.width,i.canvas.height),o.reset(),c.reset(),l.reset()}return{buffers:{color:o,depth:c,stencil:l},enable:L,disable:bt,bindFramebuffer:Mt,drawBuffers:nt,useProgram:yt,setBlending:Pt,setMaterial:te,setFlipSided:re,setCullFace:ee,setLineWidth:Jt,setPolygonOffset:Ot,setScissorTest:Wt,activeTexture:_e,bindTexture:A,unbindTexture:S,compressedTexImage2D:k,compressedTexImage3D:j,texImage2D:mt,texImage3D:_t,updateUBOMapping:It,uniformBlockBinding:Bt,texStorage2D:q,texStorage3D:ft,texSubImage2D:tt,texSubImage3D:st,compressedTexSubImage2D:vt,compressedTexSubImage3D:lt,scissor:ct,viewport:dt,reset:Xt}}function xp(i,t,e,n,s,r,a){let o=s.isWebGL2,c=s.maxTextures,l=s.maxCubemapSize,h=s.maxTextureSize,d=s.maxSamples,f=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,x,m=new WeakMap,u=!1;try{u=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(A){}function v(A,S){return u?new OffscreenCanvas(A,S):bs("canvas")}function _(A,S,k,j){let tt=1;if((A.width>j||A.height>j)&&(tt=j/Math.max(A.width,A.height)),tt<1||S===!0)if(typeof HTMLImageElement!="undefined"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&A instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&A instanceof ImageBitmap){let st=S?Dl:Math.floor,vt=st(tt*A.width),lt=st(tt*A.height);x===void 0&&(x=v(vt,lt));let q=k?v(vt,lt):x;return q.width=vt,q.height=lt,q.getContext("2d").drawImage(A,0,0,vt,lt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+A.width+"x"+A.height+") to ("+vt+"x"+lt+")."),q}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+A.width+"x"+A.height+")."),A;return A}function w(A){return fa(A.width)&&fa(A.height)}function M(A){return o?!1:A.wrapS!==ke||A.wrapT!==ke||A.minFilter!==de&&A.minFilter!==Le}function b(A,S){return A.generateMipmaps&&S&&A.minFilter!==de&&A.minFilter!==Le}function R(A){i.generateMipmap(A)}function I(A,S,k,j,tt=!1){if(o===!1)return S;if(A!==null){if(i[A]!==void 0)return i[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'"+A+"\'")}let st=S;return S===i.RED&&(k===i.FLOAT&&(st=i.R32F),k===i.HALF_FLOAT&&(st=i.R16F),k===i.UNSIGNED_BYTE&&(st=i.R8)),S===i.RG&&(k===i.FLOAT&&(st=i.RG32F),k===i.HALF_FLOAT&&(st=i.RG16F),k===i.UNSIGNED_BYTE&&(st=i.RG8)),S===i.RGBA&&(k===i.FLOAT&&(st=i.RGBA32F),k===i.HALF_FLOAT&&(st=i.RGBA16F),k===i.UNSIGNED_BYTE&&(st=j===Et&&tt===!1?i.SRGB8_ALPHA8:i.RGBA8),k===i.UNSIGNED_SHORT_4_4_4_4&&(st=i.RGBA4),k===i.UNSIGNED_SHORT_5_5_5_1&&(st=i.RGB5_A1)),(st===i.R16F||st===i.R32F||st===i.RG16F||st===i.RG32F||st===i.RGBA16F||st===i.RGBA32F)&&t.get("EXT_color_buffer_float"),st}function y(A,S,k){return b(A,k)===!0||A.isFramebufferTexture&&A.minFilter!==de&&A.minFilter!==Le?Math.log2(Math.max(S.width,S.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?S.mipmaps.length:1}function T(A){return A===de||A===Oo||A===js?i.NEAREST:i.LINEAR}function O(A){let S=A.target;S.removeEventListener("dispose",O),U(S),S.isVideoTexture&&g.delete(S)}function z(A){let S=A.target;S.removeEventListener("dispose",z),B(S)}function U(A){let S=n.get(A);if(S.__webglInit===void 0)return;let k=A.source,j=m.get(k);if(j){let tt=j[S.__cacheKey];tt.usedTimes--,tt.usedTimes===0&&N(A),Object.keys(j).length===0&&m.delete(k)}n.remove(A)}function N(A){let S=n.get(A);i.deleteTexture(S.__webglTexture);let k=A.source,j=m.get(k);delete j[S.__cacheKey],a.memory.textures--}function B(A){let S=A.texture,k=n.get(A),j=n.get(S);if(j.__webglTexture!==void 0&&(i.deleteTexture(j.__webglTexture),a.memory.textures--),A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let tt=0;tt<6;tt++)i.deleteFramebuffer(k.__webglFramebuffer[tt]),k.__webglDepthbuffer&&i.deleteRenderbuffer(k.__webglDepthbuffer[tt]);else{if(i.deleteFramebuffer(k.__webglFramebuffer),k.__webglDepthbuffer&&i.deleteRenderbuffer(k.__webglDepthbuffer),k.__webglMultisampledFramebuffer&&i.deleteFramebuffer(k.__webglMultisampledFramebuffer),k.__webglColorRenderbuffer)for(let tt=0;tt<k.__webglColorRenderbuffer.length;tt++)k.__webglColorRenderbuffer[tt]&&i.deleteRenderbuffer(k.__webglColorRenderbuffer[tt]);k.__webglDepthRenderbuffer&&i.deleteRenderbuffer(k.__webglDepthRenderbuffer)}if(A.isWebGLMultipleRenderTargets)for(let tt=0,st=S.length;tt<st;tt++){let vt=n.get(S[tt]);vt.__webglTexture&&(i.deleteTexture(vt.__webglTexture),a.memory.textures--),n.remove(S[tt])}n.remove(S),n.remove(A)}let $=0;function W(){$=0}function X(){let A=$;return A>=c&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+c),$+=1,A}function Z(A){let S=[];return S.push(A.wrapS),S.push(A.wrapT),S.push(A.wrapR||0),S.push(A.magFilter),S.push(A.minFilter),S.push(A.anisotropy),S.push(A.internalFormat),S.push(A.format),S.push(A.type),S.push(A.generateMipmaps),S.push(A.premultiplyAlpha),S.push(A.flipY),S.push(A.unpackAlignment),S.push(A.colorSpace),S.join()}function Q(A,S){let k=n.get(A);if(A.isVideoTexture&&Wt(A),A.isRenderTargetTexture===!1&&A.version>0&&k.__version!==A.version){let j=A.image;if(j===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{bt(k,A,S);return}}e.bindTexture(i.TEXTURE_2D,k.__webglTexture,i.TEXTURE0+S)}function ut(A,S){let k=n.get(A);if(A.version>0&&k.__version!==A.version){bt(k,A,S);return}e.bindTexture(i.TEXTURE_2D_ARRAY,k.__webglTexture,i.TEXTURE0+S)}function at(A,S){let k=n.get(A);if(A.version>0&&k.__version!==A.version){bt(k,A,S);return}e.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+S)}function V(A,S){let k=n.get(A);if(A.version>0&&k.__version!==A.version){Mt(k,A,S);return}e.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture,i.TEXTURE0+S)}let J={[Lr]:i.REPEAT,[ke]:i.CLAMP_TO_EDGE,[Ir]:i.MIRRORED_REPEAT},it={[de]:i.NEAREST,[Oo]:i.NEAREST_MIPMAP_NEAREST,[js]:i.NEAREST_MIPMAP_LINEAR,[Le]:i.LINEAR,[fl]:i.LINEAR_MIPMAP_NEAREST,[ki]:i.LINEAR_MIPMAP_LINEAR};function rt(A,S,k){if(k?(i.texParameteri(A,i.TEXTURE_WRAP_S,J[S.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,J[S.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,J[S.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,it[S.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,it[S.minFilter])):(i.texParameteri(A,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(A,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(S.wrapS!==ke||S.wrapT!==ke)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(A,i.TEXTURE_MAG_FILTER,T(S.magFilter)),i.texParameteri(A,i.TEXTURE_MIN_FILTER,T(S.minFilter)),S.minFilter!==de&&S.minFilter!==Le&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let j=t.get("EXT_texture_filter_anisotropic");if(S.magFilter===de||S.minFilter!==js&&S.minFilter!==ki||S.type===Un&&t.has("OES_texture_float_linear")===!1||o===!1&&S.type===Vi&&t.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(i.texParameterf(A,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,s.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function L(A,S){let k=!1;A.__webglInit===void 0&&(A.__webglInit=!0,S.addEventListener("dispose",O));let j=S.source,tt=m.get(j);tt===void 0&&(tt={},m.set(j,tt));let st=Z(S);if(st!==A.__cacheKey){tt[st]===void 0&&(tt[st]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,k=!0),tt[st].usedTimes++;let vt=tt[A.__cacheKey];vt!==void 0&&(tt[A.__cacheKey].usedTimes--,vt.usedTimes===0&&N(S)),A.__cacheKey=st,A.__webglTexture=tt[st].texture}return k}function bt(A,S,k){let j=i.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(j=i.TEXTURE_2D_ARRAY),S.isData3DTexture&&(j=i.TEXTURE_3D);let tt=L(A,S),st=S.source;e.bindTexture(j,A.__webglTexture,i.TEXTURE0+k);let vt=n.get(st);if(st.version!==vt.__version||tt===!0){e.activeTexture(i.TEXTURE0+k),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,S.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,S.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let lt=M(S)&&w(S.image)===!1,q=_(S.image,lt,!1,h);q=_e(S,q);let ft=w(q)||o,mt=r.convert(S.format,S.colorSpace),_t=r.convert(S.type),ct=I(S.internalFormat,mt,_t,S.colorSpace);rt(j,S,ft);let dt,It=S.mipmaps,Bt=o&&S.isVideoTexture!==!0,Xt=vt.__version===void 0||tt===!0,C=y(S,q,ft);if(S.isDepthTexture)ct=i.DEPTH_COMPONENT,o?S.type===Un?ct=i.DEPTH_COMPONENT32F:S.type===In?ct=i.DEPTH_COMPONENT24:S.type===ui?ct=i.DEPTH24_STENCIL8:ct=i.DEPTH_COMPONENT16:S.type===Un&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===Dn&&ct===i.DEPTH_COMPONENT&&S.type!==ec&&S.type!==In&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=In,_t=r.convert(S.type)),S.format===gi&&ct===i.DEPTH_COMPONENT&&(ct=i.DEPTH_STENCIL,S.type!==ui&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=ui,_t=r.convert(S.type))),Xt&&(Bt?e.texStorage2D(i.TEXTURE_2D,1,ct,q.width,q.height):e.texImage2D(i.TEXTURE_2D,0,ct,q.width,q.height,0,mt,_t,null));else if(S.isDataTexture)if(It.length>0&&ft){Bt&&Xt&&e.texStorage2D(i.TEXTURE_2D,C,ct,It[0].width,It[0].height);for(let H=0,K=It.length;H<K;H++)dt=It[H],Bt?e.texSubImage2D(i.TEXTURE_2D,H,0,0,dt.width,dt.height,mt,_t,dt.data):e.texImage2D(i.TEXTURE_2D,H,ct,dt.width,dt.height,0,mt,_t,dt.data);S.generateMipmaps=!1}else Bt?(Xt&&e.texStorage2D(i.TEXTURE_2D,C,ct,q.width,q.height),e.texSubImage2D(i.TEXTURE_2D,0,0,0,q.width,q.height,mt,_t,q.data)):e.texImage2D(i.TEXTURE_2D,0,ct,q.width,q.height,0,mt,_t,q.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){Bt&&Xt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,C,ct,It[0].width,It[0].height,q.depth);for(let H=0,K=It.length;H<K;H++)dt=It[H],S.format!==Ve?mt!==null?Bt?e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,H,0,0,0,dt.width,dt.height,q.depth,mt,dt.data,0,0):e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,H,ct,dt.width,dt.height,q.depth,0,dt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?e.texSubImage3D(i.TEXTURE_2D_ARRAY,H,0,0,0,dt.width,dt.height,q.depth,mt,_t,dt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,H,ct,dt.width,dt.height,q.depth,0,mt,_t,dt.data)}else{Bt&&Xt&&e.texStorage2D(i.TEXTURE_2D,C,ct,It[0].width,It[0].height);for(let H=0,K=It.length;H<K;H++)dt=It[H],S.format!==Ve?mt!==null?Bt?e.compressedTexSubImage2D(i.TEXTURE_2D,H,0,0,dt.width,dt.height,mt,dt.data):e.compressedTexImage2D(i.TEXTURE_2D,H,ct,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?e.texSubImage2D(i.TEXTURE_2D,H,0,0,dt.width,dt.height,mt,_t,dt.data):e.texImage2D(i.TEXTURE_2D,H,ct,dt.width,dt.height,0,mt,_t,dt.data)}else if(S.isDataArrayTexture)Bt?(Xt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,C,ct,q.width,q.height,q.depth),e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,q.width,q.height,q.depth,mt,_t,q.data)):e.texImage3D(i.TEXTURE_2D_ARRAY,0,ct,q.width,q.height,q.depth,0,mt,_t,q.data);else if(S.isData3DTexture)Bt?(Xt&&e.texStorage3D(i.TEXTURE_3D,C,ct,q.width,q.height,q.depth),e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,q.width,q.height,q.depth,mt,_t,q.data)):e.texImage3D(i.TEXTURE_3D,0,ct,q.width,q.height,q.depth,0,mt,_t,q.data);else if(S.isFramebufferTexture){if(Xt)if(Bt)e.texStorage2D(i.TEXTURE_2D,C,ct,q.width,q.height);else{let H=q.width,K=q.height;for(let ot=0;ot<C;ot++)e.texImage2D(i.TEXTURE_2D,ot,ct,H,K,0,mt,_t,null),H>>=1,K>>=1}}else if(It.length>0&&ft){Bt&&Xt&&e.texStorage2D(i.TEXTURE_2D,C,ct,It[0].width,It[0].height);for(let H=0,K=It.length;H<K;H++)dt=It[H],Bt?e.texSubImage2D(i.TEXTURE_2D,H,0,0,mt,_t,dt):e.texImage2D(i.TEXTURE_2D,H,ct,mt,_t,dt);S.generateMipmaps=!1}else Bt?(Xt&&e.texStorage2D(i.TEXTURE_2D,C,ct,q.width,q.height),e.texSubImage2D(i.TEXTURE_2D,0,0,0,mt,_t,q)):e.texImage2D(i.TEXTURE_2D,0,ct,mt,_t,q);b(S,ft)&&R(j),vt.__version=st.version,S.onUpdate&&S.onUpdate(S)}A.__version=S.version}function Mt(A,S,k){if(S.image.length!==6)return;let j=L(A,S),tt=S.source;e.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+k);let st=n.get(tt);if(tt.version!==st.__version||j===!0){e.activeTexture(i.TEXTURE0+k),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,S.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,S.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let vt=S.isCompressedTexture||S.image[0].isCompressedTexture,lt=S.image[0]&&S.image[0].isDataTexture,q=[];for(let H=0;H<6;H++)!vt&&!lt?q[H]=_(S.image[H],!1,!0,l):q[H]=lt?S.image[H].image:S.image[H],q[H]=_e(S,q[H]);let ft=q[0],mt=w(ft)||o,_t=r.convert(S.format,S.colorSpace),ct=r.convert(S.type),dt=I(S.internalFormat,_t,ct,S.colorSpace),It=o&&S.isVideoTexture!==!0,Bt=st.__version===void 0||j===!0,Xt=y(S,ft,mt);rt(i.TEXTURE_CUBE_MAP,S,mt);let C;if(vt){It&&Bt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,Xt,dt,ft.width,ft.height);for(let H=0;H<6;H++){C=q[H].mipmaps;for(let K=0;K<C.length;K++){let ot=C[K];S.format!==Ve?_t!==null?It?e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K,0,0,ot.width,ot.height,_t,ot.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K,dt,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K,0,0,ot.width,ot.height,_t,ct,ot.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K,dt,ot.width,ot.height,0,_t,ct,ot.data)}}}else{C=S.mipmaps,It&&Bt&&(C.length>0&&Xt++,e.texStorage2D(i.TEXTURE_CUBE_MAP,Xt,dt,q[0].width,q[0].height));for(let H=0;H<6;H++)if(lt){It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,0,0,q[H].width,q[H].height,_t,ct,q[H].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,dt,q[H].width,q[H].height,0,_t,ct,q[H].data);for(let K=0;K<C.length;K++){let ht=C[K].image[H].image;It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K+1,0,0,ht.width,ht.height,_t,ct,ht.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K+1,dt,ht.width,ht.height,0,_t,ct,ht.data)}}else{It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,0,0,_t,ct,q[H]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,dt,_t,ct,q[H]);for(let K=0;K<C.length;K++){let ot=C[K];It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K+1,0,0,_t,ct,ot.image[H]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+H,K+1,dt,_t,ct,ot.image[H])}}}b(S,mt)&&R(i.TEXTURE_CUBE_MAP),st.__version=tt.version,S.onUpdate&&S.onUpdate(S)}A.__version=S.version}function nt(A,S,k,j,tt){let st=r.convert(k.format,k.colorSpace),vt=r.convert(k.type),lt=I(k.internalFormat,st,vt,k.colorSpace);n.get(S).__hasExternalTextures||(tt===i.TEXTURE_3D||tt===i.TEXTURE_2D_ARRAY?e.texImage3D(tt,0,lt,S.width,S.height,S.depth,0,st,vt,null):e.texImage2D(tt,0,lt,S.width,S.height,0,st,vt,null)),e.bindFramebuffer(i.FRAMEBUFFER,A),Ot(S)?f.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,tt,n.get(k).__webglTexture,0,Jt(S)):(tt===i.TEXTURE_2D||tt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&tt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,tt,n.get(k).__webglTexture,0),e.bindFramebuffer(i.FRAMEBUFFER,null)}function yt(A,S,k){if(i.bindRenderbuffer(i.RENDERBUFFER,A),S.depthBuffer&&!S.stencilBuffer){let j=i.DEPTH_COMPONENT16;if(k||Ot(S)){let tt=S.depthTexture;tt&&tt.isDepthTexture&&(tt.type===Un?j=i.DEPTH_COMPONENT32F:tt.type===In&&(j=i.DEPTH_COMPONENT24));let st=Jt(S);Ot(S)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st,j,S.width,S.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,st,j,S.width,S.height)}else i.renderbufferStorage(i.RENDERBUFFER,j,S.width,S.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,A)}else if(S.depthBuffer&&S.stencilBuffer){let j=Jt(S);k&&Ot(S)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,S.width,S.height):Ot(S)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,S.width,S.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,A)}else{let j=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let tt=0;tt<j.length;tt++){let st=j[tt],vt=r.convert(st.format,st.colorSpace),lt=r.convert(st.type),q=I(st.internalFormat,vt,lt,st.colorSpace),ft=Jt(S);k&&Ot(S)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft,q,S.width,S.height):Ot(S)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft,q,S.width,S.height):i.renderbufferStorage(i.RENDERBUFFER,q,S.width,S.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ft(A,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,A),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),Q(S.depthTexture,0);let j=n.get(S.depthTexture).__webglTexture,tt=Jt(S);if(S.depthTexture.format===Dn)Ot(S)?f.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0,tt):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0);else if(S.depthTexture.format===gi)Ot(S)?f.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0,tt):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0);else throw new Error("Unknown depthTexture format")}function pt(A){let S=n.get(A),k=A.isWebGLCubeRenderTarget===!0;if(A.depthTexture&&!S.__autoAllocateDepthBuffer){if(k)throw new Error("target.depthTexture not supported in Cube render targets");Ft(S.__webglFramebuffer,A)}else if(k){S.__webglDepthbuffer=[];for(let j=0;j<6;j++)e.bindFramebuffer(i.FRAMEBUFFER,S.__webglFramebuffer[j]),S.__webglDepthbuffer[j]=i.createRenderbuffer(),yt(S.__webglDepthbuffer[j],A,!1)}else e.bindFramebuffer(i.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=i.createRenderbuffer(),yt(S.__webglDepthbuffer,A,!1);e.bindFramebuffer(i.FRAMEBUFFER,null)}function Pt(A,S,k){let j=n.get(A);S!==void 0&&nt(j.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D),k!==void 0&&pt(A)}function te(A){let S=A.texture,k=n.get(A),j=n.get(S);A.addEventListener("dispose",z),A.isWebGLMultipleRenderTargets!==!0&&(j.__webglTexture===void 0&&(j.__webglTexture=i.createTexture()),j.__version=S.version,a.memory.textures++);let tt=A.isWebGLCubeRenderTarget===!0,st=A.isWebGLMultipleRenderTargets===!0,vt=w(A)||o;if(tt){k.__webglFramebuffer=[];for(let lt=0;lt<6;lt++)k.__webglFramebuffer[lt]=i.createFramebuffer()}else{if(k.__webglFramebuffer=i.createFramebuffer(),st)if(s.drawBuffers){let lt=A.texture;for(let q=0,ft=lt.length;q<ft;q++){let mt=n.get(lt[q]);mt.__webglTexture===void 0&&(mt.__webglTexture=i.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&A.samples>0&&Ot(A)===!1){let lt=st?S:[S];k.__webglMultisampledFramebuffer=i.createFramebuffer(),k.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let q=0;q<lt.length;q++){let ft=lt[q];k.__webglColorRenderbuffer[q]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,k.__webglColorRenderbuffer[q]);let mt=r.convert(ft.format,ft.colorSpace),_t=r.convert(ft.type),ct=I(ft.internalFormat,mt,_t,ft.colorSpace,A.isXRRenderTarget===!0),dt=Jt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,dt,ct,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,k.__webglColorRenderbuffer[q])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(k.__webglDepthRenderbuffer=i.createRenderbuffer(),yt(k.__webglDepthRenderbuffer,A,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(tt){e.bindTexture(i.TEXTURE_CUBE_MAP,j.__webglTexture),rt(i.TEXTURE_CUBE_MAP,S,vt);for(let lt=0;lt<6;lt++)nt(k.__webglFramebuffer[lt],A,S,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+lt);b(S,vt)&&R(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(st){let lt=A.texture;for(let q=0,ft=lt.length;q<ft;q++){let mt=lt[q],_t=n.get(mt);e.bindTexture(i.TEXTURE_2D,_t.__webglTexture),rt(i.TEXTURE_2D,mt,vt),nt(k.__webglFramebuffer,A,mt,i.COLOR_ATTACHMENT0+q,i.TEXTURE_2D),b(mt,vt)&&R(i.TEXTURE_2D)}e.unbindTexture()}else{let lt=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(o?lt=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(lt,j.__webglTexture),rt(lt,S,vt),nt(k.__webglFramebuffer,A,S,i.COLOR_ATTACHMENT0,lt),b(S,vt)&&R(lt),e.unbindTexture()}A.depthBuffer&&pt(A)}function re(A){let S=w(A)||o,k=A.isWebGLMultipleRenderTargets===!0?A.texture:[A.texture];for(let j=0,tt=k.length;j<tt;j++){let st=k[j];if(b(st,S)){let vt=A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,lt=n.get(st).__webglTexture;e.bindTexture(vt,lt),R(vt),e.unbindTexture()}}}function ee(A){if(o&&A.samples>0&&Ot(A)===!1){let S=A.isWebGLMultipleRenderTargets?A.texture:[A.texture],k=A.width,j=A.height,tt=i.COLOR_BUFFER_BIT,st=[],vt=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,lt=n.get(A),q=A.isWebGLMultipleRenderTargets===!0;if(q)for(let ft=0;ft<S.length;ft++)e.bindFramebuffer(i.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,lt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ft=0;ft<S.length;ft++){st.push(i.COLOR_ATTACHMENT0+ft),A.depthBuffer&&st.push(vt);let mt=lt.__ignoreDepthValues!==void 0?lt.__ignoreDepthValues:!1;if(mt===!1&&(A.depthBuffer&&(tt|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&(tt|=i.STENCIL_BUFFER_BIT)),q&&i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,lt.__webglColorRenderbuffer[ft]),mt===!0&&(i.invalidateFramebuffer(i.READ_FRAMEBUFFER,[vt]),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[vt])),q){let _t=n.get(S[ft]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,_t,0)}i.blitFramebuffer(0,0,k,j,0,0,k,j,tt,i.NEAREST),p&&i.invalidateFramebuffer(i.READ_FRAMEBUFFER,st)}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),q)for(let ft=0;ft<S.length;ft++){e.bindFramebuffer(i.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.RENDERBUFFER,lt.__webglColorRenderbuffer[ft]);let mt=n.get(S[ft]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,lt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.TEXTURE_2D,mt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}}function Jt(A){return Math.min(d,A.samples)}function Ot(A){let S=n.get(A);return o&&A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Wt(A){let S=a.render.frame;g.get(A)!==S&&(g.set(A,S),A.update())}function _e(A,S){let k=A.colorSpace,j=A.format,tt=A.type;return A.isCompressedTexture===!0||A.format===Ur||k!==Je&&k!==Fn&&(k===Et?o===!1?t.has("EXT_sRGB")===!0&&j===Ve?(A.format=Ur,A.minFilter=Le,A.generateMipmaps=!1):S=Es.sRGBToLinear(S):(j!==Ve||tt!==On)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),S}this.allocateTextureUnit=X,this.resetTextureUnits=W,this.setTexture2D=Q,this.setTexture2DArray=ut,this.setTexture3D=at,this.setTextureCube=V,this.rebindTextures=Pt,this.setupRenderTarget=te,this.updateRenderTargetMipmap=re,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=pt,this.setupFrameBufferTexture=nt,this.useMultisampledRTT=Ot}function yp(i,t,e){let n=e.isWebGL2;function s(r,a=Fn){let o;if(r===On)return i.UNSIGNED_BYTE;if(r===gl)return i.UNSIGNED_SHORT_4_4_4_4;if(r===_l)return i.UNSIGNED_SHORT_5_5_5_1;if(r===dl)return i.BYTE;if(r===pl)return i.SHORT;if(r===ec)return i.UNSIGNED_SHORT;if(r===ml)return i.INT;if(r===In)return i.UNSIGNED_INT;if(r===Un)return i.FLOAT;if(r===Vi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===xl)return i.ALPHA;if(r===Ve)return i.RGBA;if(r===yl)return i.LUMINANCE;if(r===vl)return i.LUMINANCE_ALPHA;if(r===Dn)return i.DEPTH_COMPONENT;if(r===gi)return i.DEPTH_STENCIL;if(r===Ur)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===Ml)return i.RED;if(r===Sl)return i.RED_INTEGER;if(r===bl)return i.RG;if(r===El)return i.RG_INTEGER;if(r===wl)return i.RGBA_INTEGER;if(r===Qs||r===tr||r===er||r===nr)if(a===Et)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===Qs)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===tr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===er)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===nr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===Qs)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===tr)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===er)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===nr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Bo||r===zo||r===ko||r===Vo)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Bo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===zo)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===ko)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Vo)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Tl)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Ho||r===Go)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===Ho)return a===Et?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===Go)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Wo||r===Xo||r===qo||r===Yo||r===Zo||r===Jo||r===$o||r===Ko||r===jo||r===Qo||r===ta||r===ea||r===na||r===ia)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===Wo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Xo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===qo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Yo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Zo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Jo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===$o)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Ko)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===jo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Qo)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ta)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ea)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===na)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===ia)return a===Et?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===ir)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(r===ir)return a===Et?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===Al||r===sa||r===ra||r===oa)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===ir)return o.COMPRESSED_RED_RGTC1_EXT;if(r===sa)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ra)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===oa)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===ui?n?i.UNSIGNED_INT_24_8:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):i[r]!==void 0?i[r]:null}return{convert:s}}var Zr=class extends Ae{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},li=class extends xe{constructor(){super(),this.isGroup=!0,this.type="Group"}},vp={type:"move"},zi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new li,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 li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let x of t.hand.values()){let m=e.getJointPose(x,n),u=this._getHandJoint(l,x);m!==null&&(u.matrix.fromArray(m.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=m.radius),u.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],f=h.position.distanceTo(d.position),p=.02,g=.005;l.inputState.pinching&&f>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vp)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new li;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Jr=class extends me{constructor(t,e,n,s,r,a,o,c,l,h){if(h=h!==void 0?h:Dn,h!==Dn&&h!==gi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Dn&&(n=In),n===void 0&&h===gi&&(n=ui),super(null,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:de,this.minFilter=c!==void 0?c:de,this.flipY=!1,this.generateMipmaps=!1}},$r=class extends yn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,f=null,p=null,g=null,x=e.getContextAttributes(),m=null,u=null,v=[],_=[],w=new Set,M=new Map,b=new Ae;b.layers.enable(1),b.viewport=new $t;let R=new Ae;R.layers.enable(2),R.viewport=new $t;let I=[b,R],y=new Zr;y.layers.enable(1),y.layers.enable(2);let T=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let J=v[V];return J===void 0&&(J=new zi,v[V]=J),J.getTargetRaySpace()},this.getControllerGrip=function(V){let J=v[V];return J===void 0&&(J=new zi,v[V]=J),J.getGripSpace()},this.getHand=function(V){let J=v[V];return J===void 0&&(J=new zi,v[V]=J),J.getHandSpace()};function z(V){let J=_.indexOf(V.inputSource);if(J===-1)return;let it=v[J];it!==void 0&&(it.update(V.inputSource,V.frame,l||a),it.dispatchEvent({type:V.type,data:V.inputSource}))}function U(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",U),s.removeEventListener("inputsourceschange",N);for(let V=0;V<v.length;V++){let J=_[V];J!==null&&(_[V]=null,v[V].disconnect(J))}T=null,O=null,t.setRenderTarget(m),p=null,f=null,d=null,s=null,u=null,at.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(V){r=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(V){o=V,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(V){l=V},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(V){if(s=V,s!==null){if(m=t.getRenderTarget(),s.addEventListener("select",z),s.addEventListener("selectstart",z),s.addEventListener("selectend",z),s.addEventListener("squeeze",z),s.addEventListener("squeezestart",z),s.addEventListener("squeezeend",z),s.addEventListener("end",U),s.addEventListener("inputsourceschange",N),x.xrCompatible!==!0&&await e.makeXRCompatible(),s.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let J={antialias:s.renderState.layers===void 0?x.antialias:!0,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,J),s.updateRenderState({baseLayer:p}),u=new cn(p.framebufferWidth,p.framebufferHeight,{format:Ve,type:On,colorSpace:t.outputColorSpace,stencilBuffer:x.stencil})}else{let J=null,it=null,rt=null;x.depth&&(rt=x.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,J=x.stencil?gi:Dn,it=x.stencil?ui:In);let L={colorFormat:e.RGBA8,depthFormat:rt,scaleFactor:r};d=new XRWebGLBinding(s,e),f=d.createProjectionLayer(L),s.updateRenderState({layers:[f]}),u=new cn(f.textureWidth,f.textureHeight,{format:Ve,type:On,depthTexture:new Jr(f.textureWidth,f.textureHeight,it,void 0,void 0,void 0,void 0,void 0,void 0,J),stencilBuffer:x.stencil,colorSpace:t.outputColorSpace,samples:x.antialias?4:0});let bt=t.properties.get(u);bt.__ignoreDepthValues=f.ignoreDepthValues}u.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),at.setContext(s),at.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode};function N(V){for(let J=0;J<V.removed.length;J++){let it=V.removed[J],rt=_.indexOf(it);rt>=0&&(_[rt]=null,v[rt].disconnect(it))}for(let J=0;J<V.added.length;J++){let it=V.added[J],rt=_.indexOf(it);if(rt===-1){for(let bt=0;bt<v.length;bt++)if(bt>=_.length){_.push(it),rt=bt;break}else if(_[bt]===null){_[bt]=it,rt=bt;break}if(rt===-1)break}let L=v[rt];L&&L.connect(it)}}let B=new P,$=new P;function W(V,J,it){B.setFromMatrixPosition(J.matrixWorld),$.setFromMatrixPosition(it.matrixWorld);let rt=B.distanceTo($),L=J.projectionMatrix.elements,bt=it.projectionMatrix.elements,Mt=L[14]/(L[10]-1),nt=L[14]/(L[10]+1),yt=(L[9]+1)/L[5],Ft=(L[9]-1)/L[5],pt=(L[8]-1)/L[0],Pt=(bt[8]+1)/bt[0],te=Mt*pt,re=Mt*Pt,ee=rt/(-pt+Pt),Jt=ee*-pt;J.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(Jt),V.translateZ(ee),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert();let Ot=Mt+ee,Wt=nt+ee,_e=te-Jt,A=re+(rt-Jt),S=yt*nt/Wt*Ot,k=Ft*nt/Wt*Ot;V.projectionMatrix.makePerspective(_e,A,S,k,Ot,Wt),V.projectionMatrixInverse.copy(V.projectionMatrix).invert()}function X(V,J){J===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(J.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(s===null)return;y.near=R.near=b.near=V.near,y.far=R.far=b.far=V.far,(T!==y.near||O!==y.far)&&(s.updateRenderState({depthNear:y.near,depthFar:y.far}),T=y.near,O=y.far);let J=V.parent,it=y.cameras;X(y,J);for(let rt=0;rt<it.length;rt++)X(it[rt],J);it.length===2?W(y,b,R):y.projectionMatrix.copy(b.projectionMatrix),Z(V,y,J)};function Z(V,J,it){it===null?V.matrix.copy(J.matrixWorld):(V.matrix.copy(it.matrixWorld),V.matrix.invert(),V.matrix.multiply(J.matrixWorld)),V.matrix.decompose(V.position,V.quaternion,V.scale),V.updateMatrixWorld(!0);let rt=V.children;for(let L=0,bt=rt.length;L<bt;L++)rt[L].updateMatrixWorld(!0);V.projectionMatrix.copy(J.projectionMatrix),V.projectionMatrixInverse.copy(J.projectionMatrixInverse),V.isPerspectiveCamera&&(V.fov=Dr*2*Math.atan(1/V.projectionMatrix.elements[5]),V.zoom=1)}this.getCamera=function(){return y},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(V){c=V,f!==null&&(f.fixedFoveation=V),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=V)},this.getPlanes=function(){return w};let Q=null;function ut(V,J){if(h=J.getViewerPose(l||a),g=J,h!==null){let it=h.views;p!==null&&(t.setRenderTargetFramebuffer(u,p.framebuffer),t.setRenderTarget(u));let rt=!1;it.length!==y.cameras.length&&(y.cameras.length=0,rt=!0);for(let L=0;L<it.length;L++){let bt=it[L],Mt=null;if(p!==null)Mt=p.getViewport(bt);else{let yt=d.getViewSubImage(f,bt);Mt=yt.viewport,L===0&&(t.setRenderTargetTextures(u,yt.colorTexture,f.ignoreDepthValues?void 0:yt.depthStencilTexture),t.setRenderTarget(u))}let nt=I[L];nt===void 0&&(nt=new Ae,nt.layers.enable(L),nt.viewport=new $t,I[L]=nt),nt.matrix.fromArray(bt.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(bt.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(Mt.x,Mt.y,Mt.width,Mt.height),L===0&&(y.matrix.copy(nt.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale)),rt===!0&&y.cameras.push(nt)}}for(let it=0;it<v.length;it++){let rt=_[it],L=v[it];rt!==null&&L!==void 0&&L.update(rt,J,l||a)}if(Q&&Q(V,J),J.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:J.detectedPlanes});let it=null;for(let rt of w)J.detectedPlanes.has(rt)||(it===null&&(it=[]),it.push(rt));if(it!==null)for(let rt of it)w.delete(rt),M.delete(rt),n.dispatchEvent({type:"planeremoved",data:rt});for(let rt of J.detectedPlanes)if(!w.has(rt))w.add(rt),M.set(rt,J.lastChangedTime),n.dispatchEvent({type:"planeadded",data:rt});else{let L=M.get(rt);rt.lastChangedTime>L&&(M.set(rt,rt.lastChangedTime),n.dispatchEvent({type:"planechanged",data:rt}))}}g=null}let at=new ac;at.setAnimationLoop(ut),this.setAnimationLoop=function(V){Q=V},this.dispose=function(){}}};function Mp(i,t){function e(m,u){m.matrixAutoUpdate===!0&&m.updateMatrix(),u.value.copy(m.matrix)}function n(m,u){u.color.getRGB(m.fogColor.value,oc(i)),u.isFog?(m.fogNear.value=u.near,m.fogFar.value=u.far):u.isFogExp2&&(m.fogDensity.value=u.density)}function s(m,u,v,_,w){u.isMeshBasicMaterial||u.isMeshLambertMaterial?r(m,u):u.isMeshToonMaterial?(r(m,u),d(m,u)):u.isMeshPhongMaterial?(r(m,u),h(m,u)):u.isMeshStandardMaterial?(r(m,u),f(m,u),u.isMeshPhysicalMaterial&&p(m,u,w)):u.isMeshMatcapMaterial?(r(m,u),g(m,u)):u.isMeshDepthMaterial?r(m,u):u.isMeshDistanceMaterial?(r(m,u),x(m,u)):u.isMeshNormalMaterial?r(m,u):u.isLineBasicMaterial?(a(m,u),u.isLineDashedMaterial&&o(m,u)):u.isPointsMaterial?c(m,u,v,_):u.isSpriteMaterial?l(m,u):u.isShadowMaterial?(m.color.value.copy(u.color),m.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function r(m,u){m.opacity.value=u.opacity,u.color&&m.diffuse.value.copy(u.color),u.emissive&&m.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(m.map.value=u.map,e(u.map,m.mapTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap,e(u.alphaMap,m.alphaMapTransform)),u.bumpMap&&(m.bumpMap.value=u.bumpMap,e(u.bumpMap,m.bumpMapTransform),m.bumpScale.value=u.bumpScale,u.side===le&&(m.bumpScale.value*=-1)),u.normalMap&&(m.normalMap.value=u.normalMap,e(u.normalMap,m.normalMapTransform),m.normalScale.value.copy(u.normalScale),u.side===le&&m.normalScale.value.negate()),u.displacementMap&&(m.displacementMap.value=u.displacementMap,e(u.displacementMap,m.displacementMapTransform),m.displacementScale.value=u.displacementScale,m.displacementBias.value=u.displacementBias),u.emissiveMap&&(m.emissiveMap.value=u.emissiveMap,e(u.emissiveMap,m.emissiveMapTransform)),u.specularMap&&(m.specularMap.value=u.specularMap,e(u.specularMap,m.specularMapTransform)),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest);let v=t.get(u).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=u.reflectivity,m.ior.value=u.ior,m.refractionRatio.value=u.refractionRatio),u.lightMap){m.lightMap.value=u.lightMap;let _=i.useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=u.lightMapIntensity*_,e(u.lightMap,m.lightMapTransform)}u.aoMap&&(m.aoMap.value=u.aoMap,m.aoMapIntensity.value=u.aoMapIntensity,e(u.aoMap,m.aoMapTransform))}function a(m,u){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,u.map&&(m.map.value=u.map,e(u.map,m.mapTransform))}function o(m,u){m.dashSize.value=u.dashSize,m.totalSize.value=u.dashSize+u.gapSize,m.scale.value=u.scale}function c(m,u,v,_){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,m.size.value=u.size*v,m.scale.value=_*.5,u.map&&(m.map.value=u.map,e(u.map,m.uvTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest)}function l(m,u){m.diffuse.value.copy(u.color),m.opacity.value=u.opacity,m.rotation.value=u.rotation,u.map&&(m.map.value=u.map,e(u.map,m.mapTransform)),u.alphaMap&&(m.alphaMap.value=u.alphaMap),u.alphaTest>0&&(m.alphaTest.value=u.alphaTest)}function h(m,u){m.specular.value.copy(u.specular),m.shininess.value=Math.max(u.shininess,1e-4)}function d(m,u){u.gradientMap&&(m.gradientMap.value=u.gradientMap)}function f(m,u){m.metalness.value=u.metalness,u.metalnessMap&&(m.metalnessMap.value=u.metalnessMap,e(u.metalnessMap,m.metalnessMapTransform)),m.roughness.value=u.roughness,u.roughnessMap&&(m.roughnessMap.value=u.roughnessMap,e(u.roughnessMap,m.roughnessMapTransform)),t.get(u).envMap&&(m.envMapIntensity.value=u.envMapIntensity)}function p(m,u,v){m.ior.value=u.ior,u.sheen>0&&(m.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),m.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(m.sheenColorMap.value=u.sheenColorMap,e(u.sheenColorMap,m.sheenColorMapTransform)),u.sheenRoughnessMap&&(m.sheenRoughnessMap.value=u.sheenRoughnessMap,e(u.sheenRoughnessMap,m.sheenRoughnessMapTransform))),u.clearcoat>0&&(m.clearcoat.value=u.clearcoat,m.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(m.clearcoatMap.value=u.clearcoatMap,e(u.clearcoatMap,m.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,e(u.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(m.clearcoatNormalMap.value=u.clearcoatNormalMap,e(u.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===le&&m.clearcoatNormalScale.value.negate())),u.iridescence>0&&(m.iridescence.value=u.iridescence,m.iridescenceIOR.value=u.iridescenceIOR,m.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(m.iridescenceMap.value=u.iridescenceMap,e(u.iridescenceMap,m.iridescenceMapTransform)),u.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=u.iridescenceThicknessMap,e(u.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),u.transmission>0&&(m.transmission.value=u.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),u.transmissionMap&&(m.transmissionMap.value=u.transmissionMap,e(u.transmissionMap,m.transmissionMapTransform)),m.thickness.value=u.thickness,u.thicknessMap&&(m.thicknessMap.value=u.thicknessMap,e(u.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=u.attenuationDistance,m.attenuationColor.value.copy(u.attenuationColor)),m.specularIntensity.value=u.specularIntensity,m.specularColor.value.copy(u.specularColor),u.specularColorMap&&(m.specularColorMap.value=u.specularColorMap,e(u.specularColorMap,m.specularColorMapTransform)),u.specularIntensityMap&&(m.specularIntensityMap.value=u.specularIntensityMap,e(u.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,u){u.matcap&&(m.matcap.value=u.matcap)}function x(m,u){let v=t.get(u).light;m.referencePosition.value.setFromMatrixPosition(v.matrixWorld),m.nearDistance.value=v.shadow.camera.near,m.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Sp(i,t,e,n){let s={},r={},a=[],o=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(v,_){let w=_.program;n.uniformBlockBinding(v,w)}function l(v,_){let w=s[v.id];w===void 0&&(g(v),w=h(v),s[v.id]=w,v.addEventListener("dispose",m));let M=_.program;n.updateUBOMapping(v,M);let b=t.render.frame;r[v.id]!==b&&(f(v),r[v.id]=b)}function h(v){let _=d();v.__bindingPointIndex=_;let w=i.createBuffer(),M=v.__size,b=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,M,b),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,w),w}function d(){for(let v=0;v<o;v++)if(a.indexOf(v)===-1)return a.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(v){let _=s[v.id],w=v.uniforms,M=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,_);for(let b=0,R=w.length;b<R;b++){let I=w[b];if(p(I,b,M)===!0){let y=I.__offset,T=Array.isArray(I.value)?I.value:[I.value],O=0;for(let z=0;z<T.length;z++){let U=T[z],N=x(U);typeof U=="number"?(I.__data[0]=U,i.bufferSubData(i.UNIFORM_BUFFER,y+O,I.__data)):U.isMatrix3?(I.__data[0]=U.elements[0],I.__data[1]=U.elements[1],I.__data[2]=U.elements[2],I.__data[3]=U.elements[0],I.__data[4]=U.elements[3],I.__data[5]=U.elements[4],I.__data[6]=U.elements[5],I.__data[7]=U.elements[0],I.__data[8]=U.elements[6],I.__data[9]=U.elements[7],I.__data[10]=U.elements[8],I.__data[11]=U.elements[0]):(U.toArray(I.__data,O),O+=N.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,y,I.__data)}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(v,_,w){let M=v.value;if(w[_]===void 0){if(typeof M=="number")w[_]=M;else{let b=Array.isArray(M)?M:[M],R=[];for(let I=0;I<b.length;I++)R.push(b[I].clone());w[_]=R}return!0}else if(typeof M=="number"){if(w[_]!==M)return w[_]=M,!0}else{let b=Array.isArray(w[_])?w[_]:[w[_]],R=Array.isArray(M)?M:[M];for(let I=0;I<b.length;I++){let y=b[I];if(y.equals(R[I])===!1)return y.copy(R[I]),!0}}return!1}function g(v){let _=v.uniforms,w=0,M=16,b=0;for(let R=0,I=_.length;R<I;R++){let y=_[R],T={boundary:0,storage:0},O=Array.isArray(y.value)?y.value:[y.value];for(let z=0,U=O.length;z<U;z++){let N=O[z],B=x(N);T.boundary+=B.boundary,T.storage+=B.storage}if(y.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),y.__offset=w,R>0){b=w%M;let z=M-b;b!==0&&z-T.boundary<0&&(w+=M-b,y.__offset=w)}w+=T.storage}return b=w%M,b>0&&(w+=M-b),v.__size=w,v.__cache={},this}function x(v){let _={boundary:0,storage:0};return typeof v=="number"?(_.boundary=4,_.storage=4):v.isVector2?(_.boundary=8,_.storage=8):v.isVector3||v.isColor?(_.boundary=16,_.storage=12):v.isVector4?(_.boundary=16,_.storage=16):v.isMatrix3?(_.boundary=48,_.storage=48):v.isMatrix4?(_.boundary=64,_.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),_}function m(v){let _=v.target;_.removeEventListener("dispose",m);let w=a.indexOf(_.__bindingPointIndex);a.splice(w,1),i.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function u(){for(let v in s)i.deleteBuffer(s[v]);a=[],s={},r={}}return{bind:c,update:l,dispose:u}}function bp(){let i=bs("canvas");return i.style.display="block",i}var Kr=class{constructor(t={}){let{canvas:e=bp(),context:n=null,depth:s=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=t;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=a;let p=null,g=null,x=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Et,this.useLegacyLights=!0,this.toneMapping=on,this.toneMappingExposure=1;let u=this,v=!1,_=0,w=0,M=null,b=-1,R=null,I=new $t,y=new $t,T=null,O=e.width,z=e.height,U=1,N=null,B=null,$=new $t(0,0,O,z),W=new $t(0,0,O,z),X=!1,Z=new Us,Q=!1,ut=!1,at=null,V=new Gt,J=new P,it={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function rt(){return M===null?U:1}let L=n;function bt(E,F){for(let G=0;G<E.length;G++){let D=E[G],Y=e.getContext(D,F);if(Y!==null)return Y}return null}try{let E={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${ao}`),e.addEventListener("webglcontextlost",dt,!1),e.addEventListener("webglcontextrestored",It,!1),e.addEventListener("webglcontextcreationerror",Bt,!1),L===null){let F=["webgl2","webgl","experimental-webgl"];if(u.isWebGL1Renderer===!0&&F.shift(),L=bt(F,E),L===null)throw bt(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}L.getShaderPrecisionFormat===void 0&&(L.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Mt,nt,yt,Ft,pt,Pt,te,re,ee,Jt,Ot,Wt,_e,A,S,k,j,tt,st,vt,lt,q,ft,mt;function _t(){Mt=new Wf(L),nt=new Bf(L,Mt,t),Mt.init(nt),q=new yp(L,Mt,nt),yt=new _p(L,Mt,nt),Ft=new Yf(L),pt=new rp,Pt=new xp(L,Mt,yt,pt,nt,q,Ft),te=new kf(u),re=new Gf(u),ee=new sh(L,nt),ft=new Ff(L,Mt,ee,nt),Jt=new Xf(L,ee,Ft,ft),Ot=new Kf(L,Jt,ee,Ft),st=new $f(L,nt,Pt),k=new zf(pt),Wt=new sp(u,te,re,Mt,nt,ft,k),_e=new Mp(u,pt),A=new ap,S=new dp(Mt,nt),tt=new Nf(u,te,re,yt,Ot,f,c),j=new gp(u,Ot,nt),mt=new Sp(L,Ft,nt,yt),vt=new Of(L,Mt,Ft,nt),lt=new qf(L,Mt,Ft,nt),Ft.programs=Wt.programs,u.capabilities=nt,u.extensions=Mt,u.properties=pt,u.renderLists=A,u.shadowMap=j,u.state=yt,u.info=Ft}_t();let ct=new $r(u,L);this.xr=ct,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let E=Mt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Mt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return U},this.setPixelRatio=function(E){E!==void 0&&(U=E,this.setSize(O,z,!1))},this.getSize=function(E){return E.set(O,z)},this.setSize=function(E,F,G=!0){if(ct.isPresenting){console.warn("THREE.WebGLRenderer: Can\'t change size while VR device is presenting.");return}O=E,z=F,e.width=Math.floor(E*U),e.height=Math.floor(F*U),G===!0&&(e.style.width=E+"px",e.style.height=F+"px"),this.setViewport(0,0,E,F)},this.getDrawingBufferSize=function(E){return E.set(O*U,z*U).floor()},this.setDrawingBufferSize=function(E,F,G){O=E,z=F,U=G,e.width=Math.floor(E*G),e.height=Math.floor(F*G),this.setViewport(0,0,E,F)},this.getCurrentViewport=function(E){return E.copy(I)},this.getViewport=function(E){return E.copy($)},this.setViewport=function(E,F,G,D){E.isVector4?$.set(E.x,E.y,E.z,E.w):$.set(E,F,G,D),yt.viewport(I.copy($).multiplyScalar(U).floor())},this.getScissor=function(E){return E.copy(W)},this.setScissor=function(E,F,G,D){E.isVector4?W.set(E.x,E.y,E.z,E.w):W.set(E,F,G,D),yt.scissor(y.copy(W).multiplyScalar(U).floor())},this.getScissorTest=function(){return X},this.setScissorTest=function(E){yt.setScissorTest(X=E)},this.setOpaqueSort=function(E){N=E},this.setTransparentSort=function(E){B=E},this.getClearColor=function(E){return E.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(E=!0,F=!0,G=!0){let D=0;E&&(D|=L.COLOR_BUFFER_BIT),F&&(D|=L.DEPTH_BUFFER_BIT),G&&(D|=L.STENCIL_BUFFER_BIT),L.clear(D)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",dt,!1),e.removeEventListener("webglcontextrestored",It,!1),e.removeEventListener("webglcontextcreationerror",Bt,!1),A.dispose(),S.dispose(),pt.dispose(),te.dispose(),re.dispose(),Ot.dispose(),ft.dispose(),mt.dispose(),Wt.dispose(),ct.dispose(),ct.removeEventListener("sessionstart",ht),ct.removeEventListener("sessionend",kt),at&&(at.dispose(),at=null),Vt.stop()};function dt(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function It(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;let E=Ft.autoReset,F=j.enabled,G=j.autoUpdate,D=j.needsUpdate,Y=j.type;_t(),Ft.autoReset=E,j.enabled=F,j.autoUpdate=G,j.needsUpdate=D,j.type=Y}function Bt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Xt(E){let F=E.target;F.removeEventListener("dispose",Xt),C(F)}function C(E){H(E),pt.remove(E)}function H(E){let F=pt.get(E).programs;F!==void 0&&(F.forEach(function(G){Wt.releaseProgram(G)}),E.isShaderMaterial&&Wt.releaseShaderCache(E))}this.renderBufferDirect=function(E,F,G,D,Y,gt){F===null&&(F=it);let xt=Y.isMesh&&Y.matrixWorld.determinant()<0,St=Rc(E,F,G,D,Y);yt.setMaterial(D,xt);let wt=G.index,At=1;D.wireframe===!0&&(wt=Jt.getWireframeAttribute(G),At=2);let Rt=G.drawRange,Lt=G.attributes.position,zt=Rt.start*At,he=(Rt.start+Rt.count)*At;gt!==null&&(zt=Math.max(zt,gt.start*At),he=Math.min(he,(gt.start+gt.count)*At)),wt!==null?(zt=Math.max(zt,0),he=Math.min(he,wt.count)):Lt!=null&&(zt=Math.max(zt,0),he=Math.min(he,Lt.count));let De=he-zt;if(De<0||De===1/0)return;ft.setup(Y,D,St,G,wt);let En,Yt=vt;if(wt!==null&&(En=ee.get(wt),Yt=lt,Yt.setIndex(En)),Y.isMesh)D.wireframe===!0?(yt.setLineWidth(D.wireframeLinewidth*rt()),Yt.setMode(L.LINES)):Yt.setMode(L.TRIANGLES);else if(Y.isLine){let Ut=D.linewidth;Ut===void 0&&(Ut=1),yt.setLineWidth(Ut*rt()),Y.isLineSegments?Yt.setMode(L.LINES):Y.isLineLoop?Yt.setMode(L.LINE_LOOP):Yt.setMode(L.LINE_STRIP)}else Y.isPoints?Yt.setMode(L.POINTS):Y.isSprite&&Yt.setMode(L.TRIANGLES);if(Y.isInstancedMesh)Yt.renderInstances(zt,De,Y.count);else if(G.isInstancedBufferGeometry){let Ut=G._maxInstanceCount!==void 0?G._maxInstanceCount:1/0,Zs=Math.min(G.instanceCount,Ut);Yt.renderInstances(zt,De,Zs)}else Yt.render(zt,De)},this.compile=function(E,F){function G(D,Y,gt){D.transparent===!0&&D.side===ze&&D.forceSinglePass===!1?(D.side=le,D.needsUpdate=!0,$i(D,Y,gt),D.side=He,D.needsUpdate=!0,$i(D,Y,gt),D.side=ze):$i(D,Y,gt)}g=S.get(E),g.init(),m.push(g),E.traverseVisible(function(D){D.isLight&&D.layers.test(F.layers)&&(g.pushLight(D),D.castShadow&&g.pushShadow(D))}),g.setupLights(u.useLegacyLights),E.traverse(function(D){let Y=D.material;if(Y)if(Array.isArray(Y))for(let gt=0;gt<Y.length;gt++){let xt=Y[gt];G(xt,E,D)}else G(Y,E,D)}),m.pop(),g=null};let K=null;function ot(E){K&&K(E)}function ht(){Vt.stop()}function kt(){Vt.start()}let Vt=new ac;Vt.setAnimationLoop(ot),typeof self!="undefined"&&Vt.setContext(self),this.setAnimationLoop=function(E){K=E,ct.setAnimationLoop(E),E===null?Vt.stop():Vt.start()},ct.addEventListener("sessionstart",ht),ct.addEventListener("sessionend",kt),this.render=function(E,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),ct.enabled===!0&&ct.isPresenting===!0&&(ct.cameraAutoUpdate===!0&&ct.updateCamera(F),F=ct.getCamera()),E.isScene===!0&&E.onBeforeRender(u,E,F,M),g=S.get(E,m.length),g.init(),m.push(g),V.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Z.setFromProjectionMatrix(V),ut=this.localClippingEnabled,Q=k.init(this.clippingPlanes,ut),p=A.get(E,x.length),p.init(),x.push(p),oe(E,F,0,u.sortObjects),p.finish(),u.sortObjects===!0&&p.sort(N,B),Q===!0&&k.beginShadows();let G=g.state.shadowsArray;if(j.render(G,E,F),Q===!0&&k.endShadows(),this.info.autoReset===!0&&this.info.reset(),tt.render(p,E),g.setupLights(u.useLegacyLights),F.isArrayCamera){let D=F.cameras;for(let Y=0,gt=D.length;Y<gt;Y++){let xt=D[Y];fn(p,E,xt,xt.viewport)}}else fn(p,E,F);M!==null&&(Pt.updateMultisampleRenderTarget(M),Pt.updateRenderTargetMipmap(M)),E.isScene===!0&&E.onAfterRender(u,E,F),ft.resetDefaultState(),b=-1,R=null,m.pop(),m.length>0?g=m[m.length-1]:g=null,x.pop(),x.length>0?p=x[x.length-1]:p=null};function oe(E,F,G,D){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)G=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);else if(E.isLight)g.pushLight(E),E.castShadow&&g.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Z.intersectsSprite(E)){D&&J.setFromMatrixPosition(E.matrixWorld).applyMatrix4(V);let xt=Ot.update(E),St=E.material;St.visible&&p.push(E,xt,St,G,J.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Z.intersectsObject(E))){E.isSkinnedMesh&&E.skeleton.frame!==Ft.render.frame&&(E.skeleton.update(),E.skeleton.frame=Ft.render.frame);let xt=Ot.update(E),St=E.material;if(D&&(xt.boundingSphere===null&&xt.computeBoundingSphere(),J.copy(xt.boundingSphere.center).applyMatrix4(E.matrixWorld).applyMatrix4(V)),Array.isArray(St)){let wt=xt.groups;for(let At=0,Rt=wt.length;At<Rt;At++){let Lt=wt[At],zt=St[Lt.materialIndex];zt&&zt.visible&&p.push(E,xt,zt,G,J.z,Lt)}}else St.visible&&p.push(E,xt,St,G,J.z,null)}}let gt=E.children;for(let xt=0,St=gt.length;xt<St;xt++)oe(gt[xt],F,G,D)}function fn(E,F,G,D){let Y=E.opaque,gt=E.transmissive,xt=E.transparent;g.setupLightsView(G),Q===!0&&k.setGlobalState(u.clippingPlanes,G),gt.length>0&&qt(Y,gt,F,G),D&&yt.viewport(I.copy(D)),Y.length>0&&Ce(Y,F,G),gt.length>0&&Ce(gt,F,G),xt.length>0&&Ce(xt,F,G),yt.buffers.depth.setTest(!0),yt.buffers.depth.setMask(!0),yt.buffers.color.setMask(!0),yt.setPolygonOffset(!1)}function qt(E,F,G,D){if(at===null){let St=nt.isWebGL2;at=new cn(1024,1024,{generateMipmaps:!0,type:Mt.has("EXT_color_buffer_half_float")?Vi:On,minFilter:ki,samples:St&&o===!0?4:0})}let Y=u.getRenderTarget();u.setRenderTarget(at),u.clear();let gt=u.toneMapping;u.toneMapping=on,Ce(E,G,D),Pt.updateMultisampleRenderTarget(at),Pt.updateRenderTargetMipmap(at);let xt=!1;for(let St=0,wt=F.length;St<wt;St++){let At=F[St],Rt=At.object,Lt=At.geometry,zt=At.material,he=At.group;if(zt.side===ze&&Rt.layers.test(D.layers)){let De=zt.side;zt.side=le,zt.needsUpdate=!0,Xe(Rt,G,D,Lt,zt,he),zt.side=De,zt.needsUpdate=!0,xt=!0}}xt===!0&&(Pt.updateMultisampleRenderTarget(at),Pt.updateRenderTargetMipmap(at)),u.setRenderTarget(Y),u.toneMapping=gt}function Ce(E,F,G){let D=F.isScene===!0?F.overrideMaterial:null;for(let Y=0,gt=E.length;Y<gt;Y++){let xt=E[Y],St=xt.object,wt=xt.geometry,At=D===null?xt.material:D,Rt=xt.group;St.layers.test(G.layers)&&Xe(St,F,G,wt,At,Rt)}}function Xe(E,F,G,D,Y,gt){E.onBeforeRender(u,F,G,D,Y,gt),E.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),Y.onBeforeRender(u,F,G,D,E,gt),Y.transparent===!0&&Y.side===ze&&Y.forceSinglePass===!1?(Y.side=le,Y.needsUpdate=!0,u.renderBufferDirect(G,F,D,Y,E,gt),Y.side=He,Y.needsUpdate=!0,u.renderBufferDirect(G,F,D,Y,E,gt),Y.side=ze):u.renderBufferDirect(G,F,D,Y,E,gt),E.onAfterRender(u,F,G,D,Y,gt)}function $i(E,F,G){F.isScene!==!0&&(F=it);let D=pt.get(E),Y=g.state.lights,gt=g.state.shadowsArray,xt=Y.state.version,St=Wt.getParameters(E,Y.state,gt,F,G),wt=Wt.getProgramCacheKey(St),At=D.programs;D.environment=E.isMeshStandardMaterial?F.environment:null,D.fog=F.fog,D.envMap=(E.isMeshStandardMaterial?re:te).get(E.envMap||D.environment),At===void 0&&(E.addEventListener("dispose",Xt),At=new Map,D.programs=At);let Rt=At.get(wt);if(Rt!==void 0){if(D.currentProgram===Rt&&D.lightsStateVersion===xt)return wo(E,St),Rt}else St.uniforms=Wt.getUniforms(E),E.onBuild(G,St,u),E.onBeforeCompile(St,u),Rt=Wt.acquireProgram(St,wt),At.set(wt,Rt),D.uniforms=St.uniforms;let Lt=D.uniforms;(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Lt.clippingPlanes=k.uniform),wo(E,St),D.needsLights=Pc(E),D.lightsStateVersion=xt,D.needsLights&&(Lt.ambientLightColor.value=Y.state.ambient,Lt.lightProbe.value=Y.state.probe,Lt.directionalLights.value=Y.state.directional,Lt.directionalLightShadows.value=Y.state.directionalShadow,Lt.spotLights.value=Y.state.spot,Lt.spotLightShadows.value=Y.state.spotShadow,Lt.rectAreaLights.value=Y.state.rectArea,Lt.ltc_1.value=Y.state.rectAreaLTC1,Lt.ltc_2.value=Y.state.rectAreaLTC2,Lt.pointLights.value=Y.state.point,Lt.pointLightShadows.value=Y.state.pointShadow,Lt.hemisphereLights.value=Y.state.hemi,Lt.directionalShadowMap.value=Y.state.directionalShadowMap,Lt.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,Lt.spotShadowMap.value=Y.state.spotShadowMap,Lt.spotLightMatrix.value=Y.state.spotLightMatrix,Lt.spotLightMap.value=Y.state.spotLightMap,Lt.pointShadowMap.value=Y.state.pointShadowMap,Lt.pointShadowMatrix.value=Y.state.pointShadowMatrix);let zt=Rt.getUniforms(),he=di.seqWithValue(zt.seq,Lt);return D.currentProgram=Rt,D.uniformsList=he,Rt}function wo(E,F){let G=pt.get(E);G.outputColorSpace=F.outputColorSpace,G.instancing=F.instancing,G.skinning=F.skinning,G.morphTargets=F.morphTargets,G.morphNormals=F.morphNormals,G.morphColors=F.morphColors,G.morphTargetsCount=F.morphTargetsCount,G.numClippingPlanes=F.numClippingPlanes,G.numIntersection=F.numClipIntersection,G.vertexAlphas=F.vertexAlphas,G.vertexTangents=F.vertexTangents,G.toneMapping=F.toneMapping}function Rc(E,F,G,D,Y){F.isScene!==!0&&(F=it),Pt.resetTextureUnits();let gt=F.fog,xt=D.isMeshStandardMaterial?F.environment:null,St=M===null?u.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:Je,wt=(D.isMeshStandardMaterial?re:te).get(D.envMap||xt),At=D.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,Rt=!!D.normalMap&&!!G.attributes.tangent,Lt=!!G.morphAttributes.position,zt=!!G.morphAttributes.normal,he=!!G.morphAttributes.color,De=D.toneMapped?u.toneMapping:on,En=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Yt=En!==void 0?En.length:0,Ut=pt.get(D),Zs=g.state.lights;if(Q===!0&&(ut===!0||E!==R)){let be=E===R&&D.id===b;k.setState(D,E,be)}let ne=!1;D.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==Zs.state.version||Ut.outputColorSpace!==St||Y.isInstancedMesh&&Ut.instancing===!1||!Y.isInstancedMesh&&Ut.instancing===!0||Y.isSkinnedMesh&&Ut.skinning===!1||!Y.isSkinnedMesh&&Ut.skinning===!0||Ut.envMap!==wt||D.fog===!0&&Ut.fog!==gt||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==k.numPlanes||Ut.numIntersection!==k.numIntersection)||Ut.vertexAlphas!==At||Ut.vertexTangents!==Rt||Ut.morphTargets!==Lt||Ut.morphNormals!==zt||Ut.morphColors!==he||Ut.toneMapping!==De||nt.isWebGL2===!0&&Ut.morphTargetsCount!==Yt)&&(ne=!0):(ne=!0,Ut.__version=D.version);let wn=Ut.currentProgram;ne===!0&&(wn=$i(D,F,Y));let To=!1,Ii=!1,Js=!1,ue=wn.getUniforms(),Tn=Ut.uniforms;if(yt.useProgram(wn.program)&&(To=!0,Ii=!0,Js=!0),D.id!==b&&(b=D.id,Ii=!0),To||R!==E){if(ue.setValue(L,"projectionMatrix",E.projectionMatrix),nt.logarithmicDepthBuffer&&ue.setValue(L,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),R!==E&&(R=E,Ii=!0,Js=!0),D.isShaderMaterial||D.isMeshPhongMaterial||D.isMeshToonMaterial||D.isMeshStandardMaterial||D.envMap){let be=ue.map.cameraPosition;be!==void 0&&be.setValue(L,J.setFromMatrixPosition(E.matrixWorld))}(D.isMeshPhongMaterial||D.isMeshToonMaterial||D.isMeshLambertMaterial||D.isMeshBasicMaterial||D.isMeshStandardMaterial||D.isShaderMaterial)&&ue.setValue(L,"isOrthographic",E.isOrthographicCamera===!0),(D.isMeshPhongMaterial||D.isMeshToonMaterial||D.isMeshLambertMaterial||D.isMeshBasicMaterial||D.isMeshStandardMaterial||D.isShaderMaterial||D.isShadowMaterial||Y.isSkinnedMesh)&&ue.setValue(L,"viewMatrix",E.matrixWorldInverse)}if(Y.isSkinnedMesh){ue.setOptional(L,Y,"bindMatrix"),ue.setOptional(L,Y,"bindMatrixInverse");let be=Y.skeleton;be&&(nt.floatVertexTextures?(be.boneTexture===null&&be.computeBoneTexture(),ue.setValue(L,"boneTexture",be.boneTexture,Pt),ue.setValue(L,"boneTextureSize",be.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let $s=G.morphAttributes;if(($s.position!==void 0||$s.normal!==void 0||$s.color!==void 0&&nt.isWebGL2===!0)&&st.update(Y,G,wn),(Ii||Ut.receiveShadow!==Y.receiveShadow)&&(Ut.receiveShadow=Y.receiveShadow,ue.setValue(L,"receiveShadow",Y.receiveShadow)),D.isMeshGouraudMaterial&&D.envMap!==null&&(Tn.envMap.value=wt,Tn.flipEnvMap.value=wt.isCubeTexture&&wt.isRenderTargetTexture===!1?-1:1),Ii&&(ue.setValue(L,"toneMappingExposure",u.toneMappingExposure),Ut.needsLights&&Cc(Tn,Js),gt&&D.fog===!0&&_e.refreshFogUniforms(Tn,gt),_e.refreshMaterialUniforms(Tn,D,U,z,at),di.upload(L,Ut.uniformsList,Tn,Pt)),D.isShaderMaterial&&D.uniformsNeedUpdate===!0&&(di.upload(L,Ut.uniformsList,Tn,Pt),D.uniformsNeedUpdate=!1),D.isSpriteMaterial&&ue.setValue(L,"center",Y.center),ue.setValue(L,"modelViewMatrix",Y.modelViewMatrix),ue.setValue(L,"normalMatrix",Y.normalMatrix),ue.setValue(L,"modelMatrix",Y.matrixWorld),D.isShaderMaterial||D.isRawShaderMaterial){let be=D.uniformsGroups;for(let Ks=0,Lc=be.length;Ks<Lc;Ks++)if(nt.isWebGL2){let Ao=be[Ks];mt.update(Ao,wn),mt.bind(Ao,wn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return wn}function Cc(E,F){E.ambientLightColor.needsUpdate=F,E.lightProbe.needsUpdate=F,E.directionalLights.needsUpdate=F,E.directionalLightShadows.needsUpdate=F,E.pointLights.needsUpdate=F,E.pointLightShadows.needsUpdate=F,E.spotLights.needsUpdate=F,E.spotLightShadows.needsUpdate=F,E.rectAreaLights.needsUpdate=F,E.hemisphereLights.needsUpdate=F}function Pc(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(E,F,G){pt.get(E.texture).__webglTexture=F,pt.get(E.depthTexture).__webglTexture=G;let D=pt.get(E);D.__hasExternalTextures=!0,D.__hasExternalTextures&&(D.__autoAllocateDepthBuffer=G===void 0,D.__autoAllocateDepthBuffer||Mt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),D.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(E,F){let G=pt.get(E);G.__webglFramebuffer=F,G.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(E,F=0,G=0){M=E,_=F,w=G;let D=!0,Y=null,gt=!1,xt=!1;if(E){let wt=pt.get(E);wt.__useDefaultFramebuffer!==void 0?(yt.bindFramebuffer(L.FRAMEBUFFER,null),D=!1):wt.__webglFramebuffer===void 0?Pt.setupRenderTarget(E):wt.__hasExternalTextures&&Pt.rebindTextures(E,pt.get(E.texture).__webglTexture,pt.get(E.depthTexture).__webglTexture);let At=E.texture;(At.isData3DTexture||At.isDataArrayTexture||At.isCompressedArrayTexture)&&(xt=!0);let Rt=pt.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Y=Rt[F],gt=!0):nt.isWebGL2&&E.samples>0&&Pt.useMultisampledRTT(E)===!1?Y=pt.get(E).__webglMultisampledFramebuffer:Y=Rt,I.copy(E.viewport),y.copy(E.scissor),T=E.scissorTest}else I.copy($).multiplyScalar(U).floor(),y.copy(W).multiplyScalar(U).floor(),T=X;if(yt.bindFramebuffer(L.FRAMEBUFFER,Y)&&nt.drawBuffers&&D&&yt.drawBuffers(E,Y),yt.viewport(I),yt.scissor(y),yt.setScissorTest(T),gt){let wt=pt.get(E.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+F,wt.__webglTexture,G)}else if(xt){let wt=pt.get(E.texture),At=F||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,wt.__webglTexture,G||0,At)}b=-1},this.readRenderTargetPixels=function(E,F,G,D,Y,gt,xt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=pt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St){yt.bindFramebuffer(L.FRAMEBUFFER,St);try{let wt=E.texture,At=wt.format,Rt=wt.type;if(At!==Ve&&q.convert(At)!==L.getParameter(L.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Lt=Rt===Vi&&(Mt.has("EXT_color_buffer_half_float")||nt.isWebGL2&&Mt.has("EXT_color_buffer_float"));if(Rt!==On&&q.convert(Rt)!==L.getParameter(L.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Rt===Un&&(nt.isWebGL2||Mt.has("OES_texture_float")||Mt.has("WEBGL_color_buffer_float")))&&!Lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=E.width-D&&G>=0&&G<=E.height-Y&&L.readPixels(F,G,D,Y,q.convert(At),q.convert(Rt),gt)}finally{let wt=M!==null?pt.get(M).__webglFramebuffer:null;yt.bindFramebuffer(L.FRAMEBUFFER,wt)}}},this.copyFramebufferToTexture=function(E,F,G=0){let D=Math.pow(2,-G),Y=Math.floor(F.image.width*D),gt=Math.floor(F.image.height*D);Pt.setTexture2D(F,0),L.copyTexSubImage2D(L.TEXTURE_2D,G,0,0,E.x,E.y,Y,gt),yt.unbindTexture()},this.copyTextureToTexture=function(E,F,G,D=0){let Y=F.image.width,gt=F.image.height,xt=q.convert(G.format),St=q.convert(G.type);Pt.setTexture2D(G,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,G.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,G.unpackAlignment),F.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,D,E.x,E.y,Y,gt,xt,St,F.image.data):F.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,D,E.x,E.y,F.mipmaps[0].width,F.mipmaps[0].height,xt,F.mipmaps[0].data):L.texSubImage2D(L.TEXTURE_2D,D,E.x,E.y,xt,St,F.image),D===0&&G.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),yt.unbindTexture()},this.copyTextureToTexture3D=function(E,F,G,D,Y=0){if(u.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let gt=E.max.x-E.min.x+1,xt=E.max.y-E.min.y+1,St=E.max.z-E.min.z+1,wt=q.convert(D.format),At=q.convert(D.type),Rt;if(D.isData3DTexture)Pt.setTexture3D(D,0),Rt=L.TEXTURE_3D;else if(D.isDataArrayTexture)Pt.setTexture2DArray(D,0),Rt=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,D.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,D.unpackAlignment);let Lt=L.getParameter(L.UNPACK_ROW_LENGTH),zt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),he=L.getParameter(L.UNPACK_SKIP_PIXELS),De=L.getParameter(L.UNPACK_SKIP_ROWS),En=L.getParameter(L.UNPACK_SKIP_IMAGES),Yt=G.isCompressedTexture?G.mipmaps[0]:G.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Yt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Yt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,E.min.x),L.pixelStorei(L.UNPACK_SKIP_ROWS,E.min.y),L.pixelStorei(L.UNPACK_SKIP_IMAGES,E.min.z),G.isDataTexture||G.isData3DTexture?L.texSubImage3D(Rt,Y,F.x,F.y,F.z,gt,xt,St,wt,At,Yt.data):G.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),L.compressedTexSubImage3D(Rt,Y,F.x,F.y,F.z,gt,xt,St,wt,Yt.data)):L.texSubImage3D(Rt,Y,F.x,F.y,F.z,gt,xt,St,wt,At,Yt),L.pixelStorei(L.UNPACK_ROW_LENGTH,Lt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,zt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,he),L.pixelStorei(L.UNPACK_SKIP_ROWS,De),L.pixelStorei(L.UNPACK_SKIP_IMAGES,En),Y===0&&D.generateMipmaps&&L.generateMipmap(Rt),yt.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Pt.setTextureCube(E,0):E.isData3DTexture?Pt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Pt.setTexture2DArray(E,0):Pt.setTexture2D(E,0),yt.unbindTexture()},this.resetState=function(){_=0,w=0,M=null,yt.reset(),ft.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Et?Nn:nc}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Nn?Et:Je}},jr=class extends Kr{};jr.prototype.isWebGL1Renderer=!0;function _n(i,t,e){return fc(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function ys(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function fc(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var vi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Qr=class extends vi{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:aa,endingEnd:aa}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case ca:r=t,o=2*e-n;break;case la:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case ca:a=t,c=2*n-e;break;case la:a=1,c=n+s[1]-s[0];break;default:a=t-1,c=e}let l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,g=(n-e)/(s-e),x=g*g,m=x*g,u=-f*m+2*f*x-f*g,v=(1+f)*m+(-1.5-2*f)*x+(-.5+f)*g+1,_=(-1-p)*m+(1.5+p)*x+.5*g,w=p*m-p*x;for(let M=0;M!==o;++M)r[M]=u*a[h+M]+v*a[l+M]+_*a[c+M]+w*a[d+M];return r}},to=class extends vi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(s-e),d=1-h;for(let f=0;f!==o;++f)r[f]=a[l+f]*d+a[c+f]*h;return r}},eo=class extends vi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},We=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ys(e,this.TimeBufferType),this.values=ys(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ys(t.times,Array),values:ys(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new eo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new to(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Qr(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ms:e=this.InterpolantFactoryMethodDiscrete;break;case Ss:e=this.InterpolantFactoryMethodLinear;break;case sr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ms;case this.InterpolantFactoryMethodLinear:return Ss;case this.InterpolantFactoryMethodSmooth:return sr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=_n(n,r,a),this.values=_n(this.values,r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&fc(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=_n(this.times),e=_n(this.values),n=this.getValueSize(),s=this.getInterpolation()===sr,r=t.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(s)c=!0;else{let d=o*n,f=d-n,p=d+n;for(let g=0;g!==n;++g){let x=e[d+g];if(x!==e[f+g]||x!==e[p+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];let d=o*n,f=a*n;for(let p=0;p!==n;++p)e[f+p]=e[d+p]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=_n(t,0,a),this.values=_n(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=_n(this.times,0),e=_n(this.values,0),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};We.prototype.TimeBufferType=Float32Array;We.prototype.ValueBufferType=Float32Array;We.prototype.DefaultInterpolation=Ss;var kn=class extends We{};kn.prototype.ValueTypeName="bool";kn.prototype.ValueBufferType=Array;kn.prototype.DefaultInterpolation=Ms;kn.prototype.InterpolantFactoryMethodLinear=void 0;kn.prototype.InterpolantFactoryMethodSmooth=void 0;var no=class extends We{};no.prototype.ValueTypeName="color";var io=class extends We{};io.prototype.ValueTypeName="number";var so=class extends vi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)vn.slerpFlat(r,0,a,l-o,a,l,c);return r}},Gi=class extends We{InterpolantFactoryMethodLinear(t){return new so(this.times,this.values,this.getValueSize(),t)}};Gi.prototype.ValueTypeName="quaternion";Gi.prototype.DefaultInterpolation=Ss;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;var Vn=class extends We{};Vn.prototype.ValueTypeName="string";Vn.prototype.ValueBufferType=Array;Vn.prototype.DefaultInterpolation=Ms;Vn.prototype.InterpolantFactoryMethodLinear=void 0;Vn.prototype.InterpolantFactoryMethodSmooth=void 0;var ro=class extends We{};ro.prototype.ValueTypeName="vector";var lo="\\\\[\\\\]\\\\.:\\\\/",Ep=new RegExp("["+lo+"]","g"),ho="[^"+lo+"]",wp="[^"+lo.replace("\\\\.","")+"]",Tp=/((?:WC+[\\/:])*)/.source.replace("WC",ho),Ap=/(WCOD+)?/.source.replace("WCOD",wp),Rp=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",ho),Cp=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",ho),Pp=new RegExp("^"+Tp+Ap+Rp+Cp+"$"),Lp=["material","materials","bones","map"],oo=class{constructor(t,e,n){let s=n||Nt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Nt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Nt.parseTrackName(e),this.node=Nt.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Nt.Composite(t,e,n):new Nt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(Ep,"")}static parseTrackName(t){let e=Pp.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Lp.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let c=n(o.children);if(c)return c}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=Nt.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn\'t found.");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.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[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let a=t[s];if(a===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn\'t found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Nt.Composite=oo;Nt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Nt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Nt.prototype.GetterByBindingType=[Nt.prototype._getValue_direct,Nt.prototype._getValue_array,Nt.prototype._getValue_arrayElement,Nt.prototype._getValue_toArray];Nt.prototype.SetterByBindingTypeAndVersioning=[[Nt.prototype._setValue_direct,Nt.prototype._setValue_direct_setNeedsUpdate,Nt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_array,Nt.prototype._setValue_array_setNeedsUpdate,Nt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_arrayElement,Nt.prototype._setValue_arrayElement_setNeedsUpdate,Nt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Nt.prototype._setValue_fromArray,Nt.prototype._setValue_fromArray_setNeedsUpdate,Nt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Qp=new Float32Array(1);var Ja=new P,vs=new P,ye=class{constructor(t=new P,e=new P){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Ja.subVectors(t,this.start),vs.subVectors(this.end,this.start);let n=vs.dot(vs),r=vs.dot(Ja)/n;return e&&(r=pe(r,0,1)),r}closestPointToPoint(t,e,n){let s=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ao}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ao);var dc=Math.pow(2,-24);var Hn=class{constructor(){}};function Ie(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function uo(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let s=i[n+3]-i[n];s>e&&(e=s,t=n)}return t}function fo(i,t){t.set(i)}function po(i,t,e){let n,s;for(let r=0;r<3;r++){let a=r+3;n=i[r],s=t[r],e[r]=n<s?n:s,n=i[a],s=t[a],e[a]=n>s?n:s}}function Xi(i,t,e){for(let n=0;n<3;n++){let s=t[i+2*n],r=t[i+2*n+1],a=s-r,o=s+r;a<e[n]&&(e[n]=a),o>e[n+3]&&(e[n+3]=o)}}function Si(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function Dp(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;e>65535?s=new Uint32Array(new n(4*e)):s=new Uint16Array(new n(2*e)),i.setIndex(new Kt(s,1));for(let r=0;r<e;r++)s[r]=r}}function Np(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let s of i.groups)e.add(s.start),e.add(s.start+s.count);let n=Array.from(e.values()).sort((s,r)=>s-r);for(let s=0;s<n.length-1;s++){let r=n[s],a=n[s+1];t.push({offset:r/3,count:(a-r)/3})}return t}function go(i,t,e,n,s=null){let r=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,h=-1/0,d=1/0,f=1/0,p=1/0,g=-1/0,x=-1/0,m=-1/0,u=s!==null;for(let v=t*6,_=(t+e)*6;v<_;v+=6){let w=i[v+0],M=i[v+1],b=w-M,R=w+M;b<r&&(r=b),R>c&&(c=R),u&&w<d&&(d=w),u&&w>g&&(g=w);let I=i[v+2],y=i[v+3],T=I-y,O=I+y;T<a&&(a=T),O>l&&(l=O),u&&I<f&&(f=I),u&&I>x&&(x=I);let z=i[v+4],U=i[v+5],N=z-U,B=z+U;N<o&&(o=N),B>h&&(h=B),u&&z<p&&(p=z),u&&z>m&&(m=z)}n[0]=r,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,u&&(s[0]=d,s[1]=f,s[2]=p,s[3]=g,s[4]=x,s[5]=m)}function Fp(i,t,e,n){let s=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,l=-1/0;for(let h=t*6,d=(t+e)*6;h<d;h+=6){let f=i[h+0];f<s&&(s=f),f>o&&(o=f);let p=i[h+2];p<r&&(r=p),p>c&&(c=p);let g=i[h+4];g<a&&(a=g),g>l&&(l=g)}n[0]=s,n[1]=r,n[2]=a,n[3]=o,n[4]=c,n[5]=l}function Op(i,t,e,n,s){let r=e,a=e+n-1,o=s.pos,c=s.axis*2;for(;;){for(;r<=a&&t[r*6+c]<o;)r++;for(;r<=a&&t[a*6+c]>=o;)a--;if(r<a){for(let l=0;l<3;l++){let h=i[r*3+l];i[r*3+l]=i[a*3+l],i[a*3+l]=h;let d=t[r*6+l*2+0];t[r*6+l*2+0]=t[a*6+l*2+0],t[a*6+l*2+0]=d;let f=t[r*6+l*2+1];t[r*6+l*2+1]=t[a*6+l*2+1],t[a*6+l*2+1]=f}r++,a--}else return r}}var hn=32,Bp=(i,t)=>i.candidate-t.candidate,Mn=new Array(hn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Os=new Float32Array(6);function zp(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=uo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=uo(i),a!==-1&&(o=kp(e,n,s,a));else if(r===2){let c=Si(i),l=1.25*s,h=n*6,d=(n+s)*6;for(let f=0;f<3;f++){let p=t[f],m=(t[f+3]-p)/hn;if(s<hn/4){let u=[...Mn];u.length=s;let v=0;for(let w=h;w<d;w+=6,v++){let M=u[v];M.candidate=e[w+2*f],M.count=0;let{bounds:b,leftCacheBounds:R,rightCacheBounds:I}=M;for(let y=0;y<3;y++)I[y]=1/0,I[y+3]=-1/0,R[y]=1/0,R[y+3]=-1/0,b[y]=1/0,b[y+3]=-1/0;Xi(w,e,b)}u.sort(Bp);let _=s;for(let w=0;w<_;w++){let M=u[w];for(;w+1<_&&u[w+1].candidate===M.candidate;)u.splice(w+1,1),_--}for(let w=h;w<d;w+=6){let M=e[w+2*f];for(let b=0;b<_;b++){let R=u[b];M>=R.candidate?Xi(w,e,R.rightCacheBounds):(Xi(w,e,R.leftCacheBounds),R.count++)}}for(let w=0;w<_;w++){let M=u[w],b=M.count,R=s-M.count,I=M.leftCacheBounds,y=M.rightCacheBounds,T=0;b!==0&&(T=Si(I)/c);let O=0;R!==0&&(O=Si(y)/c);let z=1+1.25*(T*b+O*R);z<l&&(a=f,l=z,o=M.candidate)}}else{for(let _=0;_<hn;_++){let w=Mn[_];w.count=0,w.candidate=p+m+_*m;let M=w.bounds;for(let b=0;b<3;b++)M[b]=1/0,M[b+3]=-1/0}for(let _=h;_<d;_+=6){let b=~~((e[_+2*f]-p)/m);b>=hn&&(b=hn-1);let R=Mn[b];R.count++,Xi(_,e,R.bounds)}let u=Mn[hn-1];fo(u.bounds,u.rightCacheBounds);for(let _=hn-2;_>=0;_--){let w=Mn[_],M=Mn[_+1];po(w.bounds,M.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let _=0;_<hn-1;_++){let w=Mn[_],M=w.count,b=w.bounds,I=Mn[_+1].rightCacheBounds;M!==0&&(v===0?fo(b,Os):po(b,Os,Os)),v+=M;let y=0,T=0;v!==0&&(y=Si(Os)/c);let O=s-v;O!==0&&(T=Si(I)/c);let z=1+1.25*(y*v+T*O);z<l&&(a=f,l=z,o=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:a,pos:o}}function kp(i,t,e,n){let s=0;for(let r=t,a=t+e;r<a;r++)s+=i[r*6+n*2];return s/e}function Vp(i,t){let e=i.attributes.position,n=i.index.array,s=n.length/3,r=new Float32Array(s*6),a=e.normalized,o=e.array,c=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);let h=["getX","getY","getZ"];for(let d=0;d<s;d++){let f=d*3,p=d*6,g,x,m;a?(g=n[f+0],x=n[f+1],m=n[f+2]):(g=n[f+0]*l+c,x=n[f+1]*l+c,m=n[f+2]*l+c);for(let u=0;u<3;u++){let v,_,w;a?(v=e[h[u]](g),_=e[h[u]](x),w=e[h[u]](m)):(v=o[g+u],_=o[x+u],w=o[m+u]);let M=v;_<M&&(M=_),w<M&&(M=w);let b=v;_>b&&(b=_),w>b&&(b=w);let R=(b-M)/2,I=u*2;r[p+I+0]=M+R,r[p+I+1]=R+(Math.abs(M)+R)*dc,M<t[u]&&(t[u]=M),b>t[u+3]&&(t[u+3]=b)}}return r}function Hp(i,t){function e(u){f&&f(u/p)}function n(u,v,_,w=null,M=0){if(!g&&M>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||M>=c)return e(v+_),u.offset=v,u.count=_,u;let b=zp(u.boundingData,w,a,v,_,d);if(b.axis===-1)return e(v+_),u.offset=v,u.count=_,u;let R=Op(o,a,v,_,b);if(R===v||R===v+_)e(v+_),u.offset=v,u.count=_;else{u.splitAxis=b.axis;let I=new Hn,y=v,T=R-v;u.left=I,I.boundingData=new Float32Array(6),go(a,y,T,I.boundingData,r),n(I,y,T,r,M+1);let O=new Hn,z=R,U=_-T;u.right=O,O.boundingData=new Float32Array(6),go(a,z,U,O.boundingData,r),n(O,z,U,r,M+1)}return u}Dp(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=Vp(i,s),o=i.index.array,c=t.maxDepth,l=t.verbose,h=t.maxLeafTris,d=t.strategy,f=t.onProgress,p=i.index.count/3,g=!1,x=[],m=Np(i);if(m.length===1){let u=m[0],v=new Hn;v.boundingData=s,Fp(a,u.offset,u.count,r),n(v,u.offset,u.count,r),x.push(v)}else for(let u of m){let v=new Hn;v.boundingData=new Float32Array(6),go(a,u.offset,u.count,v.boundingData,r),n(v,u.offset,u.count,r),x.push(v)}return x}function gc(i,t){let e=Hp(i,t),n,s,r,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;h<e.length;h++){let d=e[h],f=c(d),p=new o(32*f);n=new Float32Array(p),s=new Uint32Array(p),r=new Uint16Array(p),l(0,d),a.push(p)}return a;function c(h){return h.count?1:1+c(h.left)+c(h.right)}function l(h,d){let f=h/4,p=h/2,g=!!d.count,x=d.boundingData;for(let m=0;m<6;m++)n[f+m]=x[m];if(g){let m=d.offset,u=d.count;return s[f+6]=m,r[p+14]=u,r[p+15]=65535,h+32}else{let m=d.left,u=d.right,v=d.splitAxis,_;if(_=l(h+32,m),_/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[f+6]=_/4,_=l(_,u),s[f+7]=v,_}}}var ve=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,s=-1/0;for(let r=0,a=t.length;r<a;r++){let c=t[r][e];n=c<n?c:n,s=c>s?c:s}this.min=n,this.max=s}setFromPoints(t,e){let n=1/0,s=-1/0;for(let r=0,a=e.length;r<a;r++){let o=e[r],c=t.dot(o);n=c<n?c:n,s=c>s?c:s}this.min=n,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}};ve.prototype.setFromBox=function(){let i=new P;return function(e,n){let s=n.min,r=n.max,a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){i.x=s.x*c+r.x*(1-c),i.y=s.y*l+r.y*(1-l),i.z=s.z*h+r.z*(1-h);let d=e.dot(i);a=Math.min(d,a),o=Math.max(d,o)}this.min=a,this.max=o}}();var hm=function(){let i=new ve;return function(e,n){let s=e.points,r=e.satAxes,a=e.satBounds,o=n.points,c=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let d=a[h],f=r[h];if(i.setFromPoints(f,o),d.isSeparated(i))return!1}for(let h=0;h<3;h++){let d=l[h],f=c[h];if(i.setFromPoints(f,s),d.isSeparated(i))return!1}}}();var Gp=function(){let i=new P,t=new P,e=new P;return function(s,r,a){let o=s.start,c=i,l=r.start,h=t;e.subVectors(o,l),i.subVectors(s.end,s.start),t.subVectors(r.end,r.start);let d=e.dot(h),f=h.dot(c),p=h.dot(h),g=e.dot(c),m=c.dot(c)*p-f*f,u,v;m!==0?u=(d*f-g*p)/m:u=0,v=(d+u*f)/p,a.x=u,a.y=v}}(),qi=function(){let i=new Dt,t=new P,e=new P;return function(s,r,a,o){Gp(s,r,i);let c=i.x,l=i.y;if(c>=0&&c<=1&&l>=0&&l<=1){s.at(c,a),r.at(l,o);return}else if(c>=0&&c<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else{let h;c<0?h=s.start:h=s.end;let d;l<0?d=r.start:d=r.end;let f=t,p=e;if(s.closestPointToPoint(d,!0,t),r.closestPointToPoint(h,!0,e),f.distanceToSquared(d)<=p.distanceToSquared(h)){a.copy(f),o.copy(d);return}else{a.copy(h),o.copy(p);return}}}}(),_c=function(){let i=new P,t=new P,e=new Re,n=new ye;return function(r,a){let{radius:o,center:c}=r,{a:l,b:h,c:d}=a;if(n.start=l,n.end=h,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o||(n.start=l,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o)||(n.start=h,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o))return!0;let x=a.getPlane(e);if(Math.abs(x.distanceToPoint(c))<=o){let u=x.projectPoint(c,t);if(a.containsPoint(u))return!0}return!1}}();var Wp=1e-15;function bi(i){return Math.abs(i)<Wp}var Me=class extends se{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new P),this.satBounds=new Array(4).fill().map(()=>new ve),this.points=[this.a,this.b,this.c],this.sphere=new Bn,this.plane=new Re,this.needsUpdate=!0}intersectsSphere(t){return _c(t,this)}update(){let t=this.a,e=this.b,n=this.c,s=this.points,r=this.satAxes,a=this.satBounds,o=r[0],c=a[0];this.getNormal(o),c.setFromPoints(o,s);let l=r[1],h=a[1];l.subVectors(t,e),h.setFromPoints(l,s);let d=r[2],f=a[2];d.subVectors(e,n),f.setFromPoints(d,s);let p=r[3],g=a[3];p.subVectors(n,t),g.setFromPoints(p,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}};Me.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new ye;return function(s,r=null,a=null){let{start:o,end:c}=s,l=this.points,h,d=1/0;for(let f=0;f<3;f++){let p=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[p]),qi(e,s,i,t),h=i.distanceToSquared(t),h<d&&(d=h,r&&r.copy(i),a&&a.copy(t))}return this.closestPointToPoint(o,i),h=o.distanceToSquared(i),h<d&&(d=h,r&&r.copy(i),a&&a.copy(o)),this.closestPointToPoint(c,i),h=c.distanceToSquared(i),h<d&&(d=h,r&&r.copy(i),a&&a.copy(c)),Math.sqrt(d)}}();Me.prototype.intersectsTriangle=function(){let i=new Me,t=new Array(3),e=new Array(3),n=new ve,s=new ve,r=new P,a=new P,o=new P,c=new P,l=new ye,h=new ye,d=new ye;return function(p,g=null,x=!1){this.needsUpdate&&this.update(),p.isExtendedTriangle?p.needsUpdate&&p.update():(i.copy(p),i.update(),p=i);let m=this.plane,u=p.plane;if(Math.abs(m.normal.dot(u.normal))>1-1e-10){let v=this.satBounds,_=this.satAxes;e[0]=p.a,e[1]=p.b,e[2]=p.c;for(let b=0;b<4;b++){let R=v[b],I=_[b];if(n.setFromPoints(I,e),R.isSeparated(n))return!1}let w=p.satBounds,M=p.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let b=0;b<4;b++){let R=w[b],I=M[b];if(n.setFromPoints(I,t),R.isSeparated(n))return!1}for(let b=0;b<4;b++){let R=_[b];for(let I=0;I<4;I++){let y=M[I];if(r.crossVectors(R,y),n.setFromPoints(r,t),s.setFromPoints(r,e),n.isSeparated(s))return!1}}return g&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let v=this.points,_=!1,w=0;for(let N=0;N<3;N++){let B=v[N],$=v[(N+1)%3];l.start.copy(B),l.end.copy($),l.delta(a);let W=_?h.start:h.end,X=bi(u.distanceToPoint(B));if(bi(u.normal.dot(a))&&X){h.copy(l),w=2;break}if((u.intersectLine(l,W)||X)&&!bi(W.distanceTo($))){if(w++,_)break;_=!0}}if(w===1&&p.containsPoint(h.end))return g&&(g.start.copy(h.end),g.end.copy(h.end)),!0;if(w!==2)return!1;let M=p.points,b=!1,R=0;for(let N=0;N<3;N++){let B=M[N],$=M[(N+1)%3];l.start.copy(B),l.end.copy($),l.delta(o);let W=b?d.start:d.end,X=bi(m.distanceToPoint(B));if(bi(m.normal.dot(o))&&X){d.copy(l),R=2;break}if((m.intersectLine(l,W)||X)&&!bi(W.distanceTo($))){if(R++,b)break;b=!0}}if(R===1&&this.containsPoint(d.end))return g&&(g.start.copy(d.end),g.end.copy(d.end)),!0;if(R!==2)return!1;if(h.delta(a),d.delta(o),a.dot(o)<0){let N=d.start;d.start=d.end,d.end=N}let I=h.start.dot(a),y=h.end.dot(a),T=d.start.dot(a),O=d.end.dot(a),z=y<T,U=I<O;return I!==O&&T!==y&&z===U?!1:(g&&(c.subVectors(h.start,d.start),c.dot(a)>0?g.start.copy(h.start):g.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?g.end.copy(h.end):g.end.copy(d.end)),!0)}}}();Me.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Me.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new ye,s=new ye;return function(a,o=null,c=null){let l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let h=1/0;for(let d=0;d<3;d++){let f,p=e[d],g=a[p];this.closestPointToPoint(g,i),f=g.distanceToSquared(i),f<h&&(h=f,o&&o.copy(i),c&&c.copy(g));let x=this[p];a.closestPointToPoint(x,i),f=x.distanceToSquared(i),f<h&&(h=f,o&&o.copy(x),c&&c.copy(i))}for(let d=0;d<3;d++){let f=e[d],p=e[(d+1)%3];n.set(this[f],this[p]);for(let g=0;g<3;g++){let x=e[g],m=e[(g+1)%3];s.set(a[x],a[m]),qi(n,s,i,t);let u=i.distanceToSquared(t);u<h&&(h=u,o&&o.copy(i),c&&c.copy(t))}}return Math.sqrt(h)}}();var Se=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new P,this.max=new P,this.matrix=new Gt,this.invMatrix=new Gt,this.points=new Array(8).fill().map(()=>new P),this.satAxes=new Array(3).fill().map(()=>new P),this.satBounds=new Array(3).fill().map(()=>new ve),this.alignedSatBounds=new Array(3).fill().map(()=>new ve),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Se.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,s=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let f=1*l|2*h|4*d,p=s[f];p.x=l?n.x:e.x,p.y=h?n.y:e.y,p.z=d?n.z:e.z,p.applyMatrix4(t)}let r=this.satBounds,a=this.satAxes,o=s[0];for(let l=0;l<3;l++){let h=a[l],d=r[l],f=1<<l,p=s[f];h.subVectors(o,p),d.setFromPoints(h,s)}let c=this.alignedSatBounds;c[0].setFromPointsField(s,"x"),c[1].setFromPointsField(s,"y"),c[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Se.prototype.intersectsBox=function(){let i=new ve;return function(e){this.needsUpdate&&this.update();let n=e.min,s=e.max,r=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(i.min=n.x,i.max=s.x,o[0].isSeparated(i)||(i.min=n.y,i.max=s.y,o[1].isSeparated(i))||(i.min=n.z,i.max=s.z,o[2].isSeparated(i)))return!1;for(let c=0;c<3;c++){let l=a[c],h=r[c];if(i.setFromBox(l,e),h.isSeparated(i))return!1}return!0}}();Se.prototype.intersectsTriangle=function(){let i=new Me,t=new Array(3),e=new ve,n=new ve,s=new P;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(i.copy(a),i.update(),a=i);let o=this.satBounds,c=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let f=0;f<3;f++){let p=o[f],g=c[f];if(e.setFromPoints(g,t),p.isSeparated(e))return!1}let l=a.satBounds,h=a.satAxes,d=this.points;for(let f=0;f<3;f++){let p=l[f],g=h[f];if(e.setFromPoints(g,d),p.isSeparated(e))return!1}for(let f=0;f<3;f++){let p=c[f];for(let g=0;g<4;g++){let x=h[g];if(s.crossVectors(p,x),e.setFromPoints(s,t),n.setFromPoints(s,d),e.isSeparated(n))return!1}}return!0}}();Se.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Se.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Se.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new ye),e=new Array(12).fill().map(()=>new ye),n=new P,s=new P;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(s),this.closestPointToPoint(s,n),a.closestPointToPoint(n,s),c&&c.copy(n),l&&l.copy(s)),0;let h=o*o,d=a.min,f=a.max,p=this.points,g=1/0;for(let m=0;m<8;m++){let u=p[m];s.copy(u).clamp(d,f);let v=u.distanceToSquared(s);if(v<g&&(g=v,c&&c.copy(u),l&&l.copy(s),v<h))return Math.sqrt(v)}let x=0;for(let m=0;m<3;m++)for(let u=0;u<=1;u++)for(let v=0;v<=1;v++){let _=(m+1)%3,w=(m+2)%3,M=u<<_|v<<w,b=1<<m|u<<_|v<<w,R=p[M],I=p[b];t[x].set(R,I);let T=i[m],O=i[_],z=i[w],U=e[x],N=U.start,B=U.end;N[T]=d[T],N[O]=u?d[O]:f[O],N[z]=v?d[z]:f[O],B[T]=f[T],B[O]=u?d[O]:f[O],B[z]=v?d[z]:f[O],x++}for(let m=0;m<=1;m++)for(let u=0;u<=1;u++)for(let v=0;v<=1;v++){s.x=m?f.x:d.x,s.y=u?f.y:d.y,s.z=v?f.z:d.z,this.closestPointToPoint(s,n);let _=s.distanceToSquared(n);if(_<g&&(g=_,c&&c.copy(n),l&&l.copy(s),_<h))return Math.sqrt(_)}for(let m=0;m<12;m++){let u=t[m];for(let v=0;v<12;v++){let _=e[v];qi(u,_,n,s);let w=n.distanceToSquared(s);if(w<g&&(g=w,c&&c.copy(n),l&&l.copy(s),w<h))return Math.sqrt(w)}}return Math.sqrt(g)}}();var zs=new P,ks=new P,Vs=new P,xc=new Dt,yc=new Dt,vc=new Dt,Mc=new P;function Xp(i,t,e,n,s,r){let a;return r===le?a=i.intersectTriangle(n,e,t,!0,s):a=i.intersectTriangle(t,e,n,r!==ze,s),a===null?null:{distance:i.origin.distanceTo(s),point:s.clone()}}function qp(i,t,e,n,s,r,a){zs.fromBufferAttribute(t,n),ks.fromBufferAttribute(t,s),Vs.fromBufferAttribute(t,r);let o=Xp(i,zs,ks,Vs,Mc,a);if(o){e&&(xc.fromBufferAttribute(e,n),yc.fromBufferAttribute(e,s),vc.fromBufferAttribute(e,r),o.uv=se.getUV(Mc,zs,ks,Vs,xc,yc,vc,new Dt));let c={a:n,b:s,c:r,normal:new P,materialIndex:0};se.getNormal(zs,ks,Vs,c.normal),o.face=c,o.faceIndex=n}return o}function xo(i,t,e,n,s){let r=n*3,a=i.index.getX(r),o=i.index.getX(r+1),c=i.index.getX(r+2),l=qp(e,i.attributes.position,i.attributes.uv,a,o,c,t);return l?(l.faceIndex=n,s&&s.push(l),l):null}function Sc(i,t,e,n,s,r){for(let a=n,o=n+s;a<o;a++)xo(i,t,e,a,r)}function bc(i,t,e,n,s){let r=1/0,a=null;for(let o=n,c=n+s;o<c;o++){let l=xo(i,t,e,o);l&&l.distance<r&&(a=l,r=l.distance)}return a}function Ue(i,t,e,n){let s=i.a,r=i.b,a=i.c,o=t,c=t+1,l=t+2;e&&(o=e.getX(t),c=e.getX(t+1),l=e.getX(t+2)),s.x=n.getX(o),s.y=n.getY(o),s.z=n.getZ(o),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function yo(i,t,e,n,s,r,a){let o=e.index,c=e.attributes.position;for(let l=i,h=t+i;l<h;l++)if(Ue(a,l*3,o,c),a.needsUpdate=!0,n(a,l,s,r))return!0;return!1}var Ei=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function un(i,t){return t[i+15]===65535}function Gn(i,t){return t[i+6]}function wi(i,t){return t[i+14]}function Ti(i){return i+8}function Ai(i,t){return t[i+6]}function Ec(i,t){return t[i+7]}var Ri=new ge,Gs=new P,Zp=["x","y","z"];function Ws(i,t,e,n,s){let r=i*2,a=Ci,o=Sn,c=bn;if(un(r,o)){let h=Gn(i,c),d=wi(r,o);Sc(t,e,n,h,d,s)}else{let h=Ti(i);qs(h,a,n,Gs)&&Ws(h,t,e,n,s);let d=Ai(i,c);qs(d,a,n,Gs)&&Ws(d,t,e,n,s)}}function Xs(i,t,e,n){let s=i*2,r=Ci,a=Sn,o=bn;if(un(s,a)){let l=Gn(i,o),h=wi(s,a);return bc(t,e,n,l,h)}else{let l=Ec(i,o),h=Zp[l],f=n.direction[h]>=0,p,g;f?(p=Ti(i),g=Ai(i,o)):(p=Ai(i,o),g=Ti(i));let m=qs(p,r,n,Gs)?Xs(p,t,e,n):null;if(m){let _=m.point[h];if(f?_<=r[g+l]:_>=r[g+l+3])return m}let v=qs(g,r,n,Gs)?Xs(g,t,e,n):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}var wc=function(){let i,t,e=[],n=new Ei(()=>new ge);return function(...a){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let o=s(...a);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let c=e.length;return c>0&&(t=e[c-1],i=e[c-2]),o};function s(r,a,o,c,l=null,h=0,d=0){function f(_){let w=_*2,M=Sn,b=bn;for(;!un(w,M);)_=Ti(_),w=_*2;return Gn(_,b)}function p(_){let w=_*2,M=Sn,b=bn;for(;!un(w,M);)_=Ai(_,b),w=_*2;return Gn(_,b)+wi(w,M)}let g=r*2,x=Ci,m=Sn,u=bn;if(un(g,m)){let _=Gn(r,u),w=wi(g,m);return Ie(r,x,i),c(_,w,!1,d,h+r,i)}else{let _=Ti(r),w=Ai(r,u),M=_,b=w,R,I,y,T;if(l&&(y=i,T=t,Ie(M,x,y),Ie(b,x,T),R=l(y),I=l(T),I<R)){M=w,b=_;let W=R;R=I,I=W,y=T}y||(y=i,Ie(M,x,y));let O=un(M*2,m),z=o(y,O,R,d+1,h+M),U;if(z===2){let W=f(M),Z=p(M)-W;U=c(W,Z,!0,d+1,h+M,y)}else U=z&&s(M,a,o,c,l,h,d+1);if(U)return!0;T=t,Ie(b,x,T);let N=un(b*2,m),B=o(T,N,I,d+1,h+b),$;if(B===2){let W=f(b),Z=p(b)-W;$=c(W,Z,!0,d+1,h+b,T)}else $=B&&s(b,a,o,c,l,h,d+1);return!!$}}}(),Tc=function(){let i=new Me,t=new Me,e=new Gt,n=new Se,s=new Se;return function r(a,o,c,l,h=null){let d=a*2,f=Ci,p=Sn,g=bn;if(h===null&&(c.boundingBox||c.computeBoundingBox(),n.set(c.boundingBox.min,c.boundingBox.max,l),h=n),un(d,p)){let m=o,u=m.index,v=m.attributes.position,_=c.index,w=c.attributes.position,M=Gn(a,g),b=wi(d,p);if(e.copy(l).invert(),c.boundsTree)return Ie(a,f,s),s.matrix.copy(e),s.needsUpdate=!0,c.boundsTree.shapecast({intersectsBounds:I=>s.intersectsBox(I),intersectsTriangle:I=>{I.a.applyMatrix4(l),I.b.applyMatrix4(l),I.c.applyMatrix4(l),I.needsUpdate=!0;for(let y=M*3,T=(b+M)*3;y<T;y+=3)if(Ue(t,y,u,v),t.needsUpdate=!0,I.intersectsTriangle(t))return!0;return!1}});for(let R=M*3,I=b+M*3;R<I;R+=3){Ue(i,R,u,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let y=0,T=_.count;y<T;y+=3)if(Ue(t,y,_,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let m=a+8,u=g[a+6];return Ie(m,f,Ri),!!(h.intersectsBox(Ri)&&r(m,o,c,l,h)||(Ie(u,f,Ri),h.intersectsBox(Ri)&&r(u,o,c,l,h)))}}}();function qs(i,t,e,n){return Ie(i,t,Ri),e.intersectBox(Ri,n)}var vo=[],Hs,Ci,Sn,bn;function Pi(i){Hs&&vo.push(Hs),Hs=i,Ci=new Float32Array(i),Sn=new Uint16Array(i),bn=new Uint32Array(i)}function Yi(){Hs=null,Ci=null,Sn=null,bn=null,vo.length&&Pi(vo.pop())}var Mo=Symbol("skip tree generation"),So=new ge,bo=new ge,Li=new Gt,Wn=new Se,Zi=new Se,Ji=new P,Ys=new P,Jp=new P,$p=new P,Kp=new P,Ac=new ge,$e=new Ei(()=>new Me),Ke=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ke.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=Ki({cloneBuffers:!0},e);let n=t.geometry,s=t._roots,r=n.getIndex(),a;return e.cloneBuffers?a={roots:s.map(o=>o.slice()),index:r.array.slice()}:a={roots:s,index:r.array},a}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ke.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=Ki({setIndex:!0},n);let{index:s,roots:r}=t,a=new Ke(e,Po(Ki({},n),{[Mo]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new Kt(t.index,1,!1);e.setIndex(c)}else o.array!==s&&(o.array.set(s),o.needsUpdate=!0)}return a}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Mo]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Mo]||(this._roots=gc(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ge))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,s=e.attributes.position,r,a,o,c,l=0,h=this._roots;for(let f=0,p=h.length;f<p;f++)r=h[f],a=new Uint32Array(r),o=new Uint16Array(r),c=new Float32Array(r),d(0,l),l+=r.byteLength;function d(f,p,g=!1){let x=f*2;if(o[x+15]===65535){let u=a[f+6],v=o[x+14],_=1/0,w=1/0,M=1/0,b=-1/0,R=-1/0,I=-1/0;for(let y=3*u,T=3*(u+v);y<T;y++){let O=n[y],z=s.getX(O),U=s.getY(O),N=s.getZ(O);z<_&&(_=z),z>b&&(b=z),U<w&&(w=U),U>R&&(R=U),N<M&&(M=N),N>I&&(I=N)}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==M||c[f+3]!==b||c[f+4]!==R||c[f+5]!==I?(c[f+0]=_,c[f+1]=w,c[f+2]=M,c[f+3]=b,c[f+4]=R,c[f+5]=I,!0):!1}else{let u=f+8,v=a[f+6],_=u+p,w=v+p,M=g,b=!1,R=!1;t?M||(b=t.has(_),R=t.has(w),M=!b&&!R):(b=!0,R=!0);let I=M||b,y=M||R,T=!1;I&&(T=d(u,p,M));let O=!1;y&&(O=d(v,p,M));let z=T||O;if(z)for(let U=0;U<3;U++){let N=u+U,B=v+U,$=c[N],W=c[N+3],X=c[B],Z=c[B+3];c[f+U]=$<X?$:X,c[f+U+3]=W>Z?W:Z}return z}}}traverse(t,e=0){let n=this._roots[e],s=new Uint32Array(n),r=new Uint16Array(n);a(0);function a(o,c=0){let l=o*2,h=r[l+15]===65535;if(h){let d=s[o+6],f=r[l+14];t(c,h,new Float32Array(n,o*4,6),d,f)}else{let d=o+32/4,f=s[o+6],p=s[o+7];t(c,h,new Float32Array(n,o*4,6),p)||(a(d,c+1),a(f,c+1))}}}raycast(t,e=He){let n=this._roots,s=this.geometry,r=[],a=e.isMaterial,o=Array.isArray(e),c=s.groups,l=a?e.side:e;for(let h=0,d=n.length;h<d;h++){let f=o?e[c[h].materialIndex].side:l,p=r.length;if(Pi(n[h]),Ws(0,s,f,t,r),Yi(),o){let g=c[h].materialIndex;for(let x=p,m=r.length;x<m;x++)r[x].face.materialIndex=g}}return r}raycastFirst(t,e=He){let n=this._roots,s=this.geometry,r=e.isMaterial,a=Array.isArray(e),o=null,c=s.groups,l=r?e.side:e;for(let h=0,d=n.length;h<d;h++){let f=a?e[c[h].materialIndex].side:l;Pi(n[h]);let p=Xs(0,s,f,t);Yi(),p!=null&&(o==null||p.distance<o.distance)&&(o=p,a&&(p.face.materialIndex=c[h].materialIndex))}return o}intersectsGeometry(t,e){let n=this.geometry,s=!1;for(let r of this._roots)if(Pi(r),s=Tc(0,n,t,e),Yi(),s)break;return s}shapecast(t,e,n){let s=this.geometry;if(t instanceof Function){if(e){let f=e;e=(p,g,x,m)=>{let u=g*3;return f(p,u,u+1,u+2,x,m)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=$e.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:o,intersectsRange:c,intersectsTriangle:l}=t;if(c&&l){let f=c;c=(p,g,x,m,u)=>f(p,g,x,m,u)?!0:yo(p,g,s,l,x,m,r)}else c||(l?c=(f,p,g,x)=>yo(f,p,s,l,g,x,r):c=(f,p,g)=>g);let h=!1,d=0;for(let f of this._roots){if(Pi(f),h=wc(0,s,o,c,a,d),Yi(),h)break;d+=f.byteLength}return $e.releasePrimitive(r),h}bvhcast(t,e,n){let{intersectsRanges:s,intersectsTriangles:r}=n,a=this.geometry.index,o=this.geometry.attributes.position,c=t.geometry.index,l=t.geometry.attributes.position;Li.copy(e).invert();let h=$e.getPrimitive(),d=$e.getPrimitive();if(r){let p=function(g,x,m,u,v,_,w,M){for(let b=m,R=m+u;b<R;b++){Ue(d,b*3,c,l),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let I=g,y=g+x;I<y;I++)if(Ue(h,I*3,a,o),h.needsUpdate=!0,r(h,d,I,b,v,_,w,M))return!0}return!1};if(s){let g=s;s=function(x,m,u,v,_,w,M,b){return g(x,m,u,v,_,w,M,b)?!0:p(x,m,u,v,_,w,M,b)}}else s=p}t.getBoundingBox(bo),bo.applyMatrix4(e);let f=this.shapecast({intersectsBounds:p=>bo.intersectsBox(p),intersectsRange:(p,g,x,m,u,v)=>(So.copy(v),So.applyMatrix4(Li),t.shapecast({intersectsBounds:_=>So.intersectsBox(_),intersectsRange:(_,w,M,b,R)=>s(p,g,_,w,m,u,b,R)}))});return $e.releasePrimitive(h),$e.releasePrimitive(d),f}intersectsBox(t,e){return Wn.set(t.min,t.max,e),Wn.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Wn.intersectsBox(n),intersectsTriangle:n=>Wn.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},s={},r=0,a=1/0){t.boundingBox||t.computeBoundingBox(),Wn.set(t.boundingBox.min,t.boundingBox.max,e),Wn.needsUpdate=!0;let o=this.geometry,c=o.attributes.position,l=o.index,h=t.attributes.position,d=t.index,f=$e.getPrimitive(),p=$e.getPrimitive(),g=Ys,x=Jp,m=null,u=null;s&&(m=$p,u=Kp);let v=1/0,_=null,w=null;return Li.copy(e).invert(),Zi.matrix.copy(Li),this.shapecast({boundsTraverseOrder:M=>Wn.distanceToBox(M),intersectsBounds:(M,b,R)=>R<v&&R<a?(b&&(Zi.min.copy(M.min),Zi.max.copy(M.max),Zi.needsUpdate=!0),!0):!1,intersectsRange:(M,b)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:R=>Zi.distanceToBox(R),intersectsBounds:(R,I,y)=>y<v&&y<a,intersectsRange:(R,I)=>{for(let y=R*3,T=(R+I)*3;y<T;y+=3){Ue(p,y,d,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let O=M*3,z=(M+b)*3;O<z;O+=3){Ue(f,O,l,c),f.needsUpdate=!0;let U=f.distanceToTriangle(p,g,m);if(U<v&&(x.copy(g),u&&u.copy(m),v=U,_=O/3,w=y/3),U<r)return!0}}}});{let R=d?d.count:h.count;for(let I=0,y=R;I<y;I+=3){Ue(p,I,d,h),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let T=M*3,O=(M+b)*3;T<O;T+=3){Ue(f,T,l,c),f.needsUpdate=!0;let z=f.distanceToTriangle(p,g,m);if(z<v&&(x.copy(g),u&&u.copy(m),v=z,_=T/3,w=I/3),z<r)return!0}}}}}),$e.releasePrimitive(f),$e.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=v,n.faceIndex=_,s&&(s.point?s.point.copy(u):s.point=u.clone(),s.point.applyMatrix4(Li),x.applyMatrix4(Li),s.distance=x.sub(s.point).length(),s.faceIndex=w),n)}closestPointToPoint(t,e={},n=0,s=1/0){let r=n*n,a=s*s,o=1/0,c=null;if(this.shapecast({boundsTraverseOrder:h=>(Ji.copy(t).clamp(h.min,h.max),Ji.distanceToSquared(t)),intersectsBounds:(h,d,f)=>f<o&&f<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(t,Ji);let f=t.distanceToSquared(Ji);return f<o&&(Ys.copy(Ji),o=f,c=d),f<r}}),o===1/0)return null;let l=Math.sqrt(o);return e.point?e.point.copy(Ys):e.point=Ys.clone(),e.distance=l,e.faceIndex=c,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ie(0,new Float32Array(n),Ac),t.union(Ac)}),t}};var Eo=self;Eo.addEventListener("message",async function({data:i}){let t=performance.now();function e(o){let c=performance.now();(c-t>=10||o===1)&&(postMessage({error:void 0,serialized:void 0,position:void 0,progress:o}),t=c)}let{id:n,index:s,position:r,options:a}=i;try{let o=new Ge;if(o.setAttribute("position",new Kt(r,3,!1)),s&&o.setIndex(new Kt(s,1,!1)),a.includedProgressCallback&&(a.onProgress=e),a.groups){let h=a.groups;for(let d in h){let f=h[d];o.addGroup(f.start,f.count,f.materialIndex)}}let c=new Ke(o,a),l=Ke.serialize(c,{cloneBuffers:!1});Eo.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Eo.postMessage({id:n,error:o,serialized:void 0,position:void 0,progress:1})}});\n/*! Bundled license information:\n\nthree/build/three.module.js:\n (**\n * @license\n * Copyright 2010-2023 Three.js Authors\n * SPDX-License-Identifier: MIT\n *)\n*/\n')}var JS=class{constructor(){this.running=!1,this.worker=new OF,this.worker.onerror=e=>{throw e.message?new Error(`[GenerateMeshBVHWorker] Could not create Web Worker with error "${e.message}"`):new Error("[GenerateMeshBVHWorker] Could not create Web Worker.")}}isRunning(){return this.running}generate(e,t={}){if(this.running)return void $.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void $.warn("[GenerateMeshBVHWorker] Worker has been disposed.");let{worker:n}=this;this.running=!0;let i=new Map;e.forEach((e=>{i.set(e.id,e)}));let r=0;return new Promise(((e,a)=>{let s=()=>{++r===i.size&&(this.running=!1,n.onmessage=null,e())};n.onerror=e=>{$.warn(`[GenerateMeshBVHWorker] ${e.message}`),a(new Error(`[GenerateMeshBVHWorker] ${e.message}`)),this.running=!1},n.onmessage=e=>{this.running=!1;let{data:n}=e;if(n.error)$.warn(n.error),s();else if(n.serialized){let{serialized:e,position:r,id:a}=n,o=i.get(a),l=Al.deserialize(e,o,{setIndex:!1}),h=Object.assign({setBoundingBox:!0},t);if(h.transferred&&(o.attributes.position.array=r),o.index)t.saveOriginalIndex&&!o.userData.originalIndex&&(o.userData.originalIndex=o.index.array),$.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new Ct(e.index,1,!1);o.setIndex(t)}o.index&&($.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new lt)),o.boundsTree=l,s()}else t.onProgress&&t.onProgress(n.progress)};for(let r of i){let e=r[0],i=r[1],a=i.index?i.index.array:void 0,o=i.attributes.position,l=o.array;if(o.isInterleavedBufferAttribute||a&&a.isInterleavedBufferAttribute){$.warn("[GenerateMeshBVHWorker] InterleavedBufferAttribute are not supported for the geometry attributes."),s();continue}let h=[];t.transferred&&(h.push(l),a&&(h.push(a),t.saveOriginalIndex&&(i.userData.originalIndex=a.slice()))),n.postMessage({id:e,index:a,position:l,options:Qr(yn({},t),{onProgress:null,includedProgressCallback:Boolean(t.onProgress),groups:[...i.groups]})},h.length>0?h.map((e=>e.buffer)):[])}}))}dispose(){this.worker.terminate(),this.worker=void 0}};function NF(){return Ry('var Mr="152";var vo=0,Pr=1,yo=2;var Za=1,Mo=2,Xt=3,on=0,_t=1,Yt=2;var an=0,Yn=1,Lr=2,Ir=3,Ur=4,So=5,Wn=100,bo=101,Eo=102,Dr=103,Nr=104,wo=200,To=201,Ao=202,Ro=203,Ja=204,$a=205,Co=206,Po=207,Lo=208,Io=209,Uo=210,Do=0,No=1,Fo=2,Hs=3,Oo=4,Bo=5,zo=6,ko=7,Ka=0,Vo=1,Ho=2,Zt=0,Go=1,Wo=2,Xo=3,qo=4,Yo=5,Qa=300,Kn=301,Qn=302,Gs=303,Ws=304,rs=306,Xs=1e3,Lt=1001,qs=1002,ht=1003,Fr=1004;var ps=1005;var wt=1006,Zo=1007;var _i=1008;var bn=1009,Jo=1010,$o=1011,ja=1012,Ko=1013,xn=1014,vn=1015,xi=1016,Qo=1017,jo=1018,Zn=1020,ec=1021,It=1023,tc=1024,nc=1025,yn=1026,jn=1027,ic=1028,sc=1029,rc=1030,ac=1031,oc=1033,ms=33776,gs=33777,_s=33778,xs=33779,Or=35840,Br=35841,zr=35842,kr=35843,cc=36196,Vr=37492,Hr=37496,Gr=37808,Wr=37809,Xr=37810,qr=37811,Yr=37812,Zr=37813,Jr=37814,$r=37815,Kr=37816,Qr=37817,jr=37818,ea=37819,ta=37820,na=37821,vs=36492,lc=36283,ia=36284,sa=36285,ra=36286;var Xi=2300,qi=2301,ys=2302,aa=2400,oa=2401,ca=2402;var eo=3e3,Mn=3001,hc=3200,uc=3201,dc=0,fc=1,Sn="",Ee="srgb",Bt="srgb-linear",to="display-p3";var Ms=7680;var pc=519,la=35044;var ha="300 es",Ys=1035,cn=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){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let s=this._listeners[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},rt=["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"],ua=1234567,fi=Math.PI/180,vi=180/Math.PI;function si(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(rt[i&255]+rt[i>>8&255]+rt[i>>16&255]+rt[i>>24&255]+"-"+rt[e&255]+rt[e>>8&255]+"-"+rt[e>>16&15|64]+rt[e>>24&255]+"-"+rt[t&63|128]+rt[t>>8&255]+"-"+rt[t>>16&255]+rt[t>>24&255]+rt[n&255]+rt[n>>8&255]+rt[n>>16&255]+rt[n>>24&255]).toLowerCase()}function ut(i,e,t){return Math.max(e,Math.min(t,i))}function Sr(i,e){return(i%e+e)%e}function mc(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function gc(i,e,t){return i!==e?(t-i)/(e-i):0}function pi(i,e,t){return(1-t)*i+t*e}function _c(i,e,t,n){return pi(i,e,1-Math.exp(-t*n))}function xc(i,e=1){return e-Math.abs(Sr(i,e*2)-e)}function vc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function yc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Mc(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Sc(i,e){return i+Math.random()*(e-i)}function bc(i){return i*(.5-Math.random())}function Ec(i){i!==void 0&&(ua=i);let e=ua+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function wc(i){return i*fi}function Tc(i){return i*vi}function Zs(i){return(i&i-1)===0&&i!==0}function Ac(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function no(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Rc(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),u=o((e+n)/2),f=r((e-n)/2),d=o((e-n)/2),m=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*u,l*f,l*d,a*c);break;case"YZY":i.set(l*d,a*u,l*f,a*c);break;case"ZXZ":i.set(l*f,l*d,a*u,a*c);break;case"XZX":i.set(a*u,l*g,l*m,a*c);break;case"YXY":i.set(l*m,a*u,l*g,a*c);break;case"ZYZ":i.set(l*g,l*m,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ui(i,e){switch(e.constructor){case Float32Array:return i;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function gt(i,e){switch(e.constructor){case Float32Array:return i;case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var io={DEG2RAD:fi,RAD2DEG:vi,generateUUID:si,clamp:ut,euclideanModulo:Sr,mapLinear:mc,inverseLerp:gc,lerp:pi,damp:_c,pingpong:xc,smoothstep:vc,smootherstep:yc,randInt:Mc,randFloat:Sc,randFloatSpread:bc,seededRandom:Ec,degToRad:wc,radToDeg:Tc,isPowerOfTwo:Zs,ceilPowerOfTwo:Ac,floorPowerOfTwo:no,setQuaternionFromProperEuler:Rc,normalize:gt,denormalize:ui},Ve=class{constructor(e=0,t=0){Ve.prototype.isVector2=!0,this.x=e,this.y=t}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 new 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 new 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,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){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(ut(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),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ce=class{constructor(){Ce.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,s,r,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=s,u[2]=a,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=o,u[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,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],f=n[7],d=n[2],m=n[5],g=n[8],x=s[0],p=s[3],h=s[6],w=s[1],M=s[4],A=s[7],b=s[2],R=s[5],L=s[8];return r[0]=o*x+a*w+l*b,r[3]=o*p+a*M+l*R,r[6]=o*h+a*A+l*L,r[1]=c*x+u*w+f*b,r[4]=c*p+u*M+f*R,r[7]=c*h+u*A+f*L,r[2]=d*x+m*w+g*b,r[5]=d*p+m*M+g*R,r[8]=d*h+m*A+g*L,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],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*r*u+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=u*o-a*c,d=a*l-u*r,m=c*r-o*l,g=t*f+n*d+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return e[0]=f*x,e[1]=(s*c-u*n)*x,e[2]=(a*n-s*o)*x,e[3]=d*x,e[4]=(u*t-s*l)*x,e[5]=(s*r-a*t)*x,e[6]=m*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*r)*x,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,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Ss.makeScale(e,t)),this}rotate(e){return this.premultiply(Ss.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ss.makeTranslation(e,t)),this}makeTranslation(e,t){return 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 s=0;s<9;s++)if(t[s]!==n[s])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)}},Ss=new Ce;function so(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Yi(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}var da={};function mi(i){i in da||(da[i]=!0,console.warn(i))}function Jn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function bs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Cc=new Ce().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Pc=new Ce().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function Lc(i){return i.convertSRGBToLinear().applyMatrix3(Pc)}function Ic(i){return i.applyMatrix3(Cc).convertLinearToSRGB()}var Uc={[Bt]:i=>i,[Ee]:i=>i.convertSRGBToLinear(),[to]:Lc},Dc={[Bt]:i=>i,[Ee]:i=>i.convertLinearToSRGB(),[to]:Ic},At={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Bt},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,e,t){if(this.enabled===!1||e===t||!e||!t)return i;let n=Uc[e],s=Dc[t];if(n===void 0||s===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return s(n(i))},fromWorkingColorSpace:function(i,e){return this.convert(i,this.workingColorSpace,e)},toWorkingColorSpace:function(i,e){return this.convert(i,e,this.workingColorSpace)}},Rn,Zi=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Rn===void 0&&(Rn=Yi("canvas")),Rn.width=e.width,Rn.height=e.height;let n=Rn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Rn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){let t=Yi("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=Jn(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Jn(t[n]/255)*255):t[n]=Jn(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Ji=class{constructor(e=null){this.isSource=!0,this.uuid=si(),this.data=e,this.version=0}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:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Es(s[o].image)):r.push(Es(s[o]))}else r=Es(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Es(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?Zi.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Nc=0,ft=class extends cn{constructor(e=ft.DEFAULT_IMAGE,t=ft.DEFAULT_MAPPING,n=Lt,s=Lt,r=wt,o=_i,a=It,l=bn,c=ft.DEFAULT_ANISOTROPY,u=Sn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Nc++}),this.uuid=si(),this.name="",this.source=new Ji(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ce,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===Mn?Ee:Sn),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.5,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!==Qa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xs:e.x=e.x-Math.floor(e.x);break;case Lt:e.x=e.x<0?0:1;break;case qs:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Xs:e.y=e.y-Math.floor(e.y);break;case Lt:e.y=e.y<0?0:1;break;case qs:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-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)}get encoding(){return mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ee?Mn:eo}set encoding(e){mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Mn?Ee:Sn}};ft.DEFAULT_IMAGE=null;ft.DEFAULT_MAPPING=Qa;ft.DEFAULT_ANISOTROPY=1;var Je=class{constructor(e=0,t=0,n=0,s=1){Je.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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 new 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 new 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?e.w:1,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,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,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,s,r,l=e.elements,c=l[0],u=l[4],f=l[8],d=l[1],m=l[5],g=l[9],x=l[2],p=l[6],h=l[10];if(Math.abs(u-d)<.01&&Math.abs(f-x)<.01&&Math.abs(g-p)<.01){if(Math.abs(u+d)<.1&&Math.abs(f+x)<.1&&Math.abs(g+p)<.1&&Math.abs(c+m+h-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let M=(c+1)/2,A=(m+1)/2,b=(h+1)/2,R=(u+d)/4,L=(f+x)/4,V=(g+p)/4;return M>A&&M>b?M<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(M),s=R/n,r=L/n):A>b?A<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(A),n=R/s,r=V/s):b<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(b),n=L/r,s=V/r),this.set(n,s,r,t),this}let w=Math.sqrt((p-g)*(p-g)+(f-x)*(f-x)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(p-g)/w,this.y=(f-x)/w,this.z=(d-u)/w,this.w=Math.acos((c+m+h-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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 cn{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Je(0,0,e,t),this.scissorTest=!1,this.viewport=new Je(0,0,e,t);let s={width:e,height:t,depth:1};n.encoding!==void 0&&(mi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Mn?Ee:Sn),this.texture=new ft(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:wt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Ji(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},$i=class extends ft{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=ht,this.minFilter=ht,this.wrapR=Lt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Js=class extends ft{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=ht,this.minFilter=ht,this.wrapR=Lt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ln=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],u=n[s+2],f=n[s+3],d=r[o+0],m=r[o+1],g=r[o+2],x=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f;return}if(a===1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=x;return}if(f!==x||l!==d||c!==m||u!==g){let p=1-a,h=l*d+c*m+u*g+f*x,w=h>=0?1:-1,M=1-h*h;if(M>Number.EPSILON){let b=Math.sqrt(M),R=Math.atan2(b,h*w);p=Math.sin(p*R)/b,a=Math.sin(a*R)/b}let A=a*w;if(l=l*p+d*A,c=c*p+m*A,u=u*p+g*A,f=f*p+x*A,p===1-a){let b=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=b,c*=b,u*=b,f*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],u=n[s+3],f=r[o],d=r[o+1],m=r[o+2],g=r[o+3];return e[t]=a*g+u*f+l*m-c*d,e[t+1]=l*g+u*d+c*f-a*m,e[t+2]=c*g+u*m+a*d-l*f,e[t+3]=u*g-a*f-l*d-c*m,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(s/2),f=a(r/2),d=l(n/2),m=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=d*u*f+c*m*g,this._y=c*m*f-d*u*g,this._z=c*u*g+d*m*f,this._w=c*u*f-d*m*g;break;case"YXZ":this._x=d*u*f+c*m*g,this._y=c*m*f-d*u*g,this._z=c*u*g-d*m*f,this._w=c*u*f+d*m*g;break;case"ZXY":this._x=d*u*f-c*m*g,this._y=c*m*f+d*u*g,this._z=c*u*g+d*m*f,this._w=c*u*f-d*m*g;break;case"ZYX":this._x=d*u*f-c*m*g,this._y=c*m*f+d*u*g,this._z=c*u*g-d*m*f,this._w=c*u*f+d*m*g;break;case"YZX":this._x=d*u*f+c*m*g,this._y=c*m*f+d*u*g,this._z=c*u*g-d*m*f,this._w=c*u*f-d*m*g;break;case"XZY":this._x=d*u*f-c*m*g,this._y=c*m*f-d*u*g,this._z=c*u*g+d*m*f,this._w=c*u*f+d*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],f=t[10],d=n+a+f;if(d>0){let m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-l)*m,this._y=(r-c)*m,this._z=(o-s)*m}else if(n>a&&n>f){let m=2*Math.sqrt(1+n-a-f);this._w=(u-l)/m,this._x=.25*m,this._y=(s+o)/m,this._z=(r+c)/m}else if(a>f){let m=2*Math.sqrt(1+a-n-f);this._w=(r-c)/m,this._x=(s+o)/m,this._y=.25*m,this._z=(l+u)/m}else{let m=2*Math.sqrt(1+f-n-a);this._w=(o-s)/m,this._x=(r+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(ut(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),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=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=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,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+s*c-r*l,this._y=s*u+o*l+r*a-n*c,this._z=r*u+o*c+n*l-s*a,this._w=o*u-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,s=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=s,this._z=r,this;let l=1-a*a;if(l<=Number.EPSILON){let m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*s+t*this._y,this._z=m*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*f+this._w*d,this._x=n*f+this._x*d,this._y=s*f+this._y*d,this._z=r*f+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),s=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(s),n*Math.sin(r),n*Math.cos(r),t*Math.sin(s))}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}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}},D=class{constructor(e=0,t=0,n=0){D.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}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 new 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 new 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(fa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fa.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*s-a*n,u=l*n+a*t-r*s,f=l*s+r*n-o*t,d=-r*t-o*n-a*s;return this.x=c*l+d*-r+u*-a-f*-o,this.y=u*l+d*-o+f*-r-c*-a,this.z=f*l+d*-a+c*-o-u*-r,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,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){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,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,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 ws.copy(this).projectOnVector(e),this.sub(ws)}reflect(e){return this.sub(ws.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(ut(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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 s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ws=new D,fa=new ln,En=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-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(kt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(kt.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=kt.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){if(e.updateWorldMatrix(!1,!1),e.boundingBox!==void 0)e.boundingBox===null&&e.computeBoundingBox(),Cn.copy(e.boundingBox),Cn.applyMatrix4(e.matrixWorld),this.union(Cn);else{let s=e.geometry;if(s!==void 0)if(t&&s.attributes!==void 0&&s.attributes.position!==void 0){let r=s.attributes.position;for(let o=0,a=r.count;o<a;o++)kt.fromBufferAttribute(r,o).applyMatrix4(e.matrixWorld),this.expandByPoint(kt)}else s.boundingBox===null&&s.computeBoundingBox(),Cn.copy(s.boundingBox),Cn.applyMatrix4(e.matrixWorld),this.union(Cn)}let n=e.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],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,kt),kt.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(oi),Ei.subVectors(this.max,oi),Pn.subVectors(e.a,oi),Ln.subVectors(e.b,oi),In.subVectors(e.c,oi),en.subVectors(Ln,Pn),tn.subVectors(In,Ln),fn.subVectors(Pn,In);let t=[0,-en.z,en.y,0,-tn.z,tn.y,0,-fn.z,fn.y,en.z,0,-en.x,tn.z,0,-tn.x,fn.z,0,-fn.x,-en.y,en.x,0,-tn.y,tn.x,0,-fn.y,fn.x,0];return!Ts(t,Pn,Ln,In,Ei)||(t=[1,0,0,0,1,0,0,0,1],!Ts(t,Pn,Ln,In,Ei))?!1:(wi.crossVectors(en,tn),t=[wi.x,wi.y,wi.z],Ts(t,Pn,Ln,In,Ei))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kt).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:(zt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zt),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)}},zt=[new D,new D,new D,new D,new D,new D,new D,new D],kt=new D,Cn=new En,Pn=new D,Ln=new D,In=new D,en=new D,tn=new D,fn=new D,oi=new D,Ei=new D,wi=new D,pn=new D;function Ts(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){pn.fromArray(i,r);let a=s.x*Math.abs(pn.x)+s.y*Math.abs(pn.y)+s.z*Math.abs(pn.z),l=e.dot(pn),c=t.dot(pn),u=n.dot(pn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var Fc=new En,ci=new D,As=new D,yi=class{constructor(e=new D,t=-1){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?n.copy(t):Fc.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),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=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;ci.subVectors(e,this.center);let t=ci.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(ci,s/n),this.radius+=s}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):(As.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ci.copy(e.center).add(As)),this.expandByPoint(ci.copy(e.center).sub(As))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Vt=new D,Rs=new D,Ti=new D,nn=new D,Cs=new D,Ai=new D,Ps=new D,$s=class{constructor(e=new D,t=new D(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,Vt)),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=Vt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Vt.copy(this.origin).addScaledVector(this.direction,t),Vt.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Rs.copy(e).add(t).multiplyScalar(.5),Ti.copy(t).sub(e).normalize(),nn.copy(this.origin).sub(Rs);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Ti),a=nn.dot(this.direction),l=-nn.dot(Ti),c=nn.lengthSq(),u=Math.abs(1-o*o),f,d,m,g;if(u>0)if(f=o*l-a,d=o*a-l,g=r*u,f>=0)if(d>=-g)if(d<=g){let x=1/u;f*=x,d*=x,m=f*(f+o*d+2*a)+d*(o*f+d+2*l)+c}else d=r,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*l)+c;else d=-r,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*l)+c;else d<=-g?(f=Math.max(0,-(-o*r+a)),d=f>0?-r:Math.min(Math.max(-r,-l),r),m=-f*f+d*(d+2*l)+c):d<=g?(f=0,d=Math.min(Math.max(-r,-l),r),m=d*(d+2*l)+c):(f=Math.max(0,-(o*r+a)),d=f>0?r:Math.min(Math.max(-r,-l),r),m=-f*f+d*(d+2*l)+c);else d=o>0?-r:r,f=Math.max(0,-(o*d+a)),m=-f*f+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),s&&s.copy(Rs).addScaledVector(Ti,d),m}intersectSphere(e,t){Vt.subVectors(e.center,this.origin);let n=Vt.dot(this.direction),s=Vt.dot(Vt)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return 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,s,r,o,a,l,c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),f>=0?(a=(e.min.z-d.z)*f,l=(e.max.z-d.z)*f):(a=(e.max.z-d.z)*f,l=(e.min.z-d.z)*f),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Vt)!==null}intersectTriangle(e,t,n,s,r){Cs.subVectors(t,e),Ai.subVectors(n,e),Ps.crossVectors(Cs,Ai);let o=this.direction.dot(Ps),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;nn.subVectors(this.origin,e);let l=a*this.direction.dot(Ai.crossVectors(nn,Ai));if(l<0)return null;let c=a*this.direction.dot(Cs.cross(nn));if(c<0||l+c>o)return null;let u=-a*nn.dot(Ps);return u<0?null:this.at(u/o,r)}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)}},$e=class{constructor(){$e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,s,r,o,a,l,c,u,f,d,m,g,x,p){let h=this.elements;return h[0]=e,h[4]=t,h[8]=n,h[12]=s,h[1]=r,h[5]=o,h[9]=a,h[13]=l,h[2]=c,h[6]=u,h[10]=f,h[14]=d,h[3]=m,h[7]=g,h[11]=x,h[15]=p,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 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){let t=this.elements,n=e.elements,s=1/Un.setFromMatrixColumn(e,0).length(),r=1/Un.setFromMatrixColumn(e,1).length(),o=1/Un.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,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,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),u=Math.cos(r),f=Math.sin(r);if(e.order==="XYZ"){let d=o*u,m=o*f,g=a*u,x=a*f;t[0]=l*u,t[4]=-l*f,t[8]=c,t[1]=m+g*c,t[5]=d-x*c,t[9]=-a*l,t[2]=x-d*c,t[6]=g+m*c,t[10]=o*l}else if(e.order==="YXZ"){let d=l*u,m=l*f,g=c*u,x=c*f;t[0]=d+x*a,t[4]=g*a-m,t[8]=o*c,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=m*a-g,t[6]=x+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*u,m=l*f,g=c*u,x=c*f;t[0]=d-x*a,t[4]=-o*f,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*u,t[9]=x-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*u,m=o*f,g=a*u,x=a*f;t[0]=l*u,t[4]=g*c-m,t[8]=d*c+x,t[1]=l*f,t[5]=x*c+d,t[9]=m*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*u,t[4]=x-d*f,t[8]=g*f+m,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=m*f+g,t[10]=d-x*f}else if(e.order==="XZY"){let d=o*l,m=o*c,g=a*l,x=a*c;t[0]=l*u,t[4]=-f,t[8]=c*u,t[1]=d*f+x,t[5]=o*u,t[9]=m*f-g,t[2]=g*f-m,t[6]=a*u,t[10]=x*f+d}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(Oc,e,Bc)}lookAt(e,t,n){let s=this.elements;return yt.subVectors(e,t),yt.lengthSq()===0&&(yt.z=1),yt.normalize(),sn.crossVectors(n,yt),sn.lengthSq()===0&&(Math.abs(n.z)===1?yt.x+=1e-4:yt.z+=1e-4,yt.normalize(),sn.crossVectors(n,yt)),sn.normalize(),Ri.crossVectors(yt,sn),s[0]=sn.x,s[4]=Ri.x,s[8]=yt.x,s[1]=sn.y,s[5]=Ri.y,s[9]=yt.y,s[2]=sn.z,s[6]=Ri.z,s[10]=yt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],f=n[5],d=n[9],m=n[13],g=n[2],x=n[6],p=n[10],h=n[14],w=n[3],M=n[7],A=n[11],b=n[15],R=s[0],L=s[4],V=s[8],_=s[12],E=s[1],X=s[5],J=s[9],U=s[13],N=s[2],k=s[6],Q=s[10],q=s[14],W=s[3],Z=s[7],j=s[11],ue=s[15];return r[0]=o*R+a*E+l*N+c*W,r[4]=o*L+a*X+l*k+c*Z,r[8]=o*V+a*J+l*Q+c*j,r[12]=o*_+a*U+l*q+c*ue,r[1]=u*R+f*E+d*N+m*W,r[5]=u*L+f*X+d*k+m*Z,r[9]=u*V+f*J+d*Q+m*j,r[13]=u*_+f*U+d*q+m*ue,r[2]=g*R+x*E+p*N+h*W,r[6]=g*L+x*X+p*k+h*Z,r[10]=g*V+x*J+p*Q+h*j,r[14]=g*_+x*U+p*q+h*ue,r[3]=w*R+M*E+A*N+b*W,r[7]=w*L+M*X+A*k+b*Z,r[11]=w*V+M*J+A*Q+b*j,r[15]=w*_+M*U+A*q+b*ue,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],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],f=e[6],d=e[10],m=e[14],g=e[3],x=e[7],p=e[11],h=e[15];return g*(+r*l*f-s*c*f-r*a*d+n*c*d+s*a*m-n*l*m)+x*(+t*l*m-t*c*d+r*o*d-s*o*m+s*c*u-r*l*u)+p*(+t*c*f-t*a*m-r*o*f+n*o*m+r*a*u-n*c*u)+h*(-s*a*u-t*l*f+t*a*d+s*o*f-n*o*d+n*l*u)}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 s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=e[9],d=e[10],m=e[11],g=e[12],x=e[13],p=e[14],h=e[15],w=f*p*c-x*d*c+x*l*m-a*p*m-f*l*h+a*d*h,M=g*d*c-u*p*c-g*l*m+o*p*m+u*l*h-o*d*h,A=u*x*c-g*f*c+g*a*m-o*x*m-u*a*h+o*f*h,b=g*f*l-u*x*l-g*a*d+o*x*d+u*a*p-o*f*p,R=t*w+n*M+s*A+r*b;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let L=1/R;return e[0]=w*L,e[1]=(x*d*r-f*p*r-x*s*m+n*p*m+f*s*h-n*d*h)*L,e[2]=(a*p*r-x*l*r+x*s*c-n*p*c-a*s*h+n*l*h)*L,e[3]=(f*l*r-a*d*r-f*s*c+n*d*c+a*s*m-n*l*m)*L,e[4]=M*L,e[5]=(u*p*r-g*d*r+g*s*m-t*p*m-u*s*h+t*d*h)*L,e[6]=(g*l*r-o*p*r-g*s*c+t*p*c+o*s*h-t*l*h)*L,e[7]=(o*d*r-u*l*r+u*s*c-t*d*c-o*s*m+t*l*m)*L,e[8]=A*L,e[9]=(g*f*r-u*x*r-g*n*m+t*x*m+u*n*h-t*f*h)*L,e[10]=(o*x*r-g*a*r+g*n*c-t*x*c-o*n*h+t*a*h)*L,e[11]=(u*a*r-o*f*r-u*n*c+t*f*c+o*n*m-t*a*m)*L,e[12]=b*L,e[13]=(u*x*s-g*f*s+g*n*d-t*x*d-u*n*p+t*f*p)*L,e[14]=(g*a*s-o*x*s-g*n*l+t*x*l+o*n*p-t*a*p)*L,e[15]=(o*f*s-u*a*s+u*n*l-t*f*l-o*n*d+t*a*d)*L,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return 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),s=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,u=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,u*a+n,u*l-s*o,0,c*l-s*a,u*l+s*o,r*l*l+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,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,u=o+o,f=a+a,d=r*c,m=r*u,g=r*f,x=o*u,p=o*f,h=a*f,w=l*c,M=l*u,A=l*f,b=n.x,R=n.y,L=n.z;return s[0]=(1-(x+h))*b,s[1]=(m+A)*b,s[2]=(g-M)*b,s[3]=0,s[4]=(m-A)*R,s[5]=(1-(d+h))*R,s[6]=(p+w)*R,s[7]=0,s[8]=(g+M)*L,s[9]=(p-w)*L,s[10]=(1-(d+x))*L,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements,r=Un.set(s[0],s[1],s[2]).length(),o=Un.set(s[4],s[5],s[6]).length(),a=Un.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],Rt.copy(this);let c=1/r,u=1/o,f=1/a;return Rt.elements[0]*=c,Rt.elements[1]*=c,Rt.elements[2]*=c,Rt.elements[4]*=u,Rt.elements[5]*=u,Rt.elements[6]*=u,Rt.elements[8]*=f,Rt.elements[9]*=f,Rt.elements[10]*=f,t.setFromRotationMatrix(Rt),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,s,r,o){let a=this.elements,l=2*r/(t-e),c=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),d=-(o+r)/(o-r),m=-2*o*r/(o-r);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=f,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,s,r,o){let a=this.elements,l=1/(t-e),c=1/(n-s),u=1/(o-r),f=(t+e)*l,d=(n+s)*c,m=(o+r)*u;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-f,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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}},Un=new D,Rt=new $e,Oc=new D(0,0,0),Bc=new D(1,1,1),sn=new D,Ri=new D,yt=new D,pa=new $e,ma=new ln,ei=class{constructor(e=0,t=0,n=0,s=ei.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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 s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],u=s[9],f=s[2],d=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(ut(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ut(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(ut(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-ut(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(ut(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-ut(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return pa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pa,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ma.setFromEuler(this),this.setFromQuaternion(ma,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}};ei.DEFAULT_ORDER="XYZ";var Ki=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}},zc=0,ga=new D,Dn=new ln,Ht=new $e,Ci=new D,li=new D,kc=new D,Vc=new ln,_a=new D(1,0,0),xa=new D(0,1,0),va=new D(0,0,1),Hc={type:"added"},ya={type:"removed"},xt=class extends cn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:zc++}),this.uuid=si(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xt.DEFAULT_UP.clone();let e=new D,t=new ei,n=new ln,s=new D(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new $e},normalMatrix:{value:new Ce}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ki,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 Dn.setFromAxisAngle(e,t),this.quaternion.multiply(Dn),this}rotateOnWorldAxis(e,t){return Dn.setFromAxisAngle(e,t),this.quaternion.premultiply(Dn),this}rotateX(e){return this.rotateOnAxis(_a,e)}rotateY(e){return this.rotateOnAxis(xa,e)}rotateZ(e){return this.rotateOnAxis(va,e)}translateOnAxis(e,t){return ga.copy(e).applyQuaternion(this.quaternion),this.position.add(ga.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_a,e)}translateY(e){return this.translateOnAxis(xa,e)}translateZ(e){return this.translateOnAxis(va,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ht.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ci.copy(e):Ci.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),li.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ht.lookAt(li,Ci,this.up):Ht.lookAt(Ci,li,this.up),this.quaternion.setFromRotationMatrix(Ht),s&&(Ht.extractRotation(s.matrixWorld),Dn.setFromRotationMatrix(Ht),this.quaternion.premultiply(Dn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can\'t be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Hc)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ya)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(ya)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ht.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ht.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ht),this.add(e),e.updateWorldMatrix(!1,!0),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,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let s=0,r=this.children.length;s<r;s++){let o=this.children[s].getObjectsByProperty(e,t);o.length>0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(li,e,kc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(li,Vc,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,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;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),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(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,s=t.length;n<s;n++){let r=t[n];(r.matrixWorldAutoUpdate===!0||e===!0)&&r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let s=this.children;for(let r=0,o=s.length;r<o;r++){let a=s[r];a.matrixWorldAutoUpdate===!0&&a.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.5,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let f=l[c];r(e.shapes,f)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),f=o(e.shapes),d=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),d.length>0&&(n.skeletons=d),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}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),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};xt.DEFAULT_UP=new D(0,1,0);xt.DEFAULT_MATRIX_AUTO_UPDATE=!0;xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ct=new D,Gt=new D,Ls=new D,Wt=new D,Nn=new D,Fn=new D,Ma=new D,Is=new D,Us=new D,Ds=new D,Pi=!1,dt=class{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ct.subVectors(e,t),s.cross(Ct);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Ct.subVectors(s,t),Gt.subVectors(n,t),Ls.subVectors(e,t);let o=Ct.dot(Ct),a=Ct.dot(Gt),l=Ct.dot(Ls),c=Gt.dot(Gt),u=Gt.dot(Ls),f=o*c-a*a;if(f===0)return r.set(-2,-1,-1);let d=1/f,m=(c*l-a*u)*d,g=(o*u-a*l)*d;return r.set(1-m-g,g,m)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Wt),Wt.x>=0&&Wt.y>=0&&Wt.x+Wt.y<=1}static getUV(e,t,n,s,r,o,a,l){return Pi===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Pi=!0),this.getInterpolation(e,t,n,s,r,o,a,l)}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,Wt),l.setScalar(0),l.addScaledVector(r,Wt.x),l.addScaledVector(o,Wt.y),l.addScaledVector(a,Wt.z),l}static isFrontFacing(e,t,n,s){return Ct.subVectors(n,t),Gt.subVectors(e,t),Ct.cross(Gt).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 Ct.subVectors(this.c,this.b),Gt.subVectors(this.a,this.b),Ct.cross(Gt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,s,r){return Pi===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Pi=!0),dt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}getInterpolation(e,t,n,s,r){return dt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return dt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;Nn.subVectors(s,n),Fn.subVectors(r,n),Is.subVectors(e,n);let l=Nn.dot(Is),c=Fn.dot(Is);if(l<=0&&c<=0)return t.copy(n);Us.subVectors(e,s);let u=Nn.dot(Us),f=Fn.dot(Us);if(u>=0&&f<=u)return t.copy(s);let d=l*f-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(Nn,o);Ds.subVectors(e,r);let m=Nn.dot(Ds),g=Fn.dot(Ds);if(g>=0&&m<=g)return t.copy(r);let x=m*c-l*g;if(x<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(Fn,a);let p=u*g-m*f;if(p<=0&&f-u>=0&&m-g>=0)return Ma.subVectors(r,s),a=(f-u)/(f-u+(m-g)),t.copy(s).addScaledVector(Ma,a);let h=1/(p+x+d);return o=x*h,a=d*h,t.copy(n).addScaledVector(Nn,o).addScaledVector(Fn,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Gc=0,ti=class extends cn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gc++}),this.uuid=si(),this.name="",this.type="Material",this.blending=Yn,this.side=on,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Ja,this.blendDst=$a,this.blendEquation=Wn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Hs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ms,this.stencilZFail=Ms,this.stencilZPass=Ms,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.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}onBuild(){}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){console.warn(`THREE.Material: parameter \'${t}\' has value of undefined.`);continue}let s=this[t];if(s===void 0){console.warn(`THREE.Material: \'${t}\' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,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&&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.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.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.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!==Yn&&(n.blending=this.blending),this.side!==on&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==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.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),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=this.flatShading),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 s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}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.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 s=t.length;n=new Array(s);for(let r=0;r!==s;++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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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++}},ro={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={h:0,s:0,l:0},Li={h:0,s:0,l:0};function Ns(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var He=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ee){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,At.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=At.workingColorSpace){return this.r=e,this.g=t,this.b=n,At.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=At.workingColorSpace){if(e=Sr(e,1),t=ut(t,0,1),n=ut(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Ns(o,r,e+1/3),this.g=Ns(o,r,e),this.b=Ns(o,r,e-1/3)}return At.toWorkingColorSpace(this,s),this}setStyle(e,t=Ee){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\\w+)\\(([^\\)]*)\\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\\#([A-Fa-f\\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ee){let n=ro[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),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=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}copyLinearToSRGB(e){return this.r=bs(e.r),this.g=bs(e.g),this.b=bs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ee){return At.fromWorkingColorSpace(at.copy(this),e),Math.round(ut(at.r*255,0,255))*65536+Math.round(ut(at.g*255,0,255))*256+Math.round(ut(at.b*255,0,255))}getHexString(e=Ee){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=At.workingColorSpace){At.fromWorkingColorSpace(at.copy(this),t);let n=at.r,s=at.g,r=at.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case n:l=(s-r)/f+(s<r?6:0);break;case s:l=(r-n)/f+2;break;case r:l=(n-s)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=At.workingColorSpace){return At.fromWorkingColorSpace(at.copy(this),t),e.r=at.r,e.g=at.g,e.b=at.b,e}getStyle(e=Ee){At.fromWorkingColorSpace(at.copy(this),e);let t=at.r,n=at.g,s=at.b;return e!==Ee?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Pt),Pt.h+=e,Pt.s+=t,Pt.l+=n,this.setHSL(Pt.h,Pt.s,Pt.l),this}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(Pt),e.getHSL(Li);let n=pi(Pt.h,Li.h,t),s=pi(Pt.s,Li.s,t),r=pi(Pt.l,Li.l,t);return this.setHSL(n,s,r),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,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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}},at=new He;He.NAMES=ro;var Qi=class extends ti{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(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.combine=Ka,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.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}};var Ye=new D,Ii=new Ve,pt=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=la,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)Ii.fromBufferAttribute(this,t),Ii.applyMatrix3(e),this.setXY(t,Ii.x,Ii.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ye.fromBufferAttribute(this,t),Ye.applyMatrix3(e),this.setXYZ(t,Ye.x,Ye.y,Ye.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ye.fromBufferAttribute(this,t),Ye.applyMatrix4(e),this.setXYZ(t,Ye.x,Ye.y,Ye.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ye.fromBufferAttribute(this,t),Ye.applyNormalMatrix(e),this.setXYZ(t,Ye.x,Ye.y,Ye.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ye.fromBufferAttribute(this,t),Ye.transformDirection(e),this.setXYZ(t,Ye.x,Ye.y,Ye.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ui(t,this.array)),t}setX(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ui(t,this.array)),t}setY(e,t){return this.normalized&&(t=gt(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=ui(t,this.array)),t}setZ(e,t){return this.normalized&&(t=gt(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=ui(t,this.array)),t}setW(e,t){return this.normalized&&(t=gt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),n=gt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),n=gt(n,this.array),s=gt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=gt(t,this.array),n=gt(n,this.array),s=gt(s,this.array),r=gt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,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!==la&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}};var ji=class extends pt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var es=class extends pt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Jt=class extends pt{constructor(e,t,n){super(new Float32Array(e),t,n)}};var Wc=0,Et=new $e,Fs=new xt,On=new D,Mt=new En,hi=new En,nt=new D,Kt=class extends cn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Wc++}),this.uuid=si(),this.name="",this.type="BufferGeometry",this.index=null,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(so(e)?es:ji)(e,1):this.index=e,this}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 r=new Ce().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Et.makeRotationFromQuaternion(e),this.applyMatrix4(Et),this}rotateX(e){return Et.makeRotationX(e),this.applyMatrix4(Et),this}rotateY(e){return Et.makeRotationY(e),this.applyMatrix4(Et),this}rotateZ(e){return Et.makeRotationZ(e),this.applyMatrix4(Et),this}translate(e,t,n){return Et.makeTranslation(e,t,n),this.applyMatrix4(Et),this}scale(e,t,n){return Et.makeScale(e,t,n),this.applyMatrix4(Et),this}lookAt(e){return Fs.lookAt(e),Fs.updateMatrix(),this.applyMatrix4(Fs.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(On).negate(),this.translate(On.x,On.y,On.z),this}setFromPoints(e){let t=[];for(let n=0,s=e.length;n<s;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Jt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new En);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(\'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".\',this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];Mt.setFromBufferAttribute(r),this.morphTargetsRelative?(nt.addVectors(this.boundingBox.min,Mt.min),this.boundingBox.expandByPoint(nt),nt.addVectors(this.boundingBox.max,Mt.max),this.boundingBox.expandByPoint(nt)):(this.boundingBox.expandByPoint(Mt.min),this.boundingBox.expandByPoint(Mt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(\'THREE.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 yi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(\'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".\',this),this.boundingSphere.set(new D,1/0);return}if(e){let n=this.boundingSphere.center;if(Mt.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];hi.setFromBufferAttribute(a),this.morphTargetsRelative?(nt.addVectors(Mt.min,hi.min),Mt.expandByPoint(nt),nt.addVectors(Mt.max,hi.max),Mt.expandByPoint(nt)):(Mt.expandByPoint(hi.min),Mt.expandByPoint(hi.max))}Mt.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)nt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(nt));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)nt.fromBufferAttribute(a,c),l&&(On.fromBufferAttribute(e,c),nt.add(On)),s=Math.max(s,n.distanceToSquared(nt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error(\'THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.array,s=t.position.array,r=t.normal.array,o=t.uv.array,a=s.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new pt(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,c=[],u=[];for(let E=0;E<a;E++)c[E]=new D,u[E]=new D;let f=new D,d=new D,m=new D,g=new Ve,x=new Ve,p=new Ve,h=new D,w=new D;function M(E,X,J){f.fromArray(s,E*3),d.fromArray(s,X*3),m.fromArray(s,J*3),g.fromArray(o,E*2),x.fromArray(o,X*2),p.fromArray(o,J*2),d.sub(f),m.sub(f),x.sub(g),p.sub(g);let U=1/(x.x*p.y-p.x*x.y);isFinite(U)&&(h.copy(d).multiplyScalar(p.y).addScaledVector(m,-x.y).multiplyScalar(U),w.copy(m).multiplyScalar(x.x).addScaledVector(d,-p.x).multiplyScalar(U),c[E].add(h),c[X].add(h),c[J].add(h),u[E].add(w),u[X].add(w),u[J].add(w))}let A=this.groups;A.length===0&&(A=[{start:0,count:n.length}]);for(let E=0,X=A.length;E<X;++E){let J=A[E],U=J.start,N=J.count;for(let k=U,Q=U+N;k<Q;k+=3)M(n[k+0],n[k+1],n[k+2])}let b=new D,R=new D,L=new D,V=new D;function _(E){L.fromArray(r,E*3),V.copy(L);let X=c[E];b.copy(X),b.sub(L.multiplyScalar(L.dot(X))).normalize(),R.crossVectors(V,X);let U=R.dot(u[E])<0?-1:1;l[E*4]=b.x,l[E*4+1]=b.y,l[E*4+2]=b.z,l[E*4+3]=U}for(let E=0,X=A.length;E<X;++E){let J=A[E],U=J.start,N=J.count;for(let k=U,Q=U+N;k<Q;k+=3)_(n[k+0]),_(n[k+1]),_(n[k+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 pt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,m=n.count;d<m;d++)n.setXYZ(d,0,0,0);let s=new D,r=new D,o=new D,a=new D,l=new D,c=new D,u=new D,f=new D;if(e)for(let d=0,m=e.count;d<m;d+=3){let g=e.getX(d+0),x=e.getX(d+1),p=e.getX(d+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,p),u.subVectors(o,r),f.subVectors(s,r),u.cross(f),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,p),a.add(u),l.add(u),c.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let d=0,m=t.count;d<m;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,r),f.subVectors(s,r),u.cross(f),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)nt.fromBufferAttribute(e,t),nt.normalize(),e.setXYZ(t,nt.x,nt.y,nt.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,f=a.normalized,d=new c.constructor(l.length*u),m=0,g=0;for(let x=0,p=l.length;x<p;x++){a.isInterleavedBufferAttribute?m=l[x]*a.data.stride+a.offset:m=l[x]*u;for(let h=0;h<u;h++)d[g++]=c[m++]}return new pt(d,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Kt,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=e(l,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let u=0,f=c.length;u<f;u++){let d=c[u],m=e(d,n);l.push(m)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,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 l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let f=0,d=c.length;f<d;f++){let m=c[f];u.push(m.toJSON(e.data))}u.length>0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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(t));let s=e.attributes;for(let c in s){let u=s[c];this.setAttribute(c,u.clone(t))}let r=e.morphAttributes;for(let c in r){let u=[],f=r[c];for(let d=0,m=f.length;d<m;d++)u.push(f[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Sa=new $e,Nt=new $s,Ui=new yi,ba=new D,Bn=new D,zn=new D,kn=new D,Os=new D,Di=new D,Ni=new Ve,Fi=new Ve,Oi=new Ve,Ea=new D,wa=new D,Ta=new D,Bi=new D,zi=new D,Ot=class extends xt{constructor(e=new Kt,t=new Qi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){Di.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let u=a[l],f=r[l];u!==0&&(Os.fromBufferAttribute(f,e),o?Di.addScaledVector(Os,u):Di.addScaledVector(Os.sub(t),u))}t.add(Di)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ui.copy(n.boundingSphere),Ui.applyMatrix4(r),Nt.copy(e.ray).recast(e.near),!(Ui.containsPoint(Nt.origin)===!1&&(Nt.intersectSphere(Ui,ba)===null||Nt.origin.distanceToSquared(ba)>(e.far-e.near)**2))&&(Sa.copy(r).invert(),Nt.copy(e.ray).applyMatrix4(Sa),!(n.boundingBox!==null&&Nt.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t)))}_computeIntersections(e,t){let n,s=this.geometry,r=this.material,o=s.index,a=s.attributes.position,l=s.attributes.uv,c=s.attributes.uv1,u=s.attributes.normal,f=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(r))for(let m=0,g=f.length;m<g;m++){let x=f[m],p=r[x.materialIndex],h=Math.max(x.start,d.start),w=Math.min(o.count,Math.min(x.start+x.count,d.start+d.count));for(let M=h,A=w;M<A;M+=3){let b=o.getX(M),R=o.getX(M+1),L=o.getX(M+2);n=ki(this,p,e,Nt,l,c,u,b,R,L),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=x.materialIndex,t.push(n))}}else{let m=Math.max(0,d.start),g=Math.min(o.count,d.start+d.count);for(let x=m,p=g;x<p;x+=3){let h=o.getX(x),w=o.getX(x+1),M=o.getX(x+2);n=ki(this,r,e,Nt,l,c,u,h,w,M),n&&(n.faceIndex=Math.floor(x/3),t.push(n))}}else if(a!==void 0)if(Array.isArray(r))for(let m=0,g=f.length;m<g;m++){let x=f[m],p=r[x.materialIndex],h=Math.max(x.start,d.start),w=Math.min(a.count,Math.min(x.start+x.count,d.start+d.count));for(let M=h,A=w;M<A;M+=3){let b=M,R=M+1,L=M+2;n=ki(this,p,e,Nt,l,c,u,b,R,L),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=x.materialIndex,t.push(n))}}else{let m=Math.max(0,d.start),g=Math.min(a.count,d.start+d.count);for(let x=m,p=g;x<p;x+=3){let h=x,w=x+1,M=x+2;n=ki(this,r,e,Nt,l,c,u,h,w,M),n&&(n.faceIndex=Math.floor(x/3),t.push(n))}}}};function Xc(i,e,t,n,s,r,o,a){let l;if(e.side===_t?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,e.side===on,a),l===null)return null;zi.copy(a),zi.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(zi);return c<t.near||c>t.far?null:{distance:c,point:zi.clone(),object:i}}function ki(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,Bn),i.getVertexPosition(l,zn),i.getVertexPosition(c,kn);let u=Xc(i,e,t,n,Bn,zn,kn,Bi);if(u){s&&(Ni.fromBufferAttribute(s,a),Fi.fromBufferAttribute(s,l),Oi.fromBufferAttribute(s,c),u.uv=dt.getInterpolation(Bi,Bn,zn,kn,Ni,Fi,Oi,new Ve)),r&&(Ni.fromBufferAttribute(r,a),Fi.fromBufferAttribute(r,l),Oi.fromBufferAttribute(r,c),u.uv1=dt.getInterpolation(Bi,Bn,zn,kn,Ni,Fi,Oi,new Ve),u.uv2=u.uv1),o&&(Ea.fromBufferAttribute(o,a),wa.fromBufferAttribute(o,l),Ta.fromBufferAttribute(o,c),u.normal=dt.getInterpolation(Bi,Bn,zn,kn,Ea,wa,Ta,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new D,materialIndex:0};dt.getNormal(Bn,zn,kn,f.normal),u.face=f}return u}var wn=class extends Kt{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],u=[],f=[],d=0,m=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Jt(c,3)),this.setAttribute("normal",new Jt(u,3)),this.setAttribute("uv",new Jt(f,2));function g(x,p,h,w,M,A,b,R,L,V,_){let E=A/L,X=b/V,J=A/2,U=b/2,N=R/2,k=L+1,Q=V+1,q=0,W=0,Z=new D;for(let j=0;j<Q;j++){let ue=j*X-U;for(let oe=0;oe<k;oe++){let O=oe*E-J;Z[x]=O*w,Z[p]=ue*M,Z[h]=N,c.push(Z.x,Z.y,Z.z),Z[x]=0,Z[p]=0,Z[h]=R>0?1:-1,u.push(Z.x,Z.y,Z.z),f.push(oe/L),f.push(1-j/V),q+=1}}for(let j=0;j<V;j++)for(let ue=0;ue<L;ue++){let oe=d+ue+k*j,O=d+ue+k*(j+1),Y=d+(ue+1)+k*(j+1),ie=d+(ue+1)+k*j;l.push(oe,O,ie),l.push(O,Y,ie),W+=6}a.addGroup(m,W,_),m+=W,d+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function ni(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function lt(i){let e={};for(let t=0;t<i.length;t++){let n=ni(i[t]);for(let s in n)e[s]=n[s]}return e}function qc(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function ao(i){return i.getRenderTarget()===null?i.outputColorSpace:Bt}var Yc={clone:ni,merge:lt},Zc=`void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}`,Jc=`void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}`,Qt=class extends ti{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zc,this.fragmentShader=Jc,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ni(e.uniforms),this.uniformsGroups=qc(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},ts=class extends xt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},St=class extends ts{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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=vi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(fi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return vi*2*Math.atan(Math.tan(fi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,s,r,o){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=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(fi*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far),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}},Vn=-90,Hn=1,Ks=class extends xt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;let s=new St(Vn,Hn,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(1,0,0),this.add(s);let r=new St(Vn,Hn,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(-1,0,0),this.add(r);let o=new St(Vn,Hn,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new St(Vn,Hn,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new St(Vn,Hn,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let c=new St(Vn,Hn,e,t);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,-1),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget,[s,r,o,a,l,c]=this.children,u=e.getRenderTarget(),f=e.toneMapping,d=e.xr.enabled;e.toneMapping=Zt,e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,s),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=m,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.toneMapping=f,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}},ns=class extends ft{constructor(e,t,n,s,r,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:Kn,super(e,t,n,s,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Qs=class extends $t{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];t.encoding!==void 0&&(mi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Mn?Ee:Sn),this.texture=new ns(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:wt}fromEquirectangularTexture(e,t){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 n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t`,fragmentShader:`\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t`},s=new wn(5,5,5),r=new Qt({name:"CubemapFromEquirect",uniforms:ni(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:_t,blending:an});r.uniforms.tEquirect.value=t;let o=new Ot(s,r),a=t.minFilter;return t.minFilter===_i&&(t.minFilter=wt),new Ks(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,s){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},Bs=new D,$c=new D,Kc=new Ce,qt=class{constructor(e=new D(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Bs.subVectors(n,t).cross($c.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,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(Bs),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||Kc.getNormalMatrix(e),s=this.coplanarPoint(Bs).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),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)}},mn=new yi,Vi=new D,is=class{constructor(e=new qt,t=new qt,n=new qt,s=new qt,r=new qt,o=new qt){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,s=n[0],r=n[1],o=n[2],a=n[3],l=n[4],c=n[5],u=n[6],f=n[7],d=n[8],m=n[9],g=n[10],x=n[11],p=n[12],h=n[13],w=n[14],M=n[15];return t[0].setComponents(a-s,f-l,x-d,M-p).normalize(),t[1].setComponents(a+s,f+l,x+d,M+p).normalize(),t[2].setComponents(a+r,f+c,x+m,M+h).normalize(),t[3].setComponents(a-r,f-c,x-m,M-h).normalize(),t[4].setComponents(a-o,f-u,x-g,M-w).normalize(),t[5].setComponents(a+o,f+u,x+g,M+w).normalize(),this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),mn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mn)}intersectsSprite(e){return mn.center.set(0,0,0),mn.radius=.7071067811865476,mn.applyMatrix4(e.matrixWorld),this.intersectsSphere(mn)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(Vi.x=s.normal.x>0?e.max.x:e.min.x,Vi.y=s.normal.y>0?e.max.y:e.min.y,Vi.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Vi)<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)}};function oo(){let i=null,e=!1,t=null,n=null;function s(r,o){t(r,o),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Qc(i,e){let t=e.isWebGL2,n=new WeakMap;function s(c,u){let f=c.array,d=c.usage,m=i.createBuffer();i.bindBuffer(u,m),i.bufferData(u,f,d),c.onUploadCallback();let g;if(f instanceof Float32Array)g=i.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)g=i.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=i.UNSIGNED_SHORT;else if(f instanceof Int16Array)g=i.SHORT;else if(f instanceof Uint32Array)g=i.UNSIGNED_INT;else if(f instanceof Int32Array)g=i.INT;else if(f instanceof Int8Array)g=i.BYTE;else if(f instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:m,type:g,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version}}function r(c,u,f){let d=u.array,m=u.updateRange;i.bindBuffer(f,c),m.count===-1?i.bufferSubData(f,0,d):(t?i.bufferSubData(f,m.offset*d.BYTES_PER_ELEMENT,d,m.offset,m.count):i.bufferSubData(f,m.offset*d.BYTES_PER_ELEMENT,d.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=n.get(c);u&&(i.deleteBuffer(u.buffer),n.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=n.get(c);(!d||d.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);let f=n.get(c);f===void 0?n.set(c,s(c,u)):f.version<c.version&&(r(f.buffer,c,u),f.version=c.version)}return{get:o,remove:a,update:l}}var Mi=class extends Kt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(s),c=a+1,u=l+1,f=e/a,d=t/l,m=[],g=[],x=[],p=[];for(let h=0;h<u;h++){let w=h*d-o;for(let M=0;M<c;M++){let A=M*f-r;g.push(A,-w,0),x.push(0,0,1),p.push(M/a),p.push(1-h/l)}}for(let h=0;h<l;h++)for(let w=0;w<a;w++){let M=w+c*h,A=w+c*(h+1),b=w+1+c*(h+1),R=w+1+c*h;m.push(M,A,R),m.push(A,b,R)}this.setIndex(m),this.setAttribute("position",new Jt(g,3)),this.setAttribute("normal",new Jt(x,3)),this.setAttribute("uv",new Jt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mi(e.width,e.height,e.widthSegments,e.heightSegments)}},jc=`#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif`,el=`#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,tl=`#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif`,nl=`#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif`,il=`#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif`,sl=`#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif`,rl="vec3 transformed = vec3( position );",al=`vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif`,ol=`float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated`,cl=`#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif`,ll=`#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif`,hl=`#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif`,ul=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,dl=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,fl=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,pl=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,ml=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,gl=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,_l=`#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif`,xl=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,vl=`#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif`,yl=`vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif`,Ml=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Sl=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,bl=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,El=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,wl="gl_FragColor = linearToOutputTexel( gl_FragColor );",Tl=`vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}`,Al=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif`,Rl=`#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif`,Cl=`#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif`,Pl=`#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif`,Ll=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif`,Il=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,Ul=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,Dl=`#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,Nl=`#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif`,Fl=`#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}`,Ol=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,Bl=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,zl=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,kl=`varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert`,Vl=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif`,Hl=`#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif`,Gl=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,Wl=`varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon`,Xl=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,ql=`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong`,Yl=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif`,Zl=`struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,Jl=`\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,$l=`#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,Kl=`#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif`,Ql=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,jl=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,eh=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,th=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,nh=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,ih=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,sh=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,rh=`#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,ah=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,oh=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,ch=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif`,lh=`#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif`,hh=`#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif`,uh=`#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif`,dh=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_NORMALMAP_TANGENTSPACE\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;`,fh=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,ph=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,mh=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,gh=`#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif`,_h=`#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif`,xh=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,vh=`#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,yh=`#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif`,Mh=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Sh=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bh=`vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}`,Eh=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,wh=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,Th=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,Ah=`#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif`,Rh=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,Ch=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,Ph=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif`,Lh=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif`,Ih=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif`,Uh=`float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}`,Dh=`#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,Nh=`#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif`,Fh=`#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,Oh=`#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif`,Bh=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,zh=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,kh=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,Vh=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,Hh=`#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif`,Gh=`#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif`,Wh=`#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,Xh=`#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,qh=`#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,Yh=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif`,Zh=`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,Jh=`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,$h=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,Kh=`#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,Qh=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}`,jh=`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,eu=`#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}`,tu=`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}`,nu=`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}`,iu=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,su=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}`,ru=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}`,au=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,ou=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,cu=`#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}`,lu=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,hu=`#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,uu=`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,du=`#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}`,fu=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,pu=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}`,mu=`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}`,gu=`#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,_u=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,xu=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}`,vu=`#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,yu=`#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,Mu=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Su=`uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}`,bu=`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,Eu=`#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}`,wu=`uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}`,Tu=`uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}`,Au=`uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}`,Te={alphamap_fragment:jc,alphamap_pars_fragment:el,alphatest_fragment:tl,alphatest_pars_fragment:nl,aomap_fragment:il,aomap_pars_fragment:sl,begin_vertex:rl,beginnormal_vertex:al,bsdfs:ol,iridescence_fragment:cl,bumpmap_pars_fragment:ll,clipping_planes_fragment:hl,clipping_planes_pars_fragment:ul,clipping_planes_pars_vertex:dl,clipping_planes_vertex:fl,color_fragment:pl,color_pars_fragment:ml,color_pars_vertex:gl,color_vertex:_l,common:xl,cube_uv_reflection_fragment:vl,defaultnormal_vertex:yl,displacementmap_pars_vertex:Ml,displacementmap_vertex:Sl,emissivemap_fragment:bl,emissivemap_pars_fragment:El,encodings_fragment:wl,encodings_pars_fragment:Tl,envmap_fragment:Al,envmap_common_pars_fragment:Rl,envmap_pars_fragment:Cl,envmap_pars_vertex:Pl,envmap_physical_pars_fragment:Hl,envmap_vertex:Ll,fog_vertex:Il,fog_pars_vertex:Ul,fog_fragment:Dl,fog_pars_fragment:Nl,gradientmap_pars_fragment:Fl,lightmap_fragment:Ol,lightmap_pars_fragment:Bl,lights_lambert_fragment:zl,lights_lambert_pars_fragment:kl,lights_pars_begin:Vl,lights_toon_fragment:Gl,lights_toon_pars_fragment:Wl,lights_phong_fragment:Xl,lights_phong_pars_fragment:ql,lights_physical_fragment:Yl,lights_physical_pars_fragment:Zl,lights_fragment_begin:Jl,lights_fragment_maps:$l,lights_fragment_end:Kl,logdepthbuf_fragment:Ql,logdepthbuf_pars_fragment:jl,logdepthbuf_pars_vertex:eh,logdepthbuf_vertex:th,map_fragment:nh,map_pars_fragment:ih,map_particle_fragment:sh,map_particle_pars_fragment:rh,metalnessmap_fragment:ah,metalnessmap_pars_fragment:oh,morphcolor_vertex:ch,morphnormal_vertex:lh,morphtarget_pars_vertex:hh,morphtarget_vertex:uh,normal_fragment_begin:dh,normal_fragment_maps:fh,normal_pars_fragment:ph,normal_pars_vertex:mh,normal_vertex:gh,normalmap_pars_fragment:_h,clearcoat_normal_fragment_begin:xh,clearcoat_normal_fragment_maps:vh,clearcoat_pars_fragment:yh,iridescence_pars_fragment:Mh,output_fragment:Sh,packing:bh,premultiplied_alpha_fragment:Eh,project_vertex:wh,dithering_fragment:Th,dithering_pars_fragment:Ah,roughnessmap_fragment:Rh,roughnessmap_pars_fragment:Ch,shadowmap_pars_fragment:Ph,shadowmap_pars_vertex:Lh,shadowmap_vertex:Ih,shadowmask_pars_fragment:Uh,skinbase_vertex:Dh,skinning_pars_vertex:Nh,skinning_vertex:Fh,skinnormal_vertex:Oh,specularmap_fragment:Bh,specularmap_pars_fragment:zh,tonemapping_fragment:kh,tonemapping_pars_fragment:Vh,transmission_fragment:Hh,transmission_pars_fragment:Gh,uv_pars_fragment:Wh,uv_pars_vertex:Xh,uv_vertex:qh,worldpos_vertex:Yh,background_vert:Zh,background_frag:Jh,backgroundCube_vert:$h,backgroundCube_frag:Kh,cube_vert:Qh,cube_frag:jh,depth_vert:eu,depth_frag:tu,distanceRGBA_vert:nu,distanceRGBA_frag:iu,equirect_vert:su,equirect_frag:ru,linedashed_vert:au,linedashed_frag:ou,meshbasic_vert:cu,meshbasic_frag:lu,meshlambert_vert:hu,meshlambert_frag:uu,meshmatcap_vert:du,meshmatcap_frag:fu,meshnormal_vert:pu,meshnormal_frag:mu,meshphong_vert:gu,meshphong_frag:_u,meshphysical_vert:xu,meshphysical_frag:vu,meshtoon_vert:yu,meshtoon_frag:Mu,points_vert:Su,points_frag:bu,shadow_vert:Eu,shadow_frag:wu,sprite_vert:Tu,sprite_frag:Au},te={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ce},alphaMap:{value:null},alphaMapTransform:{value:new Ce},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ce}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ce}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ce}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ce},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ce},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ce},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ce}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ce}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ce}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new He(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Ce}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ce},alphaMap:{value:null},alphaTest:{value:0}}},Ft={basic:{uniforms:lt([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.fog]),vertexShader:Te.meshbasic_vert,fragmentShader:Te.meshbasic_frag},lambert:{uniforms:lt([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.fog,te.lights,{emissive:{value:new He(0)}}]),vertexShader:Te.meshlambert_vert,fragmentShader:Te.meshlambert_frag},phong:{uniforms:lt([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.fog,te.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30}}]),vertexShader:Te.meshphong_vert,fragmentShader:Te.meshphong_frag},standard:{uniforms:lt([te.common,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.roughnessmap,te.metalnessmap,te.fog,te.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Te.meshphysical_vert,fragmentShader:Te.meshphysical_frag},toon:{uniforms:lt([te.common,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.gradientmap,te.fog,te.lights,{emissive:{value:new He(0)}}]),vertexShader:Te.meshtoon_vert,fragmentShader:Te.meshtoon_frag},matcap:{uniforms:lt([te.common,te.bumpmap,te.normalmap,te.displacementmap,te.fog,{matcap:{value:null}}]),vertexShader:Te.meshmatcap_vert,fragmentShader:Te.meshmatcap_frag},points:{uniforms:lt([te.points,te.fog]),vertexShader:Te.points_vert,fragmentShader:Te.points_frag},dashed:{uniforms:lt([te.common,te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Te.linedashed_vert,fragmentShader:Te.linedashed_frag},depth:{uniforms:lt([te.common,te.displacementmap]),vertexShader:Te.depth_vert,fragmentShader:Te.depth_frag},normal:{uniforms:lt([te.common,te.bumpmap,te.normalmap,te.displacementmap,{opacity:{value:1}}]),vertexShader:Te.meshnormal_vert,fragmentShader:Te.meshnormal_frag},sprite:{uniforms:lt([te.sprite,te.fog]),vertexShader:Te.sprite_vert,fragmentShader:Te.sprite_frag},background:{uniforms:{uvTransform:{value:new Ce},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Te.background_vert,fragmentShader:Te.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Te.backgroundCube_vert,fragmentShader:Te.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Te.cube_vert,fragmentShader:Te.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Te.equirect_vert,fragmentShader:Te.equirect_frag},distanceRGBA:{uniforms:lt([te.common,te.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Te.distanceRGBA_vert,fragmentShader:Te.distanceRGBA_frag},shadow:{uniforms:lt([te.lights,te.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:Te.shadow_vert,fragmentShader:Te.shadow_frag}};Ft.physical={uniforms:lt([Ft.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ce},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ce},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ce},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ce},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ce},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ce},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ce},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ce},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ce},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ce},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ce}}]),vertexShader:Te.meshphysical_vert,fragmentShader:Te.meshphysical_frag};var Hi={r:0,b:0,g:0};function Ru(i,e,t,n,s,r,o){let a=new He(0),l=r===!0?0:1,c,u,f=null,d=0,m=null;function g(p,h){let w=!1,M=h.isScene===!0?h.background:null;switch(M&&M.isTexture&&(M=(h.backgroundBlurriness>0?t:e).get(M)),M===null?x(a,l):M&&M.isColor&&(x(M,1),w=!0),i.xr.getEnvironmentBlendMode()){case"opaque":w=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,o),w=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,o),w=!0;break}(i.autoClear||w)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),M&&(M.isCubeTexture||M.mapping===rs)?(u===void 0&&(u=new Ot(new wn(1,1,1),new Qt({name:"BackgroundCubeMaterial",uniforms:ni(Ft.backgroundCube.uniforms),vertexShader:Ft.backgroundCube.vertexShader,fragmentShader:Ft.backgroundCube.fragmentShader,side:_t,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(R,L,V){this.matrixWorld.copyPosition(V.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(u)),u.material.uniforms.envMap.value=M,u.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=h.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=h.backgroundIntensity,u.material.toneMapped=M.colorSpace!==Ee,(f!==M||d!==M.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,f=M,d=M.version,m=i.toneMapping),u.layers.enableAll(),p.unshift(u,u.geometry,u.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Ot(new Mi(2,2),new Qt({name:"BackgroundMaterial",uniforms:ni(Ft.background.uniforms),vertexShader:Ft.background.vertexShader,fragmentShader:Ft.background.fragmentShader,side:on,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=h.backgroundIntensity,c.material.toneMapped=M.colorSpace!==Ee,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||d!==M.version||m!==i.toneMapping)&&(c.material.needsUpdate=!0,f=M,d=M.version,m=i.toneMapping),c.layers.enableAll(),p.unshift(c,c.geometry,c.material,0,0,null))}function x(p,h){p.getRGB(Hi,ao(i)),n.buffers.color.setClear(Hi.r,Hi.g,Hi.b,h,o)}return{getClearColor:function(){return a},setClearColor:function(p,h=1){a.set(p),l=h,x(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(p){l=p,x(a,l)},render:g}}function Cu(i,e,t,n){let s=i.getParameter(i.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||r!==null,a={},l=p(null),c=l,u=!1;function f(N,k,Q,q,W){let Z=!1;if(o){let j=x(q,Q,k);c!==j&&(c=j,m(c.object)),Z=h(N,q,Q,W),Z&&w(N,q,Q,W)}else{let j=k.wireframe===!0;(c.geometry!==q.id||c.program!==Q.id||c.wireframe!==j)&&(c.geometry=q.id,c.program=Q.id,c.wireframe=j,Z=!0)}W!==null&&t.update(W,i.ELEMENT_ARRAY_BUFFER),(Z||u)&&(u=!1,V(N,k,Q,q),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(W).buffer))}function d(){return n.isWebGL2?i.createVertexArray():r.createVertexArrayOES()}function m(N){return n.isWebGL2?i.bindVertexArray(N):r.bindVertexArrayOES(N)}function g(N){return n.isWebGL2?i.deleteVertexArray(N):r.deleteVertexArrayOES(N)}function x(N,k,Q){let q=Q.wireframe===!0,W=a[N.id];W===void 0&&(W={},a[N.id]=W);let Z=W[k.id];Z===void 0&&(Z={},W[k.id]=Z);let j=Z[q];return j===void 0&&(j=p(d()),Z[q]=j),j}function p(N){let k=[],Q=[],q=[];for(let W=0;W<s;W++)k[W]=0,Q[W]=0,q[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:k,enabledAttributes:Q,attributeDivisors:q,object:N,attributes:{},index:null}}function h(N,k,Q,q){let W=c.attributes,Z=k.attributes,j=0,ue=Q.getAttributes();for(let oe in ue)if(ue[oe].location>=0){let Y=W[oe],ie=Z[oe];if(ie===void 0&&(oe==="instanceMatrix"&&N.instanceMatrix&&(ie=N.instanceMatrix),oe==="instanceColor"&&N.instanceColor&&(ie=N.instanceColor)),Y===void 0||Y.attribute!==ie||ie&&Y.data!==ie.data)return!0;j++}return c.attributesNum!==j||c.index!==q}function w(N,k,Q,q){let W={},Z=k.attributes,j=0,ue=Q.getAttributes();for(let oe in ue)if(ue[oe].location>=0){let Y=Z[oe];Y===void 0&&(oe==="instanceMatrix"&&N.instanceMatrix&&(Y=N.instanceMatrix),oe==="instanceColor"&&N.instanceColor&&(Y=N.instanceColor));let ie={};ie.attribute=Y,Y&&Y.data&&(ie.data=Y.data),W[oe]=ie,j++}c.attributes=W,c.attributesNum=j,c.index=q}function M(){let N=c.newAttributes;for(let k=0,Q=N.length;k<Q;k++)N[k]=0}function A(N){b(N,0)}function b(N,k){let Q=c.newAttributes,q=c.enabledAttributes,W=c.attributeDivisors;Q[N]=1,q[N]===0&&(i.enableVertexAttribArray(N),q[N]=1),W[N]!==k&&((n.isWebGL2?i:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,k),W[N]=k)}function R(){let N=c.newAttributes,k=c.enabledAttributes;for(let Q=0,q=k.length;Q<q;Q++)k[Q]!==N[Q]&&(i.disableVertexAttribArray(Q),k[Q]=0)}function L(N,k,Q,q,W,Z){n.isWebGL2===!0&&(Q===i.INT||Q===i.UNSIGNED_INT)?i.vertexAttribIPointer(N,k,Q,W,Z):i.vertexAttribPointer(N,k,Q,q,W,Z)}function V(N,k,Q,q){if(n.isWebGL2===!1&&(N.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();let W=q.attributes,Z=Q.getAttributes(),j=k.defaultAttributeValues;for(let ue in Z){let oe=Z[ue];if(oe.location>=0){let O=W[ue];if(O===void 0&&(ue==="instanceMatrix"&&N.instanceMatrix&&(O=N.instanceMatrix),ue==="instanceColor"&&N.instanceColor&&(O=N.instanceColor)),O!==void 0){let Y=O.normalized,ie=O.itemSize,re=t.get(O);if(re===void 0)continue;let C=re.buffer,be=re.type,Me=re.bytesPerElement;if(O.isInterleavedBufferAttribute){let ne=O.data,ve=ne.stride,Ne=O.offset;if(ne.isInstancedInterleavedBuffer){for(let pe=0;pe<oe.locationSize;pe++)b(oe.location+pe,ne.meshPerAttribute);N.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let pe=0;pe<oe.locationSize;pe++)A(oe.location+pe);i.bindBuffer(i.ARRAY_BUFFER,C);for(let pe=0;pe<oe.locationSize;pe++)L(oe.location+pe,ie/oe.locationSize,be,Y,ve*Me,(Ne+ie/oe.locationSize*pe)*Me)}else{if(O.isInstancedBufferAttribute){for(let ne=0;ne<oe.locationSize;ne++)b(oe.location+ne,O.meshPerAttribute);N.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=O.meshPerAttribute*O.count)}else for(let ne=0;ne<oe.locationSize;ne++)A(oe.location+ne);i.bindBuffer(i.ARRAY_BUFFER,C);for(let ne=0;ne<oe.locationSize;ne++)L(oe.location+ne,ie/oe.locationSize,be,Y,ie*Me,ie/oe.locationSize*ne*Me)}}else if(j!==void 0){let Y=j[ue];if(Y!==void 0)switch(Y.length){case 2:i.vertexAttrib2fv(oe.location,Y);break;case 3:i.vertexAttrib3fv(oe.location,Y);break;case 4:i.vertexAttrib4fv(oe.location,Y);break;default:i.vertexAttrib1fv(oe.location,Y)}}}}R()}function _(){J();for(let N in a){let k=a[N];for(let Q in k){let q=k[Q];for(let W in q)g(q[W].object),delete q[W];delete k[Q]}delete a[N]}}function E(N){if(a[N.id]===void 0)return;let k=a[N.id];for(let Q in k){let q=k[Q];for(let W in q)g(q[W].object),delete q[W];delete k[Q]}delete a[N.id]}function X(N){for(let k in a){let Q=a[k];if(Q[N.id]===void 0)continue;let q=Q[N.id];for(let W in q)g(q[W].object),delete q[W];delete Q[N.id]}}function J(){U(),u=!0,c!==l&&(c=l,m(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:J,resetDefaultState:U,dispose:_,releaseStatesOfGeometry:E,releaseStatesOfProgram:X,initAttributes:M,enableAttribute:A,disableUnusedAttributes:R}}function Pu(i,e,t,n){let s=n.isWebGL2,r;function o(c){r=c}function a(c,u){i.drawArrays(r,c,u),t.update(u,r,1)}function l(c,u,f){if(f===0)return;let d,m;if(s)d=i,m="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[m](r,c,u,f),t.update(u,r,f)}this.setMode=o,this.render=a,this.renderInstances=l}function Lu(i,e,t){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let L=e.get("EXT_texture_filter_anisotropic");n=i.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(L){if(L==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext!="undefined"&&i.constructor.name==="WebGL2RenderingContext",a=t.precision!==void 0?t.precision:"highp",l=r(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),d=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),x=i.getParameter(i.MAX_VERTEX_ATTRIBS),p=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),h=i.getParameter(i.MAX_VARYING_VECTORS),w=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=d>0,A=o||e.has("OES_texture_float"),b=M&&A,R=o?i.getParameter(i.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:s,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:d,maxTextureSize:m,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:p,maxVaryings:h,maxFragmentUniforms:w,vertexTextures:M,floatFragmentTextures:A,floatVertexTextures:b,maxSamples:R}}function Iu(i){let e=this,t=null,n=0,s=!1,r=!1,o=new qt,a=new Ce,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){let m=f.length!==0||d||n!==0||s;return s=d,n=f.length,m},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,d){t=u(f,d,0)},this.setState=function(f,d,m){let g=f.clippingPlanes,x=f.clipIntersection,p=f.clipShadows,h=i.get(f);if(!s||g===null||g.length===0||r&&!p)r?u(null):c();else{let w=r?0:n,M=w*4,A=h.clippingState||null;l.value=A,A=u(g,d,M,m);for(let b=0;b!==M;++b)A[b]=t[b];h.clippingState=A,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,d,m,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=l.value,g!==!0||p===null){let h=m+x*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(p===null||p.length<h)&&(p=new Float32Array(h));for(let M=0,A=m;M!==x;++M,A+=4)o.copy(f[M]).applyMatrix4(w,a),o.normal.toArray(p,A),p[A+3]=o.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,p}}function Uu(i){let e=new WeakMap;function t(o,a){return a===Gs?o.mapping=Kn:a===Ws&&(o.mapping=Qn),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===Gs||a===Ws)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new Qs(l.height/2);return c.fromEquirectangularTexture(i,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){let a=o.target;a.removeEventListener("dispose",s);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}var js=class extends ts{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=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=s,this.near=r,this.far=o,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,s,r,o){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=s,this.view.width=r,this.view.height=o,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,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far),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}},Xn=4,Aa=[.125,.215,.35,.446,.526,.582],_n=20,zs=new js,Ra=new He,ks=null,gn=(1+Math.sqrt(5))/2,Gn=1/gn,Ca=[new D(1,1,1),new D(-1,1,1),new D(1,1,-1),new D(-1,1,-1),new D(0,gn,Gn),new D(0,gn,-Gn),new D(Gn,0,gn),new D(-Gn,0,gn),new D(gn,Gn,0),new D(-gn,Gn,0)],ss=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,s=100){ks=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ia(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=La(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ks),e.scissorTest=!1,Gi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Kn||e.mapping===Qn?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ks=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:wt,minFilter:wt,generateMipmaps:!1,type:xi,format:It,colorSpace:Bt,depthBuffer:!1},s=Pa(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Pa(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Du(r)),this._blurMaterial=Nu(r,e,t)}return s}_compileMaterial(e){let t=new Ot(this._lodPlanes[0],e);this._renderer.compile(t,zs)}_sceneToCubeUV(e,t,n,s){let a=new St(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,d=u.toneMapping;u.getClearColor(Ra),u.toneMapping=Zt,u.autoClear=!1;let m=new Qi({name:"PMREM.Background",side:_t,depthWrite:!1,depthTest:!1}),g=new Ot(new wn,m),x=!1,p=e.background;p?p.isColor&&(m.color.copy(p),e.background=null,x=!0):(m.color.copy(Ra),x=!0);for(let h=0;h<6;h++){let w=h%3;w===0?(a.up.set(0,l[h],0),a.lookAt(c[h],0,0)):w===1?(a.up.set(0,0,l[h]),a.lookAt(0,c[h],0)):(a.up.set(0,l[h],0),a.lookAt(0,0,c[h]));let M=this._cubeSize;Gi(s,w*M,h>2?M:0,M,M),u.setRenderTarget(s),x&&u.render(g,a),u.render(e,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=d,u.autoClear=f,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===Kn||e.mapping===Qn;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ia()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=La());let r=s?this._cubemapMaterial:this._equirectMaterial,o=new Ot(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;Gi(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,zs)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let s=1;s<this._lodPlanes.length;s++){let r=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Ca[(s-1)%Ca.length];this._blur(e,s-1,s,r,o)}t.autoClear=n}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,f=new Ot(this._lodPlanes[s],c),d=c.uniforms,m=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*_n-1),x=r/g,p=isFinite(r)?1+Math.floor(u*x):_n;p>_n&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${_n}`);let h=[],w=0;for(let L=0;L<_n;++L){let V=L/x,_=Math.exp(-V*V/2);h.push(_),L===0?w+=_:L<p&&(w+=2*_)}for(let L=0;L<h.length;L++)h[L]=h[L]/w;d.envMap.value=e.texture,d.samples.value=p,d.weights.value=h,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:M}=this;d.dTheta.value=g,d.mipInt.value=M-n;let A=this._sizeLods[s],b=3*A*(s>M-Xn?s-M+Xn:0),R=4*(this._cubeSize-A);Gi(t,b,R,3*A,2*A),l.setRenderTarget(t),l.render(f,zs)}};function Du(i){let e=[],t=[],n=[],s=i,r=i-Xn+1+Aa.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);t.push(a);let l=1/a;o>i-Xn?l=Aa[o-i+Xn-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),u=-c,f=1+c,d=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,g=6,x=3,p=2,h=1,w=new Float32Array(x*g*m),M=new Float32Array(p*g*m),A=new Float32Array(h*g*m);for(let R=0;R<m;R++){let L=R%3*2/3-1,V=R>2?0:-1,_=[L,V,0,L+2/3,V,0,L+2/3,V+1,0,L,V,0,L+2/3,V+1,0,L,V+1,0];w.set(_,x*g*R),M.set(d,p*g*R);let E=[R,R,R,R,R,R];A.set(E,h*g*R)}let b=new Kt;b.setAttribute("position",new pt(w,x)),b.setAttribute("uv",new pt(M,p)),b.setAttribute("faceIndex",new pt(A,h)),e.push(b),s>Xn&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Pa(i,e,t){let n=new $t(i,e,t);return n.texture.mapping=rs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Gi(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function Nu(i,e,t){let n=new Float32Array(_n),s=new D(0,1,0);return new Qt({name:"SphericalGaussianBlur",defines:{n:_n,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:br(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues\' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t`,blending:an,depthTest:!1,depthWrite:!1})}function La(){return new Qt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:br(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t`,blending:an,depthTest:!1,depthWrite:!1})}function Ia(){return new Qt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:br(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t`,blending:an,depthTest:!1,depthWrite:!1})}function br(){return`\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t`}function Fu(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===Gs||l===Ws,u=l===Kn||l===Qn;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let f=e.get(a);return t===null&&(t=new ss(i)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),e.set(a,f),f.texture}else{if(e.has(a))return e.get(a).texture;{let f=a.image;if(c&&f&&f.height>0||u&&f&&s(f)){t===null&&(t=new ss(i));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",r),d.texture}else return null}}}return a}function s(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function r(a){let l=a.target;l.removeEventListener("dispose",r);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function Ou(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){let s=t(n);return s===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function Bu(i,e,t,n){let s={},r=new WeakMap;function o(f){let d=f.target;d.index!==null&&e.remove(d.index);for(let g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete s[d.id];let m=r.get(d);m&&(e.remove(m),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(f,d){return s[d.id]===!0||(d.addEventListener("dispose",o),s[d.id]=!0,t.memory.geometries++),d}function l(f){let d=f.attributes;for(let g in d)e.update(d[g],i.ARRAY_BUFFER);let m=f.morphAttributes;for(let g in m){let x=m[g];for(let p=0,h=x.length;p<h;p++)e.update(x[p],i.ARRAY_BUFFER)}}function c(f){let d=[],m=f.index,g=f.attributes.position,x=0;if(m!==null){let w=m.array;x=m.version;for(let M=0,A=w.length;M<A;M+=3){let b=w[M+0],R=w[M+1],L=w[M+2];d.push(b,R,R,L,L,b)}}else{let w=g.array;x=g.version;for(let M=0,A=w.length/3-1;M<A;M+=3){let b=M+0,R=M+1,L=M+2;d.push(b,R,R,L,L,b)}}let p=new(so(d)?es:ji)(d,1);p.version=x;let h=r.get(f);h&&e.remove(h),r.set(f,p)}function u(f){let d=r.get(f);if(d){let m=f.index;m!==null&&d.version<m.version&&c(f)}else c(f);return r.get(f)}return{get:a,update:l,getWireframeAttribute:u}}function zu(i,e,t,n){let s=n.isWebGL2,r;function o(d){r=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function u(d,m){i.drawElements(r,m,a,d*l),t.update(m,r,1)}function f(d,m,g){if(g===0)return;let x,p;if(s)x=i,p="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),p="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[p](r,m,a,d*l,g),t.update(m,r,g)}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=f}function ku(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Vu(i,e){return i[0]-e[0]}function Hu(i,e){return Math.abs(e[1])-Math.abs(i[1])}function Gu(i,e,t){let n={},s=new Float32Array(8),r=new WeakMap,o=new Je,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,f){let d=c.morphTargetInfluences;if(e.isWebGL2===!0){let m=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,g=m!==void 0?m.length:0,x=r.get(u);if(x===void 0||x.count!==g){let N=function(){J.dispose(),r.delete(u),u.removeEventListener("dispose",N)};x!==void 0&&x.texture.dispose();let w=u.morphAttributes.position!==void 0,M=u.morphAttributes.normal!==void 0,A=u.morphAttributes.color!==void 0,b=u.morphAttributes.position||[],R=u.morphAttributes.normal||[],L=u.morphAttributes.color||[],V=0;w===!0&&(V=1),M===!0&&(V=2),A===!0&&(V=3);let _=u.attributes.position.count*V,E=1;_>e.maxTextureSize&&(E=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);let X=new Float32Array(_*E*4*g),J=new $i(X,_,E,g);J.type=vn,J.needsUpdate=!0;let U=V*4;for(let k=0;k<g;k++){let Q=b[k],q=R[k],W=L[k],Z=_*E*4*k;for(let j=0;j<Q.count;j++){let ue=j*U;w===!0&&(o.fromBufferAttribute(Q,j),X[Z+ue+0]=o.x,X[Z+ue+1]=o.y,X[Z+ue+2]=o.z,X[Z+ue+3]=0),M===!0&&(o.fromBufferAttribute(q,j),X[Z+ue+4]=o.x,X[Z+ue+5]=o.y,X[Z+ue+6]=o.z,X[Z+ue+7]=0),A===!0&&(o.fromBufferAttribute(W,j),X[Z+ue+8]=o.x,X[Z+ue+9]=o.y,X[Z+ue+10]=o.z,X[Z+ue+11]=W.itemSize===4?o.w:1)}}x={count:g,texture:J,size:new Ve(_,E)},r.set(u,x),u.addEventListener("dispose",N)}let p=0;for(let w=0;w<d.length;w++)p+=d[w];let h=u.morphTargetsRelative?1:1-p;f.getUniforms().setValue(i,"morphTargetBaseInfluence",h),f.getUniforms().setValue(i,"morphTargetInfluences",d),f.getUniforms().setValue(i,"morphTargetsTexture",x.texture,t),f.getUniforms().setValue(i,"morphTargetsTextureSize",x.size)}else{let m=d===void 0?0:d.length,g=n[u.id];if(g===void 0||g.length!==m){g=[];for(let M=0;M<m;M++)g[M]=[M,0];n[u.id]=g}for(let M=0;M<m;M++){let A=g[M];A[0]=M,A[1]=d[M]}g.sort(Hu);for(let M=0;M<8;M++)M<m&&g[M][1]?(a[M][0]=g[M][0],a[M][1]=g[M][1]):(a[M][0]=Number.MAX_SAFE_INTEGER,a[M][1]=0);a.sort(Vu);let x=u.morphAttributes.position,p=u.morphAttributes.normal,h=0;for(let M=0;M<8;M++){let A=a[M],b=A[0],R=A[1];b!==Number.MAX_SAFE_INTEGER&&R?(x&&u.getAttribute("morphTarget"+M)!==x[b]&&u.setAttribute("morphTarget"+M,x[b]),p&&u.getAttribute("morphNormal"+M)!==p[b]&&u.setAttribute("morphNormal"+M,p[b]),s[M]=R,h+=R):(x&&u.hasAttribute("morphTarget"+M)===!0&&u.deleteAttribute("morphTarget"+M),p&&u.hasAttribute("morphNormal"+M)===!0&&u.deleteAttribute("morphNormal"+M),s[M]=0)}let w=u.morphTargetsRelative?1:1-h;f.getUniforms().setValue(i,"morphTargetBaseInfluence",w),f.getUniforms().setValue(i,"morphTargetInfluences",s)}}return{update:l}}function Wu(i,e,t,n){let s=new WeakMap;function r(l){let c=n.render.frame,u=l.geometry,f=e.get(l,u);return s.get(f)!==c&&(e.update(f),s.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER)),f}function o(){s=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}var co=new ft,lo=new $i,ho=new Js,uo=new ns,Ua=[],Da=[],Na=new Float32Array(16),Fa=new Float32Array(9),Oa=new Float32Array(4);function ri(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Ua[s];if(r===void 0&&(r=new Float32Array(s),Ua[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Ke(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Qe(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function as(i,e){let t=Da[e];t===void 0&&(t=new Int32Array(e),Da[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Xu(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function qu(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ke(t,e))return;i.uniform2fv(this.addr,e),Qe(t,e)}}function Yu(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ke(t,e))return;i.uniform3fv(this.addr,e),Qe(t,e)}}function Zu(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ke(t,e))return;i.uniform4fv(this.addr,e),Qe(t,e)}}function Ju(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ke(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Qe(t,e)}else{if(Ke(t,n))return;Oa.set(n),i.uniformMatrix2fv(this.addr,!1,Oa),Qe(t,n)}}function $u(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ke(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Qe(t,e)}else{if(Ke(t,n))return;Fa.set(n),i.uniformMatrix3fv(this.addr,!1,Fa),Qe(t,n)}}function Ku(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Ke(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Qe(t,e)}else{if(Ke(t,n))return;Na.set(n),i.uniformMatrix4fv(this.addr,!1,Na),Qe(t,n)}}function Qu(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function ju(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ke(t,e))return;i.uniform2iv(this.addr,e),Qe(t,e)}}function ed(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ke(t,e))return;i.uniform3iv(this.addr,e),Qe(t,e)}}function td(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ke(t,e))return;i.uniform4iv(this.addr,e),Qe(t,e)}}function nd(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function id(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ke(t,e))return;i.uniform2uiv(this.addr,e),Qe(t,e)}}function sd(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ke(t,e))return;i.uniform3uiv(this.addr,e),Qe(t,e)}}function rd(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ke(t,e))return;i.uniform4uiv(this.addr,e),Qe(t,e)}}function ad(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2D(e||co,s)}function od(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||ho,s)}function cd(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||uo,s)}function ld(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||lo,s)}function hd(i){switch(i){case 5126:return Xu;case 35664:return qu;case 35665:return Yu;case 35666:return Zu;case 35674:return Ju;case 35675:return $u;case 35676:return Ku;case 5124:case 35670:return Qu;case 35667:case 35671:return ju;case 35668:case 35672:return ed;case 35669:case 35673:return td;case 5125:return nd;case 36294:return id;case 36295:return sd;case 36296:return rd;case 35678:case 36198:case 36298:case 36306:case 35682:return ad;case 35679:case 36299:case 36307:return od;case 35680:case 36300:case 36308:case 36293:return cd;case 36289:case 36303:case 36311:case 36292:return ld}}function ud(i,e){i.uniform1fv(this.addr,e)}function dd(i,e){let t=ri(e,this.size,2);i.uniform2fv(this.addr,t)}function fd(i,e){let t=ri(e,this.size,3);i.uniform3fv(this.addr,t)}function pd(i,e){let t=ri(e,this.size,4);i.uniform4fv(this.addr,t)}function md(i,e){let t=ri(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function gd(i,e){let t=ri(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function _d(i,e){let t=ri(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function xd(i,e){i.uniform1iv(this.addr,e)}function vd(i,e){i.uniform2iv(this.addr,e)}function yd(i,e){i.uniform3iv(this.addr,e)}function Md(i,e){i.uniform4iv(this.addr,e)}function Sd(i,e){i.uniform1uiv(this.addr,e)}function bd(i,e){i.uniform2uiv(this.addr,e)}function Ed(i,e){i.uniform3uiv(this.addr,e)}function wd(i,e){i.uniform4uiv(this.addr,e)}function Td(i,e,t){let n=this.cache,s=e.length,r=as(t,s);Ke(n,r)||(i.uniform1iv(this.addr,r),Qe(n,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||co,r[o])}function Ad(i,e,t){let n=this.cache,s=e.length,r=as(t,s);Ke(n,r)||(i.uniform1iv(this.addr,r),Qe(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||ho,r[o])}function Rd(i,e,t){let n=this.cache,s=e.length,r=as(t,s);Ke(n,r)||(i.uniform1iv(this.addr,r),Qe(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||uo,r[o])}function Cd(i,e,t){let n=this.cache,s=e.length,r=as(t,s);Ke(n,r)||(i.uniform1iv(this.addr,r),Qe(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||lo,r[o])}function Pd(i){switch(i){case 5126:return ud;case 35664:return dd;case 35665:return fd;case 35666:return pd;case 35674:return md;case 35675:return gd;case 35676:return _d;case 5124:case 35670:return xd;case 35667:case 35671:return vd;case 35668:case 35672:return yd;case 35669:case 35673:return Md;case 5125:return Sd;case 36294:return bd;case 36295:return Ed;case 36296:return wd;case 35678:case 36198:case 36298:case 36306:case 35682:return Td;case 35679:case 36299:case 36307:return Ad;case 35680:case 36300:case 36308:case 36293:return Rd;case 36289:case 36303:case 36311:case 36292:return Cd}}var er=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=hd(t.type)}},tr=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=Pd(t.type)}},nr=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},Vs=/(\\w+)(\\])?(\\[|\\.)?/g;function Ba(i,e){i.seq.push(e),i.map[e.id]=e}function Ld(i,e,t){let n=i.name,s=n.length;for(Vs.lastIndex=0;;){let r=Vs.exec(n),o=Vs.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){Ba(t,c===void 0?new er(a,i,e):new tr(a,i,e));break}else{let f=t.map[a];f===void 0&&(f=new nr(a),Ba(t,f)),t=f}}}var $n=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);Ld(r,o,this)}}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function za(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var Id=0;function Ud(i,e){let t=i.split(`\n`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`\n`)}function Dd(i){switch(i){case Bt:return["Linear","( value )"];case Ee:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function ka(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=i.getShaderInfoLog(e).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\\d+)/.exec(s);if(r){let o=parseInt(r[1]);return t.toUpperCase()+`\n\n`+s+`\n\n`+Ud(i.getShaderSource(e),o)}else return s}function Nd(i,e){let t=Dd(e);return"vec4 "+i+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Fd(i,e){let t;switch(e){case Go:t="Linear";break;case Wo:t="Reinhard";break;case Xo:t="OptimizedCineon";break;case qo:t="ACESFilmic";break;case Yo:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Od(i){return[i.extensionDerivatives||i.envMapCubeUVHeight||i.bumpMap||i.normalMapTangentSpace||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(di).join(`\n`)}function Bd(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`\n`)}function zd(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function di(i){return i!==""}function Va(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ha(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var kd=/^[ \\t]*#include +<([\\w\\d./]+)>/gm;function ir(i){return i.replace(kd,Vd)}function Vd(i,e){let t=Te[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return ir(t)}var Hd=/#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;function Ga(i){return i.replace(Hd,Gd)}function Gd(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\\[\\s*i\\s*\\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Wa(i){let e="precision "+i.precision+` float;\nprecision `+i.precision+" int;";return i.precision==="highp"?e+=`\n#define HIGH_PRECISION`:i.precision==="mediump"?e+=`\n#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`\n#define LOW_PRECISION`),e}function Wd(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Za?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Mo?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Xt&&(e="SHADOWMAP_TYPE_VSM"),e}function Xd(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Kn:case Qn:e="ENVMAP_TYPE_CUBE";break;case rs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function qd(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Qn:e="ENVMAP_MODE_REFRACTION";break}return e}function Yd(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Ka:e="ENVMAP_BLENDING_MULTIPLY";break;case Vo:e="ENVMAP_BLENDING_MIX";break;case Ho:e="ENVMAP_BLENDING_ADD";break}return e}function Zd(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function Jd(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=Wd(t),c=Xd(t),u=qd(t),f=Yd(t),d=Zd(t),m=t.isWebGL2?"":Od(t),g=Bd(r),x=s.createProgram(),p,h,w=t.glslVersion?"#version "+t.glslVersion+`\n`:"";t.isRawShaderMaterial?(p=[g].filter(di).join(`\n`),p.length>0&&(p+=`\n`),h=[m,g].filter(di).join(`\n`),h.length>0&&(h+=`\n`)):(p=[Wa(t),"#define SHADER_NAME "+t.shaderName,g,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`\n`].filter(di).join(`\n`),h=[m,Wa(t),"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Zt?"#define TONE_MAPPING":"",t.toneMapping!==Zt?Te.tonemapping_pars_fragment:"",t.toneMapping!==Zt?Fd("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Te.encodings_pars_fragment,Nd("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`\n`].filter(di).join(`\n`)),o=ir(o),o=Va(o,t),o=Ha(o,t),a=ir(a),a=Va(a,t),a=Ha(a,t),o=Ga(o),a=Ga(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(w=`#version 300 es\n`,p=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`\n`)+`\n`+p,h=["#define varying in",t.glslVersion===ha?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ha?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`\n`)+`\n`+h);let M=w+p+o,A=w+h+a,b=za(s,s.VERTEX_SHADER,M),R=za(s,s.FRAGMENT_SHADER,A);if(s.attachShader(x,b),s.attachShader(x,R),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x),i.debug.checkShaderErrors){let _=s.getProgramInfoLog(x).trim(),E=s.getShaderInfoLog(b).trim(),X=s.getShaderInfoLog(R).trim(),J=!0,U=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,b,R);else{let N=ka(s,b,"vertex"),k=ka(s,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`\n\nProgram Info Log: `+_+`\n`+N+`\n`+k)}else _!==""?console.warn("THREE.WebGLProgram: Program Info Log:",_):(E===""||X==="")&&(U=!1);U&&(this.diagnostics={runnable:J,programLog:_,vertexShader:{log:E,prefix:p},fragmentShader:{log:X,prefix:h}})}s.deleteShader(b),s.deleteShader(R);let L;this.getUniforms=function(){return L===void 0&&(L=new $n(s,x)),L};let V;return this.getAttributes=function(){return V===void 0&&(V=zd(s,x)),V},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.name=t.shaderName,this.id=Id++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=R,this}var $d=0,sr=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new rr(e),t.set(e,n)),n}},rr=class{constructor(e){this.id=$d++,this.code=e,this.usedTimes=0}};function Kd(i,e,t,n,s,r,o){let a=new Ki,l=new sr,c=[],u=s.isWebGL2,f=s.logarithmicDepthBuffer,d=s.vertexTextures,m=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(_){return _===1?"uv1":_===2?"uv2":_===3?"uv3":"uv"}function p(_,E,X,J,U){let N=J.fog,k=U.geometry,Q=_.isMeshStandardMaterial?J.environment:null,q=(_.isMeshStandardMaterial?t:e).get(_.envMap||Q),W=q&&q.mapping===rs?q.image.height:null,Z=g[_.type];_.precision!==null&&(m=s.getMaxPrecision(_.precision),m!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",m,"instead."));let j=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,ue=j!==void 0?j.length:0,oe=0;k.morphAttributes.position!==void 0&&(oe=1),k.morphAttributes.normal!==void 0&&(oe=2),k.morphAttributes.color!==void 0&&(oe=3);let O,Y,ie,re;if(Z){let ze=Ft[Z];O=ze.vertexShader,Y=ze.fragmentShader}else O=_.vertexShader,Y=_.fragmentShader,l.update(_),ie=l.getVertexShaderID(_),re=l.getFragmentShaderID(_);let C=i.getRenderTarget(),be=U.isInstancedMesh===!0,Me=!!_.map,ne=!!_.matcap,ve=!!q,Ne=!!_.aoMap,pe=!!_.lightMap,Pe=!!_.bumpMap,je=!!_.normalMap,it=!!_.displacementMap,et=!!_.emissiveMap,Ze=!!_.metalnessMap,Fe=!!_.roughnessMap,Ge=_.clearcoat>0,mt=_.iridescence>0,S=_.sheen>0,v=_.transmission>0,F=Ge&&!!_.clearcoatMap,K=Ge&&!!_.clearcoatNormalMap,ee=Ge&&!!_.clearcoatRoughnessMap,se=mt&&!!_.iridescenceMap,ye=mt&&!!_.iridescenceThicknessMap,le=S&&!!_.sheenColorMap,H=S&&!!_.sheenRoughnessMap,de=!!_.specularMap,me=!!_.specularColorMap,_e=!!_.specularIntensityMap,ce=v&&!!_.transmissionMap,fe=v&&!!_.thicknessMap,Ie=!!_.gradientMap,Oe=!!_.alphaMap,We=_.alphaTest>0,T=!!_.extensions,B=!!k.attributes.uv1,$=!!k.attributes.uv2,ae=!!k.attributes.uv3;return{isWebGL2:u,shaderID:Z,shaderName:_.type,vertexShader:O,fragmentShader:Y,defines:_.defines,customVertexShaderID:ie,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:m,instancing:be,instancingColor:be&&U.instanceColor!==null,supportsVertexTextures:d,outputColorSpace:C===null?i.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:Bt,map:Me,matcap:ne,envMap:ve,envMapMode:ve&&q.mapping,envMapCubeUVHeight:W,aoMap:Ne,lightMap:pe,bumpMap:Pe,normalMap:je,displacementMap:d&&it,emissiveMap:et,normalMapObjectSpace:je&&_.normalMapType===fc,normalMapTangentSpace:je&&_.normalMapType===dc,metalnessMap:Ze,roughnessMap:Fe,clearcoat:Ge,clearcoatMap:F,clearcoatNormalMap:K,clearcoatRoughnessMap:ee,iridescence:mt,iridescenceMap:se,iridescenceThicknessMap:ye,sheen:S,sheenColorMap:le,sheenRoughnessMap:H,specularMap:de,specularColorMap:me,specularIntensityMap:_e,transmission:v,transmissionMap:ce,thicknessMap:fe,gradientMap:Ie,opaque:_.transparent===!1&&_.blending===Yn,alphaMap:Oe,alphaTest:We,combine:_.combine,mapUv:Me&&x(_.map.channel),aoMapUv:Ne&&x(_.aoMap.channel),lightMapUv:pe&&x(_.lightMap.channel),bumpMapUv:Pe&&x(_.bumpMap.channel),normalMapUv:je&&x(_.normalMap.channel),displacementMapUv:it&&x(_.displacementMap.channel),emissiveMapUv:et&&x(_.emissiveMap.channel),metalnessMapUv:Ze&&x(_.metalnessMap.channel),roughnessMapUv:Fe&&x(_.roughnessMap.channel),clearcoatMapUv:F&&x(_.clearcoatMap.channel),clearcoatNormalMapUv:K&&x(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ee&&x(_.clearcoatRoughnessMap.channel),iridescenceMapUv:se&&x(_.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&x(_.iridescenceThicknessMap.channel),sheenColorMapUv:le&&x(_.sheenColorMap.channel),sheenRoughnessMapUv:H&&x(_.sheenRoughnessMap.channel),specularMapUv:de&&x(_.specularMap.channel),specularColorMapUv:me&&x(_.specularColorMap.channel),specularIntensityMapUv:_e&&x(_.specularIntensityMap.channel),transmissionMapUv:ce&&x(_.transmissionMap.channel),thicknessMapUv:fe&&x(_.thicknessMap.channel),alphaMapUv:Oe&&x(_.alphaMap.channel),vertexTangents:je&&!!k.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,vertexUv1s:B,vertexUv2s:$,vertexUv3s:ae,pointsUvs:U.isPoints===!0&&!!k.attributes.uv&&(Me||Oe),fog:!!N,useFog:_.fog===!0,fogExp2:N&&N.isFogExp2,flatShading:_.flatShading===!0,sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:U.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:oe,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&X.length>0,shadowMapType:i.shadowMap.type,toneMapping:_.toneMapped?i.toneMapping:Zt,useLegacyLights:i.useLegacyLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Yt,flipSided:_.side===_t,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionDerivatives:T&&_.extensions.derivatives===!0,extensionFragDepth:T&&_.extensions.fragDepth===!0,extensionDrawBuffers:T&&_.extensions.drawBuffers===!0,extensionShaderTextureLOD:T&&_.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function h(_){let E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(let X in _.defines)E.push(X),E.push(_.defines[X]);return _.isRawShaderMaterial===!1&&(w(E,_),M(E,_),E.push(i.outputColorSpace)),E.push(_.customProgramCacheKey),E.join()}function w(_,E){_.push(E.precision),_.push(E.outputColorSpace),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.mapUv),_.push(E.alphaMapUv),_.push(E.lightMapUv),_.push(E.aoMapUv),_.push(E.bumpMapUv),_.push(E.normalMapUv),_.push(E.displacementMapUv),_.push(E.emissiveMapUv),_.push(E.metalnessMapUv),_.push(E.roughnessMapUv),_.push(E.clearcoatMapUv),_.push(E.clearcoatNormalMapUv),_.push(E.clearcoatRoughnessMapUv),_.push(E.iridescenceMapUv),_.push(E.iridescenceThicknessMapUv),_.push(E.sheenColorMapUv),_.push(E.sheenRoughnessMapUv),_.push(E.specularMapUv),_.push(E.specularColorMapUv),_.push(E.specularIntensityMapUv),_.push(E.transmissionMapUv),_.push(E.thicknessMapUv),_.push(E.combine),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numSpotLightMaps),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.numSpotLightShadowsWithMaps),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function M(_,E){a.disableAll(),E.isWebGL2&&a.enable(0),E.supportsVertexTextures&&a.enable(1),E.instancing&&a.enable(2),E.instancingColor&&a.enable(3),E.matcap&&a.enable(4),E.envMap&&a.enable(5),E.normalMapObjectSpace&&a.enable(6),E.normalMapTangentSpace&&a.enable(7),E.clearcoat&&a.enable(8),E.iridescence&&a.enable(9),E.alphaTest&&a.enable(10),E.vertexColors&&a.enable(11),E.vertexAlphas&&a.enable(12),E.vertexUv1s&&a.enable(13),E.vertexUv2s&&a.enable(14),E.vertexUv3s&&a.enable(15),E.vertexTangents&&a.enable(16),_.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.skinning&&a.enable(4),E.morphTargets&&a.enable(5),E.morphNormals&&a.enable(6),E.morphColors&&a.enable(7),E.premultipliedAlpha&&a.enable(8),E.shadowMapEnabled&&a.enable(9),E.useLegacyLights&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),_.push(a.mask)}function A(_){let E=g[_.type],X;if(E){let J=Ft[E];X=Yc.clone(J.uniforms)}else X=_.uniforms;return X}function b(_,E){let X;for(let J=0,U=c.length;J<U;J++){let N=c[J];if(N.cacheKey===E){X=N,++X.usedTimes;break}}return X===void 0&&(X=new Jd(i,E,_,r),c.push(X)),X}function R(_){if(--_.usedTimes===0){let E=c.indexOf(_);c[E]=c[c.length-1],c.pop(),_.destroy()}}function L(_){l.remove(_)}function V(){l.dispose()}return{getParameters:p,getProgramCacheKey:h,getUniforms:A,acquireProgram:b,releaseProgram:R,releaseShaderCache:L,programs:c,dispose:V}}function Qd(){let i=new WeakMap;function e(r){let o=i.get(r);return o===void 0&&(o={},i.set(r,o)),o}function t(r){i.delete(r)}function n(r,o,a){i.get(r)[o]=a}function s(){i=new WeakMap}return{get:e,remove:t,update:n,dispose:s}}function jd(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function Xa(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function qa(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(f,d,m,g,x,p){let h=i[e];return h===void 0?(h={id:f.id,object:f,geometry:d,material:m,groupOrder:g,renderOrder:f.renderOrder,z:x,group:p},i[e]=h):(h.id=f.id,h.object=f,h.geometry=d,h.material=m,h.groupOrder=g,h.renderOrder=f.renderOrder,h.z=x,h.group=p),e++,h}function a(f,d,m,g,x,p){let h=o(f,d,m,g,x,p);m.transmission>0?n.push(h):m.transparent===!0?s.push(h):t.push(h)}function l(f,d,m,g,x,p){let h=o(f,d,m,g,x,p);m.transmission>0?n.unshift(h):m.transparent===!0?s.unshift(h):t.unshift(h)}function c(f,d){t.length>1&&t.sort(f||jd),n.length>1&&n.sort(d||Xa),s.length>1&&s.sort(d||Xa)}function u(){for(let f=e,d=i.length;f<d;f++){let m=i[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:a,unshift:l,finish:u,sort:c}}function ef(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new qa,i.set(n,[o])):s>=r.length?(o=new qa,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function tf(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new He};break;case"SpotLight":t={position:new D,direction:new D,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new He,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new He,groundColor:new He};break;case"RectAreaLight":t={color:new He,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function nf(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var sf=0;function rf(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function af(i,e){let t=new tf,n=nf(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let u=0;u<9;u++)s.probe.push(new D);let r=new D,o=new $e,a=new $e;function l(u,f){let d=0,m=0,g=0;for(let X=0;X<9;X++)s.probe[X].set(0,0,0);let x=0,p=0,h=0,w=0,M=0,A=0,b=0,R=0,L=0,V=0;u.sort(rf);let _=f===!0?Math.PI:1;for(let X=0,J=u.length;X<J;X++){let U=u[X],N=U.color,k=U.intensity,Q=U.distance,q=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)d+=N.r*k*_,m+=N.g*k*_,g+=N.b*k*_;else if(U.isLightProbe)for(let W=0;W<9;W++)s.probe[W].addScaledVector(U.sh.coefficients[W],k);else if(U.isDirectionalLight){let W=t.get(U);if(W.color.copy(U.color).multiplyScalar(U.intensity*_),U.castShadow){let Z=U.shadow,j=n.get(U);j.shadowBias=Z.bias,j.shadowNormalBias=Z.normalBias,j.shadowRadius=Z.radius,j.shadowMapSize=Z.mapSize,s.directionalShadow[x]=j,s.directionalShadowMap[x]=q,s.directionalShadowMatrix[x]=U.shadow.matrix,A++}s.directional[x]=W,x++}else if(U.isSpotLight){let W=t.get(U);W.position.setFromMatrixPosition(U.matrixWorld),W.color.copy(N).multiplyScalar(k*_),W.distance=Q,W.coneCos=Math.cos(U.angle),W.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),W.decay=U.decay,s.spot[h]=W;let Z=U.shadow;if(U.map&&(s.spotLightMap[L]=U.map,L++,Z.updateMatrices(U),U.castShadow&&V++),s.spotLightMatrix[h]=Z.matrix,U.castShadow){let j=n.get(U);j.shadowBias=Z.bias,j.shadowNormalBias=Z.normalBias,j.shadowRadius=Z.radius,j.shadowMapSize=Z.mapSize,s.spotShadow[h]=j,s.spotShadowMap[h]=q,R++}h++}else if(U.isRectAreaLight){let W=t.get(U);W.color.copy(N).multiplyScalar(k),W.halfWidth.set(U.width*.5,0,0),W.halfHeight.set(0,U.height*.5,0),s.rectArea[w]=W,w++}else if(U.isPointLight){let W=t.get(U);if(W.color.copy(U.color).multiplyScalar(U.intensity*_),W.distance=U.distance,W.decay=U.decay,U.castShadow){let Z=U.shadow,j=n.get(U);j.shadowBias=Z.bias,j.shadowNormalBias=Z.normalBias,j.shadowRadius=Z.radius,j.shadowMapSize=Z.mapSize,j.shadowCameraNear=Z.camera.near,j.shadowCameraFar=Z.camera.far,s.pointShadow[p]=j,s.pointShadowMap[p]=q,s.pointShadowMatrix[p]=U.shadow.matrix,b++}s.point[p]=W,p++}else if(U.isHemisphereLight){let W=t.get(U);W.skyColor.copy(U.color).multiplyScalar(k*_),W.groundColor.copy(U.groundColor).multiplyScalar(k*_),s.hemi[M]=W,M++}}w>0&&(e.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=te.LTC_FLOAT_1,s.rectAreaLTC2=te.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=te.LTC_HALF_1,s.rectAreaLTC2=te.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=d,s.ambient[1]=m,s.ambient[2]=g;let E=s.hash;(E.directionalLength!==x||E.pointLength!==p||E.spotLength!==h||E.rectAreaLength!==w||E.hemiLength!==M||E.numDirectionalShadows!==A||E.numPointShadows!==b||E.numSpotShadows!==R||E.numSpotMaps!==L)&&(s.directional.length=x,s.spot.length=h,s.rectArea.length=w,s.point.length=p,s.hemi.length=M,s.directionalShadow.length=A,s.directionalShadowMap.length=A,s.pointShadow.length=b,s.pointShadowMap.length=b,s.spotShadow.length=R,s.spotShadowMap.length=R,s.directionalShadowMatrix.length=A,s.pointShadowMatrix.length=b,s.spotLightMatrix.length=R+L-V,s.spotLightMap.length=L,s.numSpotLightShadowsWithMaps=V,E.directionalLength=x,E.pointLength=p,E.spotLength=h,E.rectAreaLength=w,E.hemiLength=M,E.numDirectionalShadows=A,E.numPointShadows=b,E.numSpotShadows=R,E.numSpotMaps=L,s.version=sf++)}function c(u,f){let d=0,m=0,g=0,x=0,p=0,h=f.matrixWorldInverse;for(let w=0,M=u.length;w<M;w++){let A=u[w];if(A.isDirectionalLight){let b=s.directional[d];b.direction.setFromMatrixPosition(A.matrixWorld),r.setFromMatrixPosition(A.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(h),d++}else if(A.isSpotLight){let b=s.spot[g];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(h),b.direction.setFromMatrixPosition(A.matrixWorld),r.setFromMatrixPosition(A.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(h),g++}else if(A.isRectAreaLight){let b=s.rectArea[x];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(h),a.identity(),o.copy(A.matrixWorld),o.premultiply(h),a.extractRotation(o),b.halfWidth.set(A.width*.5,0,0),b.halfHeight.set(0,A.height*.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),x++}else if(A.isPointLight){let b=s.point[m];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(h),m++}else if(A.isHemisphereLight){let b=s.hemi[p];b.direction.setFromMatrixPosition(A.matrixWorld),b.direction.transformDirection(h),p++}}}return{setup:l,setupView:c,state:s}}function Ya(i,e){let t=new af(i,e),n=[],s=[];function r(){n.length=0,s.length=0}function o(f){n.push(f)}function a(f){s.push(f)}function l(f){t.setup(n,f)}function c(f){t.setupView(n,f)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function of(i,e){let t=new WeakMap;function n(r,o=0){let a=t.get(r),l;return a===void 0?(l=new Ya(i,e),t.set(r,[l])):o>=a.length?(l=new Ya(i,e),a.push(l)):l=a[o],l}function s(){t=new WeakMap}return{get:n,dispose:s}}var ar=class extends ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},or=class extends ti{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},cf=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,lf=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`;function hf(i,e,t){let n=new is,s=new Ve,r=new Ve,o=new Je,a=new ar({depthPacking:uc}),l=new or,c={},u=t.maxTextureSize,f={[on]:_t,[_t]:on,[Yt]:Yt},d=new Qt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:cf,fragmentShader:lf}),m=d.clone();m.defines.HORIZONTAL_PASS=1;let g=new Kt;g.setAttribute("position",new pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ot(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Za;let h=this.type;this.render=function(b,R,L){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||b.length===0)return;let V=i.getRenderTarget(),_=i.getActiveCubeFace(),E=i.getActiveMipmapLevel(),X=i.state;X.setBlending(an),X.buffers.color.setClear(1,1,1,1),X.buffers.depth.setTest(!0),X.setScissorTest(!1);let J=h!==Xt&&this.type===Xt,U=h===Xt&&this.type!==Xt;for(let N=0,k=b.length;N<k;N++){let Q=b[N],q=Q.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",Q,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;s.copy(q.mapSize);let W=q.getFrameExtents();if(s.multiply(W),r.copy(q.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/W.x),s.x=r.x*W.x,q.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/W.y),s.y=r.y*W.y,q.mapSize.y=r.y)),q.map===null||J===!0||U===!0){let j=this.type!==Xt?{minFilter:ht,magFilter:ht}:{};q.map!==null&&q.map.dispose(),q.map=new $t(s.x,s.y,j),q.map.texture.name=Q.name+".shadowMap",q.camera.updateProjectionMatrix()}i.setRenderTarget(q.map),i.clear();let Z=q.getViewportCount();for(let j=0;j<Z;j++){let ue=q.getViewport(j);o.set(r.x*ue.x,r.y*ue.y,r.x*ue.z,r.y*ue.w),X.viewport(o),q.updateMatrices(Q,j),n=q.getFrustum(),A(R,L,q.camera,Q,this.type)}q.isPointLightShadow!==!0&&this.type===Xt&&w(q,L),q.needsUpdate=!1}h=this.type,p.needsUpdate=!1,i.setRenderTarget(V,_,E)};function w(b,R){let L=e.update(x);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,m.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new $t(s.x,s.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,L,d,x,null),m.uniforms.shadow_pass.value=b.mapPass.texture,m.uniforms.resolution.value=b.mapSize,m.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(R,null,L,m,x,null)}function M(b,R,L,V){let _=null,E=L.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(E!==void 0)_=E;else if(_=L.isPointLight===!0?l:a,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let X=_.uuid,J=R.uuid,U=c[X];U===void 0&&(U={},c[X]=U);let N=U[J];N===void 0&&(N=_.clone(),U[J]=N),_=N}if(_.visible=R.visible,_.wireframe=R.wireframe,V===Xt?_.side=R.shadowSide!==null?R.shadowSide:R.side:_.side=R.shadowSide!==null?R.shadowSide:f[R.side],_.alphaMap=R.alphaMap,_.alphaTest=R.alphaTest,_.map=R.map,_.clipShadows=R.clipShadows,_.clippingPlanes=R.clippingPlanes,_.clipIntersection=R.clipIntersection,_.displacementMap=R.displacementMap,_.displacementScale=R.displacementScale,_.displacementBias=R.displacementBias,_.wireframeLinewidth=R.wireframeLinewidth,_.linewidth=R.linewidth,L.isPointLight===!0&&_.isMeshDistanceMaterial===!0){let X=i.properties.get(_);X.light=L}return _}function A(b,R,L,V,_){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&_===Xt)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,b.matrixWorld);let J=e.update(b),U=b.material;if(Array.isArray(U)){let N=J.groups;for(let k=0,Q=N.length;k<Q;k++){let q=N[k],W=U[q.materialIndex];if(W&&W.visible){let Z=M(b,W,V,_);i.renderBufferDirect(L,null,J,Z,b,q)}}}else if(U.visible){let N=M(b,U,V,_);i.renderBufferDirect(L,null,J,N,b,null)}}let X=b.children;for(let J=0,U=X.length;J<U;J++)A(X[J],R,L,V,_)}}function uf(i,e,t){let n=t.isWebGL2;function s(){let T=!1,B=new Je,$=null,ae=new Je(0,0,0,0);return{setMask:function(he){$!==he&&!T&&(i.colorMask(he,he,he,he),$=he)},setLocked:function(he){T=he},setClear:function(he,ze,ke,st,jt){jt===!0&&(he*=st,ze*=st,ke*=st),B.set(he,ze,ke,st),ae.equals(B)===!1&&(i.clearColor(he,ze,ke,st),ae.copy(B))},reset:function(){T=!1,$=null,ae.set(-1,0,0,0)}}}function r(){let T=!1,B=null,$=null,ae=null;return{setTest:function(he){he?C(i.DEPTH_TEST):be(i.DEPTH_TEST)},setMask:function(he){B!==he&&!T&&(i.depthMask(he),B=he)},setFunc:function(he){if($!==he){switch(he){case Do:i.depthFunc(i.NEVER);break;case No:i.depthFunc(i.ALWAYS);break;case Fo:i.depthFunc(i.LESS);break;case Hs:i.depthFunc(i.LEQUAL);break;case Oo:i.depthFunc(i.EQUAL);break;case Bo:i.depthFunc(i.GEQUAL);break;case zo:i.depthFunc(i.GREATER);break;case ko:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}$=he}},setLocked:function(he){T=he},setClear:function(he){ae!==he&&(i.clearDepth(he),ae=he)},reset:function(){T=!1,B=null,$=null,ae=null}}}function o(){let T=!1,B=null,$=null,ae=null,he=null,ze=null,ke=null,st=null,jt=null;return{setTest:function(Xe){T||(Xe?C(i.STENCIL_TEST):be(i.STENCIL_TEST))},setMask:function(Xe){B!==Xe&&!T&&(i.stencilMask(Xe),B=Xe)},setFunc:function(Xe,bt,Dt){($!==Xe||ae!==bt||he!==Dt)&&(i.stencilFunc(Xe,bt,Dt),$=Xe,ae=bt,he=Dt)},setOp:function(Xe,bt,Dt){(ze!==Xe||ke!==bt||st!==Dt)&&(i.stencilOp(Xe,bt,Dt),ze=Xe,ke=bt,st=Dt)},setLocked:function(Xe){T=Xe},setClear:function(Xe){jt!==Xe&&(i.clearStencil(Xe),jt=Xe)},reset:function(){T=!1,B=null,$=null,ae=null,he=null,ze=null,ke=null,st=null,jt=null}}}let a=new s,l=new r,c=new o,u=new WeakMap,f=new WeakMap,d={},m={},g=new WeakMap,x=[],p=null,h=!1,w=null,M=null,A=null,b=null,R=null,L=null,V=null,_=!1,E=null,X=null,J=null,U=null,N=null,k=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),Q=!1,q=0,W=i.getParameter(i.VERSION);W.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\\d)/.exec(W)[1]),Q=q>=1):W.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\\d)/.exec(W)[1]),Q=q>=2);let Z=null,j={},ue=i.getParameter(i.SCISSOR_BOX),oe=i.getParameter(i.VIEWPORT),O=new Je().fromArray(ue),Y=new Je().fromArray(oe);function ie(T,B,$,ae){let he=new Uint8Array(4),ze=i.createTexture();i.bindTexture(T,ze),i.texParameteri(T,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(T,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ke=0;ke<$;ke++)n&&(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)?i.texImage3D(B,0,i.RGBA,1,1,ae,0,i.RGBA,i.UNSIGNED_BYTE,he):i.texImage2D(B+ke,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,he);return ze}let re={};re[i.TEXTURE_2D]=ie(i.TEXTURE_2D,i.TEXTURE_2D,1),re[i.TEXTURE_CUBE_MAP]=ie(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(re[i.TEXTURE_2D_ARRAY]=ie(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),re[i.TEXTURE_3D]=ie(i.TEXTURE_3D,i.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),C(i.DEPTH_TEST),l.setFunc(Hs),it(!1),et(Pr),C(i.CULL_FACE),Pe(an);function C(T){d[T]!==!0&&(i.enable(T),d[T]=!0)}function be(T){d[T]!==!1&&(i.disable(T),d[T]=!1)}function Me(T,B){return m[T]!==B?(i.bindFramebuffer(T,B),m[T]=B,n&&(T===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=B),T===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=B)),!0):!1}function ne(T,B){let $=x,ae=!1;if(T)if($=g.get(B),$===void 0&&($=[],g.set(B,$)),T.isWebGLMultipleRenderTargets){let he=T.texture;if($.length!==he.length||$[0]!==i.COLOR_ATTACHMENT0){for(let ze=0,ke=he.length;ze<ke;ze++)$[ze]=i.COLOR_ATTACHMENT0+ze;$.length=he.length,ae=!0}}else $[0]!==i.COLOR_ATTACHMENT0&&($[0]=i.COLOR_ATTACHMENT0,ae=!0);else $[0]!==i.BACK&&($[0]=i.BACK,ae=!0);ae&&(t.isWebGL2?i.drawBuffers($):e.get("WEBGL_draw_buffers").drawBuffersWEBGL($))}function ve(T){return p!==T?(i.useProgram(T),p=T,!0):!1}let Ne={[Wn]:i.FUNC_ADD,[bo]:i.FUNC_SUBTRACT,[Eo]:i.FUNC_REVERSE_SUBTRACT};if(n)Ne[Dr]=i.MIN,Ne[Nr]=i.MAX;else{let T=e.get("EXT_blend_minmax");T!==null&&(Ne[Dr]=T.MIN_EXT,Ne[Nr]=T.MAX_EXT)}let pe={[wo]:i.ZERO,[To]:i.ONE,[Ao]:i.SRC_COLOR,[Ja]:i.SRC_ALPHA,[Uo]:i.SRC_ALPHA_SATURATE,[Lo]:i.DST_COLOR,[Co]:i.DST_ALPHA,[Ro]:i.ONE_MINUS_SRC_COLOR,[$a]:i.ONE_MINUS_SRC_ALPHA,[Io]:i.ONE_MINUS_DST_COLOR,[Po]:i.ONE_MINUS_DST_ALPHA};function Pe(T,B,$,ae,he,ze,ke,st){if(T===an){h===!0&&(be(i.BLEND),h=!1);return}if(h===!1&&(C(i.BLEND),h=!0),T!==So){if(T!==w||st!==_){if((M!==Wn||R!==Wn)&&(i.blendEquation(i.FUNC_ADD),M=Wn,R=Wn),st)switch(T){case Yn:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Lr:i.blendFunc(i.ONE,i.ONE);break;case Ir:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ur:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}else switch(T){case Yn:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Lr:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Ir:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ur:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",T);break}A=null,b=null,L=null,V=null,w=T,_=st}return}he=he||B,ze=ze||$,ke=ke||ae,(B!==M||he!==R)&&(i.blendEquationSeparate(Ne[B],Ne[he]),M=B,R=he),($!==A||ae!==b||ze!==L||ke!==V)&&(i.blendFuncSeparate(pe[$],pe[ae],pe[ze],pe[ke]),A=$,b=ae,L=ze,V=ke),w=T,_=!1}function je(T,B){T.side===Yt?be(i.CULL_FACE):C(i.CULL_FACE);let $=T.side===_t;B&&($=!$),it($),T.blending===Yn&&T.transparent===!1?Pe(an):Pe(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.premultipliedAlpha),l.setFunc(T.depthFunc),l.setTest(T.depthTest),l.setMask(T.depthWrite),a.setMask(T.colorWrite);let ae=T.stencilWrite;c.setTest(ae),ae&&(c.setMask(T.stencilWriteMask),c.setFunc(T.stencilFunc,T.stencilRef,T.stencilFuncMask),c.setOp(T.stencilFail,T.stencilZFail,T.stencilZPass)),Fe(T.polygonOffset,T.polygonOffsetFactor,T.polygonOffsetUnits),T.alphaToCoverage===!0?C(i.SAMPLE_ALPHA_TO_COVERAGE):be(i.SAMPLE_ALPHA_TO_COVERAGE)}function it(T){E!==T&&(T?i.frontFace(i.CW):i.frontFace(i.CCW),E=T)}function et(T){T!==vo?(C(i.CULL_FACE),T!==X&&(T===Pr?i.cullFace(i.BACK):T===yo?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):be(i.CULL_FACE),X=T}function Ze(T){T!==J&&(Q&&i.lineWidth(T),J=T)}function Fe(T,B,$){T?(C(i.POLYGON_OFFSET_FILL),(U!==B||N!==$)&&(i.polygonOffset(B,$),U=B,N=$)):be(i.POLYGON_OFFSET_FILL)}function Ge(T){T?C(i.SCISSOR_TEST):be(i.SCISSOR_TEST)}function mt(T){T===void 0&&(T=i.TEXTURE0+k-1),Z!==T&&(i.activeTexture(T),Z=T)}function S(T,B,$){$===void 0&&(Z===null?$=i.TEXTURE0+k-1:$=Z);let ae=j[$];ae===void 0&&(ae={type:void 0,texture:void 0},j[$]=ae),(ae.type!==T||ae.texture!==B)&&(Z!==$&&(i.activeTexture($),Z=$),i.bindTexture(T,B||re[T]),ae.type=T,ae.texture=B)}function v(){let T=j[Z];T!==void 0&&T.type!==void 0&&(i.bindTexture(T.type,null),T.type=void 0,T.texture=void 0)}function F(){try{i.compressedTexImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function K(){try{i.compressedTexImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ee(){try{i.texSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function se(){try{i.texSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ye(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function le(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function H(){try{i.texStorage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function de(){try{i.texStorage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function me(){try{i.texImage2D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function _e(){try{i.texImage3D.apply(i,arguments)}catch(T){console.error("THREE.WebGLState:",T)}}function ce(T){O.equals(T)===!1&&(i.scissor(T.x,T.y,T.z,T.w),O.copy(T))}function fe(T){Y.equals(T)===!1&&(i.viewport(T.x,T.y,T.z,T.w),Y.copy(T))}function Ie(T,B){let $=f.get(B);$===void 0&&($=new WeakMap,f.set(B,$));let ae=$.get(T);ae===void 0&&(ae=i.getUniformBlockIndex(B,T.name),$.set(T,ae))}function Oe(T,B){let ae=f.get(B).get(T);u.get(B)!==ae&&(i.uniformBlockBinding(B,ae,T.__bindingPointIndex),u.set(B,ae))}function We(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),n===!0&&(i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},Z=null,j={},m={},g=new WeakMap,x=[],p=null,h=!1,w=null,M=null,A=null,b=null,R=null,L=null,V=null,_=!1,E=null,X=null,J=null,U=null,N=null,O.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:C,disable:be,bindFramebuffer:Me,drawBuffers:ne,useProgram:ve,setBlending:Pe,setMaterial:je,setFlipSided:it,setCullFace:et,setLineWidth:Ze,setPolygonOffset:Fe,setScissorTest:Ge,activeTexture:mt,bindTexture:S,unbindTexture:v,compressedTexImage2D:F,compressedTexImage3D:K,texImage2D:me,texImage3D:_e,updateUBOMapping:Ie,uniformBlockBinding:Oe,texStorage2D:H,texStorage3D:de,texSubImage2D:ee,texSubImage3D:se,compressedTexSubImage2D:ye,compressedTexSubImage3D:le,scissor:ce,viewport:fe,reset:We}}function df(i,e,t,n,s,r,o){let a=s.isWebGL2,l=s.maxTextures,c=s.maxCubemapSize,u=s.maxTextureSize,f=s.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,x,p=new WeakMap,h=!1;try{h=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(S){}function w(S,v){return h?new OffscreenCanvas(S,v):Yi("canvas")}function M(S,v,F,K){let ee=1;if((S.width>K||S.height>K)&&(ee=K/Math.max(S.width,S.height)),ee<1||v===!0)if(typeof HTMLImageElement!="undefined"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&S instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&S instanceof ImageBitmap){let se=v?no:Math.floor,ye=se(ee*S.width),le=se(ee*S.height);x===void 0&&(x=w(ye,le));let H=F?w(ye,le):x;return H.width=ye,H.height=le,H.getContext("2d").drawImage(S,0,0,ye,le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+S.width+"x"+S.height+") to ("+ye+"x"+le+")."),H}else return"data"in S&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+S.width+"x"+S.height+")."),S;return S}function A(S){return Zs(S.width)&&Zs(S.height)}function b(S){return a?!1:S.wrapS!==Lt||S.wrapT!==Lt||S.minFilter!==ht&&S.minFilter!==wt}function R(S,v){return S.generateMipmaps&&v&&S.minFilter!==ht&&S.minFilter!==wt}function L(S){i.generateMipmap(S)}function V(S,v,F,K,ee=!1){if(a===!1)return v;if(S!==null){if(i[S]!==void 0)return i[S];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'"+S+"\'")}let se=v;return v===i.RED&&(F===i.FLOAT&&(se=i.R32F),F===i.HALF_FLOAT&&(se=i.R16F),F===i.UNSIGNED_BYTE&&(se=i.R8)),v===i.RG&&(F===i.FLOAT&&(se=i.RG32F),F===i.HALF_FLOAT&&(se=i.RG16F),F===i.UNSIGNED_BYTE&&(se=i.RG8)),v===i.RGBA&&(F===i.FLOAT&&(se=i.RGBA32F),F===i.HALF_FLOAT&&(se=i.RGBA16F),F===i.UNSIGNED_BYTE&&(se=K===Ee&&ee===!1?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(se=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(se=i.RGB5_A1)),(se===i.R16F||se===i.R32F||se===i.RG16F||se===i.RG32F||se===i.RGBA16F||se===i.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function _(S,v,F){return R(S,F)===!0||S.isFramebufferTexture&&S.minFilter!==ht&&S.minFilter!==wt?Math.log2(Math.max(v.width,v.height))+1:S.mipmaps!==void 0&&S.mipmaps.length>0?S.mipmaps.length:S.isCompressedTexture&&Array.isArray(S.image)?v.mipmaps.length:1}function E(S){return S===ht||S===Fr||S===ps?i.NEAREST:i.LINEAR}function X(S){let v=S.target;v.removeEventListener("dispose",X),U(v),v.isVideoTexture&&g.delete(v)}function J(S){let v=S.target;v.removeEventListener("dispose",J),k(v)}function U(S){let v=n.get(S);if(v.__webglInit===void 0)return;let F=S.source,K=p.get(F);if(K){let ee=K[v.__cacheKey];ee.usedTimes--,ee.usedTimes===0&&N(S),Object.keys(K).length===0&&p.delete(F)}n.remove(S)}function N(S){let v=n.get(S);i.deleteTexture(v.__webglTexture);let F=S.source,K=p.get(F);delete K[v.__cacheKey],o.memory.textures--}function k(S){let v=S.texture,F=n.get(S),K=n.get(v);if(K.__webglTexture!==void 0&&(i.deleteTexture(K.__webglTexture),o.memory.textures--),S.depthTexture&&S.depthTexture.dispose(),S.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++)i.deleteFramebuffer(F.__webglFramebuffer[ee]),F.__webglDepthbuffer&&i.deleteRenderbuffer(F.__webglDepthbuffer[ee]);else{if(i.deleteFramebuffer(F.__webglFramebuffer),F.__webglDepthbuffer&&i.deleteRenderbuffer(F.__webglDepthbuffer),F.__webglMultisampledFramebuffer&&i.deleteFramebuffer(F.__webglMultisampledFramebuffer),F.__webglColorRenderbuffer)for(let ee=0;ee<F.__webglColorRenderbuffer.length;ee++)F.__webglColorRenderbuffer[ee]&&i.deleteRenderbuffer(F.__webglColorRenderbuffer[ee]);F.__webglDepthRenderbuffer&&i.deleteRenderbuffer(F.__webglDepthRenderbuffer)}if(S.isWebGLMultipleRenderTargets)for(let ee=0,se=v.length;ee<se;ee++){let ye=n.get(v[ee]);ye.__webglTexture&&(i.deleteTexture(ye.__webglTexture),o.memory.textures--),n.remove(v[ee])}n.remove(v),n.remove(S)}let Q=0;function q(){Q=0}function W(){let S=Q;return S>=l&&console.warn("THREE.WebGLTextures: Trying to use "+S+" texture units while this GPU supports only "+l),Q+=1,S}function Z(S){let v=[];return v.push(S.wrapS),v.push(S.wrapT),v.push(S.wrapR||0),v.push(S.magFilter),v.push(S.minFilter),v.push(S.anisotropy),v.push(S.internalFormat),v.push(S.format),v.push(S.type),v.push(S.generateMipmaps),v.push(S.premultiplyAlpha),v.push(S.flipY),v.push(S.unpackAlignment),v.push(S.colorSpace),v.join()}function j(S,v){let F=n.get(S);if(S.isVideoTexture&&Ge(S),S.isRenderTargetTexture===!1&&S.version>0&&F.__version!==S.version){let K=S.image;if(K===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{be(F,S,v);return}}t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+v)}function ue(S,v){let F=n.get(S);if(S.version>0&&F.__version!==S.version){be(F,S,v);return}t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+v)}function oe(S,v){let F=n.get(S);if(S.version>0&&F.__version!==S.version){be(F,S,v);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+v)}function O(S,v){let F=n.get(S);if(S.version>0&&F.__version!==S.version){Me(F,S,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+v)}let Y={[Xs]:i.REPEAT,[Lt]:i.CLAMP_TO_EDGE,[qs]:i.MIRRORED_REPEAT},ie={[ht]:i.NEAREST,[Fr]:i.NEAREST_MIPMAP_NEAREST,[ps]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[Zo]:i.LINEAR_MIPMAP_NEAREST,[_i]:i.LINEAR_MIPMAP_LINEAR};function re(S,v,F){if(F?(i.texParameteri(S,i.TEXTURE_WRAP_S,Y[v.wrapS]),i.texParameteri(S,i.TEXTURE_WRAP_T,Y[v.wrapT]),(S===i.TEXTURE_3D||S===i.TEXTURE_2D_ARRAY)&&i.texParameteri(S,i.TEXTURE_WRAP_R,Y[v.wrapR]),i.texParameteri(S,i.TEXTURE_MAG_FILTER,ie[v.magFilter]),i.texParameteri(S,i.TEXTURE_MIN_FILTER,ie[v.minFilter])):(i.texParameteri(S,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(S,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(S===i.TEXTURE_3D||S===i.TEXTURE_2D_ARRAY)&&i.texParameteri(S,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(v.wrapS!==Lt||v.wrapT!==Lt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(S,i.TEXTURE_MAG_FILTER,E(v.magFilter)),i.texParameteri(S,i.TEXTURE_MIN_FILTER,E(v.minFilter)),v.minFilter!==ht&&v.minFilter!==wt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let K=e.get("EXT_texture_filter_anisotropic");if(v.magFilter===ht||v.minFilter!==ps&&v.minFilter!==_i||v.type===vn&&e.has("OES_texture_float_linear")===!1||a===!1&&v.type===xi&&e.has("OES_texture_half_float_linear")===!1)return;(v.anisotropy>1||n.get(v).__currentAnisotropy)&&(i.texParameterf(S,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy)}}function C(S,v){let F=!1;S.__webglInit===void 0&&(S.__webglInit=!0,v.addEventListener("dispose",X));let K=v.source,ee=p.get(K);ee===void 0&&(ee={},p.set(K,ee));let se=Z(v);if(se!==S.__cacheKey){ee[se]===void 0&&(ee[se]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,F=!0),ee[se].usedTimes++;let ye=ee[S.__cacheKey];ye!==void 0&&(ee[S.__cacheKey].usedTimes--,ye.usedTimes===0&&N(v)),S.__cacheKey=se,S.__webglTexture=ee[se].texture}return F}function be(S,v,F){let K=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(K=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(K=i.TEXTURE_3D);let ee=C(S,v),se=v.source;t.bindTexture(K,S.__webglTexture,i.TEXTURE0+F);let ye=n.get(se);if(se.version!==ye.__version||ee===!0){t.activeTexture(i.TEXTURE0+F),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let le=b(v)&&A(v.image)===!1,H=M(v.image,le,!1,u);H=mt(v,H);let de=A(H)||a,me=r.convert(v.format,v.colorSpace),_e=r.convert(v.type),ce=V(v.internalFormat,me,_e,v.colorSpace);re(K,v,de);let fe,Ie=v.mipmaps,Oe=a&&v.isVideoTexture!==!0,We=ye.__version===void 0||ee===!0,T=_(v,H,de);if(v.isDepthTexture)ce=i.DEPTH_COMPONENT,a?v.type===vn?ce=i.DEPTH_COMPONENT32F:v.type===xn?ce=i.DEPTH_COMPONENT24:v.type===Zn?ce=i.DEPTH24_STENCIL8:ce=i.DEPTH_COMPONENT16:v.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),v.format===yn&&ce===i.DEPTH_COMPONENT&&v.type!==ja&&v.type!==xn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),v.type=xn,_e=r.convert(v.type)),v.format===jn&&ce===i.DEPTH_COMPONENT&&(ce=i.DEPTH_STENCIL,v.type!==Zn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),v.type=Zn,_e=r.convert(v.type))),We&&(Oe?t.texStorage2D(i.TEXTURE_2D,1,ce,H.width,H.height):t.texImage2D(i.TEXTURE_2D,0,ce,H.width,H.height,0,me,_e,null));else if(v.isDataTexture)if(Ie.length>0&&de){Oe&&We&&t.texStorage2D(i.TEXTURE_2D,T,ce,Ie[0].width,Ie[0].height);for(let B=0,$=Ie.length;B<$;B++)fe=Ie[B],Oe?t.texSubImage2D(i.TEXTURE_2D,B,0,0,fe.width,fe.height,me,_e,fe.data):t.texImage2D(i.TEXTURE_2D,B,ce,fe.width,fe.height,0,me,_e,fe.data);v.generateMipmaps=!1}else Oe?(We&&t.texStorage2D(i.TEXTURE_2D,T,ce,H.width,H.height),t.texSubImage2D(i.TEXTURE_2D,0,0,0,H.width,H.height,me,_e,H.data)):t.texImage2D(i.TEXTURE_2D,0,ce,H.width,H.height,0,me,_e,H.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Oe&&We&&t.texStorage3D(i.TEXTURE_2D_ARRAY,T,ce,Ie[0].width,Ie[0].height,H.depth);for(let B=0,$=Ie.length;B<$;B++)fe=Ie[B],v.format!==It?me!==null?Oe?t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,B,0,0,0,fe.width,fe.height,H.depth,me,fe.data,0,0):t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,B,ce,fe.width,fe.height,H.depth,0,fe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Oe?t.texSubImage3D(i.TEXTURE_2D_ARRAY,B,0,0,0,fe.width,fe.height,H.depth,me,_e,fe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,B,ce,fe.width,fe.height,H.depth,0,me,_e,fe.data)}else{Oe&&We&&t.texStorage2D(i.TEXTURE_2D,T,ce,Ie[0].width,Ie[0].height);for(let B=0,$=Ie.length;B<$;B++)fe=Ie[B],v.format!==It?me!==null?Oe?t.compressedTexSubImage2D(i.TEXTURE_2D,B,0,0,fe.width,fe.height,me,fe.data):t.compressedTexImage2D(i.TEXTURE_2D,B,ce,fe.width,fe.height,0,fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Oe?t.texSubImage2D(i.TEXTURE_2D,B,0,0,fe.width,fe.height,me,_e,fe.data):t.texImage2D(i.TEXTURE_2D,B,ce,fe.width,fe.height,0,me,_e,fe.data)}else if(v.isDataArrayTexture)Oe?(We&&t.texStorage3D(i.TEXTURE_2D_ARRAY,T,ce,H.width,H.height,H.depth),t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,H.width,H.height,H.depth,me,_e,H.data)):t.texImage3D(i.TEXTURE_2D_ARRAY,0,ce,H.width,H.height,H.depth,0,me,_e,H.data);else if(v.isData3DTexture)Oe?(We&&t.texStorage3D(i.TEXTURE_3D,T,ce,H.width,H.height,H.depth),t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,H.width,H.height,H.depth,me,_e,H.data)):t.texImage3D(i.TEXTURE_3D,0,ce,H.width,H.height,H.depth,0,me,_e,H.data);else if(v.isFramebufferTexture){if(We)if(Oe)t.texStorage2D(i.TEXTURE_2D,T,ce,H.width,H.height);else{let B=H.width,$=H.height;for(let ae=0;ae<T;ae++)t.texImage2D(i.TEXTURE_2D,ae,ce,B,$,0,me,_e,null),B>>=1,$>>=1}}else if(Ie.length>0&&de){Oe&&We&&t.texStorage2D(i.TEXTURE_2D,T,ce,Ie[0].width,Ie[0].height);for(let B=0,$=Ie.length;B<$;B++)fe=Ie[B],Oe?t.texSubImage2D(i.TEXTURE_2D,B,0,0,me,_e,fe):t.texImage2D(i.TEXTURE_2D,B,ce,me,_e,fe);v.generateMipmaps=!1}else Oe?(We&&t.texStorage2D(i.TEXTURE_2D,T,ce,H.width,H.height),t.texSubImage2D(i.TEXTURE_2D,0,0,0,me,_e,H)):t.texImage2D(i.TEXTURE_2D,0,ce,me,_e,H);R(v,de)&&L(K),ye.__version=se.version,v.onUpdate&&v.onUpdate(v)}S.__version=v.version}function Me(S,v,F){if(v.image.length!==6)return;let K=C(S,v),ee=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,S.__webglTexture,i.TEXTURE0+F);let se=n.get(ee);if(ee.version!==se.__version||K===!0){t.activeTexture(i.TEXTURE0+F),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let ye=v.isCompressedTexture||v.image[0].isCompressedTexture,le=v.image[0]&&v.image[0].isDataTexture,H=[];for(let B=0;B<6;B++)!ye&&!le?H[B]=M(v.image[B],!1,!0,c):H[B]=le?v.image[B].image:v.image[B],H[B]=mt(v,H[B]);let de=H[0],me=A(de)||a,_e=r.convert(v.format,v.colorSpace),ce=r.convert(v.type),fe=V(v.internalFormat,_e,ce,v.colorSpace),Ie=a&&v.isVideoTexture!==!0,Oe=se.__version===void 0||K===!0,We=_(v,de,me);re(i.TEXTURE_CUBE_MAP,v,me);let T;if(ye){Ie&&Oe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,We,fe,de.width,de.height);for(let B=0;B<6;B++){T=H[B].mipmaps;for(let $=0;$<T.length;$++){let ae=T[$];v.format!==It?_e!==null?Ie?t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$,0,0,ae.width,ae.height,_e,ae.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$,fe,ae.width,ae.height,0,ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ie?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$,0,0,ae.width,ae.height,_e,ce,ae.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$,fe,ae.width,ae.height,0,_e,ce,ae.data)}}}else{T=v.mipmaps,Ie&&Oe&&(T.length>0&&We++,t.texStorage2D(i.TEXTURE_CUBE_MAP,We,fe,H[0].width,H[0].height));for(let B=0;B<6;B++)if(le){Ie?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,0,0,H[B].width,H[B].height,_e,ce,H[B].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,fe,H[B].width,H[B].height,0,_e,ce,H[B].data);for(let $=0;$<T.length;$++){let he=T[$].image[B].image;Ie?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$+1,0,0,he.width,he.height,_e,ce,he.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$+1,fe,he.width,he.height,0,_e,ce,he.data)}}else{Ie?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,0,0,_e,ce,H[B]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,fe,_e,ce,H[B]);for(let $=0;$<T.length;$++){let ae=T[$];Ie?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$+1,0,0,_e,ce,ae.image[B]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+B,$+1,fe,_e,ce,ae.image[B])}}}R(v,me)&&L(i.TEXTURE_CUBE_MAP),se.__version=ee.version,v.onUpdate&&v.onUpdate(v)}S.__version=v.version}function ne(S,v,F,K,ee){let se=r.convert(F.format,F.colorSpace),ye=r.convert(F.type),le=V(F.internalFormat,se,ye,F.colorSpace);n.get(v).__hasExternalTextures||(ee===i.TEXTURE_3D||ee===i.TEXTURE_2D_ARRAY?t.texImage3D(ee,0,le,v.width,v.height,v.depth,0,se,ye,null):t.texImage2D(ee,0,le,v.width,v.height,0,se,ye,null)),t.bindFramebuffer(i.FRAMEBUFFER,S),Fe(v)?d.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,ee,n.get(F).__webglTexture,0,Ze(v)):(ee===i.TEXTURE_2D||ee>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ee<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,K,ee,n.get(F).__webglTexture,0),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ve(S,v,F){if(i.bindRenderbuffer(i.RENDERBUFFER,S),v.depthBuffer&&!v.stencilBuffer){let K=i.DEPTH_COMPONENT16;if(F||Fe(v)){let ee=v.depthTexture;ee&&ee.isDepthTexture&&(ee.type===vn?K=i.DEPTH_COMPONENT32F:ee.type===xn&&(K=i.DEPTH_COMPONENT24));let se=Ze(v);Fe(v)?d.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,se,K,v.width,v.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,se,K,v.width,v.height)}else i.renderbufferStorage(i.RENDERBUFFER,K,v.width,v.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,S)}else if(v.depthBuffer&&v.stencilBuffer){let K=Ze(v);F&&Fe(v)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,K,i.DEPTH24_STENCIL8,v.width,v.height):Fe(v)?d.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,K,i.DEPTH24_STENCIL8,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,S)}else{let K=v.isWebGLMultipleRenderTargets===!0?v.texture:[v.texture];for(let ee=0;ee<K.length;ee++){let se=K[ee],ye=r.convert(se.format,se.colorSpace),le=r.convert(se.type),H=V(se.internalFormat,ye,le,se.colorSpace),de=Ze(v);F&&Fe(v)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,de,H,v.width,v.height):Fe(v)?d.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,de,H,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,H,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ne(S,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,S),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(v.depthTexture).__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),j(v.depthTexture,0);let K=n.get(v.depthTexture).__webglTexture,ee=Ze(v);if(v.depthTexture.format===yn)Fe(v)?d.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,K,0,ee):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,K,0);else if(v.depthTexture.format===jn)Fe(v)?d.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,K,0,ee):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function pe(S){let v=n.get(S),F=S.isWebGLCubeRenderTarget===!0;if(S.depthTexture&&!v.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");Ne(v.__webglFramebuffer,S)}else if(F){v.__webglDepthbuffer=[];for(let K=0;K<6;K++)t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[K]),v.__webglDepthbuffer[K]=i.createRenderbuffer(),ve(v.__webglDepthbuffer[K],S,!1)}else t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer=i.createRenderbuffer(),ve(v.__webglDepthbuffer,S,!1);t.bindFramebuffer(i.FRAMEBUFFER,null)}function Pe(S,v,F){let K=n.get(S);v!==void 0&&ne(K.__webglFramebuffer,S,S.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D),F!==void 0&&pe(S)}function je(S){let v=S.texture,F=n.get(S),K=n.get(v);S.addEventListener("dispose",J),S.isWebGLMultipleRenderTargets!==!0&&(K.__webglTexture===void 0&&(K.__webglTexture=i.createTexture()),K.__version=v.version,o.memory.textures++);let ee=S.isWebGLCubeRenderTarget===!0,se=S.isWebGLMultipleRenderTargets===!0,ye=A(S)||a;if(ee){F.__webglFramebuffer=[];for(let le=0;le<6;le++)F.__webglFramebuffer[le]=i.createFramebuffer()}else{if(F.__webglFramebuffer=i.createFramebuffer(),se)if(s.drawBuffers){let le=S.texture;for(let H=0,de=le.length;H<de;H++){let me=n.get(le[H]);me.__webglTexture===void 0&&(me.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&S.samples>0&&Fe(S)===!1){let le=se?v:[v];F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let H=0;H<le.length;H++){let de=le[H];F.__webglColorRenderbuffer[H]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[H]);let me=r.convert(de.format,de.colorSpace),_e=r.convert(de.type),ce=V(de.internalFormat,me,_e,de.colorSpace,S.isXRRenderTarget===!0),fe=Ze(S);i.renderbufferStorageMultisample(i.RENDERBUFFER,fe,ce,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+H,i.RENDERBUFFER,F.__webglColorRenderbuffer[H])}i.bindRenderbuffer(i.RENDERBUFFER,null),S.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),ve(F.__webglDepthRenderbuffer,S,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ee){t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),re(i.TEXTURE_CUBE_MAP,v,ye);for(let le=0;le<6;le++)ne(F.__webglFramebuffer[le],S,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+le);R(v,ye)&&L(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(se){let le=S.texture;for(let H=0,de=le.length;H<de;H++){let me=le[H],_e=n.get(me);t.bindTexture(i.TEXTURE_2D,_e.__webglTexture),re(i.TEXTURE_2D,me,ye),ne(F.__webglFramebuffer,S,me,i.COLOR_ATTACHMENT0+H,i.TEXTURE_2D),R(me,ye)&&L(i.TEXTURE_2D)}t.unbindTexture()}else{let le=i.TEXTURE_2D;(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)&&(a?le=S.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(le,K.__webglTexture),re(le,v,ye),ne(F.__webglFramebuffer,S,v,i.COLOR_ATTACHMENT0,le),R(v,ye)&&L(le),t.unbindTexture()}S.depthBuffer&&pe(S)}function it(S){let v=A(S)||a,F=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let K=0,ee=F.length;K<ee;K++){let se=F[K];if(R(se,v)){let ye=S.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,le=n.get(se).__webglTexture;t.bindTexture(ye,le),L(ye),t.unbindTexture()}}}function et(S){if(a&&S.samples>0&&Fe(S)===!1){let v=S.isWebGLMultipleRenderTargets?S.texture:[S.texture],F=S.width,K=S.height,ee=i.COLOR_BUFFER_BIT,se=[],ye=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=n.get(S),H=S.isWebGLMultipleRenderTargets===!0;if(H)for(let de=0;de<v.length;de++)t.bindFramebuffer(i.FRAMEBUFFER,le.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,le.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let de=0;de<v.length;de++){se.push(i.COLOR_ATTACHMENT0+de),S.depthBuffer&&se.push(ye);let me=le.__ignoreDepthValues!==void 0?le.__ignoreDepthValues:!1;if(me===!1&&(S.depthBuffer&&(ee|=i.DEPTH_BUFFER_BIT),S.stencilBuffer&&(ee|=i.STENCIL_BUFFER_BIT)),H&&i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,le.__webglColorRenderbuffer[de]),me===!0&&(i.invalidateFramebuffer(i.READ_FRAMEBUFFER,[ye]),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[ye])),H){let _e=n.get(v[de]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,_e,0)}i.blitFramebuffer(0,0,F,K,0,0,F,K,ee,i.NEAREST),m&&i.invalidateFramebuffer(i.READ_FRAMEBUFFER,se)}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),H)for(let de=0;de<v.length;de++){t.bindFramebuffer(i.FRAMEBUFFER,le.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,le.__webglColorRenderbuffer[de]);let me=n.get(v[de]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,le.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,me,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}}function Ze(S){return Math.min(f,S.samples)}function Fe(S){let v=n.get(S);return a&&S.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function Ge(S){let v=o.render.frame;g.get(S)!==v&&(g.set(S,v),S.update())}function mt(S,v){let F=S.colorSpace,K=S.format,ee=S.type;return S.isCompressedTexture===!0||S.format===Ys||F!==Bt&&F!==Sn&&(F===Ee?a===!1?e.has("EXT_sRGB")===!0&&K===It?(S.format=Ys,S.minFilter=wt,S.generateMipmaps=!1):v=Zi.sRGBToLinear(v):(K!==It||ee!==bn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),v}this.allocateTextureUnit=W,this.resetTextureUnits=q,this.setTexture2D=j,this.setTexture2DArray=ue,this.setTexture3D=oe,this.setTextureCube=O,this.rebindTextures=Pe,this.setupRenderTarget=je,this.updateRenderTargetMipmap=it,this.updateMultisampleRenderTarget=et,this.setupDepthRenderbuffer=pe,this.setupFrameBufferTexture=ne,this.useMultisampledRTT=Fe}function ff(i,e,t){let n=t.isWebGL2;function s(r,o=Sn){let a;if(r===bn)return i.UNSIGNED_BYTE;if(r===Qo)return i.UNSIGNED_SHORT_4_4_4_4;if(r===jo)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Jo)return i.BYTE;if(r===$o)return i.SHORT;if(r===ja)return i.UNSIGNED_SHORT;if(r===Ko)return i.INT;if(r===xn)return i.UNSIGNED_INT;if(r===vn)return i.FLOAT;if(r===xi)return n?i.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(r===ec)return i.ALPHA;if(r===It)return i.RGBA;if(r===tc)return i.LUMINANCE;if(r===nc)return i.LUMINANCE_ALPHA;if(r===yn)return i.DEPTH_COMPONENT;if(r===jn)return i.DEPTH_STENCIL;if(r===Ys)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(r===ic)return i.RED;if(r===sc)return i.RED_INTEGER;if(r===rc)return i.RG;if(r===ac)return i.RG_INTEGER;if(r===oc)return i.RGBA_INTEGER;if(r===ms||r===gs||r===_s||r===xs)if(o===Ee)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===ms)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===gs)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===_s)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===xs)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===ms)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===gs)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===_s)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===xs)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Or||r===Br||r===zr||r===kr)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===Or)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Br)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===zr)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===kr)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===cc)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Vr||r===Hr)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===Vr)return o===Ee?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===Hr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Gr||r===Wr||r===Xr||r===qr||r===Yr||r===Zr||r===Jr||r===$r||r===Kr||r===Qr||r===jr||r===ea||r===ta||r===na)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Gr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Wr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Xr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===qr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Yr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Zr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Jr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===$r)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Kr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Qr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===jr)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ea)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===ta)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===na)return o===Ee?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===vs)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===vs)return o===Ee?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===lc||r===ia||r===sa||r===ra)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===vs)return a.COMPRESSED_RED_RGTC1_EXT;if(r===ia)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===sa)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===ra)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Zn?n?i.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[r]!==void 0?i[r]:null}return{convert:s}}var cr=class extends St{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},qn=class extends xt{constructor(){super(),this.isGroup=!0,this.type="Group"}},pf={type:"move"},gi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qn,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 qn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),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 s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let x of e.hand.values()){let p=t.getJointPose(x,n),h=this._getHandJoint(c,x);p!==null&&(h.matrix.fromArray(p.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=p.radius),h.visible=p!==null}let u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],d=u.position.distanceTo(f.position),m=.02,g=.005;c.inputState.pinching&&d>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(pf)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new qn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},lr=class extends ft{constructor(e,t,n,s,r,o,a,l,c,u){if(u=u!==void 0?u:yn,u!==yn&&u!==jn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===yn&&(n=xn),n===void 0&&u===jn&&(n=Zn),super(null,s,r,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:ht,this.minFilter=l!==void 0?l:ht,this.flipY=!1,this.generateMipmaps=!1}},hr=class extends cn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,d=null,m=null,g=null,x=t.getContextAttributes(),p=null,h=null,w=[],M=[],A=new Set,b=new Map,R=new St;R.layers.enable(1),R.viewport=new Je;let L=new St;L.layers.enable(2),L.viewport=new Je;let V=[R,L],_=new cr;_.layers.enable(1),_.layers.enable(2);let E=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let Y=w[O];return Y===void 0&&(Y=new gi,w[O]=Y),Y.getTargetRaySpace()},this.getControllerGrip=function(O){let Y=w[O];return Y===void 0&&(Y=new gi,w[O]=Y),Y.getGripSpace()},this.getHand=function(O){let Y=w[O];return Y===void 0&&(Y=new gi,w[O]=Y),Y.getHandSpace()};function J(O){let Y=M.indexOf(O.inputSource);if(Y===-1)return;let ie=w[Y];ie!==void 0&&(ie.update(O.inputSource,O.frame,c||o),ie.dispatchEvent({type:O.type,data:O.inputSource}))}function U(){s.removeEventListener("select",J),s.removeEventListener("selectstart",J),s.removeEventListener("selectend",J),s.removeEventListener("squeeze",J),s.removeEventListener("squeezestart",J),s.removeEventListener("squeezeend",J),s.removeEventListener("end",U),s.removeEventListener("inputsourceschange",N);for(let O=0;O<w.length;O++){let Y=M[O];Y!==null&&(M[O]=null,w[O].disconnect(Y))}E=null,X=null,e.setRenderTarget(p),m=null,d=null,f=null,s=null,h=null,oe.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(O){r=O,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){a=O,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(O){c=O},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return f},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(O){if(s=O,s!==null){if(p=e.getRenderTarget(),s.addEventListener("select",J),s.addEventListener("selectstart",J),s.addEventListener("selectend",J),s.addEventListener("squeeze",J),s.addEventListener("squeezestart",J),s.addEventListener("squeezeend",J),s.addEventListener("end",U),s.addEventListener("inputsourceschange",N),x.xrCompatible!==!0&&await t.makeXRCompatible(),s.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let Y={antialias:s.renderState.layers===void 0?x.antialias:!0,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,t,Y),s.updateRenderState({baseLayer:m}),h=new $t(m.framebufferWidth,m.framebufferHeight,{format:It,type:bn,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil})}else{let Y=null,ie=null,re=null;x.depth&&(re=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Y=x.stencil?jn:yn,ie=x.stencil?Zn:xn);let C={colorFormat:t.RGBA8,depthFormat:re,scaleFactor:r};f=new XRWebGLBinding(s,t),d=f.createProjectionLayer(C),s.updateRenderState({layers:[d]}),h=new $t(d.textureWidth,d.textureHeight,{format:It,type:bn,depthTexture:new lr(d.textureWidth,d.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Y),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0});let be=e.properties.get(h);be.__ignoreDepthValues=d.ignoreDepthValues}h.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),oe.setContext(s),oe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode};function N(O){for(let Y=0;Y<O.removed.length;Y++){let ie=O.removed[Y],re=M.indexOf(ie);re>=0&&(M[re]=null,w[re].disconnect(ie))}for(let Y=0;Y<O.added.length;Y++){let ie=O.added[Y],re=M.indexOf(ie);if(re===-1){for(let be=0;be<w.length;be++)if(be>=M.length){M.push(ie),re=be;break}else if(M[be]===null){M[be]=ie,re=be;break}if(re===-1)break}let C=w[re];C&&C.connect(ie)}}let k=new D,Q=new D;function q(O,Y,ie){k.setFromMatrixPosition(Y.matrixWorld),Q.setFromMatrixPosition(ie.matrixWorld);let re=k.distanceTo(Q),C=Y.projectionMatrix.elements,be=ie.projectionMatrix.elements,Me=C[14]/(C[10]-1),ne=C[14]/(C[10]+1),ve=(C[9]+1)/C[5],Ne=(C[9]-1)/C[5],pe=(C[8]-1)/C[0],Pe=(be[8]+1)/be[0],je=Me*pe,it=Me*Pe,et=re/(-pe+Pe),Ze=et*-pe;Y.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(Ze),O.translateZ(et),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert();let Fe=Me+et,Ge=ne+et,mt=je-Ze,S=it+(re-Ze),v=ve*ne/Ge*Fe,F=Ne*ne/Ge*Fe;O.projectionMatrix.makePerspective(mt,S,v,F,Fe,Ge),O.projectionMatrixInverse.copy(O.projectionMatrix).invert()}function W(O,Y){Y===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(Y.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(s===null)return;_.near=L.near=R.near=O.near,_.far=L.far=R.far=O.far,(E!==_.near||X!==_.far)&&(s.updateRenderState({depthNear:_.near,depthFar:_.far}),E=_.near,X=_.far);let Y=O.parent,ie=_.cameras;W(_,Y);for(let re=0;re<ie.length;re++)W(ie[re],Y);ie.length===2?q(_,R,L):_.projectionMatrix.copy(R.projectionMatrix),Z(O,_,Y)};function Z(O,Y,ie){ie===null?O.matrix.copy(Y.matrixWorld):(O.matrix.copy(ie.matrixWorld),O.matrix.invert(),O.matrix.multiply(Y.matrixWorld)),O.matrix.decompose(O.position,O.quaternion,O.scale),O.updateMatrixWorld(!0);let re=O.children;for(let C=0,be=re.length;C<be;C++)re[C].updateMatrixWorld(!0);O.projectionMatrix.copy(Y.projectionMatrix),O.projectionMatrixInverse.copy(Y.projectionMatrixInverse),O.isPerspectiveCamera&&(O.fov=vi*2*Math.atan(1/O.projectionMatrix.elements[5]),O.zoom=1)}this.getCamera=function(){return _},this.getFoveation=function(){if(!(d===null&&m===null))return l},this.setFoveation=function(O){l=O,d!==null&&(d.fixedFoveation=O),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=O)},this.getPlanes=function(){return A};let j=null;function ue(O,Y){if(u=Y.getViewerPose(c||o),g=Y,u!==null){let ie=u.views;m!==null&&(e.setRenderTargetFramebuffer(h,m.framebuffer),e.setRenderTarget(h));let re=!1;ie.length!==_.cameras.length&&(_.cameras.length=0,re=!0);for(let C=0;C<ie.length;C++){let be=ie[C],Me=null;if(m!==null)Me=m.getViewport(be);else{let ve=f.getViewSubImage(d,be);Me=ve.viewport,C===0&&(e.setRenderTargetTextures(h,ve.colorTexture,d.ignoreDepthValues?void 0:ve.depthStencilTexture),e.setRenderTarget(h))}let ne=V[C];ne===void 0&&(ne=new St,ne.layers.enable(C),ne.viewport=new Je,V[C]=ne),ne.matrix.fromArray(be.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray(be.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(Me.x,Me.y,Me.width,Me.height),C===0&&(_.matrix.copy(ne.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale)),re===!0&&_.cameras.push(ne)}}for(let ie=0;ie<w.length;ie++){let re=M[ie],C=w[ie];re!==null&&C!==void 0&&C.update(re,Y,c||o)}if(j&&j(O,Y),Y.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:Y.detectedPlanes});let ie=null;for(let re of A)Y.detectedPlanes.has(re)||(ie===null&&(ie=[]),ie.push(re));if(ie!==null)for(let re of ie)A.delete(re),b.delete(re),n.dispatchEvent({type:"planeremoved",data:re});for(let re of Y.detectedPlanes)if(!A.has(re))A.add(re),b.set(re,Y.lastChangedTime),n.dispatchEvent({type:"planeadded",data:re});else{let C=b.get(re);re.lastChangedTime>C&&(b.set(re,re.lastChangedTime),n.dispatchEvent({type:"planechanged",data:re}))}}g=null}let oe=new oo;oe.setAnimationLoop(ue),this.setAnimationLoop=function(O){j=O},this.dispose=function(){}}};function mf(i,e){function t(p,h){p.matrixAutoUpdate===!0&&p.updateMatrix(),h.value.copy(p.matrix)}function n(p,h){h.color.getRGB(p.fogColor.value,ao(i)),h.isFog?(p.fogNear.value=h.near,p.fogFar.value=h.far):h.isFogExp2&&(p.fogDensity.value=h.density)}function s(p,h,w,M,A){h.isMeshBasicMaterial||h.isMeshLambertMaterial?r(p,h):h.isMeshToonMaterial?(r(p,h),f(p,h)):h.isMeshPhongMaterial?(r(p,h),u(p,h)):h.isMeshStandardMaterial?(r(p,h),d(p,h),h.isMeshPhysicalMaterial&&m(p,h,A)):h.isMeshMatcapMaterial?(r(p,h),g(p,h)):h.isMeshDepthMaterial?r(p,h):h.isMeshDistanceMaterial?(r(p,h),x(p,h)):h.isMeshNormalMaterial?r(p,h):h.isLineBasicMaterial?(o(p,h),h.isLineDashedMaterial&&a(p,h)):h.isPointsMaterial?l(p,h,w,M):h.isSpriteMaterial?c(p,h):h.isShadowMaterial?(p.color.value.copy(h.color),p.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function r(p,h){p.opacity.value=h.opacity,h.color&&p.diffuse.value.copy(h.color),h.emissive&&p.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,t(h.alphaMap,p.alphaMapTransform)),h.bumpMap&&(p.bumpMap.value=h.bumpMap,t(h.bumpMap,p.bumpMapTransform),p.bumpScale.value=h.bumpScale,h.side===_t&&(p.bumpScale.value*=-1)),h.normalMap&&(p.normalMap.value=h.normalMap,t(h.normalMap,p.normalMapTransform),p.normalScale.value.copy(h.normalScale),h.side===_t&&p.normalScale.value.negate()),h.displacementMap&&(p.displacementMap.value=h.displacementMap,t(h.displacementMap,p.displacementMapTransform),p.displacementScale.value=h.displacementScale,p.displacementBias.value=h.displacementBias),h.emissiveMap&&(p.emissiveMap.value=h.emissiveMap,t(h.emissiveMap,p.emissiveMapTransform)),h.specularMap&&(p.specularMap.value=h.specularMap,t(h.specularMap,p.specularMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest);let w=e.get(h).envMap;if(w&&(p.envMap.value=w,p.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=h.reflectivity,p.ior.value=h.ior,p.refractionRatio.value=h.refractionRatio),h.lightMap){p.lightMap.value=h.lightMap;let M=i.useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=h.lightMapIntensity*M,t(h.lightMap,p.lightMapTransform)}h.aoMap&&(p.aoMap.value=h.aoMap,p.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,p.aoMapTransform))}function o(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform))}function a(p,h){p.dashSize.value=h.dashSize,p.totalSize.value=h.dashSize+h.gapSize,p.scale.value=h.scale}function l(p,h,w,M){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.size.value=h.size*w,p.scale.value=M*.5,h.map&&(p.map.value=h.map,t(h.map,p.uvTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function c(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.rotation.value=h.rotation,h.map&&(p.map.value=h.map,t(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function u(p,h){p.specular.value.copy(h.specular),p.shininess.value=Math.max(h.shininess,1e-4)}function f(p,h){h.gradientMap&&(p.gradientMap.value=h.gradientMap)}function d(p,h){p.metalness.value=h.metalness,h.metalnessMap&&(p.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,p.metalnessMapTransform)),p.roughness.value=h.roughness,h.roughnessMap&&(p.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,p.roughnessMapTransform)),e.get(h).envMap&&(p.envMapIntensity.value=h.envMapIntensity)}function m(p,h,w){p.ior.value=h.ior,h.sheen>0&&(p.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),p.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(p.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,p.sheenColorMapTransform)),h.sheenRoughnessMap&&(p.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,p.sheenRoughnessMapTransform))),h.clearcoat>0&&(p.clearcoat.value=h.clearcoat,p.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(p.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,p.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(p.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===_t&&p.clearcoatNormalScale.value.negate())),h.iridescence>0&&(p.iridescence.value=h.iridescence,p.iridescenceIOR.value=h.iridescenceIOR,p.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(p.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,p.iridescenceMapTransform)),h.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),h.transmission>0&&(p.transmission.value=h.transmission,p.transmissionSamplerMap.value=w.texture,p.transmissionSamplerSize.value.set(w.width,w.height),h.transmissionMap&&(p.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,p.transmissionMapTransform)),p.thickness.value=h.thickness,h.thicknessMap&&(p.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=h.attenuationDistance,p.attenuationColor.value.copy(h.attenuationColor)),p.specularIntensity.value=h.specularIntensity,p.specularColor.value.copy(h.specularColor),h.specularColorMap&&(p.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,p.specularColorMapTransform)),h.specularIntensityMap&&(p.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,h){h.matcap&&(p.matcap.value=h.matcap)}function x(p,h){let w=e.get(h).light;p.referencePosition.value.setFromMatrixPosition(w.matrixWorld),p.nearDistance.value=w.shadow.camera.near,p.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function gf(i,e,t,n){let s={},r={},o=[],a=t.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(w,M){let A=M.program;n.uniformBlockBinding(w,A)}function c(w,M){let A=s[w.id];A===void 0&&(g(w),A=u(w),s[w.id]=A,w.addEventListener("dispose",p));let b=M.program;n.updateUBOMapping(w,b);let R=e.render.frame;r[w.id]!==R&&(d(w),r[w.id]=R)}function u(w){let M=f();w.__bindingPointIndex=M;let A=i.createBuffer(),b=w.__size,R=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,b,R),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,M,A),A}function f(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(w){let M=s[w.id],A=w.uniforms,b=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,M);for(let R=0,L=A.length;R<L;R++){let V=A[R];if(m(V,R,b)===!0){let _=V.__offset,E=Array.isArray(V.value)?V.value:[V.value],X=0;for(let J=0;J<E.length;J++){let U=E[J],N=x(U);typeof U=="number"?(V.__data[0]=U,i.bufferSubData(i.UNIFORM_BUFFER,_+X,V.__data)):U.isMatrix3?(V.__data[0]=U.elements[0],V.__data[1]=U.elements[1],V.__data[2]=U.elements[2],V.__data[3]=U.elements[0],V.__data[4]=U.elements[3],V.__data[5]=U.elements[4],V.__data[6]=U.elements[5],V.__data[7]=U.elements[0],V.__data[8]=U.elements[6],V.__data[9]=U.elements[7],V.__data[10]=U.elements[8],V.__data[11]=U.elements[0]):(U.toArray(V.__data,X),X+=N.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,_,V.__data)}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(w,M,A){let b=w.value;if(A[M]===void 0){if(typeof b=="number")A[M]=b;else{let R=Array.isArray(b)?b:[b],L=[];for(let V=0;V<R.length;V++)L.push(R[V].clone());A[M]=L}return!0}else if(typeof b=="number"){if(A[M]!==b)return A[M]=b,!0}else{let R=Array.isArray(A[M])?A[M]:[A[M]],L=Array.isArray(b)?b:[b];for(let V=0;V<R.length;V++){let _=R[V];if(_.equals(L[V])===!1)return _.copy(L[V]),!0}}return!1}function g(w){let M=w.uniforms,A=0,b=16,R=0;for(let L=0,V=M.length;L<V;L++){let _=M[L],E={boundary:0,storage:0},X=Array.isArray(_.value)?_.value:[_.value];for(let J=0,U=X.length;J<U;J++){let N=X[J],k=x(N);E.boundary+=k.boundary,E.storage+=k.storage}if(_.__data=new Float32Array(E.storage/Float32Array.BYTES_PER_ELEMENT),_.__offset=A,L>0){R=A%b;let J=b-R;R!==0&&J-E.boundary<0&&(A+=b-R,_.__offset=A)}A+=E.storage}return R=A%b,R>0&&(A+=b-R),w.__size=A,w.__cache={},this}function x(w){let M={boundary:0,storage:0};return typeof w=="number"?(M.boundary=4,M.storage=4):w.isVector2?(M.boundary=8,M.storage=8):w.isVector3||w.isColor?(M.boundary=16,M.storage=12):w.isVector4?(M.boundary=16,M.storage=16):w.isMatrix3?(M.boundary=48,M.storage=48):w.isMatrix4?(M.boundary=64,M.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),M}function p(w){let M=w.target;M.removeEventListener("dispose",p);let A=o.indexOf(M.__bindingPointIndex);o.splice(A,1),i.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function h(){for(let w in s)i.deleteBuffer(s[w]);o=[],s={},r={}}return{bind:l,update:c,dispose:h}}function _f(){let i=Yi("canvas");return i.style.display="block",i}var ur=class{constructor(e={}){let{canvas:t=_f(),context:n=null,depth:s=!0,stencil:r=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let d;n!==null?d=n.getContextAttributes().alpha:d=o;let m=null,g=null,x=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Ee,this.useLegacyLights=!0,this.toneMapping=Zt,this.toneMappingExposure=1;let h=this,w=!1,M=0,A=0,b=null,R=-1,L=null,V=new Je,_=new Je,E=null,X=t.width,J=t.height,U=1,N=null,k=null,Q=new Je(0,0,X,J),q=new Je(0,0,X,J),W=!1,Z=new is,j=!1,ue=!1,oe=null,O=new $e,Y=new D,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function re(){return b===null?U:1}let C=n;function be(y,I){for(let z=0;z<y.length;z++){let P=y[z],G=t.getContext(P,I);if(G!==null)return G}return null}try{let y={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Mr}`),t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),C===null){let I=["webgl2","webgl","experimental-webgl"];if(h.isWebGL1Renderer===!0&&I.shift(),C=be(I,y),C===null)throw be(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}C.getShaderPrecisionFormat===void 0&&(C.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let Me,ne,ve,Ne,pe,Pe,je,it,et,Ze,Fe,Ge,mt,S,v,F,K,ee,se,ye,le,H,de,me;function _e(){Me=new Ou(C),ne=new Lu(C,Me,e),Me.init(ne),H=new ff(C,Me,ne),ve=new uf(C,Me,ne),Ne=new ku(C),pe=new Qd,Pe=new df(C,Me,ve,pe,ne,H,Ne),je=new Uu(h),it=new Fu(h),et=new Qc(C,ne),de=new Cu(C,Me,et,ne),Ze=new Bu(C,et,Ne,de),Fe=new Wu(C,Ze,et,Ne),se=new Gu(C,ne,Pe),F=new Iu(pe),Ge=new Kd(h,je,it,Me,ne,de,F),mt=new mf(h,pe),S=new ef,v=new of(Me,ne),ee=new Ru(h,je,it,ve,Fe,d,l),K=new hf(h,Fe,ne),me=new gf(C,Ne,ne,ve),ye=new Pu(C,Me,Ne,ne),le=new zu(C,Me,Ne,ne),Ne.programs=Ge.programs,h.capabilities=ne,h.extensions=Me,h.properties=pe,h.renderLists=S,h.shadowMap=K,h.state=ve,h.info=Ne}_e();let ce=new hr(h,C);this.xr=ce,this.getContext=function(){return C},this.getContextAttributes=function(){return C.getContextAttributes()},this.forceContextLoss=function(){let y=Me.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Me.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return U},this.setPixelRatio=function(y){y!==void 0&&(U=y,this.setSize(X,J,!1))},this.getSize=function(y){return y.set(X,J)},this.setSize=function(y,I,z=!0){if(ce.isPresenting){console.warn("THREE.WebGLRenderer: Can\'t change size while VR device is presenting.");return}X=y,J=I,t.width=Math.floor(y*U),t.height=Math.floor(I*U),z===!0&&(t.style.width=y+"px",t.style.height=I+"px"),this.setViewport(0,0,y,I)},this.getDrawingBufferSize=function(y){return y.set(X*U,J*U).floor()},this.setDrawingBufferSize=function(y,I,z){X=y,J=I,U=z,t.width=Math.floor(y*z),t.height=Math.floor(I*z),this.setViewport(0,0,y,I)},this.getCurrentViewport=function(y){return y.copy(V)},this.getViewport=function(y){return y.copy(Q)},this.setViewport=function(y,I,z,P){y.isVector4?Q.set(y.x,y.y,y.z,y.w):Q.set(y,I,z,P),ve.viewport(V.copy(Q).multiplyScalar(U).floor())},this.getScissor=function(y){return y.copy(q)},this.setScissor=function(y,I,z,P){y.isVector4?q.set(y.x,y.y,y.z,y.w):q.set(y,I,z,P),ve.scissor(_.copy(q).multiplyScalar(U).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(y){ve.setScissorTest(W=y)},this.setOpaqueSort=function(y){N=y},this.setTransparentSort=function(y){k=y},this.getClearColor=function(y){return y.copy(ee.getClearColor())},this.setClearColor=function(){ee.setClearColor.apply(ee,arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha.apply(ee,arguments)},this.clear=function(y=!0,I=!0,z=!0){let P=0;y&&(P|=C.COLOR_BUFFER_BIT),I&&(P|=C.DEPTH_BUFFER_BIT),z&&(P|=C.STENCIL_BUFFER_BIT),C.clear(P)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),S.dispose(),v.dispose(),pe.dispose(),je.dispose(),it.dispose(),Fe.dispose(),de.dispose(),me.dispose(),Ge.dispose(),ce.dispose(),ce.removeEventListener("sessionstart",he),ce.removeEventListener("sessionend",ze),oe&&(oe.dispose(),oe=null),ke.stop()};function fe(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function Ie(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;let y=Ne.autoReset,I=K.enabled,z=K.autoUpdate,P=K.needsUpdate,G=K.type;_e(),Ne.autoReset=y,K.enabled=I,K.autoUpdate=z,K.needsUpdate=P,K.type=G}function Oe(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function We(y){let I=y.target;I.removeEventListener("dispose",We),T(I)}function T(y){B(y),pe.remove(y)}function B(y){let I=pe.get(y).programs;I!==void 0&&(I.forEach(function(z){Ge.releaseProgram(z)}),y.isShaderMaterial&&Ge.releaseShaderCache(y))}this.renderBufferDirect=function(y,I,z,P,G,ge){I===null&&(I=ie);let xe=G.isMesh&&G.matrixWorld.determinant()<0,Se=mo(y,I,z,P,G);ve.setMaterial(P,xe);let we=z.index,Ae=1;P.wireframe===!0&&(we=Ze.getWireframeAttribute(z),Ae=2);let Re=z.drawRange,Le=z.attributes.position,Be=Re.start*Ae,ot=(Re.start+Re.count)*Ae;ge!==null&&(Be=Math.max(Be,ge.start*Ae),ot=Math.min(ot,(ge.start+ge.count)*Ae)),we!==null?(Be=Math.max(Be,0),ot=Math.min(ot,we.count)):Le!=null&&(Be=Math.max(Be,0),ot=Math.min(ot,Le.count));let Tt=ot-Be;if(Tt<0||Tt===1/0)return;de.setup(G,P,Se,z,we);let hn,qe=ye;if(we!==null&&(hn=et.get(we),qe=le,qe.setIndex(hn)),G.isMesh)P.wireframe===!0?(ve.setLineWidth(P.wireframeLinewidth*re()),qe.setMode(C.LINES)):qe.setMode(C.TRIANGLES);else if(G.isLine){let Ue=P.linewidth;Ue===void 0&&(Ue=1),ve.setLineWidth(Ue*re()),G.isLineSegments?qe.setMode(C.LINES):G.isLineLoop?qe.setMode(C.LINE_LOOP):qe.setMode(C.LINE_STRIP)}else G.isPoints?qe.setMode(C.POINTS):G.isSprite&&qe.setMode(C.TRIANGLES);if(G.isInstancedMesh)qe.renderInstances(Be,Tt,G.count);else if(z.isInstancedBufferGeometry){let Ue=z._maxInstanceCount!==void 0?z._maxInstanceCount:1/0,hs=Math.min(z.instanceCount,Ue);qe.renderInstances(Be,Tt,hs)}else qe.render(Be,Tt)},this.compile=function(y,I){function z(P,G,ge){P.transparent===!0&&P.side===Yt&&P.forceSinglePass===!1?(P.side=_t,P.needsUpdate=!0,bi(P,G,ge),P.side=on,P.needsUpdate=!0,bi(P,G,ge),P.side=Yt):bi(P,G,ge)}g=v.get(y),g.init(),p.push(g),y.traverseVisible(function(P){P.isLight&&P.layers.test(I.layers)&&(g.pushLight(P),P.castShadow&&g.pushShadow(P))}),g.setupLights(h.useLegacyLights),y.traverse(function(P){let G=P.material;if(G)if(Array.isArray(G))for(let ge=0;ge<G.length;ge++){let xe=G[ge];z(xe,y,P)}else z(G,y,P)}),p.pop(),g=null};let $=null;function ae(y){$&&$(y)}function he(){ke.stop()}function ze(){ke.start()}let ke=new oo;ke.setAnimationLoop(ae),typeof self!="undefined"&&ke.setContext(self),this.setAnimationLoop=function(y){$=y,ce.setAnimationLoop(y),y===null?ke.stop():ke.start()},ce.addEventListener("sessionstart",he),ce.addEventListener("sessionend",ze),this.render=function(y,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),ce.enabled===!0&&ce.isPresenting===!0&&(ce.cameraAutoUpdate===!0&&ce.updateCamera(I),I=ce.getCamera()),y.isScene===!0&&y.onBeforeRender(h,y,I,b),g=v.get(y,p.length),g.init(),p.push(g),O.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Z.setFromProjectionMatrix(O),ue=this.localClippingEnabled,j=F.init(this.clippingPlanes,ue),m=S.get(y,x.length),m.init(),x.push(m),st(y,I,0,h.sortObjects),m.finish(),h.sortObjects===!0&&m.sort(N,k),j===!0&&F.beginShadows();let z=g.state.shadowsArray;if(K.render(z,y,I),j===!0&&F.endShadows(),this.info.autoReset===!0&&this.info.reset(),ee.render(m,y),g.setupLights(h.useLegacyLights),I.isArrayCamera){let P=I.cameras;for(let G=0,ge=P.length;G<ge;G++){let xe=P[G];jt(m,y,xe,xe.viewport)}}else jt(m,y,I);b!==null&&(Pe.updateMultisampleRenderTarget(b),Pe.updateRenderTargetMipmap(b)),y.isScene===!0&&y.onAfterRender(h,y,I),de.resetDefaultState(),R=-1,L=null,p.pop(),p.length>0?g=p[p.length-1]:g=null,x.pop(),x.length>0?m=x[x.length-1]:m=null};function st(y,I,z,P){if(y.visible===!1)return;if(y.layers.test(I.layers)){if(y.isGroup)z=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(I);else if(y.isLight)g.pushLight(y),y.castShadow&&g.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Z.intersectsSprite(y)){P&&Y.setFromMatrixPosition(y.matrixWorld).applyMatrix4(O);let xe=Fe.update(y),Se=y.material;Se.visible&&m.push(y,xe,Se,z,Y.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Z.intersectsObject(y))){y.isSkinnedMesh&&y.skeleton.frame!==Ne.render.frame&&(y.skeleton.update(),y.skeleton.frame=Ne.render.frame);let xe=Fe.update(y),Se=y.material;if(P&&(xe.boundingSphere===null&&xe.computeBoundingSphere(),Y.copy(xe.boundingSphere.center).applyMatrix4(y.matrixWorld).applyMatrix4(O)),Array.isArray(Se)){let we=xe.groups;for(let Ae=0,Re=we.length;Ae<Re;Ae++){let Le=we[Ae],Be=Se[Le.materialIndex];Be&&Be.visible&&m.push(y,xe,Be,z,Y.z,Le)}}else Se.visible&&m.push(y,xe,Se,z,Y.z,null)}}let ge=y.children;for(let xe=0,Se=ge.length;xe<Se;xe++)st(ge[xe],I,z,P)}function jt(y,I,z,P){let G=y.opaque,ge=y.transmissive,xe=y.transparent;g.setupLightsView(z),j===!0&&F.setGlobalState(h.clippingPlanes,z),ge.length>0&&Xe(G,ge,I,z),P&&ve.viewport(V.copy(P)),G.length>0&&bt(G,I,z),ge.length>0&&bt(ge,I,z),xe.length>0&&bt(xe,I,z),ve.buffers.depth.setTest(!0),ve.buffers.depth.setMask(!0),ve.buffers.color.setMask(!0),ve.setPolygonOffset(!1)}function Xe(y,I,z,P){if(oe===null){let Se=ne.isWebGL2;oe=new $t(1024,1024,{generateMipmaps:!0,type:Me.has("EXT_color_buffer_half_float")?xi:bn,minFilter:_i,samples:Se&&a===!0?4:0})}let G=h.getRenderTarget();h.setRenderTarget(oe),h.clear();let ge=h.toneMapping;h.toneMapping=Zt,bt(y,z,P),Pe.updateMultisampleRenderTarget(oe),Pe.updateRenderTargetMipmap(oe);let xe=!1;for(let Se=0,we=I.length;Se<we;Se++){let Ae=I[Se],Re=Ae.object,Le=Ae.geometry,Be=Ae.material,ot=Ae.group;if(Be.side===Yt&&Re.layers.test(P.layers)){let Tt=Be.side;Be.side=_t,Be.needsUpdate=!0,Dt(Re,z,P,Le,Be,ot),Be.side=Tt,Be.needsUpdate=!0,xe=!0}}xe===!0&&(Pe.updateMultisampleRenderTarget(oe),Pe.updateRenderTargetMipmap(oe)),h.setRenderTarget(G),h.toneMapping=ge}function bt(y,I,z){let P=I.isScene===!0?I.overrideMaterial:null;for(let G=0,ge=y.length;G<ge;G++){let xe=y[G],Se=xe.object,we=xe.geometry,Ae=P===null?xe.material:P,Re=xe.group;Se.layers.test(z.layers)&&Dt(Se,I,z,we,Ae,Re)}}function Dt(y,I,z,P,G,ge){y.onBeforeRender(h,I,z,P,G,ge),y.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),G.onBeforeRender(h,I,z,P,y,ge),G.transparent===!0&&G.side===Yt&&G.forceSinglePass===!1?(G.side=_t,G.needsUpdate=!0,h.renderBufferDirect(z,I,P,G,y,ge),G.side=on,G.needsUpdate=!0,h.renderBufferDirect(z,I,P,G,y,ge),G.side=Yt):h.renderBufferDirect(z,I,P,G,y,ge),y.onAfterRender(h,I,z,P,G,ge)}function bi(y,I,z){I.isScene!==!0&&(I=ie);let P=pe.get(y),G=g.state.lights,ge=g.state.shadowsArray,xe=G.state.version,Se=Ge.getParameters(y,G.state,ge,I,z),we=Ge.getProgramCacheKey(Se),Ae=P.programs;P.environment=y.isMeshStandardMaterial?I.environment:null,P.fog=I.fog,P.envMap=(y.isMeshStandardMaterial?it:je).get(y.envMap||P.environment),Ae===void 0&&(y.addEventListener("dispose",We),Ae=new Map,P.programs=Ae);let Re=Ae.get(we);if(Re!==void 0){if(P.currentProgram===Re&&P.lightsStateVersion===xe)return Ar(y,Se),Re}else Se.uniforms=Ge.getUniforms(y),y.onBuild(z,Se,h),y.onBeforeCompile(Se,h),Re=Ge.acquireProgram(Se,we),Ae.set(we,Re),P.uniforms=Se.uniforms;let Le=P.uniforms;(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Le.clippingPlanes=F.uniform),Ar(y,Se),P.needsLights=_o(y),P.lightsStateVersion=xe,P.needsLights&&(Le.ambientLightColor.value=G.state.ambient,Le.lightProbe.value=G.state.probe,Le.directionalLights.value=G.state.directional,Le.directionalLightShadows.value=G.state.directionalShadow,Le.spotLights.value=G.state.spot,Le.spotLightShadows.value=G.state.spotShadow,Le.rectAreaLights.value=G.state.rectArea,Le.ltc_1.value=G.state.rectAreaLTC1,Le.ltc_2.value=G.state.rectAreaLTC2,Le.pointLights.value=G.state.point,Le.pointLightShadows.value=G.state.pointShadow,Le.hemisphereLights.value=G.state.hemi,Le.directionalShadowMap.value=G.state.directionalShadowMap,Le.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Le.spotShadowMap.value=G.state.spotShadowMap,Le.spotLightMatrix.value=G.state.spotLightMatrix,Le.spotLightMap.value=G.state.spotLightMap,Le.pointShadowMap.value=G.state.pointShadowMap,Le.pointShadowMatrix.value=G.state.pointShadowMatrix);let Be=Re.getUniforms(),ot=$n.seqWithValue(Be.seq,Le);return P.currentProgram=Re,P.uniformsList=ot,Re}function Ar(y,I){let z=pe.get(y);z.outputColorSpace=I.outputColorSpace,z.instancing=I.instancing,z.skinning=I.skinning,z.morphTargets=I.morphTargets,z.morphNormals=I.morphNormals,z.morphColors=I.morphColors,z.morphTargetsCount=I.morphTargetsCount,z.numClippingPlanes=I.numClippingPlanes,z.numIntersection=I.numClipIntersection,z.vertexAlphas=I.vertexAlphas,z.vertexTangents=I.vertexTangents,z.toneMapping=I.toneMapping}function mo(y,I,z,P,G){I.isScene!==!0&&(I=ie),Pe.resetTextureUnits();let ge=I.fog,xe=P.isMeshStandardMaterial?I.environment:null,Se=b===null?h.outputColorSpace:b.isXRRenderTarget===!0?b.texture.colorSpace:Bt,we=(P.isMeshStandardMaterial?it:je).get(P.envMap||xe),Ae=P.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,Re=!!P.normalMap&&!!z.attributes.tangent,Le=!!z.morphAttributes.position,Be=!!z.morphAttributes.normal,ot=!!z.morphAttributes.color,Tt=P.toneMapped?h.toneMapping:Zt,hn=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,qe=hn!==void 0?hn.length:0,Ue=pe.get(P),hs=g.state.lights;if(j===!0&&(ue===!0||y!==L)){let vt=y===L&&P.id===R;F.setState(P,y,vt)}let tt=!1;P.version===Ue.__version?(Ue.needsLights&&Ue.lightsStateVersion!==hs.state.version||Ue.outputColorSpace!==Se||G.isInstancedMesh&&Ue.instancing===!1||!G.isInstancedMesh&&Ue.instancing===!0||G.isSkinnedMesh&&Ue.skinning===!1||!G.isSkinnedMesh&&Ue.skinning===!0||Ue.envMap!==we||P.fog===!0&&Ue.fog!==ge||Ue.numClippingPlanes!==void 0&&(Ue.numClippingPlanes!==F.numPlanes||Ue.numIntersection!==F.numIntersection)||Ue.vertexAlphas!==Ae||Ue.vertexTangents!==Re||Ue.morphTargets!==Le||Ue.morphNormals!==Be||Ue.morphColors!==ot||Ue.toneMapping!==Tt||ne.isWebGL2===!0&&Ue.morphTargetsCount!==qe)&&(tt=!0):(tt=!0,Ue.__version=P.version);let un=Ue.currentProgram;tt===!0&&(un=bi(P,I,G));let Rr=!1,ai=!1,us=!1,ct=un.getUniforms(),dn=Ue.uniforms;if(ve.useProgram(un.program)&&(Rr=!0,ai=!0,us=!0),P.id!==R&&(R=P.id,ai=!0),Rr||L!==y){if(ct.setValue(C,"projectionMatrix",y.projectionMatrix),ne.logarithmicDepthBuffer&&ct.setValue(C,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),L!==y&&(L=y,ai=!0,us=!0),P.isShaderMaterial||P.isMeshPhongMaterial||P.isMeshToonMaterial||P.isMeshStandardMaterial||P.envMap){let vt=ct.map.cameraPosition;vt!==void 0&&vt.setValue(C,Y.setFromMatrixPosition(y.matrixWorld))}(P.isMeshPhongMaterial||P.isMeshToonMaterial||P.isMeshLambertMaterial||P.isMeshBasicMaterial||P.isMeshStandardMaterial||P.isShaderMaterial)&&ct.setValue(C,"isOrthographic",y.isOrthographicCamera===!0),(P.isMeshPhongMaterial||P.isMeshToonMaterial||P.isMeshLambertMaterial||P.isMeshBasicMaterial||P.isMeshStandardMaterial||P.isShaderMaterial||P.isShadowMaterial||G.isSkinnedMesh)&&ct.setValue(C,"viewMatrix",y.matrixWorldInverse)}if(G.isSkinnedMesh){ct.setOptional(C,G,"bindMatrix"),ct.setOptional(C,G,"bindMatrixInverse");let vt=G.skeleton;vt&&(ne.floatVertexTextures?(vt.boneTexture===null&&vt.computeBoneTexture(),ct.setValue(C,"boneTexture",vt.boneTexture,Pe),ct.setValue(C,"boneTextureSize",vt.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let ds=z.morphAttributes;if((ds.position!==void 0||ds.normal!==void 0||ds.color!==void 0&&ne.isWebGL2===!0)&&se.update(G,z,un),(ai||Ue.receiveShadow!==G.receiveShadow)&&(Ue.receiveShadow=G.receiveShadow,ct.setValue(C,"receiveShadow",G.receiveShadow)),P.isMeshGouraudMaterial&&P.envMap!==null&&(dn.envMap.value=we,dn.flipEnvMap.value=we.isCubeTexture&&we.isRenderTargetTexture===!1?-1:1),ai&&(ct.setValue(C,"toneMappingExposure",h.toneMappingExposure),Ue.needsLights&&go(dn,us),ge&&P.fog===!0&&mt.refreshFogUniforms(dn,ge),mt.refreshMaterialUniforms(dn,P,U,J,oe),$n.upload(C,Ue.uniformsList,dn,Pe)),P.isShaderMaterial&&P.uniformsNeedUpdate===!0&&($n.upload(C,Ue.uniformsList,dn,Pe),P.uniformsNeedUpdate=!1),P.isSpriteMaterial&&ct.setValue(C,"center",G.center),ct.setValue(C,"modelViewMatrix",G.modelViewMatrix),ct.setValue(C,"normalMatrix",G.normalMatrix),ct.setValue(C,"modelMatrix",G.matrixWorld),P.isShaderMaterial||P.isRawShaderMaterial){let vt=P.uniformsGroups;for(let fs=0,xo=vt.length;fs<xo;fs++)if(ne.isWebGL2){let Cr=vt[fs];me.update(Cr,un),me.bind(Cr,un)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return un}function go(y,I){y.ambientLightColor.needsUpdate=I,y.lightProbe.needsUpdate=I,y.directionalLights.needsUpdate=I,y.directionalLightShadows.needsUpdate=I,y.pointLights.needsUpdate=I,y.pointLightShadows.needsUpdate=I,y.spotLights.needsUpdate=I,y.spotLightShadows.needsUpdate=I,y.rectAreaLights.needsUpdate=I,y.hemisphereLights.needsUpdate=I}function _o(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(y,I,z){pe.get(y.texture).__webglTexture=I,pe.get(y.depthTexture).__webglTexture=z;let P=pe.get(y);P.__hasExternalTextures=!0,P.__hasExternalTextures&&(P.__autoAllocateDepthBuffer=z===void 0,P.__autoAllocateDepthBuffer||Me.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),P.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(y,I){let z=pe.get(y);z.__webglFramebuffer=I,z.__useDefaultFramebuffer=I===void 0},this.setRenderTarget=function(y,I=0,z=0){b=y,M=I,A=z;let P=!0,G=null,ge=!1,xe=!1;if(y){let we=pe.get(y);we.__useDefaultFramebuffer!==void 0?(ve.bindFramebuffer(C.FRAMEBUFFER,null),P=!1):we.__webglFramebuffer===void 0?Pe.setupRenderTarget(y):we.__hasExternalTextures&&Pe.rebindTextures(y,pe.get(y.texture).__webglTexture,pe.get(y.depthTexture).__webglTexture);let Ae=y.texture;(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)&&(xe=!0);let Re=pe.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(G=Re[I],ge=!0):ne.isWebGL2&&y.samples>0&&Pe.useMultisampledRTT(y)===!1?G=pe.get(y).__webglMultisampledFramebuffer:G=Re,V.copy(y.viewport),_.copy(y.scissor),E=y.scissorTest}else V.copy(Q).multiplyScalar(U).floor(),_.copy(q).multiplyScalar(U).floor(),E=W;if(ve.bindFramebuffer(C.FRAMEBUFFER,G)&&ne.drawBuffers&&P&&ve.drawBuffers(y,G),ve.viewport(V),ve.scissor(_),ve.setScissorTest(E),ge){let we=pe.get(y.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+I,we.__webglTexture,z)}else if(xe){let we=pe.get(y.texture),Ae=I||0;C.framebufferTextureLayer(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,we.__webglTexture,z||0,Ae)}R=-1},this.readRenderTargetPixels=function(y,I,z,P,G,ge,xe){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=pe.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se){ve.bindFramebuffer(C.FRAMEBUFFER,Se);try{let we=y.texture,Ae=we.format,Re=we.type;if(Ae!==It&&H.convert(Ae)!==C.getParameter(C.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Le=Re===xi&&(Me.has("EXT_color_buffer_half_float")||ne.isWebGL2&&Me.has("EXT_color_buffer_float"));if(Re!==bn&&H.convert(Re)!==C.getParameter(C.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Re===vn&&(ne.isWebGL2||Me.has("OES_texture_float")||Me.has("WEBGL_color_buffer_float")))&&!Le){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=y.width-P&&z>=0&&z<=y.height-G&&C.readPixels(I,z,P,G,H.convert(Ae),H.convert(Re),ge)}finally{let we=b!==null?pe.get(b).__webglFramebuffer:null;ve.bindFramebuffer(C.FRAMEBUFFER,we)}}},this.copyFramebufferToTexture=function(y,I,z=0){let P=Math.pow(2,-z),G=Math.floor(I.image.width*P),ge=Math.floor(I.image.height*P);Pe.setTexture2D(I,0),C.copyTexSubImage2D(C.TEXTURE_2D,z,0,0,y.x,y.y,G,ge),ve.unbindTexture()},this.copyTextureToTexture=function(y,I,z,P=0){let G=I.image.width,ge=I.image.height,xe=H.convert(z.format),Se=H.convert(z.type);Pe.setTexture2D(z,0),C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,z.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,z.unpackAlignment),I.isDataTexture?C.texSubImage2D(C.TEXTURE_2D,P,y.x,y.y,G,ge,xe,Se,I.image.data):I.isCompressedTexture?C.compressedTexSubImage2D(C.TEXTURE_2D,P,y.x,y.y,I.mipmaps[0].width,I.mipmaps[0].height,xe,I.mipmaps[0].data):C.texSubImage2D(C.TEXTURE_2D,P,y.x,y.y,xe,Se,I.image),P===0&&z.generateMipmaps&&C.generateMipmap(C.TEXTURE_2D),ve.unbindTexture()},this.copyTextureToTexture3D=function(y,I,z,P,G=0){if(h.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ge=y.max.x-y.min.x+1,xe=y.max.y-y.min.y+1,Se=y.max.z-y.min.z+1,we=H.convert(P.format),Ae=H.convert(P.type),Re;if(P.isData3DTexture)Pe.setTexture3D(P,0),Re=C.TEXTURE_3D;else if(P.isDataArrayTexture)Pe.setTexture2DArray(P,0),Re=C.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,P.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,P.unpackAlignment);let Le=C.getParameter(C.UNPACK_ROW_LENGTH),Be=C.getParameter(C.UNPACK_IMAGE_HEIGHT),ot=C.getParameter(C.UNPACK_SKIP_PIXELS),Tt=C.getParameter(C.UNPACK_SKIP_ROWS),hn=C.getParameter(C.UNPACK_SKIP_IMAGES),qe=z.isCompressedTexture?z.mipmaps[0]:z.image;C.pixelStorei(C.UNPACK_ROW_LENGTH,qe.width),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,qe.height),C.pixelStorei(C.UNPACK_SKIP_PIXELS,y.min.x),C.pixelStorei(C.UNPACK_SKIP_ROWS,y.min.y),C.pixelStorei(C.UNPACK_SKIP_IMAGES,y.min.z),z.isDataTexture||z.isData3DTexture?C.texSubImage3D(Re,G,I.x,I.y,I.z,ge,xe,Se,we,Ae,qe.data):z.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),C.compressedTexSubImage3D(Re,G,I.x,I.y,I.z,ge,xe,Se,we,qe.data)):C.texSubImage3D(Re,G,I.x,I.y,I.z,ge,xe,Se,we,Ae,qe),C.pixelStorei(C.UNPACK_ROW_LENGTH,Le),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,Be),C.pixelStorei(C.UNPACK_SKIP_PIXELS,ot),C.pixelStorei(C.UNPACK_SKIP_ROWS,Tt),C.pixelStorei(C.UNPACK_SKIP_IMAGES,hn),G===0&&P.generateMipmaps&&C.generateMipmap(Re),ve.unbindTexture()},this.initTexture=function(y){y.isCubeTexture?Pe.setTextureCube(y,0):y.isData3DTexture?Pe.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Pe.setTexture2DArray(y,0):Pe.setTexture2D(y,0),ve.unbindTexture()},this.resetState=function(){M=0,A=0,b=null,ve.reset(),de.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ee?Mn:eo}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Mn?Ee:Bt}},dr=class extends ur{};dr.prototype.isWebGL1Renderer=!0;function rn(i,e,t){return fo(i)?new i.constructor(i.subarray(e,t!==void 0?t:i.length)):i.slice(e,t)}function Wi(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function fo(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var ii=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},fr=class extends ii{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:aa,endingEnd:aa}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case oa:r=e,a=2*t-n;break;case ca:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case oa:o=e,l=2*n-t;break;case ca:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,f=this._offsetNext,d=this._weightPrev,m=this._weightNext,g=(n-t)/(s-t),x=g*g,p=x*g,h=-d*p+2*d*x-d*g,w=(1+d)*p+(-1.5-2*d)*x+(-.5+d)*g+1,M=(-1-m)*p+(1.5+m)*x+.5*g,A=m*p-m*x;for(let b=0;b!==a;++b)r[b]=h*o[u+b]+w*o[c+b]+M*o[l+b]+A*o[f+b];return r}},pr=class extends ii{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(n-t)/(s-t),f=1-u;for(let d=0;d!==a;++d)r[d]=o[c+d]*f+o[l+d]*u;return r}},mr=class extends ii{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},Ut=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Wi(t,this.TimeBufferType),this.values=Wi(n,this.ValueBufferType),this.setInterpolation(s||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:Wi(e.times,Array),values:Wi(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new mr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new pr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new fr(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Xi:t=this.InterpolantFactoryMethodDiscrete;break;case qi:t=this.InterpolantFactoryMethodLinear;break;case ys:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="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 new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Xi;case this.InterpolantFactoryMethodLinear:return qi;case this.InterpolantFactoryMethodSmooth:return ys}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=rn(n,r,o),this.values=rn(this.values,r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&fo(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=rn(this.times),t=rn(this.values),n=this.getValueSize(),s=this.getInterpolation()===ys,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(s)l=!0;else{let f=a*n,d=f-n,m=f+n;for(let g=0;g!==n;++g){let x=t[f+g];if(x!==t[d+g]||x!==t[m+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let f=a*n,d=o*n;for(let m=0;m!==n;++m)t[d+m]=t[f+m]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=rn(e,0,o),this.values=rn(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=rn(this.times,0),t=rn(this.values,0),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};Ut.prototype.TimeBufferType=Float32Array;Ut.prototype.ValueBufferType=Float32Array;Ut.prototype.DefaultInterpolation=qi;var Tn=class extends Ut{};Tn.prototype.ValueTypeName="bool";Tn.prototype.ValueBufferType=Array;Tn.prototype.DefaultInterpolation=Xi;Tn.prototype.InterpolantFactoryMethodLinear=void 0;Tn.prototype.InterpolantFactoryMethodSmooth=void 0;var gr=class extends Ut{};gr.prototype.ValueTypeName="color";var _r=class extends Ut{};_r.prototype.ValueTypeName="number";var xr=class extends ii{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let u=c+a;c!==u;c+=4)ln.slerpFlat(r,0,o,c-a,o,c,l);return r}},Si=class extends Ut{InterpolantFactoryMethodLinear(e){return new xr(this.times,this.values,this.getValueSize(),e)}};Si.prototype.ValueTypeName="quaternion";Si.prototype.DefaultInterpolation=qi;Si.prototype.InterpolantFactoryMethodSmooth=void 0;var An=class extends Ut{};An.prototype.ValueTypeName="string";An.prototype.ValueBufferType=Array;An.prototype.DefaultInterpolation=Xi;An.prototype.InterpolantFactoryMethodLinear=void 0;An.prototype.InterpolantFactoryMethodSmooth=void 0;var vr=class extends Ut{};vr.prototype.ValueTypeName="vector";var Er="\\\\[\\\\]\\\\.:\\\\/",xf=new RegExp("["+Er+"]","g"),wr="[^"+Er+"]",vf="[^"+Er.replace("\\\\.","")+"]",yf=/((?:WC+[\\/:])*)/.source.replace("WC",wr),Mf=/(WCOD+)?/.source.replace("WCOD",vf),Sf=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",wr),bf=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",wr),Ef=new RegExp("^"+yf+Mf+Sf+bf+"$"),wf=["material","materials","bones","map"],yr=class{constructor(e,t,n){let s=n||De.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].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()}},De=class{constructor(e,t,n){this.path=t,this.parsedPath=n||De.parseTrackName(t),this.node=De.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new De.Composite(e,t,n):new De(e,t,n)}static sanitizeNodeName(e){return e.replace(/\\s/g,"_").replace(xf,"")}static parseTrackName(e){let t=Ef.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);wf.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new 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(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},s=n(e.children);if(s)return s}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 s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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 s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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 e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=De.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn\'t found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[s];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn\'t found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};De.Composite=yr;De.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};De.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};De.prototype.GetterByBindingType=[De.prototype._getValue_direct,De.prototype._getValue_array,De.prototype._getValue_arrayElement,De.prototype._getValue_toArray];De.prototype.SetterByBindingTypeAndVersioning=[[De.prototype._setValue_direct,De.prototype._setValue_direct_setNeedsUpdate,De.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[De.prototype._setValue_array,De.prototype._setValue_array_setNeedsUpdate,De.prototype._setValue_array_setMatrixWorldNeedsUpdate],[De.prototype._setValue_arrayElement,De.prototype._setValue_arrayElement_setNeedsUpdate,De.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[De.prototype._setValue_fromArray,De.prototype._setValue_fromArray_setNeedsUpdate,De.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Tf=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Mr}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Mr);var os=new D,cs=new D,Tr=new D,ls=new dt,po=self;po.addEventListener("message",async function(i){let e=JSON.parse(i.data),{id:t,position:n,index:s,thresholdAngle:r}=e;if(t&&n&&s&&r){let a=Math.pow(10,4),l=Math.cos(io.DEG2RAD*r),c=s.type,u=n.type,f=new pt(new self[c](s.array),s.itemSize,s.normalized),d=new pt(new self[u](n.array),n.itemSize,n.normalized),m=f?f.count:d.count,g=[0,0,0],x=["a","b","c"],p=new Array(3),h={},w=[];for(let A=0;A<m;A+=3){f?(g[0]=f.getX(A),g[1]=f.getX(A+1),g[2]=f.getX(A+2)):(g[0]=A,g[1]=A+1,g[2]=A+2);let{a:b,b:R,c:L}=ls;b.fromBufferAttribute(d,g[0]),R.fromBufferAttribute(d,g[1]),L.fromBufferAttribute(d,g[2]),ls.getNormal(Tr);let V=_=>Math.round(_*a);if(p[0]=`${V(b.x)}, ${V(b.y)}, ${V(b.z)}`,p[1]=`${V(R.x)}, ${V(R.y)}, ${V(R.z)}`,p[2]=`${V(L.x)}, ${V(L.y)}, ${V(L.z)}`,!(p[0]===p[1]||p[1]===p[2]||p[2]===p[0]))for(let _=0;_<3;_++){let E=(_+1)%3,X=p[_],J=p[E],U=ls[x[_]],N=ls[x[E]],k=`${X}_${J}`,Q=`${J}_${X}`;Q in h&&h[Q]?(Tr.dot(h[Q].normal)<=l&&(w.push(U.x,U.y,U.z),w.push(N.x,N.y,N.z)),h[Q]=null):k in h||(h[k]={index0:g[_],index1:g[E],normal:Tr.clone()})}}for(let A in h)if(h[A]){let{index0:b,index1:R}=h[A];os.fromBufferAttribute(d,b),cs.fromBufferAttribute(d,R),w.push(os.x,os.y,os.z),w.push(cs.x,cs.y,cs.z)}let M=new self[u](w);po.postMessage({id:t,vertices:M},[M.buffer])}});\n/*! Bundled license information:\n\nthree/build/three.module.js:\n (**\n * @license\n * Copyright 2010-2023 Three.js Authors\n * SPDX-License-Identifier: MIT\n *)\n*/\n')}var $a,Ay=class{constructor(){this.worker=new NF,this.geometries=new Map,this.loadedGeometries=new Map,this.jobCount=0,this.init()}add(e,t){this.geometries.set(e,t),this.jobCount++}get(e){return this.geometries.get(e)}init(){this.worker.addEventListener("message",(e=>{let t=this.geometries.get(e.data.id.toString());(null==t?void 0:t.length)>0&&(t.forEach((t=>{null!=t&&t.geometry&&null!=t&&t.geom&&null!=t&&t.line&&(t.geom.parameters={geometry:t.geometry,thresholdAngle:5},t.geom.setAttribute("position",new tt(e.data.vertices,3)),t.line.geometry=t.geom,t.line.visible=!0)})),this.geometries.delete(e.data.id.toString()),this.jobCount--),this.loadedGeometries.set(e.data.id.toString(),e.data.vertices)}))}postMessage(e){this.worker.postMessage(JSON.stringify(e))}},lrt=new M(0,1,0),Ho=class{static resetObjectStyle(e){this.revertWireframeMode(e),this.revertObjectOpacity(e,[]),this.revertAppliedMaterialToObject(e),this.revertVisibleForFloors(e)}static resetObjectStyleById(e,t){let n=this.getObjectById(e,t);this.resetObjectStyle(n)}static setObjectOpacity(e,t=.3,n,i){let r=[],a=e=>{r.find((t=>t.id===e.id))||(r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side}),e.opacity*=t,e.transparent=!0,e.side=tr)},s=e=>{let n=r.find((t=>t.id===e.id));if(!n){let n=e.clone();return r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side,material:e,clonedMaterial:n}),n.opacity*=t,n.transparent=!0,n}return n.clonedMaterial};return e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof Ge){let t=e;if(n||i){if(Array.isArray(t.material)){let e=[];t.material.forEach((t=>{let n=s(t);n&&e.push(n)})),t.material=e}else if(t.material){let e=s(t.material);e&&(t.material=e)}}else if(Array.isArray(t.material))t.material.forEach((e=>{a(e)}));else if(t.material){let e=t.material;a(e)}}})),r}static revertObjectOpacity(e,t,n,i){let r=new Set,a=e=>{if(!e||null==e.id||r.has(e.id))return;r.add(e.id);let n=t.find((t=>t.id===e.id));n&&(e.opacity=n.opacity,e.transparent=n.transparent,e.side=n.side,0===e.opacity&&$.warn(`[ObjectUtils] Material '${e.name}'s opacity is 0, you may not be able to see your objects!`))},s=e=>{let n=t.find((t=>t.clonedMaterial&&t.clonedMaterial.id===e.id));if(n)return n.material};e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof Ge)if(Array.isArray(e.material)){let t=[];e.material.forEach((e=>{let n=s(e);n?t.push(n):a(e)})),e.material=t}else if(e.material){let t=s(e.material);t?e.material=t:a(e.material)}}))}static setObjectOpacityById(e,t,n=.3,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);return Ho.setObjectOpacity(a,n,i,r)}static revertObjectOpacityById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);Ho.revertObjectOpacity(a,n,i,r)}static applyMaterialToObject(e,t,n,i){e.traverse((e=>{i&&-1!==i.indexOf(e.id)||n&&-1===n.indexOf(e.id)||e instanceof Ge&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),e.material=t)}))}static revertAppliedMaterialToObject(e,t,n){e.traverse((e=>{n&&-1!==n.indexOf(e.id)||t&&-1===t.indexOf(e.id)||e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,e.userData.originalMaterial=void 0)}))}static applyMaterialToObjectById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);this.applyMaterialToObject(a,n,i,r)}static revertAppliedMaterialToObjectById(e,t,n,i){let r=e.getObjectById(t);if(!r)throw new Error(`Failed to find object by id: ${t}`);this.revertAppliedMaterialToObject(r,n,i)}static applyOpacityMaterialToObject(e,t,n){let i=new Pt({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,i,t,n)}static setWireframeMode(e){let t=new Pt({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof Ge){let n=e;n.userData.materialForWireframe=n.material,n.material=t}}))}static setWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ho.setWireframeMode(n)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof Ge&&e.userData.materialForWireframe&&(e.material=e.userData.materialForWireframe,e.userData.materialForWireframe=void 0)}))}static revertWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ho.revertWireframeMode(n)}static findInner(e,t,n=[],i=!1){let r=t.toLowerCase(),a=[],s=e=>-1!==e.toLowerCase().indexOf(r),o=e=>-1!==e.toString().indexOf(r),l=e=>{if(e.name&&-1!==e.name.toLowerCase().indexOf(r))return!0;if(e.gltfExtensions){let t=e.gltfExtensions,n=t.objectId&&t.objectId.Value||t.elementId&&t.elementId.Value;if(n&&-1!==n.toLowerCase().indexOf(r))return!0}return!1};if(n.length>0)for(let h=0;h<n.length;++h){let t=n[h],r=e.getObjectById(t);if(r&&r.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]]}else if(e.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]];return a}static find(e,t,n=[],i=!1){return this.findInner(e,t,n,i)}static findFirst(e,t,n=[],i=!1){let r=this.findInner(e,t,n,i);if(r.length>0)return r[0]}static getFloorsFromString(e){let t=[],n=new RegExp(/(?:-?(?:\d+(?:\.5)?)F)(?=\W|$)/,"g").exec(e);return n&&n.length>0&&n.forEach((e=>{if(e){let n=e.replace("F",""),i=Number(n);i?t.push(i):console.log(`[OU] invalid floor: ${e}`)}})),t}static matchFloor(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>e===t))}static matchFloors(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>-1!==t.findIndex((t=>t===e))))}static distinctFloors(e,t){let n=[],i=e=>{this.getFloorsFromString(e).forEach((e=>{n[e]=!0}))};return t.forEach((t=>{let n=e.getObjectById(t);n&&n.traverse((e=>{if(i(e.name),e.userData.gltfExtensions){let t=e.userData.gltfExtensions;t.level&&t.level.Value&&i(t.level.Value)}}))})),Object.keys(n).sort()}static traverseObjectByFloors(e,t,n,i,r){let a=e.getObjectById(t);if(!a)return[];a.traverse((e=>{let t=this.matchFloors(e.name,n);if(!t&&e.userData&&e.userData.gltfExtensions){let i=e.userData.gltfExtensions;i.level&&i.level.Value&&(t=this.matchFloors(i.level.Value,n))}t&&i&&i(e),!t&&r&&r(e)}))}static setVisibleForFloors(e,t,n,i=!0){this.traverseObjectByFloors(e,t,n,(e=>{let t=e;for(;t;)t.visible=!0,t=t.parent||void 0}),(e=>{i&&(e.visible=!1)}))}static revertVisibleForFloors(e){e.traverse((e=>{e.visible=!0}))}static revertVisibleForFloorsById(e,t){let n=this.getObjectById(e,t);this.revertVisibleForFloors(n)}static getObjectById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);return n}static createOutlines(e,t={visibleOnly:!0,meshOnly:!0,replaceOriginalObject:!1}){if(!e)return[];if(0===e.children.length&&(t.visibleOnly&&!e.visible||t.meshOnly&&!(e instanceof Ge)))return[];let n=[],i=e;for(let r=i.children.length-1;r>=0;--r){let e=i.children[r],a=this.createOutlines(e,t);n.push(...a)}if(!i.geometry)return n;if(i instanceof Ar)for(let r=0;r<i.count;++r){let e=new Ae;i.getMatrixAt(r,e);let a=this.createOutline(i.geometry);if(t.replaceOriginalObject&&i.parent){let t=i.parent;a.applyMatrix4(e.premultiply(i.matrix)),t.add(a)}else a.applyMatrix4(e),i.add(a);a.updateWorldMatrix(!0,!1),n.push(a)}else if(i instanceof Ge){let e=this.createOutline(i.geometry);if(t.replaceOriginalObject&&i.parent){let t=i.parent;e.userData=Object.assign(e.userData,i.userData),i.removeFromParent(),i.geometry.dispose(),e.applyMatrix4(i.matrix),t.add(e)}else i.add(e);e.updateWorldMatrix(!0,!1),n.push(e)}return n}static addOutlines(e,t={visibleOnly:!0,meshOnly:!0,replaceOriginalObject:!1}){let n=this.createOutlines(e,t);return $a||($a=new Ay),$a.loadedGeometries.clear(),n}static removeOutlines(e){if(e&&Array.isArray(e.children))for(let t=e.children.length-1;t>=0;--t){let n=e.children[t];n.children.length>0&&this.removeOutlines(n),n.userData.isOutline&&e.remove(n)}}static hasOutline(e){let t=!1;for(let n=0;n<e.children.length;++n){let i=e.children[n];if(i.userData.isOutline){t=!0;break}if(i.children.length>0&&(t=this.hasOutline(i),t))break}return t}static setOutlinesVisibility(e,t){e.traverse((e=>{e.userData.isOutline&&(e.visible=t)}))}static createOutline(e,t=this.OUTLINE_MATERIAL){let n=new ja(e,5),i=new Dn(n,t);if(i.layers.enableAll(),Ho.disableLayerChannels(i,[12]),i.userData.isOutline=!0,i.matrixAutoUpdate=!1,i.visible=!1,i.updateMatrix(),$a||($a=new Ay),$a.loadedGeometries.has(e.id.toString())){let t=$a.loadedGeometries.get(e.id.toString());return n.setAttribute("position",new tt(t,3)),i.geometry=n,i.visible=!0,i}if($a.get(e.id.toString())||$a.add(e.id.toString(),[]),!$a.loadedGeometries.has(e.id.toString())){$a.add(e.id.toString(),$a.get(e.id.toString()).concat([{geometry:e,geom:n,line:i}]));let t=e.getAttribute("position");$a.postMessage({id:e.id,position:t.toJSON(),index:e.getIndex(),thresholdAngle:5})}return i}static createOutlineSync(e,t,n=this.OUTLINE_MATERIAL){let i=new ja(e,5),r=new Dn(i,n);return r.layers.enableAll(),Ho.disableLayerChannels(r,[12]),r.userData.isOutline=!0,r.matrixAutoUpdate=!1,r.applyMatrix4(t),r}static cloneObject(e,t=!0){let n=e.clone();return t&&n.traverse((e=>{(e instanceof Ge||e instanceof sn)&&(e.material=yi.cloneMaterial(e.material))})),n}static createBox(e,t,n,i=Ho.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,n)=>{a.push(new M(e,t,n))};s(0,0,0),s(e,0,0),s(e,t,0),s(0,t,0),s(0,0,n),s(e,0,n),s(e,t,n),s(0,t,n);let o=new et;o.setFromPoints(a);let l=[0,3,2,0,2,1,4,6,7,4,5,6,0,7,3,0,4,7,3,6,2,3,7,6,1,6,5,1,2,6];return r&&l.push(0,5,4,0,1,5),o.setIndex(l),o.computeVertexNormals(),new Ge(o,i)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof et))return e;let n=t.geometry;if(!n.hasAttribute("position"))return e;let i=n.getAttribute("position");if(0===i.count)return e;let r=i.itemSize,a=i.array,s=[];for(let h=0;h<r;h++)s.push(a[h]);for(let h=0;h<i.count;h++)for(let e=0;e<r;e++)a[h*r+e]-=s[e];e.updateMatrix();let o=e.matrix.clone();e.matrix.makeTranslation(s[0],s[1],s.length>2?s[2]:0);let l=e.matrixAutoUpdate;return e.matrixAutoUpdate=!1,e.applyMatrix4(o),e.matrixAutoUpdate=l,e}static isEmptyObject(e){if(0===e.children.length){let t=e.geometry;if(!t||!t.hasAttribute("position")||0===t.getAttribute("position").count)return!0}return!1}static removeEmptyObjects(e){for(let t=0;t<e.children.length;)this.removeEmptyObjects(e.children[t])||++t;return!!this.isEmptyObject(e)&&(e.removeFromParent(),!0)}static removeEmptyObjectsFromRemovingObjects(e,t){0!==e.length&&(e.forEach((e=>{e.removeFromParent()})),this.removeEmptyObjects(t))}static setSharedVariablesOfObject(e){e.uuid="",e.up=lrt}static isLeafObject(e){return(e instanceof Ge||e instanceof sn||e instanceof or)&&!!e.geometry}static enableLayerChannels(e,t,n=!0){for(let i=0,r=t.length;i<r;i++)e.layers.enable(t[i]);if(n){let n=e.children;for(let e=0,i=n.length;e<i;e++)Ho.enableLayerChannels(n[e],t,!0)}}static disableLayerChannels(e,t,n=!0){for(let i=0,r=t.length;i<r;i++)e.layers.disable(t[i]);if(n){let n=e.children;for(let e=0,i=n.length;e<i;e++)Ho.disableLayerChannels(n[e],t,!0)}}static setLayerChannels(e,t,n=!0){e.layers.disableAll();for(let i=0,r=t.length;i<r;i++)e.layers.enable(t[i]);if(n){let n=e.children;for(let e=0,i=n.length;e<i;e++)Ho.setLayerChannels(n[e],t,!0)}}},cn=Ho;cn.OUTLINE_MATERIAL=new Jt({name:"outline",color:0,transparent:!0,opacity:.2}),cn.BOX_FACE_MATERIAL=new es({color:11648971,transparent:!0,opacity:.3,side:Tr});var QS=new Ae,crt=new Ae,eR=class{static resetMergeInfo(){this.mergeInfo.removedObjects=0,this.mergeInfo.mergedMeshes=0,this.mergeInfo.mergedLines=0,this.mergeInfo.mergedPoints=0,this.mergeInfo.mergedUnknownTypeObjects=0,this.mergeInfo.elapsedTime=0}static merge(e,t=!0){let n=Date.now();this.mergeInner(e,t),this.mergeInfo.elapsedTime+=Date.now()-n}static mergeInner(e,t=!0){if(!e.children||e.children.length<1)return;let n=e.children.length,i={},r=[];for(let h=0;h<n;++h){let n=e.children[h];if(n.children.length>0){this.mergeInner(n,t);continue}if(n.userData.relativeToCenter||n.isInstancedMesh||!n.geometry||!(n.geometry instanceof et))continue;let a=!1,s=Object.values(i);for(let t=s.length-1;t>=0;--t){let n=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let n=r[t];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}a||r.push(h)}if(Object.keys(i).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(i).forEach((n=>{let i,r=n.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a;let s=e.children[n],o=s.geometry.clone();if(o.applyMatrix4(s.matrix),xt.tryConvertInterleavedBufferAttributes(o),o.userData.isLineSegments=!0===s.isLineSegments,c.push(o),t){let e=null==(r=null==(i=o.attributes)?void 0:i.position)?void 0:r.count,t=(null==(a=o.index)?void 0:a.count)||0;f.push({batchId:u,positionStart:d,positionCount:e,indexStart:p,indexCount:t}),d+=e,p+=t,u++}})),0!==c.length){if(h.isMesh){let e=Fo(c);if(!e)return;e.userData={},i=new Ge(e,h.material),a.push(i)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof fp||h.material instanceof It,f);if(!e)return;i=new Dn(e,h.material),s.push(i)}else if(h.isPoints){let e=Fo(c);if(!e)return;e.userData={},i=new or(e,h.material),o.push(i)}i&&(t?i.userData.batches=f:(i.userData=h.userData,i.userData.batches=void 0),i.userData.layerName=h.userData.layerName,i.name=`[Merged] ${h.name}`,i.matrixAutoUpdate=!1,i.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,i.visible=h.visible,l.push(...r)),c.forEach((e=>{xt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let n=e.children[t];e.remove(n)})),[...a,...s,...o].forEach((t=>{e.add(t)})),e.updateMatrix(),this.mergeInfo.removedObjects+=l.length,this.mergeInfo.mergedMeshes+=a.length,this.mergeInfo.mergedLines+=s.length,this.mergeInfo.mergedPoints+=o.length}static tryHandleMergeableObjects(e,t,n,i,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===n||t>=o||n>=o)return a;let l=s?e[t]:e.children[t],h=s?e[n]:e.children[n];return this.areObjectsMergeable(l,h)&&this.areGeometriesMergeable(l.geometry,h.geometry)&&yi.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}static isFilteredByOtherFactors(e,t){let n=e;if(n.isMesh&&n.material.isShaderMaterial)return!0;let i=!1,r=e;for(;r&&r!==t;){let e=r.userData;if(e.relativeToCenter||e.spatialFilterHandle){i=!0;break}r=r.parent}return i}static deepMerge(e,t=void 0,n=!0,i=!0,r=!0){let a={added:[],removed:[]};if(e.length<=1)return a;let s=Date.now(),o={},l=[];for(let m=0;m<e.length;++m){let n=e[m];if(n.isInstancedMesh||!n.geometry||!(n.geometry instanceof et)||this.isFilteredByOtherFactors(e[m],t))continue;let i=!1,r=Object.values(o);for(let t=r.length-1;t>=0;--t){let n=r[t].indexes[0];if(i=this.tryHandleMergeableObjects(e,m,n,o,l),i)break}for(let t=l.length-1;!i&&t>=0;--t){let n=l[t];if(i=this.tryHandleMergeableObjects(e,m,n,o,l),i)break}i||l.push(m)}if(Object.keys(o).length<=0)return a;$.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((n=>{let i=n.indexes;if(i.length<2)return;let a,s=e[i[0]],o=[],l=0,p=0,f=0,m=[];if(i.forEach((n=>{var i,a,h;let c=e[n],u=c.geometry.clone();if(s.material instanceof Jt&&u.deleteAttribute("lineDistance"),this.applyMatrix(u,c,t),u.userData.isLineSegments=!0===c.isLineSegments,o.push(u),r){let e,t=null==(a=null==(i=u.attributes)?void 0:i.position)?void 0:a.count,n=(null==(h=u.index)?void 0:h.count)||0;s.isLine&&(u.boundingSphere||u.computeBoundingSphere(),e=u.boundingSphere.clone()),m.push({batchId:l,positionStart:p,positionCount:t,indexStart:f,indexCount:n,boundingSphere:e}),p+=t,f+=n,l++}})),0!==o.length){if(s.isMesh){let e=Fo(o);if(!e)return;e.userData={},a=new Ge(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof fp||s.material instanceof It,m);if(!e)return;a=new Dn(e,s.material),c.push(a)}else if(s.isPoints){let e=Fo(o);if(!e)return;e.userData={},a=new or(e,s.material),u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.matrixAutoUpdate=!1,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,a.visible=s.visible,i.forEach((e=>d.push(e)))),o.forEach((e=>{xt.releaseGeometryManually(e)})),o=[]}})),$.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let i=e[t];p.push(i),n&&i.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),n&&t&&(t.add(e),e.updateWorldMatrix(!1,!1))})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,i&&t&&cn.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(QS.identity();i&&i!==n&&(QS.premultiply(i.matrix),i.parent);)i=i.parent;return QS.equals(crt)?e:e.applyMatrix4(QS)}static mergeLineGeometries(e,t,n,i){let r;if(n)r=eR.mergeBufferGeometriesWithLinesToLineSegments(e,t,i);else{if(r=Fo(e),!r)return;r.userData={};let n=[],a=0;e.forEach(((e,r)=>{let s=e.attributes.position;if(!s)return;let o=e.index,l=!0===e.userData.isLineSegments,h=n.length;if(o)for(let t=0;t<o.count;t++){let e=o.array[t];l?n.push(a+e):t>0&&n.push(a+o.array[t-1],a+e)}else for(let t=0;t<s.count;t++)t>0&&(l?t%2==1&&n.push(a+t-1,a+t):n.push(a+t-1,a+t));a+=s.count,t&&i&&(i[r].indexStart=h,i[r].indexCount=n.length-h)})),r.setIndex(n)}return r}static mergeBufferGeometriesWithLinesToLineSegments(e,t,n){let i=new Set(Object.keys(e[0].attributes)),r={},a=new et,s=[],o=0;for(let l=0;l<e.length;++l){let a=e[l],h=!0===a.userData.isLineSegments;s.push(h),a.index&&($.debug(`[Merge] Geometry '${l}' contains index buffer, going to convert it to non-indexed.`),a=xt.convertGeometryWithIndexedToNonIndexed(a));let c=0;for(let e in a.attributes){if(!i.has(e))return void $.error(`[Merge] mergeGeometries() failed with geometry at index ${l}. All geometries must have compatible attributes; make sure ${e} attribute exists among all geometries, or in none of them`);r[e]||(r[e]=[]),r[e].push(a.attributes[e]),c++}if(c!==i.size)return void $.error(`[Merge] mergeGeometries() failed with geometry at index ${l}. Make sure all geometries have the same number of attributes.`);if(t&&n){let e=a.attributes.position;n[l].indexStart=0,n[l].indexCount=0;let t=h?e.count:2*e.count-2;n[l].positionStart=o,n[l].positionCount=t,o+=t}}for(let l in r){let e=eR.mergeBufferAttributesWithLinesToLineSegments(r[l],s);if(!e)return void $.error(`[Merge] mergeGeometries() failed while trying to merge the ${l} attribute.`);a.setAttribute(l,e)}return a}static mergeBufferAttributesWithLinesToLineSegments(e,t){let n,i,r,a=0;for(let l=0;l<e.length;++l){let s=e[l];if(void 0===n&&(n=s.array.constructor),n!==s.array.constructor)return void $.error("[Merge] mergeBufferAttributes() failed. THREE.BufferAttribute.array must be of consistent array types across matching attributes.");if(void 0===i&&(i=s.itemSize),i!==s.itemSize)return void $.error("[Merge] mergeBufferAttributes() failed. THREE.BufferAttribute.itemSize must be consistent across matching attributes.");if(void 0===r&&(r=s.normalized),r!==s.normalized)return void $.error("[Merge] mergeBufferAttributes() failed. THREE.BufferAttribute.normalized must be consistent across matching attributes.");let o=t[l]?0:s.count-2;a+=(s.count+o)*i}let s=new n(a),o=0;for(let l=0;l<e.length;++l){let i=t[l],r=e[l],a=i?0:r.count-2,h=r.count+a,c=r.itemSize,u=new n(h*c),d=0;for(let e=0;e<r.count;e++){let t=e*c,n=0!==e&&e!==r.count-1&&!i;for(let e=0;e<c;e++)u[d+e]=r.array[t+e],n&&(u[d+c+e]=r.array[t+e]);d+=n?2*c:c}s.set(u,o),o+=h*c}return new Ct(s,i,r)}static removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static removeObjectFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areGeometriesMergeable(e,t){if(!e||!t||"InstancedBufferGeometry"===e.type||"InstancedBufferGeometry"===t.type||!!e.index!=!!t.index)return!1;let n=Object.keys(e.attributes);if(n.length!==Object.keys(t.attributes).length)return!1;for(let i of n)if(!t.attributes[i])return!1;return!0}static areObjectsMergeable(e,t){if(e.layers.mask!==t.layers.mask||e.renderOrder!==t.renderOrder||e.visible!==t.visible||e.userData.layerName!==t.userData.layerName)return!1;if(e.type===t.type)return!0;let n=e,i=t;return n.isMesh&&i.isMesh||n.isLine&&i.isLine||n.isPoints&&i.isPoints}static isMergedMesh(e){return!(!e||!e.userData.batches)}static isFaceIndexInBatch(e,t,n){if(e.boundsTree){let i=e.index.getX(3*n);if(i>=t.positionStart&&i<t.positionStart+t.positionCount)return!0}else if(e.index){let e=t.indexStart/3,i=(t.indexStart+t.indexCount)/3-1;if(n>=e&&n<=i)return!0}else{let e=3*n;if(e>=t.positionStart&&e<t.positionStart+t.positionCount)return!0}return!1}static getBatchByFaceIndex(e,t){if(t<0)return void $.error(`[Merge]: Invalid faceIndex: ${t}`);let n=e&&e.geometry&&e.userData.batches;if(n)for(let i=0;i<n.length;++i){let r=n[i];if(this.isFaceIndexInBatch(e.geometry,r,t))return r}}static getBatchIdByFaceIndex(e,t){let n=this.getBatchByFaceIndex(e,t);return n?n.batchId:-1}static getBatchByBatchId(e,t){let n=e&&e.geometry&&e.userData.batches;if(n)for(let i=0;i<n.length;++i){let e=n[i];if(e.batchId===t)return e}}static cloneGeometryForBatch(e,t){var n;let i=e&&e.geometry;if(!i)return;let r=i.attributes.position,a=null==r?void 0:r.array,s=null==(n=i.index)?void 0:n.array;if(!a||!s)return void $.warn(`[Merge]: Unexpected position: ${a}, or index: ${s}!`);let o=new et,l=t.positionStart,h=t.positionStart+t.positionCount,c=i.attributes;for(let m in c){let e=c[m],t=e.itemSize,n=e.array.slice(l*t,h*t);o.setAttribute(m,new Ct(n,t,e.normalized))}if(i.boundsTree&&(s=i.userData.originalIndex,!s))return void $.warn("[Merge] After building bvh, the original index data is not preserved !");let u=t.indexStart,d=t.indexStart+t.indexCount,p=[],f=0;for(let m=u;m<d&&m<s.length;++m)p[f++]=s[m]-t.positionStart;return o.setIndex(p),i.boundingBox&&o.computeBoundingBox(),i.boundingSphere&&o.computeBoundingSphere(),o}},gr=eR;gr.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var Vce=wi(Nce(),1),Bce={triangulate:function(e,t,n=2){let i,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*n:e.length,d=Fce(e,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=qrt(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(let t=n;t<u;t+=n)o=e[t],l=e[t+1],o<i&&(i=o),l<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return Ly(d,p,n,i,r,h,0),p}};function Fce(e,t,n,i,r){let a,s;if(r===tit(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Uce(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Uce(a,e[a],e[a+1],s);return s&&cR(s,s.next)&&(Ny(s),s=s.next),s}function wp(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!cR(i,i.next)&&0!==oi(i.prev,i,i.next))i=i.next;else{if(Ny(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Ly(e,t,n,i,r,a,s){if(!e)return;!s&&a&&$rt(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Vrt(e,i,r,a):krt(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Ny(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Ly(e=zrt(wp(e),t,n),t,n,i,r,a,2):2===s&&Grt(e,t,n,i,r,a):Ly(wp(e),t,n,i,r,a,1);break}}function krt(e){let t=e.prev,n=e,i=e.next;if(oi(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Mv(r,o,a,l,s,h,f.x,f.y)&&oi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Vrt(e,t,n,i){let r=e.prev,a=e,s=e.next;if(oi(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=zF(p,f,t,n,i),y=zF(m,g,t,n,i),x=e.prevZ,_=e.nextZ;for(;x&&x.z>=v&&_&&_.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Mv(o,c,l,u,h,d,x.x,x.y)&&oi(x.prev,x,x.next)>=0||(x=x.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&Mv(o,c,l,u,h,d,_.x,_.y)&&oi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Mv(o,c,l,u,h,d,x.x,x.y)&&oi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;_&&_.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&Mv(o,c,l,u,h,d,_.x,_.y)&&oi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function zrt(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!cR(r,a)&&Hce(r,i,i.next,a)&&Oy(r,a)&&Oy(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Ny(i),Ny(i.next),i=e=a),i=i.next}while(i!==e);return wp(i)}function Grt(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Jrt(s,e)){let o=kce(s,e);return s=wp(s,s.next),o=wp(o,o.next),Ly(s,t,n,i,r,a,0),void Ly(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function qrt(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r<a;r++)s=t[r]*i,o=r<a-1?t[r+1]*i:e.length,l=Fce(e,s,o,i,!1),l===l.next&&(l.steiner=!0),h.push(Krt(l));for(h.sort(Wrt),r=0;r<h.length;r++)n=jrt(h[r],n);return n}function Wrt(e,t){return e.x-t.x}function jrt(e,t){let n=Xrt(e,t);if(!n)return t;let i=kce(n,e);return wp(i,i.next),wp(n,n.next)}function Xrt(e,t){let n,i=t,r=-1/0,a=e.x,s=e.y;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x<i.next.x?i:i.next,e===a))return n}i=i.next}while(i!==t);if(!n)return null;let o,l=n,h=n.x,c=n.y,u=1/0;i=n;do{a>=i.x&&i.x>=h&&a!==i.x&&Mv(s<c?a:r,s,h,c,s<c?r:a,s,i.x,i.y)&&(o=Math.abs(s-i.y)/(a-i.x),Oy(i,e)&&(o<u||o===u&&(i.x>n.x||i.x===n.x&&Yrt(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function Yrt(e,t){return oi(e.prev,e,t.prev)<0&&oi(t.next,e,e.next)<0}function $rt(e,t,n,i){let r=e;do{0===r.z&&(r.z=zF(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Zrt(r)}function Zrt(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t<h&&(o++,i=i.nextZ,i);t++);for(l=h;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function zF(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Krt(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 Mv(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Jrt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Qrt(e,t)&&(Oy(e,t)&&Oy(t,e)&&eit(e,t)&&(oi(e.prev,e,t.prev)||oi(e,t.prev,t))||cR(e,t)&&oi(e.prev,e,e.next)>0&&oi(t.prev,t,t.next)>0)}function oi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function cR(e,t){return e.x===t.x&&e.y===t.y}function Hce(e,t,n,i){let r=lR(oi(e,t,n)),a=lR(oi(e,t,i)),s=lR(oi(n,i,e)),o=lR(oi(n,i,t));return!!(r!==a&&s!==o||0===r&&oR(e,n,t)||0===a&&oR(e,i,t)||0===s&&oR(n,e,i)||0===o&&oR(n,t,i))}function oR(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 lR(e){return e>0?1:e<0?-1:0}function Qrt(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&&Hce(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Oy(e,t){return oi(e.prev,e,e.next)<0?oi(e,t,e.next)>=0&&oi(e,e.prev,t)>=0:oi(e,t,e.prev)<0||oi(e,e.next,t)<0}function eit(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function kce(e,t){let n=new GF(e.i,e.x,e.y),i=new GF(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Uce(e,t,n,i){let r=new GF(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ny(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 GF(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function tit(e,t,n,i){let r=0;for(let a=t,s=n-i;a<n;a+=i)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}var nit=.01,bd=class{static getFaces(e){let t=e.map((e=>e.toArray())).reduce(((e,t)=>(e.push(...t),e)),[]),n=[];return Bce.triangulate(t,[],3).forEach((e=>n.push(e))),n}static arePointsCoplanar(e){if(e.length<4)return!0;let t=e[1].clone().sub(e[0]),n=e[2].clone().sub(e[0]).cross(t).normalize();for(let i=3;i<e.length;i++)if(e[i].clone().sub(e[0]).projectOnVector(n).length()>nit)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,Vce.default)(t).length>0}},qF=class{constructor(e,t,n=void 0,i=qF.DEFAULT_SCALE){this.isExplodeUp=!1,this.scene=e,this.objectId=t,t||console.log(`[EXP] Invalid objectId: ${t}`),this.scale=i,i<=0&&console.log(`[EXP] Invalid scale: ${i}`),n?this.position=n:(this.position=new M,this.getObjectCenter(this.position))}explode(){if(!this.objectId||!this.position||!this.scale)return void console.log(`[EXP] Invalid objectId: ${this.objectId}, or position: ${this.position}, or this.power: ${this.scale}`);let e=this.scene.getObjectById(this.objectId);e&&e.children?(console.log(`[EXP] Exploding ${e.name} at: ${this.position.x}, ${this.position.y}, ${this.position.z}`),this.explodeObject(e)):console.log("[EXP] No children to explode!")}explodeObject(e){e.geometry?this.explodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.explodeObject(e))):this.explodeLeafObject(e)}explodeLeafObject(e){if(e.geometry){if(e.userData.originalPosition=e.position.clone(),e instanceof Ar){let t=new Ae,n=new M,i=new En,r=new M;for(let a=0;a<e.count;++a){if(e.getMatrixAt(a,t),t.decompose(n,i,r),this.isExplodeUp){let e=(n.z-this.position.z)*this.scale;n.setZ(n.z+e)}else{let e=n.clone().sub(this.position);n.addScaledVector(e,this.scale)}t.setPosition(n),e.setMatrixAt(a,t)}e.matrixWorldNeedsUpdate=!0,e.instanceMatrix.needsUpdate=!0}else{let t=e.position.clone();if(e instanceof Ge&&e.geometry&&e.geometry.boundingBox?e.geometry.boundingBox.getCenter(t):console.warn(`[EXP] Failed to get center for ${e.type} '${e.name||e.id}', will use its position as center`),this.isExplodeUp){let n=(t.z-this.position.z)*this.scale;e.position.setZ(t.z+n)}else{let n=t.sub(this.position);e.position.addScaledVector(n,this.scale)}}e.updateMatrix()}}unexplode(){let e=this.scene.getObjectById(this.objectId);e&&e.children?(console.log(`[EXP] Unexploding ${e.name} at: ${this.position.x}, ${this.position.y}, ${this.position.z}`),this.unexplodeObject(e)):console.log("[EXP] No children to explode!")}unexplodeObject(e){e.geometry?this.unexplodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.unexplodeObject(e))):this.unexplodeLeafObject(e)}unexplodeLeafObject(e){let t=e.userData.originalPosition;t&&(e.position.set(t.x,t.y,t.z),e.updateMatrix(),delete e.userData.originalPosition)}setOnlyExplodeUp(e){this.isExplodeUp=e}getObjectCenter(e){let t=new lt;if(!this.objectId)return void console.log(`[EXP] Invalid objectId: ${this.objectId}`);let n=this.scene.getObjectById(this.objectId);n&&n.children?(n.traverse((e=>{t.expandByObject(e)})),t.getCenter(e)):console.log("[EXP] No children to explode!")}},Uy=qF;Uy.DEFAULT_SCALE=1;var Fr=class{static getVisibleObjectBoundingBox(e){let t=new lt;return e.traverseVisible((e=>{e instanceof Ge&&!1!==e.userData.selectable&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,n){let i=new lt;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=Fr.getBoundingBox(r,n);e.isEmpty()||i.union(e)}})),i}static getBoundingBox(e,t=!0){let n=new lt;if(e instanceof Ar)return Fr.getInstancedMeshBoundingBox(e);if(0===e.children.length)return n.expandByObject(e),n;let i=e.children.length,r=1;i>20&&(r=3),i>100&&(r=5),i>200&&(r=10),i>1e3&&(r=100),e.updateMatrixWorld(!1);for(let a=0;a<i;++a){let i=e.children[a];if(!t||a%r==0)if(i.updateMatrix(),i instanceof Ar){let e=Fr.getInstancedMeshBoundingBox(i);e.isEmpty()||n.union(e)}else if(it.isMatrixValid(i.matrixWorld)){let e=Fr.getBoundingBox(i);e.isEmpty()||n.union(e)}else console.warn(`[SceneUtils] Found object(${i.type}) with invalid matrix: ${i.matrixWorld.elements}`)}return e.geometry&&n.expandByObject(e),n}static getInstancedMeshBoundingBox(e){let t=new lt,n=new Ae;for(let i=0;i<e.count;++i){e.getMatrixAt(i,n);let r=e.geometry.clone();if(r.boundingBox){let e=r.boundingBox.applyMatrix4(n);!e.isEmpty()&&it.isBoxValid(e)&&t.union(e)}}return t.applyMatrix4(e.matrixWorld),t}static explodeObject(e,t,n,i=!1){n[e.id]&&n[e.id].unexplode();let r=new M;Fr.getObjectCenter(e,r);let a=new Uy(t,e.id,r);a.setOnlyExplodeUp(i),a.explode(),n[e.id]=a}static explodeObjects(e,t,n,i=!1){return e.traverse((r=>{n.find((e=>e===r.id))&&(r.children&&1===r.children.length?Fr.explodeObject(r.children[0],e,t,i):Fr.explodeObject(r,e,t,i))})),t}static unexplodeObjects(e,t){e.traverse((e=>{let n=t[e.id];n&&(n.unexplode(),delete t[e.id])}))}static getObjectCenter(e,t){let n=Fr.getBoundingBox(e);n.getCenter(t),t.y=n.min.y}},Ic=class{static setMaterialSection(e,t,n=!1,i=!1){let r=n&&e.clippingPlanes?e.clippingPlanes:[];r.push(...t),e.clippingPlanes=r,e.clipIntersection=i}static removeSection(e){e&&e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{e.clippingPlanes=void 0})):t&&(t.clippingPlanes=void 0)}))}static addSection(e,t,n=!1,i=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{Ic.setMaterialSection(e,t,n,i)})):r&&Ic.setMaterialSection(r,t,n,i)}))}static generateSectionPlanesByBox(e){let t=e.min,n=e.max;return[new er(new M(0,-1,0),n.y),new er(new M(0,1,0),-t.y),new er(new M(1,0,0),-t.x),new er(new M(-1,0,0),n.x)]}static generateSectionPlanesByPoints(e,t=!0){let n=e.length;if(n<2)return;let i=[];for(let r=0;r<n-1;r++){let a=e[r],s=e[(r+1)%n],o=new er;o.setFromCoplanarPoints(new M(a.x,a.y,-1),new M(a.x,a.y,0),new M(s.x,s.y,0)),t||o.negate(),i.push(o)}return i}},WF=new M,zce=new M,uR=class{modify(e,t){let n=(e=e.clone()).attributes;for(let u in n)"position"!==u&&e.deleteAttribute(u);let i=[],r=[],a=(e=mce(e)).getAttribute("position");for(let u=0;u<a.count;u++){let e=(new M).fromBufferAttribute(a,u),t=new jF(e);i.push(t)}let s=e.getIndex();if(null!==s)for(let u=0;u<s.count;u+=3){let e=s.getX(u),t=s.getX(u+1),n=s.getX(u+2),a=new hR(i[e],i[t],i[n],e,t,n);r.push(a)}else for(let u=0;u<a.count;u+=3){let e=u,t=u+1,n=u+2,a=new hR(i[e],i[t],i[n],e,t,n);r.push(a)}for(let u=0,d=i.length;u<d;u++)qce(i[u]);let o,l=t;for(;l--;){if(o=oit(i),!o){console.log("THREE.SimplifyModifier: No next vertex");break}ait(i,r,o,o.collapseNeighbor)}let h=new et,c=[];s=[];for(let u=0;u<i.length;u++){let e=i[u].position;c.push(e.x,e.y,e.z),i[u].id=u}for(let u=0;u<r.length;u++){let e=r[u];s.push(e.v1.id,e.v2.id,e.v3.id)}return h.setAttribute("position",new tt(c,3)),h.setIndex(s),h}};function rit(e,t){-1===e.indexOf(t)&&e.push(t)}function Mp(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function iit(e,t){let n=t.position.distanceTo(e.position),i=0,r=[];for(let a=0,s=e.faces.length;a<s;a++){let n=e.faces[a];n.hasVertex(t)&&r.push(n)}for(let a=0,s=e.faces.length;a<s;a++){let t=1,n=e.faces[a];for(let e=0;e<r.length;e++){let i=r[e],a=n.normal.dot(i.normal);t=Math.min(t,(1.001-a)/2)}i=Math.max(i,t)}return r.length<2&&(i=1),n*i+0}function qce(e){if(0===e.neighbors.length)return e.collapseNeighbor=null,void(e.collapseCost=-.01);e.collapseCost=1e5,e.collapseNeighbor=null;for(let t=0;t<e.neighbors.length;t++){let n=iit(e,e.neighbors[t]);e.collapseNeighbor||(e.collapseNeighbor=e.neighbors[t],e.collapseCost=n,e.minCost=n,e.totalCost=0,e.costCount=0),e.costCount++,e.totalCost+=n,n<e.minCost&&(e.collapseNeighbor=e.neighbors[t],e.minCost=n)}e.collapseCost=e.totalCost/e.costCount}function Gce(e,t){for(console.assert(0===e.faces.length);e.neighbors.length;)Mp(e.neighbors.pop().neighbors,e);Mp(t,e)}function sit(e,t){Mp(t,e),e.v1&&Mp(e.v1.faces,e),e.v2&&Mp(e.v2.faces,e),e.v3&&Mp(e.v3.faces,e);let n=[e.v1,e.v2,e.v3];for(let i=0;i<3;i++){let e=n[i],t=n[(i+1)%3];!e||!t||(e.removeIfNonNeighbor(t),t.removeIfNonNeighbor(e))}}function ait(e,t,n,i){if(!i)return void Gce(n,e);let r=[];for(let a=0;a<n.neighbors.length;a++)r.push(n.neighbors[a]);for(let a=n.faces.length-1;a>=0;a--)n.faces[a]&&n.faces[a].hasVertex(i)&&sit(n.faces[a],t);for(let a=n.faces.length-1;a>=0;a--)n.faces[a].replaceVertex(n,i);Gce(n,e);for(let a=0;a<r.length;a++)qce(r[a])}function oit(e){let t=e[0];for(let n=0;n<e.length;n++)e[n].collapseCost<t.collapseCost&&(t=e[n]);return t}var hR=class{constructor(e,t,n,i,r,a){this.a=i,this.b=r,this.c=a,this.v1=e,this.v2=t,this.v3=n,this.normal=new M,this.computeNormal(),e.faces.push(this),e.addUniqueNeighbor(t),e.addUniqueNeighbor(n),t.faces.push(this),t.addUniqueNeighbor(e),t.addUniqueNeighbor(n),n.faces.push(this),n.addUniqueNeighbor(e),n.addUniqueNeighbor(t)}computeNormal(){let e=this.v1.position,t=this.v2.position,n=this.v3.position;WF.subVectors(n,t),zce.subVectors(e,t),WF.cross(zce).normalize(),this.normal.copy(WF)}hasVertex(e){return e===this.v1||e===this.v2||e===this.v3}replaceVertex(e,t){e===this.v1?this.v1=t:e===this.v2?this.v2=t:e===this.v3&&(this.v3=t),Mp(e.faces,this),t.faces.push(this),e.removeIfNonNeighbor(this.v1),this.v1.removeIfNonNeighbor(e),e.removeIfNonNeighbor(this.v2),this.v2.removeIfNonNeighbor(e),e.removeIfNonNeighbor(this.v3),this.v3.removeIfNonNeighbor(e),this.v1.addUniqueNeighbor(this.v2),this.v1.addUniqueNeighbor(this.v3),this.v2.addUniqueNeighbor(this.v1),this.v2.addUniqueNeighbor(this.v3),this.v3.addUniqueNeighbor(this.v1),this.v3.addUniqueNeighbor(this.v2),this.computeNormal()}},jF=class{constructor(e){this.position=e,this.id=-1,this.faces=[],this.neighbors=[],this.collapseCost=0,this.collapseNeighbor=null}addUniqueNeighbor(e){rit(this.neighbors,e)}removeIfNonNeighbor(e){let t=this.neighbors,n=this.faces,i=t.indexOf(e);if(-1!==i){for(let t=0;t<n.length;t++)if(n[t].hasVertex(e))return;t.splice(i,1)}}},Wce=class{static simplifyGeometry(e,t){let n=this.getNumberOfVerticesToRemove(e,t);return n>0?(new uR).modify(e,n):e}static getNumberOfVerticesToRemove(e,t){let n=0;e instanceof et&&e.index&&(n=e.attributes.position.count);let i=Math.floor(n*t);return n<20?0:i}},Sp=class{static createSkyOfGradientRamp(e=4e3,t=32,n=15,i=new M,r=new M(0,.7,.5)){let a=this.COLOR_TEMPLATES.default,s={topColor:{value:new Ie(a[0])},skylineColor:{value:new Ie(a[1])},bottomColor:{value:new Ie(a[2])},offset:{value:400},exponent:{value:.9},skyCenter:{value:i||new M},sunDirection:{value:r.normalize()}},o=new da(e,t,n),l=new It({uniforms:s,vertexShader:this.vertexShader,fragmentShader:this.fragmentShader,side:ri}),h=new Ge(o,l);return h.matrixAutoUpdate=!1,h.name=this.NAME,h.userData.selectable=!1,h}static createSkyOfGradientRampByBoundingBox(e){let t=2*(e.max.x-e.min.x+(e.max.y-e.min.y)+(e.max.z-e.min.z));t<Sp.MIN_SKY_RADIUS?t=Sp.MIN_SKY_RADIUS:t>Sp.MAX_SKY_RADIUS&&(t=Sp.MAX_SKY_RADIUS);let n=new M;e.getCenter(n);let i=Sp.createSkyOfGradientRamp(t,void 0,void 0,n);return i.position.set(n.x,0,n.z),i}static createSkyFromTextures(e){return $e(this,null,(function*(){let t=new ty;return new Promise((n=>{t.load(e,(e=>n(e)))}))}))}},Ka=Sp;Ka.NAME="SKYBOX",Ka.MIN_SKY_RADIUS=4e3,Ka.MAX_SKY_RADIUS=2e4,Ka.vertexShader="\n varying vec3 vWorldPosition;\n void main() {\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",Ka.fragmentShader="\n uniform vec3 topColor;\n uniform vec3 skylineColor;\n uniform vec3 bottomColor;\n uniform float offset;\n uniform float exponent;\n uniform vec3 skyCenter;\n uniform vec3 sunDirection;\n varying vec3 vWorldPosition;\n // Used to find the position to draw the sun. Sun size is bigger when this value is smaller\n const float sunDirectionDotThreshold = 0.98;\n\n void main() {\n vec3 position = vec3(vWorldPosition.x - skyCenter.x, vWorldPosition.y - skyCenter.y, vWorldPosition.z - skyCenter.z);\n vec3 normalizedPosition = normalize( position + offset );\n float h = normalizedPosition.y;\n vec3 color;\n if (h > 0.0) {\n color = mix( skylineColor, topColor, pow( h, exponent ) );\n\n // draw the sun\n float dotResult = dot(sunDirection, normalizedPosition);\n if (dotResult > sunDirectionDotThreshold) {\n const float sunSize = 1.0 - sunDirectionDotThreshold; // maximum sun size\n const vec3 sunColor = vec3(1.0, 1.0, 1.0);\n color = mix(color, sunColor, pow((dotResult + sunSize - 1.0) / sunSize, 3.0));\n }\n } else {\n color = mix( skylineColor, bottomColor, pow( -h, exponent ) );\n }\n gl_FragColor = vec4(color , 1.0);\n }",Ka.COLOR_TEMPLATES={default:[8828661,16777215,10066329],blueSky:[11189247,16777215,6974058],boardwalk:[14413823,16777215,15459804]};var dR=class extends Tt{constructor(e){super(),this.isSVGObject=!0,this.node=e}},Kwt=10,Xce=(e=>(e.Dot="Dot",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(Xce||{}),jce=class{static createSVGObject(e){return new dR(e)}},fR=class extends gp{constructor(e){super(e),this.type=Ga}parse(e){let t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,a=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=o.indexOf("\n"))&&a<t&&i<e.byteLength;)s+=o,a+=o.length,i+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<r&&(!1!==n&&(e.pos+=a+r+1),s+o.slice(0,r))},i=function(e,t,n,i){let r=e[t+3],a=Math.pow(2,r-128)/255;n[i+0]=e[t+0]*a,n[i+1]=e[t+1]*a,n[i+2]=e[t+2]*a,n[i+3]=1},r=function(e,t,n,i){let r=e[t+3],a=Math.pow(2,r-128)/255;n[i+0]=iv.toHalfFloat(Math.min(e[t+0]*a,65504)),n[i+1]=iv.toHalfFloat(Math.min(e[t+1]*a,65504)),n[i+2]=iv.toHalfFloat(Math.min(e[t+2]*a,65504)),n[i+3]=iv.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;let s=function(e){let i,r,a=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,l=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,h={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=e.byteLength||!(i=n(e)))return t(1,"no header found");if(!(r=i.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(h.valid|=1,h.programtype=r[1],h.string+=i+"\n";i=n(e),!1!==i;)if(h.string+=i+"\n","#"!==i.charAt(0)){if((r=i.match(a))&&(h.gamma=parseFloat(r[1])),(r=i.match(s))&&(h.exposure=parseFloat(r[1])),(r=i.match(o))&&(h.valid|=2,h.format=r[1]),(r=i.match(l))&&(h.valid|=4,h.height=parseInt(r[1],10),h.width=parseInt(r[2],10)),2&h.valid&&4&h.valid)break}else h.comments+=i+"\n";return 2&h.valid?4&h.valid?h:t(3,"missing image size specifier"):t(3,"missing format specifier")}(a);if(-1!==s){let e=s.width,n=s.height,o=function(e,n,i){let r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");let a=new Uint8Array(4*n*i);if(!a.length)return t(4,"unable to allocate buffer space");let s=0,o=0,l=4*r,h=new Uint8Array(4),c=new Uint8Array(l),u=i;for(;u>0&&o<e.byteLength;){if(o+4>e.byteLength)return t(1);if(h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i<l&&o<e.byteLength;){n=e[o++];let r=n>128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){let t=e[o++];for(let e=0;e<n;e++)c[i++]=t}else c.set(e.subarray(o,o+n),i),i+=n,o+=n}let d=r;for(let e=0;e<d;e++){let t=0;a[s]=c[e+t],t+=r,a[s+1]=c[e+t],t+=r,a[s+2]=c[e+t],t+=r,a[s+3]=c[e+t],s+=4}u--}return a}(a.subarray(a.pos),e,n);if(-1!==o){let t,a,l;switch(this.type){case Bs:l=o.length/4;let e=new Float32Array(4*l);for(let t=0;t<l;t++)i(o,4*t,e,4*t);t=e,a=Bs;break;case Ga:l=o.length/4;let n=new Uint16Array(4*l);for(let t=0;t<l;t++)r(o,4*t,n,4*t);t=n,a=Ga;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:s.string,gamma:s.gamma,exposure:s.exposure,type:a}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case Bs:case Ga:e.colorSpace=ks,e.minFilter=Vn,e.magFilter=Vn,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}},Cl=class{static createEnvTexture(e,t){return $e(this,null,(function*(){let n=new fR;return new Promise((i=>{n.load(t,(t=>{if(e){let n=e.fromEquirectangular(t).texture;e.dispose(),i(n)}}))}))}))}static createEnvTextureFromDataArray(e){return $e(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,n=64,i=32){if(e){let r=new Ro(t,n,i);r.flipY=!0,r.magFilter=Vn,r.minFilter=Vn,r.type=Ga,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function lit(){if(tn.isBrowser){let e=document.createElement("div");return e.setAttribute("style","height: 1in; visibility: hidden; position: absolute; margin: 0; padding: 0;"),document.body.appendChild(e),.0254/e.clientHeight}return.0254/96}Cl.HDR_CITY_STREET_64x32=Uint16Array.from([11910,12340,12797,15360,11926,12348,12806,15360,11958,12364,12814,15360,11974,12380,12830,15360,11958,12364,12822,15360,11926,12348,12797,15360,11878,12324,12773,15360,11830,12308,12749,15360,11798,12292,12733,15360,11782,12279,12725,15360,11765,12263,12709,15360,11749,12247,12701,15360,11733,12231,12701,15360,11701,12215,12693,15360,11685,12199,12685,15360,11685,12199,12685,15360,11701,12215,12693,15360,11717,12231,12701,15360,11733,12247,12709,15360,11749,12263,12717,15360,11749,12279,12717,15360,11765,12279,12725,15360,11765,12279,12725,15360,11765,12292,12725,15360,11798,12300,12733,15360,11830,12316,12749,15360,11846,12324,12757,15360,11894,12340,12781,15360,11926,12356,12797,15360,11942,12356,12797,15360,11926,12348,12789,15360,11926,12348,12789,15360,11942,12356,12797,15360,11942,12356,12797,15360,11942,12348,12806,15360,11942,12356,12806,15360,11942,12356,12814,15360,11958,12372,12830,15360,11974,12372,12830,15360,11974,12372,12838,15360,11990,12388,12854,15360,12055,12420,12886,15360,12119,12452,12918,15360,12167,12476,12950,15360,12231,12500,12982,15360,12263,12516,12998,15360,12231,12500,12974,15360,12199,12484,12958,15360,12199,12484,12958,15360,12199,12492,12966,15360,12247,12508,12982,15360,12247,12508,12990,15360,12231,12500,12982,15360,12199,12484,12966,15360,12167,12468,12942,15360,12119,12444,12918,15360,12087,12436,12902,15360,12055,12420,12886,15360,12055,12412,12878,15360,12039,12412,12878,15360,12022,12396,12862,15360,12006,12388,12846,15360,11958,12364,12830,15360,11910,12340,12806,15360,12119,12508,13103,15360,12087,12484,13071,15360,12055,12468,13046,15360,12006,12436,13006,15360,11926,12396,12958,15360,11878,12364,12926,15360,11846,12348,12894,15360,11782,12308,12854,15360,11749,12292,12830,15360,11717,12263,12814,15360,11685,12247,12806,15360,11669,12215,12789,15360,11685,12231,12789,15360,11701,12247,12797,15360,11701,12247,12806,15360,11717,12263,12814,15360,11749,12292,12822,15360,11782,12308,12838,15360,11798,12316,12846,15360,11814,12332,12862,15360,11846,12340,12870,15360,11862,12348,12878,15360,11846,12340,12870,15360,11846,12340,12862,15360,11878,12356,12886,15360,11910,12372,12910,15360,11942,12396,12934,15360,11958,12412,12958,15360,12039,12452,12998,15360,12071,12468,13022,15360,12039,12452,12998,15360,12039,12452,12998,15360,12006,12444,13006,15360,11974,12436,12998,15360,11942,12412,12982,15360,11926,12396,12974,15360,11926,12404,12974,15360,11958,12420,12998,15360,12006,12452,13038,15360,12055,12476,13071,15360,12039,12476,13079,15360,12087,12508,13127,15360,12247,12597,13231,15360,12388,12693,13332,15360,12420,12741,13364,15360,12436,12757,13372,15360,12468,12773,13380,15360,12500,12806,13388,15360,12516,12822,13404,15360,12629,12934,13452,15360,12741,13046,13508,15360,12806,13095,13532,15360,12757,13046,13516,15360,12645,12950,13460,15360,12565,12870,13428,15360,12532,12838,13412,15360,12549,12854,13412,15360,12516,12838,13396,15360,12452,12757,13356,15360,12420,12725,13340,15360,12404,12709,13332,15360,12372,12677,13316,15360,12279,12589,13207,15360,12135,12516,13119,15360,12388,12709,13348,15360,12247,12581,13223,15360,12055,12476,13087,15360,11910,12388,12982,15360,11733,12308,12886,15360,11669,12247,12846,15360,11621,12199,12814,15360,11541,12103,12765,15360,11492,12055,12733,15360,11508,12055,12733,15360,11476,12022,12717,15360,11525,12055,12725,15360,11589,12135,12757,15360,11669,12199,12765,15360,11765,12292,12814,15360,11862,12348,12886,15360,11910,12372,12910,15360,12006,12420,12966,15360,12071,12452,12998,15360,12119,12476,13022,15360,12167,12492,13046,15360,12183,12500,13063,15360,12199,12524,13079,15360,12308,12589,13151,15360,12300,12581,13151,15360,12167,12516,13087,15360,12087,12468,13030,15360,12022,12444,13014,15360,11990,12420,12990,15360,11974,12420,12990,15360,11974,12420,12990,15360,11990,12436,13014,15360,11990,12444,13030,15360,12103,12500,13103,15360,12087,12508,13111,15360,12039,12484,13103,15360,12039,12476,13103,15360,11942,12436,13054,15360,11974,12452,13087,15360,12039,12492,13135,15360,12103,12532,13199,15360,12183,12581,13263,15360,12308,12661,13340,15360,12484,12822,13436,15360,12613,12918,13484,15360,12725,13046,13540,15360,13046,13332,13677,15360,13143,13380,13717,15360,13223,13420,13741,15360,13396,13540,13862,15360,13436,13589,13902,15360,13484,13629,13942,15360,13468,13621,13934,15360,13412,13564,13878,15360,13372,13524,13846,15360,13287,13452,13781,15360,13223,13428,13749,15360,13340,13492,13805,15360,13239,13428,13749,15360,13095,13364,13685,15360,12918,13223,13597,15360,12822,13111,13556,15360,12613,12934,13468,15360,12532,12854,13428,15360,12565,12870,13444,15360,12468,12789,13396,15360,12372,12693,13340,15360,12087,12492,13111,15360,11846,12364,12958,15360,11717,12300,12878,15360,11557,12135,12781,15360,11476,12055,12741,15360,11460,12022,12725,15360,11476,12022,12725,15360,11476,12022,12709,15360,11476,11958,12605,15360,11364,11733,12332,15360,11111,11412,11661,15360,11223,11476,11773,15360,11388,11669,12095,15360,11765,12119,12492,15360,12388,12613,13079,15360,12661,12902,13356,15360,12998,13255,13564,15360,13372,13508,13797,15360,13412,13548,13846,15360,13287,13436,13725,15360,13271,13428,13709,15360,13287,13428,13717,15360,13014,13287,13597,15360,12709,12998,13460,15360,12452,12741,13332,15360,12364,12653,13271,15360,12404,12693,13316,15360,12420,12709,13316,15360,12420,12709,13332,15360,12263,12589,13231,15360,12332,12661,13312,15360,12300,12629,13295,15360,12263,12605,13287,15360,12231,12597,13279,15360,12247,12613,13303,15360,12231,12597,13295,15360,12231,12605,13312,15360,12199,12597,13324,15360,12231,12613,13340,15360,12516,12870,13468,15360,12725,13063,13564,15360,12741,13079,13573,15360,12854,13175,13613,15360,12902,13223,13629,15360,13046,13348,13693,15360,13356,13516,13846,15360,13605,13765,14078,15360,13717,13870,14191,15360,13765,13918,14255,15360,13765,13910,14247,15360,13701,13854,14191,15360,13573,13733,14070,15360,13508,13677,14006,15360,13380,13548,13886,15360,13111,13380,13741,15360,13063,13348,13709,15360,12886,13207,13629,15360,12725,13046,13548,15360,12645,12966,13508,15360,12677,12982,13508,15360,12629,12950,13492,15360,12452,12789,13412,15360,12324,12661,13332,15360,12356,12677,13340,15360,12388,12693,13348,15360,12279,12597,13247,15360,11894,12396,12998,15360,11637,12231,12846,15360,11573,12135,12789,15360,11589,12151,12797,15360,11621,12167,12797,15360,11637,12119,12677,15360,11079,11404,11693,15360,10517,10701,10653,15360,10252,10348,10007,15360,9902,9999,9428,15360,9846,9886,9047,15360,10135,10260,9685,15360,10412,10533,10412,15360,11268,11436,11549,15360,12364,12605,13087,15360,12444,12709,13255,15360,12549,12822,13348,15360,12613,12886,13396,15360,12597,12886,13412,15360,12581,12870,13404,15360,12661,12950,13460,15360,12725,13014,13492,15360,13079,13332,13645,15360,12757,13046,13500,15360,12677,12982,13476,15360,12854,13143,13556,15360,12693,12982,13492,15360,12581,12886,13452,15360,12709,13030,13508,15360,12372,12709,13364,15360,12324,12661,13348,15360,12292,12645,13340,15360,12292,12645,13348,15360,12468,12806,13436,15360,12532,12854,13460,15360,12500,12854,13468,15360,12500,12854,13484,15360,12725,13063,13589,15360,12982,13324,13701,15360,13111,13388,13741,15360,13014,13340,13709,15360,13014,13332,13717,15360,13287,13476,13862,15360,13436,13621,13974,15360,13532,13717,14095,15360,13725,13902,14295,15360,13942,14103,14420,15360,13974,14135,14436,15360,13862,14022,14388,15360,13725,13894,14295,15360,13789,13958,14336,15360,13830,13990,14348,15360,13372,13548,13942,15360,13014,13332,13733,15360,12886,13239,13661,15360,12854,13207,13637,15360,12757,13095,13589,15360,12757,13079,13573,15360,12645,12982,13516,15360,12629,12966,13532,15360,12549,12870,13468,15360,12356,12693,13372,15360,12151,12549,13231,15360,12215,12573,13247,15360,12199,12565,13231,15360,12071,12492,13135,15360,12055,12468,13087,15360,11878,12372,12958,15360,11685,12199,12781,15360,10774,11159,11412,15360,9533,9621,8870,15360,9308,9340,8071,15360,9276,9300,7878,15360,9324,9332,8420,15360,9191,9216,7991,15360,8950,8983,7766,15360,9493,9525,8677,15360,10252,10332,10007,15360,10661,10846,10894,15360,10701,10926,10998,15360,10950,11276,11428,15360,11364,11637,12063,15360,11958,12388,12926,15360,12183,12540,13175,15360,12340,12645,13295,15360,12420,12693,13316,15360,12757,13030,13460,15360,13046,13324,13645,15360,13095,13348,13677,15360,13303,13460,13781,15360,13207,13404,13741,15360,13127,13372,13717,15360,13372,13524,13862,15360,12693,13030,13540,15360,12725,13046,13548,15360,12468,12822,13436,15360,12263,12629,13348,15360,12436,12773,13428,15360,12693,12998,13524,15360,12725,13046,13564,15360,12645,12982,13556,15360,12613,12966,13556,15360,12886,13255,13685,15360,13436,13629,14022,15360,13637,13813,14231,15360,13621,13789,14215,15360,13878,14038,14412,15360,14022,14183,14468,15360,13926,14119,14452,15360,14054,14231,14508,15360,14135,14311,14540,15360,14348,14436,14669,15360,14460,14540,14749,15360,14404,14484,14709,15360,14420,14500,14709,15360,14653,14717,14894,15360,14119,14279,14508,15360,13484,13669,14078,15360,13063,13380,13773,15360,12677,13079,13613,15360,12484,12886,13516,15360,12436,12822,13476,15360,12468,12838,13476,15360,12039,12532,13316,15360,12231,12613,13340,15360,12468,12789,13436,15360,12388,12725,13396,15360,12135,12557,13287,15360,12151,12557,13271,15360,12039,12484,13175,15360,11878,12396,13038,15360,11814,12348,12950,15360,11492,11894,12460,15360,9950,10103,9621,15360,8830,8838,7220,15360,8565,8533,7015,15360,8541,8501,6919,15360,8332,8300,6822,15360,8412,8372,7220,15360,8710,8701,7686,15360,9372,9404,8549,15360,9533,9621,9079,15360,9268,9292,8196,15360,9452,9460,8167,15360,9533,9581,8533,15360,9742,9870,9316,15360,11460,11814,12348,15360,11942,12388,12902,15360,11749,12167,12573,15360,11300,11492,11621,15360,11974,12332,12669,15360,12436,12741,13364,15360,12597,12886,13460,15360,12966,13271,13653,15360,12998,13303,13669,15360,13476,13629,13974,15360,13733,13886,14239,15360,13364,13524,13894,15360,13063,13356,13725,15360,12982,13287,13669,15360,12484,12806,13444,15360,12565,12902,13500,15360,12950,13287,13693,15360,12934,13271,13677,15360,12693,13046,13589,15360,12661,13030,13605,15360,12870,13271,13717,15360,13348,13548,13966,15360,13621,13813,14271,15360,13797,13974,14412,15360,13942,14119,14484,15360,14263,14388,14629,15360,14420,14508,14733,15360,14460,14548,14773,15360,14982,15046,15231,15360,15564,15580,15669,15360,15974,15982,16078,15360,15805,15821,15926,15360,15460,15476,15572,15360,15436,15460,15556,15360,14781,14862,15127,15360,13621,13813,14348,15360,12789,13207,13757,15360,12452,12886,13581,15360,12263,12709,13476,15360,12039,12597,13396,15360,11942,12516,13340,15360,11846,12468,13271,15360,11733,12380,13127,15360,11926,12460,13191,15360,12055,12524,13263,15360,11878,12428,13159,15360,11605,12231,12886,15360,11412,11990,12709,15360,11508,12103,12789,15360,11637,12231,12854,15360,10661,11079,11380,15360,9541,9685,9252,15360,8573,8605,7493,15360,8404,8388,7348,15360,8830,8822,8212,15360,9308,9324,9095,15360,9324,9364,9220,15360,9047,9119,8653,15360,9023,9055,8404,15360,9055,9063,8167,15360,8870,8846,7541,15360,8862,8806,7380,15360,8950,8910,7252,15360,9268,9284,7557,15360,10316,10468,10380,15360,11239,11476,11677,15360,10653,10942,11047,15360,9661,9814,9324,15360,10693,10958,11047,15360,11396,11653,11990,15360,11878,12292,12597,15360,12468,12789,13396,15360,12773,13095,13589,15360,13364,13516,13894,15360,13894,14054,14380,15360,13717,13870,14247,15360,13420,13589,13958,15360,13255,13452,13830,15360,12806,13143,13637,15360,13159,13412,13830,15360,13629,13813,14215,15360,13303,13500,13910,15360,13079,13396,13805,15360,13191,13452,13878,15360,13412,13621,14062,15360,14103,14279,14540,15360,14773,14854,15086,15360,14717,14805,15046,15360,14295,14420,14685,15360,14380,14476,14733,15360,14572,14661,14902,15360,15596,15612,15701,15360,16351,16335,16384,15360,16484,16476,16492,15360,16516,16500,16516,15360,16388,16375,16404,15360,16054,16054,16118,15360,15918,15926,16006,15360,15556,15572,15669,15360,14653,14725,14982,15360,13637,13838,14319,15360,13412,13613,14054,15360,12870,13287,13789,15360,12404,12838,13524,15360,12199,12677,13428,15360,12324,12741,13452,15360,11942,12516,13324,15360,11765,12380,13111,15360,11428,11942,12589,15360,10886,11388,11902,15360,10372,10717,11006,15360,9846,10240,10191,15360,10252,10549,10766,15360,10613,11079,11484,15360,10581,10998,11388,15360,9613,9846,9629,15360,8525,8557,7541,15360,8605,8613,7814,15360,9292,9324,9079,15360,9388,9396,9220,15360,10709,10846,11031,15360,9894,9966,9854,15360,9252,9236,8774,15360,8822,8790,8183,15360,8292,8260,6533,15360,8111,8007,6324,15360,8228,8183,6405,15360,8501,8501,6565,15360,8814,8878,7172,15360,9260,9364,8244,15360,8902,9095,8252,15360,9444,9581,9047,15360,9509,9637,8790,15360,9477,9613,8806,15360,10725,11063,11079,15360,11508,11910,12356,15360,12484,12789,13380,15360,12838,13159,13629,15360,13428,13589,13974,15360,14135,14279,14484,15360,13942,14087,14396,15360,13677,13846,14247,15360,13436,13613,14006,15360,13597,13781,14183,15360,14183,14340,14540,15360,14022,14215,14484,15360,13637,13838,14271,15360,14038,14231,14508,15360,14380,14476,14701,15360,14757,14854,15078,15360,15030,15111,15343,15360,15420,15452,15556,15360,15476,15500,15588,15360,15351,15388,15492,15360,15572,15596,15677,15360,15653,15669,15717,15360,15821,15821,15853,15360,15845,15845,15869,15360,15998,15990,16022,15360,15926,15926,15974,15360,15653,15669,15733,15360,15661,15677,15749,15360,15612,15629,15717,15360,15271,15335,15452,15360,14484,14572,14821,15360,14215,14372,14588,15360,13468,13677,14167,15360,12773,13175,13653,15360,12725,13143,13637,15360,12452,12886,13532,15360,12263,12709,13444,15360,11894,12436,13103,15360,10252,10533,10661,15360,8613,8693,7445,15360,8742,8782,7047,15360,8420,8412,6565,15360,7926,7910,6405,15360,8806,8854,7300,15360,9127,9228,8007,15360,8685,8750,7300,15360,8348,8356,6758,15360,8380,8340,7300,15360,8991,8918,8388,15360,9838,9790,9549,15360,10055,10127,10047,15360,9501,9493,9268,15360,9332,9292,8902,15360,9079,9007,8509,15360,8300,8260,7252,15360,8693,8701,8196,15360,8228,8212,7111,15360,8469,8501,7380,15360,8420,8501,6919,15360,8549,8645,6983,15360,8581,8661,6951,15360,9268,9332,7718,15360,9063,9207,7445,15360,9284,9380,7718,15360,9412,9557,8693,15360,10276,10517,10103,15360,11830,12279,12589,15360,12725,13079,13589,15360,13127,13396,13773,15360,14087,14231,14460,15360,13974,14119,14412,15360,13677,13854,14247,15360,14119,14279,14500,15360,13990,14167,14460,15360,14364,14452,14653,15360,14564,14653,14837,15360,14404,14492,14701,15360,14870,14942,15135,15360,15388,15420,15500,15360,15207,15287,15420,15360,14797,14894,15127,15360,15271,15335,15452,15360,15926,15942,15990,15360,16207,16207,16231,15360,16118,16110,16126,15360,15741,15733,15741,15360,16239,16207,16175,15360,16444,16460,16484,15360,16046,16022,16006,15360,15942,15950,15966,15360,15773,15789,15829,15360,15789,15797,15845,15360,15693,15709,15757,15360,15540,15564,15653,15360,15303,15364,15468,15360,14733,14813,15014,15360,13862,14054,14420,15360,12838,13255,13725,15360,12789,13207,13693,15360,12468,12918,13564,15360,12404,12838,13500,15360,11428,11862,12412,15360,9143,9276,8388,15360,8541,8533,6726,15360,8444,8428,6629,15360,8212,8183,6597,15360,8388,8380,7015,15360,8726,8710,6758,15360,8332,8316,6437,15360,8453,8428,6565,15360,8597,8605,7814,15360,8701,8661,8151,15360,9452,9396,9015,15360,10581,10557,10380,15360,10950,10974,10846,15360,10380,10356,10252,15360,10749,10741,10685,15360,9870,9854,9693,15360,9023,9039,8669,15360,8790,8854,8509,15360,8196,8167,7332,15360,7975,8015,7079,15360,8589,8750,7445,15360,9095,9260,7111,15360,8983,9135,7188,15360,8902,8991,7252,15360,8862,9007,7015,15360,8967,9111,7300,15360,8742,8878,7493,15360,9557,9999,9549,15360,11292,11613,11862,15360,12135,12468,12982,15360,12215,12460,12878,15360,13356,13468,13685,15360,13821,13934,14199,15360,13548,13701,14022,15360,14103,14263,14468,15360,14279,14388,14572,15360,14364,14452,14645,15360,14709,14789,14950,15360,15143,15199,15327,15360,15388,15412,15468,15360,15476,15500,15548,15360,15420,15444,15492,15360,15436,15460,15516,15360,15612,15637,15685,15360,16086,16086,16110,15360,16396,16388,16396,15360,16094,16094,16110,15360,15869,15861,15861,15360,16135,16110,16070,15360,16428,16420,16404,15360,15588,15556,15524,15360,15484,15500,15508,15360,15335,15364,15396,15360,15677,15685,15717,15360,15604,15621,15661,15360,15420,15444,15500,15360,15303,15372,15452,15360,14717,14805,14998,15360,14412,14508,14701,15360,13548,13765,14199,15360,13271,13508,13942,15360,12661,13159,13709,15360,12468,12854,13436,15360,10260,10484,10509,15360,8613,8669,6951,15360,8151,8143,6469,15360,8653,8629,7814,15360,8469,8444,7541,15360,8718,8693,7814,15360,8372,8332,6597,15360,8356,8308,7111,15360,9047,8983,8396,15360,8822,8798,8308,15360,9372,9348,8967,15360,10364,10364,10183,15360,10268,10260,9894,15360,10541,10533,10468,15360,10380,10364,10276,15360,10621,10613,10549,15360,9910,9942,9758,15360,8364,8380,7621,15360,8581,8637,8135,15360,8252,8300,7573,15360,8119,8175,7300,15360,8372,8453,7493,15360,8420,8501,6983,15360,8742,8822,7573,15360,8782,8854,8151,15360,8581,8661,7079,15360,9220,9268,8340,15360,9549,9645,8854,15360,11717,11950,12127,15360,12468,12741,13207,15360,12709,12966,13388,15360,12300,12508,12886,15360,12492,12709,13063,15360,13239,13372,13548,15360,12476,12597,12814,15360,13581,13685,13878,15360,14476,14548,14685,15360,14556,14629,14773,15360,14765,14829,14966,15360,15159,15207,15303,15360,15372,15396,15444,15360,15516,15532,15572,15360,15653,15661,15693,15360,15829,15837,15853,15360,16022,16014,16022,15360,16311,16295,16279,15360,16343,16319,16303,15360,16412,16388,16359,15360,15813,15797,15773,15360,13063,13151,13183,15360,11484,11701,11798,15360,12300,12412,12468,15360,14613,14637,14653,15360,11974,12215,12316,15360,14135,14215,14303,15360,15604,15629,15677,15360,15524,15548,15596,15360,15351,15380,15428,15360,14797,14894,15054,15360,13990,14231,14500,15360,13492,13709,14070,15360,12886,13316,13701,15360,12613,13207,13749,15360,11525,11974,12428,15360,9284,9412,8629,15360,8597,8653,6951,15360,7806,7790,6292,15360,7589,7541,6437,15360,7485,7437,6597,15360,7453,7404,6180,15360,7774,7686,6565,15360,8300,8260,7332,15360,9918,9942,9862,15360,10348,10372,10231,15360,9725,9709,9228,15360,10613,10621,10509,15360,10199,10175,9838,15360,10380,10388,10340,15360,11207,11255,11284,15360,10661,10717,10725,15360,10103,10135,9950,15360,8444,8436,7669,15360,8469,8501,7445,15360,8950,9111,8854,15360,9485,9798,10071,15360,8364,8501,8039,15360,7959,7951,6806,15360,8597,8605,8039,15360,8501,8533,7557,15360,8758,8830,7509,15360,10758,10830,10693,15360,11508,11605,11621,15360,13524,13669,13886,15360,13830,14022,14327,15360,13926,14103,14364,15360,13460,13621,13886,15360,12854,13191,13420,15360,13597,13733,13926,15360,13846,13990,14223,15360,13773,13942,14199,15360,13910,14087,14356,15360,13813,14022,14319,15360,14247,14396,14540,15360,14693,14765,14878,15360,15223,15279,15343,15360,15508,15524,15540,15360,15540,15548,15564,15360,15327,15335,15319,15360,15303,15311,15303,15360,15918,15910,15886,15360,16247,16207,16151,15360,16175,16143,16086,15360,14436,14452,14436,15360,12263,12380,12404,15360,11476,11701,11773,15360,12380,12492,12532,15360,14797,14797,14757,15360,11372,11589,11677,15360,12597,12934,13356,15360,13990,14364,14725,15360,14183,14444,14773,15360,14231,14444,14717,15360,14412,14532,14709,15360,14054,14199,14380,15360,12372,12500,12605,15360,12199,12565,13006,15360,12581,13175,13653,15360,10055,10380,10324,15360,8557,8573,6726,15360,8167,8196,6533,15360,7517,7485,6119,15360,7244,7172,5798,15360,7071,6959,5718,15360,7669,7581,6260,15360,8661,8605,7975,15360,10942,11079,11151,15360,12573,12741,13014,15360,11902,12030,12191,15360,10308,10332,10135,15360,11255,11300,11284,15360,11276,11348,11396,15360,10055,10215,10292,15360,12183,12332,12468,15360,9918,9966,9798,15360,8734,8742,8196,15360,8967,8950,8469,15360,10260,10276,10039,15360,9734,9758,9605,15360,9388,9404,9308,15360,7943,7878,7095,15360,7726,7637,6645,15360,8047,7983,7204,15360,9284,9236,8693,15360,9621,9565,9143,15360,11255,11268,11047,15360,13175,13332,13420,15360,13773,13934,14175,15360,13854,14022,14271,15360,13870,14038,14279,15360,13388,13516,13677,15360,12279,12629,12966,15360,13348,13452,13564,15360,13821,13918,14054,15360,13701,13846,14022,15360,13460,13605,13781,15360,13492,13637,13821,15360,13709,13821,13950,15360,14372,14428,14476,15360,14516,14572,14613,15360,14741,14789,14813,15360,14725,14749,14749,15360,13452,13484,13468,15360,13476,13500,13492,15360,14990,15022,15022,15360,14556,14572,14564,15360,15094,15111,15094,15360,13231,13287,13215,15360,11255,11380,11175,15360,10677,10886,10492,15360,11846,12006,11934,15360,14327,14340,14279,15360,10766,11039,10862,15360,12918,13255,13452,15360,14231,14548,14886,15360,13878,14380,14765,15360,13444,13862,14412,15360,12151,12404,12621,15360,12637,12902,13215,15360,11549,11749,11870,15360,12279,12653,13119,15360,13223,13404,13516,15360,9228,9260,8276,15360,8087,7991,6308,15360,7918,7814,6919,15360,7469,7364,6148,15360,7485,7380,6212,15360,8228,7991,7204,15360,9276,8967,8212,15360,9806,9573,8742,15360,10135,10087,9621,15360,11452,11452,11452,15360,10629,10637,10509,15360,10693,10733,10637,15360,11095,11111,10982,15360,11292,11348,11372,15360,10199,10244,10167,15360,10814,10926,10846,15360,8669,8774,7493,15360,7870,7910,6244,15360,8204,8183,6919,15360,9806,9758,9159,15360,9460,9436,8629,15360,9159,9087,8260,15360,7637,7509,6790,15360,7758,7629,6838,15360,7967,7918,6774,15360,10854,10749,10501,15360,11508,11412,11316,15360,12372,12300,12151,15360,12030,12119,12063,15360,12781,12910,12982,15360,13476,13581,13661,15360,13484,13589,13677,15360,12404,12428,12380,15360,11605,11765,11798,15360,11492,11533,11452,15360,11838,11886,11798,15360,12263,12372,12380,15360,12151,12231,12175,15360,11492,11508,11412,15360,11119,11111,10838,15360,12508,12581,12573,15360,12621,12693,12677,15360,12573,12629,12589,15360,12292,12324,12231,15360,12476,12565,12573,15360,11998,12159,12215,15360,12950,13071,13159,15360,12263,12372,12428,15360,12380,12428,12444,15360,11300,11308,11143,15360,10199,10244,9734,15360,9709,9701,9252,15360,10492,10581,10404,15360,11476,11516,11388,15360,9477,9517,8790,15360,11717,11854,11838,15360,14247,14420,14524,15360,14054,14311,14436,15360,13597,13805,13982,15360,11364,11533,11597,15360,12263,12428,12549,15360,11436,11605,11653,15360,13079,13324,13444,15360,12516,12613,12605,15360,10039,10015,9605,15360,8693,8621,7878,15360,7951,7862,6902,15360,8196,8204,7015,15360,8677,8589,7637,15360,9284,9031,8340,15360,9814,9605,8902,15360,10685,10428,9910,15360,10492,10260,9685,15360,9404,9252,7943,15360,8830,8766,7220,15360,9220,9047,7943,15360,9693,9669,9015,15360,11412,11468,11372,15360,11135,11159,11023,15360,10087,10055,9428,15360,9910,10007,9621,15360,9236,9300,8934,15360,9597,9557,8902,15360,10669,10549,9782,15360,9926,9870,9127,15360,9894,9918,9047,15360,8685,8742,7910,15360,9958,10167,10284,15360,10215,10332,10396,15360,11396,11428,11452,15360,11223,11255,11300,15360,11814,11862,11958,15360,10685,10846,10870,15360,10340,10380,10007,15360,11175,11207,10894,15360,12103,12207,12215,15360,11143,11103,10902,15360,9910,9966,9613,15360,10015,10079,9493,15360,10806,10846,10517,15360,10862,10934,10637,15360,10838,10942,10661,15360,10958,11087,10878,15360,10709,10838,10701,15360,10669,10741,10589,15360,10581,10669,10525,15360,10252,10348,9974,15360,11396,11500,11525,15360,11207,11255,11264,15360,10878,10910,10934,15360,11031,11063,11159,15360,11292,11324,11396,15360,11223,11255,11300,15360,10693,10685,10645,15360,10428,10420,10324,15360,10300,10252,9991,15360,10838,10846,10798,15360,10428,10428,10364,15360,9669,9605,9380,15360,10167,10244,10087,15360,11709,11854,11910,15360,11223,11284,11268,15360,10231,10244,9878,15360,10199,10244,9862,15360,10183,10260,9942,15360,10525,10653,10541,15360,12500,12597,12621,15360,11814,11741,11597,15360,11533,11460,11175,15360,11103,11006,10557,15360,10444,10396,9846,15360,10007,10023,9228,15360,9653,9790,8469,15360,9316,9372,8039,15360,9557,9830,8071,15360,9621,9918,8071,15360,9677,10015,8167,15360,9991,10284,8420,15360,10215,10436,8581,15360,10260,10484,8645,15360,10292,10476,8902,15360,10324,10468,9252,15360,9910,9894,8886,15360,10525,10573,9701,15360,9782,10039,8581,15360,9565,9814,8167,15360,9950,10039,8934,15360,10749,10758,10199,15360,10669,10685,10244,15360,10838,10838,10460,15360,11215,10910,10087,15360,11492,11364,10806,15360,11095,11159,11055,15360,11364,11388,11356,15360,11023,11039,10990,15360,11653,11653,11613,15360,11798,11725,11557,15360,11974,11862,11637,15360,12039,11942,11765,15360,12119,12047,11934,15360,12151,12071,11950,15360,12087,12006,11886,15360,12047,11966,11838,15360,11990,11926,11790,15360,11974,11910,11798,15360,11998,11934,11814,15360,12111,12039,11886,15360,12231,12143,11998,15360,12292,12199,12039,15360,12039,11974,11846,15360,11822,11782,11653,15360,11862,11838,11765,15360,11798,11765,11701,15360,11782,11733,11669,15360,11798,11749,11685,15360,11838,11790,11725,15360,11870,11822,11749,15360,11741,11701,11621,15360,11565,11541,11452,15360,11533,11500,11412,15360,11621,11581,11484,15360,11605,11557,11460,15360,11516,11468,11372,15360,11565,11533,11444,15360,11677,11637,11541,15360,11725,11661,11557,15360,11725,11661,11557,15360,11733,11669,11573,15360,11838,11773,11677,15360,11998,11926,11814,15360,12014,11926,11798,15360,11460,11404,11332,15360,11637,11557,11428,15360,12014,11894,11693,15360,12167,12022,11765,15360,12119,11982,11709,15360,11926,11806,11516,15360,11685,11589,11300,15360,11476,11404,10886,15360,11239,11151,10468,15360,10766,10733,9894,15360,10565,10565,9589,15360,10436,10444,9332,15360,10308,10308,9031,15360,10308,10316,8999,15360,10199,10244,8774,15360,9725,9645,8549,15360,10244,10276,8967,15360,10878,10838,10183,15360,11055,10966,10348,15360,11119,11006,10404,15360,11264,11135,10565,15360,11404,11316,10822,15360,11492,11388,10982,15360,11798,11613,11223,15360,12047,11830,11412,15360,12039,11894,11597,15360,12127,11990,11693,15360,12127,11990,11725,15360,12191,12055,11806,15360,12191,12055,11830,15360,11870,11773,11613,15360,11573,11516,11428,15360,11533,11484,11412,15360,11541,11492,11420,15360,11565,11516,11452,15360,11589,11541,11476,15360,11605,11557,11500,15360,11637,11589,11533,15360,11669,11621,11557,15360,11701,11645,11573,15360,11733,11669,11589,15360,11798,11717,11605,15360,11838,11749,11621,15360,11878,11782,11661,15360,11894,11798,11661,15360,11926,11806,11653,15360,11958,11822,11661,15360,11982,11846,11677,15360,12006,11870,11685,15360,12095,11950,11765,15360,12047,11910,11741,15360,11886,11765,11605,15360,11838,11733,11589,15360,11814,11717,11589,15360,11814,11709,11573,15360,11790,11693,11565,15360,11741,11677,11589,15360,11733,11677,11613,15360,11733,11685,11629,15360,11717,11669,11621,15360,11685,11645,11589,15360,11629,11589,11533,15360,11573,11525,11468,15360,11492,11444,11380,15360,11316,11255,11111,15360,11348,11292,11143,15360,11516,11436,11316,15360,11854,11749,11589,15360,12127,11990,11765,15360,12199,12055,11782,15360,12340,12231,11910,15360,12372,12292,11958,15360,12380,12300,11974,15360,12348,12247,11910,15360,12324,12215,11878,15360,12247,12103,11773,15360,12095,11958,11637,15360,12055,11926,11613,15360,11974,11854,11541,15360,11870,11765,11468,15360,11966,11854,11541,15360,12300,12151,11846,15360,12396,12316,12006,15360,12388,12308,11990,15360,12388,12308,12006,15360,12396,12316,12022,15360,12396,12308,12022,15360,12396,12308,12022,15360,12364,12279,11974,15360,12340,12247,11942,15360,12340,12231,11926,15360,12215,12071,11806,15360,12095,11966,11749,15360,11741,11645,11500,15360,11420,11356,11255,15360,11364,11308,11207,15360,11356,11300,11175,15360,11348,11292,11191,15360,11372,11324,11255,15360,11412,11364,11308,15360,11420,11372,11316,15360,11428,11380,11324,15360,11444,11388,11332,15360,11484,11428,11364,15360,11508,11460,11396,15360,11557,11500,11436,15360,11589,11533,11460,15360,11613,11557,11484,15360,11621,11557,11492,15360,11613,11557,11500,15360,11621,11557,11500,15360,11629,11573,11508,15360,11629,11573,11508,15360,11605,11557,11484,15360,11589,11533,11468,15360,11557,11508,11436,15360,11549,11500,11428,15360,11557,11500,11436,15360,11549,11492,11436,15360,11533,11484,11428,15360,11525,11476,11428,15360,11516,11476,11428,15360,11525,11484,11444,15360,11516,11476,11428,15360,11468,11428,11380,15360,11428,11388,11332,15360,11356,11308,11239,15360,11308,11255,11127,15360,11167,11071,10926,15360,11223,11119,10966,15360,11276,11175,10998,15360,11404,11332,11191,15360,11773,11693,11557,15360,11926,11798,11613,15360,12207,12039,11773,15360,12348,12231,11894,15360,12308,12151,11846,15360,12332,12215,11894,15360,12364,12279,11958,15360,12380,12292,11974,15360,12396,12316,12022,15360,12404,12316,12039,15360,12412,12332,12087,15360,12412,12332,12103,15360,12436,12356,12135,15360,12372,12292,12039,15360,12420,12332,12087,15360,12396,12316,12055,15360,12356,12263,11990,15360,12340,12231,11942,15360,12271,12127,11854,15360,12215,12071,11814,15360,12292,12135,11878,15360,12288,12135,11870,15360,12111,11982,11765,15360,11990,11886,11717,15360,11637,11557,11428,15360,11364,11300,11143,15360,11316,11239,11079,15360,11300,11207,11047,15360,11268,11159,11015,15360,11268,11159,11015,15360,11268,11159,11031,15360,11300,11223,11095,15360,11340,11292,11191,15360,11348,11300,11223,15360,11372,11324,11255,15360,11380,11332,11255,15360,11372,11316,11239,15360,11396,11340,11268,15360,11468,11404,11300,15360,11460,11404,11324,15360,11484,11428,11356,15360,11492,11436,11372,15360,11500,11444,11388,15360,11508,11460,11404,15360,11500,11452,11396,15360,11492,11436,11380,15360,11468,11412,11356,15360,11444,11388,11324,15360,11444,11388,11324,15360,11428,11380,11316,15360,11412,11356,11300,15360,11404,11348,11300,15360,11404,11356,11308,15360,11396,11356,11308,15360,11388,11348,11308,15360,11372,11340,11292,15360,11348,11308,11255,15360,11284,11223,11111,15360,11231,11143,11023,15360,11199,11111,10974,15360,11047,10958,10814,15360,11127,11023,10870,15360,11119,11006,10846,15360,11175,11055,10886,15360,11292,11191,10998,15360,11525,11404,11284,15360,11822,11637,11476,15360,11878,11733,11549,15360,11918,11790,11573,15360,12063,11918,11653,15360,12223,12063,11765,15360,12300,12151,11846,15360,12255,12103,11814,15360,12271,12127,11846,15360,12271,12127,11862,15360,12271,12127,11886,15360,12308,12183,11942,15360,12175,12039,11814,15360,12063,11934,11709,15360,12159,12014,11765,15360,12215,12063,11798,15360,12143,11998,11757,15360,12071,11934,11693,15360,11998,11870,11661,15360,11974,11870,11685,15360,11998,11910,11757,15360,11846,11765,11629,15360,11468,11396,11284,15360,11308,11223,11031,15360,11215,11103,10934,15360,11207,11095,10942,15360,11215,11103,10950,15360,11191,11087,10942,15360,11175,11079,10942,15360,11167,11063,10934,15360,11143,11031,10902,15360,11247,11143,11015,15360,11284,11191,11079,15360,11300,11223,11095,15360,11316,11268,11127,15360,11340,11284,11143,15360,11340,11284,11159,15360,11356,11300,11191,15360,11372,11316,11239,15360,11380,11324,11255,15360,11372,11316,11255,15360,11380,11324,11276,15360,11380,11324,11268,15360,11372,11316,11255,15360,11364,11316,11255,15360,11364,11308,11239,15360,11348,11292,11207,15360,11340,11284,11191,15360,11348,11292,11191,15360,11348,11292,11207,15360,11340,11292,11207,15360,11340,11292,11207,15360,11324,11276,11207,15360,11308,11255,11175,15360,11264,11175,11079,15360,11119,11039,10934,15360,11103,11015,10902,15360,11095,11006,10878,15360,11031,10942,10806,15360,10990,10902,10766,15360,11047,10942,10814,15360,11031,10926,10790,15360,11055,10942,10806,15360,11119,10998,10846,15360,11151,11015,10830,15360,11268,11095,10886,15360,11484,11396,11268,15360,11790,11701,11549,15360,11886,11790,11637,15360,11838,11741,11581,15360,11838,11725,11541,15360,11902,11782,11581,15360,11966,11838,11629,15360,11974,11846,11629,15360,11958,11838,11629,15360,11950,11838,11637,15360,11814,11701,11525,15360,11581,11492,11332,15360,11645,11541,11380,15360,11806,11701,11533,15360,11902,11806,11637,15360,11950,11862,11717,15360,12014,11934,11790,15360,11942,11862,11725,15360,11565,11492,11388,15360,11292,11191,11015,15360,11231,11111,10950,15360,11159,11047,10894,15360,11119,11006,10854,15360,11127,11023,10878,15360,11159,11055,10902,15360,11135,11031,10894,15360,11111,11006,10878,15360,11095,10990,10870,15360,11095,10998,10886,15360,11071,10966,10846,15360,11111,11006,10902,15360,11191,11095,10974,15360,11268,11159,11031,15360,11284,11191,11063,15360,11292,11207,11063,15360,11300,11223,11079,15360,11332,11268,11143,15360,11316,11255,11127,15360,11316,11255,11143,15360,11308,11239,11127,15360,11316,11255,11159,15360,11300,11223,11127,15360,11292,11207,11095,15360,11300,11223,11111,15360,11300,11223,11095,15360,11300,11223,11095,15360,11308,11239,11111,15360,11300,11223,11111,15360,11292,11207,11111,15360,11264,11167,11071,15360,11215,11127,11047,15360,11135,11055,10966,15360,11015,10934,10846,15360,10918,10838,10733,15360,10982,10894,10782,15360,10974,10886,10766,15360,10982,10894,10766,15360,10958,10862,10749,15360,10982,10886,10774,15360,10958,10862,10758,15360,10958,10862,10749,15360,11015,10910,10790,15360,11023,10910,10774,15360,11079,10958,10806,15360,11103,10974,10798,15360,11191,11047,10846,15360,11468,11388,11276,15360,11846,11765,11637,15360,12006,11918,11782,15360,11998,11910,11782,15360,11902,11822,11693,15360,11838,11749,11637,15360,11782,11709,11605,15360,11806,11741,11645,15360,11782,11717,11629,15360,11773,11717,11621,15360,11870,11806,11701,15360,11942,11862,11757,15360,12183,12103,11974,15360,11974,11894,11765,15360,11476,11404,11308,15360,11268,11143,10966,15360,11183,11063,10902,15360,11111,10998,10854,15360,11055,10942,10806,15360,11023,10910,10766,15360,11047,10934,10782,15360,11039,10926,10782,15360,11079,10966,10830,15360,11031,10918,10782,15360,11031,10926,10806,15360,10990,10894,10782,15360,10974,10886,10790,15360,10966,10870,10774,15360,11006,10902,10806,15360,11039,10942,10838,15360,11127,11023,10910,15360,11175,11079,10958,15360,11191,11087,10958,15360,11207,11095,10958,15360,11268,11143,11015,15360,11276,11175,11047,15360,11284,11191,11079,15360,11292,11191,11079,15360,11276,11175,11079,15360,11239,11135,11031,15360,11268,11159,11047,15360,11215,11111,11006,15360,11239,11127,11015,15360,11255,11143,11031,15360,11223,11119,11015,15360,11199,11103,10998,15360,11175,11087,10982,15360,11143,11047,10958,15360,11031,10942,10854,15360,10958,10878,10790,15360,10910,10830,10741,15360,10942,10862,10758,15360,10926,10838,10733,15360,10854,10758,10637,15360,10918,10830,10709,15360,10910,10822,10717,15360,10942,10846,10749,15360,10942,10854,10741,15360,10942,10854,10749,15360,10966,10870,10758,15360,10966,10870,10758,15360,10958,10854,10733,15360,10998,10886,10741,15360,10942,10830,10677,15360,11039,10918,10749,15360,11095,10974,10806,15360,11308,11223,11031,15360,11468,11396,11292,15360,11605,11533,11428,15360,11701,11621,11525,15360,11693,11629,11541,15360,11685,11621,11549,15360,11685,11629,11549,15360,11629,11565,11484,15360,11589,11533,11444,15360,11364,11308,11191,15360,11191,11087,10958,15360,11135,11031,10902,15360,11135,11031,10894,15360,11055,10950,10830,15360,11015,10910,10782,15360,10958,10854,10733,15360,10942,10838,10717,15360,10974,10870,10733,15360,10982,10878,10749,15360,10990,10886,10758,15360,11015,10910,10798,15360,10966,10862,10758,15360,10950,10854,10758,15360,10910,10822,10733,15360,10894,10798,10709,15360,10902,10814,10725,15360,10934,10846,10758,15360,10910,10822,10733,15360,10950,10854,10749,15360,10974,10878,10766,15360,11047,10942,10830,15360,11095,10990,10878,15360,11167,11055,10942,15360,11199,11103,10990,15360,11191,11087,10982,15360,11151,11047,10950,15360,11135,11031,10934,15360,11095,10998,10902,15360,11143,11047,10950,15360,11079,10990,10894,15360,11079,10990,10902,15360,11103,11006,10910,15360,11079,10982,10886,15360,11023,10926,10822,15360,10982,10894,10798,15360,10958,10870,10782,15360,10910,10814,10725,15360,10926,10838,10741,15360,10934,10838,10733,15360,10950,10854,10749,15360,10886,10798,10709,15360,10910,10814,10709,15360,10926,10830,10725,15360,10910,10814,10701,15360,10862,10774,10677,15360,10950,10854,10733,15360,10926,10830,10717,15360,10926,10838,10725,15360,10926,10830,10725,15360,10894,10798,10685,15360,10926,10830,10701,15360,10958,10854,10717,15360,10934,10830,10685,15360,10950,10846,10709,15360,10974,10862,10717,15360,10942,10830,10685,15360,10958,10846,10701,15360,11006,10894,10749,15360,10950,10846,10725,15360,10958,10862,10741,15360,10894,10806,10701,15360,10854,10774,10669,15360,10886,10806,10701,15360,10862,10790,10693,15360,10878,10806,10717,15360,10982,10902,10798,15360,10990,10902,10798,15360,10950,10862,10758,15360,10942,10846,10733,15360,10870,10774,10669,15360,10894,10798,10693,15360,10918,10830,10725,15360,10894,10806,10701,15360,10926,10830,10733,15360,10902,10830,10725,15360,10870,10790,10693,15360,10886,10814,10725,15360,10814,10741,10661,15360,10838,10766,10677,15360,10822,10741,10661,15360,10822,10741,10669,15360,10862,10790,10709,15360,10846,10758,10669,15360,10894,10798,10693,15360,10974,10878,10766,15360,10966,10870,10766,15360,11023,10926,10814,15360,11079,10974,10862,15360,11006,10910,10814,15360,10950,10862,10766,15360,10982,10894,10798,15360,10958,10862,10774,15360,10958,10870,10782,15360,10910,10830,10741,15360,10950,10862,10766,15360,10982,10886,10790,15360,10918,10822,10725,15360,10886,10798,10701,15360,10854,10766,10669,15360,10894,10806,10709,15360,10926,10830,10725,15360,10926,10830,10725,15360,10958,10862,10749,15360,10958,10862,10749,15360,10894,10806,10717,15360,10902,10814,10717,15360,10878,10790,10677,15360,10942,10838,10717,15360,10918,10814,10701,15360,10886,10790,10661,15360,10942,10838,10717,15360,10950,10854,10725,15360,10950,10854,10725,15360,10910,10814,10693,15360,10910,10814,10685,15360,10942,10838,10709,15360,10894,10790,10661,15360,10910,10806,10669,15360,10822,10725,10597,15360,10749,10661,10541,15360,10830,10733,10613,15360,10838,10741,10629,15360,10806,10709,10597,15360,10854,10766,10653,15360,10862,10774,10669,15360,10798,10725,10629,15360,10822,10749,10653,15360,10854,10782,10693,15360,10806,10741,10661,15360,10862,10790,10701,15360,10870,10790,10685,15360,10870,10790,10693,15360,10878,10790,10677,15360,10862,10782,10677,15360,10870,10790,10693,15360,10870,10782,10685,15360,10894,10814,10709,15360,10886,10814,10709,15360,10846,10782,10685,15360,10741,10669,10573,15360,10766,10693,10589,15360,10709,10637,10541,15360,10741,10669,10589,15360,10741,10677,10589,15360,10709,10637,10557,15360,10774,10701,10613,15360,10862,10774,10677,15360,11006,10918,10806,15360,11006,10902,10782,15360,10974,10870,10749,15360,10958,10854,10733,15360,10934,10838,10725,15360,10934,10838,10733,15360,10934,10838,10725,15360,10886,10790,10685,15360,10854,10766,10661,15360,10886,10798,10701,15360,10838,10749,10645,15360,10878,10782,10661,15360,10822,10725,10613,15360,10822,10717,10605,15360,10846,10749,10629,15360,10854,10749,10637,15360,10950,10854,10733,15360,10958,10854,10741,15360,10910,10806,10693,15360,10926,10822,10693,15360,10934,10838,10725,15360,10910,10822,10709,15360,10910,10822,10709,15360,10886,10782,10661,15360,10910,10814,10677,15360,10910,10806,10677,15360,10926,10822,10685,15360,10958,10854,10717,15360,10974,10870,10725,15360,10926,10830,10693,15360,10926,10830,10693,15360,10918,10822,10693,15360,10934,10838,10701,15360,10918,10814,10685,15360,10878,10782,10653,15360,10870,10774,10645,15360,10838,10749,10629,15360,10806,10717,10605,15360,10822,10733,10621,15360,10822,10733,10621,15360,10846,10758,10653,15360,10846,10766,10653,15360,10822,10741,10629,15360,10806,10733,10629,15360,10806,10725,10621,15360,10790,10709,10605,15360,10766,10693,10589,15360,10814,10741,10629,15360,10846,10766,10653,15360,10838,10758,10653,15360,10878,10790,10677,15360,10894,10798,10685,15360,10830,10741,10629,15360,10830,10758,10653,15360,10798,10725,10629,15360,10806,10733,10629,15360,10717,10637,10525,15360,10661,10581,10476,15360,10701,10621,10517,15360,10733,10661,10565,15360,10782,10685,10557,15360,10862,10758,10613,15360,10974,10862,10725,15360,10958,10846,10709,15360,11006,10902,10766,15360,11006,10902,10774,15360,11039,10934,10814,15360,11006,10902,10790,15360,11006,10910,10790,15360,10950,10854,10741,15360,10934,10830,10709,15360,10918,10814,10701,15360,10854,10758,10653,15360,10918,10814,10701,15360,10870,10766,10645,15360,10830,10733,10621,15360,10934,10830,10709,15360,10990,10886,10758,15360,10950,10838,10717,15360,10910,10814,10701,15360,10926,10822,10693,15360,10934,10830,10709,15360,10878,10774,10653,15360,10934,10830,10701,15360,10926,10822,10693,15360,10878,10782,10661,15360,10878,10782,10661,15360,10862,10766,10621,15360,10886,10782,10645,15360,10886,10782,10653,15360,10926,10822,10701,15360,10902,10806,10685,15360,10926,10822,10701,15360,10918,10814,10685,15360,10878,10782,10645,15360,10910,10806,10669,15360,10854,10758,10621,15360,10886,10790,10645,15360,10854,10758,10629,15360,10830,10741,10613,15360,10918,10814,10685,15360,10862,10766,10645,15360,10830,10741,10613,15360,10806,10717,10597,15360,10741,10661,10557,15360,10774,10693,10581,15360,10749,10669,10557,15360,10774,10693,10581,15360,10766,10685,10573,15360,10790,10709,10597,15360,10782,10701,10589,15360,10790,10709,10597,15360,10838,10749,10621,15360,10870,10774,10645,15360,10894,10790,10661,15360,10878,10782,10653,15360,10846,10741,10613,15360,10790,10693,10557,15360,10814,10717,10597,15360,10790,10701,10581,15360,10741,10645,10525,15360,10717,10629,10509,15360,10774,10685,10573,15360,10725,10637,10525,15360,10854,10749,10621,15360,10950,10846,10701,15360,10966,10854,10709,15360,10934,10814,10677,15360,10926,10822,10701,15360,10982,10878,10766,15360,10998,10894,10782,15360,10990,10878,10766,15360,10998,10894,10782,15360,10998,10886,10774,15360,10998,10886,10758,15360,11006,10894,10774,15360,10942,10838,10733,15360,10958,10854,10741,15360,10958,10854,10749,15360,11006,10902,10790,15360,11015,10902,10798,15360,10982,10870,10758,15360,10998,10894,10782,15360,10974,10870,10758,15360,11006,10902,10790,15360,10998,10894,10774,15360,10974,10870,10758,15360,10950,10854,10741,15360,10878,10790,10693,15360,10902,10814,10701,15360,10918,10822,10709,15360,10838,10733,10613,15360,10878,10782,10661,15360,10934,10838,10717,15360,10902,10806,10693,15360,10918,10822,10709,15360,10926,10830,10709,15360,10838,10733,10605,15360,10910,10806,10661,15360,10942,10838,10693,15360,10886,10782,10645,15360,10886,10782,10637,15360,10854,10749,10621,15360,10926,10830,10709,15360,10966,10862,10741,15360,10846,10749,10629,15360,10830,10733,10605,15360,10854,10758,10637,15360,10822,10725,10605,15360,10886,10790,10661,15360,10902,10806,10669,15360,10918,10814,10677,15360,10830,10733,10605,15360,10806,10717,10589,15360,10870,10774,10645,15360,10934,10838,10709,15360,10958,10862,10733,15360,10886,10790,10661,15360,10894,10798,10661,15360,10958,10854,10709,15360,10934,10830,10709,15360,10814,10717,10581,15360,10862,10758,10613,15360,10854,10741,10589,15360,10814,10717,10573,15360,10886,10782,10645,15360,10814,10725,10597,15360,10862,10766,10637,15360,10910,10806,10669,15360,10942,10838,10709,15360,10966,10862,10733,15360,10974,10870,10741,15360,10974,10870,10749,15360,10958,10862,10749,15360,11031,10934,10822,15360,10998,10894,10782,15360,10974,10870,10766,15360,11023,10918,10814,15360,11039,10926,10822,15360,10958,10846,10741,15360,10918,10814,10693,15360,10966,10870,10741,15360,10982,10886,10766,15360,10982,10878,10766,15360,10942,10846,10733,15360,10958,10862,10758,15360,10950,10854,10758,15360,10934,10830,10717,15360,10966,10862,10733,15360,10942,10846,10725,15360,10934,10846,10733,15360,10934,10846,10733,15360,10878,10798,10693,15360,10886,10798,10693,15360,10910,10814,10709,15360,10942,10846,10733,15360,10838,10733,10597,15360,10878,10774,10645,15360,10918,10822,10701,15360,10878,10782,10653,15360,10894,10790,10661,15360,10934,10838,10725,15360,10958,10854,10725,15360,10966,10862,10733,15360,10910,10806,10685,15360,10982,10878,10758,15360,10942,10854,10749,15360,10934,10838,10733,15360,10918,10814,10701,15360,10894,10798,10669,15360,10894,10798,10669,15360,10814,10725,10605,15360,10902,10798,10669,15360,10814,10725,10605,15360,10894,10798,10685,15360,10958,10862,10749,15360,10910,10814,10701,15360,10910,10806,10685,15360,10918,10814,10693,15360,10926,10822,10709,15360,10894,10790,10661,15360,10902,10806,10677,15360,10902,10806,10685,15360,10934,10838,10717,15360,10934,10838,10701,15360,10934,10838,10717,15360,10950,10854,10725,15360,10894,10798,10661,15360,10862,10749,10597,15360,10894,10798,10677,15360,10878,10782,10661,15360,10926,10838,10717,15360,10926,10838,10717,15360,10918,10822,10709,15360,10934,10838,10733,15360,10926,10838,10733,15360,10958,10870,10766,15360,10942,10854,10749,15360,10958,10870,10774,15360,10974,10878,10774,15360,10958,10854,10741,15360,10950,10846,10741,15360,10950,10854,10758,15360,10934,10838,10733,15360,10942,10846,10725,15360,10966,10862,10741,15360,10926,10838,10733,15360,10958,10862,10749,15360,10910,10822,10709,15360,10942,10854,10758,15360,10926,10838,10733,15360,10910,10822,10717,15360,10934,10838,10733,15360,10934,10846,10733,15360,10902,10814,10709,15360,10926,10830,10717,15360,10918,10822,10709,15360,10838,10749,10637,15360,10878,10790,10677,15360,10942,10846,10733,15360,10926,10822,10701,15360,10958,10862,10749,15360,10886,10790,10685,15360,10918,10814,10693,15360,10910,10814,10693,15360,10902,10806,10701,15360,10878,10774,10637,15360,10798,10693,10565,15360,10822,10725,10597,15360,10934,10838,10709,15360,10958,10854,10725,15360,10886,10790,10669,15360,10910,10806,10677,15360,10886,10782,10645,15360,10830,10725,10597,15360,10822,10717,10581,15360,10862,10758,10637,15360,10878,10782,10669,15360,10926,10822,10709,15360,10974,10878,10774,15360,10966,10870,10758,15360,10918,10822,10709,15360,10846,10749,10645,15360,10894,10798,10693,15360,10918,10822,10709,15360,10974,10878,10774,15360,10918,10822,10717,15360,10982,10886,10774,15360,10974,10878,10758,15360,10950,10854,10741,15360,10958,10854,10725,15360,10982,10886,10766,15360,10918,10822,10701,15360,10878,10782,10669,15360,10886,10790,10669,15360,10934,10838,10717,15360,10950,10854,10741,15360,10934,10838,10733,15360,10982,10886,10782,15360,10886,10798,10701,15360,10870,10782,10685,15360,10894,10814,10717,15360,10910,10822,10725,15360,10934,10838,10733,15360,10950,10846,10741,15360,10934,10838,10725,15360,10934,10846,10749,15360,10902,10814,10717,15360,10878,10790,10677,15360,10878,10782,10669,15360,10854,10766,10645,15360,10838,10749,10629,15360,10902,10814,10701,15360,10910,10814,10693,15360,10902,10798,10669,15360,10910,10806,10677,15360,10886,10782,10653,15360,10854,10749,10629,15360,10870,10774,10653,15360,10974,10870,10758,15360,10990,10878,10758,15360,10918,10822,10709,15360,10926,10838,10725,15360,10958,10854,10733,15360,10894,10790,10653,15360,10822,10725,10605,15360,10878,10782,10661,15360,10974,10870,10749,15360,10902,10806,10677,15360,10934,10838,10725,15360,10870,10774,10653,15360,10798,10701,10581,15360,10854,10749,10621,15360,10894,10798,10669,15360,10934,10822,10685,15360,10942,10830,10701,15360,10910,10806,10669,15360,10870,10758,10629,15360,10886,10774,10645,15360,10950,10838,10701,15360,10966,10870,10749,15360,10886,10790,10685,15360,10870,10782,10677,15360,10934,10838,10733,15360,10934,10838,10725,15360,10822,10725,10621,15360,10878,10790,10677,15360,10894,10798,10693,15360,10822,10733,10629,15360,10894,10798,10685,15360,10998,10902,10790,15360,11015,10918,10806,15360,10950,10854,10741,15360,10950,10846,10741,15360,10934,10838,10733,15360,10942,10846,10749,15360,10910,10822,10725,15360,10846,10758,10653,15360,10878,10790,10685,15360,10894,10798,10701,15360,10862,10774,10669,15360,10814,10725,10621,15360,10846,10758,10645,15360,10870,10774,10661,15360,10870,10774,10677,15360,10878,10790,10693,15360,10878,10782,10677,15360,10830,10741,10637,15360,10870,10782,10677,15360,10966,10870,10766,15360,11015,10918,10814,15360,10910,10814,10701,15360,10942,10846,10725,15360,10950,10846,10725,15360,10942,10838,10725,15360,10934,10830,10701,15360,10910,10798,10677,15360,10886,10782,10653,15360,10838,10733,10597,15360,10902,10806,10669,15360,10830,10733,10613,15360,10838,10741,10621,15360,10838,10741,10621,15360,10894,10798,10669,15360,10934,10830,10685,15360,10886,10790,10669,15360,10902,10806,10685,15360,10854,10749,10637,15360]);var Yce={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:lit()},cit={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},$ce=e=>2===e?"\xb2":3===e?"\xb3":"",By=(e,t=1)=>cit[e]+$ce(t),sMt=(e,t,n,i=1)=>(null==n&&(n=t),n===t?{value:e,unit:By(n)}:{value:e*Math.pow(Yce[t]/Yce[n],i),unit:By(n)+$ce(i)}),XF=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(XF||{}),Ws=class{static getCameraPositionByBboxAndView(e,t,n,i,r){let a=Ws.getCameraDirectionByView(t);return this.getCameraPositionByBboxAndDirection(e,n,i,r,a)}static getCameraPositionByBboxAndDirection(e,t,n,i,r){if(e.isEmpty()||!i)return;let a=new M,s=new M,o=new M(0,1,0);e.getSize(s),e.getCenter(a);let l,h,c=(s.x+s.y+s.z)/3*1.5;if(!r||null!=r&&r.equals(new M))l=new M(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new M(c,c/1.5,c).length();h=new M(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new Ae;u.lookAt(l,a,o);let d=new Ae;d.makeTranslation(-l.x,-l.y,-l.z);let p=e.clone().applyMatrix4(d).applyMatrix4(u.invert()).applyMatrix4(i),f=Math.max(Math.abs(p.max.x),Math.abs(p.min.x)),m=Math.max(Math.abs(p.max.y),Math.abs(p.min.y));c*=1.1*Math.sqrt(Math.pow(f,2)+Math.pow(m,2)),l=h.multiplyScalar(c).add(a),n.set(a.x,a.y,a.z),t.set(l.x,l.y,l.z)}static getCameraDirectionByView(e){let t=new M(1,0,0);return"Top"===e?t.set(0,-1,0):"Bottom"===e?t.set(0,1,0):"Front"===e?t.set(0,0,-1):"Back"===e?t.set(0,0,1):"Left"===e?t.set(1,0,0):"Right"===e&&t.set(-1,0,0),t}},uit=!1,ns=class extends Xi{constructor(e){super(),this.DEFAULT_LINE_WIDTH=1,this.DEFAULT_STROKE_STYLE="#000000",this.DEFAULT_FILL_STYLE="#000000",this.lineWidth=this.DEFAULT_LINE_WIDTH,this.lineColor=this.DEFAULT_STROKE_STYLE,this.fillColor=this.DEFAULT_FILL_STYLE,this.x=0,this.y=0,this.width=0,this.height=0,this.points=[],this.userData={},this.tolerance=1,this.visible=!0,this.selected=!1,this.renderOrder=1,this.needsFrustumCulled=!0,this.editPointSize=3,this.editPointColor="#ffffff",this.matrix=new Ae,this.id=e||it.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),uit&&(this.drawBounds(e,t),this.drawCenter(e,t))}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.getClassType()}}setData(e){this.id=e.id,this.setLineWidth(e.lineWidth),this.setLineColor(e.lineColor),this.setFillColor(e.fillColor)}getVertexes(){return[new M(this.x,this.y,0),new M(this.x+this.width,this.y,0),new M(this.x+this.width,this.y-this.height,0),new M(this.x,this.y-this.height,0)]}setLineWidth(e){this.lineWidth=e||this.DEFAULT_LINE_WIDTH}setLineColor(e){this.lineColor=e||this.DEFAULT_STROKE_STYLE}setFillColor(e){this.fillColor=e||this.DEFAULT_FILL_STYLE}isSelected(){return this.selected}getCenter(){return this.getBounds().getCenter(new M)}transToScreenCoord(e,t){return this.ctx?nn.worldPosition2ScreenPoint(e,t,this.ctx.canvas):new Q}drawBounds(e,t){let{min:n,max:i}=this.getBounds(),r=[],a=(e,t,n)=>r.push(new M(e,t,n));a(i.x,i.y,i.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,i.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,i.y,n.z),a(i.x,i.y,i.z),a(i.x,i.y,n.z),a(n.x,n.y,i.z),a(n.x,n.y,n.z),a(i.x,n.y,i.z),a(i.x,n.y,n.z),e.save(),e.strokeStyle="yellow",e.beginPath(),r.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);i%2==0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}drawCenter(e,t){let n=this.transToScreenCoord(this.getCenter(),t);e.save(),e.fillStyle="yellow",e.beginPath(),e.arc(n.x,n.y,5,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}getBounds(){let e=this.getVertexes();return(new lt).setFromPoints(e)}},Ja=(e=>(e.MouseClicked="MouseClicked",e.LayoutChanged="LayoutChanged",e.ModelLoaded="ModelLoaded",e.AfterRender="AfterRender",e.CameraChanged="CameraChanged",e.BoxSelectActivated="BoxSelectActivated",e.BoxSelectDeactivated="BoxSelectDeactivated",e.PickMarkupActivated="PickMarkupActivated",e.PickMarkupDeactivated="PickMarkupDeactivated",e.MarkupActivated="MarkupActivated",e.MarkupDeactivated="MarkupDeactivated",e.MarkupAdded="MarkupAdded",e.MarkupUpdated="MarkupUpdated",e.MarkupRemoved="MarkupRemoved",e.BeforeRemoveMarkup="BeforeRemoveMarkup",e.MeasurementActivated="MeasurementActivated",e.MeasurementDeactivated="MeasurementDeactivated",e.MeasurementAdded="MeasurementAdded",e.MeasurementRemoved="MeasurementRemoved",e))(Ja||{}),Zce={},$t=class extends Xi{constructor(e){super(),this.drawableLists=[],this.frustum=new ps,this.projScreenMatrix=new Ae,this.viewer=e,this.init()}static _registerDrawableClass(e){Zce[e.prototype.getClassType()]=e}static createDrawable(e){let t=Zce[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let n=e.points.map((e=>new M(e[0],e[1],e[2]||0))),i=new t(e.id,n);return i.setData(e),i}get container(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}init(){this.initCanvas(),this.viewer.addEventListener("AfterRender",(()=>{this.projScreenMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projScreenMatrix),this.render()}))}initCanvas(){let e=this.viewer.getViewConfig();if(tn.isBrowser&&!e.context2d){let e=this.canvas=document.createElement("canvas"),t=this.viewer.viewerContainer;t.appendChild(e),e.classList.add("overlay-renderer"),e.style.pointerEvents="none",e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.userSelect="none",this.context=e.getContext("2d",{willReadFrequently:!0});let{clientWidth:n,clientHeight:i}=t;this.setSize(n,i)}else e.context2d&&(this.context=e.context2d,this.canvas=tn.creatReactNativeCanvas(this.context),this.context.canvas||(this.context.canvas=this.canvas))}toHighDpr(e,t,n){let i=Math.max(window.devicePixelRatio||1,1),r=this.canvas;return r.width=t*i,r.height=n*i,e.scale(i,i),r.style.width=`${t}px`,r.style.height=`${n}px`,e}clearCanvas(){var e,t,n;null==(n=this.context)||n.clearRect(0,0,null==(e=this.canvas)?void 0:e.width,null==(t=this.canvas)?void 0:t.height)}addDrawableList(e){this.drawableLists.push(e)}render(){if(!this.canvas||!this.context||this.drawableLists.length<1)return;this.clearCanvas();let e=this.getSortedDrawables(),t=new hr;for(let n=0;n<e.length;n++){let i=e[n];i.setTolerance(this.viewer.getPixelSizeInWorldCoord()),i.visible&&(i.getBounds().getBoundingSphere(t),!i.needsFrustumCulled||this.frustum.intersectsSphere(t))&&i.render(this.context,this.camera)}}setSize(e,t){let n=this.canvas;n.width=e,n.height=t,n.style.width=`${e}px`,n.style.height=`${t}px`,this.toHighDpr(this.context,e,t)}getSortedDrawables(){let e=[];return this.drawableLists.forEach((t=>{e.push(...Array.from(t.getDrawables().values()))})),e.sort(((e,t)=>e.renderOrder===t.renderOrder?t.getCenter().distanceTo(this.camera.position)-e.getCenter().distanceTo(this.camera.position):e.renderOrder-t.renderOrder)),e}getDrawablesByPosition(e,t){let n=this.getSortedDrawables(),i=[];for(let r=0;r<n.length;r++){let a=n[r];a.isPointInPath(e,t)&&i.push(a)}return i}getDrawableById(e){return this.getSortedDrawables().find((t=>t.id===e))}measureTextLength(e,t){let n=this.context,i=e.split("\n"),r=0;for(let a=0;a<i.length;a++){let e=i[a];n.save(),n.font=t;let s=n.measureText(e).width;n.restore(),r=Math.max(r,s)}return r}screenshot(){return $e(this,arguments,(function*(e={type:"image/png",quality:.8}){var t,n,i;if(!this.canvas)return;let r=yield it.canvasToImage(this.canvas),a=yield it.canvasToImage(null==(t=this.viewer.renderer)?void 0:t.domElement);return this.clearCanvas(),null==(n=this.context)||n.drawImage(a,0,0,a.width/window.devicePixelRatio,a.height/window.devicePixelRatio),null==(i=this.context)||i.drawImage(r,0,0,r.width/window.devicePixelRatio,r.height/window.devicePixelRatio),this.canvas.toDataURL(e.type,e.quality)}))}getImage(e){this.clearCanvas();let t=this.getSortedDrawables();for(let n=0;n<t.length;n++){let i=t[n];e(i)&&i.render(this.context,this.camera)}return it.canvasToImage(this.canvas)}getCanvas(){return this.canvas}destroy(){var e;this.drawableLists.forEach((e=>e.clear())),this.drawableLists=[],this.canvas&&(null==(e=this.viewer.viewerContainer)||e.removeChild(this.canvas),this.canvas=void 0)}},Pl=class extends Xi{constructor(e){super(),this.drawableMap=new Map,this.category=e}addDrawable(e){this.drawableMap.set(e.id,e),this.dispatchEvent("addDrawable",e.getData())}updateDrawable(e,t){e.setData(t),this.dispatchEvent("updateDrawable",e.getData())}removeDrawable(e){this.drawableMap.delete(e.id),this.dispatchEvent("removeDrawable",e.getData())}getDrawableById(e){return this.drawableMap.get(e)}clear(){this.drawableMap.forEach((e=>this.removeDrawable(e)))}getDrawables(){return this.drawableMap}getDrawableDatas(){return Array.from(this.drawableMap).map((([e,t])=>t.getData()))}setDrawableDatas(e){for(let t=0;t<e.length;t++){let n=e[t],i=$t.createDrawable(n);this.addDrawable(i)}}getDrawableByPosition(e,t){let n;for(let[i,r]of this.drawableMap)if(r.visible&&r.isPointInPath(e,t)){n=r;break}return n}},hit=new lt,wr=class extends ns{constructor(e){super(e),this.editPointSize=3,this.editPointColor="#ffffff",this.id=e||it.guid()}isSelected(){return this.selected}drawSelect(e,t){let n=this.getVertexes();this.drawPoints(e,t,n)}drawPoints(e,t,n){e.save(),e.fillStyle=this.editPointColor,e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.moveTo(i.x,i.y),e.arc(i.x,i.y,this.editPointSize,0,2*Math.PI)})),e.closePath(),e.fill(),e.restore()}setEditPointSize(e){this.editPointSize=e}setEditPointColor(e){this.editPointColor=e}getCenter(){return this.getBounds().getCenter(new M)}isPointInPath(e){let t=this.getVertexes().map((e=>new Q(e.x,e.y)));return xt.isPointInPolygon(new Q(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new M(e[0],e[1],0))))}setParent(e){this.parent=e}setLeaderText(e){this.leaderText=e,e.setParent(this)}update(e){let{min:t,max:n}=hit.setFromPoints(e);return this.x=t.x,this.y=n.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}translate(e,t){let n=new M(e,t,0);return this.points.forEach((e=>e.add(n))),this.update(this.points),this}rotate(){return this}scale(){return this}},js=(e=>(e.Arrow="ArrowMarkup",e.Circle="CircleMarkup",e.CloudLine="CloudLineMarkup",e.CloudLineRectangle="CloudRectMarkup",e.CloudRectWithText="CloudRectWithTextMarkup",e.Dot="DotMarkup",e.Ellipse="EllipseMarkup",e.LeaderLine="LeaderLineMarkup",e.PolyLine="PolylineMarkup",e.Rectangle="RectMarkup",e.Text="TextMarkup",e.X="XMarkup",e))(js||{}),YF=class extends wr{constructor(e,t){super(e),this.type="ArrowMarkup",this.update(t)}draw(e,t){let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new M).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[0],n[1],10,a)}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor;let[i,r]=t,a=(new Q).subVectors(r,i).normalize();e.beginPath(),e.moveTo(i.x,i.y);let s=r.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new Q(n.x+l,n.y+h),p=new Q(n.x+c,n.y+u);e.save(),e.fillStyle=this.lineColor,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}getVertexes(){return this.points}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this}isPointInPath(e){return xt.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};$t._registerDrawableClass(YF);var dit=new Q,Kce=new M,$F=class extends wr{constructor(e,t){super(e),this.radius=1,this.type="CircleMarkup",this.update(t)}draw(e,t){let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t)));this.radius=dit.subVectors(i,n).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath(),e.arc(n.x,n.y,this.radius,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}update(e){let[t,n]=e,i=Kce.subVectors(n,t).length();return this.width=2*i,this.height=2*i,this.x=t.x-this.width/2,this.y=t.y+this.height/2,this.points=e,this}isPointInPath(e){let[t,n]=this.points,i=Kce.subVectors(t,n).length();return Math.abs(e.distanceTo(t)-i)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};$t._registerDrawableClass($F);var Jce=new lt,Il=class extends wr{constructor(e,t){super(e),this.type="CloudLineMarkup",this.update(t)}draw(e,t){let n=this.points,i=[];e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath();for(let s=0;s<n.length-1;s++){let r=this.transToScreenCoord(n[s],t),a=this.transToScreenCoord(n[s+1],t),o=Il.getControlPointByTwoPoints(r,a);0===s&&e.moveTo(r.x,r.y),e.quadraticCurveTo(o.x,o.y,a.x,a.y),i.push(n[s],n[s+1],nn.screenPoint2worldPosition(o,t,this.ctx.canvas))}e.stroke(),e.restore(),Jce.setFromPoints(i);let{min:r,max:a}=Jce;this.width=Math.abs(a.x-r.x),this.height=Math.abs(a.y-r.y),this.x=r.x,this.y=a.y}static getControlPointByTwoPoints(e,t){let n=(new Q).subVectors(t,e),i=n.angle(),r=n.length(),a=Yt.degToRad(45),s=r/2/Math.cos(a);return new Q(e.x+s*Math.cos(a-i),e.y-s*Math.sin(a-i))}getClassType(){return"CloudLineMarkup"}};$t._registerDrawableClass(Il);var ZF=class extends wr{constructor(e,t){super(e),this.type="CloudRectMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath();let n=this.getVertexes();n.push(n[0]);let i,r=[],a=new M;for(let s=0;s<n.length-1;s++){let e=n[s],t=n[s+1];a.subVectors(t,e),i||(i=a.length()/10);let o=a.length(),l=a.normalize(),h=Math.round(o/i);for(let n=0;n<h;n++)r.push(e.clone().add(l.clone().multiplyScalar(i*n)))}r.push(r[0]),this.vertexes=[];for(let s=0;s<r.length-1;s++){let n=r[s],i=r[s+1],a=this.transToScreenCoord(n,t),o=this.transToScreenCoord(i,t),l=Il.getControlPointByTwoPoints(a,o);this.vertexes.push(n,i,nn.screenPoint2worldPosition(l,t,this.ctx.canvas)),0===s&&e.moveTo(a.x,a.y),e.quadraticCurveTo(l.x,l.y,o.x,o.y)}e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let t=this.getVertexes(),n=[];for(let i=0;i<t.length;i++){let e=t[i],r=t[i+1]||t[0];n.push(e,r)}return xt.isPointOnLineSegments(e,n,3*this.tolerance)}getClassType(){return"CloudRectMarkup"}};$t._registerDrawableClass(ZF);var KF=class extends wr{constructor(e,t){super(e),this.radius=8,this.update(t)}draw(e,t){let n=this.transToScreenCoord(this.points[0],t);this.width=2*this.radius*this.tolerance,this.height=2*this.radius*this.tolerance,this.x=this.points[0].x-this.radius*this.tolerance,this.y=this.points[0].y+this.radius*this.tolerance,e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath(),e.arc(n.x,n.y,this.radius,0,2*Math.PI),e.closePath(),e.fill(),e.stroke(),e.restore()}update(e){let t=e[0];return this.width=2*this.radius*this.tolerance,this.height=2*this.radius*this.tolerance,this.x=t.x-this.radius*this.tolerance,this.y=t.y+this.radius*this.tolerance,this.points=e,this}getClassType(){return"DotMarkup"}};$t._registerDrawableClass(KF);var JF=class extends wr{constructor(e,t){super(e),this.radiusX=1,this.radiusY=1,this.type="EllipseMarkup",this.update(t)}draw(e,t){let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t))),r=(new Q).lerpVectors(n,i,.5);this.radiusX=Math.abs(i.x-n.x)/2,this.radiusY=Math.abs(i.y-n.y)/2,e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath(),e.ellipse(r.x,r.y,this.radiusX,this.radiusY,0,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n]=this.points,i=(new M).lerpVectors(t,n,.5),r=Math.pow(e.x-i.x,2),a=Math.pow(e.y-i.y,2),s=2*this.tolerance,o=Math.abs(n.x-t.x)/2-s,l=Math.abs(n.y-t.y)/2-s,h=r/(o*o),c=a/(l*l),u=Math.abs(n.x-t.x)/2+s,d=Math.abs(n.y-t.y)/2+s;return h+c>=1&&r/(u*u)+a/(d*d)<=1}getClassType(){return"EllipseMarkup"}};$t._registerDrawableClass(JF);var QF=class extends wr{constructor(e,t,n){super(e),this.text="",this.fontSize=12,this.type="TextMarkup",this.padding=200,this.update(t),this.text=n}draw(e,t){this.drawText(e,this.text,t),this.drawTextBorder(e,t)}drawText(e,t,n){let i=t.split("\n"),r=this.transToScreenCoord(new M(this.x,this.y,0),n),a=this.fontSize/this.tolerance,s=new Q(r.x+this.padding/this.tolerance,r.y+this.padding/this.tolerance),o=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.lineColor,e.textAlign="left",e.textBaseline="top",e.font=`${a}px Arial`;for(let l=0;l<i.length;l++){let t=i[l],n=e.measureText(t).width;n>o&&(o=n),e.fillText(t,s.x,s.y+l*a)}e.restore(),this.width||(this.width=o*this.tolerance+2*this.padding),this.height||(this.height=i.length*this.fontSize+2*this.padding)}drawTextBorder(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.lineColor,e.beginPath(),this.getVertexes().forEach(((n,i)=>{let{x:r,y:a}=this.transToScreenCoord(n,t);0===i?e.moveTo(r,a):e.lineTo(r,a)})),e.closePath(),e.stroke()}setFontSize(e){this.fontSize=e}update(e){let t=e[0];return this.x=t.x,this.y=t.y,this.points=[t],this}setData(e){super.setData(e),this.text=e.text,this.setFontSize(e.fontSize||12)}updateText(e){this.text=e}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}getClassType(){return"TextMarkup"}};$t._registerDrawableClass(QF);var e5=class extends wr{constructor(e,t){super(e),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new lt,this.update(t)}draw(e,t){let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new M).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[1],n[0],10,a),this.text.length>0&&this.drawText(e,this.text,t)}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new Q(n.x+l,n.y+h),p=new Q(n.x+c,n.y+u);e.save(),e.fillStyle=this.lineColor,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor;let[i,r]=t,a=(new Q).subVectors(i,r).normalize();e.beginPath(),e.moveTo(r.x,r.y);let s=i.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let[i,r]=this.points.map((e=>this.transToScreenCoord(e,n))),a=(new Q).subVectors(r,i).normalize().cross(new Q(0,-1))<0,s=t.split("\n"),o=this.fontSize/this.tolerance;e.save(),e.font=this.fontSize/this.tolerance+"px Arial";let l=Math.max(...s.map((t=>e.measureText(t).width)));e.fillStyle=this.lineColor,e.strokeStyle=this.lineColor;for(let d=0;d<s.length;d++){let t=s[d];e.fillText(t,a?r.x:r.x-l,r.y+(d+1)*o-2)}e.strokeRect(a?r.x:r.x-l,r.y,l,o*s.length),e.restore();let h=this.points[1],c=new M(a?h.x:h.x-l*this.tolerance,h.y-s.length*this.fontSize,h.z),u=new M(c.x+l*this.tolerance,h.y,h.z);this.textBounds.set(c,u)}setFontSize(e){this.fontSize=e}getVertexes(){return this.points}setData(e){super.setData(e),this.text=e.text||"",this.setFontSize(e.fontSize||12)}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}isPointInPath(e){return xt.isPointOnLineSegments(e,this.points,this.tolerance)||this.textBounds.containsPoint(e)}updateText(e){this.text=e}getClassType(){return"LeaderLineMarkup"}};$t._registerDrawableClass(e5);var t5=class extends wr{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor;let n=this.points;e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.stroke(),e.restore()}isPointInPath(e){let t=this.points,n=[];for(let i=0;i<t.length-1;i++)n.push(t[i],t[i+1]);return xt.isPointOnLineSegments(e,n,1*this.tolerance)}getVertexes(){return this.points}getClassType(){return"PolylineMarkup"}};$t._registerDrawableClass(t5);var n5=class extends wr{constructor(e,t){super(e),this.type="RectMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath(),this.getVertexes().forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let t=this.getVertexes(),n=[];for(let i=0;i<t.length;i++){let e=t[i],r=t[i+1]||t[0];n.push(e,r)}return xt.isPointOnLineSegments(e,n,2*this.tolerance)}getClassType(){return"RectMarkup"}};$t._registerDrawableClass(n5);var r5=class extends wr{constructor(e,t){super(e),this.type="XMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.beginPath();let[n,i,r,a]=this.getVertexes().map((e=>this.transToScreenCoord(e,t)));e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n,i,r]=this.getVertexes();return xt.isPointOnLineSegments(e,[t,i,n,r],.1)}getClassType(){return"XMarkup"}};$t._registerDrawableClass(r5);var Qce=new lt,i5=new M,eue=new Q,fit=new Q(1,0),pit=new Q(0,-1),Sv=class extends wr{constructor(e,t){super(e),this.type="CloudRectWithTextMarkup",this.textPosition=new M,this.textBounds=new lt,this.showLeaderLine=!0,this.text="CloudRectWithText",this.fontSize=12,this.padding=200,this.update(t)}enableLeaderLine(e){this.showLeaderLine=e}draw(e,t){this.drawCloudRect(e,t),this.showLeaderLine&&this.drawLeaderLine(e,t),this.text.length>0&&this.drawText(e,t,this.text)}drawCloudRect(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor,e.beginPath();let n=this.getCloudPoints();n.push(n[0]);let i,r=[];for(let a=0;a<n.length-1;a++){let e=n[a],t=n[a+1],s=i5.subVectors(t,e);i||(i=s.length()/10);let o=s.length(),l=s.normalize(),h=Math.round(o/i);for(let n=0;n<h;n++)r.push(e.clone().add(l.clone().multiplyScalar(i*n)))}r.push(r[0]),this.controlPoints=[],this.vertexes=[];for(let a=0;a<r.length-1;a++){let n=r[a],i=r[a+1],s=this.transToScreenCoord(n,t),o=this.transToScreenCoord(i,t),l=Il.getControlPointByTwoPoints(s,o);this.controlPoints.push(s,o),this.vertexes.push(n,i,nn.screenPoint2worldPosition(l,t,this.ctx.canvas)),0===a&&e.moveTo(s.x,s.y),e.quadraticCurveTo(l.x,l.y,o.x,o.y)}e.closePath(),e.stroke(),e.restore()}drawLeaderLine(e,t){if(!this.controlPoints)return;let n=this.transToScreenCoord(this.textPosition,t);this.controlPoints.sort(((e,t)=>n.distanceTo(e)-n.distanceTo(t)));let i=this.controlPoints[0];e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(n.x,n.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let i=this.transToScreenCoord(this.points[0],t),r=this.transToScreenCoord(this.textPosition,t),a=(new Q).subVectors(r,i).normalize(),s=a.cross(fit)<0,o=a.cross(pit)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.lineColor,e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let m=0;m<l.length;m++){let t=l[m],n=e.measureText(t).width;n>c&&(c=n)}let u=this.padding/this.tolerance,d=new Q(o?r.x:r.x-c-2*u,s?r.y:r.y-l.length*h-2*u);for(let m=0;m<l.length;m++){let t=l[m];e.fillText(t,d.x+u,d.y+u+m*h,c+2*u)}e.strokeRect(d.x,d.y,c+2*u,l.length*h+2*u),e.restore();let p=nn.screenPoint2worldPosition(eue.set(d.x,d.y),t,this.ctx.canvas);p.z=0;let f=nn.screenPoint2worldPosition(eue.set(d.x+c+2*u,d.y+(l.length*h+2*u)),t,this.ctx.canvas);f.z=0,this.textBounds.setFromPoints([p,f])}translate(e,t){let n=i5.set(e,t,0);this.points.forEach((e=>e.add(n))),this.textPosition.add(n);let[i,r]=this.points;return this.x=Math.min(i.x,r.x),this.y=Math.max(i.y,r.y),this.width=Math.abs(r.x-i.x),this.height=Math.abs(r.y-i.y),this}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.textPosition.set(Math.max(t.x,n.x),Math.max(t.y,n.y),0),this}getCloudPoints(){return[new M(this.x,this.y,0),new M(this.x+this.width,this.y,0),new M(this.x+this.width,this.y-this.height,0),new M(this.x,this.y-this.height,0)]}getBounds(){return Qce.setFromPoints([...this.points,...this.vertexes||[]]),Qce.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,n=e.getSize(i5);return[new M(t.x,t.y,0),new M(t.x+n.x,t.y,0),new M(t.x+n.x,t.y+n.y,0),new M(t.x,t.y+n.y,0)]}updateTextPosition(e){this.textPosition.copy(e)}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let n=new M(e,t,0);return this.textPosition.add(n),this}isPointInPath(e){let t=this.getCloudPoints(),n=[];for(let i=0;i<t.length;i++){let e=t[i],r=t[(i+1)%t.length];n.push(e,r)}return xt.isPointOnLineSegments(e,n,3*this.tolerance)||this.textBounds.containsPoint(e)}setFontSize(e){this.fontSize=e}setData(e){super.setData(e),this.text=e.text||"",this.setFontSize(e.fontSize||12);let t=e.textPosition||[0,0];this.textPosition.set(t[0],t[1],0)}updateText(e){this.text=e}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,text:this.text,textPosition:[this.textPosition.x,this.textPosition.y],type:this.getClassType()}}getClassType(){return"CloudRectWithTextMarkup"}};$t._registerDrawableClass(Sv);var un={LEFT:1,RIGHT:2,MIDDLE:4},Ve=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768});function _d(e){return e.isPerspectiveCamera}function Dc(e){return e.isOrthographicCamera}var mit=(e=>(e[e.NONE=-1]="NONE",e[e.ROTATE=0]="ROTATE",e[e.DOLLY=1]="DOLLY",e[e.PAN=2]="PAN",e[e.TOUCH_ROTATE=3]="TOUCH_ROTATE",e[e.TOUCH_DOLLY=4]="TOUCH_DOLLY",e))(mit||{}),git=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(git||{});function Rv(e){return{type:e}}var Lc={movable:!1,startDistBetweenFingers:0,scale:1},Av=2*Math.PI,tue=1e-6,pR=class extends qa{constructor(e,t,n=!1){super(),this.enabled=!0,this.target=new M,this.enableZoom=!1,this.enablePan=!1,this.enableRotate=!0,this.state=-1,this.rotateSpeed=1,this.zoomSpeed=1,this.panSpeed=1,this.scale=1,this.minZoom=0,this.maxZoom=1/0,this.screenSpacePanning=!0,this.autoRotate=!0,this.autoRotateSpeed=2,this.enableDamping=!1,this.dampingFactor=.05,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minDistance=0,this.maxDistance=1/0,this.keyPanSpeed=7,this.minFov=50,this.maxFov=95,this.zoomChanged=!1,this.panOffset=new M,this.pointerPositions={},this.rotateStart=new Q,this.rotateEnd=new Q,this.rotateDelta=new Q,this.dollyStart=new Q,this.dollyEnd=new Q,this.dollyDelta=new Q,this.panStart=new Q,this.panEnd=new Q,this.panDelta=new Q,this.pointers=[],this.spherical=new od,this.sphericalDelta=new od,this.update=function(e){let t=new M,n=new M,i=new En;return function(){let r=e.quat,a=r.clone().invert(),s=e.object.position;t.copy(s).sub(e.target),t.applyQuaternion(r),e.spherical.setFromVector3(t),e.autoRotate&&-1===e.state&&(e.isVRMode?e.sphericalDelta.theta+=Av/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=Av/60/60*e.autoRotateSpeed),e.enableDamping?(e.spherical.theta+=e.sphericalDelta.theta*e.dampingFactor,e.spherical.phi+=e.sphericalDelta.phi*e.dampingFactor):(e.spherical.theta+=e.sphericalDelta.theta,e.spherical.phi+=e.sphericalDelta.phi);let o=e.minAzimuthAngle,l=e.maxAzimuthAngle;return isFinite(o)&&isFinite(l)&&(o<-Math.PI?o+=Av:o>Math.PI&&(o-=Av),l<-Math.PI?l+=Av:l>Math.PI&&(l-=Av),e.spherical.theta=o<=l?Math.max(o,Math.min(l,e.spherical.theta)):e.spherical.theta>(o+l)/2?Math.max(o,e.spherical.theta):Math.min(l,e.spherical.theta)),e.spherical.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,e.spherical.phi)),e.spherical.makeSafe(),e.spherical.radius*=e.scale,e.spherical.radius=Math.max(e.minDistance,Math.min(e.maxDistance,e.spherical.radius)),!0===e.enableDamping?e.target.addScaledVector(e.panOffset,e.dampingFactor):e.target.add(e.panOffset),t.setFromSpherical(e.spherical),t.applyQuaternion(a),s.copy(e.target).add(t),e.object.lookAt(e.target),!0===e.enableDamping?(e.sphericalDelta.theta*=1-e.dampingFactor,e.sphericalDelta.phi*=1-e.dampingFactor,e.panOffset.multiplyScalar(1-e.dampingFactor)):(e.sphericalDelta.set(0,0,0),e.panOffset.set(0,0,0)),e.scale=1,!!(e.zoomChanged||n.distanceToSquared(e.object.position)>tue||8*(1-i.dot(e.object.quaternion))>tue)&&(e.dispatchEvent(Rv("change")),n.copy(e.object.position),i.copy(e.object.quaternion),e.zoomChanged=!1,!0)}}(this),this.onContextMenu=function(e){return t=>{!1!==e.enabled&&t.preventDefault()}}(this),this.onPointerDown=function(e){return t=>{!1!==e.enabled&&(0===e.pointers.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",e.onPointerMove),e.domElement.addEventListener("pointerup",e.onPointerUp)),e.addPointer(t),"touch"===t.pointerType?e.onTouchStart(t):e.onMouseDown(t))}}(this),this.onPointerMove=function(e){return t=>{!1!==e.enabled&&("touch"===t.pointerType?e.onTouchMove(t):e.onMouseMove(t))}}(this),this.onPointerUp=function(e){return t=>{e.removePointer(t),0===e.pointers.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",e.onPointerMove),e.domElement.removeEventListener("pointerup",e.onPointerUp)),"touch"===t.pointerType&&e.handlerTouchEnd(t),e.dispatchEvent(Rv("end")),e.state=-1}}(this),this.onPointerCancel=function(e){return t=>{e.removePointer(t),e.handlerTouchEnd(t)}}(this),this.onMouseWheel=function(e){return t=>{!1===e.enabled||!1===e.enableZoom||-1!==e.state||(t.preventDefault(),t.stopPropagation(),e.dispatchEvent(Rv("start")),e.handleMouseWheel(t),e.dispatchEvent(Rv("end")))}}(this),this.pan=function(e){let t=new M;return function(n,i){let r=e.domElement;if(e.object instanceof bn){let a=e.object.position;t.copy(a).sub(e.target);let s=t.length();s*=Math.tan(e.object.fov/2*Math.PI/180),e.panLeft(2*n*s/r.clientHeight,e.object.matrix),e.panUp(2*i*s/r.clientHeight,e.object.matrix)}else console.warn("WARNING: VRControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1}}(this),this.panLeft=function(e){let t=new M;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new M;return function(n,i){!0===e.screenSpacePanning?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),e.panOffset.add(t)}}(this),this.onKeyDown=e=>{!1===this.enabled||!1===this.enablePan||this.handleKeyDown(e)},this.object=e,this.domElement=t,this.isVRMode=n,this.quat=(new En).setFromUnitVectors(this.object.up,new M(0,1,0)),this.domElement&&this.domElement.style&&(this.domElement.style.touchAction="none"),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElementKeyEvents&&this.domElementKeyEvents.removeEventListener("keydown",this.onKeyDown)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t<this.pointers.length;t++)if(this.pointers[t].pointerId==e.pointerId)return void this.pointers.splice(t,1)}getDist(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}trackPointer(e){let t=this.pointerPositions[e.pointerId];void 0===t&&(t=new Q,this.pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}onTouchStart(e){switch(this.trackPointer(e),this.pointers.length){case 1:if(!1===this.enableRotate)return;this.handleTouchStartRotate(),this.state=3;break;case 2:this.handleTouchStartDolly(this.pointers),this.state=4;break;default:this.state=-1}-1!==this.state&&this.dispatchEvent(Rv("start"))}onMouseDown(e){switch(e.button){case 0:if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0;break;case 1:if(!1===this.enableZoom)return;this.handleMouseDownDolly(e),this.state=1;break;case 2:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0}break;default:this.state=-1}-1!==this.state&&this.dispatchEvent(Rv("start"))}onTouchMove(e){switch(this.trackPointer(e),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(e);break;case 4:this.handleTouchMoveDolly(e)}}onMouseMove(e){if(!1!==this.enabled)switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(e);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(e);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(e)}}handlerTouchEnd(e){Lc.movable=!1,Lc.scale=1}handleMouseWheel(e){let t=Math.pow(.95,this.zoomSpeed);e.deltaY<0?this.dollyIn(t):e.deltaY>0&&this.dollyOut(t),this.update()}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleTouchStartRotate(){if(1===this.pointers.length)this.rotateStart.set(this.pointers[0].pageX,this.pointers[0].pageY);else{let e=.5*(this.pointers[0].pageX+this.pointers[1].pageX),t=.5*(this.pointers[0].pageY+this.pointers[1].pageY);this.rotateStart.set(e,t)}}handleTouchStartDolly(e){if(e.length<2)return;let t=e[0],n=e[1];Lc.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[n.pageX,n.pageY]),Lc.movable=!0,Lc.scale=1}updateRotate(){let e=this.isVRMode,t=this.sphericalDelta;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let n=this.domElement;e?(t.theta+=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi+=2*Math.PI*this.rotateDelta.y/n.clientHeight):(t.theta-=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi-=2*Math.PI*this.rotateDelta.y/n.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.updateRotate()}dollyOut(e){this.object instanceof bn?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof bn?this.scale*=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart);let t=Math.pow(.95,this.zoomSpeed);this.dollyDelta.y>0?this.dollyOut(t):this.dollyIn(t),this.dollyStart.copy(this.dollyEnd)}handleMouseMovePan(e){this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}getSecondPointerPosition(e){let t=e.pointerId===this.pointers[0].pointerId?this.pointers[1]:this.pointers[0];return this.pointerPositions[t.pointerId]}handleTouchMoveRotate(e){if(1==this.pointers.length)this.rotateEnd.set(e.pageX,e.pageY);else{let t=this.getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this.rotateEnd.set(n,i)}this.updateRotate()}updateFov(e){var t;let n=this.object;if(!(n&&n instanceof bn))return void console.warn("WARNING: VRControls.js encountered an unknown camera type - updateFov disabled.");let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix(),this.dispatchEvent({type:"change"}))},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}handleTouchMoveDolly(e){if(!Lc.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),n=[e.pageX,e.pageY],i=[t.x,t.y],r=Lc.startDistBetweenFingers,a=this.getDist(n,i);if(!r||!a||Math.abs(r-a)<10)return;let s=a/r;console.log(s),s=Math.min(s,3),s=Math.max(s,1/3);let o=s-Lc.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(Lc.scale/s-1),this.updateFov(l),Lc.scale=s}handleKeyDown(e){let t=!1;switch(e.code){case"ArrowUp":this.pan(0,this.keyPanSpeed),t=!0;break;case"ArrowDown":this.pan(0,-this.keyPanSpeed),t=!0;break;case"ArrowLeft":this.pan(this.keyPanSpeed,0),t=!0;break;case"ArrowRight":this.pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}listenToKeyEvents(e){e.addEventListener("keydown",this.onKeyDown),this.domElementKeyEvents=e}},Rp=class extends Xi{constructor(e){super(),this.enable=!0,this.mouseDownPositionX=0,this.mouseDownPositionY=0,this.downClickTime=0,this.upClickTime=0,this.pointers=[],this.handleClick=e=>{if(!this.enable)return;this.stop(e);let t=this.getBaseEvent(e);this.dispatchEvent("click",t)},this.handlePointerDown=e=>{if(!this.enable)return;this.stop(e);let t,n=this.getBaseEvent(e);this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,this.downClickTime=n.timestamp,0===n.button&&this.downClickTime-this.upClickTime<300&&(t&&clearTimeout(t),t=setTimeout((()=>{this.dispatchEvent("dblclick",n)}),300)),this.dispatchEvent("pointerdown",n),"touch"===e.pointerType?(this.pointers.push(n),n.pointers=this.pointers,this.dispatchEvent("touchstart",n)):this.dispatchEvent("mousedown",n)},this.handlePointerMove=e=>{if(!this.enable)return;this.stop(e);let t=this.getBaseEvent(e);(Math.abs(t.x-this.mouseDownPositionX)>5||Math.abs(t.y-this.mouseDownPositionY)>5)&&(this.dispatchEvent("pointermove",t),"touch"===e.pointerType?(this.updatePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchmove",t)):this.dispatchEvent("mousemove",t))},this.handlePointerUp=e=>{if(!this.enable)return;this.stop(e);let t=this.getBaseEvent(e);0===t.button&&(this.upClickTime=t.timestamp),this.dispatchEvent("pointerup",t),"touch"===e.pointerType?(this.removePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchend",t)):this.dispatchEvent("mouseup",t),this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.handlePointerCancel=e=>{this.enable&&(this.stop(e),this.dispatchEvent("pointercancel",this.getBaseEvent(e)))},this.handleMouseWheel=e=>{this.enable&&(this.stop(e),this.dispatchEvent("wheel",this.getBaseEvent(e)))},this.handleContextMenu=e=>{if(this.enable)return this.stop(e),this.dispatchEvent("contextmenu",this.getBaseEvent(e)),!1},this.handlePointerEnter=e=>{this.enable&&(this.stop(e),this.dispatchEvent("pointerenter",this.getBaseEvent(e)))},this.handlePointerLeave=e=>{this.enable&&(this.stop(e),this.dispatchEvent("pointerleave",this.getBaseEvent(e)))},this.handleResize=e=>{this.enable&&(this.stop(e),this.dispatchEvent("resize",this.getBaseEvent(e)))},this.handleKeydown=e=>{this.enable&&this.dispatchEvent("keydown",this.getBaseEvent(e))},this.handleKeyup=e=>{this.enable&&this.dispatchEvent("keyup",this.getBaseEvent(e))},this.style={},this.element=e,this.bindEvents()}setEnable(e){this.enable=e}setCursor(e){this.element.style&&(this.element.style.cursor=e||"default")}bindEvents(){this.element.style.touchAction="none",this.element.style.userSelect="none",this.element.style.webkitUserSelect="none",this.element.addEventListener("click",this.handleClick),this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("pointermove",this.handlePointerMove),this.element.addEventListener("pointerup",this.handlePointerUp),this.element.addEventListener("pointercancel",this.handlePointerCancel),this.element.addEventListener("pointerenter",this.handlePointerEnter),this.element.addEventListener("pointerleave",this.handlePointerLeave),this.element.addEventListener("contextmenu",this.handleContextMenu),this.element.addEventListener("wheel",this.handleMouseWheel),window.addEventListener("resize",this.handleResize),window.addEventListener("keydown",this.handleKeydown),window.addEventListener("keyup",this.handleKeyup)}unBindEvents(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("pointermove",this.handlePointerMove),this.element.removeEventListener("pointerup",this.handlePointerUp),this.element.removeEventListener("pointerenter",this.handlePointerEnter),this.element.removeEventListener("pointerleave",this.handlePointerLeave),this.element.removeEventListener("contextmenu",this.handleContextMenu),this.element.removeEventListener("wheel",this.handleMouseWheel),window.removeEventListener("resize",this.handleResize),window.removeEventListener("keydown",this.handleKeydown),window.removeEventListener("keyup",this.handleKeyup),this.element.style.touchAction="",this.element.style.userSelect="",this.element.style.webkitUserSelect=""}getBaseEvent(e){let t={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};if(t.timestamp=e.timeStamp,mR(e,"clientX"))if(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.clientX=e.clientX,t.clientY=e.clientY,t.button=e.button,mR(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let n=nn.getScreenPointByEvent(e,this.element);t.x=n.x,t.y=n.y,t.movementX=e.movementX,t.movementY=e.movementY}else mR(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else mR(e,"code")&&(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.metaKey=e.metaKey,t.code=e.code);return t}stop(e){e.preventDefault()}updatePointers(e){for(let t=0;t<this.pointers.length;t++)if(e.pointerId==this.pointers[t].pointerId){this.pointers[t]=e;break}}removePointers(e){for(let t=0;t<this.pointers.length;t++)if(this.pointers[t].pointerId==e.pointerId){this.pointers.splice(t,1);break}}getBoundingClientRect(){return this.element.getBoundingClientRect()}};function mR(e,t){return void 0!==e[t]}var Ap=2*Math.PI,s5=Math.PI/2,Cv=Math.PI/180;function Cp(e,t,n){return Math.max(t,Math.min(n,e))}function qr(e,t=1e-5){return Math.abs(e)<t}function Wr(e,t,n=1e-5){return qr(e-t,n)}function a5(e,t){return Math.round(e/t)*t}function Pv(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Iv(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function Fy(e,t,n,i,r=1/0,a){let s=2/(i=Math.max(1e-4,i)),o=s*a,l=1/(1+o+.48*o*o+.235*o*o*o),h=e-t,c=t,u=r*i;h=Cp(h,-u,u),t=e-h;let d=(n.value+s*h)*a;n.value=(n.value-s*d)*l;let p=t+(h+d)*l;return c-e>0==p>c&&(p=c,n.value=(p-c)/a),p}function o5(e,t,n,i,r=1/0,a,s){let o=2/(i=Math.max(1e-4,i)),l=o*a,h=1/(1+l+.48*l*l+.235*l*l*l),c=t.x,u=t.y,d=t.z,p=e.x-c,f=e.y-u,m=e.z-d,g=c,v=u,y=d,x=r*i,_=p*p+f*f+m*m;if(_>x*x){let e=Math.sqrt(_);p=p/e*x,f=f/e*x,m=m/e*x}c=e.x-p,u=e.y-f,d=e.z-m;let b=(n.x+o*p)*a,M=(n.y+o*f)*a,w=(n.z+o*m)*a;n.x=(n.x-o*b)*h,n.y=(n.y-o*M)*h,n.z=(n.z-o*w)*h,s.x=c+(p+b)*h,s.y=u+(f+M)*h,s.z=d+(m+w)*h;let S=g-e.x,E=v-e.y,T=y-e.z;return S*(s.x-g)+E*(s.y-v)+T*(s.z-y)>0&&(s.x=g,s.y=v,s.z=y,n.x=(s.x-g)/a,n.y=(s.y-v)/a,n.z=(s.z-y)/a),s}function gR(e,t){t.set(0,0),e.forEach((e=>{t.x+=e.clientX,t.y+=e.clientY})),t.x/=e.length,t.y/=e.length}function vR(e,t){return!!Dc(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var hn,nue,ER,l5,Ea,pn,Cr,Dv,Oc,Nc,Pp,rue,iue,Dl,Hy,Lv,sue,c5,aue,u5,h5,bR,xR=class{constructor(){this._listeners={}}addEventListener(e,t){let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e)}}},yR=1/8,vit=tn.isBrowser&&/Mac/.test(navigator.platform),xit=!(tn.isBrowser&&"PointerEvent"in window),Td=class extends xR{constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=0,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=Ve.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=tn.isBrowser?new DOMRect:{x:0,y:0,width:0,height:0,left:0,right:0,top:0,bottom:0},this._activePointers=[],this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new hn.Vector3,this._focalOffsetVelocity=new hn.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,n)=>{if(_d(this._camera)){let i=pn.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*Cv,a=i.length()*Math.tan(.5*r),s=this.truckSpeed*e*a/this._elementRect.height,o=this.truckSpeed*t*a/this._elementRect.height;this.verticalDragToForward?(n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(s,0,!0),this.forward(-o,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(s,o,!0)}else if(Dc(this._camera)){let i=this._camera,r=e*(i.right-i.left)/i.zoom/this._elementRect.width,a=t*(i.top-i.bottom)/i.zoom/this._elementRect.height;n?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(r,a,!0)}},this._rotateInternal=(e,t)=>{let n=Ap*this.azimuthRotateSpeed*e/this._elementRect.height,i=Ap*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,i,!0)},this._dollyInternal=(e,t,n)=>{let i=Math.pow(.95,-e*this.dollySpeed),r=this._sphericalEnd.radius*i,a=this._sphericalEnd.radius,s=a*(e>=0?-1:1);this.dollyTo(r),this.infinityDolly&&(r<this.minDistance||this.maxDistance===this.minDistance)&&(this._camera.getWorldDirection(pn),this._targetEnd.add(pn.normalize().multiplyScalar(s)),this._target.add(pn.normalize().multiplyScalar(s))),this.dollyToCursor&&(this._dollyControlAmount+=this._sphericalEnd.radius-a,this.infinityDolly&&(r<this.minDistance||this.maxDistance===this.minDistance)&&(this._dollyControlAmount-=s),this._dollyControlCoord.set(t,n))},this._zoomInternal=(e,t,n)=>{let i=Math.pow(.95,e*this.dollySpeed),r=this._zoomEnd;this.zoomTo(this._zoom*i),this.dollyToCursor&&(this._dollyControlAmount+=this._zoomEnd-r,this._dollyControlCoord.set(t,n))},void 0===hn&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new hn.Quaternion).setFromUnitVectors(this._camera.up,ER),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Ve.NONE,this._target=new hn.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new hn.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new hn.Spherical).setFromVector3(pn.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new hn.Vector3,new hn.Vector3,new hn.Vector3,new hn.Vector3],this._updateNearPlaneCorners(),this._boundary=new hn.Box3(new hn.Vector3(-1/0,-1/0,-1/0),new hn.Vector3(1/0,1/0,1/0)),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlAmount=0,this._dollyControlCoord=new hn.Vector2,this.mouseButtons={left:Ve.ROTATE,middle:Ve.DOLLY,right:Ve.TRUCK,wheel:_d(this._camera)?Ve.DOLLY:Dc(this._camera)?Ve.ZOOM:Ve.NONE},this.touches={one:Ve.TOUCH_ROTATE,two:_d(this._camera)?Ve.TOUCH_DOLLY_TRUCK:Dc(this._camera)?Ve.TOUCH_ZOOM_TRUCK:Ve.NONE,three:Ve.TOUCH_TRUCK};let n=new hn.Vector2,i=new hn.Vector2,r=new hn.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&un.LEFT)===un.LEFT?un.LEFT:(e.buttons&un.MIDDLE)===un.MIDDLE?un.MIDDLE:(e.buttons&un.RIGHT)===un.RIGHT?un.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.addEventListener("pointermove",o),this._domElement.addEventListener("pointerup",h),f(e)},s=e=>{if(!this._enabled||!this._domElement)return;let t=(e.buttons&un.LEFT)===un.LEFT?un.LEFT:(e.buttons&un.MIDDLE)===un.MIDDLE?un.MIDDLE:(e.buttons&un.RIGHT)===un.RIGHT?un.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:(e.buttons&un.LEFT)===un.LEFT?un.LEFT:(e.buttons&un.MIDDLE)===un.LEFT?un.MIDDLE:(e.buttons&un.RIGHT)===un.LEFT?un.RIGHT:null};this._activePointers.push(n),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("mouseup",c),this._domElement.addEventListener("mousemove",l),this._domElement.addEventListener("mouseup",c),f(e)},o=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&un.LEFT)===un.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&un.MIDDLE)===un.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&un.RIGHT)===un.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=e=>{let t=this._findPointerById(0);t&&(t.clientX=e.clientX,t.clientY=e.clientY,t.deltaX=e.movementX,t.deltaY=e.movementY,this._state=0,(e.buttons&un.LEFT)===un.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&un.MIDDLE)===un.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&un.RIGHT)===un.RIGHT&&(this._state=this._state|this.mouseButtons.right),m())},h=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n&&this._activePointers.splice(this._activePointers.indexOf(n),1),"touch"===e.pointerType)switch(this._activePointers.length){case 0:this._state=Ve.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=Ve.NONE;g()},c=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=Ve.NONE,g()},u=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===Ve.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===Ve.ROTATE||this.mouseButtons.wheel===Ve.TRUCK){let e=performance.now();u-e<1e3&&this._getClientRect(this._elementRect),u=e}let t=vit?-1:-3,n=1===e.deltaMode?e.deltaY/t:e.deltaY/(10*t),i=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,r=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case Ve.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case Ve.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case Ve.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case Ve.DOLLY:this._dollyInternal(-n,i,r),this._isUserControllingDolly=!0;break;case Ve.ZOOM:this._zoomInternal(-n,i,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Td.ACTION.NONE){let t=e instanceof PointerEvent?e.pointerId:(MouseEvent,0),n=this._findPointerById(t);return n&&this._activePointers.splice(this._activePointers.indexOf(n),1),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mousemove",l),void this._domElement.removeEventListener("mouseup",c)}},f=e=>{if(this._enabled){if(gR(this._activePointers,Ea),this._getClientRect(this._elementRect),n.copy(Ea),i.copy(Ea),this._activePointers.length>=2){let e=Ea.x-this._activePointers[1].clientX,t=Ea.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);r.set(0,n);let a=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),s=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);i.set(a,s)}if("pointerType"in e&&"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&un.LEFT)===un.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&un.MIDDLE)===un.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&un.RIGHT)===un.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&Ve.ROTATE)===Ve.ROTATE||(this._state&Ve.TOUCH_ROTATE)===Ve.TOUCH_ROTATE||(this._state&Ve.TOUCH_DOLLY_ROTATE)===Ve.TOUCH_DOLLY_ROTATE||(this._state&Ve.TOUCH_ZOOM_ROTATE)===Ve.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&Ve.TRUCK)===Ve.TRUCK||(this._state&Ve.TOUCH_TRUCK)===Ve.TOUCH_TRUCK||(this._state&Ve.TOUCH_DOLLY_TRUCK)===Ve.TOUCH_DOLLY_TRUCK||(this._state&Ve.TOUCH_ZOOM_TRUCK)===Ve.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&Ve.DOLLY)===Ve.DOLLY||(this._state&Ve.TOUCH_DOLLY)===Ve.TOUCH_DOLLY||(this._state&Ve.TOUCH_DOLLY_TRUCK)===Ve.TOUCH_DOLLY_TRUCK||(this._state&Ve.TOUCH_DOLLY_OFFSET)===Ve.TOUCH_DOLLY_OFFSET||(this._state&Ve.TOUCH_DOLLY_ROTATE)===Ve.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&Ve.ZOOM)===Ve.ZOOM||(this._state&Ve.TOUCH_ZOOM)===Ve.TOUCH_ZOOM||(this._state&Ve.TOUCH_ZOOM_TRUCK)===Ve.TOUCH_ZOOM_TRUCK||(this._state&Ve.TOUCH_ZOOM_OFFSET)===Ve.TOUCH_ZOOM_OFFSET||(this._state&Ve.TOUCH_ZOOM_ROTATE)===Ve.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&Ve.OFFSET)===Ve.OFFSET||(this._state&Ve.TOUCH_OFFSET)===Ve.TOUCH_OFFSET||(this._state&Ve.TOUCH_DOLLY_OFFSET)===Ve.TOUCH_DOLLY_OFFSET||(this._state&Ve.TOUCH_ZOOM_OFFSET)===Ve.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;gR(this._activePointers,Ea);let e=!!tn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:i.x-Ea.x,a=e?-this._activePointers[0].deltaY:i.y-Ea.y;if(i.copy(Ea),((this._state&Ve.ROTATE)===Ve.ROTATE||(this._state&Ve.TOUCH_ROTATE)===Ve.TOUCH_ROTATE||(this._state&Ve.TOUCH_DOLLY_ROTATE)===Ve.TOUCH_DOLLY_ROTATE||(this._state&Ve.TOUCH_ZOOM_ROTATE)===Ve.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&Ve.DOLLY)===Ve.DOLLY||(this._state&Ve.ZOOM)===Ve.ZOOM){let e=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Ve.DOLLY)===Ve.DOLLY?(this._dollyInternal(a*yR,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*yR,e,t),this._isUserControllingZoom=!0)}if((this._state&Ve.TOUCH_DOLLY)===Ve.TOUCH_DOLLY||(this._state&Ve.TOUCH_ZOOM)===Ve.TOUCH_ZOOM||(this._state&Ve.TOUCH_DOLLY_TRUCK)===Ve.TOUCH_DOLLY_TRUCK||(this._state&Ve.TOUCH_ZOOM_TRUCK)===Ve.TOUCH_ZOOM_TRUCK||(this._state&Ve.TOUCH_DOLLY_OFFSET)===Ve.TOUCH_DOLLY_OFFSET||(this._state&Ve.TOUCH_ZOOM_OFFSET)===Ve.TOUCH_ZOOM_OFFSET||(this._state&Ve.TOUCH_DOLLY_ROTATE)===Ve.TOUCH_DOLLY_ROTATE||(this._state&Ve.TOUCH_ZOOM_ROTATE)===Ve.TOUCH_ZOOM_ROTATE){let e=Ea.x-this._activePointers[1].clientX,t=Ea.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),a=r.y-n;r.set(0,n);let s=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,o=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Ve.TOUCH_DOLLY)===Ve.TOUCH_DOLLY||(this._state&Ve.TOUCH_DOLLY_ROTATE)===Ve.TOUCH_DOLLY_ROTATE||(this._state&Ve.TOUCH_DOLLY_TRUCK)===Ve.TOUCH_DOLLY_TRUCK||(this._state&Ve.TOUCH_DOLLY_OFFSET)===Ve.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*yR,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*yR,s,o),this._isUserControllingZoom=!0)}((this._state&Ve.TRUCK)===Ve.TRUCK||(this._state&Ve.TOUCH_TRUCK)===Ve.TOUCH_TRUCK||(this._state&Ve.TOUCH_DOLLY_TRUCK)===Ve.TOUCH_DOLLY_TRUCK||(this._state&Ve.TOUCH_ZOOM_TRUCK)===Ve.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&Ve.OFFSET)===Ve.OFFSET||(this._state&Ve.TOUCH_OFFSET)===Ve.TOUCH_OFFSET||(this._state&Ve.TOUCH_DOLLY_OFFSET)===Ve.TOUCH_DOLLY_OFFSET||(this._state&Ve.TOUCH_ZOOM_OFFSET)===Ve.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{gR(this._activePointers,Ea),i.copy(Ea),0===this._activePointers.length&&this._domElement&&(this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c),this.dispatchEvent({type:"controlend"}))};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),xit&&this._domElement.addEventListener("mousedown",s),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",d),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("mousedown",s),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",d),this._domElement.removeEventListener("contextmenu",p),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c))},this.cancel=()=>{this._state!==Ve.NONE&&(this._state=Ve.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){hn=e.THREE,nue=Object.freeze(new hn.Vector3(0,0,0)),ER=Object.freeze(new hn.Vector3(0,1,0)),l5=Object.freeze(new hn.Vector3(0,0,1)),Ea=new hn.Vector2,pn=new hn.Vector3,Cr=new hn.Vector3,Dv=new hn.Vector3,Oc=new hn.Vector3,Nc=new hn.Vector3,Pp=new hn.Vector3,rue=new hn.Vector3,iue=new hn.Vector3,Dl=new hn.Spherical,Hy=new hn.Spherical,Lv=new hn.Box3,sue=new hn.Box3,c5=new hn.Sphere,aue=new hn.Quaternion,u5=new hn.Quaternion,h5=new hn.Matrix4,bR=new hn.Raycaster}static get ACTION(){return Ve}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let i=Cp(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Cp(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||Wr(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Wr(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){this._isUserControllingDolly=!1;let n=this._sphericalEnd.radius,i=Cp(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=Wr(e,this._spherical.radius);if(!(n>i)&&t)return Promise.resolve();this._sphericalEnd.radius=Math.min(i,e)}else this._sphericalEnd.radius=i;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||Wr(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Cp(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||Wr(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Oc.setFromMatrixColumn(this._camera.matrix,0),Nc.setFromMatrixColumn(this._camera.matrix,1),Oc.multiplyScalar(e),Nc.multiplyScalar(-t);let i=pn.copy(Oc).add(Nc),r=Cr.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){pn.setFromMatrixColumn(this._camera.matrix,0),pn.crossVectors(this._camera.up,pn),pn.multiplyScalar(e);let n=Cr.copy(this._targetEnd).add(pn);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return pn.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+pn.x,this._targetEnd.y+pn.y,this._targetEnd.z+pn.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;let r=pn.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);let a=!i||Wr(this._target.x,this._targetEnd.x,this.restThreshold)&&Wr(this._target.y,this._targetEnd.y,this.restThreshold)&&Wr(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,i=!1){let r=pn.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:s=0}={}){let o=[],l=e.isBox3?Lv.copy(e):Lv.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=a5(this._sphericalEnd.theta,s5),c=a5(this._sphericalEnd.phi,s5);o.push(this.rotateTo(h,c,t));let u=pn.setFromSpherical(this._sphericalEnd).normalize(),d=aue.setFromUnitVectors(u,l5),p=Wr(Math.abs(u.y),1);p&&d.multiply(u5.setFromAxisAngle(ER,h)),d.multiply(this._yAxisUpSpaceInverse);let f=sue.makeEmpty();Cr.copy(l.min).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(Cr),Cr.copy(l.max).applyQuaternion(d),f.expandByPoint(Cr),f.min.x-=i,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(l5,u),p&&d.premultiply(u5.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(pn),g=f.getCenter(Cr).applyQuaternion(d);if(_d(this._camera)){let e=this.getDistanceToFitBox(m.x,m.y,m.z,n);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.dollyTo(e,t)),o.push(this.setFocalOffset(0,0,0,t))}else if(Dc(this._camera)){let e=this._camera,i=e.right-e.left,r=e.top-e.bottom,a=n?Math.max(i/m.x,r/m.y):Math.min(i/m.x,r/m.y);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.zoomTo(a,t)),o.push(this.setFocalOffset(0,0,0,t))}return Promise.all(o)}fitToSphere(e,t){let n=[],i=e instanceof hn.Sphere?c5.copy(e):Td.createBoundingSphere(e,c5);if(n.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),_d(this._camera)){let e=this.getDistanceToFitSphere(i.radius);n.push(this.dollyTo(e,t))}else if(Dc(this._camera)){let e=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*i.radius,s=Math.min(e/a,r/a);n.push(this.zoomTo(s,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,r,a,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let o=Cr.set(i,r,a),l=pn.set(e,t,n);this._targetEnd.copy(o),this._sphericalEnd.setFromVector3(l.sub(o).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let h=!s||Wr(this._target.x,this._targetEnd.x,this.restThreshold)&&Wr(this._target.y,this._targetEnd.y,this.restThreshold)&&Wr(this._target.z,this._targetEnd.z,this.restThreshold)&&Wr(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Wr(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Wr(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,i,r,a,s,o,l,h,c,u,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let f=pn.set(i,r,a),m=Cr.set(e,t,n);Dl.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=Dv.set(h,c,u),v=Cr.set(s,o,l);Hy.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=Hy.theta-Dl.theta,x=Hy.phi-Dl.phi,_=Hy.radius-Dl.radius;this._sphericalEnd.set(Dl.radius+_*d,Dl.phi+x*d,Dl.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let b=!p||Wr(this._target.x,this._targetEnd.x,this.restThreshold)&&Wr(this._target.y,this._targetEnd.y,this.restThreshold)&&Wr(this._target.z,this._targetEnd.z,this.restThreshold)&&Wr(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Wr(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Wr(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){let r=this.getPosition(pn),a=this.setLookAt(r.x,r.y,r.z,e,t,n,i);return this._sphericalEnd.phi=Cp(this.polarAngle,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);let r=!i||Wr(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Wr(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Wr(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Oc.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Nc.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Pp.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let i=pn.set(e,t,n),r=i.distanceTo(this._camera.position),a=i.sub(this._camera.position);Oc.multiplyScalar(a.x),Nc.multiplyScalar(a.y),Pp.multiplyScalar(a.z),pn.copy(Oc).add(Nc).add(Pp),pn.z=pn.z+r,this.dollyTo(r,!1),this.setFocalOffset(-pn.x,pn.y,-pn.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){null!==e?(this._viewport=this._viewport||new hn.Vector4,"number"==typeof e?this._viewport.set(e,t,n,i):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,n,i=!1){if(vR(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*Cv,s=this._camera.aspect;return.5*((i?r>s:r<s)?t:e/s)/Math.tan(.5*a)+.5*n}getDistanceToFitSphere(e){if(vR(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;let t=this._camera.getEffectiveFOV()*Cv,n=2*Math.atan(Math.tan(.5*t)*this._camera.aspect),i=1<this._camera.aspect?t:n;return e/Math.sin(.5*i)}getTarget(e){return(e&&e.isVector3?e:new hn.Vector3).copy(this._targetEnd)}getPosition(e){return(e&&e.isVector3?e:new hn.Vector3).setFromSpherical(this._sphericalEnd).applyQuaternion(this._yAxisUpSpaceInverse).add(this._targetEnd)}getFocalOffset(e){return(e&&e.isVector3?e:new hn.Vector3).copy(this._focalOffsetEnd)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ap,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ap),this._spherical.theta+=Ap*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ap)}reset(e=!1){let t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ER),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert}update(e){let t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,r=rue.subVectors(this._targetEnd,this._target),a=iue.subVectors(this._focalOffsetEnd,this._focalOffset),s=this._zoomEnd-this._zoom;if(qr(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Fy(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(qr(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Fy(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(qr(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{let t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Fy(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,t,this.maxSpeed,e),this._needsUpdate=!0}if(qr(r.x)&&qr(r.y)&&qr(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{let t=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;o5(this._target,this._targetEnd,this._targetVelocity,t,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(qr(a.x)&&qr(a.y)&&qr(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{let t=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;o5(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(0!==this._dollyControlAmount){if(_d(this._camera)){let e=this._camera,t=pn.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).normalize().negate(),n=Cr.copy(t).cross(e.up).normalize();0===n.lengthSq()&&(n.x=1);let i=Dv.crossVectors(n,t),r=this._sphericalEnd.radius*Math.tan(e.getEffectiveFOV()*Cv*.5),a=(this._sphericalEnd.radius-this._dollyControlAmount-this._sphericalEnd.radius)/this._sphericalEnd.radius,s=pn.copy(this._targetEnd).add(n.multiplyScalar(this._dollyControlCoord.x*r*e.aspect)).add(i.multiplyScalar(this._dollyControlCoord.y*r));this._targetEnd.lerp(s,a)}else if(Dc(this._camera)){let e=this._camera,t=pn.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(e.near+e.far)/(e.near-e.far)).unproject(e),n=Cr.set(0,0,-1).applyQuaternion(e.quaternion),i=Dv.copy(t).add(n.multiplyScalar(-t.dot(e.up))),r=-(this._zoom-this._dollyControlAmount-this._zoomEnd)/this._zoom,a=pn.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).normalize().negate(),s=this._targetEnd.dot(a);this._targetEnd.lerp(i,r);let o=this._targetEnd.dot(a),l=a.multiplyScalar(o-s);this._targetEnd.sub(l)}this._target.copy(this._targetEnd),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._dollyControlAmount=0}if(qr(s))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{let t=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Fy(this._zoom,this._zoomEnd,this._zoomVelocity,t,1/0,e)}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);let o=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,o),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!qr(this._focalOffset.x)||!qr(this._focalOffset.y)||!qr(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Oc.setFromMatrixColumn(this._camera.matrix,0),Nc.setFromMatrixColumn(this._camera.matrix,1),Pp.setFromMatrixColumn(this._camera.matrix,2),Oc.multiplyScalar(this._focalOffset.x),Nc.multiplyScalar(-this._focalOffset.y),Pp.multiplyScalar(this._focalOffset.z),pn.copy(Oc).add(Nc).add(Pp),this._camera.position.add(pn)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),pn.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);let l=this._needsUpdate;return l&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):l?(this.dispatchEvent({type:"update"}),qr(t,this.restThreshold)&&qr(n,this.restThreshold)&&qr(i,this.restThreshold)&&qr(r.x,this.restThreshold)&&qr(r.y,this.restThreshold)&&qr(r.z,this.restThreshold)&&qr(a.x,this.restThreshold)&&qr(a.y,this.restThreshold)&&qr(a.z,this.restThreshold)&&qr(s,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!l&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._updatedLastTime=l,this._needsUpdate=!1,l}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Pv(this.maxDistance),minZoom:this.minZoom,maxZoom:Pv(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Pv(this.maxPolarAngle),minAzimuthAngle:Pv(this.minAzimuthAngle),maxAzimuthAngle:Pv(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:pn.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){let n=JSON.parse(e),i=pn.fromArray(n.position);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=Iv(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=Iv(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=Iv(n.maxPolarAngle),this.minAzimuthAngle=Iv(n.minAzimuthAngle),this.maxAzimuthAngle=Iv(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Dl.setFromVector3(i.sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Dl.theta,Dl.phi,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){this._domElement?console.warn("camera-controls is already connected."):this._addAllEventListeners(e)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_findPointerById(e){return this._activePointers.find((t=>t.pointerId===e))}_findPointerByMouseButton(e){return this._activePointers.find((t=>t.mouseButton===e))}_encloseToBoundary(e,t,n){let i=t.lengthSq();if(0===i)return e;let r=Cr.copy(t).add(e),a=this._boundary.clampPoint(r,Dv).sub(r),s=a.lengthSq();if(0===s)return e.add(t);if(s===i)return e;if(0===n)return e.add(t).add(a);{let i=1+n*s/t.dot(a);return e.add(Cr.copy(t).multiplyScalar(i)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(_d(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*Cv,i=Math.tan(.5*n)*t,r=i*e.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(Dc(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||vR(this._camera,"_collisionTest"))return e;let t=pn.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);h5.lookAt(nue,t,this._camera.up);for(let n=0;n<4;n++){let i=Cr.copy(this._nearPlaneCorners[n]);i.applyMatrix4(h5);let r=Dv.addVectors(this._target,i);bR.set(r,t),bR.far=this._spherical.radius+1;let a=bR.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;let t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise((e=>{let t=()=>{this.removeEventListener("rest",t),e()};this.addEventListener("rest",t)})))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new hn.Sphere){let n=t,i=n.center;Lv.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&Lv.expandByObject(e)})),Lv.getCenter(i);let r=0;return e.traverseVisible((e=>{if(!e.isMesh)return;let t=e,n=t.geometry.clone();if(n.applyMatrix4(t.matrixWorld),n.isBufferGeometry){let e=n.attributes.position;for(let t=0,n=e.count;t<n;t++)pn.fromBufferAttribute(e,t),r=Math.max(r,i.distanceToSquared(pn))}else{let e=n.attributes.position;for(let t=0,n=e.count;t<n;t++)pn.fromBufferAttribute(e,t),r=Math.max(r,i.distanceToSquared(pn))}})),n.radius=Math.sqrt(r),n}};Td.install({THREE:pt});var ba=class extends Td{constructor(e,t){super(e,t),this.minZoom=0,this.draggingSmoothTime=0,this.keyTruckSpeed=7,this.keys={left:"ArrowLeft",up:"ArrowUp",right:"ArrowRight",bottom:"ArrowDown"},this.onKeyDown=e=>{if(this.enabled){switch(e.code){case this.keys.up:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,1),this._isUserControllingRotate=!0):(this._truckInternal(0,this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.bottom:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,-1),this._isUserControllingRotate=!0):(this._truckInternal(0,-this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.left:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(1,0),this._isUserControllingRotate=!0):(this._truckInternal(this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0);break;case this.keys.right:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(-1,0),this._isUserControllingRotate=!0):(this._truckInternal(-this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0)}this.dispatchEvent({type:"control"})}},this.onKeyUp=e=>{this.dispatchEvent({type:"controlend"})},this._getClientRect(this._elementRect),this.dollySpeedBackup=this.dollySpeed,this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.truckSpeedBackup=this.truckSpeed}get enableZoom(){return!!this.dollySpeed}set enableZoom(e){e?this.dollySpeed=this.dollySpeedBackup:(this.dollySpeedBackup=this.dollySpeed,this.dollySpeed=0)}get enableRotate(){return!!this.azimuthRotateSpeed||!!this.polarRotateSpeed}set enableRotate(e){e?(this.azimuthRotateSpeed=this.azimuthRotateSpeedBackup,this.polarRotateSpeed=this.polarRotateSpeedBackup):(this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.azimuthRotateSpeed=0,this.polarRotateSpeed=0)}get enableTruck(){return!!this.truckSpeed}set enableTruck(e){e?this.truckSpeed=this.truckSpeedBackup:(this.truckSpeedBackup=this.truckSpeed,this.truckSpeed=0)}listenToKeyEvents(){var e,t;null==(e=this._domElement)||e.addEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.addEventListener("keyup",this.onKeyUp)}stopListenToKeyEvents(){var e,t;null==(e=this._domElement)||e.removeEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.removeEventListener("keyup",this.onKeyUp)}dispose(){super.dispose(),this.stopListenToKeyEvents()}},Vo=class{constructor(e){this.name=e}},_R=class{constructor(e){this.history=[],this.step=0,this.maxCount=50,this.isBatchCommand=!1,this.batchCommands=[],this.maxCount=e||this.maxCount}addCommand(e){this.isBatchCommand?this.batchCommands.push(e):(this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.history.push(e),this.step++)}startTransaction(){this.isBatchCommand=!0}endTransaction(){this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.batchCommands.length>0&&(this.history.push(this.batchCommands.slice()),this.step++),this.isBatchCommand=!1,this.batchCommands=[]}undo(){if(this.canUndo())return!1;this.step--;let e=this.history[this.step];return e&&(Array.isArray(e)?e.forEach((e=>e.undo())):e.undo()),!0}redo(){if(this.canRedo())return!1;this.step++;let e=this.history[this.step-1];return e&&(Array.isArray(e)?e.forEach((e=>e.redo())):e.redo()),!0}getCommands(){return this.history}canUndo(){return this.step<=0}canRedo(){return this.step>=this.history.length}clear(){this.history=[],this.step=0}destroy(){this.clear(),this.maxCount=0}},ky=class extends Vo{constructor(e,t){super("AddMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}redo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}},TR=class extends Vo{constructor(e,t,n){super("UpdateMarkup"),this.manager=e,this.oldData=t,this.newData=n}undo(){let e=this.manager.getMarkupById(this.oldData.id);return!!e&&(this.manager.updateMarkup(e,this.oldData),!0)}redo(){let e=this.manager.getMarkupById(this.newData.id);return!!e&&(this.manager.updateMarkup(e,this.newData),!0)}},Ip=class extends Vo{constructor(e,t){super("RemoveMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}redo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}},Vy=class extends Vo{constructor(e,t){super("AddMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.getMeasurementById(this.data.id);return!!e&&(this.manager.removeMeasurement(e),!0)}redo(){let e=this.manager.createMeasurement(this.data);return!!e&&(this.manager.addMeasurement(e),!0)}},Ov=class extends Vo{constructor(e,t){super("RemoveMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.createMeasurement(this.data);return!!e&&(this.manager.addMeasurement(e),!0)}redo(){let e=this.manager.getMeasurementById(this.data.id);return!!e&&(this.manager.removeMeasurement(e),!0)}},oue=new M,zy=50,Gy=class extends Xi{constructor(e,t){var n;super(),this.drawableList=new Pl("markup"),this.lineWidth=2,this.lineColor="#ff0000",this.fillColor="rgba(255, 0, 0, 0.3)",this.fontSize=20,this.mouseDown=!1,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.isSelectLeaderText=!1,this.isDrawing=!1,this.tempPoints=[],this.activated=!1,this.handleInputMousemove=e=>{var t;if(!this.mouseDown&&"CloudRectWithTextMarkup"===this.type&&this.isDrawing&&this.textInput&&this.creatingShape){let n=nn.getScreenPointByEvent(e,this.viewerCanvas),i=n.clone().sub(this.mousedownPoint).normalize().cross(new Q(0,-1))<0,r=this.textInput.value,a=(null==(t=this.overlayRender)?void 0:t.measureTextLength(r,`${this.fontSize}px Arial`))||zy;this.textInput.style.left=`${i?n.x:n.x-10-a}px`,this.textInput.style.top=`${n.y}px`;let s=nn.screenPoint2worldPosition(n,this.camera,this.viewerCanvas);this.creatingShape.updateTextPosition(s),this.render()}},this.mousedown=e=>{var t;if(e.pointers&&e.pointers.length>1)return;let n=this.pickThreejsPositionByMouse(e);if(this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,this.mousedownPoint=new Q(e.x,e.y),0===e.button&&(this.mouseDown=!0),2!==e.button){if(this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0,this.render()),!this.isDrawing){let e=this.drawableList.getDrawableByPosition(n);e&&(this.selectedShape=e,e.selected=!0,e instanceof Sv&&(this.isSelectLeaderText=e.isLeaderTextSelected(n)),this.render())}if(this.textInput&&(this.textInput.style.display="none"),this.isCreateTextMode()&&this.mouseDown&&!this.selectedShape&&((!this.textInitialPosition||this.textInput&&0===this.textInput.value.length)&&(this.textInitialPosition=n.clone()),this.addInput(e.x,e.y-5)),this.isCreateLineMode()&&this.mouseDown&&!this.selectedShape){if(this.tempPoints.length>0){let e=this.tempPoints[0];if(oue.subVectors(e,n).length()<5*this.viewer.getPixelSizeInWorldCoord())return n=this.tempPoints[0].clone(),this.tempPoints.push(n),void this.endDraw(this.creatingShape)}if(this.isDrawing=!0,this.tempPoints.push(n),!this.creatingShape){let e=this.creatingShape=this.drawLine([...this.tempPoints,n]);e&&this.addMarkup(e,!1)}this.creatingShape&&(this.creatingShape.update([...this.tempPoints,n]),this.render()),this.dispatchEvent("StartDraw",this.creatingShape)}if(this.isCreateDotMode()&&this.mouseDown&&!this.selectedShape){if(!this.creatingShape){let e=this.creatingShape=this.drawShape(n);e&&this.addMarkup(e,!1)}this.isDrawing=!0,this.render()}null==(t=this.creatingShape)||t.setTolerance(this.viewer.getPixelSizeInWorldCoord())}else this.isDrawing&&this.endDraw(this.creatingShape)},this.mousemove=e=>{if(e.pointers&&e.pointers.length>1)return;let t=this.pickThreejsPositionByMouse(e);if(this.selectedShape){if(this.mouseDown&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){this.isEditing()||(this.initialDataForEditing=this.selectedShape.getData());let e=t.x-this.mouseDownPositionX,n=t.y-this.mouseDownPositionY;this.selectedShape instanceof Sv&&this.isSelectLeaderText?this.selectedShape.translateLeaderText(e,n):this.selectedShape.translate(e,n),this.render(),this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y}}else{if(this.isCreateDotMode())return;if(this.mouseDown&&this.isCreateShapeMode()&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){let e=new M(this.mouseDownPositionX,this.mouseDownPositionY,0);if(!this.creatingShape){let n=this.creatingShape=this.drawShape(e,t);n&&this.addMarkup(n,!1)}this.creatingShape.update([e,t]),this.isDrawing=!0,this.render()}if(this.isCreateLineMode()&&this.tempPoints.length>0&&this.isDrawing){let e=this.tempPoints[0];oue.subVectors(e,t).length()<5*this.viewer.getPixelSizeInWorldCoord()&&(t=this.tempPoints[0].clone()),this.creatingShape.update([...this.tempPoints,t]),this.render()}}},this.mouseup=e=>{if(this.mouseDown=!1,this.selectedShape&&this.isEditing()&&this.endEdit(this.selectedShape),this.isCreateShapeMode()&&this.isDrawing)if("LeaderLineMarkup"===this.type&&this.creatingShape)this.addInput(e.x,e.y+this.fontSize);else if("CloudRectWithTextMarkup"===this.type){let t=this.fontSize,n=new Q(e.x,e.y).sub(this.mousedownPoint).normalize().cross(new Q(0,-1))<0;this.addInput(n?e.x+3:e.x+3+5,e.y+this.fontSize-t)}else this.endDraw(this.creatingShape)},this.keydown=e=>{var t,n;"Delete"===e.code?this.selectedShape&&(this.viewer.hasEventListener("BeforeRemoveMarkup")?this.viewer.dispatchEvent("BeforeRemoveMarkup",this.confirmToRemove.bind(this)):(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Ip(this,this.selectedShape.getData())),this.selectedShape=void 0)):"Escape"===e.code&&("CloudRectWithTextMarkup"===this.type&&(null==(n=this.textInput)||n.blur()),this.cancelDraw(this.creatingShape))},this.viewer=e,this.inputManager=t,this.overlayRender=this.viewer.overlayRender,null==(n=this.overlayRender)||n.addDrawableList(this.drawableList)}get viewerCanvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}setMarkupVisibility(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setMarkupsVisibility(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clearAll(){this.drawableList.clear(),this.textInput&&(this.textInput.style.display="none"),this.isDrawing&&this.reset(),this.render()}isMarkupActive(){return this.activated}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.isDrawing&&this.endDraw(this.creatingShape),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("StartDraw",(()=>{this.exitButton&&(this.exitButton.style.display="inline")})),this.addEventListener("EndDraw",(()=>{this.exitButton&&(this.exitButton.style.display="none")})),this.exitButton}activate(){this.activated=!0,tn.isMobile?(this.inputManager.addEventListener("touchstart",this.mousedown),this.inputManager.addEventListener("touchmove",this.mousemove),this.inputManager.addEventListener("touchend",this.mouseup)):(this.inputManager.addEventListener("mousedown",this.mousedown),this.inputManager.addEventListener("mousemove",this.mousemove),this.inputManager.addEventListener("mouseup",this.mouseup)),this.inputManager.addEventListener("keydown",this.keydown),window.addEventListener("mousemove",this.handleInputMousemove);let e=this.viewer.controls;this.tempKey=e.mouseButtons.left,e.mouseButtons.left=Ve.NONE,this.tempTouch=e.touches.one,e.touches.one=Ve.NONE,this.tempArrowKeys=e.keys,e.keys={},this.render()}deactivate(){this.activated=!1,tn.isMobile?(this.inputManager.removeEventListener("touchstart",this.mousedown),this.inputManager.removeEventListener("touchmove",this.mousemove),this.inputManager.removeEventListener("touchend",this.mouseup)):(this.inputManager.removeEventListener("mousedown",this.mousedown),this.inputManager.removeEventListener("mousemove",this.mousemove),this.inputManager.removeEventListener("mouseup",this.mouseup)),this.inputManager.removeEventListener("keydown",this.keydown),window.removeEventListener("mousemove",this.handleInputMousemove),this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.keys=this.tempArrowKeys,this.viewer.controls.touches.one=this.tempTouch,this.textInput&&(this.textInput.onkeydown=null),this.textInput&&(this.textInput.onkeyup=null),this.textInput&&(this.textInput.onblur=null),this.textInput&&this.textInput.remove(),this.textInput=void 0,this.textInitialPosition=void 0,this.mouseDown=!1,this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}getActiveMarkupType(){return this.type}setDrawType(e){this.type=e,this.reset()}setLineWidth(e){this.lineWidth=e}getLineWidth(){return this.lineWidth}setLineColor(e){this.lineColor=e}getLineColor(){return this.lineColor}setFillColor(e){this.fillColor=e}getFillColor(){return this.fillColor}setFontSize(e){this.fontSize=e}getFontSize(){return this.fontSize}pickPositionByScreenPoint(e){let t=new M,n=nn.screenPoint2NdcPoint(e,this.camera,this.viewerCanvas);this.raycaster.layers.set(10),this.raycaster.setFromCamera(n,this.camera);let i=this.viewer.scene,r=this.raycaster.intersectObject(this.viewer.groundPlane||i)||[];return r.length>0&&t.copy(r[0].point),t}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new Q(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Ip(this,this.selectedShape.getData())),this.selectedShape=void 0)}isEditing(){return!!this.initialDataForEditing}endEdit(e){var t;if(!this.initialDataForEditing)return;let n=e.getData();this.viewer.dispatchEvent("MarkupUpdated",{oldData:this.initialDataForEditing,newData:n}),this.dispatchEvent("EndEdit",e),null==(t=this.viewer.undoRedoManager)||t.addCommand(new TR(this,this.initialDataForEditing,n)),this.initialDataForEditing=void 0,this.isSelectLeaderText=!1}endDraw(e){var t;if("PolylineMarkup"===this.type&&this.creatingShape&&(this.tempPoints.length<2?(this.removeMarkup(this.creatingShape,!1),this.creatingShape=void 0):this.creatingShape.update(this.tempPoints)),e){let n=e.getData();this.viewer.dispatchEvent("MarkupAdded",n),null==(t=this.viewer.undoRedoManager)||t.addCommand(new ky(this,n))}this.dispatchEvent("EndDraw",e),this.reset()}cancelDraw(e){e&&this.removeMarkup(e,!1),this.reset()}reset(){this.textInput&&(this.textInput.style.display="none",this.textInput.value=""),this.textInitialPosition=void 0,this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.mousedownPoint=void 0,this.isSelectLeaderText=!1,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}render(){var e;null==(e=this.overlayRender)||e.render()}addMarkup(e,t=!0){this.drawableList.addDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupAdded",e.getData())}updateMarkup(e,t,n=!0){this.drawableList.updateDrawable(e,t),this.render(),n&&this.viewer.dispatchEvent("MarkupUpdated",{oldData:e.getData(),newData:t})}removeMarkup(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupRemoved",e.getData())}removeMarkupById(e){let t=this.getMarkupById(e);return!!t&&(this.removeMarkup(t,!1),!0)}createMarkup(e){return $t.createDrawable(e)}getMarkupById(e){return this.drawableList.getDrawableById(e)}getMarkupData(){return this.drawableList.getDrawableDatas()}setMarkupData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.addMarkup(this.createMarkup(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new ky(this,e))})),null==(n=this.viewer.undoRedoManager)||n.endTransaction(),this.render()}isCreateLineMode(){return["PolylineMarkup","CloudLineMarkup"].includes(this.type)}isCreateDotMode(){return["DotMarkup"].includes(this.type)}isCreateTextMode(){return["TextMarkup"].includes(this.type)}isCreateShapeMode(){return["XMarkup","RectMarkup","CloudRectMarkup","CircleMarkup","EllipseMarkup","ArrowMarkup","LeaderLineMarkup","CloudRectWithTextMarkup","DotMarkup"].includes(this.type)}drawShape(e,t){let n=[[e.x,e.y]];return t&&n.push([t.x,t.y]),$t.createDrawable({id:it.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:n})}drawLine(e){return $t.createDrawable({id:it.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:e.map((e=>[e.x,e.y]))})}drawText(e,t){return $t.createDrawable({id:it.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize*this.viewer.getPixelSizeInWorldCoord(),type:this.type,text:t,points:[[e.x,e.y]]})}addInput(e,t){var n;if(!this.textInput){let e,t=document.createElement("textarea");t.style.cssText=`\n position: absolute;\n border: 1px solid red;\n background: transparent;\n outline: none;\n resize: none;\n overflow: hidden;\n z-index: 1000;\n box-sizing: content-box;\n padding: 5px;\n whiteSpace: 'nowrap';\n color: ${this.lineColor}`,t.setAttribute("wrap","off"),t.onkeydown=n=>{var i,r;this.isDrawing=!0;let a=n.target;if("Enter"===n.key){let e=parseInt(t.style.height);t.style.height=`${Math.round(e+this.fontSize)}px`}else if("Escape"===n.code)"CloudRectWithTextMarkup"===this.type&&(null==(i=this.textInput)||i.blur());else{let t=a.value,n=(null==(r=this.overlayRender)?void 0:r.measureTextLength(t,`${this.fontSize}px Arial`))||0;if(n>zy){if(["CloudRectWithTextMarkup","LeaderLineMarkup"].includes(this.type)){let t=a.getBoundingClientRect();new Q(t.x,t.y).sub(this.mousedownPoint).normalize().cross(new Q(0,-1))<0||(e||(e=parseFloat(a.style.left)),a.style.left=`${Math.round(e-(n-zy)-this.fontSize)}px`)}a.style.width=`${Math.round(n+4+this.fontSize)}px`}}},t.onclick=()=>{"CloudRectWithTextMarkup"===this.type&&t.blur()},t.onfocus=()=>{"CloudRectWithTextMarkup"===this.type&&this.inputManager.setEnable(!1)},t.onblur=t=>{var n,i;let r=t.target.value;if(r.length>0){let e=this.viewer.getPixelSizeInWorldCoord();if("TextMarkup"===this.type&&this.textInitialPosition){let t=this.creatingShape=this.drawText(this.textInitialPosition,r);t.setTolerance(e),this.addMarkup(t,!1)}["CloudRectWithTextMarkup","LeaderLineMarkup"].includes(this.type)&&(this.creatingShape.updateText(r),this.creatingShape.setFontSize(this.fontSize*e)),this.endDraw(this.creatingShape)}else"CloudRectWithTextMarkup"===this.type&&(this.creatingShape.enableLeaderLine(!1),this.endDraw(this.creatingShape),null==(n=this.viewerCanvas)||n.focus()),"LeaderLineMarkup"===this.type&&(this.cancelDraw(this.creatingShape),null==(i=this.viewerCanvas)||i.focus());e=void 0,this.inputManager.setEnable(!0)},null==(n=this.viewer.viewerContainer)||n.appendChild(t),this.textInput=t}setTimeout((()=>{var e,t;null==(e=this.textInput)||e.blur(),null==(t=this.textInput)||t.focus()}),0),this.textInput.style.width=`${zy}px`,this.textInput.style.height=`${this.fontSize}px`,this.textInput.style.lineHeight=`${this.fontSize}px`,this.textInput.style.fontSize=`${this.fontSize}px`,this.textInput.style.color=this.lineColor,this.textInput.style.display="inline-block",["CloudRectWithTextMarkup","LeaderLineMarkup"].includes(this.type)?(new Q(e,t).sub(this.mousedownPoint).normalize().cross(new Q(0,-1))<0?this.textInput.style.left=e+4+"px":this.textInput.style.left=e-10-4-zy+"px",this.textInput.style.top=t+5+"px"):(this.textInput.style.left=e+4+"px",this.textInput.style.top=t+5+"px")}destroy(){this.deactivate(),this.clearAll()}},lue=new M,Dp=class extends ns{constructor(e,t){super(e),this.lineSegments=[],this.boxes=t,this.lineColor="red",this.lineWidth=2,this.calculateCloudLineSegments(t)}calculateCloudLineSegments(e){var t;for(let n=0;n<e.length;n++){let i=e[n],r=[new M(i.min.x,i.min.y),new M(i.max.x,i.min.y),new M(i.max.x,i.max.y),new M(i.min.x,i.max.y),new M(i.min.x,i.min.y)],a=lue.subVectors(r[0],r[2]).length()/10||1e-4,s=[];for(let e=0;e<r.length-1;e++){let t=r[e],n=r[e+1],i=lue.subVectors(n,t),o=i.length(),l=i.normalize(),h=Math.ceil(o/a);for(let e=0;e<h;e++)s.push(t.clone().add(l.clone().multiplyScalar(a*e)))}s.push(s[0]),null==(t=this.lineSegments)||t.push(s)}}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=this.lineColor,e.fillStyle=this.fillColor;for(let n=0;n<this.lineSegments.length;n++){let i=this.lineSegments[n];this.drawBox(e,t,i)}}drawBox(e,t,n){e.beginPath();for(let i=0;i<n.length-1;i++){let r=this.transToScreenCoord(n[i],t),a=this.transToScreenCoord(n[i+1],t),s=Il.getControlPointByTwoPoints(a,r);0===i&&e.moveTo(r.x,r.y),e.quadraticCurveTo(s.x,s.y,a.x,a.y)}e.stroke()}drawSelect(e,t){throw new Error("Method not implemented.")}isPointInPath(e){return!1}getBounds(){let e=new lt;for(let t=0;t<this.boxes.length;t++){let n=this.boxes[t];e.union(n)}return e}getClassType(){return"CompareDrawable"}};$t._registerDrawableClass(Dp);var wR="BYLAYER",d5="BYBLOCK",cue=(e=>(e[e.Mesh=-1]="Mesh",e[e.MeshWithPattern=0]="MeshWithPattern",e[e.LineWithWidth=1]="LineWithWidth",e[e.Line=2]="Line",e[e.LineWithPattern=3]="LineWithPattern",e[e.Point=4]="Point",e[e.Text=5]="Text",e))(cue||{}),Lp=["INSERT","DIMENSION"],wDt=wi(pue(),1),MR=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215],Nv=class{constructor(){this.pointer=0,this.eof=!1}},m5=wi(mue(),1),wd=class{constructor(e,t){this.endian=t&&"big"===t?"big":"little",this.position=0,this.data=new DataView(e)}readAsciiString(e){if(this.data.byteLength<this.position+e)throw"range error";let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(this.data.getInt8(this.position+n));return this.position+=e,t}readUtf8String(e){let t=this.readBytes(e);return this.decoder||(this.decoder=new TextDecoder("utf-8")),this.decoder.decode(t)}readBytes(e=1){if(this.data.byteLength<this.position+e)throw"range error";let t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=this.data.getUint8(this.position+n);return this.position+=e,t}readUint8(){if(this.data.byteLength<this.position+1)throw"range error";let e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){if(this.data.byteLength<this.position+1)throw"range error";let e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(){if(this.data.byteLength<this.position+2)throw"range error";let e=this.data.getUint16(this.position,"little"===this.endian);return this.position+=2,e}readInt16(){if(this.data.byteLength<this.position+2)throw"range error";let e=this.data.getInt16(this.position,"little"===this.endian);return this.position+=2,e}readUint32(){if(this.data.byteLength<this.position+4)throw"range error";let e=this.data.getUint32(this.position,"little"===this.endian);return this.position+=4,e}readInt32(){if(this.data.byteLength<this.position+4)throw"range error";let e=this.data.getInt32(this.position,"little"===this.endian);return this.position+=4,e}readFloat32(){if(this.data.byteLength<this.position+4)throw"range error";let e=this.data.getFloat32(this.position,"little"===this.endian);return this.position+=4,e}readFloat64(){if(this.data.byteLength<this.position+8)throw"range error";let e=this.data.getFloat64(this.position,"little"===this.endian);return this.position+=8,e}readInt64(){if(this.data.byteLength<this.position+8)throw"range error";let e=m5.default.DataViewGetBigInt64(this.data,this.position,"little"===this.endian);return this.position+=8,e}readUint64(){if(this.data.byteLength<this.position+8)throw"range error";let e=m5.default.DataViewGetBigUint64(this.data,this.position,"little"===this.endian);return this.position+=8,e}getPosition(){return this.position}setPosition(e){if(this.data.byteLength<e)throw"range error";this.position=e}isEnd(){return this.position===this.data.byteLength-1}},gue=1e3,Wy=class extends Nv{constructor(e){super(),this.int8Array=new Int8Array(gue),this.caches=new Map,this.reader=new wd(e);let t=this.reader.readBytes(22),n="";for(let i=0;i<18;i++)n+=String.fromCharCode(t[i]);if("AutoCAD Binary DXF"!=n)throw new Error("Invalid DXF file")}next(){if(!this.hasNext())throw this.eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file.");let e={code:this.reader.readInt16()};return e.value=this.parseGroupValue(e.code),0===e.code&&"EOF"===e.value&&(this.eof=!0),this.lastReadGroup=e,e}hasNext(){return!this.eof&&!this.reader.isEnd()}isEOF(){return this.eof}parseGroupValue(e){if(e>=0&&e<=9)return this.readNullTerminatedString();if(e>=10&&e<=59)return this.reader.readFloat64();if(e>=60&&e<=79)return this.reader.readInt16();if(e>=90&&e<=99)return this.reader.readInt32();if(e>=100&&e<=109)return this.readNullTerminatedString();if(e>=110&&e<=149)return this.reader.readFloat64();if(e>=160&&e<=169)return this.reader.readInt64();if(e>=170&&e<=179)return this.reader.readInt16();if(e>=210&&e<=239)return this.reader.readFloat64();if(e>=270&&e<=289)return this.reader.readInt16();if(e>=290&&e<=299)return this.reader.readInt8()>0;if(e>=300&&e<=309)return this.readNullTerminatedString();if(e>=310&&e<=319)return vue(this.ReadBinaryData());if(e>=320&&e<=369)return this.readNullTerminatedString();if(e>=370&&e<=389)return this.reader.readInt16();if(e>=390&&e<=399)return this.readNullTerminatedString();if(e>=400&&e<=409)return this.reader.readInt16();if(e>=410&&e<=419)return this.readNullTerminatedString();if(e>=420&&e<=429)return this.reader.readInt32();if(e>=430&&e<=439)return this.readNullTerminatedString();if(e>=440&&e<=459)return this.reader.readInt32();if(e>=460&&e<=469)return this.reader.readFloat64();if(e>=470&&e<=481)return this.readNullTerminatedString();if(999===e)throw new Error("The comment group 999, is not used in binary DXF files at byte address!");return 1004===e?vue(this.ReadBinaryData()):e>=1e3&&e<=1009?this.readNullTerminatedString():e>=1010&&e<=1059?this.reader.readFloat64():e>=1060&&e<=1070?this.reader.readInt16():1071===e?this.reader.readInt32():void $.warn(`[DxfBinReader] Invalid code '${e}' at byte address ${this.reader.getPosition()}`)}readNullTerminatedString(){var e;this.decoder||(this.decoder=new TextDecoder("utf-8"));let t=0,n=this.reader.readInt8();for(;0!==n;)this.int8Array[t++]=n,n=this.reader.readInt8();if(0===t)return"";if(t>gue)return $.warn(`[DxfBinReader] Failed to read string! The number of bytes is ${t} !`),"";let i=this.int8Array.subarray(0,t),r=i.toString();if(this.caches.get(r))return this.caches.get(r);let a=null==(e=this.decoder)?void 0:e.decode(i);return this.caches.set(r,a),a}ReadBinaryData(){let e=this.reader.readUint8();return this.reader.readBytes(e)}};function vue(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var Uv=class extends Nv{constructor(e){super(),this.data=e}next(){if(!this.hasNext())throw this.eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this.data[this.pointer]);let e={code:parseInt(this.data[this.pointer])};return this.pointer++,e.value=Eit(e.code,this.data[this.pointer].trim()),this.pointer++,0===e.code&&"EOF"===e.value&&(this.eof=!0),this.lastReadGroup=e,e}hasNext(){return!(this.eof||this.pointer>this.data.length-2)}isEOF(){return this.eof}};function Eit(e,t){return e>=0&&e<=9?t:e>=10&&e<=59?parseFloat(t):e>=60&&e<=99?parseInt(t):e>=100&&e<=109?t:e>=110&&e<=149?parseFloat(t):e>=160&&e<=179?parseInt(t):e>=210&&e<=239?parseFloat(t):e>=270&&e<=289?parseInt(t):e>=290&&e<=299?bit(t):e>=300&&e<=369?t:e>=370&&e<=389?parseInt(t):e>=390&&e<=399?t:e>=400&&e<=409?parseInt(t):e>=410&&e<=419?t:e>=420&&e<=429?parseInt(t):e>=430&&e<=439?t:e>=440&&e<=459?parseInt(t):e>=460&&e<=469?parseFloat(t):e>=470&&e<=481||999===e||e>=1e3&&e<=1009?t:e>=1010&&e<=1059?parseFloat(t):e>=1060&&e<=1071?parseInt(t):($.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function bit(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var Eue=wi(Ll(),1),_it="OriginalHandle",Tit="OriginalType",wit="Outlines",xue=["PROXY","REGION","INSERT","HATCH"];function Op(e){return MR[e]}function Ke(e){let t={},n=e.lastReadGroup,i=n.code;if(t.x=n.value,i+=10,n=e.next(),n.code!=i)throw new Error(`Expected code for point value to be ${i} but got ${n.code}`);return t.y=n.value,i+=10,n=e.next(),n.code!=i||(t.z=n.value,e.next()),t}function yue(e,t){let n=e.lastReadGroup,i=[];for(let r=0;r<16;r++){if(n.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${n.code}`);i.push(n.value),n=e.next()}return i}function Gt(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 6:e.lineType=t.value.toUpperCase();break;case 8:e.layer=t.value;break;case 48:e.lineTypeScale=t.value,e.lineTypeScale<=0&&(e.lineTypeScale=1);break;case 60:e.visible=0===t.value;break;case 62:e.isTrueColor||(e.colorIndex=t.value,e.colorIndex<0&&$.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=Op(Math.abs(t.value)));break;case 67:e.inPaperSpace=0!==t.value;break;case 100:case 1001:break;case 330:e.ownerHandle=t.value;break;case 347:e.materialObjectHandle=t.value;break;case 370:e.lineweight=t.value;break;case 410:e.layoutName=t.value;break;case 420:e.isTrueColor=!0,e.color=t.value;break;case 1e3:if(t.value&&t.value.includes(_it)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalHandle=n[1]}if(e.extendedData&&e.extendedData.outlines)try{e.extendedData.outlines=JSON.parse(t.value||"[]")}catch(t){e.extendedData.outlines=void 0}if(t.value&&t.value.includes(wit)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(Tit)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalType=n[1]}break;default:return!1}return!0}function zo(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 330:e.ownerHandle=t.value;break;case 1e3:case 1001:break;default:return!1}return!0}var Xy=class{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:if(0!==t.value){let e=Math.log2(t.value)-1;n.vertices.splice(e,1)}t=e.next();break;case 10:n.vertices=Mit(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}};function Mit(e,t){let n=[],i=!1,r=!1;for(let a=0;a<=4;a++){let a={};for(;!e.isEOF()&&0!==t.code&&!r;){switch(t.code){case 10:case 11:case 12:case 13:if(i){r=!0;continue}a.x=t.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=t.value;break;case 30:case 31:case 32:case 33:a.z=t.value;break;default:return n}t=e.next()}(0,Eue.isEmpty)(a)||n.push(a),i=!1,r=!1}return n}var Yy=class{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ke(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:n.endAngle=Math.PI/180*t.value,n.angleLength=n.endAngle-n.startAngle,t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},$y=class{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ke(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ke(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},Zy=class{constructor(){this.ForEntityName="ATTRIB"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ke(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ke(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},Ky=class{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ke(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:let i=Math.PI/180*t.value;i<n.startAngle?n.angleLength=i+2*Math.PI-n.startAngle:n.angleLength=i-n.startAngle,n.endAngle=i,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},Jy=class{constructor(){this.ForEntityName="DIMENSION"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:n.block=t.value,t=e.next();break;case 3:n.dimStyleName=t.value,t=e.next();break;case 10:n.anchorPoint=Ke(e),t=e.lastReadGroup;break;case 11:n.middleOfText=Ke(e),t=e.lastReadGroup;break;case 12:n.insertionPoint=Ke(e),t=e.lastReadGroup;break;case 13:n.linearOrAngularPoint1=Ke(e),t=e.lastReadGroup;break;case 14:n.linearOrAngularPoint2=Ke(e),t=e.lastReadGroup;break;case 15:n.diameterOrRadiusPoint=Ke(e),t=e.lastReadGroup;break;case 16:n.arcPoint=Ke(e),t=e.lastReadGroup;break;case 70:n.dimensionType=t.value,t=e.next();break;case 71:n.attachmentPoint=t.value,t=e.next();break;case 42:n.actualMeasurement=t.value,t=e.next();break;case 1:n.text=t.value,t=e.next();break;case 50:n.angle=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},Qy=class{constructor(){this.ForEntityName="ELLIPSE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ke(e),t=e.lastReadGroup;break;case 11:n.majorAxisEndPoint=Ke(e),t=e.lastReadGroup;break;case 40:n.axisRatio=t.value,t=e.next();break;case 41:n.startAngle=t.value,t=e.next();break;case 42:n.endAngle=t.value,t=e.next();break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 2:n.name=t.value,t=e.next();break;default:Gt(n,t),t=e.next()}return n}},Np=class{constructor(e){this.type=e}},g5=class extends Np{constructor(){super(0),this.points=[],this.isClosed=!0}},v5=class extends Np{constructor(){super(1),this.startPoint={x:0,y:0,z:0},this.endPoint={x:0,y:0,z:0}}},x5=class extends Np{constructor(){super(2),this.center={x:0,y:0,z:0},this.radius=0,this.startAngle=0,this.endAngle=0,this.bCounterclockwise=!1}},y5=class extends Np{constructor(){super(3),this.center={x:0,y:0,z:0},this.majorAxisEndPoint={x:0,y:0,z:0},this.minorRatio=0,this.startAngle=0,this.endAngle=0,this.bCounterclockwise=!1}},E5=class extends Np{constructor(){super(4),this.controlPoints=[],this.numControlPoints=0,this.knotValues=[],this.numKnots=0,this.bPeriodic=!1,this.bRational=!1,this.degreeOfSplineCurve=0}},eE=class{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){let n={type:t.value,boundaryPaths:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:n.patternName=t.value,t=e.next();break;case 10:n.elevationX=t.value,t=e.next();break;case 20:n.elevationY=t.value,t=e.next();break;case 30:n.elevationZ=t.value,t=e.next();break;case 41:n.patternScale=t.value,t=e.next();break;case 47:n.pixelSize=t.value,t=e.next();break;case 52:n.patternAngle=t.value,t=e.next();break;case 63:n.patternFillColor=t.value,t=e.next();break;case 70:n.solidFill=0!=(1&t.value),t=e.next();break;case 71:n.associativity=0!=(1&t.value),t=e.next();break;case 73:n.annotatedBoundary=0!=(1&t.value),t=e.next();break;case 75:n.style=t.value,t=e.next();break;case 76:n.patternType=t.value,t=e.next();break;case 78:n.patternLines=Cit(t.value,e),t=e.lastReadGroup;break;case 91:n.boundaryPathsCount=t.value,n.boundaryPaths=Ait(n.boundaryPathsCount,e),t=e.lastReadGroup;break;case 98:n.seedPointsCount=t.value,t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 450:n.isGradientColor=1===t.value,t=e.next();break;case 451:case 452:case 460:case 461:case 462:case 463:case 470:t=e.next();break;case 453:n.gradientColorCount=t.value,n.gradientColors=Pit(n.gradientColorCount,e),t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}};function Sit(e){let t=new g5,n=e.next(),i=0!==n.value;n=e.next(),t.isClosed=0!==n.value,n=e.next();let r=n.value;n=e.next();for(let s=0;s<r;s++){let r=Ke(e);n=e.lastReadGroup,i&&(r.bulge=n.value,n=e.next()),t.points.push(r)}n=e.lastReadGroup,console.assert(97===n.code,"The reference count code 97 was expected.");let a=n.value;n=e.next();for(let s=0;s<a;s++)console.assert(330===n.code,"The reference handle code 330 was expected."),n=e.next();return{edges:[t],pathTypeFlag:-1}}function Rit(e,t){let n=[],i=t.next();for(;n.length<e;)if(72===i.code)switch(i.value){case 1:{i=t.next();let e=new v5;e.startPoint=Ke(t),e.endPoint=Ke(t),i=t.lastReadGroup,n.push(e);break}case 2:{i=t.next();let e=new x5;e.center=Ke(t),i=t.lastReadGroup,e.radius=i.value,i=t.next(),e.startAngle=i.value,i=t.next(),e.endAngle=i.value,i=t.next(),e.bCounterclockwise=0!==i.value,i=t.next(),n.push(e);break}case 3:{i=t.next();let e=new y5;e.center=Ke(t),e.majorAxisEndPoint=Ke(t),i=t.lastReadGroup,e.minorRatio=i.value,i=t.next(),e.startAngle=i.value,i=t.next(),e.endAngle=i.value,i=t.next(),e.bCounterclockwise=0!==i.value,i=t.next(),n.push(e);break}case 4:{i=t.next();let e=new E5;e.degreeOfSplineCurve=i.value,i=t.next(),e.bRational=0!==i.value,i=t.next(),e.bPeriodic=0!==i.value,i=t.next(),e.numKnots=i.value,i=t.next(),e.numControlPoints=i.value,i=t.next();for(let n=0;n<e.numKnots;n++)e.knotValues.push(i.value),i=t.next();for(let n=0;n<e.numControlPoints;n++){let n=i.value;i=t.next();let r=i.value,a=1;i=t.next(),42===i.code&&(a=i.value,i=t.next()),e.controlPoints.push({x:n,y:r,z:a})}n.push(e);break}default:i=t.next()}else i=t.next();i=t.lastReadGroup,console.assert(97===i.code,"The reference count code 97 was expected.");let r=i.value;i=t.next();for(let a=0;a<r;a++)console.assert(330===i.code,"The reference handle code 330 was expected."),i=t.next();return{edges:n,pathTypeFlag:-1}}function Ait(e,t){let n=[],i=-1,r=t.next();for(;n.length<e;){let e;switch(r.code){case 92:if(i=r.value,2&i){if(e=Sit(t),!e)throw new Error("[Hatch] Failed to parse hatch polyline boundary path !");e.pathTypeFlag=i,n.push(e),r=t.lastReadGroup}else r=t.next();break;case 93:e=Rit(r.value,t),e.pathTypeFlag=i,n.push(e),r=t.lastReadGroup;break;default:r=t.next()}}return n}function Cit(e,t){if(e<=0)return;let n=[],i=t.next();for(let r=0;r<e;r++){let e=0,r={x:0,y:0},a={x:0,y:0},s=-1,o=[];for(;!t.isEOF()&&0!==i.code;){let n=!1;switch(i.code){case 53:e=i.value;break;case 43:r.x=i.value;break;case 44:r.y=i.value;break;case 45:a.x=i.value;break;case 46:a.y=i.value;break;case 79:s=i.value;break;case 49:o.push(i.value);break;default:n=!0}if(i=t.next(),n||o.length===s)break}s>=0&&n.push({angle:e,origin:r,delta:a,dashPattern:o})}return n}function Pit(e,t){let n=[],i=t.next();for(;n.length<e;)switch(i.code){case 63:default:i=t.next();break;case 421:n.push(i.value),i=t.next()}return n}var tE=class{constructor(){this.ForEntityName="IMAGE"}parseEntity(e,t){let n={type:t.value,clippingBoundaryPath:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.position=Ke(e),t=e.lastReadGroup;break;case 11:n.uPixel=Ke(e),t=e.lastReadGroup;break;case 12:n.vPixel=Ke(e),t=e.lastReadGroup;break;case 13:n.imageSize=Ke(e),t=e.lastReadGroup;break;case 340:n.imageDefHandle=t.value,t=e.next();break;case 70:n.flags=t.value,t=e.next();break;case 280:n.clipping=t.value,t=e.next();break;case 281:n.brightness=t.value,t=e.next();break;case 282:n.contrast=t.value,t=e.next();break;case 283:n.fade=t.value,t=e.next();break;case 360:n.imageDefReactorHandle=t.value,t=e.next();break;case 71:n.clippingBoundaryType=t.value,t=e.next();break;case 91:n.countBoundaryPoints=t.value,t=e.next();break;case 14:n.clippingBoundaryPath.push(Ke(e)),t=e.lastReadGroup;break;case 290:n.clipMode=t.value,t=e.next();default:Gt(n,t),t=e.next()}return n}},nE=class{constructor(){this.ForEntityName="INSERT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:n.block=t.value,t=e.next();break;case 66:n.attributesFollow=0!=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 42:n.yScale=t.value,t=e.next();break;case 43:n.zScale=t.value,t=e.next();break;case 10:n.position=Ke(e),t=e.lastReadGroup;break;case 50:n.rotation=t.value,t=e.next();break;case 70:n.columnCount=t.value,t=e.next();break;case 71:n.rowCount=t.value,t=e.next();break;case 44:n.columnSpacing=t.value,t=e.next();break;case 45:n.rowSpacing=t.value,t=e.next();break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},rE=class{constructor(){this.ForEntityName="LEADER"}parseEntity(e,t){let n={type:t.value,arrowFlag:1,vertices:[]};t=e.next();let i=!1;for(;!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.push(Ke(e)),t=e.lastReadGroup;break;case 3:n.dimensionStyle=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.textWidth=t.value,t=e.next();break;case 71:n.arrowFlag=t.value,t=e.next();break;case 72:n.pathType=t.value,t=e.next();break;case 73:n.creationFlag=t.value,t=e.next();break;case 74:n.direction=t.value,t=e.next();break;case 75:n.hasHookline=1===t.value,t=e.next();break;case 1001:i="ACAD"===t.value,t=e.next();break;case 1070:if(i){let i=Iit(t.value);i&&(1005==(t=e.next()).code||1040==t.code||1070==t.code)&&("DIMLDRBLK"===i&&(n.arrowHeadBlockHandle=t.value),"DIMASZ"===i&&(n.arrowHeight=t.value),"DIMSCALE"===i&&(n.arrowHeadScale=t.value),"DIMCLRD"===i&&t.value>0&&(n.colorIndex=t.value,n.color=Op(Math.abs(t.value))))}t=e.next();break;default:Gt(n,t),t=e.next()}return n}};function Iit(e){switch(e){case 40:return"DIMSCALE";case 41:return"DIMASZ";case 42:return"DIMEXO";case 44:return"DIMEXE";case 75:return"DIMSE1";case 76:return"DIMSE2";case 77:return"DIMTAD";case 140:return"DIMTXT";case 144:return"DIMLFAC";case 147:return"DIMGAP";case 176:return"DIMCLRD";case 178:return"DIMCLRT";case 271:return"DIMDEC";case 341:return"DIMLDRBLK";default:return null}}var iE=class{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ke(e)),t=e.lastReadGroup;break;case 11:n.vertices.push(Ke(e)),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},sE=class{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]},i=0;for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 38:n.elevation=t.value,t=e.next();break;case 39:n.thickness=t.value,t=e.next();break;case 70:n.shape=1==(1&t.value),n.hasContinuousLinetypePattern=128==(128&t.value),t=e.next();break;case 90:i=t.value,t=e.next();break;case 10:n.vertices.push(...Dit(i,e)),t=e.lastReadGroup;break;case 43:0!==t.value&&(n.constantWidth=t.value),t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}};function Dit(e,t){if(!e||e<=0)throw Error("n must be greater than 0 verticies");let n=[],i=!1,r=!1,a=t.lastReadGroup,s={};for(;!t.isEOF()&&0!==a.code&&!r;)switch(a.code){case 10:if(i){r=!0;continue}s.x=a.value,i=!0,a=t.next();break;case 20:s.y=a.value,a=t.next();break;case 30:s.z=a.value,a=t.next();break;case 40:s.startWidth=a.value,a=t.next();break;case 41:s.endWidth=a.value,a=t.next();break;case 42:0!=a.value&&(s.bulge=a.value),a=t.next();break;default:return i&&n.push(s),n}return n.push(s),i=!1,r=!1,n}var aE=class{constructor(){this.ForEntityName="MULTILEADER"}parseEntity(e,t){let n={type:t.value};function i(){for(;!e.isEOF();)switch(t.code){case 40:n.contextData.contentScale=t.value,t=e.next();break;case 10:n.contextData.contentBasePosition=Ke(e),t=e.lastReadGroup;break;case 145:n.contextData.landingGap=t.value,t=e.next();break;case 290:n.contextData.hasMText=t.value,t=e.next();break;case 304:n.contextData.defaultTextContents=t.value,t=e.next();break;case 11:n.contextData.textNormalDirection=Ke(e),t=e.lastReadGroup;break;case 12:n.contextData.textLocation=Ke(e),t=e.lastReadGroup;break;case 13:n.contextData.textDirection=Ke(e),t=e.lastReadGroup;break;case 140:n.contextData.arrowHeadSize=t.value,t=e.next();break;case 41:n.contextData.textHeight=t.value,t=e.next();break;case 42:n.contextData.textRotation=t.value,t=e.next();break;case 43:n.contextData.textWidth=t.value,t=e.next();break;case 44:default:t=e.next();break;case 45:n.contextData.textLineSpacingFactor=t.value,t=e.next();break;case 90:n.contextData.textColor=t.value,t=e.next();break;case 170:n.contextData.textLineSpacingStyle=t.value,t=e.next();break;case 171:n.contextData.textAttachment=t.value,t=e.next();break;case 172:n.contextData.textFlowDirection=t.value,t=e.next();break;case 141:n.contextData.textBackgroundScaleFactor=t.value,t=e.next();break;case 92:n.contextData.textBackgroundTransparency=t.value,t=e.next();break;case 291:n.contextData.textBackgroundColorOn=t.value,t=e.next();break;case 292:n.contextData.textBackgroundFillOn=t.value,t=e.next();break;case 293:n.contextData.textUseAutoHeight=t.value,t=e.next();break;case 173:n.contextData.textColumnType=t.value,t=e.next();break;case 142:n.contextData.textColumnWidth=t.value,t=e.next();break;case 143:n.contextData.textColumnGutterWidth=t.value,t=e.next();break;case 144:n.contextData.textColumnHeight=t.value,t=e.next();break;case 295:n.contextData.textUseWordBreak=t.value,t=e.next();break;case 296:n.contextData.hasBlock=t.value,t=e.next();break;case 341:n.contextData.blockContentId=t.value,t=e.next();break;case 14:n.contextData.blockContentNormalDirection=Ke(e),t=e.lastReadGroup;break;case 15:n.contextData.blockContentPosition=Ke(e),t=e.lastReadGroup;break;case 16:n.contextData.blockContentScale=t.value,t=e.next();break;case 46:n.contextData.blockContentRotation=t.value,t=e.next();break;case 93:n.contextData.blockContentColor=t.value,t=e.next();break;case 47:n.contextData.blockTransformationMatrix=yue(e,47),t=e.lastReadGroup;break;case 110:n.contextData.planeOriginPoint=Ke(e),t=e.lastReadGroup;break;case 111:n.contextData.planeXAxisDirection=Ke(e),t=e.lastReadGroup;break;case 112:n.contextData.planeYAxisDirection=Ke(e),t=e.lastReadGroup;break;case 297:n.contextData.planeNormalReversed=t.value,t=e.next();break;case 301:return;case 302:r(),t=e.lastReadGroup}}function r(){let i={leaderLines:[]};for(n.contextData.leaders.push(i);!e.isEOF();)switch(t.code){case 290:i.hasSetLastLeaderLinePoint=t.value,t=e.next();break;case 291:i.hasSetDoglegVector=t.value,t=e.next();break;case 10:i.lastLeaderLinePoint=Ke(e),t=e.lastReadGroup;break;case 11:i.doglegVector=Ke(e),t=e.lastReadGroup;break;case 90:i.leaderBranchIndex=t.value,t=e.next();break;case 40:i.doglegLength=t.value,t=e.next();break;case 303:return;case 304:a(),t=e.lastReadGroup;break;default:t=e.next()}}function a(){let i={vertices:[[]]};for(n.contextData.leaders[n.contextData.leaders.length-1].leaderLines.push(i);!e.isEOF();)switch(t.code){case 10:i.vertices[0].push(Ke(e)),t=e.lastReadGroup;break;case 305:return;default:t=e.next()}}return n.contextData={leaders:[]},t=e.next(),function(){for(;!e.isEOF();)switch(t.code){case 0:return;case 340:n.leaderStyleId=t.value,t=e.next();break;case 170:n.leaderLineType=t.value,t=e.next();break;case 91:n.leaderLineColor=t.value,t=e.next();break;case 341:n.leaderLineTypeId=t.value,t=e.next();break;case 171:n.leaderLineWeight=t.value,t=e.next();break;case 41:n.doglegLength=t.value,t=e.next();break;case 290:n.enableLanding=t.value,t=e.next();break;case 291:n.enableDogLeg=t.value,t=e.next();break;case 342:n.arrowHeadId=t.value,t=e.next();break;case 42:n.arrowHeadSize=t.value,t=e.next();break;case 172:n.contentType=t.value,t=e.next();break;case 173:case 95:n.textLeftAttachmentType=t.value,t=e.next();break;case 174:n.textAngleType=t.value,t=e.next();break;case 175:n.textAlignmentType=t.value,t=e.next();break;case 343:n.textStyleId=t.value,t=e.next();break;case 92:n.textColor=t.value,t=e.next();break;case 292:n.enableFrameText=t.value,t=e.next();break;case 344:n.blockContentId=t.value,t=e.next();break;case 93:n.blockContentColor=t.value,t=e.next();break;case 10:n.blockContentScale=Ke(e),t=e.lastReadGroup;break;case 43:n.blockContentRotation=t.value,t=e.next();break;case 176:n.blockContentConnectionType=t.value,t=e.next();break;case 293:n.enableAnotationScale=t.value,t=e.next();break;case 94:n.arrowHeadIndex=t.value,t=e.next();break;case 177:n.blockAttributeIndex=t.value,t=e.next();break;case 44:n.blockAttributeWidth=t.value,t=e.next();break;case 302:n.blockAttributeTextString=t.value,t=e.next();break;case 294:n.textDirectionNegative=t.value,t=e.next();break;case 178:n.textAlignInIPE=t.value,t=e.next();break;case 179:n.textAttachmentPoint=t.value,t=e.next();break;case 271:n.textAttachmentDirectionMText=t.value,t=e.next();break;case 272:n.textAttachmentDirectionBottom=t.value,t=e.next();break;case 273:n.textAttachmentDirectionTop=t.value,t=e.next();break;case 300:i(),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}}(),n}},oE=class{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 3:case 1:n.text?n.text+=t.value:n.text=t.value,t=e.next();break;case 10:n.position=Ke(e),t=e.lastReadGroup;break;case 7:n.textStyle=t.value,t=e.next();break;case 44:n.lineSpaceFactor=t.value,t=e.next();break;case 11:n.directionVector=Ke(e),n.rotation=void 0,t=e.lastReadGroup;break;case 40:n.height=t.value,t=e.next();break;case 41:n.width=t.value,t=e.next();break;case 50:n.rotation=t.value,n.directionVector=void 0,t=e.next();break;case 71:n.attachmentPoint=t.value,t=e.next();break;case 72:n.drawingDirection=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},lE=class{constructor(){this.ForEntityName="OLE2FRAME"}parseEntity(e,t){let n={type:t.value,binaryData:""};for(t=e.next();"OLE"!==t.value&&0!==t.code;)switch(t.code){case 3:n.documentType=t.value,t=e.next();break;case 70:n.version=t.value,t=e.next();break;case 10:n.leftUpX=t.value,t=e.next();break;case 20:n.leftUpY=t.value,t=e.next();break;case 30:n.leftUpZ=t.value,t=e.next();break;case 11:n.rightDownX=t.value,t=e.next();break;case 21:n.rightDownY=t.value,t=e.next();break;case 31:n.rightDownZ=t.value,t=e.next();break;case 90:n.lengthOfBinaryData=t.value,t=e.next();break;case 310:n.binaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},cE=class{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.position=Ke(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},uE=class{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.x=t.value,t=e.next();break;case 20:n.y=t.value,t=e.next();break;case 30:n.z=t.value,t=e.next();break;case 40:case 41:case 50:t=e.next();break;case 42:0!=t.value&&(n.bulge=t.value),t=e.next();break;case 70:n.curveFittingVertex=0!=(1&t.value),n.curveFitTangent=0!=(2&t.value),n.splineVertex=0!=(8&t.value),n.splineControlPoint=0!=(16&t.value),n.threeDPolylineVertex=0!=(32&t.value),n.threeDPolylineMesh=0!=(64&t.value),n.polyfaceMeshVertex=0!=(128&t.value),t=e.next();break;case 71:n.faceA=t.value,t=e.next();break;case 72:n.faceB=t.value,t=e.next();break;case 73:n.faceC=t.value,t=e.next();break;case 74:n.faceD=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},hE=class{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:case 20:case 30:case 40:case 41:case 71:case 72:case 73:case 74:case 75:t=e.next();break;case 39:t=e.next(),n.thickness=t.value;break;case 70:n.shape=0!=(1&t.value),n.includesCurveFitVertices=0!=(2&t.value),n.includesSplineFitVertices=0!=(4&t.value),n.is3dPolyline=0!=(8&t.value),n.is3dPolygonMesh=0!=(16&t.value),n.is3dPolygonMeshClosed=0!=(32&t.value),n.isPolyfaceMesh=0!=(64&t.value),n.hasContinuousLinetypePattern=0!=(128&t.value),t=e.next();break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n.vertices=Lit(e,t),n}};function Lit(e,t){let n=new uE,i=[];for(;!e.isEOF();)if(0===t.code)if("VERTEX"===t.value)i.push(n.parseEntity(e,t)),t=e.lastReadGroup;else if("SEQEND"===t.value){Oit(e,t);break}return i}function Oit(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)if(101===t.code)for(;0!=t.code;)t=e.next();else Gt(n,t),t=e.next();return n}var dE=class{constructor(){this.ForEntityName="RAY"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ke(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ke(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},fE=class{constructor(){this.ForEntityName="REGION"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:n.modelerVersion=t.value,t=e.next();break;case 1:n.proprietaryData=t.value,t=e.next();break;case 3:n.proprietaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},pE=class{constructor(){this.ForEntityName="SEQEND"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)-2===t.code||(Gt(n,t),t=e.next());return n}},mE=class{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){let n={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.points[0]=Ke(e),t=e.lastReadGroup;break;case 11:n.points[1]=Ke(e),t=e.lastReadGroup;break;case 12:n.points[2]=Ke(e),t=e.lastReadGroup;break;case 13:n.points[3]=Ke(e),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ke(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},gE=class{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.controlPoints||(n.controlPoints=[]),n.controlPoints.push(Ke(e)),t=e.lastReadGroup;break;case 11:n.fitPoints||(n.fitPoints=[]),n.fitPoints.push(Ke(e)),t=e.lastReadGroup;break;case 12:n.startTangent=Ke(e),t=e.lastReadGroup;break;case 13:n.endTangent=Ke(e),t=e.lastReadGroup;break;case 40:n.knotValues||(n.knotValues=[]),n.knotValues.push(t.value),t=e.next();break;case 70:1&t.value&&(n.closed=!0),2&t.value&&(n.periodic=!0),4&t.value&&(n.rational=!0),8&t.value&&(n.planar=!0),16&t.value&&(n.planar=!0,n.linear=!0),t=e.next();break;case 71:n.degreeOfSplineCurve=t.value,t=e.next();break;case 72:n.numberOfKnots=t.value,t=e.next();break;case 73:n.numberOfControlPoints=t.value,t=e.next();break;case 74:n.numberOfFitPoints=t.value,t=e.next();break;case 210:n.normalVector=Ke(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},vE=class{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.startPoint=Ke(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ke(e),t=e.lastReadGroup;break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 1:n.text=t.value,t=e.next();break;case 72:n.halign=t.value,t=e.next();break;case 73:n.valign=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 71:n.mirrored=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},xE=class{constructor(){this.ForEntityName="VIEWPORT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 68:n.viewportStatus=t.value,t=e.next();break;case 40:n.width_paperSpace=t.value,t=e.next();break;case 41:n.height_paperSpace=t.value,t=e.next();break;case 69:n.viewportId=t.value,t=e.next();break;case 10:n.centerPoint=Ke(e),t=e.lastReadGroup;break;case 12:n.centerPoint_dcs=Ke(e),t=e.lastReadGroup;break;case 13:n.snapBasePoint_dcs=Ke(e),t=e.lastReadGroup;break;case 14:n.snapSpacing_dcs=Ke(e),t=e.lastReadGroup;break;case 15:n.gridSpacing_dcs=Ke(e),t=e.lastReadGroup;break;case 16:n.viewDirection=Ke(e),t=e.lastReadGroup;break;case 17:n.viewTarget=Ke(e),t=e.lastReadGroup;break;case 42:n.perspectiveLens=t.value,t=e.next();break;case 43:n.frontClippingPlaneZ=t.value,t=e.next();break;case 44:n.backClippingPlaneZ=t.value,t=e.next();break;case 45:n.viewHeight=t.value,t=e.next();break;case 50:n.snapAngle=t.value,t=e.next();break;case 51:n.viewTwistAngle=t.value,t=e.next();break;case 72:n.circleZoomPercent=t.value,t=e.next();break;case 331:n.frozenLayerHandles=n.frozenLayerHandles||[],n.frozenLayerHandles.push(t.value),t=e.next();break;case 90:n.viewportStatusFlags=t.value,t=e.next();break;case 340:n.viewportClippingBoundaryhandleId=t.value,t=e.next();break;case 1:n.plotStyleSheetName=t.value,t=e.next();break;case 281:n.renderMode=t.value,t=e.next();break;case 71:n.viewportFlag_ucs=t.value,t=e.next();break;case 74:n.ucsIcon=t.value,t=e.next();break;case 110:n.ucsOrigin=Ke(e),t=e.lastReadGroup;break;case 111:n.ucsXAxis=Ke(e),t=e.lastReadGroup;break;case 112:n.ucsYAxis=Ke(e),t=e.lastReadGroup;break;case 345:n.ucsTableRecordHandle=t.value,t=e.next();break;case 346:n.baseUcsTableRecordHandle=t.value,t=e.next();break;case 79:n.orthographicType=t.value,t=e.next();break;case 146:n.elevation=t.value,t=e.next();break;case 170:n.shadePlotMode=t.value,t=e.next();break;case 61:n.frequency=t.value,t=e.next();break;case 292:n.lightingFlag=t.value,t=e.next();break;case 282:n.lightingType=t.value,t=e.next();break;case 141:n.viewBrightness=t.value,t=e.next();break;case 142:n.viewContrast=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},yE=class{constructor(){this.ForEntityName="XLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ke(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ke(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Gt(n,t),t=e.next()}return n}},SR=class{constructor(){this.ForObjectName="DICTIONARY"}parseObject(e,t){let n={type:t.value},i=[],r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 280:n.isHardOwner=1===t.value,t=e.next();break;case 281:n.cloningFlag=t.value,t=e.next();break;case 3:i.push(t.value),t=e.next();break;case 350:case 360:r.push(t.value),t=e.next();break;case 100:case 102:t=e.next();break;default:zo(n,t),t=e.next()}if(i.length!==r.length)throw new Error("The number of Dictionary entries does not match !");return n.entries={},i.forEach(((e,t)=>{n.entries[r[t]]=e})),n}},RR=class{constructor(){this.ForObjectName="IMAGEDEF"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 90:n.classVersion=t.value,t=e.next();break;case 1:n.filename=t.value,t=e.next();break;case 10:n.imageSize=Ke(e),t=e.next();break;case 11:n.pixelSize=Ke(e),t=e.next();break;case 280:n.loaded=t.value,t=e.next();break;case 281:n.resolutionUnits=t.value,t=e.next();break;default:zo(n,t),t=e.next()}return n}},AR=class{constructor(){this.ForObjectName="LAYOUT"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 100:t=e.next();break;case 1:n.layoutName=t.value,t=e.next();break;case 70:n.flag=t.value,t=e.next();break;case 71:n.tabOrder=t.value,t=e.next();break;case 76:n.orthographicType=t.value,t=e.next();break;case 10:n.minLimit=Ke(e),t=e.lastReadGroup;break;case 11:n.maxLimit=Ke(e),t=e.lastReadGroup;break;case 12:n.basePoint=Ke(e),t=e.lastReadGroup;break;case 13:n.origin=Ke(e),t=e.lastReadGroup;break;case 14:n.minExtent=Ke(e),t=e.lastReadGroup;break;case 15:n.maxExtent=Ke(e),t=e.lastReadGroup;break;case 16:n.XAxis=Ke(e),t=e.lastReadGroup;break;case 17:n.YAxis=Ke(e),t=e.lastReadGroup;break;case 146:n.elevation=t.value,t=e.next();break;case 331:n.viewportHandle=t.value,t=e.next();break;default:zo(n,t),t=e.next()}return n.blockTableHandle=n.ownerHandle,n}},CR=class{constructor(){this.ForObjectName="SORTENTSTABLE"}parseObject(e,t){let n={type:t.value},i=!1;n.sortEntsObject={},n.sortEntsObject.entityHandles=[];let r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 5:i?(r.push(t.value),n.sortEntsObject.entityHandles.push(r),r=[]):n.handle=t.value,t=e.next();break;case 100:t=e.next(),i=!0;break;case 102:t=e.next();break;case 330:i?n.sortEntsObject.ownerHandle=t.value:n.ownerHandle=t.value,t=e.next();break;case 331:r.push(t.value),t=e.next();break;default:zo(n,t),t=e.next()}return n}},PR=class{constructor(){this.ForObjectName="SPATIAL_FILTER"}parseObject(e,t){let n,i,r={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 11:r.origin=Ke(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),n=Ke(e),t=e.lastReadGroup,i=Ke(e),t=e.lastReadGroup,r.vertices.push(n,{x:i.x,y:n.y},i,{x:n.x,y:i.y},n)):r.numberOfPointsOnClipBoundary>2?(r.vertices=Nit(r.numberOfPointsOnClipBoundary,e),t=e.lastReadGroup):t=e.next();break;case 71:r.clipBoundaryVisible=1===t.value,t=e.next();break;case 72:r.frontClippingPlaneFlag=1===t.value,t=e.next(),r.frontClippingPlaneFlag&&40===t.code&&(r.frontClippingPlaneDistance=t.value,t=e.next());break;case 73:r.backClippingPlaneFlag=1===t.value,t=e.next(),r.backClippingPlaneFlag&&41===t.code&&(r.backClippingPlaneDistance=t.value,t=e.next());break;case 100:case 102:t=e.next();break;case 210:r.extrusionDirectionX=t.value,t=e.next();break;case 220:r.extrusionDirectionY=t.value,t=e.next();break;case 230:r.extrusionDirectionZ=t.value,t=e.next();break;case 40:r.invertBlockMatrix=bue(e,40),r.matrix=bue(e,40),t=e.lastReadGroup;break;default:zo(r,t),t=e.next()}return r}};function Nit(e,t){t.next();let n=[];for(;n.length<e;)n.push(Ke(t));return n}function bue(e,t){let n=e.lastReadGroup,i=[];for(let r=0;r<12;r++){if(n.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${n.code}`);i.push(n.value),n=e.next()}return i}var IR=class{constructor(){this.ForObjectName="XRECORD"}parseObject(e,t){let n={type:t.value,binaryData:""};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 100:case 311:t=e.next();break;case 280:n.cloningFlag=t.value,t=e.next();break;case 310:n.binaryData+=t.value,t=e.next();break;default:zo(n,t),t=e.next()}return n}};function Uit(e){e.registerEntityHandler(Xy),e.registerEntityHandler(Yy),e.registerEntityHandler($y),e.registerEntityHandler(Zy),e.registerEntityHandler(Ky),e.registerEntityHandler(Jy),e.registerEntityHandler(aE),e.registerEntityHandler(Qy),e.registerEntityHandler(eE),e.registerEntityHandler(tE),e.registerEntityHandler(nE),e.registerEntityHandler(rE),e.registerEntityHandler(iE),e.registerEntityHandler(sE),e.registerEntityHandler(oE),e.registerEntityHandler(lE),e.registerEntityHandler(cE),e.registerEntityHandler(hE),e.registerEntityHandler(fE),e.registerEntityHandler(dE),e.registerEntityHandler(pE),e.registerEntityHandler(mE),e.registerEntityHandler(gE),e.registerEntityHandler(vE),e.registerEntityHandler(xE),e.registerEntityHandler(yE)}function Bit(e){e.registerObjectHandler(SR),e.registerObjectHandler(RR),e.registerObjectHandler(AR),e.registerObjectHandler(CR),e.registerObjectHandler(PR),e.registerObjectHandler(IR)}function Fit(e){let t=new wd(e).readBytes(22),n="";for(let i=0;i<18;i++)n+=String.fromCharCode(t[i]);return"AutoCAD Binary DXF"===n}var Up=class{constructor(){this._entityHandlers={},this._objectHandlers={},this._layoutBlocks={},this.unhandledSections={},this.unhandledObjects={},this.unhandledEntities={},this.unsupportedLineTypes={},Uit(this),Bit(this)}parse(e){if("string"==typeof e){let t=this.splitByLineSeparator(e),n=new Uv(t);return this._parse(n)}{let t;if(Fit(e))t=new Wy(e);else{let n=(new TextDecoder).decode(e),i=Date.now(),r=this.splitByLineSeparator(n);$.info(`[DxfParser] string.split costed ${(Date.now()-i)/1e3}s, it is avoidable by using dxf in binary.`),t=new Uv(r)}return this._parse(t)}}registerEntityHandler(e){let t=new e;this._entityHandlers[t.ForEntityName]=t}registerObjectHandler(e){let t=new e;this._objectHandlers[t.ForObjectName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="",n=this;return new Promise(((i,r)=>{e.on("data",(e=>{t+=e})),e.on("end",(()=>{try{i(n.parse(t))}catch(e){r(e)}})),e.on("error",(e=>{r(e)}))}))}_parse(e){let t={},n=0;if(!e.hasNext())throw Error("Empty file");let i,r=this;function a(){let t=null,n=null,r={};for(i=e.next();;){if(eo(i,0,"ENDSEC")){t&&(r[t]=n);break}9===i.code?(t&&(r[t]=n),t=i.value):10===i.code?n={x:i.value}:20===i.code?n.y=i.value:30===i.code?n.z=i.value:n=i.value,i=e.next()}return i=e.next(),r}function s(){let t={};for(i=e.next();"EOF"!==i.value&&!eo(i,0,"ENDSEC");)if(eo(i,0,"BLOCK")){$.trace("block {");let e=o();$.trace("}"),m(e),e.name?t[e.name]=e:$.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else Ju(i),i=e.next();return t}function o(){let t={};for(i=e.next();"EOF"!==i.value;){switch(i.code){case 1:t.xrefPath=i.value,i=e.next();break;case 2:t.name=i.value,i=e.next();break;case 3:t.name2=i.value,i=e.next();break;case 4:t.description=i.value,i=e.next();break;case 5:t.handle=i.value,i=e.next();break;case 8:t.layer=i.value,i=e.next();break;case 10:t.position=f(i),i=e.lastReadGroup;break;case 67:t.paperSpace=!(!i.value||1!==i.value),i=e.next();break;case 70:t.blockType=i.value,i=e.next();break;case 100:i=e.next();break;case 330:t.ownerHandle=i.value,i=e.next();break;case 0:if("ENDBLK"==i.value)break;t.entities=d(!0);break;default:Ju(i),i=e.next()}if(eo(i,0,"ENDBLK")){i=e.next();break}}return t}function l(){let t={};for(i=e.next();"EOF"!==i.value&&!eo(i,0,"ENDSEC");)eo(i,0,"TABLE")?(i=e.next(),u[i.value]?($.trace(i.value+" Table {"),t[u[i.value].tableName]=c(i),$.trace("}")):$.trace("Unhandled Table "+i.value)):i=e.next();return i=e.next(),t}let h="ENDTAB";function c(t){let n=u[t.value],r={},a=0;for(i=e.next();!eo(i,0,h);)switch(i.code){case 5:r.handle=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 100:"AcDbSymbolTable"===i.value||Ju(i),i=e.next();break;case 70:a=i.value,i=e.next();break;case 0:i.value===n.dxfSymbolName?r[n.tableRecordsProperty]=n.parseTableRecords():(Ju(i),i=e.next());break;default:Ju(i),i=e.next()}let s=r[n.tableRecordsProperty];if(s){let e=s.constructor===Array?s.length:"object"==typeof s?Object.keys(s).length:void 0;a!==e&&$.warn(`[DxfParser] Parsed ${e} ${n.dxfSymbolName}s but expected ${a}`)}return i=e.next(),r}let u={VPORT:{tableRecordsProperty:"viewports",tableName:"viewport",dxfSymbolName:"VPORT",parseTableRecords:function(){let t=[],n={};for($.trace("Viewport {"),i=e.next();!eo(i,0,h);)switch(i.code){case 2:n.name=i.value,i=e.next();break;case 10:n.lowerLeftCorner=f(i),i=e.lastReadGroup;break;case 11:n.upperRightCorner=f(i),i=e.lastReadGroup;break;case 12:n.center=f(i),i=e.lastReadGroup;break;case 13:n.snapBasePoint=f(i),i=e.lastReadGroup;break;case 14:n.snapSpacing=f(i),i=e.lastReadGroup;break;case 15:n.gridSpacing=f(i),i=e.lastReadGroup;break;case 16:n.viewDirectionFromTarget=f(i),i=e.lastReadGroup;break;case 17:n.viewTarget=f(i),i=e.lastReadGroup;break;case 40:case 45:n.viewHeight=i.value,i=e.next();break;case 41:n.aspectRatio=i.value,i=e.next();break;case 42:n.lensLength=i.value,i=e.next();break;case 43:n.frontClippingPlane=i.value,i=e.next();break;case 44:n.backClippingPlane=i.value,i=e.next();break;case 50:n.snapRotationAngle=i.value,i=e.next();break;case 51:n.viewTwistAngle=i.value,i=e.next();break;case 79:n.orthographicType=i.value,i=e.next();break;case 110:n.ucsOrigin=f(i),i=e.lastReadGroup;break;case 111:n.ucsXAxis=f(i),i=e.lastReadGroup;break;case 112:n.ucsYAxis=f(i),i=e.lastReadGroup;break;case 281:n.renderMode=i.value,i=e.next();break;case 282:n.defaultLightingType=i.value,i=e.next();break;case 292:n.defaultLightingOn=i.value,i=e.next();break;case 330:n.ownerHandle=i.value,i=e.next();break;case 63:case 421:case 431:n.ambientColor=i.value,i=e.next();break;case 0:"VPORT"===i.value&&($.trace("}"),t.push(n),$.trace("Viewport {"),n={},i=e.next());break;default:Ju(i),i=e.next()}return $.trace("}"),t.push(n),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},n={},a=0,s="",o=!1;for($.trace("LType {"),i=e.next();!eo(i,0,"ENDTAB");)switch(i.code){case 2:n.name=i.value.toUpperCase(),s=n.name,i=e.next();break;case 3:n.description=i.value,i=e.next();break;case 9:case 44:case 45:case 46:case 70:case 75:default:i=e.next();break;case 40:n.patternLength=i.value,i=e.next();break;case 49:let l=i.value;o&&(l=Math.abs(l),o=!1),n.pattern.push(l),i=e.next();break;case 73:a=i.value,a>0&&(n.pattern=[]),i=e.next();break;case 74:0!==i.value&&(o=!0,r.unsupportedLineTypes[n.name]?r.unsupportedLineTypes[n.name]++:r.unsupportedLineTypes[n.name]=1),i=e.next();break;case 0:$.trace("}"),a>0&&a!==n.pattern.length&&$.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=n,n={},$.trace("LType {"),i=e.next()}return $.trace("}"),t[s]=n,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,n={},r={};for($.trace("Layer {"),i=e.next();!eo(i,0,"ENDTAB");)switch(i.code){case 2:r.name=i.value,t=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 62:r.visible=i.value>=0,r.colorIndex=Math.abs(i.value),r.color=Hit(r.colorIndex),i=e.next();break;case 70:r.flag=i.value,r.frozen=(1&r.flag)>0,i=e.next();break;case 420:r.color=Math.abs(i.value),i=e.next();break;case 6:r.lineType=i.value.toUpperCase(),i=e.next();break;case 370:r.lineweight=i.value,i=e.next();break;case 0:"LAYER"===i.value&&($.trace("}"),t&&(n[t]=r),$.trace("Layer {"),r={},t=void 0,i=e.next());break;default:Ju(i),i=e.next()}return $.trace("}"),t&&(n[t]=r),n}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,n={},a={};for($.trace("BlockRecord {"),i=e.next();!eo(i,0,"ENDTAB");)switch(i.code){case 5:a.handle=i.value,i=e.next();break;case 330:a.ownerHandle=i.value,i=e.next();break;case 2:a.blockName=i.value,t=a.blockName,i=e.next();break;case 340:a.layoutHandle=i.value,i=e.next();break;case 70:a.blockInsertUnits=i.value,i=e.next();break;case 280:a.blockExplodability=i.value,i=e.next();break;case 281:a.blockScalability=i.value,i=e.next();break;case 310:a.bitmap=i.value,i=e.next();break;case 0:if("BLOCK_RECORD"===i.value){$.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),$.trace("BlockRecord {"),a={},t=void 0,i=e.next()}else Ju(i),i=e.next();break;default:Ju(i),i=e.next()}$.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;return t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),n}},STYLE:{tableRecordsProperty:"styles",tableName:"style",dxfSymbolName:"STYLE",parseTableRecords:function(){let t,n={},r={};for($.trace("Style {"),i=e.next();!eo(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 3:r.fontFile=i.value,i=e.next();break;case 4:r.bigFontFile=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 40:r.textHeight=i.value,i=e.next();break;case 41:r.xScale=i.value,i=e.next();break;case 42:r.priorTextHeight=i.value,i=e.next();break;case 50:r.rotation=i.value,i=e.next();break;case 70:default:i=e.next();break;case 71:r.mirrorType=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 0:"STYLE"===i.value&&($.trace("}"),t&&(n[t]=r),$.trace("Style {"),r={},t=void 0,i=e.next())}return $.trace("}"),t&&(n[t]=r),n}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,n={},r={};for($.trace("DimStyle {"),i=e.next();!eo(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 40:r.DIMSCALE=i.value,i=e.next();break;case 41:r.DIMASZ=i.value,i=e.next();break;case 42:r.DIMEXO=i.value,i=e.next();break;case 44:r.DIMEXE=i.value,i=e.next();break;case 75:r.DIMSE1=i.value,i=e.next();break;case 76:r.DIMSE2=i.value,i=e.next();break;case 77:r.DIMTAD=i.value,i=e.next();break;case 140:r.DIMTXT=i.value,i=e.next();break;case 144:r.DIMLFAC=i.value,i=e.next();break;case 147:r.DIMGAP=i.value,i=e.next();break;case 176:r.DIMCLRD=i.value,i=e.next();break;case 178:r.DIMCLRT=i.value,i=e.next();break;case 271:r.DIMDEC=i.value,i=e.next();break;case 341:r.DIMLDRBLK=i.value,i=e.next();break;case 70:default:i=e.next();break;case 0:"DIMSTYLE"===i.value&&($.trace("}"),t&&(n[t]=r),$.trace("DimStyle {"),r={},t=void 0,i=e.next())}return $.trace("}"),t&&(n[t]=r),n}}};function d(t){let n=[],a=t?"ENDBLK":"ENDSEC";for(t||(i=e.next());;)if(0===i.code){if(i.value===a)break;let t=r._entityHandlers[i.value];if(null==t){let t=i.value;r.unhandledEntities[t]||(r.unhandledEntities[t]=0),r.unhandledEntities[t]++,i=e.next();continue}{$.trace(i.value+" {");let r=t.parseEntity(e,i);r&&(r.layer||(r.layer="0"),void 0===r.colorIndex&&(r.colorIndex=256),r.lineType||(r.lineType=wR)),i=e.lastReadGroup,$.trace("}"),m(r),n.push(r)}}else i=e.next();return"ENDSEC"==a&&(i=e.next()),n}function p(){let t={};for(i=e.next();"EOF"!==i.value;)if(0===i.code){if("ENDSEC"===i.value)break;let n=r._objectHandlers[i.value];if(null==n){let t=i.value;r.unhandledObjects[t]||(r.unhandledObjects[t]=0),r.unhandledObjects[t]++,i=e.next();continue}{$.trace(i.value+" {");let r=n.parseObject(e,i),a=i.value;i=e.lastReadGroup,$.trace("}"),m(r),t[a]||(t[a]=[]),t[a].push(r)}}else i=e.next();return i=e.next(),t.LAYOUT&&(Object.keys(r._layoutBlocks).length!==t.LAYOUT.length&&$.warn("[DxfParser] The number of layout and block associations does not match!"),t.LAYOUT.forEach((e=>{r._layoutBlocks[e.handle]&&(e.associatedBlockName=r._layoutBlocks[e.handle].blockName)})),t.LAYOUT.sort(((e,t)=>e.tabOrder-t.tabOrder))),t}function f(t){let n={},i=t.code;if(n.x=t.value,i+=10,(t=e.next()).code!=i)throw new Error(`Expected code for point value to be ${i} but got ${t.code}.`);return n.y=t.value,i+=10,(t=e.next()).code!=i||(n.z=t.value,t=e.next()),n}function m(e){if(!e)throw new TypeError("entity cannot be undefined or null");e.handle||(e.handle=(n++).toString())}return function(){for(i=e.next();999===i.code;)i=e.next();for(;!e.isEOF();)if(0===i.code&&"SECTION"===i.value){if(i=e.next(),2!==i.code){$.error("Unexpected code %s after 0:SECTION",_ue(i)),i=e.next();continue}if("HEADER"===i.value)$.trace("> HEADER"),t.header=a(),$.trace("<");else if("TABLES"===i.value)$.trace("> TABLES"),t.tables=l(),$.trace("<");else if("BLOCKS"===i.value)$.trace("> BLOCKS"),t.blocks=s(),$.trace("<");else if("ENTITIES"===i.value)$.trace("> ENTITIES"),t.entities=d(!1),$.trace("<");else if("OBJECTS"===i.value)$.trace("> OBJECTS"),t.objects=p(),$.trace("<");else if("EOF"===i.value)$.trace("EOF");else{let e=i.value;r.unhandledSections[e]?r.unhandledSections[e]++:r.unhandledSections[e]=1}}else i=e.next();r.unhandledSections={},r.unhandledEntities={},r.unhandledObjects={},r.unsupportedLineTypes={}}(),t}splitByLineSeparator(e){let t=[],n=0;for(let i=0,r=e.length;i<r;++i){let r=e[i];if("\r"===r||"\n"===r){let a=e.substring(n,i);t.push(a),"\r"===r&&"\n"===e[i+1]&&i++,n=i+1}}return t.push(e.substring(n,e.length)),t}};function eo(e,t,n){return e.code===t&&e.value===n}function Ju(e){$.trace("unhandled group "+_ue(e))}function _ue(e){return e.code+":"+e.value}function Hit(e){return MR[e]}var b5=(e=>(e.Added="Added",e.Removed="Removed",e.Modified="Modified",e.NoChange="NoChange",e))(b5||{}),rs=1,DR=class{constructor(e,t){if(this.changes={},this.comparedBlocks=new Map,this.isComparingBlock=!1,this.isComparingDimension=!1,this.dxf1=e,this.dxf2=t,!e||!t)throw new Error("Invalid dxf data to compare!")}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}compare(e){return $e(this,null,(function*(){this.changes={};let t=[],n=new Map;return this.dxf1.entities.forEach((e=>{if(!0!==e.inPaperSpace){let n=!0===this.getLayerFrozen(this.dxf1,e);!DR.ignoreEntityTypes.includes(e.type)&&!n&&t.push(e)}})),this.dxf2.entities.forEach((e=>{if(!0!==e.inPaperSpace){let t=!0===this.getLayerFrozen(this.dxf2,e);!DR.ignoreEntityTypes.includes(e.type)&&!t&&n.set(e.handle,e)}})),yield this.compareEntities(t,n,void 0,e),Promise.resolve(this.changes)}))}isDimensionBlock(e){return e.includes("*D")}compareInsertOrDemensionEntities(e,t,n,i){if(!e.block||!t.block)return;let r,a=e.block;if(this.isComparingBlock=!0,this.isDimensionBlock(a)){let n=this.dxf1.blocks[e.block],i=this.dxf2.blocks[t.block],s=Date.now();this.isComparingDimension=!0,r=this.compareBlock(n,i),this.isComparingDimension=!1,$.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-s)/1e3}s`)}else{if(!this.comparedBlocks.has(a)){let e=this.dxf1.blocks[a],t=this.dxf2.blocks[a],n=Date.now(),i=this.compareBlock(e,t);this.comparedBlocks.set(a,i),$.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-n)/1e3}s`)}r=this.comparedBlocks.get(a)}return null==r||r.forEach((t=>{if(t.parentHandles||(t.parentHandles=[]),n&&i)"Added"===t.type?t.parentHandles.push(i):"Removed"===t.type&&t.parentHandles.push(n);else{let n=[...t.parentHandles,e.handle];("Added"===t.type||"Removed"===t.type)&&(this.changes[rs]=Qr(yn({id:rs},t),{parentHandles:n})),rs++}})),!n&&!i&&(this.isComparingBlock=!1),r}compareBlock(e,t){var n,i;let r=[],a=[];null==(n=null==e?void 0:e.entities)||n.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&r.push(e)})),null==(i=null==t?void 0:t.entities)||i.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&a.push(e)}));let s=[],o=[];for(let l=0;l<r.length;l++){let e=r[l],t=!1;0===a.length&&(t=!0),this.isComparingDimension||(this.isComparingDimension="DIMENSION"===e.type);for(let n=0;n<a.length;n++){let i=a[n];if(this.entitiesEqual(e,i)){if("INSERT"===e.type&&"INSERT"===i.type||"DIMENSION"===e.type&&"DIMENSION"===i.type){let r=this.compareInsertOrDemensionEntities(e,i,e.handle,i.handle);r&&r.length>0&&s.push(...r),t=!1,a.splice(n--,1);break}t=!1,a.splice(n--,1);break}t=!0}t&&(s.push({type:"Removed",handle:e.handle}),o.push(e.handle))}return a.forEach((e=>{o.includes(e.handle)||s.push({type:"Added",handle:e.handle})})),s}compareEntities(e,t,n,i){return $e(this,null,(function*(){var r,a;let s=e.length,o=Math.round(Math.pow(s,.5)),l=Date.now(),h=e=>$e(this,null,(function*(){if(i&&(e%o==0||e===s-1)){i(new ProgressEvent("compareProgress",{loaded:e+1,total:s}));let t=500,n=Date.now();(n-l>t||e===s-1)&&(yield it.sleep(0),l=n)}}));for(let i=0;i<e.length;i++){let s=e[i].handle;if(t.has(s)){let o=e[i],l=t.get(s);if(this.entitiesEqual(o,l)){if(Lp.includes(o.type)){if(this.bIgnoreChildEntitiesOriginalType(o)){t.delete(s),$.warn(`[DxfCompare] We cannot compare insert (handle '${o.handle}') yet, ignored!`);continue}this.compareInsertOrDemensionEntities(o,l)}}else{if(null!=(r=o.extendedData)&&r.originalType&&null!=(a=l.extendedData)&&a.originalType&&o.block!==l.block){t.delete(s);continue}this.changes[rs]={id:rs,type:"Modified",handle:s},n&&(this.changes[rs].parentHandles=[n]),rs++}t.delete(s)}else this.changes[rs]={id:rs,type:"Removed",handle:s},n&&(this.changes[rs].parentHandles=[n]),rs++;yield h(i)}for(let e of t){let t=e[0];this.changes[rs]={id:rs,type:"Added",handle:t},n&&(this.changes[rs].parentHandles=[n]),rs++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return xue.includes(null==(t=e.extendedData)?void 0:t.originalType)}entitiesEqual(e,t){if(!this.baseEntitiesEqual(e,t))return!1;let n=e.type,i=!0;return"CIRCLE"===n||"ARC"===n?i=this.arcsEqual(e,t):"LWPOLYLINE"===n||"LINE"===n?i=this.linesEqual(e,t):"POLYLINE"===n?i=this.polylinesEqual(e,t):"TEXT"===n?i=this.textsEqual(e,t):"SOLID"===n?i=this.solidsEqual(e,t):"POINT"===n?i=this.pointEntitiesEqual(e,t):"INSERT"===n?i=this.insertsEqual(e,t):"SPLINE"===n?i=this.splinesEqual(e,t):"MTEXT"===n?i=this.mtextsEqual(e,t):"ELLIPSE"===n?i=this.ellipsesEqual(e,t):"DIMENSION"===n?i=this.dimensionsEqual(e,t):"REGION"===n?i=this.regionsEqual(e,t):"ATTDEF"===n?i=this.attDefsEqual(e,t):"ATTRIB"===n?i=this.attribsEqual(e,t):"HATCH"===n?i=this.hatchesEqual(e,t):"VIEWPORT"===n?i=this.viewportsEqual(e,t):"LEADER"===n?i=this.leadersEqual(e,t):"MULTILEADER"===n?i=this.mleadersEqual(e,t):"OLE2FRAME"===n&&(i=this.ole2framesEqual(e,t)),i}baseEntitiesEqual(e,t){var n,i;return!((null==(n=e.extendedData)?void 0:n.originalType)!==(null==(i=t.extendedData)?void 0:i.originalType)||!this.isComparingBlock&&!this.isComparingDimension&&e.handle!==t.handle||!this.isComparingDimension&&e.ownerHandle!==t.ownerHandle||e.type!==t.type)}arcsEqual(e,t){return!!(this.vectorsEqual(e.center,t.center)&&this.numberEqual(e.radius,t.radius)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}linesEqual(e,t){return!(!this.verticesEqual(e.vertices,t.vertices)||e.shape!==t.shape)}polylinesEqual(e,t){return!(!this.vertexEntitiesEqual(e.vertices,t.vertices)||e.shape!==t.shape||e.isPolyfaceMesh!==t.isPolyfaceMesh)}textsEqual(e,t){if(e.halign!==t.halign)return!1;if(3===e.halign||5===e.halign){if(!this.pointsEqual(e.startPoint,t.startPoint))return!1}else if(!this.pointsEqual(e.endPoint,t.endPoint))return!1;return e.text===t.text}solidsEqual(e,t){return!!this.verticesEqual(e.points,t.points)}pointEntitiesEqual(e,t){return!!this.pointsEqual(e.position,t.position)}splinesEqual(e,t){return!(!this.verticesEqual(e.controlPoints,t.controlPoints)||!this.numbersEqual(e.knotValues,t.knotValues)||!this.numberEqual(e.degreeOfSplineCurve,t.degreeOfSplineCurve))}mtextsEqual(e,t){return!(!this.pointsEqual(e.position,t.position)||e.text!==t.text||!this.numberEqual(e.rotation,t.rotation))}ellipsesEqual(e,t){return!!(this.pointsEqual(e.center,t.center)&&this.pointsEqual(e.majorAxisEndPoint,t.majorAxisEndPoint)&&this.numberEqual(e.axisRatio,t.axisRatio)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}attDefsEqual(e,t){return!(!this.pointsEqual(e.startPoint,t.startPoint)||!this.pointsEqual(e.endPoint,t.endPoint)||!this.numberEqual(e.xScale,t.xScale)||e.text!==t.text||e.tag!==t.tag||e.prompt!==t.prompt)}attribsEqual(e,t){return this.attDefsEqual(e,t)}hatchesEqual(e,t){let n=e,i=t;return!!(this.numberEqual(n.elevationX,i.elevationX)&&this.numberEqual(n.elevationY,i.elevationY)&&this.numberEqual(n.elevationZ,i.elevationZ)&&this.hatchBoundaryPathArraysEqual(n.boundaryPaths,i.boundaryPaths))}viewportsEqual(e,t){let n=e,i=t;return!!(this.pointsEqual(n.centerPoint,i.centerPoint)&&this.pointsEqual(n.centerPoint_dcs,i.centerPoint_dcs)&&this.pointsEqual(n.viewDirection,i.viewDirection)&&this.numberEqual(n.viewHeight,i.viewHeight)&&n.width_paperSpace===i.width_paperSpace&&n.height_paperSpace===i.height_paperSpace)}leadersEqual(e,t){return!!(this.pointsEqual(e.position,t.position)&&this.verticesEqual(e.vertices,t.vertices)&&e.arrowHeadBlockHandle===t.arrowHeadBlockHandle&&this.numberEqual(e.arrowHeadSize,t.arrowHeadSize)&&this.numberEqual(e.rotation,t.rotation)&&e.block===t.block)}mleadersEqual(e,t){return!(e.arrowHeadId!==t.arrowHeadId||!this.numberEqual(e.arrowHeadSize,t.arrowHeadSize))&&this.mleaderContextEqual(e.contextData,t.contextData)}ole2framesEqual(e,t){return!(e.leftUpX!==t.leftUpX||e.leftUpY!==t.leftUpY||e.leftUpZ!==t.leftUpZ||e.rightDownX!==t.rightDownX||e.rightDownY!==t.rightDownY||e.rightDownZ!==t.rightDownZ)}insertsEqual(e,t){var n,i,r,a;return"INSERT"===(null==(n=e.extendedData)?void 0:n.originalType)&&"INSERT"===(null==(i=t.extendedData)?void 0:i.originalType)?($.warn(`[DxfCompare] We cannot compare insert (handle '${e.handle}') yet, ignored!`),!0):!!(this.pointsEqual(e.position,t.position)&&this.numberEqual(void 0===e.xScale?1:e.xScale,void 0===t.xScale?1:t.xScale)&&this.numberEqual(void 0===e.yScale?1:e.yScale,void 0===t.yScale?1:t.yScale)&&this.numberEqual(void 0===e.zScale?1:e.zScale,void 0===t.zScale?1:t.zScale)&&e.block===t.block&&(null==(r=e.entities)?void 0:r.length)===(null==(a=t.entities)?void 0:a.length))}dimensionsEqual(e,t){return!!this.pointsEqual(e.anchorPoint,t.anchorPoint)}regionsEqual(e,t){return $.warn("Cannot compare region yet!"),!0}vectorsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)}pointsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)&&this.numberEqual(e.bulge,t.bulge)}vertexEntityEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.pointsEqual(e,t)||e.polyfaceMeshVertex!==t.polyfaceMeshVertex||e.threeDPolylineMesh!==t.threeDPolylineMesh)}numbersEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.numberEqual(e[n],t[n]))return!1;return!0}return!1}numberEqual(e,t){return null==e&&null==t||null!=e&&null!=t&&wt.areNumbersEqual(e,t)}vectorArraysEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.vectorsEqual(e[n],t[n]))return!1;return!0}return!1}verticesEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.pointsEqual(e[n],t[n]))return!1;return!0}return!1}verticesArrayEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.verticesEqual(e[n],t[n]))return!1;return!0}return!1}vertexEntitiesEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.vertexEntityEqual(e[n],t[n]))return!1;return!0}return!1}hatchEdgesEqual(e,t){return!e&&!t||!(!e||!t)&&e.type===t.type}hatchEdgeArraysEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.hatchEdgesEqual(e[n],t[n]))return!1;return!0}return!1}hatchBoundaryPathsEqual(e,t){return!e&&!t||!(!e||!t)&&e.pathTypeFlag===t.pathTypeFlag&&this.hatchEdgeArraysEqual(e.edges,t.edges)}hatchBoundaryPathArraysEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.hatchBoundaryPathsEqual(e[n],t[n]))return!1;return!0}return!1}mleaderLineEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.verticesArrayEqual(e.vertices,t.vertices)||e.leaderLineIndex!==t.leaderLineIndex)}mleaderLinesEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.mleaderLineEqual(e[n],t[n]))return!1;return!0}return!1}mleaderLeaderEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.pointsEqual(e.lastLeaderLinePoint,t.lastLeaderLinePoint)||!this.pointsEqual(e.doglegVector,t.doglegVector)||!this.mleaderLinesEqual(e.leaderLines,t.leaderLines))}mleaderLeadersEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!this.mleaderLeaderEqual(e[n],t[n]))return!1;return!0}return!1}mleaderContextEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.pointsEqual(e.contentBasePosition,t.contentBasePosition)||!this.pointsEqual(e.blockContentPosition,t.blockContentPosition)||!this.mleaderLeadersEqual(e.leaders,t.leaders))}compareHexStrings(e,t){return parseInt(e,16)-parseInt(t,16)}},Zr=DR;Zr.ENTITY_COLOR_ADDED=65280,Zr.ENTITY_COLOR_REMOVED=16711680,Zr.ENTITY_COLOR_NO_CHANGE=10066329,Zr.ENTITY_COLOR_MARKUP=16744231,Zr.ignoreEntityTypes=["ATTRIB","SEQEND"];var khe=wi(Hue(),1),Wue="3.7.5",$it=Wue,Zit="function"==typeof atob,Kit="function"==typeof btoa,kv="function"==typeof Buffer,kue="function"==typeof TextDecoder?new TextDecoder:void 0,Vue="function"==typeof TextEncoder?new TextEncoder:void 0,Jit="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",EE=Array.prototype.slice.call(Jit),BR=(e=>{let t={};return EE.forEach(((e,n)=>t[e]=n)),t})(),Qit=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,is=String.fromCharCode.bind(String),zue="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),jue=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),Xue=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Yue=e=>{let t,n,i,r,a="",s=e.length%3;for(let o=0;o<e.length;){if((n=e.charCodeAt(o++))>255||(i=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=n<<16|i<<8|r,a+=EE[t>>18&63]+EE[t>>12&63]+EE[t>>6&63]+EE[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},D5=Kit?e=>btoa(e):kv?e=>Buffer.from(e,"binary").toString("base64"):Yue,P5=kv?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,i=e.length;n<i;n+=4096)t.push(is.apply(null,e.subarray(n,n+4096)));return D5(t.join(""))},FR=(e,t=!1)=>t?jue(P5(e)):P5(e),est=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?is(192|t>>>6)+is(128|63&t):is(224|t>>>12&15)+is(128|t>>>6&63)+is(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return is(240|t>>>18&7)+is(128|t>>>12&63)+is(128|t>>>6&63)+is(128|63&t)},tst=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,$ue=e=>e.replace(tst,est),Gue=kv?e=>Buffer.from(e,"utf8").toString("base64"):Vue?e=>P5(Vue.encode(e)):e=>D5($ue(e)),Hv=(e,t=!1)=>t?jue(Gue(e)):Gue(e),que=e=>Hv(e,!0),nst=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,rst=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return is(55296+(t>>>10))+is(56320+(1023&t));case 3:return is((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return is((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Zue=e=>e.replace(nst,rst),Kue=e=>{if(e=e.replace(/\s+/g,""),!Qit.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,i,r="";for(let a=0;a<e.length;)t=BR[e.charAt(a++)]<<18|BR[e.charAt(a++)]<<12|(n=BR[e.charAt(a++)])<<6|(i=BR[e.charAt(a++)]),r+=64===n?is(t>>16&255):64===i?is(t>>16&255,t>>8&255):is(t>>16&255,t>>8&255,255&t);return r},L5=Zit?e=>atob(Xue(e)):kv?e=>Buffer.from(e,"base64").toString("binary"):Kue,Jue=kv?e=>zue(Buffer.from(e,"base64")):e=>zue(L5(e).split("").map((e=>e.charCodeAt(0)))),Que=e=>Jue(ehe(e)),ist=kv?e=>Buffer.from(e,"base64").toString("utf8"):kue?e=>kue.decode(Jue(e)):e=>Zue(L5(e)),ehe=e=>Xue(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),I5=e=>ist(ehe(e)),sst=e=>{if("string"!=typeof e)return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},the=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),nhe=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,the(t));e("fromBase64",(function(){return I5(this)})),e("toBase64",(function(e){return Hv(this,e)})),e("toBase64URI",(function(){return Hv(this,!0)})),e("toBase64URL",(function(){return Hv(this,!0)})),e("toUint8Array",(function(){return Que(this)}))},rhe=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,the(t));e("toBase64",(function(e){return FR(this,e)})),e("toBase64URI",(function(){return FR(this,!0)})),e("toBase64URL",(function(){return FR(this,!0)}))},ast=()=>{nhe(),rhe()},ihe={version:Wue,VERSION:$it,atob:L5,atobPolyfill:Kue,btoa:D5,btoaPolyfill:Yue,fromBase64:I5,toBase64:Hv,encode:Hv,encodeURI:que,encodeURL:que,utob:$ue,btou:Zue,decode:I5,isValid:sst,fromUint8Array:FR,toUint8Array:Que,extendString:nhe,extendUint8Array:rhe,extendBuiltins:ast},qo=wi(_he(),1),HR=class extends qu{constructor(e,t={}){let n=t.font;if(void 0===n)super();else{let i=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}},Uc=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new rr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){let n=r.parse(JSON.parse(e));t&&t(n)}),n,i)}parse(e){return new Bp(e)}},Bp=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=vst(e,t,this.data);for(let r=0,a=i.length;r<a;r++)n.push(...i[r].toShapes());return n}};function vst(e,t,n){let i=Array.from(e),r=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,s=[],o=0,l=0;for(let h=0;h<i.length;h++){let e=i[h];if("\n"===e)o=0,l-=a;else{let t=xst(e,r,o,l,n);o+=t.offsetX,s.push(t.path)}}return s}function xst(e,t,n,i,r){let a=r.glyphs[e]||r.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");let s,o,l,h,c,u,d,p,f=new uy;if(a.o){let e=a._cachedOutline||(a._cachedOutline=a.o.split(" "));for(let r=0,a=e.length;r<a;)switch(e[r++]){case"m":s=e[r++]*t+n,o=e[r++]*t+i,f.moveTo(s,o);break;case"l":s=e[r++]*t+n,o=e[r++]*t+i,f.lineTo(s,o);break;case"q":l=e[r++]*t+n,h=e[r++]*t+i,c=e[r++]*t+n,u=e[r++]*t+i,f.quadraticCurveTo(c,u,l,h);break;case"b":l=e[r++]*t+n,h=e[r++]*t+i,c=e[r++]*t+n,u=e[r++]*t+i,d=e[r++]*t+n,p=e[r++]*t+i,f.bezierCurveTo(c,u,d,p,l,h)}}return{offsetX:a.ha*t,path:f}}function The(e,t,n,i){let r={u_cameraZoom:n,u_patternLines:{value:e},u_patternAngle:{value:t},u_color:{value:i}},a=`\n uniform mat4 modelMatrix;\n uniform float u_cameraZoom;\n uniform vec3 u_color;\n varying vec3 v_pos;\n\n struct PatternLine {\n vec2 origin;\n vec2 delta;\n float angle;\n float pattern[MAX_PATTERN_SEGMENT_COUNT];\n float patternSum[MAX_PATTERN_SEGMENT_COUNT+1];\n float patternLength;\n };\n\n uniform PatternLine u_patternLines[${e.length}];\n uniform float u_patternAngle;\n\n #include <clipping_planes_pars_fragment>\n\n // Clamp [0..1] range\n #define saturate(a) clamp(a, 0.0, 1.0)\n\n const float EPS = 1000.0;\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n vec2 rotate(vec2 st, float rotation) {\n const float PI = 3.1415926;\n float angle = rotation * PI/180.0;\n float sine = sin(angle), cosine = cos(angle);\n return vec2(cosine * st.x - sine * st.y, cosine * st.y + sine * st.x);\n }\n\n vec2 translate(vec2 samplePosition, vec2 offset) {\n //move sample point in the opposite direction that we want to move shapes in\n return samplePosition - offset;\n }\n\n vec2 scale(vec2 samplePosition, float scale) {\n return samplePosition / scale;\n }\n\n float sdfLine(vec2 st, vec2 a, vec2 b) {\n vec2 ap = st - a;\n vec2 ab = b - a;\n return abs(((ap.x * ab.y) - (ab.x * ap.y))) / length(ab);\n }\n\n float drawSpaceLine(vec2 st, float distanceBetweenLines, float thick) {\n float dist = sdfLine(st , vec2(0.0, 0.0) , vec2(1.0, 0.0));\n \n //vec2 tt = dFdy(st);\n //float scale = (abs(tt.x)+abs(tt.y))/2.0;\n //float scale = length(fwidth(st)) * 0.5;\n // close to a pixel\n //float thick = 2.0;\n //thick = (thick * 0.5 - 0.5) * scale;\n\n float lineDistance = abs(fract(dist / distanceBetweenLines + 0.5) - 0.5) * distanceBetweenLines;\n //float lineDistance = fract(dist / distanceBetweenLines);\n //float distanceChange = fwidth(dist) * 0.5;\n //float threshold = smoothstep(thick - distanceChange, thick + distanceChange, lineDistance);\n //float threshold = step(thick,lineDistance);\n // remove gradient\n //float threshold = step(0.001,lineDistance);\n float threshold = step(thick,lineDistance);\n\n return threshold;\n }\n\n float drawSolidLine(PatternLine patternLine, float thick) {\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta;\n float distanceBetweenLines = length(delta);\n\n origin = rotate(origin,u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n return drawSpaceLine(st, distanceBetweenLines , thick);\n }\n\n int getPatternIndex(PatternLine patternLine, float u, out float distance ) {\n //u = mod(u, patternLine.patternLength);\n float y = floor(u/patternLine.patternLength);\n u = u - patternLine.patternLength * y;\n //float distance = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 1; i < patternLine.patternSum.length(); i++){\n if(u <= patternLine.patternSum[i]) {\n distance = u - patternLine.patternSum[i-1];\n return i - 1;\n }\n }\n #pragma unroll_loop_end\n\n return -1;\n }\n\n float drawDashedLine(PatternLine patternLine, float thick){\n float threshold = 1.0;\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta; \n float distanceBetweenLines = abs(delta.y);\n\n origin = rotate(origin, u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n float offsetX = st.y * delta.x/delta.y;\n float u = st.x - offsetX;\n float distance = 0.0;\n int index = getPatternIndex(patternLine, u, distance);\n if(index < 0) {\n return threshold;\n }\n\n float size = patternLine.pattern[index];\n if(size >= 0.0) {\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n // Try to solve the problem caused by the precision after zooming out by drawing a part of the dashed line\n } else if (distance < thick) {\n //threshold = 0.8;\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n }\n \n return threshold;\n }\n\n float drawLine(PatternLine patternLine, float thick) {\n float t = 0.0;\n if(patternLine.patternLength > 0.0) {\n t = drawDashedLine(patternLine, thick);\n } else {\n t = drawSolidLine(patternLine, thick);\n }\n return t;\n }\n\n void main() {\n #include <clipping_planes_fragment>\n \n vec2 worldScale = getWorldScale();\n float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // possible size of a pixel \n float thick = (0.7 / averageScale) / u_cameraZoom;\n\n if(thick > EPS) {\n gl_FragColor = vec4(u_color, 1.0);\n return;\n }\n\n float total = 0.0;\n\n#if ${e.length} > 1\n #pragma unroll_loop_start\n for (int i = 0; i < u_patternLines.length(); i++) {\n PatternLine pl = u_patternLines[i];\n float t = drawLine(pl, thick);\n total += (1.0 - t);\n }\n #pragma unroll_loop_end\n#else\n float t = drawLine(u_patternLines[0], thick);\n total += (1.0 - t);\n#endif\n\n total = saturate(total);\n if (total < 0.001) {\n discard;\n }\n\n gl_FragColor = vec4(u_color * total, 1.0);\n }\n `;return new It({uniforms:r,vertexShader:"\n varying vec3 v_pos;\n\n #include <clipping_planes_pars_vertex>\n void main() {\n //vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n v_pos = position;\n\n #include <begin_vertex>\n #include <project_vertex>\n #include <clipping_planes_vertex>\n }",fragmentShader:a,clipping:!0})}var kR=class{static createLineShaderMaterial(e,t,n,i,r){let a=0,s=[];for(let h=0;h<e.length;h++)s[h]=e[h],0===s[h]&&(s[h]=.5),s[h]*=n,a+=Math.abs(s[h]);let o=Lr.merge([gt.common,{pattern:{type:"fv1",value:s},patternLength:{type:"f",value:a},u_color:{value:new Ie(t)}}]);o.u_viewportScale=i,o.u_cameraZoom=r;let l=`\n uniform mat4 modelMatrix;\n uniform vec3 diffuse;\n uniform vec3 u_color;\n uniform float opacity;\n uniform float pattern[${e.length}];\n uniform float patternLength;\n uniform float u_viewportScale;\n uniform float u_cameraZoom;\n varying float vLineDistance;\n\n #include <clipping_planes_pars_fragment>\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n void main() {\n\n #include <clipping_planes_fragment>\n\n // vec2 worldScale = getWorldScale();\n // float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // When zoomed out to a certain extent, it is displayed as a solid line.\n if(patternLength * u_viewportScale * u_cameraZoom/1.5 < 1.0){\n gl_FragColor = vec4(u_color, opacity);\n return;\n }\n\n float pos = mod(vLineDistance, patternLength * u_viewportScale);\n\n for ( int i = 0; i < ${e.length}; i++ ) {\n pos = pos - abs(pattern[i] * u_viewportScale);\n if ( pos < 0.0 ) {\n if ( pattern[i] > 0.0 ) {\n gl_FragColor = vec4(u_color, opacity);\n break;\n }\n discard;\n }\n }\n }`;return new It({uniforms:o,vertexShader:"\n attribute float lineDistance;\n varying float vLineDistance;\n\n #include <clipping_planes_pars_vertex>\n\n void main() {\n vLineDistance = lineDistance;\n\n #include <begin_vertex>\n #include <project_vertex>\n #include <clipping_planes_vertex>\n }",fragmentShader:l,clipping:!0})}},B5={};l_(B5,{default:()=>U5});var N5={};l_(N5,{default:()=>O5});var O5=(e,t)=>void 0===t||0==+t?Math.round(e):(e=+e,t=+t,isNaN(e)||"number"!=typeof t||t%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-t:-t)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+t:t)))),U5=(e,t,n,i,r)=>{let a=n.length,s=n[0].length;if(e<0||e>1)throw new Error("t out of bounds [0,1]: "+e);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>a-1)throw new Error("degree must be less than or equal to point count - 1");if(i){if(i.length!==a+t+1)throw new Error("bad knot vector length")}else{i=[];for(let e=0;e<a+t+1;e++)i[e]=e}let o,l=[t,i.length-1-t],h=i[l[0]],c=i[l[1]];for(e=e*(c-h)+h,e=Math.max(e,h),e=Math.min(e,c),o=l[0];o<l[1]&&!(e>=i[o]&&e<=i[o+1]);o++);let u,d=[];for(let f=0;f<a;f++){d[f]=[];let e=r?r[f]:1;for(let t=0;t<s;t++)d[f][t]=n[f][t]*e;d[f][s]=e}for(let f=1;f<=t+1;f++)for(let n=o;n>o-t-1+f;n--){u=(e-i[n])/(i[n+t+1-f]-i[n]);for(let e=0;e<s+1;e++)d[n][e]=(1-u)*d[n-1][e]+u*d[n][e]}let p=[];for(let f=0;f<s;f++)p[f]=O5(d[o][f]/d[o][s],-9);return p},yst={d:"\xb0",c:"\u2300",p:"\xb1"},VR=(e,t)=>{if(!e)return[];e=e.replace(/%%(.)/g,((e,t)=>yst[t]||t));let n,i=null==t?void 0:t.encoding,r=i instanceof TextDecoder?i:void 0,a="",s=[],o=e=>{a&&(s.push(a),a=""),s.push(e)};for(let l=0;l<e.length;l++)switch(n=e[l]){default:a+=n,";"===n&&o(a);break;case"\\":switch(n=e[++l]){default:a+=n;break;case"P":a+="\n";break;case"f":case"F":{let t="";for(;n=e[++l];){if(";"===n){o({f:t});break}if("|"===n){let n={f:t},i=e.indexOf(";",++l);for(let t of e.slice(l,i).split("|"))n[t[0]]=+t.slice(1);l=i,o(n);break}t+="\\"===n?e[++l]:n}break}case"S":{let t,i="",r="";for(;n=e[++l];){if(";"===n){t&&o({S:[i,t,r]});break}"\\"===n?t?r+=e[++l]:i+=e[++l]:t?r+=n:"^"===n||"/"===n||"#"===n?t=n:i+=n}break}case"H":case"W":let t=++l,[,s,h]=e.slice(t,l=e.indexOf(";",l)).match(/^(\d*(?:\.\d+)?)(\D*)$/);o({[n]:[+s,h]});break;case"Q":case"A":case"C":case"c":case"T":{let t=++l;o({[n]:+e.slice(t,l=e.indexOf(";",l))});break}case"L":case"O":case"K":o({[n]:1});break;case"l":case"o":case"k":o({[n.toUpperCase()]:0});break;case"U":case"u":"+"===e[l+1]?(a+=String.fromCodePoint(parseInt(e.substr(l+2,4),16)),l+=5):a+=n;break;case"M":case"m":i?"+"!==e[l+1]||"0"!==e[l+2]&&"1"!==e[l+2]?a+=n:(a+=(r=r||new TextDecoder(i)).decode(new Uint8Array([parseInt(e.substr(l+3,2),16),parseInt(e.substr(l+5,2),16)])),l+=6):a+="\\"+n}break;case"{":{let t=1,i=l;for(;n=e[++l];)if("{"===n)t++;else if("}"===n){if(0==--t){o(VR(e.slice(i+1,l)));break}}else"\\"===n&&l++;break}}return a&&s.push(a),s},Est={d:"\xb0",c:"\u2300",p:"\xb1"},bst=(e,t)=>(e=_st(e),t?Tst(e,t):e),_st=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),Tst=(e,t)=>{let n=t instanceof TextDecoder?t:new TextDecoder(t);return e.replace(/\\[mM]\+[0|1]([0-9a-fA-F]{2})([0-9a-fA-F]{2})/g,((e,i,r)=>(n=n||new TextDecoder(t)).decode(new Uint8Array([parseInt(i,16),parseInt(r,16)]))))},zR=(e,t)=>{let n=0,i={text:""},r=[i],a=(e=bst(e,null==t?void 0:t.encoding)).matchAll(/%%(\d\d\d|.)/g);for(let s of a){i.text+=e.slice(n,s.index);let t=s[1].toLowerCase(),a=Est[t];a?i.text+=a:3===t.length?i.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(i=Qr(yn({},i),{text:""}),i[t]?delete i[t]:i[t]=1,r.push(i)):i.text+=t,n=s.index+s[0].length}return i.text+=e.slice(n),r.filter((e=>e.text))},F5=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(F5||{}),whe=e=>"Unitless"===e?1:"Inches"===e?.0254:"Feet"===e?.3048:"Millimeters"===e?.001:"Centimeters"===e?.01:("Meters"===e||console.warn(`[Units] Unsupported unit '${e}', will return 1 for unit scale.`),1),H5=(e,t)=>whe(e)/whe(t),SE="0.2.46",Mhe="VERSION",wst=()=>window.localStorage.getItem(Mhe),Mst=()=>{window.localStorage.setItem(Mhe,SE)},She=()=>wst()!==SE&&(Mst(),!0),Vv=class{constructor(){this.DATABASE_NAME="gemini_viewer_db",this.TABLES=[{name:"viewpoint",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"annotation",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"dxfdata",options:{keyPath:"dxfDataId",autoIncrement:!1},indexArray:[]},{name:"fontdata",options:{keyPath:"url",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return Vv._instance||(Vv._instance=new Vv),Vv._instance}getDatabase(){return $e(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),She()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,$.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,$.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,$.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{$.debug("onversionchange",e)},this.db=e,Promise.resolve(this.db)}))}closeDatabase(){this.db&&this.db.close()}deleteDataBase(e){return new Promise(((t,n)=>{let i=window.indexedDB.deleteDatabase(e);i.onerror=e=>{$.debug(e),n(e)},i.onsuccess=n=>{let i=n.target;$.debug(`[DB] Db ${e} delete old version ${n.oldVersion}.`),t(i)}}))}getDB(e){return $e(this,null,(function*(){return new Promise(((t,n)=>{let i=window.indexedDB.open(e);i.onerror=n,i.onsuccess=e=>{let n=e.target.result;$.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}getUpgradedDB(e){return $e(this,null,(function*(){return new Promise(((t,n)=>{$.debug(`[DB] Upgrading db ${e.name} (version ${e.version})`);let i=window.indexedDB.open(e.name,e.version+1);i.onerror=n,i.onblocked=e=>{$.debug("onblocked",e)},i.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{$.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,n=[];for(let i=0;i<this.TABLES.length;++i){let e=this.TABLES[i];if(!t.objectStoreNames.contains(e.name)){$.debug(`[DB] Creating table ${e.name}...`);let i=this.createTable(t,e.name,e.options,e.indexArray);n.push(i)}}n.length>0&&Promise.all(n).then((()=>{$.debug(`[DB] All(${n.length}) tables created.`)}))},i.onsuccess=e=>{let n=e.target.result;$.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}createTable(e,t,n,i){return $e(this,null,(function*(){return new Promise((r=>{let a=e.createObjectStore(t,n);i&&i.forEach((e=>{a.createIndex(e.name,e.fields,{unique:e.unique})})),$.debug(`[DB] Table ${t} created.`),r(e)}))}))}},Ei=Vv;Ei._instance=void 0;var Bc=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===Ei.instance().TABLES.findIndex((e=>e.name===this.tableName())))throw new Error(`Make sure to add table '${this.tableName()}' to IndexedDbManager.TABLES!`)}tableName(){throw new Error("Derived class have to override 'tableName', and set a proper table name!")}add(e,t,n){let i=this.tableName();Ei.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).add(e);a.onsuccess=t,a.onerror=n})).finally((()=>{Ei.instance().closeDatabase()})).catch((e=>{n&&n(e)}))}save(e,t,n){let i=this.tableName();Ei.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).put(e);a.onsuccess=t,a.onerror=n})).finally((()=>{Ei.instance().closeDatabase()}))}delete(e,t,n){let i=this.tableName();Ei.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).delete(e);a.onsuccess=t,a.onerror=n})).finally((()=>{Ei.instance().closeDatabase()}))}update(){Ei.instance().getDatabase().then((()=>{}))}query(e,t){let n=this.tableName();Ei.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).openCursor();r.onsuccess=t=>{let n=t.target.result;n&&n.continue(),e&&e(n)},r.onerror=t})).finally((()=>{Ei.instance().closeDatabase()}))}queryAll(e,t){let n=this.tableName();Ei.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{Ei.instance().closeDatabase()}))}clearAll(e,t){let n=this.tableName();Ei.instance().getDatabase().then((i=>{let r=i.transaction([n],"readwrite").objectStore(n).clear();r.onsuccess=t=>{e&&e(t)},r.onerror=e=>{t&&t(e)}})).finally((()=>{Ei.instance().closeDatabase()}))}},zv=class extends Bc{tableName(){return"annotation"}static instance(){return zv._instance||(zv._instance=new zv),zv._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{console.log(e)}))}},k5=zv;k5._instance=void 0;var Gv=class extends Bc{tableName(){return"viewpoint"}static instance(){return Gv._instance||(Gv._instance=new Gv),Gv._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{n&&n(),console.log(e)}))}},V5=Gv;V5._instance=void 0;var qv=class extends Bc{tableName(){return"dxfdata"}static instance(){return qv._instance||(qv._instance=new qv),qv._instance}query(e,t,n){let i=[],r=this.tableName();Ei.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{n&&n(e),$.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&i.push(s.result),t&&t(i)}})).finally((()=>{Ei.instance().closeDatabase()}))}},Wv=qv;Wv._instance=void 0;var Fp=class extends Bc{tableName(){return"fontdata"}static instance(){return Fp._instance||(Fp._instance=new Fp),Fp._instance}query(e,t,n){let i;super.query((n=>{n?!n.value||n.value.url!==e||(i=n.value):t&&t(i)}),(e=>{n&&n(),console.log(e)}))}queryAll(){return $e(this,null,(function*(){return new Promise(((e,t)=>{G4(Fp.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},Fc=Fp;Fc._instance=void 0;var qR,Rhe=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.All=2]="All",e))(Rhe||{}),Hp=(e=>(e[e.Shapes=0]="Shapes",e[e.Bigfont=1]="Bigfont",e[e.Unifont=2]="Unifont",e))(Hp||{}),GR=12,Qu=class extends Fs{constructor(e,t){super(),this.width=0,this.lastPoint=e,this.polylines=t,this.width=this.calcWidth(t)}offset(e){let t=[];for(let n=0;n<this.polylines.length;n++){let i=this.polylines[n],r=[];for(let t=0;t<i.length;t++){let n=i[t];r.push(n.clone().add(e))}t.push(r)}return new Qu(this.lastPoint,t)}transform(e){let t=[];for(let n=0;n<this.polylines.length;n++){let i=this.polylines[n],r=[];for(let t=0;t<i.length;t++){let n=i[t];r.push(n.clone().applyMatrix3(e))}t.push(r)}return new Qu(this.lastPoint.clone().applyMatrix3(e),t)}calcWidth(e){let t=new si(new Q,new Q);for(let i=0;i<e.length;i++){let n=e[i];for(let e=0;e<n.length;e++){let i=n[e];t.expandByPoint(i)}}let n=t.min.x||0;return(t.max.x||0)-n}toThreeGeometry(){let e=this.polylines,t=[],n=[],i=0,r=new et;for(let a=0;a<e.length;a++){let r=e[a];for(let e=0;e<r.length;e++){let a=r[e];t.push(a.x,a.y,0),e===r.length-1||n.push(i,i+1),i++}}return r.setAttribute("position",new tt(t,3)),r.setIndex(n),r}};function Sst(){let e=[[161,169,161,254],[176,247,161,254],[129,160,64,254],[170,254,64,160],[168,169,64,160],[170,175,161,254],[248,254,161,254],[161,167,64,160]],t=new Uint16Array(23940),n=0;for(let[r,a,s,o]of e)for(let e=s;e<=o;e++)if(127!==e)for(let i=r;i<=a;i++)t[n++]=e<<8|i;let i=new TextDecoder("gbk").decode(t);for(qR=new Uint16Array(65536),n=0;n<i.length;n++)qR[i.charCodeAt(n)]=t[n]}function Ahe(e){qR||Sst();let t=new Uint8Array(2*e.length),n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r<128)t[n++]=r;else{let e=qR[r];t[n++]=255&e,t[n++]=e>>8}}return t.subarray(0,n)}var Rst="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u7691\u764c\u853c\u77ee\u827e\u788d\u7231\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u80ae\u6602\u76ce\u51f9\u6556\u71ac\u7ff1\u8884\u50b2\u5965\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u575d\u9738\u7f62\u7238\u767d\u67cf\u767e\u6446\u4f70\u8d25\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9881\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u529e\u7eca\u90a6\u5e2e\u6886\u699c\u8180\u7ed1\u68d2\u78c5\u868c\u9551\u508d\u8c24\u82de\u80de\u5305\u8912\u5265\u8584\u96f9\u4fdd\u5821\u9971\u5b9d\u62b1\u62a5\u66b4\u8c79\u9c8d\u7206\u676f\u7891\u60b2\u5351\u5317\u8f88\u80cc\u8d1d\u94a1\u500d\u72c8\u5907\u60eb\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7ef7\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b14\u5f7c\u78a7\u84d6\u853d\u6bd5\u6bd9\u6bd6\u5e01\u5e87\u75f9\u95ed\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u8fb9\u7f16\u8d2c\u6241\u4fbf\u53d8\u535e\u8fa8\u8fa9\u8fab\u904d\u6807\u5f6a\u8198\u8868\u9cd6\u618b\u522b\u762a\u5f6c\u658c\u6fd2\u6ee8\u5bbe\u6448\u5175\u51b0\u67c4\u4e19\u79c9\u997c\u70b3\u75c5\u5e76\u73bb\u83e0\u64ad\u62e8\u94b5\u6ce2\u535a\u52c3\u640f\u94c2\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u9a73\u6355\u535c\u54fa\u8865\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8d22\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c2\u8695\u6b8b\u60ed\u60e8\u707f\u82cd\u8231\u4ed3\u6ca7\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5395\u7b56\u4fa7\u518c\u6d4b\u5c42\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8be7\u62c6\u67f4\u8c7a\u6400\u63ba\u8749\u998b\u8c17\u7f20\u94f2\u4ea7\u9610\u98a4\u660c\u7316\u573a\u5c1d\u5e38\u957f\u507f\u80a0\u5382\u655e\u7545\u5531\u5021\u8d85\u6284\u949e\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8f66\u626f\u64a4\u63a3\u5f7b\u6f88\u90f4\u81e3\u8fb0\u5c18\u6668\u5ff1\u6c89\u9648\u8d81\u886c\u6491\u79f0\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u60e9\u6f84\u8bda\u627f\u901e\u9a8b\u79e4\u5403\u75f4\u6301\u5319\u6c60\u8fdf\u5f1b\u9a70\u803b\u9f7f\u4f88\u5c3a\u8d64\u7fc5\u65a5\u70bd\u5145\u51b2\u866b\u5d07\u5ba0\u62bd\u916c\u7574\u8e0c\u7a20\u6101\u7b79\u4ec7\u7ef8\u7785\u4e11\u81ed\u521d\u51fa\u6a71\u53a8\u8e87\u9504\u96cf\u6ec1\u9664\u695a\u7840\u50a8\u77d7\u6410\u89e6\u5904\u63e3\u5ddd\u7a7f\u693d\u4f20\u8239\u5598\u4e32\u75ae\u7a97\u5e62\u5e8a\u95ef\u521b\u5439\u708a\u6376\u9524\u5782\u6625\u693f\u9187\u5507\u6df3\u7eaf\u8822\u6233\u7ef0\u75b5\u8328\u78c1\u96cc\u8f9e\u6148\u74f7\u8bcd\u6b64\u523a\u8d50\u6b21\u806a\u8471\u56f1\u5306\u4ece\u4e1b\u51d1\u7c97\u918b\u7c07\u4fc3\u8e7f\u7be1\u7a9c\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u9519\u642d\u8fbe\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e26\u6b86\u4ee3\u8d37\u888b\u5f85\u902e\u6020\u803d\u62c5\u4e39\u5355\u90f8\u63b8\u80c6\u65e6\u6c2e\u4f46\u60ee\u6de1\u8bde\u5f39\u86cb\u5f53\u6321\u515a\u8361\u6863\u5200\u6363\u8e48\u5012\u5c9b\u7977\u5bfc\u5230\u7a3b\u60bc\u9053\u76d7\u5fb7\u5f97\u7684\u8e6c\u706f\u767b\u7b49\u77aa\u51f3\u9093\u5824\u4f4e\u6ef4\u8fea\u654c\u7b1b\u72c4\u6da4\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u9012\u7f14\u98a0\u6382\u6ec7\u7898\u70b9\u5178\u975b\u57ab\u7535\u4f43\u7538\u5e97\u60e6\u5960\u6dc0\u6bbf\u7889\u53fc\u96d5\u51cb\u5201\u6389\u540a\u9493\u8c03\u8dcc\u7239\u789f\u8776\u8fed\u8c0d\u53e0\u4e01\u76ef\u53ee\u9489\u9876\u9f0e\u952d\u5b9a\u8ba2\u4e22\u4e1c\u51ac\u8463\u61c2\u52a8\u680b\u4f97\u606b\u51bb\u6d1e\u515c\u6296\u6597\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u728a\u72ec\u8bfb\u5835\u7779\u8d4c\u675c\u9540\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u953b\u6bb5\u65ad\u7f0e\u5806\u5151\u961f\u5bf9\u58a9\u5428\u8e72\u6566\u987f\u56e4\u949d\u76fe\u9041\u6387\u54c6\u591a\u593a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u5815\u86fe\u5ce8\u9e45\u4fc4\u989d\u8bb9\u5a25\u6076\u5384\u627c\u904f\u9102\u997f\u6069\u800c\u513f\u8033\u5c14\u9975\u6d31\u4e8c\u8d30\u53d1\u7f5a\u7b4f\u4f10\u4e4f\u9600\u6cd5\u73d0\u85e9\u5e06\u756a\u7ffb\u6a0a\u77fe\u9492\u7e41\u51e1\u70e6\u53cd\u8fd4\u8303\u8d29\u72af\u996d\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8bbf\u7eba\u653e\u83f2\u975e\u5561\u98de\u80a5\u532a\u8bfd\u5420\u80ba\u5e9f\u6cb8\u8d39\u82ac\u915a\u5429\u6c1b\u5206\u7eb7\u575f\u711a\u6c7e\u7c89\u594b\u4efd\u5fff\u6124\u7caa\u4e30\u5c01\u67ab\u8702\u5cf0\u950b\u98ce\u75af\u70fd\u9022\u51af\u7f1d\u8bbd\u5949\u51e4\u4f5b\u5426\u592b\u6577\u80a4\u5b75\u6276\u62c2\u8f90\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u629a\u8f85\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8d4b\u590d\u5085\u4ed8\u961c\u7236\u8179\u8d1f\u5bcc\u8ba3\u9644\u5987\u7f1a\u5490\u5676\u560e\u8be5\u6539\u6982\u9499\u76d6\u6e89\u5e72\u7518\u6746\u67d1\u7aff\u809d\u8d76\u611f\u79c6\u6562\u8d63\u5188\u521a\u94a2\u7f38\u809b\u7eb2\u5c97\u6e2f\u6760\u7bd9\u768b\u9ad8\u818f\u7f94\u7cd5\u641e\u9550\u7a3f\u544a\u54e5\u6b4c\u6401\u6208\u9e3d\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u9601\u9694\u94ec\u4e2a\u5404\u7ed9\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f9a\u4f9b\u8eac\u516c\u5bab\u5f13\u5de9\u6c5e\u62f1\u8d21\u5171\u94a9\u52fe\u6c9f\u82df\u72d7\u57a2\u6784\u8d2d\u591f\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u86ca\u9aa8\u8c37\u80a1\u6545\u987e\u56fa\u96c7\u522e\u74dc\u5250\u5be1\u6302\u8902\u4e56\u62d0\u602a\u68fa\u5173\u5b98\u51a0\u89c2\u7ba1\u9986\u7f50\u60ef\u704c\u8d2f\u5149\u5e7f\u901b\u7470\u89c4\u572d\u7845\u5f52\u9f9f\u95fa\u8f68\u9b3c\u8be1\u7678\u6842\u67dc\u8dea\u8d35\u523d\u8f8a\u6eda\u68cd\u9505\u90ed\u56fd\u679c\u88f9\u8fc7\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u9a87\u9163\u61a8\u90af\u97e9\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6c49\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u53f7\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u9602\u6cb3\u6db8\u8d6b\u8910\u9e64\u8d3a\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a2a\u8861\u6052\u8f70\u54c4\u70d8\u8679\u9e3f\u6d2a\u5b8f\u5f18\u7ea2\u5589\u4faf\u7334\u543c\u539a\u5019\u540e\u547c\u4e4e\u5ffd\u745a\u58f6\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u62a4\u4e92\u6caa\u6237\u82b1\u54d7\u534e\u733e\u6ed1\u753b\u5212\u5316\u8bdd\u69d0\u5f8a\u6000\u6dee\u574f\u6b22\u73af\u6853\u8fd8\u7f13\u6362\u60a3\u5524\u75ea\u8c62\u7115\u6da3\u5ba6\u5e7b\u8352\u614c\u9ec4\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8c0e\u7070\u6325\u8f89\u5fbd\u6062\u86d4\u56de\u6bc1\u6094\u6167\u5349\u60e0\u6666\u8d3f\u79fd\u4f1a\u70e9\u6c47\u8bb3\u8bf2\u7ed8\u8364\u660f\u5a5a\u9b42\u6d51\u6df7\u8c41\u6d3b\u4f19\u706b\u83b7\u6216\u60d1\u970d\u8d27\u7978\u51fb\u573e\u57fa\u673a\u7578\u7a3d\u79ef\u7b95\u808c\u9965\u8ff9\u6fc0\u8ba5\u9e21\u59ec\u7ee9\u7f09\u5409\u6781\u68d8\u8f91\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7ea7\u6324\u51e0\u810a\u5df1\u84df\u6280\u5180\u5b63\u4f0e\u796d\u5242\u60b8\u6d4e\u5bc4\u5bc2\u8ba1\u8bb0\u65e2\u5fcc\u9645\u7ee7\u7eaa\u5609\u67b7\u5939\u4f73\u5bb6\u52a0\u835a\u988a\u8d3e\u7532\u94be\u5047\u7a3c\u4ef7\u67b6\u9a7e\u5ac1\u6b7c\u76d1\u575a\u5c16\u7b3a\u95f4\u714e\u517c\u80a9\u8270\u5978\u7f04\u8327\u68c0\u67ec\u78b1\u7877\u62e3\u6361\u7b80\u4fed\u526a\u51cf\u8350\u69db\u9274\u8df5\u8d31\u89c1\u952e\u7bad\u4ef6\u5065\u8230\u5251\u996f\u6e10\u6e85\u6da7\u5efa\u50f5\u59dc\u5c06\u6d46\u6c5f\u7586\u848b\u6868\u5956\u8bb2\u5320\u9171\u964d\u8549\u6912\u7901\u7126\u80f6\u4ea4\u90ca\u6d47\u9a84\u5a07\u56bc\u6405\u94f0\u77eb\u4fa5\u811a\u72e1\u89d2\u997a\u7f34\u7ede\u527f\u6559\u9175\u8f7f\u8f83\u53eb\u7a96\u63ed\u63a5\u7686\u79f8\u8857\u9636\u622a\u52ab\u8282\u830e\u775b\u6676\u9cb8\u4eac\u60ca\u7cbe\u7cb3\u7ecf\u4e95\u8b66\u666f\u9888\u9759\u5883\u656c\u955c\u5f84\u75c9\u9756\u7adf\u7ade\u51c0\u70af\u7a98\u63ea\u7a76\u7ea0\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u53a9\u6551\u65e7\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u9a79\u83ca\u5c40\u5480\u77e9\u4e3e\u6cae\u805a\u62d2\u636e\u5de8\u5177\u8ddd\u8e1e\u952f\u4ff1\u53e5\u60e7\u70ac\u5267\u6350\u9e43\u5a1f\u5026\u7737\u5377\u7ee2\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u6770\u6377\u776b\u7aed\u6d01\u7ed3\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8beb\u5c4a\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7d27\u9526\u4ec5\u8c28\u8fdb\u9773\u664b\u7981\u8fd1\u70ec\u6d78\u5c3d\u52b2\u8346\u5162\u89c9\u51b3\u8bc0\u7edd\u5747\u83cc\u94a7\u519b\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u9a8f\u5580\u5496\u5361\u54af\u5f00\u63e9\u6977\u51ef\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9897\u79d1\u58f3\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8bfe\u80af\u5543\u57a6\u6073\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u62a0\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5e93\u88e4\u5938\u57ae\u630e\u8de8\u80ef\u5757\u7b77\u4fa9\u5feb\u5bbd\u6b3e\u5321\u7b50\u72c2\u6846\u77ff\u7736\u65f7\u51b5\u4e8f\u76d4\u5cbf\u7aa5\u8475\u594e\u9b41\u5080\u9988\u6127\u6e83\u5764\u6606\u6346\u56f0\u62ec\u6269\u5ed3\u9614\u5783\u62c9\u5587\u8721\u814a\u8fa3\u5566\u83b1\u6765\u8d56\u84dd\u5a6a\u680f\u62e6\u7bee\u9611\u5170\u6f9c\u8c30\u63fd\u89c8\u61d2\u7f06\u70c2\u6ee5\u7405\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u635e\u52b3\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6d9d\u52d2\u4e50\u96f7\u956d\u857e\u78ca\u7d2f\u5121\u5792\u64c2\u808b\u7c7b\u6cea\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7bf1\u72f8\u79bb\u6f13\u7406\u674e\u91cc\u9ca4\u793c\u8389\u8354\u540f\u6817\u4e3d\u5389\u52b1\u783e\u5386\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u6ca5\u96b6\u529b\u7483\u54e9\u4fe9\u8054\u83b2\u8fde\u9570\u5ec9\u601c\u6d9f\u5e18\u655b\u8138\u94fe\u604b\u70bc\u7ec3\u7cae\u51c9\u6881\u7cb1\u826f\u4e24\u8f86\u91cf\u667e\u4eae\u8c05\u64a9\u804a\u50da\u7597\u71ce\u5be5\u8fbd\u6f66\u4e86\u6482\u9563\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u730e\u7433\u6797\u78f7\u9716\u4e34\u90bb\u9cde\u6dcb\u51db\u8d41\u541d\u62ce\u73b2\u83f1\u96f6\u9f84\u94c3\u4f36\u7f9a\u51cc\u7075\u9675\u5cad\u9886\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u998f\u7559\u5218\u7624\u6d41\u67f3\u516d\u9f99\u804b\u5499\u7b3c\u7abf\u9686\u5784\u62e2\u9647\u697c\u5a04\u6402\u7bd3\u6f0f\u964b\u82a6\u5362\u9885\u5e90\u7089\u63b3\u5364\u864f\u9c81\u9e93\u788c\u9732\u8def\u8d42\u9e7f\u6f5e\u7984\u5f55\u9646\u622e\u9a74\u5415\u94dd\u4fa3\u65c5\u5c65\u5c61\u7f15\u8651\u6c2f\u5f8b\u7387\u6ee4\u7eff\u5ce6\u631b\u5b6a\u6ee6\u5375\u4e71\u63a0\u7565\u62a1\u8f6e\u4f26\u4ed1\u6ca6\u7eb6\u8bba\u841d\u87ba\u7f57\u903b\u9523\u7ba9\u9aa1\u88f8\u843d\u6d1b\u9a86\u7edc\u5988\u9ebb\u739b\u7801\u8682\u9a6c\u9a82\u561b\u5417\u57cb\u4e70\u9ea6\u5356\u8fc8\u8109\u7792\u9992\u86ee\u6ee1\u8513\u66fc\u6162\u6f2b\u8c29\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u732b\u8305\u951a\u6bdb\u77db\u94c6\u536f\u8302\u5192\u5e3d\u8c8c\u8d38\u4e48\u73ab\u679a\u6885\u9176\u9709\u7164\u6ca1\u7709\u5a92\u9541\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u95e8\u95f7\u4eec\u840c\u8499\u6aac\u76df\u9530\u731b\u68a6\u5b5f\u772f\u919a\u9761\u7cdc\u8ff7\u8c1c\u5f25\u7c73\u79d8\u89c5\u6ccc\u871c\u5bc6\u5e42\u68c9\u7720\u7ef5\u5195\u514d\u52c9\u5a29\u7f05\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5e99\u5999\u8511\u706d\u6c11\u62bf\u76bf\u654f\u60af\u95fd\u660e\u879f\u9e23\u94ed\u540d\u547d\u8c2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8c0b\u725f\u67d0\u62c7\u7261\u4ea9\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5450\u94a0\u90a3\u5a1c\u7eb3\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96be\u56ca\u6320\u8111\u607c\u95f9\u6dd6\u5462\u9981\u5185\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u62df\u4f60\u533f\u817b\u9006\u6eba\u852b\u62c8\u5e74\u78be\u64b5\u637b\u5ff5\u5a18\u917f\u9e1f\u5c3f\u634f\u8042\u5b7d\u556e\u954a\u954d\u6d85\u60a8\u67e0\u72de\u51dd\u5b81\u62e7\u6cde\u725b\u626d\u94ae\u7ebd\u8113\u6d53\u519c\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u759f\u632a\u61e6\u7cef\u8bfa\u54e6\u6b27\u9e25\u6bb4\u85d5\u5455\u5076\u6ca4\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76d8\u78d0\u76fc\u7554\u5224\u53db\u4e53\u5e9e\u65c1\u802a\u80d6\u629b\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8d54\u966a\u914d\u4f69\u6c9b\u55b7\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9e4f\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a97\u98d8\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u9891\u8d2b\u54c1\u8058\u4e52\u576a\u82f9\u840d\u5e73\u51ed\u74f6\u8bc4\u5c4f\u5761\u6cfc\u9887\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u6251\u94fa\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6734\u5703\u666e\u6d66\u8c31\u66dd\u7011\u671f\u6b3a\u6816\u621a\u59bb\u4e03\u51c4\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u8110\u9f50\u65d7\u7948\u7941\u9a91\u8d77\u5c82\u4e5e\u4f01\u542f\u5951\u780c\u5668\u6c14\u8fc4\u5f03\u6c7d\u6ce3\u8bab\u6390\u6d3d\u7275\u6266\u948e\u94c5\u5343\u8fc1\u7b7e\u4edf\u8c26\u4e7e\u9ed4\u94b1\u94b3\u524d\u6f5c\u9063\u6d45\u8c34\u5811\u5d4c\u6b20\u6b49\u67aa\u545b\u8154\u7f8c\u5899\u8537\u5f3a\u62a2\u6a47\u9539\u6572\u6084\u6865\u77a7\u4e54\u4fa8\u5de7\u9798\u64ac\u7fd8\u5ced\u4fcf\u7a8d\u5207\u8304\u4e14\u602f\u7a83\u94a6\u4fb5\u4eb2\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5bdd\u6c81\u9752\u8f7b\u6c22\u503e\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9877\u8bf7\u5e86\u743c\u7a77\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8d8b\u533a\u86c6\u66f2\u8eaf\u5c48\u9a71\u6e20\u53d6\u5a36\u9f8b\u8da3\u53bb\u5708\u98a7\u6743\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u529d\u7f3a\u7094\u7638\u5374\u9e4a\u69b7\u786e\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8ba9\u9976\u6270\u7ed5\u60f9\u70ed\u58ec\u4ec1\u4eba\u5fcd\u97e7\u4efb\u8ba4\u5203\u598a\u7eab\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u8363\u878d\u7194\u6eb6\u5bb9\u7ed2\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8f6f\u962e\u854a\u745e\u9510\u95f0\u6da6\u82e5\u5f31\u6492\u6d12\u8428\u816e\u9cc3\u585e\u8d5b\u4e09\u53c1\u4f1e\u6563\u6851\u55d3\u4e27\u6414\u9a9a\u626b\u5ac2\u745f\u8272\u6da9\u68ee\u50e7\u838e\u7802\u6740\u5239\u6c99\u7eb1\u50bb\u5565\u715e\u7b5b\u6652\u73ca\u82eb\u6749\u5c71\u5220\u717d\u886b\u95ea\u9655\u64c5\u8d61\u81b3\u5584\u6c55\u6247\u7f2e\u5892\u4f24\u5546\u8d4f\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u70e7\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7ecd\u5962\u8d4a\u86c7\u820c\u820d\u8d66\u6444\u5c04\u6151\u6d89\u793e\u8bbe\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7ec5\u795e\u6c88\u5ba1\u5a76\u751a\u80be\u614e\u6e17\u58f0\u751f\u7525\u7272\u5347\u7ef3\u7701\u76db\u5269\u80dc\u5723\u5e08\u5931\u72ee\u65bd\u6e7f\u8bd7\u5c38\u8671\u5341\u77f3\u62fe\u65f6\u4ec0\u98df\u8680\u5b9e\u8bc6\u53f2\u77e2\u4f7f\u5c4e\u9a76\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52bf\u662f\u55dc\u566c\u9002\u4ed5\u4f8d\u91ca\u9970\u6c0f\u5e02\u6043\u5ba4\u89c6\u8bd5\u6536\u624b\u9996\u5b88\u5bff\u6388\u552e\u53d7\u7626\u517d\u852c\u67a2\u68b3\u6b8a\u6292\u8f93\u53d4\u8212\u6dd1\u758f\u4e66\u8d4e\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c5e\u672f\u8ff0\u6811\u675f\u620d\u7ad6\u5885\u5eb6\u6570\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e05\u6813\u62f4\u971c\u53cc\u723d\u8c01\u6c34\u7761\u7a0e\u542e\u77ac\u987a\u821c\u8bf4\u7855\u6714\u70c1\u65af\u6495\u5636\u601d\u79c1\u53f8\u4e1d\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u9972\u5df3\u677e\u8038\u6002\u9882\u9001\u5b8b\u8bbc\u8bf5\u641c\u8258\u64de\u55fd\u82cf\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8bc9\u8083\u9178\u849c\u7b97\u867d\u968b\u968f\u7ee5\u9ad3\u788e\u5c81\u7a57\u9042\u96a7\u795f\u5b59\u635f\u7b0b\u84d1\u68ad\u5506\u7f29\u7410\u7d22\u9501\u6240\u584c\u4ed6\u5b83\u5979\u5854\u736d\u631e\u8e4b\u8e0f\u80ce\u82d4\u62ac\u53f0\u6cf0\u915e\u592a\u6001\u6c70\u574d\u644a\u8d2a\u762b\u6ee9\u575b\u6a80\u75f0\u6f6d\u8c2d\u8c08\u5766\u6bef\u8892\u78b3\u63a2\u53f9\u70ad\u6c64\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u70eb\u638f\u6d9b\u6ed4\u7ee6\u8404\u6843\u9003\u6dd8\u9676\u8ba8\u5957\u7279\u85e4\u817e\u75bc\u8a8a\u68af\u5254\u8e22\u9511\u63d0\u9898\u8e44\u557c\u4f53\u66ff\u568f\u60d5\u6d95\u5243\u5c49\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u6761\u8fe2\u773a\u8df3\u8d34\u94c1\u5e16\u5385\u542c\u70c3\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u94dc\u5f64\u7ae5\u6876\u6345\u7b52\u7edf\u75db\u5077\u6295\u5934\u900f\u51f8\u79c3\u7a81\u56fe\u5f92\u9014\u6d82\u5c60\u571f\u5410\u5154\u6e4d\u56e2\u63a8\u9893\u817f\u8715\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u8131\u9e35\u9640\u9a6e\u9a7c\u692d\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u6d3c\u5a03\u74e6\u889c\u6b6a\u5916\u8c4c\u5f2f\u6e7e\u73a9\u987d\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u4e07\u8155\u6c6a\u738b\u4ea1\u6789\u7f51\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97e6\u8fdd\u6845\u56f4\u552f\u60df\u4e3a\u6f4d\u7ef4\u82c7\u840e\u59d4\u4f1f\u4f2a\u5c3e\u7eac\u672a\u851a\u5473\u754f\u80c3\u5582\u9b4f\u4f4d\u6e2d\u8c13\u5c09\u6170\u536b\u761f\u6e29\u868a\u6587\u95fb\u7eb9\u543b\u7a33\u7d0a\u95ee\u55e1\u7fc1\u74ee\u631d\u8717\u6da1\u7a9d\u6211\u65a1\u5367\u63e1\u6c83\u5deb\u545c\u94a8\u4e4c\u6c61\u8bec\u5c4b\u65e0\u829c\u68a7\u543e\u5434\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u575e\u620a\u96fe\u6664\u7269\u52ff\u52a1\u609f\u8bef\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u9521\u727a\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u88ad\u5e2d\u4e60\u5ab3\u559c\u94e3\u6d17\u7cfb\u9699\u620f\u7ec6\u778e\u867e\u5323\u971e\u8f96\u6687\u5ce1\u4fa0\u72ed\u4e0b\u53a6\u590f\u5413\u6380\u9528\u5148\u4ed9\u9c9c\u7ea4\u54b8\u8d24\u8854\u8237\u95f2\u6d8e\u5f26\u5acc\u663e\u9669\u73b0\u732e\u53bf\u817a\u9985\u7fa1\u5baa\u9677\u9650\u7ebf\u76f8\u53a2\u9576\u9999\u7bb1\u8944\u6e58\u4e61\u7fd4\u7965\u8be6\u60f3\u54cd\u4eab\u9879\u5df7\u6a61\u50cf\u5411\u8c61\u8427\u785d\u9704\u524a\u54ee\u56a3\u9500\u6d88\u5bb5\u6dc6\u6653\u5c0f\u5b5d\u6821\u8096\u5578\u7b11\u6548\u6954\u4e9b\u6b47\u874e\u978b\u534f\u631f\u643a\u90aa\u659c\u80c1\u8c10\u5199\u68b0\u5378\u87f9\u61c8\u6cc4\u6cfb\u8c22\u5c51\u85aa\u82af\u950c\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u8845\u661f\u8165\u7329\u60fa\u5174\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u51f6\u80f8\u5308\u6c79\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u9508\u79c0\u8896\u7ee3\u589f\u620c\u9700\u865a\u5618\u987b\u5f90\u8bb8\u84c4\u9157\u53d9\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7eea\u7eed\u8f69\u55a7\u5ba3\u60ac\u65cb\u7384\u9009\u7663\u7729\u7eda\u9774\u859b\u5b66\u7a74\u96ea\u8840\u52cb\u718f\u5faa\u65ec\u8be2\u5bfb\u9a6f\u5de1\u6b89\u6c5b\u8bad\u8baf\u900a\u8fc5\u538b\u62bc\u9e26\u9e2d\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u54d1\u4e9a\u8bb6\u7109\u54bd\u9609\u70df\u6df9\u76d0\u4e25\u7814\u8712\u5ca9\u5ef6\u8a00\u989c\u960e\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8273\u5830\u71d5\u538c\u781a\u96c1\u5501\u5f66\u7130\u5bb4\u8c1a\u9a8c\u6b83\u592e\u9e2f\u79e7\u6768\u626c\u4f6f\u75a1\u7f8a\u6d0b\u9633\u6c27\u4ef0\u75d2\u517b\u6837\u6f3e\u9080\u8170\u5996\u7476\u6447\u5c27\u9065\u7a91\u8c23\u59da\u54ac\u8200\u836f\u8981\u8000\u6930\u564e\u8036\u7237\u91ce\u51b6\u4e5f\u9875\u6396\u4e1a\u53f6\u66f3\u814b\u591c\u6db2\u4e00\u58f9\u533b\u63d6\u94f1\u4f9d\u4f0a\u8863\u9890\u5937\u9057\u79fb\u4eea\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5d\u6905\u8681\u501a\u5df2\u4e59\u77e3\u4ee5\u827a\u6291\u6613\u9091\u5c79\u4ebf\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u5fc6\u4e49\u76ca\u6ea2\u8be3\u8bae\u8c0a\u8bd1\u5f02\u7ffc\u7fcc\u7ece\u8335\u836b\u56e0\u6bb7\u97f3\u9634\u59fb\u541f\u94f6\u6deb\u5bc5\u996e\u5c39\u5f15\u9690\u5370\u82f1\u6a31\u5a74\u9e70\u5e94\u7f28\u83b9\u8424\u8425\u8367\u8747\u8fce\u8d62\u76c8\u5f71\u9896\u786c\u6620\u54df\u62e5\u4f63\u81c3\u75c8\u5eb8\u96cd\u8e0a\u86f9\u548f\u6cf3\u6d8c\u6c38\u607f\u52c7\u7528\u5e7d\u4f18\u60a0\u5fe7\u5c24\u7531\u90ae\u94c0\u72b9\u6cb9\u6e38\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8bf1\u53c8\u5e7c\u8fc2\u6de4\u4e8e\u76c2\u6986\u865e\u611a\u8206\u4f59\u4fde\u903e\u9c7c\u6109\u6e1d\u6e14\u9685\u4e88\u5a31\u96e8\u4e0e\u5c7f\u79b9\u5b87\u8bed\u7fbd\u7389\u57df\u828b\u90c1\u5401\u9047\u55bb\u5cea\u5fa1\u6108\u6b32\u72f1\u80b2\u8a89\u6d74\u5bd3\u88d5\u9884\u8c6b\u9a6d\u9e33\u6e0a\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f95\u56ed\u5458\u5706\u733f\u6e90\u7f18\u8fdc\u82d1\u613f\u6028\u9662\u66f0\u7ea6\u8d8a\u8dc3\u94a5\u5cb3\u7ca4\u6708\u60a6\u9605\u8018\u4e91\u90e7\u5300\u9668\u5141\u8fd0\u8574\u915d\u6655\u97f5\u5b55\u531d\u7838\u6742\u683d\u54c9\u707e\u5bb0\u8f7d\u518d\u5728\u54b1\u6512\u6682\u8d5e\u8d43\u810f\u846c\u906d\u7cdf\u51ff\u85fb\u67a3\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7076\u71e5\u8d23\u62e9\u5219\u6cfd\u8d3c\u600e\u589e\u618e\u66fe\u8d60\u624e\u55b3\u6e23\u672d\u8f67\u94e1\u95f8\u7728\u6805\u69a8\u548b\u4e4d\u70b8\u8bc8\u6458\u658b\u5b85\u7a84\u503a\u5be8\u77bb\u6be1\u8a79\u7c98\u6cbe\u76cf\u65a9\u8f97\u5d2d\u5c55\u8638\u6808\u5360\u6218\u7ad9\u6e5b\u7efd\u6a1f\u7ae0\u5f70\u6f33\u5f20\u638c\u6da8\u6756\u4e08\u5e10\u8d26\u4ed7\u80c0\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d75\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u86f0\u8f99\u8005\u9517\u8517\u8fd9\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8d1e\u9488\u4fa6\u6795\u75b9\u8bca\u9707\u632f\u9547\u9635\u84b8\u6323\u7741\u5f81\u72f0\u4e89\u6014\u6574\u62ef\u6b63\u653f\u5e27\u75c7\u90d1\u8bc1\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7ec7\u804c\u76f4\u690d\u6b96\u6267\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7eb8\u5fd7\u631a\u63b7\u81f3\u81f4\u7f6e\u5e1c\u5cd9\u5236\u667a\u79e9\u7a1a\u8d28\u7099\u75d4\u6ede\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u949f\u8877\u7ec8\u79cd\u80bf\u91cd\u4ef2\u4f17\u821f\u5468\u5dde\u6d32\u8bcc\u7ca5\u8f74\u8098\u5e1a\u5492\u76b1\u5b99\u663c\u9aa4\u73e0\u682a\u86db\u6731\u732a\u8bf8\u8bdb\u9010\u7af9\u70db\u716e\u62c4\u77a9\u5631\u4e3b\u8457\u67f1\u52a9\u86c0\u8d2e\u94f8\u7b51\u4f4f\u6ce8\u795d\u9a7b\u6293\u722a\u62fd\u4e13\u7816\u8f6c\u64b0\u8d5a\u7bc6\u6869\u5e84\u88c5\u5986\u649e\u58ee\u72b6\u690e\u9525\u8ffd\u8d58\u5760\u7f00\u8c06\u51c6\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u7740\u707c\u6d4a\u5179\u54a8\u8d44\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6e0d\u5b57\u9b03\u68d5\u8e2a\u5b97\u7efc\u603b\u7eb5\u90b9\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8bc5\u963b\u7ec4\u94bb\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9515\u55f3\u5ad2\u7477\u66a7\u972d\u8c19\u94f5\u9e4c\u5aaa\u9a9c\u9ccc\u94af\u5457\u94a3\u9e28\u9f85\u9e4e\u8d32\u951b\u835c\u54d4\u6ed7\u94cb\u7b5a\u8df8\u82c4\u7f0f\u7b3e\u9aa0\u98d1\u98d9\u9556\u9573\u9cd4\u50a7\u7f24\u69df\u6ba1\u8191\u9554\u9acc\u9b13\u7980\u997d\u94b9\u9e41\u94b8\u9a96\u9eea\u607b\u9538\u4faa\u9497\u5181\u8c04\u8c36\u8487\u5fcf\u5a75\u9aa3\u89c7\u7985\u9561\u4f25\u82cc\u6005\u960a\u9cb3\u7817\u4f27\u8c0c\u6987\u789c\u9f80\u67a8\u67fd\u94d6\u94db\u996c\u9e31\u94f3\u4fe6\u5e31\u96e0\u520d\u7ecc\u8e70\u948f\u6006\u7f0d\u9e51\u8f8d\u9f8a\u9e5a\u82c1\u9aa2\u679e\u8f8f\u64ba\u9509\u9e7e\u54d2\u9791\u9a80\u7ed0\u6b9a\u8d55\u7605\u7baa\u8c20\u7800\u88c6\u7118\u956b\u7c74\u8bcb\u8c1b\u7ee8\u89cc\u955d\u5dc5\u94bf\u766b\u94eb\u9cb7\u9cbd\u94e4\u94e5\u5cbd\u9e2b\u7aa6\u6e0e\u691f\u724d\u7b03\u9ee9\u7c16\u603c\u9566\u7096\u8db8\u94ce\u8c14\u57a9\u960f\u8f6d\u9507\u9537\u9e57\u989a\u989b\u9cc4\u8bf6\u8fe9\u94d2\u9e38\u9c95\u94ab\u9c82\u7eef\u9544\u9cb1\u507e\u6ca3\u51eb\u9a78\u7ec2\u7ecb\u8d59\u9eb8\u9c8b\u9cc6\u9486\u8d45\u5c34\u64c0\u7ec0\u6206\u777e\u8bf0\u7f1f\u9506\u7ea5\u9549\u988d\u4e98\u8d53\u7ee0\u9ca0\u8bdf\u7f11\u89cf\u8bc2\u6bc2\u94b4\u9522\u9e2a\u9e44\u9e58\u9e39\u63b4\u8bd6\u63bc\u9e73\u9ccf\u72b7\u5326\u523f\u59ab\u6867\u9c91\u9cdc\u886e\u7ef2\u9ca7\u57da\u5459\u5e3c\u6901\u8748\u94ea\u961a\u7ed7\u9889\u704f\u98a2\u8bc3\u9616\u86ce\u9ec9\u8ba7\u836d\u95f3\u9c8e\u6d52\u9e55\u9a85\u6866\u94e7\u5942\u7f33\u953e\u9ca9\u9cc7\u8bd9\u835f\u54d5\u6d4d\u7f0b\u73f2\u6656\u8be8\u9984\u960d\u94ac\u956c\u8ba6\u8bd8\u8360\u53fd\u54dc\u9aa5\u7391\u89ca\u9f51\u77f6\u7f81\u867f\u8dfb\u9701\u9c9a\u9cab\u90cf\u6d43\u94d7\u9553\u86f2\u8c0f\u7f23\u620b\u622c\u7751\u9e63\u7b15\u9ca3\u97af\u7edb\u7f30\u6322\u5ce4\u9e6a\u9c9b\u7596\u988c\u9c92\u537a\u8369\u9991\u7f19\u8d46\u89d0\u522d\u6cfe\u8ff3\u5f2a\u80eb\u9753\u9604\u9e20\u9e6b\u8bb5\u5c66\u6989\u98d3\u949c\u9514\u7aad\u9f83\u9529\u954c\u96bd\u8c32\u73cf\u76b2\u5240\u57b2\u5ffe\u607a\u94e0\u9534\u9f9b\u95f6\u94aa\u94d0\u9a92\u7f02\u8f72\u94b6\u951e\u9894\u9f88\u94ff\u55be\u90d0\u54d9\u810d\u72ef\u9acb\u8bd3\u8bf3\u909d\u5739\u7ea9\u8d36\u532e\u8489\u6126\u8069\u7bd1\u9603\u951f\u9cb2\u86f4\u5d03\u5f95\u6d9e\u6fd1\u8d49\u7750\u94fc\u765e\u7c41\u5c9a\u6984\u6593\u9567\u8934\u9606\u9512\u5520\u5d02\u94d1\u94f9\u75e8\u9cd3\u8bd4\u7f27\u4fea\u90e6\u575c\u82c8\u8385\u84e0\u5456\u9026\u9a8a\u7f21\u67a5\u680e\u8f79\u783a\u9502\u9e42\u75a0\u7c9d\u8dde\u96f3\u9ca1\u9ce2\u8539\u5941\u6f4b\u740f\u6b93\u88e2\u88e3\u9ca2\u9b49\u7f2d\u948c\u9e69\u853a\u5eea\u6aa9\u8f9a\u8e8f\u7eeb\u68c2\u86cf\u9cae\u6d4f\u9a9d\u7efa\u954f\u9e68\u830f\u6cf7\u73d1\u680a\u80e7\u783b\u507b\u848c\u55bd\u5d5d\u9542\u7618\u8027\u877c\u9ac5\u5786\u64b8\u565c\u95fe\u6cf8\u6e0c\u680c\u6a79\u8f73\u8f82\u8f98\u6c07\u80ea\u9e2c\u9e6d\u823b\u9c88\u8114\u5a08\u683e\u9e3e\u92ae\u56f5\u8366\u7321\u6cfa\u6924\u8136\u9559\u6988\u891b\u950a\u5452\u551b\u5b37\u6769\u52a2\u7f26\u9558\u98a1\u9cd7\u9ebd\u626a\u7116\u61d1\u9494\u8288\u8c27\u7315\u7962\u6e11\u817c\u9efe\u7f08\u7f2a\u95f5\u7f17\u8c1f\u84e6\u998d\u6b81\u9546\u94bc\u94d9\u8bb7\u94cc\u9cb5\u8f87\u9cb6\u8311\u8885\u9667\u8616\u55eb\u989f\u8e51\u82ce\u549b\u804d\u4fac\u54dd\u9a7d\u9495\u50a9\u8bb4\u6004\u74ef\u8e52\u75b1\u8f94\u7eb0\u7f74\u94cd\u8c1d\u9a88\u7f25\u5ad4\u948b\u9564\u9568\u8572\u9a90\u7eee\u6864\u789b\u9880\u9883\u9ccd\u4f65\u8368\u60ad\u9a9e\u7f31\u6920\u94a4\u5af1\u6a2f\u6217\u709d\u9516\u9535\u956a\u7f9f\u8dc4\u8bee\u8c2f\u835e\u7f32\u7857\u8df7\u60ec\u9532\u7ba7\u9513\u63ff\u9cad\u8315\u86f1\u5def\u8d47\u866e\u9cc5\u8bce\u5c96\u9612\u89d1\u9e32\u8be0\u7efb\u8f81\u94e8\u9615\u9619\u60ab\u835b\u5a06\u6861\u996a\u8f6b\u5d58\u877e\u7f1b\u94f7\u98a6\u86ac\u98d2\u6bf5\u7cc1\u7f2b\u556c\u94ef\u7a51\u94e9\u9ca8\u917e\u8baa\u59d7\u9a9f\u9490\u9cdd\u57a7\u6b87\u89de\u538d\u6ee0\u7572\u8bdc\u8c02\u6e16\u8c25\u57d8\u83b3\u5f11\u8f7c\u8d33\u94c8\u9ca5\u7ef6\u6445\u7ebe\u95e9\u94c4\u53ae\u9a77\u7f0c\u9536\u9e36\u85ae\u998a\u98d5\u953c\u8c21\u7a23\u8c07\u836a\u72f2\u5522\u7743\u95fc\u94ca\u9cce\u949b\u9c90\u6619\u94bd\u952c\u9878\u50a5\u9967\u94f4\u9557\u97ec\u94fd\u7f07\u9e48\u9617\u7c9c\u9f86\u9ca6\u6078\u94ad\u948d\u629f\u9968\u7ba8\u9f0d\u5a32\u817d\u7ea8\u7efe\u8f8b\u8bff\u5e0f\u95f1\u6ca9\u6da0\u73ae\u97ea\u709c\u9c94\u960c\u83b4\u9f8c\u90ac\u5e91\u6003\u59a9\u9a9b\u9e49\u9e5c\u9969\u960b\u73ba\u89cb\u7856\u82cb\u83b6\u85d3\u5c98\u7303\u5a34\u9e47\u75eb\u869d\u7c7c\u8df9\u8297\u9977\u9aa7\u7f03\u98e8\u54d3\u6f47\u9a81\u7ee1\u67ad\u7bab\u4eb5\u64b7\u7ec1\u7f2c\u9649\u8365\u9990\u9e3a\u8be9\u987c\u8c16\u94c9\u955f\u8c11\u6cf6\u9cd5\u57d9\u6d54\u9c9f\u57ad\u5a05\u6860\u6c29\u53a3\u8d5d\u4fe8\u5156\u8c33\u6079\u95eb\u917d\u9b47\u990d\u9f39\u7080\u8f7a\u9e5e\u9cd0\u9765\u8c12\u90ba\u6654\u70e8\u8bd2\u5453\u5cc4\u9974\u603f\u9a7f\u7f22\u8f76\u8d3b\u9487\u9552\u9571\u7617\u8223\u94df\u763e\u8314\u83ba\u8426\u84e5\u6484\u5624\u6ee2\u6f46\u748e\u9e66\u763f\u988f\u7f42\u955b\u83b8\u94d5\u9c7f\u4f1b\u4fe3\u8c00\u8c15\u84e3\u5d5b\u996b\u9608\u59aa\u7ea1\u89ce\u6b24\u94b0\u9e46\u9e6c\u9f89\u6a7c\u9e22\u9f0b\u94ba\u90d3\u82b8\u607d\u6120\u7ead\u97eb\u6b92\u6c32\u74d2\u8db1\u933e\u9a75\u8d5c\u5567\u5e3b\u7ba6\u8c2e\u7f2f\u8c35\u8bcf\u948a\u8c2a\u8f84\u9e67\u6d48\u7f1c\u6862\u8f78\u8d48\u796f\u9e29\u8be4\u5ce5\u94b2\u94ee\u7b5d\u9a98\u6809\u6800\u8f75\u8f7e\u8d3d\u9e37\u86f3\u7d77\u8e2c\u8e2f\u89ef\u953a\u7ea3\u7ec9\u4f2b\u69e0\u94e2\u556d\u9994\u989e\u9a93\u7f12\u8bfc\u956f\u8c18\u7f01\u8f8e\u8d40\u7726\u9531\u9f87\u9cbb\u506c\u8bf9\u9a7a\u9cb0\u955e\u7f35\u8e9c\u9cdf\u8ba0\u8c2b\u90c4\u52d0\u51fc\u5742\u5785\u57b4\u57ef\u57dd\u82d8\u836c\u836e\u839c\u83bc\u83f0\u85c1\u63f8\u5412\u5423\u5494\u549d\u54b4\u5658\u567c\u56af\u5e5e\u5c99\u5d74\u5f77\u5fbc\u72b8\u72cd\u9980\u9987\u9993\u9995\u6123\u61b7\u61d4\u4e2c\u6e86\u6edf\u6eb7\u6f24\u6f74\u6fb9\u752f\u7e9f\u7ed4\u7ef1\u73c9\u67a7\u684a\u6849\u69d4\u6a65\u8f71\u8f77\u8d4d\u80b7\u80e8\u98da\u7173\u7145\u7198\u610d\u6dfc\u781c\u78d9\u770d\u949a\u94b7\u94d8\u94de\u9503\u950d\u950e\u950f\u9518\u951d\u952a\u952b\u953f\u9545\u954e\u9562\u9565\u9569\u9572\u7a06\u9e4b\u9e5b\u9e71\u75ac\u75b4\u75d6\u766f\u88e5\u8941\u8022\u98a5\u87a8\u9eb4\u9c85\u9c86\u9c87\u9c9e\u9cb4\u9cba\u9cbc\u9cca\u9ccb\u9cd8\u9cd9\u9792\u97b4\u9f44",Che="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u769a\u764c\u85f9\u77ee\u827e\u7919\u611b\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u9aaf\u6602\u76ce\u51f9\u6556\u71ac\u7ffa\u8956\u50b2\u5967\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u58e9\u9738\u7f77\u7238\u767d\u67cf\u767e\u64fa\u4f70\u6557\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9812\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u8fa6\u7d46\u90a6\u5e6b\u6886\u699c\u8180\u7d81\u68d2\u78c5\u868c\u938a\u508d\u8b17\u82de\u80de\u5305\u8912\u525d\u8584\u96f9\u4fdd\u5821\u98fd\u5bf6\u62b1\u5831\u66b4\u8c79\u9b91\u7206\u676f\u7891\u60b2\u5351\u5317\u8f29\u80cc\u8c9d\u92c7\u500d\u72fd\u5099\u618a\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7e43\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b46\u5f7c\u78a7\u84d6\u853d\u7562\u6583\u6bd6\u5e63\u5e87\u75f9\u9589\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u908a\u7de8\u8cb6\u6241\u4fbf\u8b8a\u535e\u8fa8\u8faf\u8fae\u904d\u6a19\u5f6a\u8198\u8868\u9c49\u618b\u5225\u765f\u5f6c\u658c\u7015\u6ff1\u8cd3\u64ef\u5175\u51b0\u67c4\u4e19\u79c9\u9905\u70b3\u75c5\u4e26\u73bb\u83e0\u64ad\u64a5\u7f3d\u6ce2\u535a\u52c3\u640f\u9251\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u99c1\u6355\u8514\u54fa\u88dc\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8ca1\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c3\u8836\u6b98\u615a\u6158\u71e6\u84bc\u8259\u5009\u6ec4\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5ec1\u7b56\u5074\u518a\u6e2c\u5c64\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8a6b\u62c6\u67f4\u8c7a\u6519\u647b\u87ec\u995e\u8b92\u7e8f\u93df\u7522\u95e1\u986b\u660c\u7316\u5834\u5617\u5e38\u9577\u511f\u8178\u5ee0\u655e\u66a2\u5531\u5021\u8d85\u6284\u9214\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8eca\u626f\u64a4\u63a3\u5fb9\u6f88\u90f4\u81e3\u8fb0\u5875\u6668\u5ff1\u6c88\u9673\u8d81\u896f\u6490\u7a31\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u61f2\u6f84\u8aa0\u627f\u901e\u9a01\u79e4\u5403\u7661\u6301\u5319\u6c60\u9072\u5f1b\u99b3\u6065\u9f52\u4f88\u5c3a\u8d64\u7fc5\u65a5\u71be\u5145\u6c96\u87f2\u5d07\u5bf5\u62bd\u916c\u7587\u8e8a\u7a20\u6101\u7c4c\u4ec7\u7da2\u7785\u919c\u81ed\u521d\u51fa\u6ae5\u5eda\u8e87\u92e4\u96db\u6ec1\u9664\u695a\u790e\u5132\u77d7\u6410\u89f8\u8655\u63e3\u5ddd\u7a7f\u693d\u50b3\u8239\u5598\u4e32\u7621\u7a97\u5e62\u5e8a\u95d6\u5275\u5439\u708a\u6376\u9318\u5782\u6625\u693f\u9187\u5507\u6df3\u7d14\u8822\u6233\u7dbd\u75b5\u8328\u78c1\u96cc\u8fad\u6148\u74f7\u8a5e\u6b64\u523a\u8cdc\u6b21\u8070\u8525\u56ea\u5306\u5f9e\u53e2\u6e4a\u7c97\u918b\u7c07\u4fc3\u8ea5\u7be1\u7ac4\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u932f\u642d\u9054\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e36\u6b86\u4ee3\u8cb8\u888b\u5f85\u902e\u6020\u803d\u64d4\u4e39\u55ae\u9132\u64a3\u81bd\u65e6\u6c2e\u4f46\u619a\u6de1\u8a95\u5f48\u86cb\u7576\u64cb\u9ee8\u8569\u6a94\u5200\u6417\u8e48\u5012\u5cf6\u79b1\u5c0e\u5230\u7a3b\u60bc\u9053\u76dc\u5fb7\u5f97\u7684\u8e6c\u71c8\u767b\u7b49\u77aa\u51f3\u9127\u5824\u4f4e\u6ef4\u8fea\u6575\u7b1b\u72c4\u6ecc\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u905e\u7de0\u985b\u6382\u6ec7\u7898\u9ede\u5178\u975b\u588a\u96fb\u4f43\u7538\u5e97\u60e6\u5960\u6fb1\u6bbf\u7889\u53fc\u96d5\u96d5\u5201\u6389\u540a\u91e3\u8abf\u8dcc\u7239\u789f\u8776\u53e0\u8adc\u758a\u4e01\u76ef\u53ee\u91d8\u9802\u9f0e\u9320\u5b9a\u8a02\u4e1f\u6771\u51ac\u8463\u61c2\u52d5\u68df\u4f97\u606b\u51cd\u6d1e\u515c\u6296\u9b25\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u72a2\u7368\u8b80\u5835\u7779\u8ced\u675c\u934d\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u935b\u6bb5\u65b7\u7dde\u5806\u514c\u968a\u5c0d\u58a9\u5678\u8e72\u6566\u9813\u56e4\u920d\u76fe\u9041\u6387\u54c6\u591a\u596a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u58ae\u86fe\u5ce8\u9d5d\u4fc4\u984d\u8a1b\u5a25\u60e1\u5384\u627c\u904f\u9102\u9913\u6069\u800c\u5152\u8033\u723e\u990c\u6d31\u4e8c\u8cb3\u767c\u7f70\u7b4f\u4f10\u4e4f\u95a5\u6cd5\u743a\u85e9\u5e06\u756a\u7ffb\u6a0a\u792c\u91e9\u7e41\u51e1\u7169\u53cd\u8fd4\u7bc4\u8ca9\u72af\u98ef\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8a2a\u7d21\u653e\u83f2\u975e\u5561\u98db\u80a5\u532a\u8ab9\u5420\u80ba\u5ee2\u6cb8\u8cbb\u82ac\u915a\u5429\u6c1b\u5206\u7d1b\u58b3\u711a\u6c7e\u7c89\u596e\u4efd\u5fff\u61a4\u7cde\u8c50\u5c01\u6953\u8702\u5cf0\u92d2\u98a8\u760b\u70fd\u9022\u99ae\u7e2b\u8af7\u5949\u9cf3\u4f5b\u5426\u592b\u6577\u819a\u5b75\u6276\u62c2\u8f3b\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u64ab\u8f14\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8ce6\u5fa9\u5085\u4ed8\u961c\u7236\u8179\u8ca0\u5bcc\u8a03\u9644\u5a66\u7e1b\u5490\u5676\u560e\u8a72\u6539\u6982\u9223\u84cb\u6e89\u5e79\u7518\u687f\u67d1\u7aff\u809d\u8d95\u611f\u7a08\u6562\u8d1b\u5ca1\u525b\u92fc\u7f38\u809b\u7db1\u5d17\u6e2f\u6760\u7bd9\u81ef\u9ad8\u818f\u7f94\u7cd5\u641e\u93ac\u7a3f\u544a\u54e5\u6b4c\u64f1\u6208\u9d3f\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u95a3\u9694\u927b\u500b\u5404\u7d66\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f94\u4f9b\u8eac\u516c\u5bae\u5f13\u978f\u6c5e\u62f1\u8ca2\u5171\u9264\u52fe\u6e9d\u830d\u72d7\u57a2\u69cb\u8cfc\u5920\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u8831\u9aa8\u8c37\u80a1\u6545\u9867\u56fa\u96c7\u522e\u74dc\u526e\u5be1\u639b\u8902\u4e56\u62d0\u602a\u68fa\u95dc\u5b98\u51a0\u89c0\u7ba1\u9928\u7f50\u6163\u704c\u8cab\u5149\u5ee3\u901b\u7470\u898f\u572d\u77fd\u6b78\u9f9c\u95a8\u8ecc\u9b3c\u8a6d\u7678\u6842\u6ac3\u8dea\u8cb4\u528a\u8f25\u6efe\u68cd\u934b\u90ed\u570b\u679c\u88f9\u904e\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u99ed\u9163\u61a8\u90af\u97d3\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6f22\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u865f\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u95a1\u6cb3\u6db8\u8d6b\u8910\u9db4\u8cc0\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a6b\u8861\u6052\u8f5f\u54c4\u70d8\u8679\u9d3b\u6d2a\u5b8f\u5f18\u7d05\u5589\u4faf\u7334\u543c\u539a\u5019\u5f8c\u547c\u4e4e\u5ffd\u745a\u58fa\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u8b77\u4e92\u6eec\u6236\u82b1\u5629\u83ef\u733e\u6ed1\u756b\u5283\u5316\u8a71\u69d0\u5f8a\u61f7\u6dee\u58de\u6b61\u74b0\u6853\u9084\u7de9\u63db\u60a3\u559a\u7613\u8c62\u7165\u6e19\u5ba6\u5e7b\u8352\u614c\u9ec3\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8b0a\u7070\u63ee\u8f1d\u5fbd\u6062\u86d4\u56de\u6bc0\u6094\u6167\u5349\u60e0\u6666\u8cc4\u7a62\u6703\u71f4\u532f\u8af1\u8aa8\u7e6a\u8477\u660f\u5a5a\u9b42\u6e3e\u6df7\u8c41\u6d3b\u5925\u706b\u7372\u6216\u60d1\u970d\u8ca8\u798d\u64ca\u573e\u57fa\u6a5f\u7578\u7a3d\u7a4d\u7b95\u808c\u9951\u8de1\u6fc0\u8b4f\u96de\u59ec\u7e3e\u7ddd\u5409\u6975\u68d8\u8f2f\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7d1a\u64e0\u5e7e\u810a\u5df1\u858a\u6280\u5180\u5b63\u4f0e\u796d\u5291\u60b8\u6fdf\u5bc4\u5bc2\u8a08\u8a18\u65e2\u5fcc\u969b\u7e7c\u7d00\u5609\u67b7\u593e\u4f73\u5bb6\u52a0\u83a2\u9830\u8cc8\u7532\u9240\u5047\u7a3c\u50f9\u67b6\u99d5\u5ac1\u6bb2\u76e3\u5805\u5c16\u7b8b\u9593\u714e\u517c\u80a9\u8271\u5978\u7dd8\u7e6d\u6aa2\u67ec\u583f\u9e7c\u63c0\u64bf\u7c21\u5109\u526a\u6e1b\u85a6\u6abb\u9452\u8e10\u8ce4\u898b\u9375\u7bad\u4ef6\u5065\u8266\u528d\u991e\u6f38\u6ffa\u6f97\u5efa\u50f5\u59dc\u5c07\u6f3f\u6c5f\u7586\u8523\u69f3\u734e\u8b1b\u5320\u91ac\u964d\u8549\u6912\u7901\u7126\u81a0\u4ea4\u90ca\u6f86\u9a55\u5b0c\u56bc\u652a\u9278\u77ef\u50e5\u8173\u72e1\u89d2\u9903\u7e73\u7d5e\u527f\u6559\u9175\u8f4e\u8f03\u53eb\u7a96\u63ed\u63a5\u7686\u7a2d\u8857\u968e\u622a\u52ab\u7bc0\u8396\u775b\u6676\u9be8\u4eac\u9a5a\u7cbe\u7cb3\u7d93\u4e95\u8b66\u666f\u9838\u975c\u5883\u656c\u93e1\u5f91\u75d9\u9756\u7adf\u7af6\u51c8\u70af\u7a98\u63ea\u7a76\u7cfe\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u5ec4\u6551\u820a\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u99d2\u83ca\u5c40\u5480\u77e9\u8209\u6cae\u805a\u62d2\u64da\u5de8\u5177\u8ddd\u8e1e\u92f8\u4ff1\u53e5\u61fc\u70ac\u5287\u6350\u9d51\u5a1f\u5026\u7737\u5377\u7d79\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u5091\u6377\u776b\u7aed\u6f54\u7d50\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8aa1\u5c46\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7dca\u9326\u50c5\u8b39\u9032\u9773\u6649\u7981\u8fd1\u71fc\u6d78\u76e1\u52c1\u834a\u5162\u89ba\u6c7a\u8a23\u7d55\u5747\u83cc\u921e\u8ecd\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u99ff\u5580\u5496\u5361\u54af\u958b\u63e9\u6977\u51f1\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9846\u79d1\u6bbc\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8ab2\u80af\u5543\u58be\u61c7\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u6473\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5eab\u8932\u8a87\u57ae\u630e\u8de8\u80ef\u584a\u7b77\u5108\u5feb\u5bec\u6b3e\u5321\u7b50\u72c2\u6846\u7926\u7736\u66e0\u6cc1\u8667\u76d4\u5dcb\u7aba\u8475\u594e\u9b41\u5080\u994b\u6127\u6f70\u5764\u6606\u6346\u56f0\u62ec\u64f4\u5ed3\u95ca\u5783\u62c9\u5587\u881f\u81d8\u8fa3\u5566\u840a\u4f86\u8cf4\u85cd\u5a6a\u6b04\u6514\u7c43\u95cc\u862d\u703e\u8b95\u652c\u89bd\u61f6\u7e9c\u721b\u6feb\u746f\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u6488\u52de\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6f87\u52d2\u6a02\u96f7\u9433\u857e\u78ca\u7d2f\u5121\u58d8\u64c2\u808b\u985e\u6dda\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7c6c\u8c8d\u96e2\u6f13\u7406\u674e\u88cf\u9bc9\u79ae\u8389\u8354\u540f\u6817\u9e97\u53b2\u52f5\u792b\u6b77\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u701d\u96b8\u529b\u7483\u54e9\u5006\u806f\u84ee\u9023\u942e\u5ec9\u6190\u6f23\u7c3e\u6582\u81c9\u93c8\u6200\u7149\u7df4\u7ce7\u6dbc\u6881\u7cb1\u826f\u5169\u8f1b\u91cf\u667e\u4eae\u8ad2\u64a9\u804a\u50da\u7642\u71ce\u5be5\u907c\u6f66\u4e86\u6482\u9410\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u7375\u7433\u6797\u78f7\u9716\u81e8\u9130\u9c57\u6dcb\u51dc\u8cc3\u541d\u62ce\u73b2\u83f1\u96f6\u9f61\u9234\u4f36\u7f9a\u6de9\u9748\u9675\u5dba\u9818\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u993e\u7559\u5289\u7624\u6d41\u67f3\u516d\u9f8d\u807e\u56a8\u7c60\u7abf\u9686\u58df\u650f\u96b4\u6a13\u5a41\u645f\u7c0d\u6f0f\u964b\u8606\u76e7\u9871\u5eec\u7210\u64c4\u9e75\u865c\u9b6f\u9e93\u788c\u9732\u8def\u8cc2\u9e7f\u6f5e\u797f\u9304\u9678\u622e\u9a62\u5442\u92c1\u4fb6\u65c5\u5c65\u5c62\u7e37\u616e\u6c2f\u5f8b\u7387\u6ffe\u7da0\u5dd2\u6523\u5b7f\u7064\u5375\u4e82\u63a0\u7565\u6384\u8f2a\u502b\u4f96\u6dea\u7db8\u8ad6\u863f\u87ba\u7f85\u908f\u947c\u7c6e\u9a3e\u88f8\u843d\u6d1b\u99f1\u7d61\u5abd\u9ebb\u746a\u78bc\u879e\u99ac\u7f75\u561b\u55ce\u57cb\u8cb7\u9ea5\u8ce3\u9081\u8108\u779e\u9945\u883b\u6eff\u8513\u66fc\u6162\u6f2b\u8b3e\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u8c93\u8305\u9328\u6bdb\u77db\u925a\u536f\u8302\u5192\u5e3d\u8c8c\u8cbf\u9ebd\u73ab\u679a\u6885\u9176\u9ef4\u7164\u6c92\u7709\u5a92\u9382\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u9580\u60b6\u5011\u840c\u8499\u6aac\u76df\u9333\u731b\u5922\u5b5f\u7787\u919a\u9761\u7cdc\u8ff7\u8b0e\u5f4c\u7c73\u79d8\u8993\u6ccc\u871c\u5bc6\u51aa\u68c9\u7720\u7dbf\u5195\u514d\u52c9\u5a29\u7dec\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5edf\u5999\u8511\u6ec5\u6c11\u62bf\u76bf\u654f\u61ab\u95a9\u660e\u879f\u9cf4\u9298\u540d\u547d\u8b2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8b00\u725f\u67d0\u62c7\u7261\u755d\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5436\u9209\u90a3\u5a1c\u7d0d\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96e3\u56ca\u6493\u8166\u60f1\u9b27\u6dd6\u5462\u9912\u5167\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u64ec\u59b3\u533f\u81a9\u9006\u6eba\u852b\u62c8\u5e74\u78be\u6506\u649a\u5ff5\u5a18\u91c0\u9ce5\u5c3f\u634f\u8076\u5b7d\u5699\u9477\u93b3\u6d85\u60a8\u6ab8\u7370\u51dd\u5be7\u64f0\u6fd8\u725b\u626d\u9215\u7d10\u81bf\u6fc3\u8fb2\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u7627\u632a\u61e6\u7cef\u8afe\u54e6\u6b50\u9dd7\u6bc6\u85d5\u5614\u5076\u6f1a\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76e4\u78d0\u76fc\u7554\u5224\u53db\u4e53\u9f90\u65c1\u802a\u80d6\u62cb\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8ce0\u966a\u914d\u4f69\u6c9b\u5674\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9d6c\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a19\u98c4\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u983b\u8ca7\u54c1\u8058\u4e52\u576a\u860b\u840d\u5e73\u6191\u74f6\u8a55\u5c4f\u5761\u6f51\u9817\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u64b2\u92ea\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6a38\u5703\u666e\u6d66\u8b5c\u66dd\u7011\u671f\u6b3a\u68f2\u621a\u59bb\u4e03\u6dd2\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u81cd\u9f4a\u65d7\u7948\u7941\u9a0e\u8d77\u8c48\u4e5e\u4f01\u555f\u5951\u780c\u5668\u6c23\u8fc4\u68c4\u6c7d\u6ce3\u8a16\u6390\u6d3d\u727d\u6261\u91ec\u925b\u5343\u9077\u7c3d\u4edf\u8b19\u4e7e\u9ed4\u9322\u9257\u524d\u6f5b\u9063\u6dfa\u8b74\u5879\u5d4c\u6b20\u6b49\u69cd\u55c6\u8154\u7f8c\u58bb\u8594\u5f37\u6436\u6a47\u936c\u6572\u6084\u6a4b\u77a7\u55ac\u50d1\u5de7\u9798\u64ac\u7ff9\u5ced\u4fcf\u7ac5\u5207\u8304\u4e14\u602f\u7aca\u6b3d\u4fb5\u89aa\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5be2\u6c81\u9752\u8f15\u6c2b\u50be\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9803\u8acb\u6176\u74ca\u7aae\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8da8\u5340\u86c6\u66f2\u8ec0\u5c48\u9a45\u6e20\u53d6\u5a36\u9f72\u8da3\u53bb\u5708\u9874\u6b0a\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u52f8\u7f3a\u7094\u7638\u537b\u9d72\u69b7\u78ba\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8b93\u9952\u64fe\u7e5e\u60f9\u71b1\u58ec\u4ec1\u4eba\u5fcd\u97cc\u4efb\u8a8d\u5203\u598a\u7d09\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u69ae\u878d\u7194\u6eb6\u5bb9\u7d68\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8edf\u962e\u854a\u745e\u92b3\u958f\u6f64\u82e5\u5f31\u6492\u7051\u85a9\u816e\u9c13\u585e\u8cfd\u4e09\u4e09\u5098\u6563\u6851\u55d3\u55aa\u6414\u9a37\u6383\u5ac2\u745f\u8272\u6f80\u68ee\u50e7\u838e\u7802\u6bba\u524e\u6c99\u7d17\u50bb\u5565\u715e\u7be9\u66ec\u73ca\u82eb\u6749\u5c71\u522a\u717d\u886b\u9583\u965c\u64c5\u8d0d\u81b3\u5584\u6c55\u6247\u7e55\u5891\u50b7\u5546\u8cde\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u71d2\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7d39\u5962\u8cd2\u86c7\u820c\u820d\u8d66\u651d\u5c04\u61fe\u6d89\u793e\u8a2d\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7d33\u795e\u6c88\u5be9\u5b38\u751a\u814e\u614e\u6ef2\u8072\u751f\u7525\u7272\u5347\u7e69\u7701\u76db\u5269\u52dd\u8056\u5e2b\u5931\u7345\u65bd\u6fd5\u8a69\u5c4d\u8671\u5341\u77f3\u62fe\u6642\u4ec0\u98df\u8755\u5be6\u8b58\u53f2\u77e2\u4f7f\u5c4e\u99db\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52e2\u662f\u55dc\u566c\u9069\u4ed5\u4f8d\u91cb\u98fe\u6c0f\u5e02\u6043\u5ba4\u8996\u8a66\u6536\u624b\u9996\u5b88\u58fd\u6388\u552e\u53d7\u7626\u7378\u852c\u6a1e\u68b3\u6b8a\u6292\u8f38\u53d4\u8212\u6dd1\u758f\u66f8\u8d16\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c6c\u8853\u8ff0\u6a39\u675f\u620d\u8c4e\u5885\u5eb6\u6578\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e25\u6813\u62f4\u971c\u96d9\u723d\u8ab0\u6c34\u7761\u7a05\u542e\u77ac\u9806\u821c\u8aaa\u78a9\u6714\u720d\u65af\u6495\u5636\u601d\u79c1\u53f8\u7d72\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u98fc\u5df3\u677e\u8073\u616b\u980c\u9001\u5b8b\u8a1f\u8aa6\u641c\u8258\u64fb\u55fd\u8607\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8a34\u8085\u9178\u849c\u7b97\u96d6\u968b\u96a8\u7d8f\u9ad3\u788e\u6b72\u7a57\u9042\u96a7\u795f\u5b6b\u640d\u7b4d\u84d1\u68ad\u5506\u7e2e\u7463\u7d22\u9396\u6240\u584c\u4ed6\u5b83\u5979\u5854\u737a\u64bb\u8e4b\u8e0f\u80ce\u82d4\u64e1\u81fa\u6cf0\u915e\u592a\u614b\u6c70\u574d\u6524\u8caa\u7671\u7058\u58c7\u6a80\u75f0\u6f6d\u8b5a\u8ac7\u5766\u6bef\u8892\u78b3\u63a2\u5606\u70ad\u6e6f\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u71d9\u638f\u6fe4\u6ed4\u7d73\u8404\u6843\u9003\u6dd8\u9676\u8a0e\u5957\u7279\u85e4\u9a30\u75bc\u8b04\u68af\u5254\u8e22\u92bb\u63d0\u984c\u8e44\u557c\u9ad4\u66ff\u568f\u60d5\u6d95\u5243\u5c5c\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u689d\u8fe2\u773a\u8df3\u8cbc\u9435\u5e16\u5ef3\u807d\u70f4\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u9285\u5f64\u7ae5\u6876\u6345\u7b52\u7d71\u75db\u5077\u6295\u982d\u900f\u51f8\u79bf\u7a81\u5716\u5f92\u9014\u5857\u5c60\u571f\u5410\u5154\u6e4d\u5718\u63a8\u9839\u817f\u86fb\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u812b\u9d15\u9640\u99b1\u99dd\u6a62\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u7aaa\u5a03\u74e6\u896a\u6b6a\u5916\u8c4c\u5f4e\u7063\u73a9\u9811\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u842c\u8155\u6c6a\u738b\u4ea1\u6789\u7db2\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97cb\u9055\u6845\u570d\u552f\u60df\u70ba\u6ff0\u7dad\u8466\u840e\u59d4\u5049\u507d\u5c3e\u7def\u672a\u851a\u5473\u754f\u80c3\u9935\u9b4f\u4f4d\u6e2d\u8b02\u5c09\u6170\u885b\u761f\u6eab\u868a\u6587\u805e\u7d0b\u543b\u7a69\u7d0a\u554f\u55e1\u7fc1\u7515\u64be\u8778\u6e26\u7aa9\u6211\u65a1\u81e5\u63e1\u6c83\u5deb\u55da\u93a2\u70cf\u6c59\u8aa3\u5c4b\u7121\u856a\u68a7\u543e\u5433\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u5862\u620a\u9727\u6664\u7269\u52ff\u52d9\u609f\u8aa4\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u932b\u72a7\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u8972\u5e2d\u7fd2\u5ab3\u559c\u9291\u6d17\u7cfb\u9699\u6232\u7d30\u778e\u8766\u5323\u971e\u8f44\u6687\u5cfd\u4fe0\u72f9\u4e0b\u5ec8\u590f\u5687\u6380\u9341\u5148\u4ed9\u9bae\u7e96\u9e79\u8ce2\u929c\u8237\u9591\u6d8e\u5f26\u5acc\u986f\u96aa\u73fe\u737b\u7e23\u817a\u9921\u7fa8\u61b2\u9677\u9650\u7dda\u76f8\u5ec2\u9472\u9999\u7bb1\u8944\u6e58\u9109\u7fd4\u7965\u8a73\u60f3\u97ff\u4eab\u9805\u5df7\u6a61\u50cf\u5411\u8c61\u856d\u785d\u9704\u524a\u54ee\u56c2\u92b7\u6d88\u5bb5\u6dc6\u66c9\u5c0f\u5b5d\u6821\u8096\u562f\u7b11\u6548\u6954\u4e9b\u6b47\u880d\u978b\u5354\u633e\u651c\u90aa\u659c\u8105\u8ae7\u5beb\u68b0\u5378\u87f9\u61c8\u6cc4\u7009\u8b1d\u5c51\u85aa\u82af\u92c5\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u91c1\u661f\u8165\u7329\u60fa\u8208\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u5147\u80f8\u5308\u6d36\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u92b9\u79c0\u8896\u7e61\u589f\u620c\u9700\u865b\u5653\u9808\u5f90\u8a31\u84c4\u9157\u6558\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7dd2\u7e8c\u8ed2\u55a7\u5ba3\u61f8\u65cb\u7384\u9078\u766c\u7729\u7d62\u9774\u859b\u5b78\u7a74\u96ea\u8840\u52db\u718f\u5faa\u65ec\u8a62\u5c0b\u99b4\u5de1\u6b89\u6c5b\u8a13\u8a0a\u905c\u8fc5\u58d3\u62bc\u9d09\u9d28\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u555e\u4e9e\u8a1d\u7109\u54bd\u95b9\u7159\u6df9\u9e7d\u56b4\u7814\u8712\u5dd6\u5ef6\u8a00\u984f\u95bb\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8277\u5830\u71d5\u53ad\u786f\u96c1\u5501\u5f65\u7130\u5bb4\u8afa\u9a57\u6b83\u592e\u9d26\u79e7\u694a\u63da\u4f6f\u760d\u7f8a\u6d0b\u967d\u6c27\u4ef0\u7662\u990a\u6a23\u6f3e\u9080\u8170\u5996\u7464\u6416\u582f\u9059\u7aaf\u8b20\u59da\u54ac\u8200\u85e5\u8981\u8000\u6930\u564e\u8036\u723a\u91ce\u51b6\u4e5f\u9801\u6396\u696d\u8449\u66f3\u814b\u591c\u6db2\u58f9\u58f9\u91ab\u63d6\u92a5\u4f9d\u4f0a\u8863\u9824\u5937\u907a\u79fb\u5100\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5c\u6905\u87fb\u501a\u5df2\u4e59\u77e3\u4ee5\u85dd\u6291\u6613\u9091\u5c79\u5104\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u61b6\u7fa9\u76ca\u6ea2\u8a63\u8b70\u8abc\u8b6f\u7570\u7ffc\u7fcc\u7e79\u8335\u852d\u56e0\u6bb7\u97f3\u9670\u59fb\u541f\u9280\u6deb\u5bc5\u98f2\u5c39\u5f15\u96b1\u5370\u82f1\u6afb\u5b30\u9df9\u61c9\u7e93\u7469\u87a2\u71df\u7192\u8805\u8fce\u8d0f\u76c8\u5f71\u7a4e\u786c\u6620\u55b2\u64c1\u50ad\u81c3\u7670\u5eb8\u96cd\u8e34\u86f9\u8a60\u6cf3\u6e67\u6c38\u607f\u52c7\u7528\u5e7d\u512a\u60a0\u6182\u5c24\u7531\u90f5\u923e\u7336\u6cb9\u904a\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8a98\u53c8\u5e7c\u8fc2\u6de4\u65bc\u76c2\u6986\u865e\u611a\u8f3f\u4f59\u4fde\u903e\u9b5a\u6109\u6e1d\u6f01\u9685\u4e88\u5a1b\u96e8\u8207\u5dbc\u79b9\u5b87\u8a9e\u7fbd\u7389\u57df\u828b\u90c1\u7c72\u9047\u55bb\u5cea\u79a6\u6108\u6b32\u7344\u80b2\u8b7d\u6d74\u5bd3\u88d5\u9810\u8c6b\u99ad\u9d1b\u6df5\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f45\u5712\u54e1\u5713\u733f\u6e90\u7de3\u9060\u82d1\u9858\u6028\u9662\u66f0\u7d04\u8d8a\u8e8d\u9470\u5dbd\u7cb5\u6708\u6085\u95b1\u8018\u96f2\u9116\u52fb\u9695\u5141\u904b\u860a\u919e\u6688\u97fb\u5b55\u531d\u7838\u96dc\u683d\u54c9\u707d\u5bb0\u8f09\u518d\u5728\u54b1\u6522\u66ab\u8d0a\u8d13\u81df\u846c\u906d\u7cdf\u947f\u85fb\u68d7\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7ac8\u71e5\u8cac\u64c7\u5247\u6fa4\u8cca\u600e\u589e\u618e\u66fe\u8d08\u7d2e\u55b3\u6e23\u5284\u8ecb\u9358\u9598\u7728\u67f5\u69a8\u548b\u4e4d\u70b8\u8a50\u6458\u9f4b\u5b85\u7a84\u50b5\u5be8\u77bb\u6c08\u8a79\u7c98\u6cbe\u76de\u65ac\u8f3e\u5d84\u5c55\u8638\u68e7\u5360\u6230\u7ad9\u6e5b\u7dbb\u6a1f\u7ae0\u5f70\u6f33\u5f35\u638c\u6f32\u6756\u4e08\u5e33\u8cec\u4ed7\u8139\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d99\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u87c4\u8f4d\u8005\u937a\u8517\u9019\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8c9e\u91dd\u5075\u6795\u75b9\u8a3a\u9707\u632f\u93ae\u9663\u84b8\u6399\u775c\u5f81\u7319\u722d\u6014\u6574\u62ef\u6b63\u653f\u5e40\u7665\u912d\u8b49\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7e54\u8077\u76f4\u690d\u6b96\u57f7\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7d19\u8a8c\u646f\u64f2\u81f3\u81f4\u7f6e\u5e5f\u5cd9\u5236\u667a\u79e9\u7a1a\u8cea\u7099\u75d4\u6eef\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u9418\u8877\u7d42\u7a2e\u816b\u91cd\u4ef2\u773e\u821f\u5468\u5dde\u6d32\u8b05\u7ca5\u8ef8\u8098\u5e1a\u5492\u76ba\u5b99\u665d\u9a5f\u73e0\u682a\u86db\u6731\u8c6c\u8af8\u8a85\u9010\u7af9\u71ed\u716e\u62c4\u77da\u56d1\u4e3b\u8457\u67f1\u52a9\u86c0\u8caf\u9444\u7bc9\u4f4f\u8a3b\u795d\u99d0\u6293\u722a\u62fd\u5c08\u78da\u8f49\u64b0\u8cfa\u7bc6\u6a01\u838a\u88dd\u599d\u649e\u58ef\u72c0\u690e\u9310\u8ffd\u8d05\u589c\u7db4\u8ac4\u6e96\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u8457\u707c\u6fc1\u8332\u54a8\u8cc7\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6f2c\u5b57\u9b03\u68d5\u8e64\u5b97\u7d9c\u7e3d\u7e31\u9112\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8a5b\u963b\u7d44\u9246\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9312\u566f\u5b21\u74a6\u66d6\u9744\u8af3\u92a8\u9d6a\u5abc\u9a41\u9c32\u9200\u5504\u9211\u9d07\u9f59\u9d6f\u8cc1\u931b\u84fd\u55f6\u6f77\u924d\u7bf3\u8e55\u8290\u7df6\u7c69\u9a43\u98ae\u98c6\u93e2\u9463\u9c3e\u5110\u7e7d\u6ab3\u6baf\u81cf\u944c\u9ad5\u9b22\u7a1f\u9911\u9238\u9d53\u923d\u9a42\u9ef2\u60fb\u9364\u5115\u91f5\u56c5\u8ac2\u8b96\u8546\u61fa\u5b0b\u9a4f\u8998\u79aa\u9414\u5000\u8407\u60b5\u95b6\u9be7\u7868\u5096\u8af6\u6aec\u78e3\u9f54\u68d6\u6a89\u92ee\u943a\u98ed\u9d1f\u9283\u5114\u5e6c\u8b8e\u82bb\u7d40\u8e95\u91e7\u6134\u7d9e\u9d89\u8f1f\u9f6a\u9dbf\u84ef\u9a44\u6a05\u8f33\u651b\u92bc\u9e7a\u5660\u97c3\u99d8\u7d3f\u6bab\u8ce7\u7649\u7c1e\u8b9c\u78ad\u8960\u71fe\u9419\u7cf4\u8a46\u8ae6\u7d88\u89bf\u93d1\u5dd4\u923f\u7672\u929a\u9bdb\u9c08\u92cc\u92a9\u5d20\u9d87\u7ac7\u7006\u6add\u7258\u7be4\u9ef7\u7c6a\u61df\u9413\u71c9\u8e89\u9438\u8ae4\u580a\u95bc\u8edb\u92e8\u9354\u9d9a\u984e\u9853\u9c77\u8a92\u9087\u927a\u9d2f\u9b9e\u9201\u9b74\u7dcb\u9428\u9be1\u50e8\u7043\u9ce7\u99d9\u7d31\u7d3c\u8cfb\u9ea9\u9b92\u9c12\u91d3\u8cc5\u5c37\u641f\u7d3a\u6207\u776a\u8aa5\u7e1e\u92ef\u7d07\u9398\u6f41\u4e99\u8ce1\u7d86\u9bc1\u8a6c\u7df1\u89af\u8a41\u8f42\u9237\u932e\u9d23\u9d60\u9dbb\u9d30\u6451\u8a7f\u645c\u9e1b\u9c25\u7377\u532d\u528c\u5aaf\u6a9c\u9bad\u9c56\u889e\u7dc4\u9bc0\u581d\u54bc\u5e57\u69e8\u87c8\u927f\u95de\u7d4e\u9821\u705d\u9865\u8a36\u95d4\u8823\u9ecc\u8a0c\u8452\u958e\u9c5f\u6ef8\u9d98\u9a4a\u6a3a\u93f5\u5950\u7e6f\u9370\u9bc7\u9c09\u8a7c\u8588\u5666\u6fae\u7e62\u743f\u6689\u8ae2\u991b\u95bd\u9225\u944a\u8a10\u8a70\u85ba\u5630\u568c\u9a65\u74a3\u89ac\u9f4f\u78ef\u7f88\u8806\u8e8b\u973d\u9c6d\u9bfd\u90df\u6d79\u92cf\u93b5\u87ef\u8aeb\u7e11\u6214\u6229\u77bc\u9dbc\u7b67\u9c39\u97c9\u7d73\u97c1\u649f\u5da0\u9de6\u9bab\u7664\u981c\u9b9a\u5df9\u85ce\u9949\u7e09\u8d10\u89b2\u5244\u6d87\u9015\u5f33\u811b\u975a\u9b2e\u9ce9\u9df2\u8a4e\u5c68\u6af8\u98b6\u9245\u92e6\u7ab6\u9f5f\u9308\u942b\u96cb\u8b4e\u73a8\u76b8\u5274\u584f\u613e\u6137\u93a7\u9347\u9f95\u958c\u9227\u92ac\u9a0d\u7dd9\u8efb\u9233\u9301\u9837\u9f66\u93d7\u56b3\u9136\u5672\u81be\u736a\u9ad6\u8a86\u8a91\u913a\u58d9\u7e8a\u8cba\u5331\u8562\u6192\u8075\u7c23\u95ab\u9315\u9be4\u8810\u5d0d\u5fa0\u6df6\u7028\u8cda\u775e\u9338\u7669\u7c5f\u5d50\u6b16\u6595\u946d\u8964\u95ac\u92c3\u562e\u5d97\u92a0\u9412\u7646\u9c33\u8a84\u7e32\u5137\u9148\u58e2\u85f6\u849e\u863a\u56a6\u9090\u9a6a\u7e2d\u6aea\u6adf\u8f62\u792a\u92f0\u9e1d\u7658\u7cf2\u8e92\u9742\u9c7a\u9c67\u861e\u5969\u7032\u7489\u6bae\u8933\u895d\u9c31\u9b4e\u7e5a\u91d5\u9def\u85fa\u5ee9\u6a81\u8f54\u8eaa\u7dbe\u6b1e\u87f6\u9bea\u700f\u9a2e\u7db9\u93a6\u9dda\u8622\u7027\u74cf\u6af3\u6727\u7931\u50c2\u851e\u560d\u5d81\u93e4\u763a\u802c\u87bb\u9acf\u58da\u64fc\u5695\u95ad\u7018\u6de5\u6ae8\u6ad3\u8f64\u8f05\u8f46\u6c0c\u81da\u9e15\u9dfa\u826b\u9c78\u81e0\u5b4c\u6b12\u9e1e\u947e\u5707\u7296\u7380\u6ffc\u6b0f\u8161\u93cd\u6ada\u8938\u92dd\u5638\u561c\u5b24\u69aa\u52f1\u7e35\u93dd\u9859\u9c3b\u9ebc\u636b\u71dc\u61e3\u9346\u7f8b\u8b10\u737c\u79b0\u6fa0\u9766\u9efd\u7df2\u7e46\u9594\u7de1\u8b28\u9a40\u9943\u6b7f\u93cc\u926c\u9403\u8a25\u922e\u9be2\u8f26\u9bf0\u8526\u88ca\u9689\u8617\u56c1\u9862\u8ea1\u82e7\u5680\u8079\u5102\u5665\u99d1\u91f9\u513a\u8b33\u616a\u750c\u8e63\u76b0\u8f61\u7d15\u7f86\u9239\u8ade\u99e2\u7e39\u5b2a\u91d9\u93f7\u9420\u8604\u9a0f\u7dba\u69bf\u78e7\u980e\u980f\u9c2d\u50c9\u8541\u6173\u9a2b\u7e7e\u69e7\u9210\u5b19\u6aa3\u6227\u7197\u9306\u93d8\u93f9\u7fa5\u8e4c\u8a9a\u8b59\u854e\u7e70\u78fd\u8e7a\u611c\u9365\u7bcb\u92df\u64b3\u9bd6\u7162\u86fa\u5df0\u8cd5\u87e3\u9c0d\u8a58\u5d87\u95c3\u89b7\u9d1d\u8a6e\u7da3\u8f07\u9293\u95cb\u95d5\u6128\u8558\u5b08\u6a48\u98ea\u8ed4\u5db8\u8811\u7e1f\u92a3\u9870\u8706\u98af\u6bff\u7cdd\u7e45\u55c7\u92ab\u7a61\u93a9\u9bca\u91c3\u8a15\u59cd\u9a38\u91e4\u9c54\u5770\u6ba4\u89f4\u5399\u7044\u756c\u8a75\u8ad7\u700b\u8b1a\u5852\u8494\u5f12\u8efe\u8cb0\u9230\u9c23\u7dac\u6504\u7d13\u9582\u9460\u5edd\u99df\u7de6\u9376\u9de5\u85ea\u993f\u98bc\u93aa\u8b16\u7a4c\u8ab6\u84c0\u733b\u55e9\u8127\u95e5\u9248\u9c28\u9226\u9b90\u66c7\u926d\u931f\u9807\u513b\u9933\u940b\u93dc\u97dc\u92f1\u7df9\u9d5c\u95d0\u7cf6\u9f60\u9c37\u615f\u9204\u91f7\u6476\u98e9\u7c5c\u9f09\u5aa7\u8183\u7d08\u7db0\u8f1e\u8ac9\u5e43\u95c8\u6e88\u6f7f\u744b\u97d9\u7152\u9baa\u95bf\u8435\u9f77\u9114\u5ee1\u61ae\u5af5\u9a16\u9d61\u9da9\u993c\u9b29\u74bd\u89a1\u7864\u83a7\u859f\u861a\u5cf4\u736b\u5afb\u9df4\u7647\u8814\u79c8\u8e9a\u858c\u9909\u9a64\u7dd7\u9957\u5635\u701f\u9a4d\u7d83\u689f\u7c2b\u893b\u64f7\u7d32\u7e88\u9658\u6ece\u9948\u9d42\u8a61\u980a\u8afc\u9249\u93c7\u8b14\u6fa9\u9c48\u5864\u6f6f\u9c58\u57e1\u5a6d\u690f\u6c2c\u53b4\u8d17\u513c\u5157\u8b9e\u61e8\u9586\u91c5\u9b58\u995c\u9f34\u716c\u8efa\u9dc2\u9c29\u9768\u8b01\u9134\u66c4\u71c1\u8a52\u56c8\u5da7\u98f4\u61cc\u9a5b\u7e0a\u8efc\u8cbd\u91d4\u93b0\u943f\u761e\u8264\u92a6\u766e\u584b\u9daf\u7e08\u93a3\u6516\u56b6\u7005\u7020\u74d4\u9e1a\u766d\u9826\u7f4c\u93de\u8555\u92aa\u9b77\u50b4\u4fc1\u8adb\u8aed\u8577\u5d33\u98eb\u95be\u5ad7\u7d06\u89a6\u6b5f\u923a\u9d52\u9df8\u9f6c\u6ade\u9cf6\u9eff\u925e\u9106\u8553\u60f2\u614d\u7d1c\u97de\u6b9e\u6c33\u74da\u8db2\u93e8\u99d4\u8cfe\u5616\u5e58\u7c00\u8b56\u7e52\u8b6b\u8a54\u91d7\u8b2b\u8f12\u9dd3\u6e5e\u7e1d\u6968\u8eeb\u8cd1\u798e\u9d06\u8acd\u5d22\u9266\u931a\u7b8f\u9a2d\u6adb\u6894\u8ef9\u8f0a\u8d04\u9dd9\u8784\u7e36\u8e93\u8e91\u89f6\u937e\u7d02\u7e10\u4f47\u6ae7\u9296\u56c0\u994c\u9873\u9a05\u7e0b\u8ad1\u9432\u8aee\u7dc7\u8f1c\u8cb2\u7725\u9319\u9f5c\u9bd4\u50af\u8acf\u9a36\u9beb\u93c3\u7e98\u8ea6\u9c52\u8a01\u8b7e\u90e4\u731b\u6c39\u962a\u58df\u5816\u57b5\u588a\u6abe\u8552\u8464\u84e7\u8493\u83c7\u69c1\u6463\u54a4\u551a\u54e2\u565d\u5645\u6485\u5288\u8b14\u8946\u5db4\u810a\u4eff\u50e5\u7341\u9e85\u9918\u9937\u994a\u9962\u695e\u6035\u61cd\u723f\u6f35\u7069\u6df7\u6feb\u7026\u6de1\u5be7\u7cf8\u7d5d\u7dd4\u7449\u6898\u68ec\u6848\u6a70\u6aeb\u8ef2\u8ee4\u8ceb\u8181\u8156\u98c8\u7cca\u7146\u6e9c\u6e63\u6e3a\u78b8\u6efe\u7798\u9208\u9255\u92e3\u92b1\u92e5\u92f6\u9426\u9427\u9369\u9340\u9343\u9307\u9384\u9387\u93bf\u941d\u9465\u9479\u9454\u7a6d\u9d93\u9da5\u9e0c\u7667\u5c59\u7602\u81d2\u8947\u7e48\u802e\u986c\u87ce\u9eaf\u9b81\u9b83\u9b8e\u9bd7\u9bdd\u9bf4\u9c5d\u9bff\u9c20\u9c35\u9c45\u97bd\u97dd\u9f47";function Phe(e){return Rst.charAt(Che.indexOf(e.charAt(0)))}var WOt=new RegExp("[\u4e00-\u9fa5]+");function Ihe(e){return Che.includes(e)}var zn=class{static GetBytes(e){switch(typeof e){case"string":{let t=new Uint16Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return new Uint8Array(t.buffer)}case"number":return e-Math.floor(e)==0?e>4294967295?((t=new Float64Array(1))[0]=e,new Uint8Array(t.buffer)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Int32Array(1)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Float64Array(1));case"boolean":return function(t){return t[0]=Number(e),t}(new Uint8Array(1));default:if(e instanceof Array){let t=[];for(let a=0;a<e.length;a++)t.push(zn.GetBytes(e[a]));let n=0;for(let e=0;e<t.length;e++)n+=t[e].length;let i=new Uint8Array(n),r=0;for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)i[r++]=t[e][n];return i}throw"Can't Convert To Bytes!!"}var t}static Get1Bytes(e){switch(typeof e){case"number":case"boolean":return new Uint8Array([Number(e)]);default:if(e instanceof Array){let t=[];for(let a=0;a<e.length;a++)t.push(this.Get1Bytes(e[a]));let n=0;for(let e=0;e<t.length;e++)n+=t[e].length;let i=new Uint8Array(n),r=0;for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)i[r++]=t[e][n];return i}throw"Can't Convert To Bytes!!"}}static byteTosbyte(e){return(127&e)-(128&e?128:0)}static ToBoolean(e,t){return!!e[t=t||0]}static ToInt8(e,t){return 128&e[t=t||0]?-(1+(255^e[t])):e[t]}static ToUInt8(e,t){return e[t=t||0]}static ToInt16(e,t){t=t||0;let n=e.slice(t,t+2);return new Int16Array(n.buffer,0,1)[0]}static ToInt32(e,t){t=t||0;let n=e.slice(t,t+4);return new Int32Array(n.buffer,0,1)[0]}static ToUInt16(e,t){t=t||0;let n=e.slice(t,t+2);return new Uint16Array(n.buffer,0,1)[0]}static ToUInt32(e,t){t=t||0;let n=e.slice(t,t+4);return new Uint32Array(n.buffer,0,1)[0]}static ToChar(e,t){t=t||0;let n=e.slice(t,t+2);return String.fromCharCode(new Uint16Array(n.buffer,0,1)[0])}static ToAscii(e,t){return t=t||0,String.fromCharCode(e[t])}static ToAsciiString(e,t,n){t=t||0,(n=n||e.length)+t>e.length&&(n-=t);let i="";for(let r=0;r<n;r++)i+=String.fromCharCode(e[t+r]||0);return i}static ToUTF16String(e,t,n){t=t||0,(n=n||e.length)+t>e.length&&(n-=t);let i=new Uint8Array(n);for(let r=0;r<n;r++)i[r]=e[t+r]||0;return String.fromCharCode.apply(null,Array.from(new Uint16Array(i.buffer,0,n/2)))}static ToFloat32(e,t){t=t||0;let n=e.slice(t,t+4);return new Float32Array(n.buffer,0,1)[0]}static ToFloat64(e,t){t=t||0;let n=e.slice(t,t+8);return new Float64Array(n.buffer,0,1)[0]}},Md=class{static parserHeader(e,t){let n="",i=!1,r=0;for(;;){let a=e.readInt8(),s=String.fromCharCode(a);if(i)s===t[r]?r++:(i=!1,r=0);else{if(s===t[r]){i=!0,r++;continue}n+=s}if(i&&r===t.length)break}return n}static getCode(e){let t=Ahe(e);return t.length<2?t[0]:t.length<4?zn.ToUInt16(t,0):zn.ToUInt32(t,0)}static parserCode(e,t,n){let i=new Q,r=[],a=[],s=[],o=!1;for(let l=0;l<t.length;l++){let h=t[l];switch(h){case 0:break;case 1:o=!0,a.push(i.clone());break;case 2:o=!1,a.length>1?(r.push(a.slice()),a=[]):i.set(0,0);break;case 3:l++,n/=t[l];break;case 4:l++,n*=t[l];break;case 5:if(4===s.length)throw"The position stack is only four locations deep";s.push(i);break;case 6:i=s.pop(),a.length>1&&(r.push(a.slice()),a=[]),o&&a.push(i.clone());break;case 7:{let s,o=0,h=n*e.baseUp,c=i.clone();switch(a.length>1&&(r.push(a.slice()),a=[]),e.type){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=zn.ToUInt16(new Uint8Array([t[l++],t[l++]]),0),c.x=t[l++]*n,c.y=t[l++]*n,h=t[l]*n);break;case 2:l+=2,o=zn.ToUInt16(new Uint8Array([t[l-1],t[l]]),0)}0!==o&&(s=e.getGraphicDataByCodeWithOffset(o,h,c),s&&(r.push(...s.polylines.slice()),i=s.lastPoint.clone()))}break;case 8:{let e=new Q;e.x=zn.byteTosbyte(t[++l]),e.y=zn.byteTosbyte(t[++l]),i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 9:for(;;){let e=new Q;if(e.x=zn.byteTosbyte(t[++l]),e.y=zn.byteTosbyte(t[++l]),0==e.x&&0==e.y)break;i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 10:{let e=t[++l]*n,r=zn.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=Md.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=i.clone().sub(new Q(Math.cos(p)*e,Math.sin(p)*e));if(i=m.clone().add(new Q(Math.cos(f)*e,Math.sin(f)*e)),o){let t=p,n=!0;for(;n&&(t+=d,r>=0&&t<f||r<0&&t>f);)a.push(m.clone().add(new Q(e*Math.cos(t),e*Math.sin(t))));a.push(i.clone())}}break;case 11:{let e=t[++l],r=t[++l],s=(255*t[++l]+t[++l])*n,h=zn.byteTosbyte(t[++l]),c=(112&h)>>4,u=7&h;0==u&&(u=8),0!=r&&u--;let d=Math.PI/4,p=d*u,f=Md.CIRCLE_SPAN,m=1;h<0&&(f=-f,p=-p,m=-1);let g=d*c,v=g+p;g+=d*e/256*m,v+=d*r/256*m;let y=i.clone().sub(new Q(s*Math.cos(g),s*Math.sin(g)));if(i=y.clone().add(new Q(s*Math.cos(v),s*Math.sin(v))),o){let e=g,t=!0;for(;t&&(e+=f,h>0&&e<v||h<0&&e>v);)a.push(y.clone().add(new Q(s*Math.cos(e),s*Math.sin(e))));a.push(i.clone())}}break;case 12:{let e=new Q;e.x=zn.byteTosbyte(t[++l])*n,e.y=zn.byteTosbyte(t[++l])*n;let r=zn.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Md.generateArcPoints(i,e,r/127))),i.add(e)}break;case 13:for(;;){let e=new Q;if(e.x=zn.byteTosbyte(t[++l])*n,e.y=zn.byteTosbyte(t[++l])*n,0==e.x&&0==e.y)break;let r=zn.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Md.generateArcPoints(i.clone(),e,r/127))),i.add(e)}break;case 14:l=Md.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new Q;switch(t){case 0:r.x=1;break;case 1:r.x=1,r.y=.5;break;case 2:r.x=1,r.y=1;break;case 3:r.x=.5,r.y=1;break;case 4:r.y=1;break;case 5:r.x=-.5,r.y=1;break;case 6:r.x=-1,r.y=1;break;case 7:r.x=-1,r.y=.5;break;case 8:r.x=-1;break;case 9:r.x=-1,r.y=-.5;break;case 10:r.x=-1,r.y=-1;break;case 11:r.x=-.5,r.y=-1;break;case 12:r.y=-1;break;case 13:r.x=.5,r.y=-1;break;case 14:r.x=1,r.y=-1;break;case 15:r.x=1,r.y=-.5}i.add(r.multiplyScalar(e*n)),o&&a.push(i.clone())}}}return new Qu(i,r)}static skipCode(e,t,n){switch(t[n]){case 0:case 1:case 2:case 5:case 6:case 14:default:break;case 3:case 4:n++;break;case 7:switch(e.type){case 0:n++;break;case 1:0==t[++n]&&(n+=6);break;case 2:n+=2}break;case 8:case 10:n+=2;break;case 9:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break}break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break;t[++n]}}return n}static generateArcPoints(e,t,n){let i=e.clone().add(t),r=n<0;n=Math.abs(n);let a=t.length()/2,s=a*n,o=2*Math.atan(1/n),l=new Q(t.y,-t.x);l.normalize(),l.multiplyScalar(s);let h=Math.abs(a/Math.sin(o/2)),c=e.add(t.divideScalar(2));!1!==r?c.add(l):c.sub(l);let u=e.sub(c),d=i.sub(c),p=Math.atan2(u.y,u.x),f=Math.atan2(d.y,d.x),m=Md.CIRCLE_SPAN;r?(m=-m,p<f&&(p+=2*Math.PI)):p>f&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&g<f||r&&g>f)return c.add(new Q(h*Math.cos(g),h*Math.sin(g)));break}return i}},Ol=Md;Ol.FILE_STOP_FLAG=["\r","\n","\x1a"],Ol.CIRCLE_SPAN=Math.PI/18;var WR={130:[[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],131:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],132:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],133:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]]],134:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],135:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],136:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],178:[[[1.142,9.285],[1.142,9.428],[1.285,9.714],[1.428,9.857],[1.714,10],[2.285,10],[2.571,9.857],[2.714,9.714],[2.857,9.428],[2.857,9.142],[2.714,8.857],[2.428,8.428],[1,7],[3,7]]],8960:[[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]],[[0,0],[8,8]]],20393:[[[0,0],[0,6.666]],[[0,4.761],[1.428,6.19],[2.38,6.666],[3.809,6.666],[4.761,6.19],[5.238,4.761],[5.238,0]],[[5.238,4.761],[6.666,6.19],[7.619,6.666],[9.047,6.666],[10,6.19],[10.476,4.761],[10.476,0]],[[11.142,9.285],[11.142,9.428],[11.285,9.714],[11.428,9.857],[11.714,10],[12.285,10],[12.571,9.857],[12.714,9.714],[12.857,9.428],[12.857,9.142],[12.714,8.857],[12.428,8.428],[11,7],[13,7]]],41123:[],55714:[[[2,5.9],[2.6,6.1],[3.4,7],[3.4,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],55970:[[[2.3,5.6],[2.3,5.9],[2.6,6.4],[2.9,6.7],[3.4,7],[4.6,7],[5.1,6.7],[5.4,6.4],[5.7,5.9],[5.7,5.3],[5.4,4.7],[4.9,3.9],[2,1],[6,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56226:[[[2.6,7],[5.7,7],[4,4.7],[4.9,4.7],[5.4,4.4],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56482:[[[4.9,7],[2,3],[6.3,3]],[[4.9,7],[4.9,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56738:[[[5.4,7],[2.6,7],[2.3,4.4],[2.6,4.7],[3.4,5],[4.3,5],[5.1,4.7],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56994:[[[5.4,6.1],[5.1,6.7],[4.3,7],[3.7,7],[2.9,6.7],[2.3,5.9],[2,4.4],[2,3],[2.3,1.9],[2.9,1.3],[3.7,1],[4,1],[4.9,1.3],[5.4,1.9],[5.7,2.7],[5.7,3],[5.4,3.9],[4.9,4.4],[4,4.7],[3.7,4.7],[2.9,4.4],[2.3,3.9],[2,3]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57250:[[[2,7],[6,7],[3.1,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57506:[[[3.4,7],[2.6,6.7],[2.3,6.1],[2.3,5.6],[2.6,5],[3.1,4.7],[4.3,4.4],[5.1,4.1],[5.7,3.6],[6,3],[6,2.1],[5.7,1.6],[5.4,1.3],[4.6,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1],[2,3],[2.3,3.6],[2.9,4.1],[3.7,4.4],[4.9,4.7],[5.4,5],[5.7,5.6],[5.7,6.1],[5.4,6.7],[4.6,7],[3.4,7]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57762:[[[5.7,5],[5.4,4.1],[4.9,3.6],[4,3.3],[3.7,3.3],[2.9,3.6],[2.3,4.1],[2,5],[2,5.3],[2.3,6.1],[2.9,6.7],[3.7,7],[4,7],[4.9,6.7],[5.4,6.1],[5.7,5],[5.7,3.6],[5.4,2.1],[4.9,1.3],[4,1],[3.4,1],[2.6,1.3],[2.3,1.9]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],60070:[[[0,6],[10,6],[10,4]]],60326:[[[0,7],[0,5],[10,5]]]},jR=new Wt,Sd=class{constructor(e){this.type=1,this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.codes={},this.graphicData=new Map,this.url=e}getGraphicDataByCode(e,t){if(0===e)return;let n=this.codes;if(!this.graphicData.has(e)){if(!n[e]){if(WR[e]){let n=[];for(let t=0;t<WR[e].length;t++)n.push(WR[e][t].map((e=>new Q(e[0],e[1]))));let i=new Qu(new Q,n),r=t/GR;return jR.identity().scale(r,r),i.transform(jR)}return}{let t=n[e],i=GR/this.baseUp,r=Ol.parserCode(this,t,i);this.graphicData.set(e,r)}}if(this.graphicData.has(e)){let n=t/GR;return jR.identity().scale(n,n),this.graphicData.get(e).transform(jR)}}getGraphicDataByCodeWithOffset(e,t,n){var i;return null==(i=this.getGraphicDataByCode(e,t))?void 0:i.offset(n)}getFontFile(){return{url:this.url,type:this.type,codes:this.codes,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.url=e.url,this.type=e.type,this.codes=e.codes,this.info=e.info,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}releaseFontData(){this.codes={},this.graphicData.clear()}setFontDataToIndexedDb(){return $e(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,n)=>{Fc.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.url}' (${this.fileHeader}) to indexedDb`),t()}),(e=>n(`[FontFile] Failed to save '${this.url}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return $e(this,null,(function*(){return new Promise(((e,t)=>{Fc.instance().query(this.url,(t=>{e(t)}),(()=>t("[FontFile] Failed to get FontData from IndexedDB")))}))}))}},RE=class extends Sd{constructor(e){super(e),this.isExtend=!1,this.type=1}init(e){zn.ToInt16(e.readBytes(2),0);let t=zn.ToInt16(e.readBytes(2),0),n=zn.ToInt16(e.readBytes(2),0);for(let o=0;o<n;o++)e.readBytes(2),e.readBytes(2);let i=[];for(let o=0;o<t;o++){let t=e.readBytes(8),n=zn.ToUInt16(new Uint8Array([t[1],t[0]]),0),r=zn.ToUInt16(t,2),a=zn.ToUInt32(t,4);0===n&&0===r&&0===a||i.push({code:n,length:r,offset:a})}let r={};for(let o of i)e.setPosition(o.offset),r[o.code]=e.readBytes(o.length);let a=r[0],s=(this.info=Ast(a)).indexOf("\0")+1;a.length-s==4?(this.baseUp=a[s++],this.baseDown=a[s++],this.orientation=a[s++]):(this.baseUp=a[s++],s++,this.orientation=a[s++],this.baseDown=a[s++],this.isExtend=!0),this.codes=r}};function Ast(e){let t,n,i,r,a;t="";let s=e.length;for(n=0;n<s;)switch(i=e[n++],i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:r=e[n++],t+=String.fromCharCode((31&i)<<6|63&r);break;case 14:r=e[n++],a=e[n++],t+=String.fromCharCode((15&i)<<12|(63&r)<<6|(63&a)<<0)}return t}var AE=class extends Sd{constructor(e){super(e),this.type=0}init(e){e.readBytes(2),e.readBytes(2);let t=zn.ToInt16(e.readBytes(2),0),n=[];for(let s=0;s<t;s++){let t=zn.ToUInt16(e.readBytes(2),0),i=zn.ToUInt16(e.readBytes(2),0);n.push({code:t,length:i})}let i={};for(let s of n)i[s.code]=e.readBytes(s.length);let r=i[0],a=(this.info=(new TextDecoder).decode(r)).indexOf("\0");this.baseUp=r[++a],this.baseDown=r[++a],this.orientation=r[++a],this.codes=i}},CE=class extends Sd{constructor(e){super(e),this.type=2,this.isUniCode=!0,this.isEmbedded=!1}init(e){let t=zn.ToInt32(e.readBytes(4),0),n=zn.ToInt16(e.readBytes(2),0),i=e.readBytes(n),r=(this.info=(new TextDecoder).decode(i)).indexOf("\0");this.baseUp=i[++r],this.baseDown=i[++r],this.orientation=i[++r],this.isUniCode=0==i[++r],this.isEmbedded=0==i[++r];let a={};for(let s=0;s<t-1;s++){let t=zn.ToUInt16(e.readBytes(2),0),n=zn.ToUInt16(e.readBytes(2),0);a[t]=e.readBytes(n)}this.codes=a}},XR=new Q,z5=class extends Bp{constructor(e){super(""),this.unsupportedChars={},this.textShapesCache=new Map,this.files=[],this.filesMap=new Map,e&&this.loadFiles(e)}loadFiles(e){return $e(this,null,(function*(){for(let t=0;t<e.length;t++){let n=e[t];this.files.push(this.loadFile(n))}tn.isBrowser&&(yield this.saveFontDataToIndexdb(),this.releaseFontData())}))}loadFile(e){let{url:t,arrayBuffer:n}=e,i=new wd(n),r=Ol.parserHeader(i,Ol.FILE_STOP_FLAG).split(" "),a=null;switch(r[1]){case"shapes":a=new AE(t);break;case"bigfont":a=new RE(t);break;case"unifont":a=new CE(t)}return a&&(a.fileHeader=r[0],a.fileVersion=r[2],a.init(i),this.filesMap.set(t,a)),$.info(`[ShxFont] shx font loaded.The font file is ${r[0]} ${r[2]}`),a}getGraphicDataByChar(e,t){let n=Ol.getCode(e);return 0===n&&(n=e.charCodeAt(0)),this.getGraphicDataByCode(n,t)}getGraphicDataByCode(e,t){let n,i=`${e}_${t}`;if(this.textShapesCache.has(i))return this.textShapesCache.get(i);for(let r=0;r<this.files.length&&(n=this.files[r].getGraphicDataByCode(e,t),!n);r++);return n&&this.textShapesCache.set(i,n),n}getGraphicData(e,t=z5.DEFAULT_SIZE,n=0,i=0,r=0,a,s=!1){let o=[],l=e.split("\n"),h=(l.length-1)*(i+n),c=0,u=!1;for(let d=0;d<l.length;d++){let e=l[d];for(let s=0;s<e.length;s++){let l=e[s];Ihe(l)&&(l=Phe(l));let d=this.getGraphicDataByChar(l,t);if(d||(d=this.getNotFoundTextShape(t),this.addUnsupportedChar(l)),d)if(0===d.polylines.length&&(d.width=t+r,c+=r),u||a&&c+d.width>a){u?(c+=d.width+r,u=!1):(u=!0,c=0,h-=i+n),XR.set(c,h);let e=d.offset(XR);o.push(e),!u&&(c+=d.width+r)}else{XR.set(c,h);let e=d.offset(XR);o.push(e),c+=d.width+r}else this.addUnsupportedChar(l)}u=!1,c=0,h-=i+n}return o}getNotFoundTextShape(e){let t=Ol.getCode("\uff1f");return this.getGraphicDataByCode(t,e)}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}static checkFontsAreLoaded(e){return $e(this,null,(function*(){if(!tn.isBrowser)return!1;let t=!1,n=yield Fc.instance().queryAll();if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++){let r=n[i];if(r.codes instanceof Map){t=!1;break}if(0===Object.keys(r.codes).length){t=!1;break}if(!e.includes(r.url)){t=!1;break}t=!0}return t}))}saveFontDataToIndexdb(){return $e(this,null,(function*(){Fc.instance().clearAll();let e=this.files.map((e=>e.setFontDataToIndexedDb()));return yield Promise.all(e).then((()=>{$.debug("[ShxFont] Saves font data to IndexDB")}))}))}getFontData(){return $e(this,null,(function*(){if(tn.isBrowser){let e=yield Fc.instance().queryAll(),t=[],n=new Map;for(let i=0;i<e.length;i++){let r,a=e[i];switch(a.type){case 1:r=new RE(a.url);break;case 0:r=new AE(a.url);break;case 2:r=new CE(a.url)}r&&(r.setFontFile(a),t.push(r),n.set(a.url,r))}this.files=t,this.filesMap=n,$.debug("[ShxFont] Loaded font data from cache.")}}))}releaseFontData(){for(let e=0;e<this.files.length;e++)this.files[e].releaseFontData();this.files=[],this.filesMap.clear(),this.textShapesCache.clear()}destroy(){}},to=z5;to.DEFAULT_SIZE=12;var no=class extends Uc{constructor(e){super(e)}load(e,t,n,i){Array.isArray(e)||(e=[e]);let r=[];for(let a=0;a<e.length;a++){let t=e[a];no.isShxFile(t)?r.push(this.loadFile(t,n)):console.warn(`[ShxFontLoader] Invalid shx file: '${t}'`)}Promise.all(r).then((e=>{let n=this.parse(e);t&&t(n)})).catch((e=>{i&&i(e)}))}loadFile(e,t){return $e(this,null,(function*(){return new Promise(((n,i)=>{let r=new rr(this.manager);r.setResponseType("arraybuffer"),r.load(e,(t=>{n({url:e,arrayBuffer:t})}),t,(e=>{i(e)}))}))}))}loadAsync(e,t){return $e(this,null,(function*(){return Array.isArray(e)||(e=[e]),(yield to.checkFontsAreLoaded(e))?Promise.resolve(new to):new Promise(((n,i)=>{this.load(e,n,t,i)}))}))}parse(e){return new to(e)}static isShxFile(e){var t;return"shx"===(null==(t=e.split(".").pop())?void 0:t.toLowerCase())}},Rd=new M(1,0,0),G5=new M(0,1,0),YR=new M(0,0,1),Dhe=new M(0,0,0),Ad=0,Cst="CONTINUOUS",PE=new Br({color:Ad}),Xs=new Jt({color:Ad}),jv=new Pt({color:Ad}),Lhe=new Ae,q5=new Ae,ro=new Ae,Ci=new M,IE=new M,DE=new Q,Ohe=new En,Nhe=new Br({color:65280,size:5,depthTest:!1}),Uhe=new Br({color:65280,depthTest:!1}),Bhe=new Br({color:65280,depthTest:!1}),Pst=e=>void 0!==e.viewDirectionFromTarget,Ist=e=>{if(e){let t=e.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(t&&t.length>0){let n=t[1],i=e.replace("data:"+n+";","").split(",");if(i&&2===i.length&&"base64"===i[0]){let e=i[1];return ihe.decode(e)}}}return null},Fhe=(e,t)=>{let n=new Q(e.x,e.y),i=new Q(t.x,t.y);return i.sub(n),i.normalize(),i.y<0?-Math.acos(i.x):Math.acos(i.x)},Hhe=(e,t,n)=>({x:e.x+t*Math.cos(n),y:e.y+t*Math.sin(n)}),Dst=(e,t,n,i)=>{let r=e?new Q(e.x,e.y):new Q(0,0),a=t?new Q(t.x,t.y):new Q(1,0);n=n||1;let s=4*Math.atan(n),o=r.distanceTo(a)/2/Math.sin(s/2),l=Hhe(e,o,Fhe(r,a)+(Math.PI/2-s/2));i=i||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=Fhe(l,r),c=s/i,u=[];u.push(new M(r.x,r.y,0));for(let d=1;d<=i-1;d++){let e=Hhe(l,Math.abs(o),h+c*d);u.push(new M(e.x,e.y,0))}return u},Lst=(e,t,n,i=2*e.length,r)=>{let a=[],s=e.map((e=>[e.x,e.y]));for(let o=0;o<1;o+=1/i){let e=U5(o,t,s,n,r);a.push(new M(e[0],e[1],0))}return a},W5=(e,t=!1)=>{let n=[],i=e.length;for(let r=0;r<i;r++){let a=e[r];if(a.bulge&&(r!==i-1||t)){let t=a.bulge,s=r+1<i?e[r+1]:n[0],o=Dst(a,s,t);n.push(...o)}else n.push(new M(a.x,a.y,0))}return n},Ost=e=>{let t=[];return e.faceA&&t.push(e.faceA),e.faceB&&t.push(e.faceB),e.faceC&&t.push(e.faceC),e.faceD&&t.push(e.faceD),t},Nst=e=>{let t=[],n=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new M(e.x,e.y,e.z)):n.push(Ost(e)))}));let i=[];for(let r=0;r<n.length;r++){let e=n[r];if(0===e.length)continue;let a=[],s=!0;for(let n=0;n<e.length;n++){let i=e[n]-1;if(i>=t.length||i<0){s=!1;break}a.push(t[i])}!s||0===a.length||(a.push(a[0]),i.push(a))}return i},dn=class extends nr{constructor(e,t=!1,n=!0,i=!0){super(e),this.timer=Date.now(),this.ignorePaperSpace=!1,this.angBase=0,this.angDir=0,this.header=void 0,this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[],this.entityCount=0,this.curveCount=0,this.averageCurveSize=0,this.enableRenderOrder=!1,this.enableLocalCache=!0,this.enableReleaseData=!0,this.enableMerge=!0,this.enableRTC=!0,this.enablePlineWidth=!0,this.dxfDataId=void 0,this.compareContext=void 0,this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0},this.blockReferencesCache={},this.blockRecordsCache=void 0,this.entitiesCache=void 0,this.blocksCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.nonSnapableTypes=new Set(["ATTDEF","ATTRIB","LEADER","MTEXT","MULTILEADER","OLE2FRAME","TEXT"]),this.layoutsSnapObjectsMap={},this.entityHandlesWithRenderOrder={},this.addViewport=(e,t)=>{if("VIEWPORT"===e.type){t[e.ownerHandle]||(t[e.ownerHandle]=[]);let n=e;t[e.ownerHandle].push(n)}},dn.abortJobs=!1,this.ignorePaperSpace=t,this.enableLocalCache=n,this.enableMerge=i,this.pointsMaterials[Ad]=PE,this.lineBasicMaterials[Ad]=Xs,this.meshBasicMaterials[Ad]=jv}setFont(e){this.font=e}download(e,t){return $e(this,null,(function*(){let n=Ist(e);if(!n){let i=Date.now(),r=new rr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),n=yield r.loadAsync(e,t),$.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-i)/1e3}s`)}return n}))}load(e,t,n){return $e(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,n)}))}loadAsync(e,t){return $e(this,null,(function*(){let n=(e,n,i)=>{let r=100*e.loaded/e.total;r=r*(i-n)/100+n,t&&t(new ProgressEvent(e.type,{loaded:r,total:100}))},i=e=>n(e,10,100);if(tn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){$.info(`[DxfLoader] Loaded DxfData from indexedDb in ${(Date.now()-this.timer)/1e3}s`);let e=yield this.loadEntities(t,i);return Promise.resolve(e)}}catch(e){$.warn("[DxfLoader] Failed to parse data from indexedDb",e)}}let r=yield this.parse(e,(e=>n(e,0,50)));return yield this.loadEntities(r,(e=>n(e,50,100)))}))}parse(e,t){return $e(this,null,(function*(){let n=e=>{t&&t(new ProgressEvent("",{loaded:e,total:100}))},i=!1,r=yield this.download(e,(e=>((e,n,r)=>{let a=100*e.loaded/e.total;a=40*a/100+0,a>40&&(i||($.warn("[DxfLoader] Invalid ProgressEvent:",e),i=!0),a=40),t&&t(new ProgressEvent(e.type,{loaded:a,total:100}))})(e)));if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(dn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),$.info("[DxfLoader] Start parsing...");let a=(new Up).parseSync(r);if(n(80),$.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),dn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&(a.objects||(a.objects={}),a.objects.LAYOUT||($.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),a.objects.LAYOUT=[{layoutName:dn.MODEL_LAYOUT_NAME}]),tn.isBrowser&&this.enableLocalCache&&this.dxfDataId)){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),$.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){$.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return n(100),a}))}parseHeader(e){if(!e)return void $.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&$.warn(`[DxfLoader] Unexpected version: ${t}. But we'll try to continue.`),this.angBase=e.$ANGBASE||0,this.angDir=e.$ANGDIR||0}loadEntities(e,t){return $e(this,null,(function*(){var n;let i=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1);let r=0,a=e.entities.length;this.entityCount=a,Object.keys(e.blocks).forEach((t=>{var n;this.entityCount+=(null==(n=e.blocks[t].entities)?void 0:n.length)||0}));let s=Math.round(Math.pow(a,.5)),o=Date.now(),l=e=>$e(this,null,(function*(){if(t&&(e%s==0||e===a-1)){t(new ProgressEvent("parseProgress",{loaded:e+1,total:a}));let n=500,i=Date.now();(i-o>n||e===a-1)&&(yield it.sleep(0),o=i)}})),h={};e.objects.LAYOUT.forEach((e=>{let t=e;h[t.layoutName]=t}));let c={},u=e=>{let t=e.userData.layerName,n=c[t];n||(n=[],c[t]=n),n.push(e)},d={},p={},f=new Nt;cn.setSharedVariablesOfObject(f);for(let t=0;t<a&&!dn.abortJobs;t++){let n=e.entities[t];this.addViewport(n,d);let i=this.drawEntity(n,e);if(i||(yield l(t)),!i)continue;let a=this.getLayout(e,n).layoutName,s=f.children.find((e=>e.name===a));if(s||(s=new Nt,cn.setSharedVariablesOfObject(s),s.name=a,s.userData.isLayoutLevelObject=!0,f.add(s)),i.traverse((e=>{e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[a]||(this.layoutsSnapObjectsMap[a]=[]),this.layoutsSnapObjectsMap[a].push(e))})),this.enableMerge){gr.merge(i,!1),p[a]||(p[a]={object:s,layerObjects:{}});let t=p[a];if(i.geometry){cn.setSharedVariablesOfObject(i);let n=i.userData.layerName;!1===this.getLayerVisible(e,n)&&(i.visible=!1,i.userData.layerVisible=!1),t.layerObjects[n]||(t.layerObjects[n]=[]),t.layerObjects[n].push(i),i.children.forEach((e=>{e.userData.isSnapObject&&u(e)}))}else i.children.length>0&&(s.add(i),i.traverse((t=>{if(cn.setSharedVariablesOfObject(t),t.geometry){let n=t.userData.layerName;!1===this.getLayerVisible(e,n)&&(t.visible=!1,t.userData.layerVisible=!1),u(t)}})))}else{let t;if(a!==dn.MODEL_LAYOUT_NAME){let e=h[a];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),t=e.directAssociatedLeafObjectSet}s.add(i),i.traverse((n=>{if(cn.setSharedVariablesOfObject(n),n.geometry){let i=n.userData.layerName;!1===this.getLayerVisible(e,i)&&(n.visible=!1,n.userData.layerVisible=!1),u(n),t&&t.add(n)}}))}r++,yield l(t)}e.objects.LAYOUT.forEach((t=>{let n=t,i=n.layoutName;if(this.ignorePaperSpace&&i!==dn.MODEL_LAYOUT_NAME)return;let r=n.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,n,f,c,d)})),$.debug(`[DxfLoader] Drew entities in ${(Date.now()-i)/1e3}s`);for(let t in this.layoutsSnapObjectsMap){let i=f.children.find((e=>e.name===t)),r=new Nt;r.visible=dn.SHOW_SNAP_OBJECT,r.name=dn.SNAP_GROUP_NAME,i.add(r);let a=this.layoutsSnapObjectsMap[t];for(let s=0;s<a.length;s++){let i=a[s];!this.enableMerge&&t!==dn.MODEL_LAYOUT_NAME&&(null==(n=h[t].directAssociatedLeafObjectSet)||n.add(i));let o=i.userData.layerName;!1===this.getLayerVisible(e,o)&&(i.layers.disable(11),delete i.userData.layerVisible),dn.SHOW_SNAP_OBJECT&&(i.visible=!0,i.layers.enableAll(),i.material instanceof Br?i.material=Nhe:i.material instanceof Jt?i.material=Uhe:i.material instanceof Pt&&(i.material=Bhe));let l=i.parent,c=ro.identity();for(;l&&!0!==l.userData.isLayoutLevelObject;)c.premultiply(l.matrix),l=l.parent;i.applyMatrix4(c),r.add(i)}}if(this.enableMerge)for(let e in p){let t=p[e],n=t.object;for(let e in t.layerObjects){let i=t.layerObjects[e],r=gr.deepMerge(i,void 0,!1,!1,!0),a=r.added,s=r.removed;if(s.length!==i.length){let e=s;s.length>=100&&(e=new Set(s));let t=t=>Array.isArray(e)?e.indexOf(t)>=0:e.has(t);for(let r=0,a=i.length;r<a;r++){let e=i[r];t(e)||(n.add(e),u(e))}}for(let e=0;e<a.length;e++){let t=a[e];cn.setSharedVariablesOfObject(t),n.add(t),u(t)}t.layerObjects[e]=[]}}for(let e in this.entityTypesAndTimes)this.entityTypesAndTimes[e].averageTime=this.entityTypesAndTimes[e].totalTime/this.entityTypesAndTimes[e].createCount;$.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),$.debug("[DxfLoader] Entity types and mesh count:",this.statsInfo.entityTypesAndMeshCount);let m=0;if(Object.values(this.statsInfo.entityTypesAndMeshCount).forEach((e=>{m+=e})),this.enableRTC&&$.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${m}) entities`),this.enableMerge){let e=gr.mergeInfo;$.debug(`[DxfLoader] Inner merged ${e.removedObjects} objects to ${e.mergedMeshes} meshes, ${e.mergedLines} lines, ${e.mergedPoints} points, ${e.mergedUnknownTypeObjects?e.mergedUnknownTypeObjects+" unknown type,":""} in ${e.elapsedTime/1e3}s`)}let g=(e,t,...n)=>{Object.keys(t).length};g(0,this.statsInfo.unsupportedEntityTypes),g(0,this.statsInfo.unsupportedTextStyles),g(0,this.statsInfo.unsupportedHatchPatterns),g(0,this.statsInfo.invisibleEntities),g(0,this.statsInfo.ignoredFrozenLayersAndEntityCount),g(0,this.statsInfo.ignoredInserts),this.ignorePaperSpace&&g(0,this.statsInfo.ignoredPaperSpaceEntityTypesAndCount),this.font&&this.font.unsupportedChars&&g(0,this.font.unsupportedChars),this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(e)),$.info(`[DxfLoader] loadEntities() done in ${(Date.now()-i)/1e3}s`);let v=Qr(yn({},e),{threejsObject:f,layersAndThreejsObjects:c,loadedEntityCount:r,layoutViewportsMap:d});return Promise.resolve(v)}))}loadEntitiesForCompare(e,t,n,i=!0,r){return $e(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>$e(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,c=h?e:t,u=new Nt,d=h?a:s,p=c.entities.length;this.entityCount=p,Object.keys(c.blocks).forEach((e=>{var t;this.entityCount+=(null==(t=c.blocks[e].entities)?void 0:t.length)||0}));let f=Math.round(Math.pow(d,.5)),m=Date.now(),g=e=>$e(this,null,(function*(){if(r&&(e%f==0||e===d-1)){let t=e+1;h||(t+=a),r(new ProgressEvent("parseProgress",{loaded:t,total:a+s}));let n=500,i=Date.now();(i-m>n||e===d-1)&&(yield it.sleep(0),m=i)}}));this.parseHeader(c.header);let v={};for(let e=0;e<d;e++){if(dn.abortJobs)return;let t=c.entities[e],n=this.getLayout(c,t);if(n.layoutName!==dn.MODEL_LAYOUT_NAME){yield g(e);continue}let i=this.drawEntity(t,c);if(!i){yield g(e);continue}let r=u.children[0];r||(r=new Nt,r.name=dn.MODEL_LAYOUT_NAME,r.userData.isLayoutLevelObject=!0,u.add(r)),r.add(i),i.traverse((e=>{if(e.geometry){let t=e.userData.layerName,r=this.getLayerVisible(c,t);!1===r&&(e.visible=!1,e.userData.layerVisible=!1),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e),!1===r&&(i.layers.disable(11),delete i.userData.layerVisible));let a=v[t];a||(a=[],v[t]=a),a.push(e)}})),yield g(e)}let y=c;y.threejsObject=u,u.updateMatrixWorld(!0),y.layersAndThreejsObjects=v,y.layoutViewportsMap={},i&&h&&(l.preservedHandles||(l.preservedHandles=new Set));for(let e in n){let t=n[e];h&&("Added"===t.type||"Modified"===t.type)&&(null==(o=l.preservedHandles)||o.add(t.handle),t.parentHandles&&t.parentHandles.forEach((e=>{var t;return null==(t=l.preservedHandles)?void 0:t.add(e)})));let i=this.entityThreejsCache&&this.entityThreejsCache[t.handle];if(t.parentHandles&&(i=this.entityThreejsCache&&this.entityThreejsCache[t.parentHandles[t.parentHandles.length-1]]),i){if(i.parent&&i.parent.userData.originalType){this.setObjectColorByChange(i,{type:"NoChange"});continue}i=this.setObjectColorByChange(i,t)}"NoChange"!==t.type&&i&&("Added"===t.type?!h&&(t.box=(new lt).setFromObject(i)):"Removed"===t.type?h&&(t.box=(new lt).setFromObject(i)):"Modified"===t.type&&(t.box?t.box.union((new lt).setFromObject(i)):t.box=(new lt).setFromObject(i)))}for(let e in this.layoutsSnapObjectsMap){let t=u.children.find((t=>t.name===e)),n=new Nt;n.visible=dn.SHOW_SNAP_OBJECT,n.name=dn.SNAP_GROUP_NAME,t.add(n);let i=this.layoutsSnapObjectsMap[e];for(let e=0;e<i.length;e++){let t=i[e];dn.SHOW_SNAP_OBJECT&&(t.visible=!0,t.layers.enableAll(),t.material instanceof Br?t.material=Nhe:t.material instanceof Jt?t.material=Uhe:t.material instanceof Pt&&(t.material=Bhe));let r=t.parent,a=ro.identity();for(;r&&!0!==r.userData.isLayoutLevelObject;)a.premultiply(r.matrix),r=r.parent;t.applyMatrix4(a),n.add(t)}}this.enableMerge&&(yield dn.merge(y))})),l=Date.now();this.compareContext={changes:n,isTheFirstFile:!0},it.printMemory("Before loading entities for first dxf"),yield o(),$.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),it.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),it.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),$.info(`[DxfLoader] loadEntities for second dxf in ${(Date.now()-l)/1e3}s`);for(let e of Object.values(n))e.box||delete n[e.id];this.compareContext.preservedHandles=void 0,this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(t)),it.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let n=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof Jt)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof Pt)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof Br)e.material=this.getPointsMaterial(t);else if(e.material instanceof It){let n=e.material.clone();dn.updateMaterialUniforms(n),n.uniforms.u_color.value.set(t),e.material=n}}))},i=(e=>{var t;let n=Zr.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?n=Zr.ENTITY_COLOR_ADDED:"Removed"===e.type?n=Zr.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(n=null!=(t=this.compareContext)&&t.isTheFirstFile?Zr.ENTITY_COLOR_REMOVED:Zr.ENTITY_COLOR_ADDED),n})(t);return e.traverse((r=>{t.parentHandles?r.userData&&r.userData.handle&&r.userData.handle===t.handle&&(n(r,i),e=r):n(r,i)})),e}releaseCachedData(e=!0){e&&(this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[]),this.header=void 0,this.blockReferencesCache={},this.blockRecordsCache=void 0,this.blocksCache=void 0,this.entitiesCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.entityHandlesWithRenderOrder={},this.layoutsSnapObjectsMap={},this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0}}releaseEntity(e){e.vertices&&(e.vertices=void 0),e.knotValues&&(e.knotValues=void 0),e.controlPoints&&(e.controlPoints=void 0),e.binaryData&&(e.binaryData=void 0),e.text&&(e.text=void 0),e.extendedData&&(e.extendedData=void 0),e.contextData&&(e.contextData=void 0);let t=e;t.boundaryPaths&&(t.boundaryPaths=[]),t.patternLines&&(t.patternLines=void 0)}releaseDxfData(e){delete e.objects.DICTIONARY,delete e.objects.SORTENTSTABLE,delete e.objects.XRECORD,e.tables&&(delete e.tables.dimStyle,delete e.tables.lineType,delete e.tables.style,delete e.tables.blockRecord),e.entities=[],e.blocks={}}drawEntity(e,t,n,i=!1){if(this.compareContext&&this.compareContext.preservedHandles&&this.compareContext.preservedHandles.has(e.handle)&&Lp.includes(e.type)&&(i=!0),!i&&this.compareContext&&this.compareContext.preservedHandles&&!Lp.includes(e.type)&&!this.compareContext.preservedHandles.has(e.handle)&&(!n||n&&!this.compareContext.preservedHandles.has(n.handle)))return;if(!0===this.getLayerFrozen(t,e)){let t=e.layer;return this.statsInfo.ignoredFrozenLayersAndEntityCount[t]||(this.statsInfo.ignoredFrozenLayersAndEntityCount[t]=0),void this.statsInfo.ignoredFrozenLayersAndEntityCount[t]++}if(!1===e.visible||e.invisible)return this.statsInfo.invisibleEntities[e.type]||(this.statsInfo.invisibleEntities[e.type]=0),void this.statsInfo.invisibleEntities[e.type]++;if(this.ignorePaperSpace&&e.inPaperSpace)return this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]||(this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]=0),void this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]++;this.entityThreejsCache||(this.entityThreejsCache={});let r,a=Date.now(),s=!1;if(!this.compareContext&&this.entityThreejsCache[e.handle])r=this.entityThreejsCache[e.handle].clone(),s=!0;else if(!this.statsInfo.unsupportedEntity[e.handle]){if("CIRCLE"===e.type||"ARC"===e.type)r=this.drawArc(e,t,n);else if("LINE"===e.type||"POLYLINE"===e.type)r=this.drawLine(e);else if("XLINE"===e.type)r=this.drawXLine(e);else if("SEQEND"!==e.type)if("RAY"===e.type)r=this.drawRay(e);else if("LWPOLYLINE"===e.type)r=this.drawLWPolyline(e,t,n);else if("3DFACE"===e.type)r=this.draw3DFace(e);else if("TEXT"===e.type)r=this.drawText(e,t,n);else if("SOLID"===e.type)r=this.drawSolid(e,t,n);else if("POINT"===e.type)r=this.drawPoint(e,t,n);else if("IMAGE"===e.type)r=this.drawImage(e,t,n);else if("INSERT"===e.type)r=this.drawInsert(e,t,i);else if("SPLINE"===e.type)r=this.drawSpline(e,n);else if("MTEXT"===e.type)r=this.drawMText(e,t,n);else if("ELLIPSE"===e.type)r=this.drawEllipse(e,t,n);else if("DIMENSION"===e.type)r=this.drawDimension(e,t);else if("REGION"!==e.type)if("ATTDEF"===e.type)r=this.drawAttDef(e,t,n);else if("ATTRIB"===e.type){if(!n)for(let i=0;i<t.entities.length;i++){let r=t.entities[i];if(e.ownerHandle===r.handle&&(n=r).attributesFollow)break}r=this.drawAttrib(e,t,n)}else"HATCH"===e.type?r=this.drawHatch(e,t,n):"VIEWPORT"===e.type?r=this.drawViewport(e,t,n):"LEADER"===e.type?r=this.drawLeader(e,t,n):"MULTILEADER"===e.type?r=this.drawMLeader(e,t,n):"OLE2FRAME"===e.type&&(r=this.drawOle2frame(e,t));r&&(this.entityThreejsCache[e.handle]=r),this.enableReleaseData&&!this.compareContext&&this.releaseEntity(e)}if(r){r.matrixAutoUpdate=!1,r.updateMatrix();let i=this.getLayerName(e,t,n);r.userData.handle=e.handle,cn.setSharedVariablesOfObject(r),"INSERT"!==e.type&&"DIMENSION"!==e.type&&r.traverse((r=>{cn.setSharedVariablesOfObject(r),r.matrixAutoUpdate=!1,r.updateMatrix(),r.geometry&&(r.userData.layerName=i,this.setMaterial(r,e,t,n))})),s||(this.nonSnapableTypes.has(e.type)&&r.traverse((e=>{e.layers.disable(11)})),this.enableRenderOrder&&(this.entityHandlesWithRenderOrder[e.handle]?r.renderOrder=parseInt(this.entityHandlesWithRenderOrder[e.handle],16)+.1:r.renderOrder=parseInt(e.handle,16)))}return Lp.includes(e.type)||(this.entityTypesAndTimes||(this.entityTypesAndTimes={}),this.entityTypesAndTimes[e.type]||(this.entityTypesAndTimes[e.type]={createCount:0,totalTime:0,averageTime:0}),this.entityTypesAndTimes[e.type].createCount++,this.entityTypesAndTimes[e.type].totalTime+=Date.now()-a),r?this.statsInfo.entityTypesAndMeshCount[e.type]?this.statsInfo.entityTypesAndMeshCount[e.type]++:this.statsInfo.entityTypesAndMeshCount[e.type]=1:(this.statsInfo.unsupportedEntityTypes[e.type]?this.statsInfo.unsupportedEntityTypes[e.type]++:this.statsInfo.unsupportedEntityTypes[e.type]=1,Lp.includes(e.type)||(this.statsInfo.unsupportedEntity[e.handle]?this.statsInfo.unsupportedEntity[e.handle]++:this.statsInfo.unsupportedEntity[e.handle]=1)),r}drawEllipse(e,t,n){if(!e.majorAxisEndPoint||!e.center||void 0===e.axisRatio||void 0===e.startAngle||void 0===e.endAngle)return;let i=e.startAngle,r=e.endAngle;if(e.extrusionDirection&&e.extrusionDirection.z<0&&(i=2*Math.PI-e.endAngle,r=2*Math.PI-e.startAngle),wt.areNumbersEqual(i,r,1e-5))return void $.warn("[DxfLoader] Ellipse entity (handle '%s') contains the same start and end angle, ignored!",e.handle);let a=r-i;for(;a>2*Math.PI;)a-=2*Math.PI;Math.abs(a)<=1e-5&&(r=wt.floorNumber(i+2*Math.PI,5));let s=Math.sqrt(Math.pow(e.majorAxisEndPoint.x,2)+Math.pow(e.majorAxisEndPoint.y,2)),o=s*e.axisRatio,l=Math.atan2(e.majorAxisEndPoint.y,e.majorAxisEndPoint.x),h=new Gu(e.center.x,e.center.y,s,o,i,r,!1,l),c=1,u=n;null!=u&&u.xScale&&null!=u&&u.yScale&&(c=Math.max(Math.abs(u.xScale),Math.abs(u.yScale)));let d=this.getDivision(i,r,Math.max(s,o)*c),p=h.getPoints(d),f=[],m=p.length;for(let b=0;b<m-1;b++)wt.areVector2sEqual(p[b],p[b+1],1e-9)||f.push(p[b]);if(f.push(p[m-1]),f.length<2)return void $.warn("[DxfLoader] Ellipse entity (handle '%s') contains less than 2 points, ignored!",e.handle);let g=new M,v=!1;this.enableRTC&&(v=xt.checkAndRebasePositionsOnRTC(f,g));let y=(new et).setFromPoints(f),x=new sn(y,Xs),_=new or((new et).setFromPoints([new M(e.center.x,e.center.y,e.center.z)]),PE);return _.userData.isSnapObject=!0,_.userData.type="CircleCenter",_.layers.set(11),x.add(_),v&&(this.setRTCUserData(x),x.position.x+=g.x,x.position.y+=g.y),x.layers.enableAll(),x}drawMText(e,t,n){if(!e.text)return;if(!this.font)return void $.info("[DxfLoader] Font file not set, ignoring text entity.");let i=this.getTextStyle(t,e),r=VR(e.text,{encoding:this.getTextEncoding(i)}),a=this.mtextContentAndFormattingToTextAndStyle(r,e),s=this.getMTextGroup(a.text,e,t,n,a);if(!s)return;e.position&&(s.position.x+=e.position.x,s.position.y+=e.position.y);let o=(new lt).setFromObject(s).getSize(Ci),l=o.x,h=o.y,c=0,u=0;switch(e.attachmentPoint){case 1:c=0,u=0;break;case 2:c-=l/2,u=0;break;case 3:c-=l,u=0;break;case 4:c=0,u+=h/2;break;case 5:c-=l/2,u+=h/2;break;case 6:c-=l,u+=h/2;break;case 7:c=0,u+=h;break;case 8:c-=l/2,u+=h;break;case 9:c-=l,u+=h;break;default:return}switch(a.style.horizontalAlignment){case"left":c=0;break;case"center":c=0,c-=l/2;break;case"right":c=0,c-=l}if(s.traverse((e=>{e.geometry&&e.geometry.translate(c,u,0),e.layers.enableAll()})),e.rotation&&(s.rotation.z=e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,n=new M(t.x,t.y,t.z),i=n.clone().cross(Rd),r=new M(1,0,0).angleTo(n);s.rotateZ(i.z>0?-r:r)}return a.lineLength>1?s.position.y-=o.y+a.style.textHeight:s.position.y-=o.y,xt.shouldRebasePositionOnRTC(s.position)&&this.setRTCUserData(s),s}getMTextGroup(e,t,n,i,r){var a;if(0===e.length)return;let s=(r?r.style.textHeight:t.textHeight)||0;if(t.textStyle){let e=this.getTextStyle(n,t);if(e&&e.fontFile&&e.fontFile.endsWith(".shx")){$.warn(`[DxfLoader] Don't support font file ${e.fontFile}`);let t=e.styleName||"";this.statsInfo.unsupportedTextStyles[t]||(this.statsInfo.unsupportedTextStyles[t]=0),this.statsInfo.unsupportedTextStyles[t]++}s=s||e.textHeight}let o=s/1.5,l=s/2,h=new Nt;for(let c=0;c<e.length;c++){let{text:s,font:u,colorIndex:d,lineNum:p}=e[c];u&&u.includes(".shx")&&$.warn(`[DxfLoader] Doesn't support custom fonts: ${u}`);let f=this.getTextMesh(s,t,n,i,r);if(!f)continue;let m=(null==(a=s.match(new RegExp("\\n","g")))?void 0:a.length)||0;f.position.y-=(p+m)*(o+l),void 0!==d&&256!==d&&(t.color=Op(d),t.colorIndex=d);let g=this.getColor(t,n,i);f.material instanceof Pt?f.material=this.getMeshBasicMaterial(g):f.material instanceof Jt&&(f.material=this.getLineBasicMaterial(g)),h.add(f)}return 0!==h.children.length?(gr.merge(h,!1),r&&h.translateY(r.lineLength*(o+l)),h):void 0}mtextContentAndFormattingToTextAndStyle(e,t){let n={horizontalAlignment:"",textHeight:t.height||t.contextData&&t.contextData.textHeight},i={},r=1,a=[];for(let s=0;s<e.length;s++){let o=e[s];if("string"==typeof o){if(o.startsWith("\\pxq")&&o.endsWith(";"))-1!==o.indexOf("c")?n.horizontalAlignment="center":-1!==o.indexOf("l")?n.horizontalAlignment="left":-1!==o.indexOf("r")?n.horizontalAlignment="right":-1!==o.indexOf("j")&&(n.horizontalAlignment="justify");else if(!o.startsWith("pi")&&!o.startsWith("pxt")&&!o.startsWith("pt")){let e=this.getTextLineNum(o);for(let t of a)null==t.colorIndex&&(t.colorIndex=i.C),null==t.font&&(t.font=i.f);a.push({font:i.f,colorIndex:i.C,text:o,lineNum:r}),r+=e}}else if(Array.isArray(o)){let e=this.mtextContentAndFormattingToTextAndStyle(o,t);e.text.forEach((e=>{a.push(e)})),r=e.lineLength}else if("object"==typeof o)if(o.S&&3===o.S.length){let e=o.S[0]+"/"+o.S[2],t=this.getTextLineNum(e);a.push({text:o.S[0]+"/"+o.S[2],lineNum:r}),r+=t}else void 0!==o.C?i.C=o.C:void 0!==o.W?i.W=o.W:void 0!==o.H?i.H=o.H:void 0!==o.f&&(i.f=o.f)}return{text:a,lineLength:r,style:n}}getTextLineNum(e){let t=e.match(new RegExp("\\n","g"));return t?t.length:0}draw3DFace(e){if(!e.vertices||0===e.vertices.length)return void $.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new M(e.x,e.y,e.z)));if(0===t.length)return;wt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let n=new M,i=!1;this.enableRTC&&(i=xt.checkAndRebasePositionsOnRTC(t,n));let r=(new et).setFromPoints(t),a=new sn(r,Xs);return i&&(this.setRTCUserData(a),a.position.x+=n.x,a.position.y+=n.y),a.layers.enableAll(),a}drawSpline(e,t){if(!e.controlPoints||!e.degreeOfSplineCurve||!e.knotValues)return;let n=1/0,i=1/0,r=-1/0,a=-1/0;for(let g of e.controlPoints)g.x<n&&(n=g.x),g.y<i&&(i=g.y),g.x>r&&(r=g.x),g.y>a&&(a=g.y);let s=1,o=t;null!=o&&o.xScale&&null!=o&&o.yScale&&(s=Math.max(Math.abs(o.xScale),Math.abs(o.yScale)));let l=Math.max(r-n,a-i),h=this.getBSplineInterpolationsPerSplineSegment(e.controlPoints.length,l*s),c=Lst(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new M,d=!1;this.enableRTC&&(d=xt.checkAndRebasePositionsOnRTC(c,u));let p=xt.getAdjacentNonRepeatPoints(c);if(p.length<2)return void $.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new et).setFromPoints(p),m=new sn(f,Xs);return d&&(this.setRTCUserData(m),m.position.x+=u.x,m.position.y+=u.y),m.layers.enableAll(),m}drawXLine(e){if(!e.vertices||0===e.vertices.length)return void $.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=it.arrayOrObjectToVector3(e.directionVector),n=new M(e.vertices[0].x,e.vertices[0].y,0),i=[];if(i.push(t.clone().multiplyScalar(-1e6).add(n)),i.push(t.clone().multiplyScalar(1e6).add(n)),0===i.length)return;let r=new M,a=!1;this.enableRTC&&(a=xt.checkAndRebasePositionsOnRTC(i,r));let s=(new et).setFromPoints(i),o=new sn(s,Xs);return a&&(this.setRTCUserData(o),o.position.x+=r.x,o.position.y+=r.y),o.layers.enableAll(),o}drawRay(e){if(!e.vertices||0===e.vertices.length)return void $.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=it.arrayOrObjectToVector3(e.directionVector),n=e.vertices.map((e=>new M(e.x,e.y,0)));if(n.push(t.multiplyScalar(1e6).add(n[0])),0===n.length)return;let i=new M,r=!1;this.enableRTC&&(r=xt.checkAndRebasePositionsOnRTC(n,i));let a=(new et).setFromPoints(n),s=new sn(a,Xs);return r&&(this.setRTCUserData(s),s.position.x+=i.x,s.position.y+=i.y),s.layers.enableAll(),s}drawLine(e){if(!e.vertices||0===e.vertices.length)return void $.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=Nst(e.vertices);else{let n=W5(e.vertices,e.shape);e.shape&&n.length>0&&n.push(n[0]),n.length>0&&(t=[n])}if(0===t.length)return;let n=[];for(let s=0;s<t.length;){let[e,i]=t[s];wt.areVector3sEqual(e,i)?(n.push(e),t.splice(s,1)):s++}let i,r=new M,a=!1;if(t.length>0){if(this.enableRTC){let e=0;t.forEach((t=>{t.forEach((t=>{r.add(t),e++}))})),r.divideScalar(e),a=xt.shouldRebasePositionOnRTC(r)}let e=[],n=[],s=0,o=0,l=0,h=0;t.forEach((t=>{for(let i=0;i<t.length;i++)a?(o=t[i].x-r.x,l=t[i].y-r.y,h=t[i].z-r.z,e.push(new M(o,l,h))):e.push(t[i]),i>0&&n.push(s+i-1,s+i);s=t.length}));let c=(new et).setFromPoints(e);c.setIndex(n),i=new Dn(c,Xs)}if(n.length>0){this.enableRTC&&(a=xt.checkAndRebasePositionsOnRTC(n,r));let e=(new et).setFromPoints(n);i=new or(e,PE)}return i?(a&&(this.setRTCUserData(i),i.position.x+=r.x,i.position.y+=r.y),i.layers.enableAll(),i):void 0}drawLWPolyline(e,t,n){var i,r,a;if(!e.vertices||e.vertices.length<2)return void $.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let s=e;if(void 0!==s.extrusionDirectionX&&void 0!==s.extrusionDirectionY&&void 0!==s.extrusionDirectionZ){Ci.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=dn.getOcsMatrix(Ci).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((n=>{let i=Ci.set(n.x,n.y,t).applyMatrix4(e);n.x=i.x,n.y=i.y}))}let o=W5(e.vertices,e.shape);if(e.shape&&o.length>0&&!wt.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void $.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new Nt;if(null!=(i=e.extendedData)&&i.outlines){let t=e.extendedData.outlines,n=[];t.forEach((e=>{let t=new Fs;e.forEach(((e,n)=>{0===n?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),n.push(new bc(t))}));let i=Fo(n),r=new Ge(i,jv);r.layers.enableAll(),l.add(r)}let h=new M,c=!1;this.enableRTC&&(c=xt.checkAndRebasePositionsOnRTC(o,h));let u=xt.getAdjacentNonRepeatPoints(o);if(u.length<2)return void $.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);if(this.enablePlineWidth&&void 0!==s.constantWidth&&s.constantWidth>0){let i=null==(a=null==(r=t.tables)?void 0:r.lineType)?void 0:a.lineTypes,o=i&&i[this.getLineType(e,t,n)];if(!o||!o.pattern||0===o.pattern.length){$.warn("[DxfLoader] It doesn't support line with width and lineType, lineType will be ignored!");let t=xt.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new Ge(t,jv);e.layers.enableAll(),e.layers.disable(11),l.add(e);let n=cn.createOutlineSync(t,e.matrix,Xs);n.layers.enableAll(),n.layers.disable(11),l.add(n)}else $.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new sn((new et).setFromPoints(u),Xs);return d.layers.enableAll(),l.children.length>0?l.add(d):l=d,c&&(this.setRTCUserData(l),l.position.x+=h.x,l.position.y+=h.y,l.position.z+=h.z),l}drawMLeader(e,t,n){var i,r,a,s,o,l,h,c;let u=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),d=null==(i=e.contextData)?void 0:i.defaultTextContents;if(!d)return;let p=new Nt,f=VR(d),m=this.mtextContentAndFormattingToTextAndStyle(f,e),g=this.getMTextGroup(m.text,e,t,n,m);if(g){null!=(r=e.contextData)&&r.textLocation&&(g.position.x+=e.contextData.textLocation.x,g.position.y+=e.contextData.textLocation.y);let t=(null==(a=e.contextData)?void 0:a.textWidth)||1;switch(m.style.horizontalAlignment){case"left":default:break;case"center":t&&(g.position.x+=t/2);break;case"right":t&&(g.position.x+=t)}let n=(new lt).setFromObject(g).getSize(Ci),i=n.x,h=n.y,c=0,u=0;switch(null==(s=e.contextData)?void 0:s.textAttachment){case 1:c=0,u=0;break;case 2:c-=i/2,u=0;break;case 3:c-=i,u=0;break;case 4:c=0,u+=h/2;break;case 5:c-=i/2,u+=h/2;break;case 6:c-=i,u+=h/2;break;case 7:c=0,u+=h;break;case 8:c-=i/2,u+=h;break;case 9:c-=i,u+=h;break;default:return}if(g.traverse((e=>{e.geometry&&e.geometry.translate(c,u,0)})),null!=(o=e.contextData)&&o.textRotation&&(g.rotation.z=e.contextData.textRotation*Math.PI/180),null!=(l=e.contextData)&&l.textDirection){let t=e.contextData.textDirection,n=new M(t.x,t.y,t.z),i=n.clone().cross(new M(1,0,0)),r=new M(1,0,0).angleTo(n);g.rotateZ(i.z>0?-r:r)}xt.shouldRebasePositionOnRTC(g.position)&&this.setRTCUserData(g),g.renderOrder=5,p.add(g)}if(0===e.leaderLineType)return null==g||g.traverse((e=>{e.layers.enableAll()})),g;{let n=[],i=null==(h=e.contextData)?void 0:h.leaders[0];if(!i)return p;let r=i.lastLeaderLinePoint;if(e.enableDogLeg){let e=new M(r.x,r.y,r.z),t=i.doglegLength,a=new M(i.doglegVector.x,i.doglegVector.y,i.doglegVector.z).multiplyScalar(t),s=e.clone().add(a);n.push(s,e)}let a=(null==(c=e.contextData)?void 0:c.leaders[0].leaderLines)||[];for(let h=0;h<a.length;h++){let i=a[h].vertices[0].reverse().map((e=>new M(e.x,e.y,e.z))),s=new M(r.x,r.y,r.z);for(let e=0;e<i.length;e++)n.push(s,i[e]),s=i[e];let o=Ci.subVectors(n[0],n[1]).length(),l=(e.arrowHeadSize||u.DIMASZ||2.5)*(e.arrowHeadScale||u.DIMSCALE||1);e.leaderLineType;let c="";if(e.arrowHeadId?c=e.arrowHeadId:u&&u.DIMLDRBLK&&(c=u.DIMLDRBLK),c){let i=this.getBlockByHandle(t.blocks,c);if(i&&i.entities)for(let r=0;r<i.entities.length;r++){let a=this.drawEntity(i.entities[r],t,e);if(a){let e=new M(n[n.length-1].x,n[n.length-1].y,n[n.length-1].z),t=new M(n[n.length-2].x,n[n.length-2].y,n[n.length-2].z),i=Math.atan2(e.y-t.y,e.x-t.x);a.position.copy(e),a.quaternion.identity(),a.scale.setScalar(l),a.rotateZ(i),a.updateMatrix(),p.add(a)}}}else this.drawDefaultLeadArrow(n[n.length-2],n[n.length-1],o/2e3,n)}let s=new M,o=!1;this.enableRTC&&(o=xt.checkAndRebasePositionsOnRTC(n,s));let l=(new et).setFromPoints(n),d=new Dn(l,Xs);d.renderOrder=2,o?(this.setRTCUserData(d),d.position.x+=s.x,d.position.y+=s.y):xt.shouldRebasePositionOnRTC(d.position)&&this.setRTCUserData(d),p.add(d)}return gr.merge(p,!1),p.traverse((e=>{e.layers.enableAll()})),p}drawLeader(e,t,n){let i=[];if(!e.vertices)return void $.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void $.warn("leader's vertices number must be greater than 2");let r=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),a=e.vertices;if(1===e.pathType&&(a=new np(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,n=new M(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new M(1,0,0).multiplyScalar(t);a.push(e.add(n))}else{let e=new M(-1,0,0).multiplyScalar(t);a.push(e.add(n))}}for(let p=0;p<a.length-1;p++){let e=a[p],t=a[p+1];i.push(e,t)}let s=Ci.subVectors(i[0],i[1]).setZ(0).length(),o=(e.arrowHeight||r.DIMASZ||2.5)*(e.arrowHeadScale||r.DIMSCALE||1),l=new Nt;if(1===e.arrowFlag){let n="";e.arrowHeadBlockHandle?n=e.arrowHeadBlockHandle:r&&r.DIMLDRBLK&&(n=r.DIMLDRBLK);let a=this.getBlockByHandle(t.blocks,n);if(a&&a.entities){r&&(e.colorIndex=r.DIMCLRD||256,e.color=Op(e.colorIndex));for(let n=0;n<a.entities.length;n++){let r=this.drawEntity(a.entities[n],t,e);if(r){let e=new M(i[0].x,i[0].y,i[0].z),t=new M(i[1].x,i[1].y,i[1].z),n=Math.atan2(e.y-t.y,e.x-t.x);r.position.copy(e),r.quaternion.identity(),r.scale.setScalar(o),r.rotateZ(n),r.updateMatrix(),l.add(r)}}}else this.drawDefaultLeadArrow(i[1],i[0],o/s/2,i)}if(0===i.length)return;let h=new M,c=!1;this.enableRTC&&(c=xt.checkAndRebasePositionsOnRTC(i,h));let u=(new et).setFromPoints(i),d=new Dn(u,Xs);return d.renderOrder=2,c?(this.setRTCUserData(d),d.position.x+=h.x,d.position.y+=h.y):xt.shouldRebasePositionOnRTC(d.position)&&this.setRTCUserData(d),l.children.length>0?(l.add(d),gr.merge(l,!1),l.traverse((e=>{e.layers.enableAll()})),l):(d.layers.enableAll(),d)}drawDefaultLeadArrow(e,t,n,i){let r=n*(e.x-t.x),a=n*(e.y-t.y),s=a,o=-r,l=new M(t.x+r+s/6,t.y+a+o/6,0),h=new M(t.x+r-s/6,t.y+a-o/6,0);i.push(t,l),i.push(t,h),i.push(l,h)}getBlockByHandle(e,t){if(!this.blocksCache){this.blocksCache={};for(let t in e){let n=e[t];this.blocksCache[n.ownerHandle]||(this.blocksCache[n.ownerHandle]=n)}}return this.blocksCache[t]}static updateMaterialUniforms(e){e instanceof It&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=dn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=dn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let n=Ci.set(1*Math.cos(t),1*Math.sin(t),0).applyMatrix4(e);return Math.atan2(n.y,n.x)}static getArcAnglesByOcsMatrix(e,t,n){let i,r=wt.getArcAngleSpanInRadian(t,n),a=dn.transformAngleByOcsMatrix(e,t),s=dn.transformAngleByOcsMatrix(e,n);if(wt.areNumbersClose(r,Math.PI)){r=1;let n=dn.transformAngleByOcsMatrix(e,t+r);i=wt.getArcAngleSpanInRadian(a,n)}else{if(wt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];i=wt.getArcAngleSpanInRadian(a,s)}return wt.areNumbersClose(r,i,1e-5)?[a,s]:[s,a]}drawArc(e,t,n){var i,r,a;if(!e.radius||e.radius<.001)return void $.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void $.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new M(0,0,1);void 0!==e.extrusionDirectionX&&void 0!==e.extrusionDirectionY&&void 0!==e.extrusionDirectionZ&&s.set(e.extrusionDirectionX,e.extrusionDirectionY,e.extrusionDirectionZ);let o,l,h=dn.getOcsMatrix(s);if("CIRCLE"===e.type)o=e.startAngle||0,l=o+2*Math.PI;else{if(null==e.startAngle||null==e.endAngle||(o=e.startAngle,l=e.endAngle,wt.areNumbersEqual(o,l,1e-6)))return;if(!wt.areNumbersClose(wt.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=dn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new tp(0,0,e.radius,o,l,0!==this.angBase),u=1,d=n;null!=d&&d.xScale&&null!=d&&d.yScale&&(u=Math.max(Math.abs(d.xScale),Math.abs(d.yScale)));let p=this.getDivision(o,l,e.radius*u),f=c.getPoints(p),m=new M,g=!1;this.enableRTC&&(g=xt.checkAndRebasePositionsOnRTC(f,m));let v=(new et).setFromPoints(f),y=new sn(v,Xs),x=new M;e.center&&(x.x=e.center.x,x.y=e.center.y);let _=new M(null==(i=e.center)?void 0:i.x,null==(r=e.center)?void 0:r.y,null==(a=e.center)?void 0:a.z).applyMatrix4(h.invert());x.x=_.x,x.y=_.y,y.position.copy(x);let b=new or((new et).setFromPoints([new M]),PE);return b.userData.handle=e.handle,b.userData.isSnapObject=!0,b.userData.type="CircleCenter",b.layers.set(11),y.add(b),g?(this.setRTCUserData(y),y.position.x+=m.x,y.position.y+=m.y):xt.shouldRebasePositionOnRTC(y.position)&&this.setRTCUserData(y),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,n,i){let r=new M,a=new M;r.subVectors(n,t),a.subVectors(i,t),r.cross(a);let s=new M(t.x,t.y,t.z),o=new M(n.x,n.y,n.z),l=new M(i.x,i.y,i.z);r.z<0?e.push(l,o,s):e.push(s,o,l)}drawSolid(e,t,n){let i=e.points;if(!i||i.length<4)return;if(e.extrusionDirection&&e.extrusionDirection.z){Ci.set(0,0,e.extrusionDirection.z);let t=dn.getOcsMatrix(Ci).invert();i.forEach((e=>{let n=Ci.set(e.x,e.y,0).applyMatrix4(t);e.x=n.x,e.y=n.y}))}let r=[],a=[];this.addTriangleFacingCamera(r,i[0],i[1],i[2]),a.push(0,1,2),this.addTriangleFacingCamera(r,i[1],i[2],i[3]),a.push(3,4,5);let s=new M,o=!1;this.enableRTC&&(o=xt.checkAndRebasePositionsOnRTC(r,s));let l=(new et).setFromPoints(r);l.setIndex(a);let h=new Ge(l,jv);return o&&(this.setRTCUserData(h),h.position.x+=s.x,h.position.y+=s.y),h.layers.enableAll(),h}getTextStyle(e,t){var n;let i=null==(n=e.tables)?void 0:n.style.styles;return i&&(i[t.textStyle]||i.STANDARD||i.Standard)||{}}getDefaultDimensionStyle(e){return e.tables.dimStyle.dimStyles.STANDARD||e.tables.dimStyle.dimStyles.Standard||{}}getTextEncoding(e){return(null==e?void 0:e.bigFontFile)&&e.bigFontFile.toUpperCase().startsWith("GB")?"gbk":"utf8"}getTextMesh(e,t,n,i,r){if(!e)return;let a=this.getTextStyle(n,t),s=(null==a?void 0:a.styleName)||"";a&&a.fontFile&&a.fontFile.endsWith(".shx")&&($.warn(`[DxfLoader] Don't support font file ${a.fontFile}`),this.statsInfo.unsupportedTextStyles[s]||(this.statsInfo.unsupportedTextStyles[s]=0),this.statsInfo.unsupportedTextStyles[s]++);let o,l=(r?r.style.textHeight:t.textHeight)||0,h=.67,c={_TCH_DIM:1.45,ROMANS:1};s&&c[s]&&(h=c[s]),t.xScale&&(h*=t.xScale),s&&(h*=(null==a?void 0:a.xScale)||1,l=l||(null==a?void 0:a.textHeight)||12);let u=0;if(t.width&&(u=t.width/h+2),t.contextData&&t.contextData.textWidth&&t.contextData.textHeight<t.contextData.textWidth&&(u=t.contextData.textWidth),this.font instanceof to){let n=this.font.getGraphicData(e,l,l/1.5,l/2,l/8,u,3===t.drawingDirection);if(0===n.length)return;let i=Fo(n.map((e=>e.toThreeGeometry())));i.scale(h,1,1),o=new Dn(i,Xs)}else if(this.font instanceof Bp){let t={font:this.font,height:0,size:l||12,curveSegments:3,bevelSegments:3},n=new HR(e,t);o=new Ge(n,jv)}return o}transformTextMesh(e,t){let n=(new lt).setFromObject(t).getSize(Ci),{halign:i,valign:r}=e,a=e.width||n.x,s=n.y;if(void 0===i&&void 0===r&&e.startPoint||[3,5].includes(i)&&e.startPoint?(t.position.x+=e.startPoint.x,t.position.y+=e.startPoint.y,t.position.z+=e.startPoint.z):e.endPoint&&(t.position.x+=e.endPoint.x,t.position.y+=e.endPoint.y,t.position.z+=e.endPoint.z),3!==i&&5!==i){if(e.rotation){let n=e.rotation*Math.PI/180;t.rotateZ(n)}2===e.mirrored?t.rotateY(Math.PI):4===e.mirrored&&t.rotateX(Math.PI)}switch(i){case 0:default:break;case 1:t.translateX(-a/2);break;case 2:t.translateX(-a);break;case 3:if(e.startPoint&&e.endPoint){let n=new M(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new M(e.endPoint.x,e.endPoint.y,e.endPoint.z),r=(new M).subVectors(n,i),s=r.length()/a;t.scale.multiplyScalar(s);let o=r.clone().cross(Rd),l=r.angleTo(Rd);t.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&t.rotateX(Math.PI)}break;case 4:t.translateX(-a/2),t.translateY(-s/2);break;case 5:if(e.startPoint&&e.endPoint){let n=new M(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new M(e.endPoint.x,e.endPoint.y,e.endPoint.z),r=(new M).subVectors(n,i),s=r.length()/a;t.scale.setX(s);let o=r.clone().cross(Rd),l=r.angleTo(Rd);t.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&t.rotateX(Math.PI)}}switch(r){case 0:case 1:default:break;case 2:t.translateY(-s/2);break;case 3:t.translateY(-s)}return t.position.z=0,t}drawText(e,t,n){let i=e.text;if(!i)return;if(!this.font)return void $.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);i=zR(i,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(i,e,t,n);if(!a)return;let s=a.geometry;if(a instanceof Ge&&!s.getIndex()){let e=s.getAttribute("position"),t=[];for(let n=0;n<e.count;n+=3)t.push(n,n+1,n+2);s.setIndex(t)}if(s.hasAttribute("uv")&&s.deleteAttribute("uv"),s.hasAttribute("normal")&&s.deleteAttribute("normal"),this.transformTextMesh(e,a),xt.shouldRebasePositionOnRTC(a.position))this.setRTCUserData(a);else{let e=xt.caculateGeometryCenter(s);e&&xt.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(a)}return a.layers.enableAll(),a}drawAttDef(e,t,n){let i=e.tag||e.text||e.prompt;if(!i||!this.font)return;i=zR(i).map((e=>e.text)).join();let r=this.getTextMesh(i,e,t,n);if(!r)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),xt.shouldRebasePositionOnRTC(r.position))this.setRTCUserData(r);else{let e=xt.caculateGeometryCenter(a);e&&xt.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawAttrib(e,t,n){let i=e.text;if(!i||!this.font)return;i=zR(i).map((e=>e.text)).join();let r=this.getTextMesh(i,e,t,n);if(!r)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),xt.shouldRebasePositionOnRTC(r.position))this.setRTCUserData(r);else{let e=xt.caculateGeometryCenter(a);e&&xt.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawPoint(e,t,n){if(!e.position)return;let i=new et,r=[new M(e.position.x,e.position.y,e.position.z)];Ci.set(0,0,0);let a=Ci,s=!1;this.enableRTC&&(s=xt.checkAndRebasePositionsOnRTC(r,a)),i.setFromPoints(r);let o=new or(i,PE);return s&&(this.setRTCUserData(o),o.position.x+=a.x,o.position.y+=a.y),o.layers.enableAll(),o}drawDimension(e,t){if(!e.block)return;let n=t.blocks[e.block];if(!n||!n.entities)return;let i=t.tables.dimStyle.dimStyles[e.dimStyleName]||this.getDefaultDimensionStyle(t);i&&i.DIMCLRD>0&&(e.colorIndex=i.DIMCLRD,e.color=Op(e.colorIndex));let r=new Nt;for(let s=0;s<n.entities.length;s++){let i=this.drawEntity(n.entities[s],t,e);i&&r.add(i)}if(0===r.children.length){r=void 0;let t=e.name||e.block;return this.statsInfo.ignoredInserts[t]||(this.statsInfo.ignoredInserts[t]=0),void this.statsInfo.ignoredInserts[t]++}this.blockReferencesCache[e.block]||(this.blockReferencesCache[e.block]={referenceCount:0}),this.blockReferencesCache[e.block].referenceCount++,r.name=`${e.type}<${n.name}>`,r.userData.entityType=e.type;let a=null==e?void 0:e.insertionPoint;return a&&(r.position.x+=a.x,r.position.y+=a.y),xt.shouldRebasePositionOnRTC(r.position)&&this.setRTCUserData(r),r}drawImage(e,t,n){var i;if(!e.imageSize||null==(i=t.objects.IMAGEDEF)||!i.length)return;let r=t.objects.IMAGEDEF.filter((t=>t.handle===e.imageDefHandle))[0];if(!r)return;console.log(e,r);let a=e.imageSize.x,s=e.imageSize.y,o=new Nt,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new Ur(a,s);if(l){let e=new Pt({transparent:!0,side:Tr,map:new Ai(this.manager).load(r.filename,void 0,void 0,(()=>{console.warn("Please upload the pictures in the same folder, or use url link in the dxf file.")}))}),t=new Ge(h,e);o.add(t)}let c=new ja(h),u=this.getColor(e,t,n),d=new Dn(c,this.getLineBasicMaterial(u)),p=e.uPixel?new M(e.uPixel.x,e.uPixel.y,e.uPixel.z):new M(r.pixelSize.x,0,0),f=e.vPixel?new M(e.vPixel.x,e.vPixel.y,e.vPixel.z):new M(r.pixelSize.y,0,0);if(o.add(d),o.scale.set(p.x,f.y,1),e.position){let t=new M(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),o.position.copy(t)}return xt.shouldRebasePositionOnRTC(o.position)&&this.setRTCUserData(o),o}drawInsert(e,t,n=!1){var i,r;if(!e.block)return;let a=t.blocks[e.block];if(!a.entities)return;e.blockPosition=a.position;let s=new Nt;for(let u=0;u<a.entities.length;u++){if("ATTDEF"===a.entities[u].type)continue;let i=this.drawEntity(a.entities[u],t,e,n);i&&s.add(i)}if(0===s.children.length){s=void 0;let t=e.name||e.block;return this.statsInfo.ignoredInserts[t]||(this.statsInfo.ignoredInserts[t]=0),void this.statsInfo.ignoredInserts[t]++}this.blockReferencesCache[e.block]||(this.blockReferencesCache[e.block]={referenceCount:0}),this.blockReferencesCache[e.block].referenceCount++,s.name=`${e.type}<${a.name}>`,s.userData.entityType=e.type,null!=(i=e.extendedData)&&i.originalType&&(s.userData.originalType=null==(r=e.extendedData)?void 0:r.originalType),null!=e&&e.blockPosition&&(s.position.x-=e.blockPosition.x,s.position.y-=e.blockPosition.y,s.updateMatrix());let o=Ci.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new rn;e.rotation&&(l.z=e.rotation*Math.PI/180),Ohe.setFromEuler(l,!1);let h=IE.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),ro.compose(h,Ohe,o),e.extrusionDirection&&e.extrusionDirection.z<0&&ro.premultiply(Lhe.identity().makeScale(-1,1,1)),q5.copy(s.matrix),s.applyMatrix4(ro),xt.shouldRebasePositionOnRTC(s.position)&&this.setRTCUserData(s);let c=this.findSpatialFilterByHandle(e.handle,t);if(c){let t=this.drawSpatialFilter(c),n=c;n&&n.clipPolylines&&n.clipPolylines.length>0&&(s.userData.spatialFilterHandle=c.handle,this.cloneMaterialsForSpatialFilter(s),t&&t.applyMatrix4(q5.invert()),$.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let n=e.invertBlockMatrix;ro.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],0,0,0,1);let i=[];e.vertices.forEach((e=>{i.push(new M(e.x,e.y,0))}));let r={polyline:[],bConcave:!1,bReversed:!1};if(2===e.numberOfPointsOnClipBoundary)r.polyline=i;else{let t=e.numberOfPointsOnClipBoundary,n=3;if(t<n)return void $.warn(`[DxfLoader] Invalid clipBoundary: ${e.handle} !`);let a=[],s=-1;for(let e=0;e<t;e++){let n=i[e];for(let r=t-1;r>e;r--){let o=i[r];if(wt.areVector3sEqual(n,o)&&e+1<r-1&&e+1<t-1&&wt.areVector3sEqual(i[e+1],i[r-1])){a.push(n),s=r;break}}if(s>0)break;a.push(n)}if(s>0)for(let e=s+1;e<t;e++)a.push(i[e]);if(a.length<n)return void $.warn(`[DxfLoader] Invalid clipBoundary: ${e.handle}!`);let o=[],l=[];if(a.forEach((e=>{o.push(new Q(e.x,e.y)),l.push([e.x,e.y])})),!xt.isConvex(o)){$.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,khe.default)(l,1/0);a=[],t.forEach((e=>{a.push(new M(e[0],e[1],0))}))}wt.areVector3sEqual(a[0],a[a.length-1])||a.push(a[0]),r.polyline=a,r.bReversed=s>0}return this.enableReleaseData&&(e.vertices=[],e.matrix=[],e.invertBlockMatrix=[]),t.localMatrix=ro.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,n,i,r,a){if(!e.entities)return;let s;if(n.layoutName!==dn.MODEL_LAYOUT_NAME){let e=n;e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),s=e.directAssociatedLeafObjectSet}let o=new Nt;cn.setSharedVariablesOfObject(o);for(let c=0;c<e.entities.length;c++){let i=e.entities[c];this.addViewport(i,a);let l=this.drawEntity(i,t);l&&(this.enableMerge&&gr.merge(l,!1),o.add(l),l.traverse((e=>{if(e.geometry){let i=e.userData.layerName;!1===this.getLayerVisible(t,i)&&(e.visible=!1,e.userData.layerVisible=!1);let a=r[i];a||(a=[],r[i]=a),a.push(e),this.enableMerge||s&&s.add(e),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e))}})))}if(0===o.children.length)return;o.userData.layerName=e.layer;let l=n.layoutName,h=i.children.find((e=>e.name===l));h||(h=new Nt,cn.setSharedVariablesOfObject(h),h.name=l,h.userData.isLayoutLevelObject=!0,i.add(h)),h.add(o),e.position&&o.position.set(e.position.x,e.position.y,e.position.z||0),o.matrixAutoUpdate=!1,o.updateMatrix()}convertEdgeToPoints(e){let t=[];switch(e.type){case 1:{let n=e;t.push(new Q(n.startPoint.x,n.startPoint.y)),t.push(new Q(n.endPoint.x,n.endPoint.y));break}case 2:{let n=e,i=n.startAngle*Yt.DEG2RAD,r=n.endAngle*Yt.DEG2RAD;n.bCounterclockwise||(i=2*Math.PI-i,r=2*Math.PI-r);let a=new tp(n.center.x,n.center.y,n.radius,i,r,!n.bCounterclockwise),s=this.getDivision(i,r,n.radius);t.push(...a.getPoints(s));break}case 3:{let n=e,i=Math.sqrt(Math.pow(n.majorAxisEndPoint.x,2)+Math.pow(n.majorAxisEndPoint.y,2)),r=i*n.minorRatio,a=Math.atan2(n.majorAxisEndPoint.y,n.majorAxisEndPoint.x),s=n.startAngle*Yt.DEG2RAD,o=n.endAngle*Yt.DEG2RAD;n.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Gu(n.center.x,n.center.y,i,r,s,o,!n.bCounterclockwise,a),h=this.getDivision(s,o,Math.max(i,r));t.push(...l.getPoints(h));break}case 4:{let n=e;t.push(...n.controlPoints);break}case 0:{let n=e;t.push(...W5(n.points,n.isClosed));break}}return t}drawHatch(e,t,n){var i;let r=e;if(0==r.boundaryPaths.length)return;let a=[],s=[],o=[],l=e=>{let t=[],n=[];n.push(...this.convertEdgeToPoints(e[0]));for(let i=1;i<e.length;i++){let r=this.convertEdgeToPoints(e[i]);if(n.push(...r),n.length>2){let a=this.convertEdgeToPoints(e[i-1]);wt.areVector2sEqual(a[a.length-1],r[0])?wt.areVector2sEqual(n[0],r[r.length-1],1e-5)&&(t.push(n),n=[]):wt.areVector2sEqual(a[0],r[r.length-1])?wt.areVector2sEqual(n[1],r[0],1e-5)&&(t.push(n),n=[]):n=[]}}return t};if(r.boundaryPaths.forEach(((e,t)=>{let n=[];if(this.IsfilteredByPathTypeFlag(e.pathTypeFlag)){let n="[DxfLoader] The %d path type flag is filtered at the %dth boundrayPath (hatch handle '%s')";return void $.info(n,e.pathTypeFlag,t,r.handle)}let i=e.edges;if(0===i.length)return;let h=[];for(let a=0;a<i.length;a++){let e=this.convertEdgeToPoints(i[a]);if(e.length<2){let e="[DxfLoader] The %dth edge of the %dth boundaryPath (hatch handle '%s') has less than 2 points, ignored!";$.warn(e,a,t,r.handle)}else h.push(...e)}if(h.length<3){let e="[DxfLoader] The %dth boundaryPath (hatch handle '%s') has less than 3 points, ignored!";$.warn(e,t,r.handle)}else if(n.push(h),e.pathTypeFlag>31&&(!(e=>{for(let t=1;t<e.length;++t){let n=e[t-1].endPoint,i=e[t].startPoint;if(!n||!i||!wt.areVector2sEqual(n,i))return!1}return!0})(e.edges)||!r.associativity)&&(n=l(i),n.length<2)){let e="[DxfLoader] The %dth boundaryPath (hatch handle '%s') has unknown path, ignored!";$.warn(e,t,r.handle)}else n.forEach((e=>{wt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new Q(it.roundNumber(e.x,7),it.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){a.push(t);let e=(new si).setFromPoints(t);s.push(e);let n=e.getSize(DE),i=n.x*n.y;o.push({area:i,index:a.length-1})}}))})),0===a.length)return;let h=new Q,c=this.checkAndRebasePolygonsOnRTC(a,h);o.sort(((e,t)=>e.area-t.area));let u=[];o.forEach((e=>{u.push(e.index)}));let d,p=this.buildContainHierarchyTree(a,s,u),f=[];if(this.buildHatchGeometry(a,p,f),f.length>0&&(d=Fo(f)),!d||!d.getIndex()||0===(null==(i=d.getIndex())?void 0:i.count))return void $.warn("[DxfLoader] Failed to convert hatch boundaries!");let m=new Ge(d,jv);this.setHatchMaterial(m,r,t,h,n);let g=m;return c?(this.setRTCUserData(m),g.position.x+=h.x,g.position.y+=h.y):xt.shouldRebasePositionOnRTC(g.position)&&this.setRTCUserData(g),g.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),g}drawOle2frame(e,t){let{leftUpX:n,leftUpY:i,rightDownX:r,rightDownY:a}=e;if(!(n&&i&&r&&a))return;let s=[new Q(n,i),new Q(n,a),new Q(r,a),new Q(r,i),new Q(n,i)],o=new M,l=!1;this.enableRTC&&(l=xt.checkAndRebasePositionsOnRTC(s,o));let h=(new et).setFromPoints(s),c=this.getLineBasicMaterial(16777215),u=new sn(h,c);u.layers.enableAll(),l&&(this.setRTCUserData(u),u.position.x+=o.x,u.position.y+=o.y);let d=new Nt;d.add(u);let p,f,m=t.objects.DICTIONARY;for(let g of m){let t=g;for(let n in t.entries)if(t.entries[n]===e.handle){p=n;break}}if(p)if(this.meshTextureMaterials[p])f=this.meshTextureMaterials[p];else for(let g=0;g<t.objects.XRECORD.length;g++){let e=t.objects.XRECORD[g];if(e.handle===p){let t=e.binaryData,n="data:image/jpg;base64,"+it.hexToBase64(t),i=new Pt({transparent:!0,map:new Ai(this.manager).load(n)});this.meshTextureMaterials[p]=i,f=i;break}}if(f){let e=(new si).setFromPoints(s),t=e.getSize(DE),n=new Ur(t.x,t.y),i=new Ge(n,f),r=e.getCenter(DE);i.position.set(r.x,r.y,0),l&&(this.setRTCUserData(i),i.position.x+=o.x,i.position.y+=o.y),i.layers.enableAll(),d.add(i)}return d.children.length>1?d:u}static getOcsMatrix(e){let t=Rd,n=G5,i=YR,r=new M(0,1,0),a=new M(0,0,1);return wt.areVectorsClose(e,a)?ro.identity():(i=e.clone().normalize(),wt.areVectorsClose(i,a)||(t=Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.cross(i).normalize():a.cross(i).normalize(),n=i.clone().cross(t).normalize()),ro.set(t.x,t.y,t.z,0,n.x,n.y,n.z,0,i.x,i.y,i.z,0,0,0,0,1))}static getDcs2WcsMatrix(e,t){let n;n=Pst(e)?e.viewDirectionFromTarget:e.viewDirection;let i,r,a,s=new M(wt.roundNumber(n.x,7),wt.roundNumber(n.y,7),n.z),o=new M(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle;a=s.clone().normalize(),i=YR.clone().cross(s),i.length()>0?(i.normalize(),r=a.clone().cross(i)):a.z<0?(i=Rd.clone().negate(),r=G5,a=YR.clone().negate()):(i=Rd,r=G5,a=YR);let h=new Ae,c=ro.identity();return c.makeBasis(i,r,a),h.premultiply(c),h.premultiply(ro.identity().compose(o.clone(),(new En).setFromAxisAngle(new M(0,0,1),Yt.degToRad(t?l:-l)),new M(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new M(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),n=new M(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),i=e.viewHeight/e.height_paperSpace,r=dn.getDcs2WcsMatrix(e,this.angDir),a=new Ae;a.setPosition(Dhe.clone().sub(n));let s=Lhe.identity();s.scale(Ci.set(i,i,i));let o=q5.identity().setPosition(Dhe.clone().sub(n));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=ro.identity();l.setPosition(t),r.multiply(l);let h=ro.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,n){let i=e;if("1"==i.viewportId)return e.psBBox=new lt,void(e.msToPsMatrix=new Ae);let r=[],a=i.centerPoint,s=i.width_paperSpace/2,o=i.height_paperSpace/2;r.push(new M(a.x-s,a.y-o,0)),r.push(new M(a.x-s,a.y+o,0)),r.push(new M(a.x+s,a.y+o,0)),r.push(new M(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new lt(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(i);let l=new M,h=!1;this.enableRTC&&(h=xt.checkAndRebasePositionsOnRTC(r,l));let c=(new et).setFromPoints(r),u=new sn(c,Xs);h&&(this.setRTCUserData(u),u.position.x+=l.x,u.position.y+=l.y),u.userData.entityType=e.type,u.layers.enableAll();let d=new Nt;d.add(u);let p=e.psBBox.clone();p.applyMatrix4(e.msToPsMatrix.clone().invert()),p.min.z=0,p.max.z=0;let f=[];f.push(p.min),f.push(new M(p.min.x,p.max.y,0)),f.push(p.max),f.push(new M(p.max.x,p.min.y,0)),f.push(f[0]);let m=new M,g=!1;this.enableRTC&&(g=xt.checkAndRebasePositionsOnRTC(f,m));let v=(new et).setFromPoints(f),y=new sn(v,Xs);return g&&(this.setRTCUserData(y),y.position.x+=m.x,y.position.y+=m.y),y.userData.entityType=e.type,y.userData.inPaperSpace=!0,y.layers.enableAll(),d.add(y),u}getColor(e,t,n){var i,r,a,s,o,l;if(this.compareContext){let t=e.compareChangeType;return"Added"===t?Zr.ENTITY_COLOR_ADDED:"Removed"===t?Zr.ENTITY_COLOR_REMOVED:"Modified"===t?this.compareContext.isTheFirstFile?Zr.ENTITY_COLOR_REMOVED:Zr.ENTITY_COLOR_ADDED:Zr.ENTITY_COLOR_NO_CHANGE}let h=e;if(h&&h.isGradientColor){let t=h.gradientColors;if(t&&t.length>=2){if(t[0]!==t[1]){let t=`[DxfLoader] Gradient colors are not supported for hatch '${e.handle}', will use the first color!`;$.warn(t)}return t[0]}}if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return n?this.getColor(n,t):null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers[0].color;if(256===e.colorIndex){let i=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=i&&i[e.layer],h=i&&n&&i[n.layer],c=Ad;return c=r&&"0"!==r.name?r.color:h?h.color:r?r.color:null==(l=null==(o=t.tables)?void 0:o.layer)?void 0:l.layers[0].color,c}return $.warn("[DxfLoader] Unknown colorIndex"),Ad}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==wR&&e.lineType!==d5)return e.lineType;if(e.lineType===d5)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers,s=Cst;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(n){let e=a&&a[n.layer];if(e)return e.lineType}return s}getLayerName(e,t,n){var i,r;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers,s=a&&a[e.layer],o=a&&n&&a[n.layer],l=(null==s?void 0:s.name)||"";return s&&"0"===s.name&&o&&(l=o.name),l||"0"}setMaterial(e,t,n,i){var r,a;let s=e;if(!s.geometry||(this.setRenderOrderByObjectType(e),"OLE2FRAME"===t.type))return;if("MTEXT"===t.type)return void(e.renderOrder=5);if("HATCH"===t.type)return DE.set(0,0),void this.setHatchMaterial(e,t,n,DE,i);if("IMAGE"===t.type)return;let o,l=this.getColor(t,n,i);if("LWPOLYLINE"===t.type&&(s.isMesh?(o=this.getMeshBasicMaterial(l),e.renderOrder=1):e.userData.isOutline&&(o=this.getLineBasicMaterial(l),e.renderOrder=3),o))s.material=o;else{if("SOLID"===t.type)o=this.getMeshBasicMaterial(l);else if("TEXT"===t.type||"ATTDEF"===t.type||"ATTRIB"===t.type)o=this.getLineBasicMaterial(l),e.renderOrder=5;else if("LEADER"===t.type||"MULTILEADER"===t.type||"VIEWPORT"===t.type)o=this.getLineBasicMaterial(l);else if("POINT"===t.type)o=this.getPointsMaterial(l);else{if(e.material instanceof Br)return o=this.getPointsMaterial(l),void(s.material=o);let h=null==(a=null==(r=n.tables)?void 0:r.lineType)?void 0:a.lineTypes,c=h&&h[this.getLineType(t,n,i)];if(c&&c.pattern&&0!==c.pattern.length){let n=t.lineTypeScale||1;o=this.getLineShaderMaterial(c,l,n),e.renderOrder=3}else o=this.getLineBasicMaterial(l)}s.material=o}}setHatchMaterial(e,t,n,i,r){let a=e;if(!a.geometry)return;let s=this.getColor(t,n,r);if(a.isLine)return void(a.material=this.getLineBasicMaterial(s));let o,l=-1;if(t.solidFill)o=this.getMeshBasicMaterial(s);else{if(a.material instanceof It){o=a.material;let e=new Ie(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),dn.updateMaterialUniforms(o),o.uniforms.u_color.value.set(s))}else o=this.getHatchShaderMaterial(t,s,i);l=0}o||(o=this.getMeshBasicMaterial(s),l=-1),a.material=o,a.renderOrder=l}setRenderOrderByObjectType(e){let t=e,n=0;t.isMesh?n=-1:t.isLine?n=2:t.isPoints&&(n=4),e.renderOrder=n}getPointsMaterial(e){return this.pointsMaterials[e]||(this.pointsMaterials[e]=new Br({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new Jt({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t,n){let i=`${e.name}_${t}_${n}`;if(!this.lineShaderMaterials[i]){let r=this.getLineTypeScales(),a=r.ltScale*r.celtScale*n;this.lineShaderMaterials[i]=kR.createLineShaderMaterial(e.pattern,t,a,dn.viewportScaleUniform,dn.cameraZoomUniform)}return this.lineShaderMaterials[i]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new Pt({color:e})),this.meshBasicMaterials[e]}getHatchShaderMaterial(e,t,n){if(!e.patternLines||e.patternLines.length<1)return;let i=this.findMatchedHatchShaderMaterial(e,t);if(i)return i;let r=2;e.patternLines.forEach((e=>{r=Math.max(e.dashPattern.length,r)}));let a=0,s=[],o=new Q;for(let h of e.patternLines){let t=new Q(h.origin.x,h.origin.y).sub(n).rotateAround(o,-Yt.degToRad(e.patternAngle)),i=new Q(h.delta.x,h.delta.y).rotateAround(o,-Yt.degToRad(h.angle));if(0===i.y)return void $.warn("[DxfLoader] delta.y is equal to zero !");let l=h.dashPattern.length,c=!0,u=0;for(let e=0;e<l;++e){let t=h.dashPattern[e];t>0&&(c=!1),u+=Math.abs(t)}let d=c?.05:.005,p=[],f=[],m=0;f[0]=m;for(let e=0;e<l;++e)p[e]=h.dashPattern[e],0===p[e]&&(p[e]=d*u),m+=Math.abs(p[e]),f[e+1]=m;for(let e=l;e<r;++e)p[e]=0;for(let e=f.length;e<r+1;++e)f[e]=m;let g={origin:t,delta:i,angle:h.angle-e.patternAngle,pattern:p,patternSum:f,patternLength:m};if(a+=4,a+=r,a+=r+1,a>dn.maxFragmentUniforms){$.warn("[DxfLoader] There will be warning in fragment shader when number of uniforms exceeds 1024, so extra hatch line patterns are ignored here!");break}s.push(g)}let l=The(s,e.patternAngle,dn.cameraZoomUniform,new Ie(t));return l.defines={MAX_PATTERN_SEGMENT_COUNT:r},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:t,material:l}),l}getDivision(e,t,n){let i=Math.round(5e4/this.entityCount);i=Math.max(i,2),i=Math.min(i,10);let r=5*i,a=2*i;this.averageCurveSize&&(a*=Math.pow(n/this.averageCurveSize,.5),a=Math.max(a,i),a=Math.min(a,r));let s=t-e;s<0&&(s+=2*Math.PI),a=Math.ceil(a*(s/Math.PI));let o=8;return s<.087?o=2:s<.174?o=3:s<.52?o=4:s<1.57?o=5:s<3.14?o=6:s<4.71&&(o=7),a=Math.max(a,o),this.averageCurveSize=(this.averageCurveSize*this.curveCount+n)/(this.curveCount+1),this.curveCount++,Math.max(a,12)}getBSplineInterpolationsPerSplineSegment(e,t){let n=1;this.averageCurveSize&&(n=Math.pow(t/this.averageCurveSize,.5),n=Math.max(n,.5),n=Math.min(n,2)),this.averageCurveSize=(this.averageCurveSize*this.curveCount+t)/(this.curveCount+1),this.curveCount++;let i=2*e*n;return e>20&&(i/=Math.log10(e)),i}setDxfDataToIndexedDb(e,t){return $e(this,null,(function*(){let n={dxfDataId:e,dxf:t};return new Promise(((t,i)=>{Wv.instance().add(n,(()=>{$.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{i(e)}))}))}))}getDxfDataFromIndexedDb(e){return $e(this,null,(function*(){return new Promise(((t,n)=>{Wv.instance().query(e,(e=>{e&&e.length>0&&t(e[0].dxf),t(void 0)}),(()=>n()))}))}))}buildContainHierarchyTree(e,t,n){var i;let r=new Map,a=n.length;for(let o=0;o<a;o++)r.set(n[o],{index:n[o],children:[]});let s={index:-1,children:[]};for(let o=0;o<a;o++){let l=n[o],h=e[l],c=t[l],u=o+1;for(;u<a;u++){let a=n[u],s=e[a];if(t[a].containsBox(c)&&xt.isPointInPolygon(h[it.generateRandomInt(0,h.length-1)],s)){null==(i=r.get(a))||i.children.push(r.get(l));break}}u===a&&s.children.push(r.get(l))}return s}buildHatchGeometry(e,t,n){if(0===t.children.length)return;let i=[],r=new Map;t.children.forEach((e=>{0===e.children.length?i.push(e.index):r.set(e.index,e.children.map((e=>e.index)))}));let a=e=>{try{let t=new bc(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),n.push(t)}catch(t){$.warn(`[DxfLoader] triangulate shape error: ${e.getPoints().map((e=>e.toArray())).toString()}`)}};i.forEach((t=>{let n=e[t];if(0===n.length)return;let i=new Fs(n);a(i)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new Fs(e[o[0]]),n={regions:[],inverted:!1},i=this.findIntersectHole(e,o[1]);i.forEach((i=>{let r={regions:[],inverted:!1};try{i.forEach(((i,a)=>{if(qo.epsilon(wt.getVector2RelativeEps(e[i][0]),1e-6),0===a)r=qo.segments({regions:[s(e[i])],inverted:!1});else{let a=qo.segments({regions:[s(e[i])],inverted:!1}),o=qo.combine(r,a);n=qo.polygon(qo.selectUnion(o)),n.regions.length>0?n.regions.forEach((e=>{if(0===e.length)return;let n=e.map((e=>new Q(e[0],e[1])));t.holes.push(new Ec(n))})):$.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){$.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${qo.epsilon()}`)}}));let r=i.flat(2);for(let a=0;a<o[1].length;a++){let n=o[1][a];r.includes(n)||t.holes.push(new Ec(e[n]))}a(t)}t.children.forEach((t=>{t.children.forEach((t=>{this.buildHatchGeometry(e,t,n)}))}))}findIntersectHole(e,t){let n=t.length,i=[];for(let r=0;r<n;r++){let a=e[t[r]],s=!1,o=[];for(let i=r+1;i<n;i++){let n=e[t[i]];xt.arePolygonsIntersect(a,n)&&(s=!0,o.push(t[i]))}s&&(o.push(t[r]),i.push(o))}return i}checkAndRebasePolygonsOnRTC(e,t){if(!this.enableRTC||0===e.length)return!1;let n=0;e.forEach((e=>{e.forEach((e=>{t.add(e),n++}))})),t.divideScalar(n);let i=!1;if(this.enableRTC&&xt.shouldRebasePositionOnRTC(t)){i=!0;for(let n=0;n<e.length;n++){let i=e[n];for(let e=0;e<i.length;e++){let n=i[e].x-t.x,r=i[e].y-t.y;i[e]=new Q(n,r)}}}else t.set(0,0);return i}setRTCUserData(e){e.userData.relativeToCenter=!0,this.statsInfo.rebasedEntityCount++}IsfilteredByPathTypeFlag(e){return e<0}findSpatialFilterByHandle(e,t){let n=t.objects.DICTIONARY;if(!n)return;if(!this.dictionaryOwnerHandleAndSpatialFilterHandlesCache){this.dictionaryOwnerHandleAndSpatialFilterHandlesCache={};for(let e of n){let t=e,n="";for(let e in t.entries)if("ACAD_FILTER"===t.entries[e]){n=e;break}n&&(this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e.ownerHandle]&&$.warn("[DxfLoader] Why this.dictionaryObjectsCache[obj.ownerHandle] already exist?",e.ownerHandle),this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e.ownerHandle]=n)}}let i=this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e];if(i){if(!this.spatialFiltersCache){this.spatialFiltersCache={};let e=t.objects.SPATIAL_FILTER||[];for(let t of e){let e=t;e.numberOfPointsOnClipBoundary<2||(this.spatialFiltersCache[e.ownerHandle]&&$.warn("[DxfLoader] Why this.spatialFiltersCache[spatialFilterObj.ownerHandle] already exist?",i),this.spatialFiltersCache[e.ownerHandle]=e)}}return this.spatialFiltersCache[i]}}initRenderOrderInfo(e){let t=new Set,n=e.objects.DICTIONARY;for(let r of n){let e=r;Object.keys(e.entries).forEach((n=>{e.entries[n]&&"ACAD_SORTENTS"===e.entries[n]&&t.add(n)}))}if(0===t.size)return;let i=e.objects.SORTENTSTABLE;if(i)for(let r=0;r<i.length;++r){let e=i[r];if(t.has(e.handle)){for(let t=0;t<e.sortEntsObject.entityHandles.length;++t){let n=e.sortEntsObject.entityHandles[t];2!==n.length||this.entityHandlesWithRenderOrder[n[0]]?$.warn(`[DxfLoader] Failed to handle sortEntsTable: ${e.handle}.`):this.entityHandlesWithRenderOrder[n[0]]=n[1]}break}}}findMatchedHatchShaderMaterial(e,t){let n=e.patternLines;if(!n||n.length<1)return;let i=(e,t)=>Math.abs(e-t)<1e-5,r=(e,t)=>i(e.angle,t.angle)&&i(e.delta.x,t.delta.x)&&i(e.delta.y,t.delta.y)&&i(e.origin.x,t.origin.x)&&i(e.origin.y,t.origin.y)&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!i(e[n],t[n]))return!1;return!0})(e.dashPattern,t.dashPattern),a=this.hatchShaderMaterials.find((i=>i.color===t&&i.patternAngle===e.patternAngle&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!r(e[n],t[n]))return!1;return!0})(i.patternLines,n)));return null==a?void 0:a.material}getLayout(e,t){var n;if(!this.blockRecordsCache){this.blockRecordsCache={};let t=this.blockRecordsCache,i=null==(n=e.tables)?void 0:n.blockRecord.blockRecords;i&&Object.values(i).forEach((e=>{t[e.handle]=e.layoutHandle}))}let i=this.blockRecordsCache[t.ownerHandle];if(i){let t=e.objects.LAYOUT.find((e=>e.handle===i));if(t)return t}if(!this.entitiesCache){this.entitiesCache={};let t=this.entitiesCache;Object.values(e.entities).forEach((e=>{t[e.handle]=e}))}let r=this.entitiesCache[t.ownerHandle];return r?this.getLayout(e,r):($.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===dn.MODEL_LAYOUT_NAME)))}getLayerVisible(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t])?void 0:r.visible)}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}cloneMaterialsForSpatialFilter(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e.id))n.push(t.get(e.id));else{let i=e.clone();dn.updateMaterialUniforms(i),t.set(e.id,i),n.push(i)}}))):e&&(t.has(e.id)?n=t.get(e.id):(n=e.clone(),dn.updateMaterialUniforms(n),t.set(e.id,n))),n})(e.material))}))}getLineTypeScales(){let e={ltScale:1,celtScale:1};return this.header&&(e.ltScale=this.header.$LTSCALE||1,e.celtScale=this.header.$CELTSCALE||1),e}static getDxfUnits(e){switch(e||0){case 0:return"Unitless";case 1:return"Inches";case 2:return"Feet";case 4:return"Millimeters";case 5:return"Centimeters";case 6:return"Meters";default:$.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,n=e.geometry,i=e.matrixWorld;if(n.index&&($.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),n=xt.convertGeometryWithIndexedToNonIndexed(n),e.userData.batches&&e.userData.batches.length>0)){$.debug("[DxfLoader] This line has been merged!");let t=0;e.userData.batches.forEach((e=>{e.positionStart=t,e.positionCount=e.indexCount,e.indexStart=0,e.indexCount=0,t+=e.positionCount}))}if(null===n.index){let r=n.attributes.position;if(!r||0===r.count)return;let a=[];if(t)for(let e=0,t=r.count;e<t;e+=2)Ci.fromBufferAttribute(r,e).applyMatrix4(i),IE.fromBufferAttribute(r,e+1).applyMatrix4(i),a[e]=0===e?0:a[e-1],a[e+1]=a[e]+Ci.distanceTo(IE);else{a[0]=0;for(let e=1,t=r.count;e<t;e++)Ci.fromBufferAttribute(r,e-1).applyMatrix4(i),IE.fromBufferAttribute(r,e).applyMatrix4(i),a[e]=a[e-1],a[e]+=Ci.distanceTo(IE)}n.setAttribute("lineDistance",new tt(a,1)),e.geometry=n}else $.warn("[DxfLoader] computeLineDistances only possible with non-indexed BufferGeometry.")}static computeLineDistances(e){let t=Date.now();e.traverse((e=>{let t=e;t.isLine&&t.material instanceof It&&dn.computeLineDistance(t)})),$.debug(`[DxfLoader] Computed line distances in ${(Date.now()-t)/1e3}s`)}static merge(e,t){return $e(this,null,(function*(){let n=Date.now(),i=e=>$e(this,null,(function*(){if(t){t(new ProgressEvent("mergeProgress",{loaded:e,total:100}));let i=500,r=Date.now();r-n>i&&(yield it.sleep(0),n=r)}})),r={};e.objects.LAYOUT.forEach((e=>{var t;let n=e;r[n.layoutName]=n,null==(t=n.directAssociatedLeafObjectSet)||t.clear()}));let a=Date.now(),s={},o={},l=0,h=0,c=()=>{let e=Date.now();for(let t in s){let e=s[t];dn.removeEmptyObjectsFromRemovingMarkedObjects(e.children,e.object),e.children=[]}l=0,h+=Date.now()-e},u=Object.keys(e.layersAndThreejsObjects).length,d=0;for(let t in e.layersAndThreejsObjects){let n=e.layersAndThreejsObjects[t];if(n.length<=1){yield i(++d/u*100);continue}let a=Date.now(),p={},f=[];for(let e of n){if(e.userData.isSnapObject){f.push(e);continue}let t,n=e;for(;n;){if(n.userData.isLayoutLevelObject){t=n;break}n=n.parent}if(!t)continue;let i=t.name;p[i]||(p[i]={object:t,children:[]}),p[i].children.push(e)}let m=Object.keys(p).length,g=0;for(let e in p){let t;if(e!==dn.MODEL_LAYOUT_NAME){let n=r[e];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),t=n.directAssociatedLeafObjectSet}let n=p[e],a=gr.deepMerge(n.children,n.object,!1,!1,!0),v=a.added,y=a.removed;s[e]||(s[e]={object:n.object,children:[]}),o[e]||(o[e]={object:n.object,children:[]});let x=y.length>15e3;if(x){let e=Date.now();dn.removeEmptyObjectsFromRemovingMarkedObjects(y,n.object),h+=Date.now()-e}else l+=y.length;if(y.length===n.children.length)x||y.forEach((t=>{s[e].children.push(t)}));else{let i=y;y.length>=100&&(i=new Set(y));let r=e=>Array.isArray(i)?i.indexOf(e)>=0:i.has(e);for(let a=0;a<n.children.length;a++){let i=n.children[a];r(i)?x||s[e].children.push(i):(f.push(i),t&&t.add(i))}}for(let i=0;i<v.length;i++){let n=v[i];cn.setSharedVariablesOfObject(n),f.push(n),o[e].children.push(n),t&&t.add(n)}l>15e3&&c(),yield i((d+ ++g/m)/u*100)}yield i(++d/u*100),e.layersAndThreejsObjects[t]=f,$.debug(`[DxfLoader] Merged layer '${t}' in ${(Date.now()-a)/1e3}s`)}l>0&&c();for(let t in o){let n=o[t],i=e.threejsObject.children.find((e=>e.name===t));if(i){let e=i.children.find((e=>e.name===dn.SNAP_GROUP_NAME));if(e&&t!==dn.MODEL_LAYOUT_NAME){let n=r[t];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),e.children.forEach((e=>{var t;return null==(t=n.directAssociatedLeafObjectSet)?void 0:t.add(e)}))}}i||e.threejsObject.add(n.object),n.children.forEach((e=>{e.visible||(e.userData.layerVisible=!1),n.object.add(e),e.updateWorldMatrix(!1,!1)})),n.children=[]}$.debug(`[DxfLoader] MergeUtils.deepMerge costed ${gr.mergeInfo.elapsedTime/1e3}s`),$.debug(`[DxfLoader] The remove operation of deep merge costed ${h/1e3}s`),$.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-a)/1e3}s`);let p=gr.mergeInfo;$.debug(`[DxfLoader] Totally merged ${p.removedObjects} objects to ${p.mergedMeshes} meshes, ${p.mergedLines} lines, ${p.mergedPoints} points, ${p.mergedUnknownTypeObjects?p.mergedUnknownTypeObjects+" unknown type,":""} `),i(100)}))}static statLayoutAndLayerObjects(e){let t=new WeakSet,n=0;for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(n++,t.has(e)?console.warn(e):t.add(e))}));let i=new WeakSet,r=0;if(e.threejsObject.traverse((e=>{e.geometry&&(r++,i.has(e)?console.warn(e):i.add(e))})),n!=r)for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(i.has(e)||console.warn(e))}));$.info(`[DxfLoader] The count of layer objects is ${n},The count of layout objects is ${r} `)}static removeEmptyObjectsFromRemovingMarkedObjects(e,t){if(0===e.length)return;let n=e=>{let i=[];for(let n of e){n.userData.validCount=0;let e=n.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&i.push(e))}i.length>0&&n(i)};n(e),this.removeEmptyObjectsFromMark(t)}static removeEmptyObjectsFromMark(e){if(0===e.userData.validCount||cn.isEmptyObject(e))return e.removeFromParent(),!0;for(let t=0;t<e.children.length;)this.removeEmptyObjectsFromMark(e.children[t])||++t;return!1}},Dt=dn;Dt.MODEL_LAYOUT_NAME="Model",Dt.SNAP_GROUP_NAME="InvisibleObjectGroupForOSnap",Dt.SHOW_SNAP_OBJECT=!1,Dt.cameraZoomUniform={value:1},Dt.viewportScaleUniform={value:1},Dt.transformMatrixUniform={value:new Ae},Dt.resolutionUniform={value:new Q},Dt.maxFragmentUniforms=1024,Dt.abortJobs=!1;var Vhe=class extends Xi{constructor(e){var t;super(),this.drawableList=new Pl("compare"),this.viewer=e,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList)}drawCompareDrawable(e){let t=[],n=[],i=[];for(let o of Object.values(e)){let e=o.box;e&&("Added"===o.type?t.push(e):"Removed"===o.type?n.push(e):i.push(e))}let r=xt.mergeBBoxes(t),a=xt.mergeBBoxes(n),s=xt.mergeBBoxes(i);this.drawableList.addDrawable(new Dp(it.guid(),r)),this.drawableList.addDrawable(new Dp(it.guid(),a)),this.drawableList.addDrawable(new Dp(it.guid(),s)),this.viewer.enableRender()}setCompareDrawableVisible(e){this.drawableList.getDrawables().forEach((t=>t.visible=e)),this.viewer.enableRender()}};function xs(e){return(xs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Wo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j5(e,t){if("object"!==xs(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==xs(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function LE(e){var t=j5(e,"string");return"symbol"===xs(t)?t:String(t)}function zhe(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,LE(i.key),i)}}function jo(e,t,n){return t&&zhe(e.prototype,t),n&&zhe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nl(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function OE(e,t){return(OE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function Xv(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&OE(e,t)}function kp(e,t){if(t&&("object"===xs(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Nl(e)}function Xo(e){return(Xo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Hc(e,t,n){return(t=LE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X5(e){if(Array.isArray(e))return e}function Y5(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function $R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function $5(e,t){if(e){if("string"==typeof e)return $R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $R(e,t)}}function Z5(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function K5(e){return X5(e)||Y5(e)||$5(e)||Z5()}function Ghe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function qhe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ghe(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ghe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ust={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Bst=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Wo(this,e),this.init(t,n)}return jo(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Ust,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,i){return i&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,qhe(qhe({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}(),Vc=new Bst,Pd=function(){function e(){Wo(this,e),this.observers={}}return jo(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter((function(e){return e!==t}))}}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)})),this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function NE(){var e,t,n=new Promise((function(n,i){e=n,t=i}));return n.resolve=e,n.reject=t,n}function Whe(e){return null==e?"":""+e}function Fst(e,t,n){e.forEach((function(e){t[e]&&(n[e]=t[e])}))}function Q5(e,t,n){function i(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function r(){return!e||"string"==typeof e}for(var a="string"!=typeof t?[].concat(t):t.split(".");a.length>1;){if(r())return{};var s=i(a.shift());!e[s]&&n&&(e[s]=new n),e=Object.prototype.hasOwnProperty.call(e,s)?e[s]:{}}return r()?{}:{obj:e,k:i(a.shift())}}function jhe(e,t,n){var i=Q5(e,t,Object);i.obj[i.k]=n}function Hst(e,t,n,i){var r=Q5(e,t,Object),a=r.obj,s=r.k;a[s]=a[s]||[],i&&(a[s]=a[s].concat(n)),i||a[s].push(n)}function JR(e,t){var n=Q5(e,t),i=n.obj,r=n.k;if(i)return i[r]}function Xhe(e,t,n){var i=JR(e,n);return void 0!==i?i:JR(t,n)}function sde(e,t,n){for(var i in t)"__proto__"!==i&&"constructor"!==i&&(i in e?"string"==typeof e[i]||e[i]instanceof String||"string"==typeof t[i]||t[i]instanceof String?n&&(e[i]=t[i]):sde(e[i],t[i],n):e[i]=t[i]);return e}function Yv(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var kst={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function Vst(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return kst[e]})):e}var eA="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,zst=[" ",",","?","!",";"];function Gst(e,t,n){t=t||"",n=n||"";var i=zst.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===i.length)return!0;var r=new RegExp("(".concat(i.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),a=!r.test(e);if(!a){var s=e.indexOf(n);s>0&&!r.test(e.substring(0,s))&&(a=!0)}return a}function Yhe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ZR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yhe(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yhe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function qst(e){var t=Wst();return function(){var n,i=Xo(e);if(t){var r=Xo(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return kp(this,n)}}function Wst(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ade(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var i=t.split(n),r=e,a=0;a<i.length;++a){if(!r||"string"==typeof r[i[a]]&&a+1<i.length)return;if(void 0===r[i[a]]){for(var s=2,o=i.slice(a,a+s).join(n),l=r[o];void 0===l&&i.length>a+s;)s++,l=r[o=i.slice(a,a+s).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=i.slice(a+s).join(n);return h?ade(l,h,n):void 0}r=r[i[a]]}return r}}var jst=function(e){Xv(n,Pd);var t=qst(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Wo(this,n),i=t.call(this),eA&&Pd.call(Nl(i)),i.data=e||{},i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),void 0===i.options.ignoreJSONStructure&&(i.options.ignoreJSONStructure=!0),i}return jo(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure,s=[e,t];n&&"string"!=typeof n&&(s=s.concat(n)),n&&"string"==typeof n&&(s=s.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(s=e.split("."));var o=JR(this.data,s);return o||!a||"string"!=typeof n?o:ade(this.data&&this.data[e]&&this.data[e][t],n,r)}},{key:"addResource",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},a=this.options.keySeparator;void 0===a&&(a=".");var s=[e,t];n&&(s=s.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(i=t,t=(s=e.split("."))[1]),this.addNamespaces(t),jhe(this.data,s,i),r.silent||this.emit("added",e,t,n,i)}},{key:"addResources",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in n)("string"==typeof n[r]||"[object Array]"===Object.prototype.toString.apply(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});i.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(i=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var o=JR(this.data,s)||{};i?sde(o,n,r):o=ZR(ZR({},o),n),jhe(this.data,s,o),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?ZR(ZR({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(),ode={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,i,r){var a=this;return e.forEach((function(e){a.processors[e]&&(t=a.processors[e].process(t,n,i,r))})),t}};function $he(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Ys(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$he(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$he(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Xst(e){var t=Yst();return function(){var n,i=Xo(e);if(t){var r=Xo(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return kp(this,n)}}function Yst(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var Zhe={},Khe=function(e){Xv(n,Pd);var t=Xst(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Wo(this,n),i=t.call(this),eA&&Pd.call(Nl(i)),Fst(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,Nl(i)),i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=Vc.create("translator"),i}return jo(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,s=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||Gst(e,n,i));if(a&&!s){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:r};var l=e.split(n);(n!==i||n===i&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(i)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,i){var r=this;if("object"!==xs(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,h=o.namespaces,c=h[h.length-1],u=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&"cimode"===u.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(c).concat(p).concat(l),f):"".concat(c).concat(p).concat(l)}return a?(f.res=l,f):l}var f=this.resolve(e,t),m=f&&f.res,g=f&&f.usedKey||l,v=f&&f.exactUsedKey||l,y=Object.prototype.toString.apply(m),x=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject;if(_&&m&&"string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof x||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var b=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,Ys(Ys({},t),{},{ns:h})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return a?(f.res=b,f):b}if(s){var M="[object Array]"===y,w=M?[]:{},S=M?v:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var T="".concat(S).concat(s).concat(E);w[E]=this.translate(T,Ys(Ys({},t),{joinArrays:!1,ns:h})),w[E]===T&&(w[E]=m[E])}m=w}}else if(_&&"string"==typeof x&&"[object Array]"===y)(m=m.join(x))&&(m=this.extendTranslation(m,e,t,i));else{var A=!1,C=!1,R=void 0!==t.count&&"string"!=typeof t.count,P=n.hasDefaultValue(t),L=R?this.pluralResolver.getSuffix(u,t.count,t):"",D=t["defaultValue".concat(L)]||t.defaultValue;!this.isValidLookup(m)&&P&&(A=!0,m=D),this.isValidLookup(m)||(C=!0,m=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,O=P&&D!==m&&this.options.updateMissing;if(C||A||O){if(this.logger.log(O?"updateKey":"missingKey",u,c,l,O?D:m),s){var U=this.resolve(l,Ys(Ys({},t),{},{keySeparator:!1}));U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var N=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var k=0;k<F.length;k++)N.push(F[k]);else"all"===this.options.saveMissingTo?N=this.languageUtils.toResolveHierarchy(t.lng||this.language):N.push(t.lng||this.language);var B=function(e,n,i){var a=P&&i!==m?i:I;r.options.missingKeyHandler?r.options.missingKeyHandler(e,c,n,a,O,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,c,n,a,O,t),r.emit("missingKey",e,c,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&R?N.forEach((function(e){r.pluralResolver.getSuffixes(e,t).forEach((function(n){B([e],l+n,t["defaultValue".concat(n)]||D)}))})):B(N,l,D))}m=this.extendTranslation(m,e,t,f,i),C&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(c,":").concat(l)),(C||A)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(c,":").concat(l):l,A?m:void 0):this.options.parseMissingKeyHandler(m))}return a?(f.res=m,f):m}},{key:"extendTranslation",value:function(e,t,n,i,r){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Ys(Ys({},this.options.interpolation.defaultVariables),n),i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Ys(Ys({},n),{interpolation:Ys(Ys({},this.options.interpolation),n.interpolation)}));var s,o="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(o){var l=e.match(this.interpolator.nestingRegexp);s=l&&l.length}var h=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(h=Ys(Ys({},this.options.interpolation.defaultVariables),h)),e=this.interpolator.interpolate(e,h,n.lng||this.language,n),o){var c=e.match(this.interpolator.nestingRegexp);s<(c&&c.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];return r&&r[0]===i[0]&&!n.context?(a.logger.warn("It seems you are nesting recursively key: ".concat(i[0]," in key: ").concat(t[0])),null):a.translate.apply(a,i.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var u=n.postProcess||this.options.postProcess,d="string"==typeof u?[u]:u;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=ode.handle(d,e,t,this.options&&this.options.postProcessPassResolved?Ys({i18nResolved:i},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,i,r,a,s=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!s.isValidLookup(t)){var l=s.extractFromKey(e,o),h=l.key;n=h;var c=l.namespaces;s.options.fallbackNS&&(c=c.concat(s.options.fallbackNS));var u=void 0!==o.count&&"string"!=typeof o.count,d=u&&!o.ordinal&&0===o.count&&s.pluralResolver.shouldUseIntlApi(),p=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,f=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);c.forEach((function(e){s.isValidLookup(t)||(a=e,!Zhe["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(Zhe["".concat(f[0],"-").concat(e)]=!0,s.logger.warn('key "'.concat(n,'" for languages "').concat(f.join(", "),'" won\'t get resolved as namespace "').concat(a,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach((function(n){if(!s.isValidLookup(t)){r=n;var a,l=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(l,h,n,e,o);else{var c;u&&(c=s.pluralResolver.getSuffix(n,o.count,o));var f="".concat(s.options.pluralSeparator,"zero");if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(i=a,t=s.getResource(n,e,a,o))}})))}))}})),{res:t,usedKey:n,exactUsedKey:i,usedLng:r,usedNS:a}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,i):this.resourceStore.getResource(e,t,n,i)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,12)&&void 0!==e[n])return!0;return!1}}]),n}();function J5(e){return e.charAt(0).toUpperCase()+e.slice(1)}var $st=function(){function e(t){Wo(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Vc.create("languageUtils")}return jo(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=J5(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=J5(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=J5(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var i=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(i))&&(t=i)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var i=n.getLanguagePartFromCode(e);if(n.isSupportedCode(i))return t=i;t=n.options.supportedLngs.find((function(e){if(0===e.indexOf(i))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],a=function(e){e&&(n.isSupportedCode(e)?r.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),i.forEach((function(e){r.indexOf(e)<0&&a(n.formatLanguageCode(e))})),r}}]),e}(),Zst=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Kst={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},Jst=["v1","v2","v3"],Jhe={zero:0,one:1,two:2,few:3,many:4,other:5};function Qst(){var e={};return Zst.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:Kst[t.fc]}}))})),e}var eat=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Wo(this,e),this.languageUtils=t,this.options=n,this.logger=Vc.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("undefined"==typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=Qst()}return jo(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?i.resolvedOptions().pluralCategories.sort((function(e,t){return Jhe[e]-Jhe[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):i.numbers.map((function(i){return t.getSuffix(e,i,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(i.select(t)):this.getSuffixRetroCompatible(i,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,i=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[i];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var a=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}},{key:"shouldUseIntlApi",value:function(){return!Jst.includes(this.options.compatibilityJSON)}}]),e}();function Qhe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Ul(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qhe(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qhe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var tat=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Wo(this,e),this.logger=Vc.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return jo(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:Vst,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Yv(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Yv(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Yv(t.nestingPrefix):t.nestingPrefixEscaped||Yv("$t("),this.nestingSuffix=t.nestingSuffix?Yv(t.nestingSuffix):t.nestingSuffixEscaped||Yv(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,i){var r,a,s,o=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function h(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(e.indexOf(o.formatSeparator)<0){var r=Xhe(t,l,e);return o.alwaysFormat?o.format(r,void 0,n,Ul(Ul(Ul({},i),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(Xhe(t,l,s),h,n,Ul(Ul(Ul({},i),t),{},{interpolationkey:s}))};this.resetRegExp();var u=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return h(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?h(o.escape(e)):h(e)}}].forEach((function(t){for(s=0;r=t.regex.exec(e);){var n=r[1].trim();if(void 0===(a=c(n)))if("function"==typeof u){var l=u(e,r,i);a="string"==typeof l?l:""}else if(i&&i.hasOwnProperty(n))a="";else{if(d){a=r[0];continue}o.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),a=""}else"string"!=typeof a&&!o.useRawValueToEscape&&(a=Whe(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,i,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=Ul({},a);function o(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var i=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(i[1]);e=i[0];var a=(r=this.interpolate(r,s)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{s=JSON.parse(r),t&&(s=Ul(Ul({},t),s))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete s.defaultValue,e}for(s.applyPostProcessor=!1,delete s.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],h=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var c=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=c.shift(),l=c,h=!0}if((i=t(o.call(this,n[1].trim(),s),s))&&n[0]===e&&"string"!=typeof i)return i;"string"!=typeof i&&(i=Whe(i)),i||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),i=""),h&&(i=l.reduce((function(e,t){return r.format(e,t,a.lng,Ul(Ul({},a),{},{interpolationkey:n[1].trim()}))}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}]),e}();function ede(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Cd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ede(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ede(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function nat(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var i=e.split("(");t=i[0].toLowerCase().trim();var r=i[1].substring(0,i[1].length-1);"currency"===t&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):"relativetime"===t&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach((function(e){if(e){var t=K5(e.split(":")),i=t[0],r=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[i.trim()]||(n[i.trim()]=r),"false"===r&&(n[i.trim()]=!1),"true"===r&&(n[i.trim()]=!0),isNaN(r)||(n[i.trim()]=parseInt(r,10))}}))}return{formatName:t,formatOptions:n}}function $v(e){var t={};return function(n,i,r){var a=i+JSON.stringify(r),s=t[a];return s||(s=e(i,r),t[a]=s),s(n)}}var rat=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Wo(this,e),this.logger=Vc.create("formatter"),this.options=t,this.formats={number:$v((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:$v((function(e,t){var n=new Intl.NumberFormat(e,Cd(Cd({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:$v((function(e,t){var n=new Intl.DateTimeFormat(e,Cd({},t));return function(e){return n.format(e)}})),relativetime:$v((function(e,t){var n=new Intl.RelativeTimeFormat(e,Cd({},t));return function(e){return n.format(e,t.range||"day")}})),list:$v((function(e,t){var n=new Intl.ListFormat(e,Cd({},t));return function(e){return n.format(e)}}))},this.init(t)}return jo(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=$v(t)}},{key:"format",value:function(e,t,n,i){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=nat(t),s=a.formatName,o=a.formatOptions;if(r.formats[s]){var l=e;try{var h=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},c=h.locale||h.lng||i.locale||i.lng||n;l=r.formats[s](e,c,Cd(Cd(Cd({},o),i),h))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(s)),e}),e)}}]),e}();function tde(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function nde(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tde(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tde(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function iat(e){var t=sat();return function(){var n,i=Xo(e);if(t){var r=Xo(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return kp(this,n)}}function sat(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function aat(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}var oat=function(e){Xv(n,Pd);var t=iat(n);function n(e,i,r){var a,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Wo(this,n),a=t.call(this),eA&&Pd.call(Nl(a)),a.backend=e,a.store=i,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=Vc.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.maxRetries=s.maxRetries>=0?s.maxRetries:5,a.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return jo(n,[{key:"queueLoad",value:function(e,t,n,i){var r=this,a={},s={},o={},l={};return e.forEach((function(e){var i=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!n.reload&&r.store.hasResourceBundle(e,t)?r.state[o]=2:r.state[o]<0||(1===r.state[o]?void 0===s[o]&&(s[o]=!0):(r.state[o]=1,i=!1,void 0===s[o]&&(s[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===l[t]&&(l[t]=!0)))})),i||(o[e]=!0)})),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var i=e.split("|"),r=i[0],a=i[1];t&&this.emit("failedLoading",r,a,t),n&&this.store.addResourceBundle(r,a,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){Hst(n.loaded,[r],a),aat(n,e),t&&n.errors.push(t),0===n.pendingCount&&!n.done&&(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===s[e][t]&&(s[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[n](e,t,(function(o,l){if(i.readingCalls--,i.waitingReads.length>0){var h=i.waitingReads.shift();i.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}o&&l&&r<i.maxRetries?setTimeout((function(){i.read.call(i,e,t,n,r+1,2*a,s)}),a):s(o,l)}))):s(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var a=this.queueLoad(e,t,i,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=e.split("|"),r=i[0],a=i[1];this.read(r,a,"read",void 0,void 0,(function(i,s){i&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(r," failed"),i),!i&&s&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(r),s),t.loaded(e,i,s)}))}},{key:"saveMissing",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,i,null,nde(nde({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,i))}}]),n}();function lat(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===xs(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===xs(e[2])||"object"===xs(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function rde(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function ide(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function kc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ide(Object(n),!0).forEach((function(t){Hc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ide(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function cat(e){var t=uat();return function(){var n,i=Xo(e);if(t){var r=Xo(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return kp(this,n)}}function uat(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function KR(){}function hat(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}))}var QR=function(e){Xv(n,Pd);var t=cat(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(Wo(this,n),e=t.call(this),eA&&Pd.call(Nl(e)),e.options=rde(i),e.services={},e.logger=Vc,e.modules={external:[]},hat(Nl(e)),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),kp(e,Nl(e));setTimeout((function(){e.init(i,r)}),0)}return e}return jo(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var i=lat();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=kc(kc(kc({},i),this.options),rde(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=kc(kc({},i.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var a;this.modules.logger?Vc.init(r(this.modules.logger),this.options):Vc.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=rat);var s=new $st(this.options);this.store=new jst(this.options.resources,this.options);var o=this.services;o.logger=Vc,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new eat(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),a&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(o.formatter=r(a),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new tat(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new oat(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];e.emit.apply(e,[t].concat(i))})),this.modules.languageDetector&&(o.languageDetector=r(this.modules.languageDetector),o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=r(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new Khe(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];e.emit.apply(e,[t].concat(i))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=KR),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var h=NE(),c=function(){var t=function(t,i){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),h.resolve(i),n(t,i)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),h}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:KR,i="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return n();var r=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){r.indexOf(e)<0&&r.push(e)}))};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return a(e)})),this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(r,this.options.ns,(function(e){!e&&!t.resolvedLanguage&&t.language&&t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var i=NE();return e||(e=this.languages),t||(t=this.options.ns),n||(n=KR),this.services.backendConnector.reload(e,t,(function(e){i.resolve(),n(e)})),i}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&ode.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var i=NE();this.emit("languageChanging",e);var r=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},a=function(a){!e&&!a&&n.services.languageDetector&&(a=[]);var s="string"==typeof a?a:n.services.languageUtils.getBestMatchFromCodes(a);s&&(n.language||r(s),n.translator.language||n.translator.changeLanguage(s),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(s)),n.loadResources(s,(function(e){!function(e,a){a?(r(a),n.translator.changeLanguage(a),n.isLanguageChangingTo=void 0,n.emit("languageChanged",a),n.logger.log("languageChanged",a)):n.isLanguageChangingTo=void 0,i.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,s)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(e,t,n){var i=this,r=function e(t,r){var a;if("object"!==xs(r)){for(var s=arguments.length,o=new Array(s>2?s-2:0),l=2;l<s;l++)o[l-2]=arguments[l];a=i.options.overloadTranslationOptionHandler([t,r].concat(o))}else a=kc({},r);a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns,a.keyPrefix=a.keyPrefix||n||e.keyPrefix;var h=i.options.keySeparator||".",c=a.keyPrefix?"".concat(a.keyPrefix).concat(h).concat(t):t;return i.t(c,a)};return"string"==typeof e?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;var s=function(e,n){var i=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===i||2===i};if(n.precheck){var o=n.precheck(this,s);if(void 0!==o)return o}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(i,e)&&(!r||s(a,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,i=NE();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=NE();"string"==typeof e&&(e=[e]);var i=this.options.preload||[],r=e.filter((function(e){return i.indexOf(e)<0}));return r.length?(this.options.preload=i.concat(r),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:KR,r=kc(kc(kc({},this.options),t),{isClone:!0}),a=new n(r);return(void 0!==t.debug||void 0!==t.prefix)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=kc({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new Khe(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];a.emit.apply(a,[e].concat(n))})),a.init(r,i),a.translator.options=a.options,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}();Hc(QR,"createInstance",(function(){return new QR(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var $s=QR.createInstance();$s.createInstance=QR.createInstance;var uFt=$s.createInstance,hFt=$s.init,dFt=$s.loadResources,fFt=$s.reloadResources,pFt=$s.use,mFt=$s.changeLanguage,gFt=$s.getFixedT,zc=$s.t,vFt=$s.exists,xFt=$s.setDefaultNamespace,yFt=$s.hasLoadedNamespace,EFt=$s.loadNamespaces,bFt=$s.loadLanguages,UE=$s,Zv=class{constructor(e){this.progresseItems=[],this.element=document.createElement("div"),this.element.classList.add("progress-bar"),e.appendChild(this.element)}setVisibility(e){this.element&&(e?this.element.classList.remove("hidden"):this.element.classList.add("hidden"))}addProgressItem(e,t){let n=this.progresseItems.find((t=>t.id===e));if(!n){let i=document.createElement("div");i.classList.add("progress-bar-item"),i.innerHTML=t||"",this.element.append(i),n={id:e,div:i},this.progresseItems.push(n)}this.setVisibility(!0)}updateProgress(e,t,n){let i=this.progresseItems.find((t=>t.id===e));if(!i)return;let r=t?`${t}`:"";t&&n&&(r+=": "),n&&(r+=`${n.toFixed(2)}%`),i.div.innerHTML=r}removeProgressItem(e){let t=this.progresseItems.find((t=>t.id===e));t&&t.div.remove(),0===this.progresseItems.length&&this.setVisibility(!1)}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{this.removeProgressItem(e)}),t)}},mi=wi(Ll(),1);function Kv(e){return{all:e=e||new Map,on:function(t,n){var i=e.get(t);i?i.push(n):e.set(t,[n])},off:function(t,n){var i=e.get(t);i&&(n?i.splice(i.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var i=e.get(t);i&&i.slice().map((function(e){e(n)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,n)}))}}}var tA=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(tA||{}),BE=(e=>(e.HomeView="HomeView",e.OrthoMode="OrthoMode",e.Measure="Measure",e.MeasureDistance="MeasureDistance",e.MeasureArea="MeasureArea",e.MeasureAngle="MeasureAngle",e.MeasureCoordinate="MeasureCoordinate",e.MeasureClear="MeasureClear",e.MarkupVisibility="MarkupVisibility",e.Markup="Markup",e.MarkupArrow="Arrow",e.MarkupRect="Rect",e.MarkupCloudRect="CloudRect",e.MarkupPolyLine="PolyLine",e.MarkupCloudLine="CloudLine",e.MarkupEllipse="Ellipse",e.MarkupCircle="Circle",e.MarkupDot="Dot",e.MarkupText="Text",e.MarkupX="X",e.MarkupStrokeStyle="StrokeStyle",e.MarkupLineWidth="LineWidth",e.MarkupLineWidth2="LineWidth2",e.MarkupLineWidth5="LineWidth5",e.MarkupLineWidth10="LineWidth10",e.MarkupFontSize="FontSize",e.MarkupFontSize14="FontSize14",e.MarkupFontSize18="FontSize18",e.MarkupFontSize24="FontSize24",e.MarkupClear="MarkupClear",e.MarkupQuit="MarkupQuit",e.Section="Section",e.SectionBox="SectionBox",e.SectionPlane="SectionPlane",e.SectionAxis="SectionAxis",e.BimTree="BimTree",e.Viewpoint="Viewpoint",e.Annotation="Annotation",e.Property="Property",e.Settings="Settings",e.Compared="Compared",e.QuitCompare="QuitCompare",e.Fullscreen="FullScreen",e.SceneClear="SceneClear",e.Layers="Layers",e.ZoomToRectangle="ZoomToRectangle",e.Screenshot="GetScreenshot",e))(BE||{}),lde=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],Gc=class{constructor(e,t,n=[...lde]){this.bimViewer=e,this.menuConfig=t,this.groupConfig=n,this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,n;if(this.visible&&"Escape"===e.code){if(null!=(t=this.bimViewer.getMeasurementManager())&&t.isMeasurementMeasuring()||null!=(n=this.bimViewer.getMarkupManager())&&n.isMarkupActive())return;this.clearActive()}},this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar"),this.groupConfig.forEach(((e,n)=>{let i=document.createElement("div");i.classList.add("toolbar-group");let r=document.createElement("div");r.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,mi.get)(this.menuConfig,e);if(t&&!1!==t.visible){let n=this.createToolbarMenu(this.bimViewer,e,t);i.appendChild(n.element)}})),i.hasChildNodes()&&(n&&t.appendChild(r),t.appendChild(i))})),this.element=t,null==(e=this.bimViewer.widgetContainer)||e.appendChild(t),t.oncontextmenu=e=>{e.preventDefault()}}clearActive(){if(this.activateMenuId){let e=this.menuList.get(this.activateMenuId);null==e||e.setActive(!1),this.activateMenuId=void 0}}setActive(e,t){let n=this.menuList.get(e);null==n||n.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,n,i){let r=new eH(e,this,t,n,i);if(this.menuList.set(t,r),n.children){let t=document.createElement("div");t.classList.add("toolbar-sub-menu");let i=document.createElement("div");i.classList.add("toolbar-sub-menu-list"),t.appendChild(i),(0,mi.forIn)(n.children,((t,n)=>{if(t&&!1!==t.visible){let a=this.createToolbarMenu(e,n,t,r);i.appendChild(a.element)}})),r.element.appendChild(t)}return r}updateMenu(e,t){(0,mi.assign)(this.menuConfig[e],t),this.refresh()}updateMenus(e){(0,mi.forEach)(e,(({menuId:e,config:t})=>{(0,mi.assign)(this.menuConfig[e],t)})),this.refresh()}addMenu(e,t,n){if((0,mi.keys)(this.menuConfig).includes(e))$.error("[Toolbar]",e,"exists.");else{if((0,mi.assign)(this.menuConfig,{[e]:t}),n){let[t,i]=n;if(t>this.groupConfig.length-1)this.groupConfig=(0,mi.concat)(this.groupConfig,[[e]]);else{let n=this.groupConfig[t];this.groupConfig[t]=i>n.length-1?(0,mi.concat)(n,e):(0,mi.concat)((0,mi.take)(n,i),e,(0,mi.takeRight)(n,n.length-i))}}else this.groupConfig=(0,mi.concat)(this.groupConfig,[[e]]);this.refresh()}}refresh(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),this.init()}show(){this.element&&(this.element.style.display=""),this.visible=!0}hide(){this.element&&(this.element.style.display="none"),this.visible=!1}destroy(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),window.removeEventListener("keydown",this.keydown,!1)}},eH=class{constructor(e,t,n,i,r){this.bimViewer=e,this.toolbar=t,this.menuId=n,this.eventBus=Kv(),this.active=i.defaultActive||!1,this.element=i.customElement&&i.customElement(e,this.menuId,i)||this.createButton(e,this.menuId,i),this.eventBus.on("activeChange",(t=>{t?(this.element.classList.add("active"),(0,mi.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.toolbar)?void 0:t.menuList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(e)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(e)),this.element.firstChild instanceof HTMLElement&&WS(this.element.firstChild.classList,i.icon,this.active),r&&r.setActive(t)})),tn.isMobile?(this.element.ontouchstart=t=>{switch(this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.toggle("toolbar-menu-active"),t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}},this.element.addEventListener("touchend",(()=>{r&&r.element.classList.remove("toolbar-parent-menu-active")}))):(this.element.onclick=t=>{switch(t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}r&&r.element.classList.remove("toolbar-parent-menu-active")},this.element.addEventListener("mouseover",(()=>{this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.add("toolbar-menu-active")})),this.element.addEventListener("mouseout",(()=>{this.element.classList.contains("toolbar-parent-menu-active")&&this.element.classList.remove("toolbar-parent-menu-active"),this.element.classList.remove("toolbar-menu-active")})))}createButton(e,t,n){let i=document.createElement("div");i.id=t,i.classList.add("toolbar-menu"),n.defaultActive&&i.classList.add("active"),n.children&&i.classList.add("toolbar-parent-menu");let{default:r="icon-new",iconFont:a=Tv}=n.icon;return i.innerHTML=`<div class="icon ${a} ${r}"></div>`,i.title=zc(n.menuName),i.innerHTML+=`<span>${i.title}</span>`,i}setActive(e){this.active=e,e?this.element.classList.add("toolbar-menu-active"):this.element.classList.remove("toolbar-menu-active"),this.eventBus.emit("activeChange",this.active)}},cde={Arrow:{menuName:"Toolbar.markupArrow",icon:{default:"icon-arrow"},type:4,onActive:e=>{e.activateMarkup("ArrowMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},Rect:{defaultActive:!1,menuName:"Toolbar.markupRect",icon:{default:"icon-rectangle"},type:4,onActive:e=>{e.activateMarkup("RectMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Arrow","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudRect:{defaultActive:!0,menuName:"Toolbar.markupCloudRect",icon:{default:"icon-cloud"},type:4,onActive:e=>{e.activateMarkup("CloudRectWithTextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},PolyLine:{menuName:"Toolbar.markupPolyLine",icon:{default:"icon-polyline"},type:4,onActive:e=>{e.activateMarkup("PolylineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","CloudRect","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudLine:{menuName:"Toolbar.markupCloudLine",icon:{default:"icon-cloud-segment"},type:4,onActive:e=>{e.activateMarkup("CloudLineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","Arrow","Ellipse","Circle","Dot","Text","X"]},Ellipse:{menuName:"Toolbar.markupEllipse",icon:{default:"icon-oval"},type:4,onActive:e=>{e.activateMarkup("EllipseMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Arrow","Circle","Dot","Text","X"]},Circle:{menuName:"Toolbar.markupCircle",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("CircleMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Dot","Text","X"]},Dot:{menuName:"Toolbar.markupDot",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("DotMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Circle","Text","X"]},X:{menuName:"Toolbar.markupX",icon:{default:"icon-cross"},type:4,onActive:e=>{e.activateMarkup("XMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","Text"]},Text:{menuName:"Toolbar.markupText",icon:{default:"icon-text"},type:4,onActive:e=>{e.activateMarkup("TextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","X"]},StrokeStyle:{menuName:"Toolbar.markupStroke",icon:{default:"icon-color-red"},type:1,onClick:(e,t,n)=>{let i=n.target.parentElement,r=null==i?void 0:i.firstElementChild,a=document.createElement("input");a.setAttribute("type","color"),a.value=e.getMarkupLineColor(),a.click(),a.oninput=t=>{let n=t.target.value;e.setMarkupLineColor(n),r.style.color=n}}},LineWidth:{menuName:"Toolbar.markupLineWidth",icon:{default:"icon-line"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=zc(n.menuName),i.innerHTML+=`<span>${i.title}</span>`,i},type:3,children:{LineWidth2:{defaultActive:!0,icon:{default:"icon-line-2"},onClick:e=>{e.setMarkupLineWidth(2)},type:4,menuName:"Toolbar.markupLineWidth2",mutexIds:["LineWidth5","LineWidth10"]},LineWidth5:{icon:{default:"icon-line-3"},onClick:e=>{e.setMarkupLineWidth(3)},type:4,menuName:"Toolbar.markupLineWidth5",mutexIds:["LineWidth2","LineWidth10"]},LineWidth10:{icon:{default:"icon-line-4"},onClick:e=>{e.setMarkupLineWidth(4)},type:4,menuName:"Toolbar.markupLineWidth10",mutexIds:["LineWidth2","LineWidth5"]}}},FontSize:{menuName:"Toolbar.markupFontSize",icon:{default:"icon-font"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=zc(n.menuName),i.innerHTML+=`<span>${i.title}</span>`,i},type:3,children:{FontSize14:{icon:{default:"icon-font14"},onClick:e=>{e.setMarkupFontSize(14)},type:4,menuName:"",mutexIds:["FontSize18","FontSize24"]},FontSize18:{defaultActive:!0,icon:{default:"icon-font18"},onClick:e=>{e.setMarkupFontSize(18)},type:4,menuName:"",mutexIds:["FontSize14","FontSize24"]},FontSize24:{icon:{default:"icon-font24"},onClick:e=>{e.setMarkupFontSize(24)},type:4,menuName:"",mutexIds:["FontSize14","FontSize18"]}}},MarkupClear:{icon:{default:"icon-eraser"},onClick:e=>{$.info("[Toolbar]","Clear Markup",e),e.clearMarkups()},type:1,menuName:"Toolbar.clearMarkup"},MarkupQuit:{icon:{default:""},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=zc(n.menuName),i.innerHTML+=`<span>${i.title}</span>`,i},onClick:(e,t)=>{var n;e.deactivateMarkup(),t.destroy(),null==(n=e.toolbar)||n.show()},type:1,menuName:"Toolbar.quitMarkup"}},dat=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],nA=class extends Gc{constructor(e,t,n=[...dat]){super(e,t,n),this.keydown=()=>{}}},Jv=class{constructor(e,t,n=document.body){this.container=n,this.isFollowing=!1,this.diffX=0,this.diffY=0,this.start=e=>{this.isFollowing=!0,this.diffX=e.clientX-this.element.offsetLeft,this.diffY=e.clientY-this.element.offsetTop},this.stop=()=>{this.isFollowing=!1},this.follow=e=>{if(!this.isFollowing)return;let t=e.clientX-this.diffX,n=e.clientY-this.diffY;this.element.style.left=t+"px",this.element.style.top=n+"px"},this.element=document.createElement("div"),this.element.id=e,this.element.classList.add("pop-panel");let i=document.createElement("div");i.classList.add("pop-panel-header"),i.append(t),this.element.appendChild(i),this.header=i;let r=document.createElement("div");r.classList.add("pop-panel-body"),this.element.appendChild(r),this.body=r,i.addEventListener(IF,this.start),i.addEventListener(PF,this.stop),document.body.addEventListener(yd,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(yd,this.follow),this.element.removeEventListener(IF,this.start),this.element.removeEventListener(PF,this.stop),this.element.remove()}},Zs=new M(1,0,0),Id=new M(0,1,0),Dd=new M(0,0,1),ude=new M(0,1,0),FE=new Ae,tH=2,Bl=class extends Nt{constructor(e=Zs){super(),this.redMaterial=new Pt({color:16711680,depthTest:!1}),this.greenMaterial=new Pt({color:65280,depthTest:!1}),this.blueMaterial=new Pt({color:255,depthTest:!1}),this.highlightMaterial=new Pt({color:16776960,depthTest:!1}),this.pickableMaterial=new Pt({color:9807270,depthTest:!1}),this.initIgnoreClipMaterial(),this.initOrUpdateByAxis(e)}initIgnoreClipMaterial(){[this.redMaterial,this.greenMaterial,this.blueMaterial,this.highlightMaterial,this.pickableMaterial].forEach((e=>{e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include <clipping_planes_pars_fragment>","").replace("#include <clipping_planes_fragment>",""),e.vertexShader=e.vertexShader.replace("#include <clipping_planes_pars_vertex>","").replace("#include <clipping_planes_vertex>","")}}))}setDirection(e){let t=new En;t.setFromUnitVectors(Zs,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:Zs,material:this.redMaterial},{actionType:"TranslateY",direction:Id,material:this.greenMaterial},{actionType:"TranslateZ",direction:Dd,material:this.blueMaterial}].forEach((t=>{let{actionType:n,direction:i,material:r}=t,a=this.createTranslateGizmo(n,i,tH,0===i.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:Zs,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:Id,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:Dd,material:this.blueMaterial,degree:90}].forEach((t=>{let{actionType:n,direction:i,material:r,degree:a}=t;if(0!==i.angleTo(e)){let e=this.createRotateGizmo(n,i,tH,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial)}createTranslateGizmo(e,t,n,i){let r=t.angleTo(ude),a=ude.clone().cross(t);FE.makeRotationAxis(a,r);let s=new Po(n/5,n/5,20*n),o=10*n;s.translate(0,o,0),s.applyMatrix4(FE);let l=new Po(0,n,3*n),h=2*o;l.translate(0,h,0),l.applyMatrix4(FE);let c=Fo([l,s]),u=new Ge(c,i);return u.layers.enable(12),u.userData.actionType=e,i===this.pickableMaterial&&u.layers.disable(12),u}createRotateGizmo(e,t,n,i,r){let a=new M(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);FE.makeRotationAxis(s,o);let l=new Wu(12*n,n/5,8,36,Yt.degToRad(r));l.applyMatrix4(FE);let h=new Ge(l,i);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t){let n=new da(e,32,16),i=new Ge(n,t);this.add(i)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=Zs;switch(e){case"RotateX":t=Zs;break;case"RotateY":t=Id;break;case"RotateZ":t=Dd}return this.createRotateGizmo("",t,tH,this.highlightMaterial,360)}setActive(e,t){var n;let i=t.userData.actionType;["RotateX","RotateY","RotateZ"].includes(i)?e?(this.hoverObject=this.createHoverRotateObjectByAxis(i),this.add(this.hoverObject),t.visible=!1):(null==(n=this.hoverObject)||n.removeFromParent(),t.visible=!0,this.hoverObject=void 0):e?(this.originalMaterial=t.material,t.material=this.highlightMaterial):this.originalMaterial&&(t.material=this.originalMaterial)}adjustSize(e){let t=new M;this.getWorldPosition(t);let n=e.position,i=1;e instanceof dr?i=(e.top-e.bottom)/e.zoom:e instanceof bn&&(i=t.distanceTo(n)*Math.min(1.9*Math.tan(Math.PI*e.fov/360)/e.zoom,7)),this.scale.set(1,1,1).multiplyScalar(i/180)}},Ld=class{constructor(e,t){if(this.raycaster=new Gs,this.mouseDown=!1,this.lastWorldPos=new M,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new er,this.active=!1,this.isShowSectionPlane=!1,this.mousedown=e=>{0===e.button&&this.camera&&this.selectedObject&&(this.inputManager.setCursor("grabbing"),this.mouseDown=!0)},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.inputManager.setCursor("grabbing"),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(this.dragStarted||(this.dragStarted=!0,this.onDragStart(e)))):(this.inputManager.setCursor("default"),this.selectedObject=void 0)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.activateSelectedObject(!1),this.mouseDown&&this.dragStarted&&(this.inputManager.setCursor("grab"),this.onDragEnd(e),this.dragStarted=!1),this.mouseDown=!1,this.selectedObject=void 0)},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer;let n=e.getBBox();if(!n)throw new Error("Need to set sectionBox first!");this.sectionBox=n.clone(),this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnable(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnable(e){var t,n;if(!this.clipPlanes||null==(t=this.clippingObjetIds)||!t.length)return;this.renderer.localClippingEnabled=e;let i=e?this.clipPlanes:[];null==(n=this.clippingObjetIds)||n.forEach((e=>{let t=this.scene.getObjectById(e);t&&t.traverse((e=>{e.material&&(Array.isArray(e.material)?e.material.forEach((e=>{e.clippingPlanes=i,e.clipIntersection=!1})):e.material&&(e.material.clippingPlanes=i,e.material.clipIntersection=!1))}))}))}clearClippingObjectIds(){this.setObjectClippingEnable(!1),this.clippingObjetIds=[]}setClippingEnable(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnable(!1),this.setObjectClippingEnable(e)):this.setGlobalClippingEnable(e)}activate(){this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup),this.inputManager.addEventListener("keydown",this.keydown),this.active=!0}deactivate(){var e;this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.selectedObject)||e.removeFromParent(),this.selectedObject=void 0,this.dragStarted=!1,this.active=!1}getIntersections(e){if(!this.raycaster)return;this.updateRaycasterByMouse(e);let t=this.raycaster.intersectObjects(this.getIntersectObjects())||[];return t.find((e=>e.object&&e.object.parent instanceof Bl))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new Q(e.x,e.y),n=nn.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera)}destroy(){this.deactivate()}},dde=new lt,fde=new En,rA=class extends Ge{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new et,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new Pt({depthTest:!1,color:rA.normalPlaneColor,transparent:!0,opacity:.01,side:tr}),this.createIgnoreClipMateriasl(this.material),this.geometry.computeVertexNormals(),this.edge=this.createEdge(t),this.add(this.edge)}createIgnoreClipMateriasl(e){e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include <clipping_planes_pars_fragment>","").replace("#include <clipping_planes_fragment>",""),e.vertexShader=e.vertexShader.replace("#include <clipping_planes_pars_vertex>","").replace("#include <clipping_planes_vertex>","")}}createEdge(e){let t=new et;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let n=new Jt({color:rA.normalLineColor});return this.createIgnoreClipMateriasl(n),new sn(t,n)}update(e){this.geometry.setFromPoints(e),this.geometry.computeBoundingSphere(),this.geometry.computeVertexNormals(),this.edge.geometry.setFromPoints(e),this.vertices=e}rotatePlane(e,t){let n=this.getPlaneCenter();fde.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(fde).add(n))),this.update(this.vertices)}setDirection(e){let t=new En;t.setFromUnitVectors(Zs,e);let n=this.getPlaneCenter();this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(t).add(n))),this.update(this.vertices)}getPlaneNormal(){let[e,t,n]=this.vertices,i=new M;return Rr.getNormal(e,t,n,i),i}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){dde.setFromPoints(this.vertices);let e=new M;return dde.getCenter(e),e}},Pr=rA;Pr.normalPlaneColor=new Ie(0,.855,.718),Pr.activePlaneColor=new Ie(1,1,0),Pr.normalLineColor=16777215;var pde=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(pde||{}),iA=class extends Ld{constructor(e,t){super(e,t),this.activeAxis="X",this.center=new M,this.sectionBox.getCenter(this.center),this.axisInfoMap={X:{normal:new M(1,0,0)},Y:{normal:new M(0,1,0)},Z:{normal:new M(0,0,1)}},this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.setActiveAxis("X")}deactivate(){var e,t;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0}resetSection(){var e,t;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){switch(this.activeAxis){case"X":this.clipPlane=new er(new M(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new er(new M(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new er(new M(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;let t=new M;this.sectionBox.getSize(t);let n=t.length(),i=this.center,r=(new lt).setFromCenterAndSize(i,new M(n,n,n)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new Pr("X",[new M(i.x,s.y,a.z),new M(i.x,s.y,s.z),new M(i.x,a.y,s.z),new M(i.x,a.y,a.z)]);break;case"Y":this.planeMesh=new Pr("Y",[new M(s.x,i.y,a.z),new M(a.x,i.y,a.z),new M(a.x,i.y,s.z),new M(s.x,i.y,s.z)]);break;case"Z":this.planeMesh=new Pr("Z",[new M(s.x,s.y,i.z),new M(a.x,s.y,i.z),new M(a.x,a.y,i.z),new M(s.x,a.y,i.z)])}this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;null==(e=this.gizmo)||e.removeFromParent();let n=this.axisInfoMap[this.activeAxis].normal;this.gizmo=new Bl,this.gizmo.setDirection(n),this.sectionBox.getCenter(this.gizmo.position),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(this.selectedObject instanceof Pr)return;this.controls&&this.dragStarted&&this.selectedObject&&!(this.selectedObject instanceof Pr)&&(this.controls.enableRotate=!1),$.info("[AxisPlaneSection] onDragStart:",e);let n=new M;this.sectionBox.getCenter(n),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||this.selectedObject&&this.selectedObject instanceof Pr)return;let r=new M;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new M).subVectors(this.lastWorldPos,this.center).normalize(),o=(new M).subVectors(r,this.center).normalize(),l=(new M).subVectors(r,this.lastWorldPos).projectOnVector(Zs.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new M).crossVectors(s,o),u=new M;this.sectionBox.getSize(u);let d,p=Math.max(u.x,u.y,u.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":d=(new M).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new M(p,p,p)).containsPoint(d)&&(null==(n=this.gizmo)||n.position.add(l),null==(i=this.planeMesh)||i.position.add(l));break;case"RotateX":{let e=Zs.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateX(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateY":{let e=Id.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateY(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateZ":{let e=Dd.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateZ(h),this.planeMesh.rotatePlane(e,h)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Pr||(this.controls&&!this.controls.enableRotate&&(this.controls.enableRotate=!0),$.info("[AxisPlaneSection] onDragEnd:",e))}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Pr?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Bl&&this.selectedObject.parent.setActive(e,this.selectedObject))}},sA=class extends Jv{constructor(e){super("axis-section-pop-panel","\u8f74\u5411\u5256\u5207",e.widgetContainer),this.axis="x",this.isVisible=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createGroupSelectLayout(),this.addGroupSelectItems(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createGroupSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-group-select"),this.body.appendChild(e),this.groupSelectNode=e}addGroupSelectItems(){let e=(e,t,n=!1)=>{let i=document.createElement("div");return i.classList.add("pop-panel-item"),i.setAttribute("itemName",e),i.append(t),n&&i.classList.add("active"),this.groupSelectNode&&this.groupSelectNode.appendChild(i),i},t=(e,t)=>a=>{a.stopPropagation(),this.activeItem!==e&&(n.classList.remove("active"),i.classList.remove("active"),r.classList.remove("active"),this.activeItem=e,t.classList.add("active"),this.section.setActiveAxis(e))},n=e("X","X",!0);n.onclick=t("X",n);let i=e("Y","Y");i.onclick=t("Y",i);let r=e("Z","Z");r.onclick=t("Z",r)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add(Tv),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=((t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r})("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");t.onclick=()=>{this.isVisible=!this.isVisible,this.isVisible?(e(t,"icon-hidesectionplane"),t.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(t,"icon-showsectionplane"),t.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible)}}},aA=class extends Jv{constructor(e){super("pick-section-pop-panel","\u62fe\u53d6\u9762\u5256\u5207",e.widgetContainer),this.isVisible=!0,this.enabled=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add("gemini-viewer-icon"),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=(t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r},n=t("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");n.onclick=()=>{this.enabled&&(this.isVisible=!this.isVisible,this.isVisible?(e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(n,"icon-showsectionplane"),n.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible))},this.activeSelectNode&&this.activeSelectNode.appendChild(n),this.visibleNode=n;let i=t("reset","\u91cd\u7f6e","icon-reset");i.onclick=t=>{t.stopPropagation(),this.enabled&&(this.isVisible=!0,e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762"),this.section.resetSection())},this.activeSelectNode&&this.activeSelectNode.appendChild(i),this.resetNode=i}enable(){this.enabled=!0,this.visibleNode&&this.visibleNode.classList.remove("disable")}disable(){this.enabled=!1,this.visibleNode&&this.visibleNode.classList.add("disable")}},nH=wi(Ll(),1),Yo=class{constructor(e,t,n){this.follow=e=>{let{x:t,y:n}=nn.getScreenPointByEvent(e,this.parentNode);this.node.style.left=t+15+"px",this.node.style.top=n-30+"px"},this.show=()=>this.node.hasAttribute("hidden")&&this.node.removeAttribute("hidden"),this.hide=()=>!this.node.hasAttribute("hidden")&&this.node.setAttribute("hidden",""),this.destroy=()=>{this.target?this.target.removeEventListener(yd,this.follow):document.removeEventListener(yd,this.follow),this.parentNode.removeChild(this.node)},this.node=document.createElement("div"),this.node.id=e,t&&this.node.append(t),this.childNode=document.createElement("div"),this.target=null==n?void 0:n.target,this.parentNode=(null==n?void 0:n.parentNode)||document.body,null!=n&&n.followPointer&&(this.node.classList.add("follow-tooltip"),this.target?this.target.addEventListener(yd,this.follow):document.addEventListener(yd,this.follow)),this.parentNode.appendChild(this.node),(null==n||!n.showOnCreate)&&this.node.setAttribute("hidden","")}setContent(e){this.node.textContent&&(this.node.textContent=null),(0,nH.forEach)(this.node.children,(e=>{this.node.removeChild(e)})),this.node.append(e),this.node.appendChild(this.childNode)}updateChildContent(e){this.childNode.textContent&&(this.childNode.textContent=null),(0,nH.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},$o=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))($o||{}),qc=class extends Xi{constructor(e,t,n,i,r){super(),this.mouseMoved=!1,this.mouseDowned=!1,this.touchDowned=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEdgeMaterial=new Jt({color:16711680}),this.snapPoint=void 0,this.touchstart=e=>{this.mobileTouchHelper&&this.mobileTouchHelper.isIntersect(e)&&!this.touchDowned&&(this.viewer.controls&&(this.viewer.controls.enabled=!1),this.touchDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y)},this.touchmove=e=>{if(e.pointers&&e.pointers.length>1)return;let{width:t,height:n}=this.canvas.getBoundingClientRect();if(!(e.x>t-15||e.x<35||e.y<15||e.y>n-35)&&this.touchDowned&&this.mobileTouchHelper){let t=e.x-this.mouseDownPositionX,n=e.y-this.mouseDownPositionY;this.mobileTouchHelper.translate(t,n),this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y;let i=this.mobileTouchHelper.getTouchPoint(),r=this.getIntersections(i);if(!r.length)return;let a=Date.now();if(this.handleSnap(r),$.debug(`[BaseMeasurement] this.handleSnap costs ${(Date.now()-a)/1e3}s`),!this.snapPoint)return void console.warn("[BaseMeasurement] Failed to find a snap point!");this.onMouseMove(this.snapPoint)}},this.touchend=e=>{var t;if(this.viewer.controls&&(this.viewer.controls.enabled=!0),!(e.pointers&&e.pointers.length>1))if(this.touchDowned){this.touchDowned=!1;let e=null==(t=this.mobileTouchHelper)?void 0:t.getTouchPoint();this.onMouseClick(e)}else this.selectMeasurementByEvent(e)},this.mousedown=e=>{this.mouseMoved=!1,this.mouseDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.mousemove=e=>{if(this.lastMoveEvent=e,this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(e.x-this.mouseDownPositionX)>5||Math.abs(e.y-this.mouseDownPositionY)>5)&&(this.mouseMoved=!0),this.mouseDowned)return;let t=this.getIntersections(e);if(!t.length)return;let n=Date.now();this.handleSnap(t),$.debug(`[BaseMeasurement] this.handleSnap costs ${(Date.now()-n)/1e3}s`),this.snapPoint?this.onMouseMove(this.snapPoint):console.warn("[BaseMeasurement] Failed to find a snap point!")},this.mouseup=e=>{this.mouseDowned=!1,this.mouseMoved||this.onMouseClick(e)},this.dblclick=()=>{$.info("[Measure] Double clicked")},this.keydown=e=>{if("Enter"===e.code){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,button:2,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};this.onMouseClick(e)}else"Escape"===e.code&&this.cancel()},this.getIntersections=e=>{if(!this.raycaster)return[];this.raycaster.layers.set(11);let t=this.viewer.getRaycastableObjectsByMouse(e);$.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let n=Date.now(),i=this.raycaster.intersectObjects(t,!0)||[];return $.debug(`[BaseMeasurement] this.raycaster.intersectObjects costs ${(Date.now()-n)/1e3}s`),this.renderer.clippingPlanes.length>0&&(i=i.filter((e=>this.renderer.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))))),i},this.type=e,this.viewer=t,this.inputManager=n,this.drawList=i,this.osnapHelper=r}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get renderer(){return this.viewer.renderer}get isActive(){return!!this.raycaster}get isMeasuring(){return!1===this.completed}setTouchHelper(e){this.mobileTouchHelper=e}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.exitDrawing(),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("FirstPointPicked",this.firstPickedListener=()=>{this.exitButton&&(this.exitButton.style.display="inline-block")}),this.addEventListener("Completed",this.completedListener=()=>{this.exitButton&&(this.exitButton.style.display="none")}),this.exitButton}activate(){if(tn.isMobile)this.inputManager.addEventListener("touchstart",this.touchstart),this.inputManager.addEventListener("touchmove",this.touchmove),this.inputManager.addEventListener("touchend",this.touchend);else{this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup);let e=this.viewer.translate;if(e){this.tooltip=new Yo("measure-tooltip",e("Tooltip.measure"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.canvas});let t=document.getElementById("measure-tooltip");t&&(t.style.pointerEvents="none")}this.setTooltipContent()}this.inputManager.addEventListener("dblclick",this.dblclick),this.inputManager.addEventListener("keydown",this.keydown),this.raycaster=this.viewer.getRaycaster()}deactivate(){var e,t;tn.isMobile?(this.inputManager.removeEventListener("touchstart",this.touchstart),this.inputManager.removeEventListener("touchmove",this.touchmove),this.inputManager.removeEventListener("touchend",this.touchend)):(this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup)),this.inputManager.removeEventListener("dblclick",this.dblclick),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.raycaster=void 0,this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}removeDrawable(e){this.dispatchEvent("WillBeRemoved",e)}clearClickedDrawable(){this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0)}onMouseClick(e){if(tn.isMobile)return;let t=Date.now();this.lastClickTime&&t-this.lastClickTime<500||(this.lastClickTime=t,this.selectMeasurementByEvent(e))}selectMeasurementByEvent(e){if(this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0),null==this.completed||!0===this.completed){let t=this.getIntersections(e)[0];if(t){let e=this.drawList.getDrawableByPosition(t.point,this.raycaster);e&&(this.dispatchEvent("ClickedOnMeasurement",e),this.clickedOnMeasurementDrawable=e)}}}onMouseMove(e){this.createOrUpdateMeasureDrawable(e)}createOrUpdateMeasureDrawable(e){if(!this.drawingPoints||this.drawingPoints&&this.drawingPoints.length<1)return;let t=[...this.drawingPoints];if(!this.currentMeasureDrawable)return this.currentMeasureDrawable=this.createMeasureDrawable(),void this.dispatchEvent("WillBeAdded",this.currentMeasureDrawable);e&&t.push(e),this.currentMeasureDrawable.update(t),this.currentMeasureDrawable.setDrawingState(!0),this.dispatchEvent("Updated")}getIntersectsIncludeOutline(e){var t;if(!this.viewer.is3d())return e.slice();let n=[];for(let a=0;a<e.length;a++){let t=e[a].object;if(t.updateWorldMatrix(!0,!1),t instanceof Ge&&!cn.hasOutline(t)){let e=new Dn(new ja(t.geometry,5),this.tempEdgeMaterial);e.layers.enableAll(),e.matrixWorld.copy(t.matrixWorld),n.push(e)}}let i=(null==(t=this.raycaster)?void 0:t.intersectObjects(n))||[];$.debug("intersects edge: ",i);let r=e.slice();return i.length>0&&(r.push(...i),r.sort(((e,t)=>e.distance-t.distance))),r}handleSnap(e){var t,n;if(!e||e.length<1)return void(this.snapPoint=void 0);let i,r=this.getIntersectsIncludeOutline(e);if(!this.viewer.is3d()){for(let e of r)if(e.point.z=0,"groundPlane"===(null==(t=e.object)?void 0:t.name)){i=e.point;continue}if(i){for(let t of r)t.distance=t.point.distanceTo(i);let e=e=>e instanceof or?0:e instanceof Dn?2:e instanceof sn?1:3;r.sort(((t,n)=>{let i=e(t.object),r=e(n.object);return i!==r?i-r:t.distance-n.distance}))}}if(!i){for(let e of r)if(e.object instanceof Ge){i=e.point;break}i||($.warn("[BaseMeasurement] Potential to produce erroneous snap results"),i=r[0].point)}$.debug("[BaseMeasurement] filteredIntersections:",r),$.debug("[BaseMeasurement] mousePosition:",i),this.snapPoint=(null==(n=this.osnapHelper.handleSnap(i,r,this.viewer.is3d(),this.lastMouseDownPosition))?void 0:n.clone())||i}},ys=class extends ns{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new si,this.drawing=!1,this.update(t)}setDrawingState(e){this.drawing=e}drawSelect(e,t){let n=this.getVertexes();this.drawPoints(e,t,n)}drawPoints(e,t,n){e.save(),e.fillStyle=ys.MAJOR_COLOR,e.strokeStyle=ys.MINOR_COLOR,e.lineWidth=ys.LINE_WIDTH,e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.moveTo(i.x+ys.POINT_RADIUS,i.y),e.arc(i.x,i.y,ys.POINT_RADIUS,0,2*Math.PI)})),e.closePath(),e.fill(),e.stroke(),e.restore()}drawText(e,t){if(!this.label||!this.labelPositon)return;e.font=`${ys.LABEL_FONT_SIZE}px Arial`;let n=1.2*e.measureText(this.label).width,i=1.5*ys.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new Q(n,i)),this.drawRoundRect(e,this.labelPositon.x-n/2,this.labelPositon.y-i/2,n,i,4),e.save(),e.fillStyle=ys.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}drawRoundRect(e,t,n,i,r,a){i<2*a&&(a=i/2),r<2*a&&(a=r/2),e.save(),e.fillStyle=ys.MAJOR_COLOR,e.strokeStyle=ys.MINOR_COLOR,e.lineWidth=ys.LINE_WIDTH,e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+i,n,t+i,n+r,a),e.arcTo(t+i,n+r,t,n+r,a),e.arcTo(t,n+r,t,n,a),e.arcTo(t,n,t+i,n,a),e.closePath(),e.fill(),this.selected&&e.stroke(),e.restore()}getVertexes(){return this.points}update(e){let{min:t,max:n}=(new lt).setFromPoints(e);return this.x=t.x,this.y=t.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}getBounds(){let e=this.getVertexes();return(new lt).setFromPoints(e)}getData(){return{id:this.id,type:this.type,points:this.points.map((e=>[e.x,e.y,e.z]))}}setData(e){super.setData(e),this.setLineColor(ys.MAJOR_COLOR),this.setFillColor(ys.AREA_FILL_COLOR),this.setLineWidth(ys.LINE_WIDTH)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=3*this.tolerance,r=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(r))return!0;let a=new M,s=new M,o=this.points;for(let l=0;l<o.length-1;l++){let e=o[l],t=o[l+1]||o[0];if(n.distanceSqToSegment(e,t,s,a)<i*i)return!0}return!1}getUnitString(){return"Distance"===this.type?By("mm"):"Area"===this.type?`${By("m",2)}`:"Angle"===this.type?"\xb0":""}},Kn=ys;Kn.MAJOR_COLOR="rgba(249, 157, 11, 0.9)",Kn.MINOR_COLOR="rgb(255, 255, 255)",Kn.AREA_FILL_COLOR="rgba(249, 157, 11, 0.3)",Kn.LINE_WIDTH=2,Kn.POINT_RADIUS=5,Kn.LABEL_FONT_SIZE=14;var HE=class extends Kn{constructor(e,t){super(e,t),this.type="Angle",this.update(t)}draw(e,t){e.save(),e.lineWidth=Kn.LINE_WIDTH,e.strokeStyle=Kn.MAJOR_COLOR;let n=this.points;if(e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),3===this.points.length){let[n,i,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new Q).subVectors(n,i).normalize(),s=(new Q).subVectors(r,i).normalize(),o=Math.min(n.distanceTo(i),r.distanceTo(i)),l=a.angle(),h=s.angle();e.moveTo(i.x,i.y),e.arc(i.x,i.y,o/5,l,h,a.cross(s)<0)}if(e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let[n,i,r]=this.points,a=this.getAngleBisector(n,i,r),s=this.calculateAngle(n,i,r);this.label=`${Cc(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(n.distanceTo(i),r.distanceTo(i));this.labelPositon=this.transToScreenCoord(i.clone().add(new M(a.x*o,a.y*o,a.z*o)),t),super.drawText(e,t)}getAngleBisector(e,t,n){let i=e,r=t,a=n,s=new M(i.x-r.x,i.y-r.y,i.z-r.z).normalize(),o=new M(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new M(s.x+o.x,s.y+o.y,s.z+o.z).normalize()}calculateAngle(e,t,n){let i=e,r=t,a=n,s=new M(i.x-r.x,i.y-r.y,i.z-r.z),o=new M(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};$t._registerDrawableClass(HE);var oA=class extends qc{constructor(e,t,n,i){super("Angle",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new HE(it.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&wt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=3&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.currentMeasureDrawable=void 0,this.drawingPoints=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(!t)return;let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}},lA=class{constructor(e,t){this.flyDuration=500,this.autoRotateRemainingTime=0,this.automaticallyAdjustCameraPosition=!0,this.rotateIntervalStartTime=0,this.camera=e,this.controls=t}flyTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;if(e.equals(t))return void console.error("[BimViewer] camera position and lookAt cannot be the same!");if(isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||isNaN(t.x)||isNaN(t.y)||isNaN(t.z))return void console.error("[BimViewer] invalid position or lookAt!");if(this.automaticallyAdjustCameraPosition){let n=e.distanceTo(t);n<i.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*i.near),console.warn("[BimViewer] camera could be too close to see the object!")):n>i.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),console.warn("[BimViewer] camera could be too far to see the object!"))}let a=i.position.clone(),s=r.target.clone(),o=this.flyDuration,l=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let h=Date.now()-l;h>o&&(h=o);let c=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new M(i,r,a)};((e,t)=>{i.lookAt(t),i.position.set(e.x,e.y,e.z),r.target.set(t.x,t.y,t.z),r.update()})(c(a,e,h/o),c(s,t,h/o)),h>=o&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0,n&&n())}),10)}lookTo(e){let t=this.camera,n=this.controls;if(!t||!n)return;let i=t.position,r=n.target.distanceTo(i),a=e.normalize().multiplyScalar(r),s=new M(i.x+a.x,i.y+a.y,i.z+a.z);this.flyTo(i,s)}startAutoRotate(){let e=this.camera,t=this.controls;if(!e||!t)return;t.autoRotate=!0;let n=new M;e.getWorldPosition(n);let i=t.target;if(i.y===n.y)return;let r=(i.y-n.y)/50;for(let a=0;a<50;++a)setTimeout((()=>{let e=t.target.y-r;t.target.setY(e),t.update()}),30*a)}delayAutoRotate(){this.autoRotateRemainingTime=5e3,this.controls&&(this.controls.autoRotate=!1)}startToRotate(e){let t=Date.now()-this.rotateIntervalStartTime;this.rotateIntervalStartTime=Date.now(),!(this.rotateInterval&&t<100)&&(this.rotateInterval&&clearInterval(this.rotateInterval),this.rotateInterval=setInterval((()=>{if(Date.now()-this.rotateIntervalStartTime>=100)return clearInterval(this.rotateInterval),void(this.rotateInterval=void 0);"ArrowLeft"===e.code||"ArrowRight"===e.code?this.rotateLeftOrRight(.3,"ArrowLeft"===e.code):("ArrowUp"===e.code||"ArrowDown"===e.code)&&this.rotateUpOrDown(.3,"ArrowUp"===e.code)}),1))}rotateLeftOrRight(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180;t&&(s=-s),a.x=(r.x-i.x)*Math.cos(s)-(r.z-i.z)*Math.sin(s)+i.x,a.z=(r.z-i.z)*Math.cos(s)+(r.x-i.x)*Math.sin(s)+i.z,this.camera.lookAt(a),n.target=a,n.update()}rotateUpOrDown(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180,o=new M(r.x-i.x,r.y-i.y,r.z-i.z).length(),l=r.y-i.y;t||(s=-s);let h=Math.asin(l/o)+s;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;a.y=r.y+(c-l),n.target=a,n.update()}},e0=class{constructor(e){this.object=e}instantiate(){let e=Date.now();this.instantiateInner(this.object),console.log(`[Inst] instantiate() costed ${(Date.now()-e)/1e3}s`)}instantiateInner(e){if(!e.children||0===e.children.length)return;let t=e.children.length,n={},i=[];for(let s=0;s<t;++s){let t=e.children[s];if(this.instantiateInner(t),t.children&&t.children.length>0||!t.geometry)continue;let r=!1,a=Object.values(n);for(let o=a.length-1;o>=0;--o){let l=a[o].indexes[0],h=e.children[l];if(this.geometryEquals(t.geometry,h.geometry)&&yi.materialsEquals(t.material,h.material)){n[l]||(n[l]={indexes:[l]},this.removeFromArray(i,l)),n[l].indexes.push(s),r=!0;break}}for(let o=i.length-1;!r&&o>=0;--o){let a=i[o],l=e.children[a];if(this.geometryEquals(t.geometry,l.geometry)&&yi.materialsEquals(t.material,l.material)){n[a]||(n[a]={indexes:[a]},this.removeFromArray(i,a)),n[a].indexes.push(s),r=!0;break}}r||i.push(s)}if(Object.keys(n).length<=0)return;let r=[],a=[];Object.values(n).forEach((t=>{let n=t.indexes;a.push(...n);let i=e.children[n[0]],s=i.material;if(s instanceof Rn)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Ar(i.geometry,s,n.length);o.name=`[Instanced] ${i.name}`;for(let r=0;r<n.length;++r){let t=n[r],i=e.children[t];i.updateMatrix(),o.setMatrixAt(r,i.matrix)}o.matrixAutoUpdate=!1,o.updateMatrix(),r.push(o)})),a.sort(((e,t)=>t-e)),a.forEach((t=>e.remove(e.children[t]))),r.forEach((t=>{t.parent=e,e.children.push(t)})),e.updateMatrix(),console.log(`[Inst] ${a.length}(out of ${t}) objects instanced to ${r.length} InstancedMesh`)}removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}geometryEquals(e,t){return xt.geometryEquals(e,t)}},t0=class{constructor(){this.TIMEOUT="timeout",this.INTERVAL="interval",this.timeoutMap={},this.intervalMap={}}run(e=this.INTERVAL,t,n=16.7){let i=Date.now,r=i(),a=r,s=Symbol(""),o=()=>{this.setIdMap(s,e,o),a=i(),a-r>=n&&(e===this.intervalMap&&(r=i(),a=r),t(),e===this.TIMEOUT&&this.clearTimeout(s))};return this.setIdMap(s,e,o),s}setIdMap(e,t,n){let i=requestAnimationFrame(n);t===this.INTERVAL?this.intervalMap[e]=i:t===this.TIMEOUT&&(this.timeoutMap[e]=i)}setTimeout(e,t){return this.run(this.TIMEOUT,e,t)}clearTimeout(e){cancelAnimationFrame(this.timeoutMap[e])}setInterval(e,t){return this.run(this.INTERVAL,e,t)}clearInterval(e){cancelAnimationFrame(this.intervalMap[e])}},kE=class extends gp{constructor(e){super(e)}parse(e){e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let t=0,n=new Uint8Array(e),i={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};(function(e){switch(e.image_type){case 1:case 9:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)})(i),i.id_length+t>e.length&&console.error("THREE.TGALoader: No data."),t+=i.id_length;let r=!1,a=!1,s=!1;switch(i.image_type){case 9:r=!0,a=!0;break;case 1:a=!0;break;case 10:r=!0;break;case 2:break;case 11:r=!0,s=!0;break;case 3:s=!0}let o=new Uint8Array(i.width*i.height*4),l=function(e,t,n,i,r){let a,s,o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(s=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){a=new Uint8Array(l);let e,t,n,s=0,h=new Uint8Array(o);for(;s<l;)if(e=r[i++],t=1+(127&e),128&e){for(n=0;n<o;++n)h[n]=r[i++];for(n=0;n<t;++n)a.set(h,s+n*o);s+=o*t}else{for(t*=o,n=0;n<t;++n)a[s+n]=r[i++];s+=t}}else a=r.subarray(i,i+=t?n.width*n.height:l);return{pixel_data:a,palettes:s}}(r,a,i,t,n);return function(e,t,n,r,a){let o,l,h,c,u,d;switch((48&i.flags)>>4){default:case 2:o=0,h=1,u=t,l=0,c=1,d=n;break;case 0:o=0,h=1,u=t,l=n-1,c=-1,d=-1;break;case 3:o=t-1,h=-1,u=-1,l=0,c=1,d=n;break;case 1:o=t-1,h=-1,u=-1,l=n-1,c=-1,d=-1}if(s)switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d++)h=l[d],e[4*(c+p*u)+0]=h,e[4*(c+p*u)+1]=h,e[4*(c+p*u)+2]=h,e[4*(c+p*u)+3]=255}(e,l,c,d,o,h,u,r);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=2)e[4*(h+d*c)+0]=l[u+0],e[4*(h+d*c)+1]=l[u+0],e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+3]=l[u+1]}(e,l,c,d,o,h,u,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l,h){let c,u,d,p=h,f=0,m=i.width;for(d=t;d!==r;d+=n)for(u=a;u!==o;u+=s,f++)c=l[f],e[4*(u+m*d)+3]=255,e[4*(u+m*d)+2]=p[3*c+0],e[4*(u+m*d)+1]=p[3*c+1],e[4*(u+m*d)+0]=p[3*c+2]}(e,l,c,d,o,h,u,r,a);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d+=2)h=l[d+0]+(l[d+1]<<8),e[4*(c+p*u)+0]=(31744&h)>>7,e[4*(c+p*u)+1]=(992&h)>>2,e[4*(c+p*u)+2]=(31&h)<<3,e[4*(c+p*u)+3]=32768&h?0:255}(e,l,c,d,o,h,u,r);break;case 24:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=3)e[4*(h+d*c)+3]=255,e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2]}(e,l,c,d,o,h,u,r);break;case 32:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=4)e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2],e[4*(h+d*c)+3]=l[u+3]}(e,l,c,d,o,h,u,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(o,i.width,i.height,l.pixel_data,l.palettes),{data:o,width:i.width,height:i.height,flipY:!0,generateMipmaps:!0,minFilter:Hs}}},cA=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?ts.extractUrlBase(e):r.path,s=new rr(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(n,a))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){function n(e,t){let n=[],i=e.childNodes;for(let r=0,a=i.length;r<a;r++){let e=i[r];e.nodeName===t&&n.push(e)}return n}function i(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),n=new Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i];return n}function r(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),n=new Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=parseFloat(t[i]);return n}function a(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),n=new Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=parseInt(t[i]);return n}function s(e){return e.substring(1)}function o(e){return 0===Object.keys(e).length}function l(e,t,i,r){let a=n(e,t)[0];if(void 0!==a){let e=n(a,i);for(let t=0;t<e.length;t++)r(e[t])}}function h(e,t){for(let n in e)e[n].build=t(e[n])}function c(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function u(e){let t={inputs:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType&&"input"===i.nodeName){let e=s(i.getAttribute("source")),n=i.getAttribute("semantic");t.inputs[n]=e}}return t}function d(e){let t={},n=e.getAttribute("target").split("/"),i=n.shift(),r=n.shift(),a=-1!==r.indexOf("("),o=-1!==r.indexOf(".");if(o)n=r.split("."),r=n.shift(),t.member=n.shift();else if(a){let e=r.split("(");r=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=i,t.sid=r,t.arraySyntax=a,t.memberSyntax=o,t.sampler=s(e.getAttribute("source")),t}function p(e){let t=[],n=e.channels,i=e.samplers,r=e.sources;for(let a in n)if(n.hasOwnProperty(a)){let e=n[a],s=i[e.sampler],o=s.inputs.INPUT,l=s.inputs.OUTPUT;x(m(e,r[o],r[l]),t)}return t}function f(e){return c(rt.animations[e],p)}function m(e,t,n){let i,r,a,s,o,l,h=rt.nodes[e.id],c=Be(h.id),u=h.transforms[e.sid],d=h.matrix.clone().transpose(),p={};switch(u){case"matrix":for(a=0,s=t.array.length;a<s;a++)if(i=t.array[a],r=a*n.stride,void 0===p[i]&&(p[i]={}),!0===e.arraySyntax){let t=n.array[r],a=e.indices[0]+4*e.indices[1];p[i][a]=t}else for(o=0,l=n.stride;o<l;o++)p[i][o]=n.array[r+o];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',u)}let f=function(e,t){let n=[];for(let i in e)n.push({time:parseFloat(i),value:e[i]});n.sort((function(e,t){return e.time-t.time}));for(let i=0;i<16;i++)_(n,i,t.elements[i]);return n}(p,d);return{name:c.uuid,keyframes:f}}let g=new M,v=new M,y=new En;function x(e,t){let n=e.keyframes,i=e.name,r=[],a=[],s=[],o=[];for(let l=0,h=n.length;l<h;l++){let e=n[l],t=e.time,i=e.value;Te.fromArray(i).transpose(),Te.decompose(g,y,v),r.push(t),a.push(g.x,g.y,g.z),s.push(y.x,y.y,y.z,y.w),o.push(v.x,v.y,v.z)}return a.length>0&&t.push(new fa(i+".position",r,a)),s.length>0&&t.push(new zs(i+".quaternion",r,s)),o.length>0&&t.push(new fa(i+".scale",r,o)),t}function _(e,t,n){let i,r,a,s=!0;for(r=0,a=e.length;r<a;r++)i=e[r],void 0===i.value[t]?i.value[t]=null:s=!1;if(!0===s)for(r=0,a=e.length;r<a;r++)i=e[r],i.value[t]=n;else!function(e,t){let n,i;for(let r=0,a=e.length;r<a;r++){let a=e[r];if(null===a.value[t]){if(n=b(e,r,t),i=w(e,r,t),null===n){a.value[t]=i.value[t];continue}if(null===i){a.value[t]=n.value[t];continue}S(a,n,i,t)}}}(e,t)}function b(e,t,n){for(;t>=0;){let i=e[t];if(null!==i.value[n])return i;t--}return null}function w(e,t,n){for(;t<e.length;){let i=e[t];if(null!==i.value[n])return i;t++}return null}function S(e,t,n,i){n.time-t.time!=0?e.value[i]=(e.time-t.time)*(n.value[i]-t.value[i])/(n.time-t.time)+t.value[i]:e.value[i]=t.value[i]}function E(e){let t=[],n=e.name,i=e.end-e.start||-1,r=e.animations;for(let a=0,s=r.length;a<s;a++){let e=f(r[a]);for(let n=0,i=e.length;n<i;n++)t.push(e[n])}return new pa(n,i,t)}function T(e){return c(rt.clips[e],E)}function A(e){let t={sources:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=r(i.textContent);break;case"source":let e=i.getAttribute("id");t.sources[e]=se(i);break;case"joints":t.joints=C(i);break;case"vertex_weights":t.vertexWeights=R(i)}}return t}function C(e){let t={inputs:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType&&"input"===i.nodeName){let e=i.getAttribute("semantic"),n=s(i.getAttribute("source"));t.inputs[e]=n}}return t}function R(e){let t={inputs:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"input":let e=i.getAttribute("semantic"),n=s(i.getAttribute("source")),r=parseInt(i.getAttribute("offset"));t.inputs[e]={id:n,offset:r};break;case"vcount":t.vcount=a(i.textContent);break;case"v":t.v=a(i.textContent)}}return t}function P(e){let t={id:e.id},n=rt.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){let t,n,i,r={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},a=e.sources,s=e.vertexWeights,o=s.vcount,l=s.v,h=s.inputs.JOINT.offset,c=s.inputs.WEIGHT.offset,u=e.sources[e.joints.inputs.JOINT],d=e.sources[e.joints.inputs.INV_BIND_MATRIX],p=a[s.inputs.WEIGHT.id].array,f=0;for(t=0,i=o.length;t<i;t++){let e=o[t],i=[];for(n=0;n<e;n++){let e=l[f+h],t=p[l[f+c]];i.push({index:e,weight:t}),f+=2}for(i.sort(m),n=0;n<4;n++){let e=i[n];void 0!==e?(r.indices.array.push(e.index),r.weights.array.push(e.weight)):(r.indices.array.push(0),r.weights.array.push(0))}}for(e.bindShapeMatrix?r.bindMatrix=(new Ae).fromArray(e.bindShapeMatrix).transpose():r.bindMatrix=(new Ae).identity(),t=0,i=u.array.length;t<i;t++){let e=u.array[t],n=(new Ae).fromArray(d.array,t*d.stride).transpose();r.joints.push({name:e,boneInverse:n})}return r;function m(e,t){return t.weight-e.weight}}(e.skin),n.sources.skinIndices=t.skin.indices,n.sources.skinWeights=t.skin.weights),t}function L(e){return c(rt.controllers[e],P)}function D(e){return void 0!==e.build?e.build:e.init_from}function I(e){let t=rt.images[e];return void 0!==t?c(t,D):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function O(e){let t={surfaces:{},samplers:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"newparam":U(i,t);break;case"technique":t.technique=k(i);break;case"extra":t.extra=j(i)}}return t}function U(e,t){let n=e.getAttribute("sid");for(let i=0,r=e.childNodes.length;i<r;i++){let r=e.childNodes[i];if(1===r.nodeType)switch(r.nodeName){case"surface":t.surfaces[n]=N(r);break;case"sampler2D":t.samplers[n]=F(r)}}}function N(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"init_from"===i.nodeName&&(t.init_from=i.textContent)}return t}function F(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"source"===i.nodeName&&(t.source=i.textContent)}return t}function k(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=i.nodeName,t.parameters=B(i);break;case"extra":t.extra=j(i)}}return t}function B(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[i.nodeName]=z(i);break;case"transparent":t[i.nodeName]={opaque:i.hasAttribute("opaque")?i.getAttribute("opaque"):"A_ONE",data:z(i)}}}return t}function z(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"color":t[i.nodeName]=r(i.textContent);break;case"float":t[i.nodeName]=parseFloat(i.textContent);break;case"texture":t[i.nodeName]={id:i.getAttribute("texture"),extra:V(i)}}}return t}function V(e){let t={technique:{}};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"extra"===i.nodeName&&H(i,t)}return t}function H(e,t){for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"technique"===i.nodeName&&G(i,t)}}function G(e,t){for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[i.nodeName]=parseFloat(i.textContent);break;case"wrapU":case"wrapV":"TRUE"===i.textContent.toUpperCase()?t.technique[i.nodeName]=1:"FALSE"===i.textContent.toUpperCase()?t.technique[i.nodeName]=0:t.technique[i.nodeName]=parseInt(i.textContent);break;case"bump":t[i.nodeName]=X(i)}}}function j(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"technique"===i.nodeName&&(t.technique=W(i))}return t}function W(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"double_sided":t[i.nodeName]=parseInt(i.textContent);break;case"bump":t[i.nodeName]=X(i)}}return t}function X(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"texture"===i.nodeName&&(t[i.nodeName]={id:i.getAttribute("texture"),texcoord:i.getAttribute("texcoord"),extra:V(i)})}return t}function q(e){return e}function Y(e){let t,n=function(e){return c(rt.effects[e],q)}(e.url),i=n.profile.technique;switch(i.type){case"phong":case"blinn":t=new es;break;case"lambert":t=new _c;break;default:t=new Pt}function r(e,t=null){let i=n.profile.samplers[e.id],r=null;if(void 0!==i?r=I(n.profile.surfaces[i.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),r=I(e.id)),null!==r){let n=function(e){let t,n=e.slice(2+(e.lastIndexOf(".")-1>>>0));return t="tga"===(n=n.toLowerCase(),n)?Ze:$e,t}(r);if(void 0!==n){let i=n.load(r),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===o(a.technique)){let e=a.technique;i.wrapS=e.wrapU?Nr:Or,i.wrapT=e.wrapV?Nr:Or,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=Nr,i.wrapT=Nr;return null!==t&&(i.colorSpace=t),i}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}t.name=e.name||"";let a=i.parameters;for(let o in a){let e=a[o];switch(o){case"diffuse":e.color&&t.color.fromArray(e.color),e.texture&&(t.map=r(e.texture,St));break;case"specular":e.color&&t.specular&&t.specular.fromArray(e.color),e.texture&&(t.specularMap=r(e.texture));break;case"bump":e.texture&&(t.normalMap=r(e.texture));break;case"ambient":e.texture&&(t.lightMap=r(e.texture,St));break;case"shininess":e.float&&t.shininess&&(t.shininess=e.float);break;case"emission":e.color&&t.emissive&&t.emissive.fromArray(e.color),e.texture&&(t.emissiveMap=r(e.texture,St))}}t.color.convertSRGBToLinear(),t.specular&&t.specular.convertSRGBToLinear(),t.emissive&&t.emissive.convertSRGBToLinear();let s=a.transparent,l=a.transparency;if(void 0===l&&s&&(l={float:1}),void 0===s&&l&&(s={opaque:"A_ONE",data:{color:[1,1,1,1]}}),s&&l)if(s.data.texture)t.transparent=!0;else{let e=s.data.color;switch(s.opaque){case"A_ONE":t.opacity=e[3]*l.float;break;case"RGB_ZERO":t.opacity=1-e[0]*l.float;break;case"A_ZERO":t.opacity=1-e[3]*l.float;break;case"RGB_ONE":t.opacity=e[0]*l.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',s.opaque)}t.opacity<1&&(t.transparent=!0)}if(void 0!==i.extra&&void 0!==i.extra.technique){let e=i.extra.technique;for(let n in e){let i=e[n];switch(n){case"double_sided":t.side=1===i?tr:Tr;break;case"bump":t.normalMap=r(i.texture),t.normalScale=new Q(1,1)}}}return t}function $(e){return c(rt.materials[e],Y)}function K(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes[t];if("technique_common"===n.nodeName)return Z(n)}return{}}function Z(e){let t={};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];switch(i.nodeName){case"perspective":case"orthographic":t.technique=i.nodeName,t.parameters=J(i)}}return t}function J(e){let t={};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];switch(i.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[i.nodeName]=parseFloat(i.textContent)}}return t}function ee(e){let t;switch(e.optics.technique){case"perspective":t=new bn(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let n=e.optics.parameters.ymag,i=e.optics.parameters.xmag,r=e.optics.parameters.aspect_ratio;i=void 0===i?n*r:i,n=void 0===n?i/r:n,i*=.5,n*=.5,t=new dr(-i,i,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new bn}return t.name=e.name||"",t}function te(e){let t=rt.cameras[e];return void 0!==t?c(t,ee):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function ne(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=i.nodeName,t.parameters=ie(i)}}return t}function ie(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"color":let e=r(i.textContent);t.color=(new Ie).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(i.textContent);break;case"quadratic_attenuation":let n=parseFloat(i.textContent);t.distance=n?Math.sqrt(1/n):0}}return t}function re(e){let t;switch(e.technique){case"directional":t=new ji;break;case"point":t=new Sl;break;case"spot":t=new wc;break;case"ambient":t=new Lo}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function ae(e){let t=rt.lights[e];return void 0!==t?c(t,re):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function se(e){let t={array:[],stride:3};for(let a=0;a<e.childNodes.length;a++){let s=e.childNodes[a];if(1===s.nodeType)switch(s.nodeName){case"float_array":t.array=r(s.textContent);break;case"Name_array":t.array=i(s.textContent);break;case"technique_common":let e=n(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function oe(e){let t={};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];1===i.nodeType&&(t[i.getAttribute("semantic")]=s(i.getAttribute("source")))}return t}function le(e){let t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"input":let e=s(i.getAttribute("source")),n=i.getAttribute("semantic"),r=parseInt(i.getAttribute("offset")),o=parseInt(i.getAttribute("set")),l=o>0?n+o:n;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(i.textContent);break;case"p":t.p=a(i.textContent)}}return t}function he(e){let t=0;for(let n=0,i=e.length;n<i;n++)!0===e[n].hasUV&&t++;t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function ce(e){let t={},n=e.sources,i=e.vertices,r=e.primitives;if(0===r.length)return{};let a=function(e){let t={};for(let n=0;n<e.length;n++){let i=e[n];void 0===t[i.type]&&(t[i.type]=[]),t[i.type].push(i)}return t}(r);for(let s in a){let e=a[s];he(e),t[s]=ue(e,n,i)}return t}function ue(e,t,n){let i={},r={array:[],stride:0},a={array:[],stride:0},s={array:[],stride:0},o={array:[],stride:0},l={array:[],stride:0},h=[],c=[],u=new et,d=[],p=0;for(let f=0;f<e.length;f++){let i=e[f],m=i.inputs,g=0;switch(i.type){case"lines":case"linestrips":g=2*i.count;break;case"triangles":g=3*i.count;break;case"polylist":for(let e=0;e<i.count;e++){let t=i.vcount[e];switch(t){case 3:g+=3;break;case 4:g+=6;break;default:g+=3*(t-2)}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",i.type)}u.addGroup(p,g,f),p+=g,i.material&&d.push(i.material);for(let u in m){let d=m[u];switch(u){case"VERTEX":for(let u in n){let p=n[u];switch(u){case"POSITION":let n=r.array.length;if(de(i,t[p],d.offset,r.array),r.stride=t[p].stride,t.skinWeights&&t.skinIndices&&(de(i,t.skinIndices,d.offset,h),de(i,t.skinWeights,d.offset,c)),!1===i.hasUV&&!0===e.uvsNeedsFix){let e=(r.array.length-n)/r.stride;for(let t=0;t<e;t++)s.array.push(0,0)}break;case"NORMAL":de(i,t[p],d.offset,a.array),a.stride=t[p].stride;break;case"COLOR":de(i,t[p],d.offset,l.array),l.stride=t[p].stride;break;case"TEXCOORD":de(i,t[p],d.offset,s.array),s.stride=t[p].stride;break;case"TEXCOORD1":de(i,t[p],d.offset,o.array),s.stride=t[p].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',u)}}break;case"NORMAL":de(i,t[d.id],d.offset,a.array),a.stride=t[d.id].stride;break;case"COLOR":de(i,t[d.id],d.offset,l.array,!0),l.stride=t[d.id].stride;break;case"TEXCOORD":de(i,t[d.id],d.offset,s.array),s.stride=t[d.id].stride;break;case"TEXCOORD1":de(i,t[d.id],d.offset,o.array),o.stride=t[d.id].stride}}}return r.array.length>0&&u.setAttribute("position",new tt(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new tt(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new tt(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new tt(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new tt(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new tt(h,4)),c.length>0&&u.setAttribute("skinWeight",new tt(c,4)),i.data=u,i.type=e[0].type,i.materialKeys=d,i}function de(e,t,n,i,r=!1){let a=e.p,s=e.stride,o=e.vcount;function l(e){let t=a[e+n]*c,s=t+c;for(;t<s;t++)i.push(h[t]);if(r){let e=i.length-c-1;Je.setRGB(i[e+0],i[e+1],i[e+2]).convertSRGBToLinear(),i[e+0]=Je.r,i[e+1]=Je.g,i[e+2]=Je.b}}let h=t.array,c=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=o.length;t<n;t++){let n=o[t];if(4===n){let t=e+1*s,n=e+2*s,i=e+3*s;l(e+0*s),l(t),l(i),l(t),l(n),l(i)}else if(3===n){let t=e+1*s,n=e+2*s;l(e+0*s),l(t),l(n)}else if(n>4)for(let t=1,i=n-2;t<=i;t++){let n=e+s*t,i=e+s*(t+1);l(e+0*s),l(n),l(i)}e+=s*n}}else for(let u=0,d=a.length;u<d;u+=s)l(u)}function pe(e){return c(rt.geometries[e],ce)}function fe(e){return void 0!==e.build?e.build:e}function me(e,t){for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"joint":t.joints[i.getAttribute("sid")]=ge(i);break;case"link":t.links.push(ye(i))}}}function ge(e){let t;for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"prismatic":case"revolute":t=ve(i)}}return t}function ve(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new M,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"axis":let e=r(i.textContent);t.axis.fromArray(e);break;case"limits":let n=i.getElementsByTagName("max")[0],a=i.getElementsByTagName("min")[0];t.limits.max=parseFloat(n.textContent),t.limits.min=parseFloat(a.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ye(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"attachment_full":t.attachments.push(xe(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(_e(i))}}return t}function xe(e){let t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"link":t.links.push(ye(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(_e(i))}}return t}function _e(e){let t={type:e.nodeName},n=r(e.textContent);switch(t.type){case"matrix":t.obj=new Ae,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new M,t.obj.fromArray(n);break;case"rotate":t.obj=new M,t.obj.fromArray(n),t.angle=Yt.degToRad(n[3])}return t}function be(e,t){for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];1===i.nodeType&&"technique_common"===i.nodeName&&Me(i,t)}}function Me(e,t){for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"inertia":t.inertia=r(i.textContent);break;case"mass":t.mass=r(i.textContent)[0]}}}function we(e){let t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];if(1===i.nodeType&&"axis"===i.nodeName){let e=i.getElementsByTagName("param")[0];t.axis=e.textContent;let n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function Se(e){return void 0!==e.build?e.build:e}function Ee(e){let t=[],n=We.querySelector('[id="'+e.id+'"]');for(let i=0;i<n.childNodes.length;i++){let e,a,s=n.childNodes[i];if(1===s.nodeType)switch(s.nodeName){case"matrix":e=r(s.textContent);let n=(new Ae).fromArray(e).transpose();t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:n});break;case"translate":case"scale":e=r(s.textContent),a=(new M).fromArray(e),t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a});break;case"rotate":e=r(s.textContent),a=(new M).fromArray(e);let i=Yt.degToRad(e[3]);t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a,angle:i})}}return t}let Te=new Ae,Ce=new M;function Re(e){let t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new Ae,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<e.childNodes.length;n++){let i,a=e.childNodes[n];if(1===a.nodeType)switch(a.nodeName){case"node":t.nodes.push(a.getAttribute("id")),Re(a);break;case"instance_camera":t.instanceCameras.push(s(a.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(Pe(a));break;case"instance_light":t.instanceLights.push(s(a.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(Pe(a));break;case"instance_node":t.instanceNodes.push(s(a.getAttribute("url")));break;case"matrix":i=r(a.textContent),t.matrix.multiply(Te.fromArray(i).transpose()),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"translate":i=r(a.textContent),Ce.fromArray(i),t.matrix.multiply(Te.makeTranslation(Ce.x,Ce.y,Ce.z)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"rotate":i=r(a.textContent);let e=Yt.degToRad(i[3]);t.matrix.multiply(Te.makeRotationAxis(Ce.fromArray(i),e)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"scale":i=r(a.textContent),t.matrix.scale(Ce.fromArray(i)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"extra":break;default:console.log(a)}}return ke(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):rt.nodes[t.id]=t,t}function Pe(e){let t={id:s(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];switch(i.nodeName){case"bind_material":let e=i.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){let i=e[n],r=i.getAttribute("symbol"),a=i.getAttribute("target");t.materials[r]=s(a)}break;case"skeleton":t.skeletons.push(s(i.textContent))}}return t}function Le(e,t){let n,i,r,a=[],s=[];for(n=0;n<e.length;n++){let i,r=e[n];if(ke(r))i=Be(r),De(i,t,a);else if(Ve(r)){let e=rt.visualScenes[r].children;for(let n=0;n<e.length;n++){let i=e[n];"JOINT"===i.type&&De(Be(i.id),t,a)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}for(n=0;n<t.length;n++)for(i=0;i<a.length;i++)if(r=a[i],r.bone.name===t[n].name){s[n]=r,r.processed=!0;break}for(n=0;n<a.length;n++)r=a[n],!1===r.processed&&(s.push(r),r.processed=!0);let o=[],l=[];for(n=0;n<s.length;n++)r=s[n],o.push(r.bone),l.push(r.boneInverse);return new Co(o,l)}function De(e,t,n){e.traverse((function(e){if(!0===e.isBone){let i;for(let n=0;n<t.length;n++){let r=t[n];if(r.name===e.name){i=r.boneInverse;break}}void 0===i&&(i=new Ae),n.push({bone:e,boneInverse:i,processed:!1})}}))}function Oe(e){let t,n=[],i=e.matrix,r=e.nodes,a=e.type,s=e.instanceCameras,o=e.instanceControllers,l=e.instanceLights,h=e.instanceGeometries,c=e.instanceNodes;for(let u=0,d=r.length;u<d;u++)n.push(Be(r[u]));for(let u=0,d=s.length;u<d;u++){let e=te(s[u]);null!==e&&n.push(e.clone())}for(let u=0,d=o.length;u<d;u++){let e=o[u],t=L(e.id),i=Fe(pe(t.id),e.materials),r=Le(e.skeletons,t.skin.joints);for(let a=0,s=i.length;a<s;a++){let e=i[a];e.isSkinnedMesh&&(e.bind(r,t.skin.bindMatrix),e.normalizeSkinWeights()),n.push(e)}}for(let u=0,d=l.length;u<d;u++){let e=ae(l[u]);null!==e&&n.push(e.clone())}for(let u=0,d=h.length;u<d;u++){let e=h[u],t=Fe(pe(e.id),e.materials);for(let i=0,r=t.length;i<r;i++)n.push(t[i])}for(let u=0,d=c.length;u<d;u++)n.push(Be(c[u]).clone());if(0===r.length&&1===n.length)t=n[0];else{t="JOINT"===a?new Ao:new Nt;for(let e=0;e<n.length;e++)t.add(n[e])}return t.name="JOINT"===a?e.sid:e.name,t.matrix.copy(i),t.matrix.decompose(t.position,t.quaternion,t.scale),t}let Ue=new Pt({color:16711935});function Ne(e,t){let n=[];for(let i=0,r=e.length;i<r;i++){let r=t[e[i]];void 0===r?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[i]),n.push(Ue)):n.push($(r))}return n}function Fe(e,t){let n=[];for(let i in e){let r=e[i],a=Ne(r.materialKeys,t);if(0===a.length&&("lines"===i||"linestrips"===i?a.push(new Jt):a.push(new es)),"lines"===i||"linestrips"===i)for(let e=0,t=a.length;e<t;e++){let t=a[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){let n=new Jt;n.color.copy(t.color),n.opacity=t.opacity,n.transparent=t.transparent,a[e]=n}}let s,o=void 0!==r.data.attributes.skinIndex,l=1===a.length?a[0]:a;switch(i){case"lines":s=new Dn(r.data,l);break;case"linestrips":s=new sn(r.data,l);break;case"triangles":case"polylist":s=o?new yc(r.data,l):new Ge(r.data,l)}n.push(s)}return n}function ke(e){return void 0!==rt.nodes[e]}function Be(e){return c(rt.nodes[e],Oe)}function ze(e){let t=new Nt;t.name=e.name;let n=e.children;for(let i=0;i<n.length;i++){let e=n[i];t.add(Be(e.id))}return t}function Ve(e){return void 0!==rt.visualScenes[e]}function He(e){return c(rt.visualScenes[e],ze)}if(0===e.length)return{scene:new ii};let je=(new DOMParser).parseFromString(e,"application/xml"),We=n(je,"COLLADA")[0],Xe=je.getElementsByTagName("parsererror")[0];if(void 0!==Xe){let e,t=n(Xe,"div")[0];return e=t?t.textContent:function(e){let t="",n=[e];for(;n.length;){let e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(Xe),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",e),null}let qe=We.getAttribute("version");console.debug("THREE.ColladaLoader: File version",qe);let Ye=(Ke=n(We,"asset")[0],{unit:function(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}(n(Ke,"unit")[0]),upAxis:function(e){return void 0!==e?e.textContent:"Y_UP"}(n(Ke,"up_axis")[0])}),$e=new Ai(this.manager);var Ke;let Ze;$e.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),kE&&(Ze=new kE(this.manager),Ze.setPath(this.resourcePath||t));let Je=new Ie,Qe=[],nt={},it=0,rt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};l(We,"library_animations","animation",(function e(t){let n={sources:{},samplers:{},channels:{}},i=!1;for(let r=0,a=t.childNodes.length;r<a;r++){let a,s=t.childNodes[r];if(1===s.nodeType)switch(s.nodeName){case"source":a=s.getAttribute("id"),n.sources[a]=se(s);break;case"sampler":a=s.getAttribute("id"),n.samplers[a]=u(s);break;case"channel":a=s.getAttribute("target"),n.channels[a]=d(s);break;case"animation":e(s),i=!0;break;default:console.log(s)}}!1===i&&(rt.animations[t.getAttribute("id")||Yt.generateUUID()]=n)})),l(We,"library_animation_clips","animation_clip",(function(e){let t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"instance_animation"===i.nodeName&&t.animations.push(s(i.getAttribute("url")))}rt.clips[e.getAttribute("id")]=t})),l(We,"library_controllers","controller",(function(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];if(1===i.nodeType)switch(i.nodeName){case"skin":t.id=s(i.getAttribute("source")),t.skin=A(i);break;case"morph":t.id=s(i.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}rt.controllers[e.getAttribute("id")]=t})),l(We,"library_images","image",(function(e){let t={init_from:n(e,"init_from")[0].textContent};rt.images[e.getAttribute("id")]=t})),l(We,"library_effects","effect",(function(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"profile_COMMON"===i.nodeName&&(t.profile=O(i))}rt.effects[e.getAttribute("id")]=t})),l(We,"library_materials","material",(function(e){let t={name:e.getAttribute("name")};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"instance_effect"===i.nodeName&&(t.url=s(i.getAttribute("url")))}rt.materials[e.getAttribute("id")]=t})),l(We,"library_cameras","camera",(function(e){let t={name:e.getAttribute("name")};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"optics"===i.nodeName&&(t.optics=K(i))}rt.cameras[e.getAttribute("id")]=t})),l(We,"library_lights","light",(function(e){let t={};for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"technique_common"===i.nodeName&&(t=ne(i))}rt.lights[e.getAttribute("id")]=t})),l(We,"library_geometries","geometry",(function(e){let t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},i=n(e,"mesh")[0];if(void 0!==i){for(let e=0;e<i.childNodes.length;e++){let n=i.childNodes[e];if(1!==n.nodeType)continue;let r=n.getAttribute("id");switch(n.nodeName){case"source":t.sources[r]=se(n);break;case"vertices":t.vertices=oe(n);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(le(n));break;default:console.log(n)}}rt.geometries[e.getAttribute("id")]=t}})),l(We,"library_nodes","node",Re),l(We,"library_visual_scenes","visual_scene",(function(e){let t={name:e.getAttribute("name"),children:[]};!function(e){let t=e.getElementsByTagName("node");for(let n=0;n<t.length;n++){let e=t[n];!1===e.hasAttribute("id")&&e.setAttribute("id","three_default_"+it++)}}(e);let i=n(e,"node");for(let n=0;n<i.length;n++)t.children.push(Re(i[n]));rt.visualScenes[e.getAttribute("id")]=t})),l(We,"library_kinematics_models","kinematics_model",(function(e){let t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];1===i.nodeType&&"technique_common"===i.nodeName&&me(i,t)}rt.kinematicsModels[e.getAttribute("id")]=t})),l(We,"library_physics_models","physics_model",(function(e){let t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];1===i.nodeType&&"rigid_body"===i.nodeName&&(t.rigidBodies[i.getAttribute("name")]={},be(i,t.rigidBodies[i.getAttribute("name")]))}rt.physicsModels[e.getAttribute("id")]=t})),l(We,"scene","instance_kinematics_scene",(function(e){let t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){let i=e.childNodes[n];1===i.nodeType&&"bind_joint_axis"===i.nodeName&&t.bindJointAxis.push(we(i))}rt.kinematicsScenes[s(e.getAttribute("url"))]=t})),h(rt.animations,p),h(rt.clips,E),h(rt.controllers,P),h(rt.images,D),h(rt.effects,q),h(rt.materials,Y),h(rt.cameras,ee),h(rt.lights,re),h(rt.geometries,ce),h(rt.visualScenes,ze),function(){let e=rt.clips;if(!0===o(e)){if(!1===o(rt.animations)){let e=[];for(let t in rt.animations){let n=f(t);for(let t=0,i=n.length;t<i;t++)e.push(n[t])}Qe.push(new pa("default",-1,e))}}else for(let t in e)Qe.push(T(t))}(),function(){let e=Object.keys(rt.kinematicsModels)[0],t=Object.keys(rt.kinematicsScenes)[0],n=Object.keys(rt.visualScenes)[0];if(void 0===e||void 0===t)return;let i=function(e){return c(rt.kinematicsModels[e],fe)}(e),r=function(e){return c(rt.kinematicsScenes[e],Se)}(t),a=He(n),s=r.bindJointAxis,o={};for(let c=0,u=s.length;c<u;c++){let e=s[c],t=We.querySelector('[sid="'+e.target+'"]');if(t){let n=t.parentElement;l(e.jointIndex,n)}}function l(e,t){let n=t.getAttribute("name"),r=i.joints[e];a.traverse((function(i){i.name===n&&(o[e]={object:i,transforms:Ee(t),joint:r,position:r.zeroPosition})}))}let h=new Ae;nt={joints:i&&i.joints,getJointValue:function(e){let t=o[e];if(t)return t.position;console.warn("THREE.ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){let n=o[e];if(n){let i=n.joint;if(t>i.limits.max||t<i.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+i.limits.min+", max: "+i.limits.max+").");else if(i.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{let r=n.object,a=i.axis,s=n.transforms;Te.identity();for(let n=0;n<s.length;n++){let r=s[n];if(r.sid&&-1!==r.sid.indexOf(e))switch(i.type){case"revolute":Te.multiply(h.makeRotationAxis(a,Yt.degToRad(t)));break;case"prismatic":Te.multiply(h.makeTranslation(a.x*t,a.y*t,a.z*t));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+i.type)}else switch(r.type){case"matrix":Te.multiply(r.obj);break;case"translate":Te.multiply(h.makeTranslation(r.obj.x,r.obj.y,r.obj.z));break;case"scale":Te.scale(r.obj);break;case"rotate":Te.multiply(h.makeRotationAxis(r.obj,r.angle))}}r.matrix.copy(Te),r.matrix.decompose(r.position,r.quaternion,r.scale),o[e].position=t}}else console.log("THREE.ColladaLoader: "+e+" does not exist.")}}}();let at=function(e){return He(s(n(e,"instance_visual_scene")[0].getAttribute("url")))}(n(We,"scene")[0]);return at.animations=Qe,"Z_UP"===Ye.upAxis&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),at.rotation.set(-Math.PI/2,0,0)),at.scale.multiplyScalar(Ye.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Qe},kinematics:nt,library:rt,scene:at}}},rH=new WeakMap,uA=class extends nr{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let r=new rr(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,i)}),n,i)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,St).catch(n)}decodeDracoFile(e,t,n,i,r=ks){let a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let n=JSON.stringify(t);if(rH.has(e)){let t=rH.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),rH.set(e,{key:n,promise:s}),s}_createGeometry(e){let t=new et;e.index&&t.setIndex(new Ct(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],r=i.name,a=i.array,s=i.itemSize,o=new Ct(a,s);"color"===r&&this._assignVertexColorSpace(o,i.vertexColorSpace),t.setAttribute(r,o)}return t}_assignVertexColorSpace(e,t){if(t!==St)return;let n=new Ie;for(let i=0,r=e.count;i<r;i++)n.fromBufferAttribute(e,i).convertSRGBToLinear(),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){let n=new rr(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{let n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let i=fat.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){let e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){let n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}};function fat(){let e,t;function n(e,t,n,i,r,a){let s=a.num_components(),o=n.num_points()*s,l=o*r.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,a,h,l,c);let u=new r(e.HEAPF32.buffer,c,o).slice();return e._free(c),{name:i,array:u,itemSize:s}}onmessage=function(i){let r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":let i=r.buffer,a=r.taskConfig;t.then((e=>{let t=e.draco,s=new t.Decoder;try{let e=function(e,t,i,r){let a,s,o=r.attributeIDs,l=r.attributeTypes,h=t.GetEncodedGeometryType(i);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,s=t.DecodeArrayToMesh(i,i.byteLength,a);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,s=t.DecodeArrayToPointCloud(i,i.byteLength,a)}if(!s.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+s.error_msg());let c={index:null,attributes:[]};for(let u in o){let i,s,h=self[l[u]];if(r.useUniqueIDs)s=o[u],i=t.GetAttributeByUniqueId(a,s);else{if(s=t.GetAttributeId(a,e[o[u]]),-1===s)continue;i=t.GetAttribute(a,s)}let d=n(e,t,a,u,h,i);"color"===u&&(d.vertexColorSpace=r.vertexColorSpace),c.attributes.push(d)}return h===e.TRIANGULAR_MESH&&(c.index=function(e,t,n){let i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);let s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,a)),e.destroy(a),c}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}var mde=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},pat=function(e){return new Worker(e)};try{URL.revokeObjectURL(mde(""))}catch(e){mde=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},pat=function(e){return new Worker(e,{type:"module"})}}var Zo=Uint8Array,Od=Uint16Array,aH=Uint32Array,gde=new Zo([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vde=new Zo([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),mat=new Zo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xde=function(e,t){for(var n=new Od(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new aH(n[30]);for(i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return[n,r]},yde=xde(gde,2),Ede=yde[0],gat=yde[1];Ede[28]=258,gat[258]=28;var bde=xde(vde,0),vat=bde[0],_Ht=bde[1],oH=new Od(32768);for(Er=0;Er<32768;++Er)eh=(61680&(eh=(52428&(eh=(43690&Er)>>>1|(21845&Er)<<1))>>>2|(13107&eh)<<2))>>>4|(3855&eh)<<4,oH[Er]=((65280&eh)>>>8|(255&eh)<<8)>>>1;var eh,VE=function(e,t,n){for(var i=e.length,r=0,a=new Od(t);r<i;++r)++a[e[r]-1];var s,o=new Od(t);for(r=0;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;if(n){s=new Od(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var h=r<<4|e[r],c=t-e[r],u=o[e[r]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)s[oH[u]>>>l]=h}else for(s=new Od(i),r=0;r<i;++r)e[r]&&(s[r]=oH[o[e[r]-1]++]>>>15-e[r]);return s},zE=new Zo(288);for(Er=0;Er<144;++Er)zE[Er]=8;for(Er=144;Er<256;++Er)zE[Er]=9;for(Er=256;Er<280;++Er)zE[Er]=7;for(Er=280;Er<288;++Er)zE[Er]=8;var Er,_de=new Zo(32);for(Er=0;Er<32;++Er)_de[Er]=5;var xat=VE(zE,9,1),yat=VE(_de,5,1),iH=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Fl=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},sH=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Eat=function(e){return(e/8|0)+(7&e&&1)},bat=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Od?Od:e instanceof aH?aH:Zo)(n-t);return i.set(e.subarray(t,n)),i},_at=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Zo(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Zo(3*i));var s=function(e){var n=t.length;if(e>n){var i=new Zo(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,h=n.b||0,c=n.l,u=n.d,d=n.m,p=n.n,f=8*i;do{if(!c){n.f=o=Fl(e,l,1);var m=Fl(e,l+1,3);if(l+=3,!m){var g=e[(A=Eat(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>i){if(a)throw"unexpected EOF";break}r&&s(h+g),t.set(e.subarray(A,v),h),n.b=h+=g,n.p=l=8*v;continue}if(1==m)c=xat,u=yat,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=Fl(e,l,31)+257,x=Fl(e,l+10,15)+4,_=y+Fl(e,l+5,31)+1;l+=14;for(var b=new Zo(_),M=new Zo(19),w=0;w<x;++w)M[mat[w]]=Fl(e,l+3*w,7);l+=3*x;var S=iH(M),E=(1<<S)-1,T=VE(M,S,1);for(w=0;w<_;){var A,C=T[Fl(e,l,E)];if(l+=15&C,(A=C>>>4)<16)b[w++]=A;else{var R=0,P=0;for(16==A?(P=3+Fl(e,l,3),l+=2,R=b[w-1]):17==A?(P=3+Fl(e,l,7),l+=3):18==A&&(P=11+Fl(e,l,127),l+=7);P--;)b[w++]=R}}var L=b.subarray(0,y),D=b.subarray(y);d=iH(L),p=iH(D),c=VE(L,d,1),u=VE(D,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var I=(1<<d)-1,O=(1<<p)-1,U=l;;U=l){var N=(R=c[sH(e,l)&I])>>>4;if((l+=15&R)>f){if(a)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if(N<256)t[h++]=N;else{if(256==N){U=l,c=null;break}var F=N-254;if(N>264){var k=gde[w=N-257];F=Fl(e,l,(1<<k)-1)+Ede[w],l+=k}var B=u[sH(e,l)&O],z=B>>>4;if(!B)throw"invalid distance";if(l+=15&B,D=vat[z],z>3&&(k=vde[z],D+=sH(e,l)&(1<<k)-1,l+=k),l>f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var V=h+F;h<V;h+=4)t[h]=t[h-D],t[h+1]=t[h+1-D],t[h+2]=t[h+2-D],t[h+3]=t[h+3-D];h=V}}n.l=c,n.p=U,n.b=h,c&&(o=1,n.m=d,n.d=u,n.n=p)}while(!o);return h==t.length?t:bat(t,0,h)},Tat=new Zo(0),wat=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function Tde(e,t){return _at((wat(e),e.subarray(2,-4)),t)}var Mat="undefined"!=typeof TextDecoder&&new TextDecoder,Sat=0;try{Mat.decode(Tat,{stream:!0}),Sat=1}catch(e){}function wde(e,t,n){let i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,a=i,s=Math.floor((r+a)/2);for(;t<n[s]||t>=n[s+1];)t<n[s]?a=s:r=s,s=Math.floor((r+a)/2);return s}function Aat(e,t,n,i){let r=[],a=[],s=[];r[0]=1;for(let o=1;o<=n;++o){a[o]=t-i[e+1-o],s[o]=i[e+o]-t;let n=0;for(let e=0;e<o;++e){let t=s[e+1],i=a[o-e],l=r[e]/(t+i);r[e]=n+t*l,n=i*l}r[o]=n}return r}function Mde(e,t,n,i){let r=wde(e,i,t),a=Aat(r,i,e,t),s=new Mn(0,0,0,0);for(let o=0;o<=e;++o){let t=n[r-e+o],i=a[o],l=t.w*i;s.x+=t.x*l,s.y+=t.y*l,s.z+=t.z*l,s.w+=t.w*i}return s}function Cat(e,t,n,i,r){let a=[];for(let u=0;u<=n;++u)a[u]=0;let s=[];for(let u=0;u<=i;++u)s[u]=a.slice(0);let o=[];for(let u=0;u<=n;++u)o[u]=a.slice(0);o[0][0]=1;let l=a.slice(0),h=a.slice(0);for(let u=1;u<=n;++u){l[u]=t-r[e+1-u],h[u]=r[e+u]-t;let n=0;for(let e=0;e<u;++e){let t=h[e+1],i=l[u-e];o[u][e]=t+i;let r=o[e][u-1]/o[u][e];o[e][u]=n+t*r,n=i*r}o[u][u]=n}for(let u=0;u<=n;++u)s[0][u]=o[u][n];for(let u=0;u<=n;++u){let e=0,t=1,r=[];for(let i=0;i<=n;++i)r[i]=a.slice(0);r[0][0]=1;for(let a=1;a<=i;++a){let i=0,l=u-a,h=n-a;u>=a&&(r[t][0]=r[e][0]/o[h+1][l],i=r[t][0]*o[l][h]);let c=u-1<=h?a-1:n-u;for(let n=l>=-1?1:-l;n<=c;++n)r[t][n]=(r[e][n]-r[e][n-1])/o[h+1][l+n],i+=r[t][n]*o[l+n][h];u<=h&&(r[t][a]=-r[e][a-1]/o[h+1][u],i+=r[t][a]*o[u][h]),s[a][u]=i;let d=e;e=t,t=d}}let c=n;for(let u=1;u<=i;++u){for(let e=0;e<=n;++e)s[u][e]*=c;c*=n-u}return s}function Pat(e,t,n,i,r){let a=r<e?r:e,s=[],o=wde(e,i,t),l=Cat(o,i,e,a,t),h=[];for(let c=0;c<n.length;++c){let e=n[c].clone(),t=e.w;e.x*=t,e.y*=t,e.z*=t,h[c]=e}for(let c=0;c<=a;++c){let t=h[o-e].clone().multiplyScalar(l[c][0]);for(let n=1;n<=e;++n)t.add(h[o-e+n].clone().multiplyScalar(l[c][n]));s[c]=t}for(let c=a+1;c<=r+1;++c)s[c]=new Mn(0,0,0);return s}function Iat(e,t){let n=1;for(let r=2;r<=e;++r)n*=r;let i=1;for(let r=2;r<=t;++r)i*=r;for(let r=2;r<=e-t;++r)i*=r;return n/i}function Dat(e){let t=e.length,n=[],i=[];for(let a=0;a<t;++a){let t=e[a];n[a]=new M(t.x,t.y,t.z),i[a]=t.w}let r=[];for(let a=0;a<t;++a){let e=n[a].clone();for(let t=1;t<=a;++t)e.sub(r[a-t].clone().multiplyScalar(Iat(a,t)*i[t]));r[a]=e.divideScalar(i[0])}return r}function Sde(e,t,n,i,r){return Dat(Pat(e,t,n,i,r))}var Gn,bi,Ta,hA=class extends Vs{constructor(e,t,n,i,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let a=0;a<n.length;++a){let e=n[a];this.controlPoints[a]=new Mn(e.x,e.y,e.z,e.w)}}getPoint(e,t=new M){let n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=Mde(this.degree,this.knots,this.controlPoints,i);return 1!==r.w&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new M){let n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Sde(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}},fA=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?ts.extractUrlBase(e):r.path,s=new rr(this.manager);s.setPath(r.path),s.setResponseType("arraybuffer"),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(n,a))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){if(Oat(e))Gn=(new pH).parse(e);else{let t=Ide(e);if(!Nat(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Rde(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Rde(t));Gn=(new fH).parse(t)}let n=new Ai(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new uH(n,this.manager).parse(Gn)}},uH=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){bi=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new hH).parse(i);return this.parseScene(i,r,n),Ta}parseConnections(){let e=new Map;return"Connections"in Gn&&Gn.Connections.connections.forEach((function(t){let n=t[0],i=t[1],r=t[2];e.has(n)||e.set(n,{parents:[],children:[]});let a={ID:i,relationship:r};e.get(n).parents.push(a),e.has(i)||e.set(i,{parents:[],children:[]});let s={ID:n,relationship:r};e.get(i).children.push(s)})),e}parseImages(){let e={},t={};if("Video"in Gn.Objects){let n=Gn.Objects.Video;for(let i in n){let r=n[i];if(e[parseInt(i)]=r.RelativeFilename||r.Filename,"Content"in r){let e=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,a="string"==typeof r.Content&&""!==r.Content;if(e||a){let e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(let n in e){let i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){let t,n=e.Content,i=e.RelativeFilename||e.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof n)return"data:"+t+";base64,"+n;{let e=new Uint8Array(n);return window.URL.createObjectURL(new Blob([e],{type:t}))}}parseTextures(e){let t=new Map;if("Texture"in Gn.Objects){let n=Gn.Objects.Texture;for(let i in n){let r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,r=e.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==r?r.value:0;if(n.wrapS=0===a?Nr:Or,n.wrapT=0===s?Nr:Or,"Scaling"in e){let t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){let t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n,i=this.textureLoader.path,r=bi.get(e.id).children;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],(0===n.indexOf("blob:")||0===n.indexOf("data:"))&&this.textureLoader.setPath(void 0));let a,s=e.FileName.slice(-3).toLowerCase();if("tga"===s){let t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new ur):(t.setPath(this.textureLoader.path),a=t.load(n))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new ur):a=this.textureLoader.load(n);return this.textureLoader.setPath(i),a}parseMaterials(e){let t=new Map;if("Material"in Gn.Objects){let n=Gn.Objects.Material;for(let i in n){let r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){let n=e.id,i=e.attrName,r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!bi.has(n))return null;let a,s=this.parseParameters(e,t,n);switch(r.toLowerCase()){case"phong":a=new es;break;case"lambert":a=new _c;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new es}return a.setValues(s),a.name=i,a}parseParameters(e,t,n){let i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new Ie).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(i.color=(new Ie).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new Ie).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(i.emissive=(new Ie).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new Ie).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new Ie).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return bi.get(n).children.forEach((function(e){let n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.colorSpace=St);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.colorSpace=St);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=Jf,i.envMap.colorSpace=St);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.colorSpace=St);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in Gn.Objects&&t in Gn.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=bi.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Gn.Objects){let n=Gn.Objects.Deformer;for(let i in n){let r=n[i],a=bi.get(parseInt(i));if("Skin"===r.attrType){let t=this.parseSkeleton(a,n);t.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=a.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){let e={id:i};e.rawTargets=this.parseMorphTargets(a,n),e.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach((function(e){let i=t[e.ID];if("Cluster"!==i.attrType)return;let r={ID:e.ID,indices:[],weights:[],transformLink:(new Ae).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let i=0;i<e.children.length;i++){let r=e.children[i],a=t[r.ID],s={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if("BlendShapeChannel"!==a.attrType)return;s.geoID=bi.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(s)}return n}parseScene(e,t,n){Ta=new Nt;let i=this.parseModels(e.skeletons,t,n),r=Gn.Objects.Model,a=this;i.forEach((function(e){let t=r[e.ID];a.setLookAtProperties(e,t),bi.get(e.ID).parents.forEach((function(t){let n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&Ta.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),Ta.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);let t=Cde(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));let s=(new dH).parse();1===Ta.children.length&&Ta.children[0].isGroup&&(Ta.children[0].animations=s,Ta=Ta.children[0]),Ta.animations=s}parseModels(e,t,n){let i=new Map,r=Gn.Objects.Model;for(let a in r){let s=parseInt(a),o=r[a],l=bi.get(s),h=this.buildSkeleton(l,e,s,o.attrName);if(!h){switch(o.attrType){case"Camera":h=this.createCamera(l);break;case"Light":h=this.createLight(l);break;case"Mesh":h=this.createMesh(l,t,n);break;case"NurbsCurve":h=this.createCurve(l,t);break;case"LimbNode":case"Root":h=new Ao;break;default:h=new Nt}h.name=o.attrName?ln.sanitizeNodeName(o.attrName):"",h.ID=s}this.getTransformData(h,o),i.set(s,h)}return i}buildSkeleton(e,t,n,i){let r=null;return e.parents.forEach((function(e){for(let a in t){let s=t[a];s.rawBones.forEach((function(t,a){if(t.ID===e.ID){let e=r;r=new Ao,r.matrixWorld.copy(t.transformLink),r.name=i?ln.sanitizeNodeName(i):"",r.ID=n,s.bones[a]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,n;if(e.children.forEach((function(e){let t=Gn.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Tt;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let i=1;void 0!==n.NearPlane&&(i=n.NearPlane.value/1e3);let r=1e3;void 0!==n.FarPlane&&(r=n.FarPlane.value/1e3);let a=window.innerWidth,s=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(a=n.AspectWidth.value,s=n.AspectHeight.value);let o=a/s,l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);let h=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new bn(l,o,i,r),null!==h&&t.setFocalLength(h);break;case 1:t=new dr(-a/2,a/2,s/2,-s/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new Tt}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){let t=Gn.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Tt;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new Ie).fromArray(n.Color.value).convertSRGBToLinear());let r=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(r=0);let a=0;void 0!==n.FarAttenuationEnd&&(a=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);let s=1;switch(e){case 0:t=new Sl(i,r,a,s);break;case 1:t=new ji(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Yt.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=Yt.degToRad(n.OuterAngle.value),o=Math.max(o,1)),t=new wc(i,r,a,e,o,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Sl(i,r)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,r=null,a=null,s=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),n.has(e.ID)&&s.push(n.get(e.ID))})),s.length>1?a=s:s.length>0?a=s[0]:(a=new es({color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new yc(r,a),i.normalizeSkinWeights()):i=new Ge(r,a),i}createCurve(e,t){let n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new Jt({color:3342591,linewidth:1});return new sn(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?Pde(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&bi.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let n=Gn.Objects.Model[t.ID];if("Lcl_Translation"in n){let t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Ta.add(e.target)):e.lookAt((new M).fromArray(t))}}}))}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let r in e){let a=e[r];bi.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;bi.get(t).parents.forEach((function(e){n.has(e.ID)&&n.get(e.ID).bind(new Co(a.bones),i[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Gn.Objects){let t=Gn.Objects.Pose;for(let n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){let i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Ae).fromArray(t.Matrix.a)})):e[i.Node]=(new Ae).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Gn&&"AmbientColor"in Gn.GlobalSettings){let e=Gn.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){let e=new Ie(t,n,i).convertSRGBToLinear();Ta.add(new Lo(e,1))}}}},hH=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Gn.Objects){let n=Gn.Objects.Geometry;for(let i in n){let r=bi.get(parseInt(i)),a=this.parseGeometry(r,n[i],e);t.set(parseInt(i),a)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let i=n.skeletons,r=[],a=e.parents.map((function(e){return Gn.Objects.Model[e.ID]}));if(0===a.length)return;let s=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));let o=a[0],l={};"RotationOrder"in o&&(l.eulerOrder=Pde(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);let h=Cde(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,n,i){let r=new et;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new tt(s.vertex,3);if(o.applyMatrix4(i),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new tt(s.colors,3)),t&&(r.setAttribute("skinIndex",new Qf(s.weightsIndices,4)),r.setAttribute("skinWeight",new tt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new Wt).getNormalMatrix(i),t=new tt(s.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(s.uvs.forEach((function(e,t){let n=0===t?"uv":`uv${t}`;r.setAttribute(n,new tt(s.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){let t=r.groups[r.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&r.addGroup(n,s.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){let n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,r=!1,a=[],s=[],o=[],l=[],h=[],c=[],u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){let t=dA(p,n,d,e.color);o.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);let e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,a=g[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;let s=e[n];e[n]=a,a=s}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}if(e.normal){let t=dA(p,n,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=dA(p,n,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let i=dA(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,m&&(i>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),u.genFace(t,e,a,f,s,o,l,h,c,i),n++,i=0,a=[],s=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,n,i,r,a,s,o,l,h){for(let c=2;c<h;c++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(c-1)]]),e.vertex.push(t.vertexPositions[n[3*(c-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(c-1)+2]]),e.vertex.push(t.vertexPositions[n[3*c]]),e.vertex.push(t.vertexPositions[n[3*c+1]]),e.vertex.push(t.vertexPositions[n[3*c+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(c-1)]),e.vertexWeights.push(o[4*(c-1)+1]),e.vertexWeights.push(o[4*(c-1)+2]),e.vertexWeights.push(o[4*(c-1)+3]),e.vertexWeights.push(o[4*c]),e.vertexWeights.push(o[4*c+1]),e.vertexWeights.push(o[4*c+2]),e.vertexWeights.push(o[4*c+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(c-1)]),e.weightsIndices.push(l[4*(c-1)+1]),e.weightsIndices.push(l[4*(c-1)+2]),e.weightsIndices.push(l[4*(c-1)+3]),e.weightsIndices.push(l[4*c]),e.weightsIndices.push(l[4*c+1]),e.weightsIndices.push(l[4*c+2]),e.weightsIndices.push(l[4*c+3])),t.color&&(e.colors.push(a[0]),e.colors.push(a[1]),e.colors.push(a[2]),e.colors.push(a[3*(c-1)]),e.colors.push(a[3*(c-1)+1]),e.colors.push(a[3*(c-1)+2]),e.colors.push(a[3*c]),e.colors.push(a[3*c+1]),e.colors.push(a[3*c+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(c-1)]),e.normal.push(r[3*(c-1)+1]),e.normal.push(r[3*(c-1)+2]),e.normal.push(r[3*c]),e.normal.push(r[3*c+1]),e.normal.push(r[3*c+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(s[n][0]),e.uvs[n].push(s[n][1]),e.uvs[n].push(s[n][2*(c-1)]),e.uvs[n].push(s[n][2*(c-1)+1]),e.uvs[n].push(s[n][2*c]),e.uvs[n].push(s[n][2*c+1])}))}addMorphTargets(e,t,n,i){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let r=this;n.forEach((function(n){n.rawTargets.forEach((function(n){let a=Gn.Objects.Geometry[n.geoID];void 0!==a&&r.genMorphGeometry(e,t,a,i,n.name)}))}))}genMorphGeometry(e,t,n,i,r){let a=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],s=void 0!==n.Vertices?n.Vertices.a:[],o=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,h=new Float32Array(l);for(let p=0;p<o.length;p++){let e=3*o[p];h[e]=s[3*p],h[e+1]=s[3*p+1],h[e+2]=s[3*p+2]}let c={vertexIndices:a,vertexPositions:h},u=this.genBuffers(c),d=new tt(u.vertex,3);d.name=r||n.attrName,d.applyMatrix4(i),e.morphAttributes.position.push(d)}parseNormals(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a,r=[];return"IndexToDirect"===n&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:t,referenceType:n}}parseUVs(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a,r=[];return"IndexToDirect"===n&&(r=e.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){let t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a,r=[];"IndexToDirect"===n&&(r=e.ColorIndex.a);for(let a=0,s=new Ie;a<i.length;a+=4)s.fromArray(i,a).convertSRGBToLinear().toArray(i,a);return{dataSize:4,buffer:i,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){let t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};let i=e.Materials.a,r=[];for(let a=0;a<i.length;++a)r.push(a);return{dataSize:1,buffer:i,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){let t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new et;let n,i,r=t-1,a=e.KnotVector.a,s=[],o=e.Points.a;for(let h=0,c=o.length;h<c;h+=4)s.push((new Mn).fromArray(o,h));if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){n=r,i=a.length-1-n;for(let e=0;e<r;++e)s.push(s[e])}let l=new hA(r,a,s,n,i).getPoints(12*s.length);return(new et).setFromPoints(l)}},dH=class{parse(){let e=[],t=this.parseClips();if(void 0!==t)for(let n in t){let i=t[n],r=this.addClip(i);e.push(r)}return e}parseClips(){if(void 0===Gn.Objects.AnimationCurve)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=Gn.Objects.AnimationCurveNode,t=new Map;for(let n in e){let i=e[n];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){let e={id:i.id,attr:i.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){let t=Gn.Objects.AnimationCurve;for(let n in t){let i={id:t[n].id,times:t[n].KeyTime.a.map(Uat),values:t[n].KeyValueFloat.a},r=bi.get(i.id);if(void 0!==r){let t=r.parents[0].ID,n=r.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=i:n.match(/Y/)?e.get(t).curves.y=i:n.match(/Z/)?e.get(t).curves.z=i:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=i)}}}parseAnimationLayers(e){let t=Gn.Objects.AnimationLayer,n=new Map;for(let i in t){let t=[],r=bi.get(parseInt(i));void 0!==r&&(r.children.forEach((function(n,i){if(e.has(n.ID)){let r=e.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[i]){let e=bi.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){let r=Gn.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);let a={modelName:r.attrName?ln.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Ta.traverse((function(e){e.ID===r.id&&(a.transform=e.matrix,e.userData.transformData&&(a.eulerOrder=e.userData.transformData.eulerOrder))})),a.transform||(a.transform=new Ae),"PreRotation"in r&&(a.preRotation=r.PreRotation.value),"PostRotation"in r&&(a.postRotation=r.PostRotation.value),t[i]=a}}t[i]&&(t[i][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[i]){let e=bi.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=bi.get(e).parents[0].ID,a=bi.get(r).parents[0].ID,s=bi.get(a).parents[0].ID,o=Gn.Objects.Model[s],l={modelName:o.attrName?ln.sanitizeNodeName(o.attrName):"",morphName:Gn.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t))}return n}parseAnimStacks(e){let t=Gn.Objects.AnimationStack,n={};for(let i in t){let r=bi.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");let a=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[],n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new pa(e.name,-1,t)}generateTracks(e){let t=[],n=new M,i=new En,r=new M;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new rn).setFromQuaternion(i,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){let i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){let n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){let n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){let n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){let r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);return new fa(e+"."+i,r,a)}generateRotationTrack(e,t,n,i,r,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Yt.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Yt.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Yt.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);void 0!==i&&((i=i.map(Yt.degToRad)).push(a),i=(new rn).fromArray(i),i=(new En).setFromEuler(i)),void 0!==r&&((r=r.map(Yt.degToRad)).push(a),r=(new rn).fromArray(r),r=(new En).setFromEuler(r).invert());let l=new En,h=new rn,c=[];for(let u=0;u<o.length;u+=3)h.set(o[u],o[u+1],o[u+2],a),l.setFromEuler(h),void 0!==i&&l.premultiply(i),void 0!==r&&l.multiply(r),l.toArray(c,u/3*4);return new zs(e+".quaternion",s,c)}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=Ta.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Ml(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let i=1;i<t.length;i++){let r=t[i];r!==n&&(t[e]=r,n=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){let i=n,r=[],a=-1,s=-1,o=-1;return e.forEach((function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(s=t.y.times.indexOf(e)),t.z&&(o=t.z.times.indexOf(e)),-1!==a){let e=t.x.values[a];r.push(e),i[0]=e}else r.push(i[0]);if(-1!==s){let e=t.y.values[s];r.push(e),i[1]=e}else r.push(i[1]);if(-1!==o){let e=t.z.values[o];r.push(e),i[2]=e}else r.push(i[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){let n=e.values[t-1],i=e.values[t]-n,r=Math.abs(i);if(r>=180){let a=r/180,s=i/a,o=n+s,l=e.times[t-1],h=(e.times[t]-l)/a,c=l+h,u=[],d=[];for(;c<e.times[t];)u.push(c),c+=h,d.push(o),o+=s;e.times=Ade(e.times,t,u),e.values=Ade(e.values,t,d)}}}},fH=class{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new mA,this.nodeStack=[],this.currentProp=[],this.currentPropName="";let t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,i){let r=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(r||a)return;let s=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),o=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");s?t.parseNodeBegin(e,s):o?t.parseNodeProperty(e,o,n[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){let n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:n},a=this.parseNodeAttr(i),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,r):n in s?("PoseNode"===n?s.PoseNode.push(r):void 0!==s[n].id&&(s[n]={},s[n][s[n].id]=s[n]),""!==a.id&&(s[n][a.id]=r)):"number"==typeof a.id?(s[n]={},s[n][a.id]=r):"Properties70"!==n&&(s[n]="PoseNode"===n?[r]:r),"number"==typeof a.id&&(r.id=a.id),""!==a.name&&(r.attrName=a.name),""!==a.type&&(r.attrType=a.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());let a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===i){let e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]),s=r.split(",").slice(3);s=s.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],Fat(r,s),void 0===a[i]&&(a[i]=[])}"Node"===i&&(a.id=r),i in a&&Array.isArray(a[i])?a[i].push(r):"a"!==i?a[i]=r:a.a=r,this.setCurrentProp(a,i),"a"===i&&","!==r.slice(-1)&&(a.a=cH(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=cH(t.a))}parseNodeSpecialProperty(e,t,n){let i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],a=i[1],s=i[2],o=i[3],l=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=cH(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},pH=class{parse(e){let t=new pA(e);t.skip(23);let n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);let i=new mA;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),s=e.getString(a);if(0===i)return null;let o=[];for(let u=0;u<r;u++)o.push(this.parseProperty(e));let l=o.length>0?o[0]:"",h=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){let i=this.parseNode(e,t);null!==i&&this.parseSubNode(s,n,i)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==h&&(n.attrName=h),""!==c&&(n.attrType=c),""!==s&&(n.name=s),n}parseSubNode(e,t,n){if(!0===n.singleProperty){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){let e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name)Object.keys(n).forEach((function(e){t[e]=n[e]}));else if("Properties70"===e&&"P"===n.name){let e,i=n.propertyList[0],r=n.propertyList[1],a=n.propertyList[2],s=n.propertyList[3];0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),e="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[i]={type:r,type2:a,flag:s,value:e}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){let t,n=e.getString(1);switch(n){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return t=e.getUint32(),e.getArrayBuffer(t);case"S":return t=e.getUint32(),e.getString(t);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":let i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(n){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}let s=Tde(new Uint8Array(e.getArrayBuffer(a))),o=new pA(s.buffer);switch(n){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+n)}}},pA=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){let t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){let e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){let e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){let e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){let e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){let e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){let e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){let t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){let t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=this.offset,n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}},mA=class{add(e,t){this[e]=t}};function Oat(e){let t="Kaydara FBX Binary \0";return e.byteLength>=21&&t===Ide(e,0,21)}function Nat(e){let t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],n=0;function i(t){let i=e[t-1];return e=e.slice(n+t),n++,i}for(let r=0;r<t.length;++r)if(i(1)===t[r])return!1;return!0}function Rde(e){let t=e.match(/FBXVersion: (\d+)/);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Uat(e){return e/46186158e3}var Bat=[];function dA(e,t,n,i){let r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);let a=r*i.dataSize,s=a+i.dataSize;return Hat(Bat,i.buffer,a,s)}var lH=new rn,n0=new M;function Cde(e){let t=new Ae,n=new Ae,i=new Ae,r=new Ae,a=new Ae,s=new Ae,o=new Ae,l=new Ae,h=new Ae,c=new Ae,u=new Ae,d=new Ae,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(n0.fromArray(e.translation)),e.preRotation){let t=e.preRotation.map(Yt.degToRad);t.push(e.eulerOrder||rn.DEFAULT_ORDER),n.makeRotationFromEuler(lH.fromArray(t))}if(e.rotation){let t=e.rotation.map(Yt.degToRad);t.push(e.eulerOrder||rn.DEFAULT_ORDER),i.makeRotationFromEuler(lH.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(Yt.degToRad);t.push(e.eulerOrder||rn.DEFAULT_ORDER),r.makeRotationFromEuler(lH.fromArray(t)),r.invert()}e.scale&&a.scale(n0.fromArray(e.scale)),e.scalingOffset&&o.setPosition(n0.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(n0.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(n0.fromArray(e.rotationOffset)),e.rotationPivot&&h.setPosition(n0.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),c.copy(e.parentMatrixWorld));let f=n.clone().multiply(i).multiply(r),m=new Ae;m.extractRotation(c);let g=new Ae;g.copyPosition(c);let v=g.clone().invert().multiply(c),y=m.clone().invert().multiply(v),x=a,_=new Ae;if(0===p)_.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)_.copy(m).multiply(y).multiply(f).multiply(x);else{let e=(new Ae).scale((new M).setFromMatrixScale(u)).clone().invert(),t=y.clone().multiply(e);_.copy(m).multiply(f).multiply(t).multiply(x)}let b=h.clone().invert(),w=s.clone().invert(),S=t.clone().multiply(l).multiply(h).multiply(n).multiply(i).multiply(r).multiply(b).multiply(o).multiply(s).multiply(a).multiply(w),E=(new Ae).copyPosition(S),T=c.clone().multiply(E);return d.copyPosition(T),S=d.clone().multiply(_),S.premultiply(c.invert()),S}function Pde(e){let t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function cH(e){return e.split(",").map((function(e){return parseFloat(e)}))}function Ide(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function Fat(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}function Hat(e,t,n,i){for(let r=n,a=0;r<i;r++,a++)e[a]=t[r];return e}function Ade(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}var Wc=class extends nr{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new EH(e)})),this.register((function(e){return new RH(e)})),this.register((function(e){return new AH(e)})),this.register((function(e){return new CH(e)})),this.register((function(e){return new _H(e)})),this.register((function(e){return new TH(e)})),this.register((function(e){return new wH(e)})),this.register((function(e){return new MH(e)})),this.register((function(e){return new yH(e)})),this.register((function(e){return new SH(e)})),this.register((function(e){return new bH(e)})),this.register((function(e){return new vH(e)})),this.register((function(e){return new PH(e)})),this.register((function(e){return new IH(e)}))}load(e,t,n,i){let r,a=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:ts.extractUrlBase(e),this.manager.itemStart(e);let s=function(t){i?i(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)},o=new rr(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{a.parse(n,r,(function(n){t(n),a.manager.itemEnd(e)}),s)}catch(e){s(e)}}),n,s)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r,a={},s={},o=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Bde){try{a[lr.KHR_BINARY_GLTF]=new DH(e)}catch(e){return void(i&&i(e))}r=JSON.parse(a[lr.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));let l=new HH(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let e=this.pluginCallbacks[h](l);s[e.name]=e,a[e.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let e=r.extensionsUsed[h],t=r.extensionsRequired||[];switch(e){case lr.KHR_MATERIALS_UNLIT:a[e]=new xH;break;case lr.KHR_DRACO_MESH_COMPRESSION:a[e]=new LH(r,this.dracoLoader);break;case lr.KHR_TEXTURE_TRANSFORM:a[e]=new OH;break;case lr.KHR_MESH_QUANTIZATION:a[e]=new NH;break;default:t.indexOf(e)>=0&&void 0===s[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){let n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}};function kat(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var lr={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},vH=class{constructor(e){this.parser=e,this.name=lr.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r,a=t.json,s=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],o=new Ie(16777215);void 0!==s.color&&o.fromArray(s.color);let l=void 0!==s.range?s.range:0;switch(s.type){case"directional":r=new ji(o),r.target.position.set(0,0,-1),r.add(r.target);break;case"point":r=new Sl(o),r.distance=l;break;case"spot":r=new wc(o),r.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,r.angle=s.spot.outerConeAngle,r.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,r.target.position.set(0,0,-1),r.add(r.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return r.position.set(0,0,0),r.decay=2,Ud(r,s),void 0!==s.intensity&&(r.intensity=s.intensity),r.name=t.createUniqueName(s.name||"light_"+e),i=Promise.resolve(r),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}},xH=class{constructor(){this.name=lr.KHR_MATERIALS_UNLIT}getMaterialType(){return Pt}extendParams(e,t,n){let i=[];e.color=new Ie(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,St))}return Promise.all(i)}},yH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}},EH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],a=i.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){let e=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Q(e,e)}return Promise.all(r)}},bH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],a=i.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(t.iridescenceIOR=a.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}},_H=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_SHEEN}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[];t.sheenColor=new Ie(0,0,0),t.sheenRoughness=0,t.sheen=1;let a=i.extensions[this.name];return void 0!==a.sheenColorFactor&&t.sheenColor.fromArray(a.sheenColorFactor),void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,St)),void 0!==a.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}},TH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],a=i.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}},wH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_VOLUME}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],a=i.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;let s=a.attenuationColor||[1,1,1];return t.attenuationColor=new Ie(s[0],s[1],s[2]),Promise.all(r)}},MH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_IOR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}},SH=class{constructor(e){this.parser=e,this.name=lr.KHR_MATERIALS_SPECULAR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Io:null}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],a=i.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));let s=a.specularColorFactor||[1,1,1];return t.specularColor=new Ie(s[0],s[1],s[2]),void 0!==a.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,St)),Promise.all(r)}},RH=class{constructor(e){this.parser=e,this.name=lr.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}},AH=class{constructor(e){this.parser=e,this.name=lr.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},CH=class{constructor(e){this.parser=e,this.name=lr.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},PH=class{constructor(e){this.name=lr.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){let n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){let t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}},IH=class{constructor(e){this.name=lr.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let i=t.meshes[n.mesh];for(let o of i.primitives)if(o.mode!==Ko.TRIANGLES&&o.mode!==Ko.TRIANGLE_STRIP&&o.mode!==Ko.TRIANGLE_FAN&&void 0!==o.mode)return null;let r=n.extensions[this.name].attributes,a=[],s={};for(let o in r)a.push(this.parser.getDependency("accessor",r[o]).then((e=>(s[o]=e,s[o]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(let a of n){let e=new Ae,t=new M,n=new En,o=new M(1,1,1),l=new Ar(a.geometry,a.material,i);for(let r=0;r<i;r++)s.TRANSLATION&&t.fromBufferAttribute(s.TRANSLATION,r),s.ROTATION&&n.fromBufferAttribute(s.ROTATION,r),s.SCALE&&o.fromBufferAttribute(s.SCALE,r),l.setMatrixAt(r,e.compose(t,n,o));for(let i in s)"TRANSLATION"!==i&&"ROTATION"!==i&&"SCALE"!==i&&a.geometry.setAttribute(i,s[i]);Tt.prototype.copy.call(l,a),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}},Bde="glTF",GE=12,Dde={JSON:1313821514,BIN:5130562},DH=class{constructor(e){this.name=lr.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,GE),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Bde)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-GE,r=new DataView(e,GE),a=0;for(;a<i;){let t=r.getUint32(a,!0);a+=4;let i=r.getUint32(a,!0);if(a+=4,i===Dde.JSON){let i=new Uint8Array(e,GE+a,t);this.content=n.decode(i)}else if(i===Dde.BIN){let n=GE+a;this.body=e.slice(n,n+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}},LH=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=lr.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,s={},o={},l={};for(let h in a){let e=BH[h]||h.toLowerCase();s[e]=a[h]}for(let h in e.attributes){let t=BH[h]||h.toLowerCase();if(void 0!==a[h]){let i=n.accessors[e.attributes[h]],r=r0[i.componentType];l[t]=r.name,o[t]=!0===i.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(let t in e.attributes){let n=e.attributes[t],i=o[t];void 0!==i&&(n.normalized=i)}t(e)}),s,l)}))}))}},OH=class{constructor(){this.name=lr.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(void 0===t.texCoord||t.texCoord===e.channel)&&void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},NH=class{constructor(){this.name=lr.KHR_MESH_QUANTIZATION}},gA=class extends ju{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=2*s,l=3*s,h=i-t,c=(n-t)/h,u=c*c,d=u*c,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+c;for(let x=0;x!==s;x++){let e=a[f+x+s],t=a[f+x+o]*h,n=a[p+x+s],i=a[p+x]*h;r[x]=v*e+y*t+m*n+g*i}return r}},Vat=new En,UH=class extends gA{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return Vat.fromArray(r).normalize().toArray(r),r}},Ko={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},r0={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Lde={9728:cr,9729:Vn,9984:ed,9985:vp,9986:Du,9987:Hs},Ode={33071:Or,33648:Nu,10497:Nr},mH={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BH={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Nd={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zat={CUBICSPLINE:void 0,LINEAR:vc,STEP:Bu},gH={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Gat(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new id({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Tr})),e.DefaultMaterial}function qE(e,t,n){for(let i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Ud(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function qat(e,t,n){let i=!1,r=!1,a=!1;for(let h=0,c=t.length;h<c;h++){let e=t[h];if(void 0!==e.POSITION&&(i=!0),void 0!==e.NORMAL&&(r=!0),void 0!==e.COLOR_0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(e);let s=[],o=[],l=[];for(let h=0,c=t.length;h<c;h++){let c=t[h];if(i){let t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;s.push(t)}if(r){let t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;o.push(t)}if(a){let t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l)]).then((function(t){let n=t[0],s=t[1],o=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=s),a&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}function Wat(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function jat(e){let t,n=e.extensions&&e.extensions[lr.KHR_DRACO_MESH_COMPRESSION];return t=n?"draco:"+n.bufferView+":"+n.indices+":"+Nde(n.attributes):e.indices+":"+Nde(e.attributes)+":"+e.mode,t}function Nde(e){let t="",n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function FH(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Xat(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}var Yat=new Ae,HH=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new kat,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Ai(this.options.manager):this.textureLoader=new ry(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new rr(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){let a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};qE(r,a,i),Ud(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let n=t[i].joints;for(let t=0,i=n.length;t<i;t++)e[n[t]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let t=e[i];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(n[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(e,t)=>{let n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(let[i,a]of e.children.entries())r(a,t.children[i])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!i)throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[lr.KHR_BINARY_GLTF].body);let i=this.options;return new Promise((function(e,r){n.load(ts.resolveURL(t.uri,i.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){let n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){let e=mH[i.type],t=r0[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new Ct(r,e,n))}let r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){let r,a,s=e[0],o=mH[i.type],l=r0[i.componentType],h=l.BYTES_PER_ELEMENT,c=h*o,u=i.byteOffset||0,d=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,p=!0===i.normalized;if(d&&d!==c){let e=Math.floor(u/d),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count,c=t.cache.get(n);c||(r=new l(s,e*d,i.count*d/h),c=new Vu(r,d/h),t.cache.add(n,c)),a=new ha(c,o,u%d/h,p)}else r=null===s?new l(i.count*o):new l(s,u,i.count*o),a=new Ct(r,o,p);if(void 0!==i.sparse){let t=mH.SCALAR,n=r0[i.sparse.indices.componentType],r=i.sparse.indices.byteOffset||0,h=i.sparse.values.byteOffset||0,c=new n(e[1],r,i.sparse.count*t),u=new l(e[2],h,i.sparse.count*o);null!==s&&(a=new Ct(a.array.slice(),a.itemSize,a.normalized));for(let e=0,i=c.length;e<i;e++){let t=c[e];if(a.setX(t,u[e*o]),o>=2&&a.setY(t,u[e*o+1]),o>=3&&a.setZ(t,u[e*o+2]),o>=4&&a.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))}loadTexture(e){let t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i],a=this.textureLoader;if(r.uri){let e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){let i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];let l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=(r.samplers||{})[a.sampler]||{};return t.magFilter=Lde[n.magFilter]||Vn,t.minFilter=Lde[n.minFilter]||Hs,t.wrapS=Ode[n.wrapS]||Nr,t.wrapT=Ode[n.wrapT]||Nr,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));let r=n.images[e],a=self.URL||self.webkitURL,s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;let t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){let t=new ur(e);t.needsUpdate=!0,n(t)}),t.load(ts.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||Xat(r.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[lr.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[lr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[lr.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new Br,Rn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new Jt,Rn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return id}loadMaterial(e){let t,n=this,i=this.json,r=this.extensions,a=i.materials[e],s={},o=[];if((a.extensions||{})[lr.KHR_MATERIALS_UNLIT]){let e=r[lr.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,n))}else{let i=a.pbrMetallicRoughness||{};if(s.color=new Ie(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==i.baseColorTexture&&o.push(n.assignTexture(s,"map",i.baseColorTexture,St)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(n.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),o.push(n.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===a.doubleSided&&(s.side=tr);let l=a.alphaMode||gH.OPAQUE;if(l===gH.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===gH.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==Pt&&(o.push(n.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new Q(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==Pt&&(o.push(n.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==Pt&&(s.emissive=(new Ie).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==Pt&&o.push(n.assignTexture(s,"emissiveMap",a.emissiveTexture,St)),Promise.all(o).then((function(){let i=new t(s);return a.name&&(i.name=a.name),Ud(i,a),n.associations.set(i,{materials:e}),a.extensions&&qE(r,i,a),i}))}createUniqueName(e){let t=ln.sanitizeNodeName(e||""),n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[lr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Ude(n,e,t)}))}let a=[];for(let s=0,o=e.length;s<o;s++){let n=e[s],o=jat(n),l=i[o];if(l)a.push(l.promise);else{let e;e=n.extensions&&n.extensions[lr.KHR_DRACO_MESH_COMPRESSION]?r(n):Ude(new et,n,t),i[o]={primitive:n,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,s=[];for(let o=0,l=a.length;o<l;o++){let e=void 0===a[o].material?Gat(this.cache):this.getDependency("material",a[o].material);s.push(e)}return s.push(t.loadGeometries(a)),Promise.all(s).then((function(n){let s=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let c=0,u=o.length;c<u;c++){let n,h=o[c],u=a[c],d=s[c];if(u.mode===Ko.TRIANGLES||u.mode===Ko.TRIANGLE_STRIP||u.mode===Ko.TRIANGLE_FAN||void 0===u.mode)n=!0===r.isSkinnedMesh?new yc(h,d):new Ge(h,d),!0===n.isSkinnedMesh&&n.normalizeSkinWeights(),u.mode===Ko.TRIANGLE_STRIP?n.geometry=LF(n.geometry,py):u.mode===Ko.TRIANGLE_FAN&&(n.geometry=LF(n.geometry,nv));else if(u.mode===Ko.LINES)n=new Dn(h,d);else if(u.mode===Ko.LINE_STRIP)n=new sn(h,d);else if(u.mode===Ko.LINE_LOOP)n=new Xg(h,d);else{if(u.mode!==Ko.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);n=new or(h,d)}Object.keys(n.geometry.morphAttributes).length>0&&Wat(n,r),n.name=t.createUniqueName(r.name||"mesh_"+e),Ud(n,r),u.extensions&&qE(i,n,u),t.assignFinalMaterial(n),l.push(n)}for(let i=0,r=l.length;i<r;i++)t.associations.set(l[i],{meshes:e,primitives:i});if(1===l.length)return l[0];let h=new Nt;t.associations.set(h,{meshes:e});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new bn(Yt.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new dr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Ud(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){let n=e.pop(),i=e,r=[],a=[];for(let s=0,o=i.length;s<o;s++){let e=i[s];if(e){r.push(e);let t=new Ae;null!==n&&t.fromArray(n.array,16*s),a.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new Co(r,a)}))}loadAnimation(e){let t=this.json.animations[e],n=t.name?t.name:"animation_"+e,i=[],r=[],a=[],s=[],o=[];for(let l=0,h=t.channels.length;l<h;l++){let e=t.channels[l],n=t.samplers[e.sampler],h=e.target,c=h.node,u=void 0!==t.parameters?t.parameters[n.input]:n.input,d=void 0!==t.parameters?t.parameters[n.output]:n.output;void 0!==h.node&&(i.push(this.getDependency("node",c)),r.push(this.getDependency("accessor",u)),a.push(this.getDependency("accessor",d)),s.push(n),o.push(h))}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(a),Promise.all(s),Promise.all(o)]).then((function(e){let t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=[];for(let n=0,l=t.length;n<l;n++){let e,l=t[n],h=i[n],c=r[n],u=a[n],d=s[n];if(void 0===l)continue;switch(l.updateMatrix(),Nd[d.path]){case Nd.weights:e=Ml;break;case Nd.rotation:e=zs;break;case Nd.position:case Nd.scale:default:e=fa}let p=l.name?l.name:l.uuid,f=void 0!==u.interpolation?zat[u.interpolation]:vc,m=[];Nd[d.path]===Nd.weights?l.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(p);let g=c.array;if(c.normalized){let e=FH(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let t=0,n=m.length;t<n;t++){let n=new e(m[t]+"."+Nd[d.path],h.array,g,f);"CUBICSPLINE"===u.interpolation&&(n.createInterpolant=function(e){return new(this instanceof zs?UH:gA)(this.times,this.values,this.getValueSize()/3,e)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),o.push(n)}}return new pa(n,void 0,o)}))}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){let t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){let t=this,n=this.json.nodes[e],i=t._loadNodeShallow(e),r=[],a=n.children||[];for(let o=0,l=a.length;o<l;o++)r.push(t.getDependency("node",a[o]));let s=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),s]).then((function(e){let t=e[0],n=e[1],i=e[2];null!==i&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(i,Yat)}));for(let r=0,a=n.length;r<a;r++)t.add(n[r]);return t}))}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];let r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",s=[],o=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&s.push(o),void 0!==r.camera&&s.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){s.push(e)})),this.nodeCache[e]=Promise.all(s).then((function(t){let s;if(s=!0===r.isBone?new Ao:t.length>1?new Nt:1===t.length?t[0]:new Tt,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(r.name&&(s.userData.name=r.name,s.name=a),Ud(s,r),r.extensions&&qE(n,s,r),void 0!==r.matrix){let e=new Ae;e.fromArray(r.matrix),s.applyMatrix4(e)}else void 0!==r.translation&&s.position.fromArray(r.translation),void 0!==r.rotation&&s.quaternion.fromArray(r.rotation),void 0!==r.scale&&s.scale.fromArray(r.scale);return i.associations.has(s)||i.associations.set(s,{}),i.associations.get(s).nodes=e,s})),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new Nt;n.name&&(r.name=i.createUniqueName(n.name)),Ud(r,n),n.extensions&&qE(t,r,n);let a=n.nodes||[],s=[];for(let o=0,l=a.length;o<l;o++)s.push(i.getDependency("node",a[o]));return Promise.all(s).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return i.associations=(e=>{let t=new Map;for(let[n,r]of i.associations)(n instanceof Rn||n instanceof ur)&&t.set(n,r);return e.traverse((e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}};function $at(e,t,n){let i=t.attributes,r=new lt;if(void 0===i.POSITION)return;{let e=n.json.accessors[i.POSITION],t=e.min,a=e.max;if(void 0===t||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new M(t[0],t[1],t[2]),new M(a[0],a[1],a[2])),e.normalized){let t=FH(r0[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}let a=t.targets;if(void 0!==a){let e=new M,t=new M;for(let i=0,r=a.length;i<r;i++){let r=a[i];if(void 0!==r.POSITION){let i=n.json.accessors[r.POSITION],a=i.min,s=i.max;if(void 0!==a&&void 0!==s){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(s[2]))),i.normalized){let e=FH(r0[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;let s=new hr;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=s}function Ude(e,t,n){let i=t.attributes,r=[];function a(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(let s in i){let t=BH[s]||s.toLowerCase();t in e.attributes||r.push(a(i[s],t))}if(void 0!==t.indices&&!e.index){let i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return Ud(e,t),$at(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?qat(e,t.targets,n):e}))}var vA=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===this.path?ts.extractUrlBase(e):this.path,s=new rr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{t(r.parse(n,a))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){let n=e.split("\n"),i={},r=/\s+/,a={};for(let o=0;o<n.length;o++){let e=n[o];if(e=e.trim(),0===e.length||"#"===e.charAt(0))continue;let t=e.indexOf(" "),s=t>=0?e.substring(0,t):e;s=s.toLowerCase();let l=t>=0?e.substring(t+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){let e=l.split(r,3);i[s]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else i[s]=l}let s=new kH(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},kH=class{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:Tr,this.wrap=void 0!==this.options.wrap?this.options.wrap:Nr}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;let t={};for(let n in e){let i=e[n],r={};t[n]=r;for(let e in i){let t=!0,n=i[e],a=e.toLowerCase();switch(a){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(t=!1)}t&&(r[a]=n)}}return t}preload(){for(let e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(let t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){let t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function r(e,n){if(i[e])return;let r=t.getTextureParams(n,i),a=t.loadTexture(function(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}(t.baseUrl,r.url));a.repeat.copy(r.scale),a.offset.copy(r.offset),a.wrapS=t.wrap,a.wrapT=t.wrap,("map"===e||"emissiveMap"===e)&&(a.colorSpace=St),i[e]=a}for(let a in n){let e,t=n[a];if(""!==t)switch(a.toLowerCase()){case"kd":i.color=(new Ie).fromArray(t).convertSRGBToLinear();break;case"ks":i.specular=(new Ie).fromArray(t).convertSRGBToLinear();break;case"ke":i.emissive=(new Ie).fromArray(t).convertSRGBToLinear();break;case"map_kd":r("map",t);break;case"map_ks":r("specularMap",t);break;case"map_ke":r("emissiveMap",t);break;case"norm":r("normalMap",t);break;case"map_bump":case"bump":r("bumpMap",t);break;case"map_d":r("alphaMap",t),i.transparent=!0;break;case"ns":i.shininess=parseFloat(t);break;case"d":e=parseFloat(t),e<1&&(i.opacity=e,i.transparent=!0);break;case"tr":e=parseFloat(t),this.options&&this.options.invertTrProperty&&(e=1-e),e>0&&(i.opacity=1-e,i.transparent=!0)}}return this.materials[e]=new es(i),this.materials[e]}getTextureParams(e,t){let n,i={scale:new Q(1,1),offset:new Q(0,0)},r=e.split(/\s+/);return n=r.indexOf("-bm"),n>=0&&(t.bumpScale=parseFloat(r[n+1]),r.splice(n,2)),n=r.indexOf("-s"),n>=0&&(i.scale.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),n=r.indexOf("-o"),n>=0&&(i.offset.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),i.url=r.join(" ").trim(),i}loadTexture(e,t,n,i,r){let a=void 0!==this.manager?this.manager:ma,s=a.getHandler(e);null===s&&(s=new Ai(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,n,i,r);return void 0!==t&&(o.mapping=t),o}},Zat=/^[og]\s*(.+)?/,Kat=/^mtllib /,Jat=/^usemtl /,Qat=/^usemap /,Fde=/\s+/,Hde=new M,VH=new M,kde=new M,Vde=new M,Jo=new M,xA=new Ie;function eot(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);let n=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){let n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){let i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){let i=this.vertices,r=this.object.geometry.normals;Hde.fromArray(i,e),VH.fromArray(i,t),kde.fromArray(i,n),Jo.subVectors(kde,VH),Vde.subVectors(Hde,VH),Jo.cross(Vde),Jo.normalize(),r.push(Jo.x,Jo.y,Jo.z),r.push(Jo.x,Jo.y,Jo.z),r.push(Jo.x,Jo.y,Jo.z)},addColor:function(e,t,n){let i=this.colors,r=this.object.geometry.colors;void 0!==i[e]&&r.push(i[e+0],i[e+1],i[e+2]),void 0!==i[t]&&r.push(i[t+0],i[t+1],i[t+2]),void 0!==i[n]&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){let i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,s,o,l){let h=this.vertices.length,c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(n,h);if(this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==s&&""!==s){let e=this.normals.length;c=this.parseNormalIndex(s,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)}else this.addFaceNormal(c,u,d);if(void 0!==i&&""!==i){let e=this.uvs.length;c=this.parseUVIndex(i,e),u=this.parseUVIndex(r,e),d=this.parseUVIndex(a,e),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";let t=this.vertices.length;for(let n=0,i=e.length;n<i;n++){let i=this.parseVertexIndex(e[n],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";let n=this.vertices.length,i=this.uvs.length;for(let r=0,a=e.length;r<a;r++)this.addVertexLine(this.parseVertexIndex(e[r],n));for(let r=0,a=t.length;r<a;r++)this.addUVLine(this.parseUVIndex(t[r],i))}};return e.startObject("",!1),e}var yA=class extends nr{constructor(e){super(e),this.materials=null}load(e,t,n,i){let r=this,a=new rr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}setMaterials(e){return this.materials=e,this}parse(e){let t=new eot;-1!==e.indexOf("\r\n")&&(e=e.replace(/\r\n/g,"\n")),-1!==e.indexOf("\\\n")&&(e=e.replace(/\\\n/g,""));let n=e.split("\n"),i=[];for(let a=0,s=n.length;a<s;a++){let e=n[a].trimStart();if(0===e.length)continue;let r=e.charAt(0);if("#"!==r)if("v"===r){let n=e.split(Fde);switch(n[0]){case"v":t.vertices.push(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])),n.length>=7?(xA.setRGB(parseFloat(n[4]),parseFloat(n[5]),parseFloat(n[6])).convertSRGBToLinear(),t.colors.push(xA.r,xA.g,xA.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));break;case"vt":t.uvs.push(parseFloat(n[1]),parseFloat(n[2]))}}else if("f"===r){let n=e.slice(1).trim().split(Fde),i=[];for(let e=0,t=n.length;e<t;e++){let t=n[e];if(t.length>0){let e=t.split("/");i.push(e)}}let r=i[0];for(let e=1,a=i.length-1;e<a;e++){let n=i[e],a=i[e+1];t.addFace(r[0],n[0],a[0],r[1],n[1],a[1],r[2],n[2],a[2])}}else if("l"===r){let n=e.substring(1).trim().split(" "),i=[],r=[];if(-1===e.indexOf("/"))i=n;else for(let e=0,t=n.length;e<t;e++){let t=n[e].split("/");""!==t[0]&&i.push(t[0]),""!==t[1]&&r.push(t[1])}t.addLineGeometry(i,r)}else if("p"===r){let n=e.slice(1).trim().split(" ");t.addPointGeometry(n)}else if(null!==(i=Zat.exec(e))){let e=(" "+i[0].slice(1).trim()).slice(1);t.startObject(e)}else if(Jat.test(e))t.object.startMaterial(e.substring(7).trim(),t.materialLibraries);else if(Kat.test(e))t.materialLibraries.push(e.substring(7).trim());else if(Qat.test(e))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===r){if(i=e.split(" "),i.length>1){let e=i[1].trim().toLowerCase();t.object.smooth="0"!==e&&"off"!==e}else t.object.smooth=!0;let n=t.object.currentMaterial();n&&(n.smooth=t.object.smooth)}else{if("\0"===e)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+e+'"')}}t.finalize();let r=new Nt;if(r.materialLibraries=[].concat(t.materialLibraries),1==!(1===t.objects.length&&0===t.objects[0].geometry.vertices.length))for(let a=0,s=t.objects.length;a<s;a++){let e=t.objects[a],n=e.geometry,i=e.materials,s="Line"===n.type,o="Points"===n.type,l=!1;if(0===n.vertices.length)continue;let h=new et;h.setAttribute("position",new tt(n.vertices,3)),n.normals.length>0&&h.setAttribute("normal",new tt(n.normals,3)),n.colors.length>0&&(l=!0,h.setAttribute("color",new tt(n.colors,3))),!0===n.hasUVIndices&&h.setAttribute("uv",new tt(n.uvs,2));let c,u=[];for(let r=0,a=i.length;r<a;r++){let e=i[r],n=e.name+"_"+e.smooth+"_"+l,a=t.materials[n];if(null!==this.materials)if(a=this.materials.create(e.name),!s||!a||a instanceof Jt){if(o&&a&&!(a instanceof Br)){let e=new Br({size:10,sizeAttenuation:!1});Rn.prototype.copy.call(e,a),e.color.copy(a.color),e.map=a.map,a=e}}else{let e=new Jt;Rn.prototype.copy.call(e,a),e.color.copy(a.color),a=e}void 0===a&&(a=s?new Jt:o?new Br({size:1,sizeAttenuation:!1}):new es,a.name=e.name,a.flatShading=!e.smooth,a.vertexColors=l,t.materials[n]=a),u.push(a)}if(u.length>1){for(let e=0,t=i.length;e<t;e++){let t=i[e];h.addGroup(t.groupStart,t.groupCount,e)}c=s?new Dn(h,u):o?new or(h,u):new Ge(h,u)}else c=s?new Dn(h,u[0]):o?new or(h,u[0]):new Ge(h,u[0]);c.name=e.name,r.add(c)}else if(t.vertices.length>0){let e=new Br({size:1,sizeAttenuation:!1}),n=new et;n.setAttribute("position",new tt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(n.setAttribute("color",new tt(t.colors,3)),e.vertexColors=!0);let i=new or(n,e);r.add(i)}return r}},EA=new Ie,bA=class extends nr{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){let r=this,a=new rr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(e){let t="",n=0,i=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(e);null!==i&&(t=i[1],n=new Blob([i[0]]).size);let r,a={comments:[],elements:[],headerLength:n,objInfo:""},s=t.split(/\r\n|\r|\n/);function o(e,t){let n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],n.name in t&&(n.name=t[n.name]),n}for(let l=0;l<s.length;l++){let e=s[l];if(e=e.trim(),""===e)continue;let t=e.split(/\s+/),n=t.shift();switch(e=t.join(" "),n){case"format":a.format=t[0],a.version=t[1];break;case"comment":a.comments.push(e);break;case"element":void 0!==r&&a.elements.push(r),r={},r.name=t[0],r.count=parseInt(t[1]),r.properties=[];break;case"property":r.properties.push(o(t,d.propertyNameMapping));break;case"obj_info":a.objInfo=e;break;default:console.log("unhandled",n,t)}}return void 0!==r&&a.elements.push(r),a}function n(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}}function i(e,t){let i={};for(let r=0;r<e.length;r++){if(t.empty())return null;if("list"===e[r].type){let a=[],s=n(t.next(),e[r].countType);for(let i=0;i<s;i++){if(t.empty())return null;a.push(n(t.next(),e[r].itemType))}i[e[r].name]=a}else i[e[r].name]=n(t.next(),e[r].type)}return i}function r(){let e={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[]};for(let t of Object.keys(d.customPropertyMapping))e[t]=[];return e}function a(e){let t=e.map((e=>e.name));function n(e){for(let n=0,i=e.length;n<i;n++){let i=e[n];if(t.includes(i))return i}return null}return{attrX:n(["x","px","posx"])||"x",attrY:n(["y","py","posy"])||"y",attrZ:n(["z","pz","posz"])||"z",attrNX:n(["nx","normalx"]),attrNY:n(["ny","normaly"]),attrNZ:n(["nz","normalz"]),attrS:n(["s","u","texture_u","tx"]),attrT:n(["t","v","texture_v","ty"]),attrR:n(["red","diffuse_red","r","diffuse_r"]),attrG:n(["green","diffuse_green","g","diffuse_g"]),attrB:n(["blue","diffuse_blue","b","diffuse_b"])}}function s(e,t){let n,s,h=r();n=null!==(s=/end_header\s+(\S[\s\S]*\S|\S)\s*$/.exec(e))?s[1].split(/\s+/):[];let c=new zH(n);e:for(let r=0;r<t.elements.length;r++){let e=t.elements[r],n=a(e.properties);for(let t=0;t<e.count;t++){let t=i(e.properties,c);if(!t)break e;l(h,e.name,t,n)}}return o(h)}function o(e){let t=new et;e.indices.length>0&&t.setIndex(e.indices),t.setAttribute("position",new tt(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new tt(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new tt(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new tt(e.colors,3)),e.faceVertexUvs.length>0&&(t=t.toNonIndexed(),t.setAttribute("uv",new tt(e.faceVertexUvs,2)));for(let n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new tt(e[n],d.customPropertyMapping[n].length));return t.computeBoundingSphere(),t}function l(e,t,n,i){if("vertex"===t){e.vertices.push(n[i.attrX],n[i.attrY],n[i.attrZ]),null!==i.attrNX&&null!==i.attrNY&&null!==i.attrNZ&&e.normals.push(n[i.attrNX],n[i.attrNY],n[i.attrNZ]),null!==i.attrS&&null!==i.attrT&&e.uvs.push(n[i.attrS],n[i.attrT]),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(EA.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(EA.r,EA.g,EA.b));for(let t of Object.keys(d.customPropertyMapping))for(let i of d.customPropertyMapping[t])e[t].push(n[i])}else if("face"===t){let t=n.vertex_indices||n.vertex_index,i=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),i&&6===i.length&&(e.faceVertexUvs.push(i[0],i[1]),e.faceVertexUvs.push(i[2],i[3]),e.faceVertexUvs.push(i[4],i[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3]))}}function h(e,t){let n={},i=0;for(let r=0;r<t.length;r++){let a=t[r],s=a.valueReader;if("list"===a.type){let t=[],r=a.countReader.read(e+i);i+=a.countReader.size;for(let n=0;n<r;n++)t.push(s.read(e+i)),i+=s.size;n[a.name]=t}else n[a.name]=s.read(e+i),i+=s.size}return[n,i]}function c(e,t,n){function i(e,t,n){switch(t){case"int8":case"char":return{read:t=>e.getInt8(t),size:1};case"uint8":case"uchar":return{read:t=>e.getUint8(t),size:1};case"int16":case"short":return{read:t=>e.getInt16(t,n),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,n),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,n),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,n),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,n),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,n),size:8}}}for(let r=0,a=e.length;r<a;r++){let a=e[r];"list"===a.type?(a.countReader=i(t,a.countType,n),a.valueReader=i(t,a.itemType,n)):a.valueReader=i(t,a.type,n)}}let u,d=this;if(e instanceof ArrayBuffer){let n=new Uint8Array(e),i=function(e){let t=0,n=!0,i="",r=[];do{let a=String.fromCharCode(e[t++]);"\n"!==a&&"\r"!==a?i+=a:("end_header"===i&&(n=!1),""!==i&&(r.push(i),i=""))}while(n&&t<e.length);return r.join("\r")+"\r"}(n),d=t(i);u="ascii"===d.format?s((new TextDecoder).decode(n),d):function(e,t){let n,i=r(),s="binary_little_endian"===t.format,u=new DataView(e,t.headerLength),d=0;for(let r=0;r<t.elements.length;r++){let e=t.elements[r],o=e.properties,p=a(o);c(o,u,s);for(let t=0;t<e.count;t++){n=h(d,o),d+=n[1];let t=n[0];l(i,e.name,t,p)}}return o(i)}(e,d)}else u=s(e,t(e));return u}},zH=class{constructor(e){this.arr=e,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}},_A=class extends nr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new rr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){function t(e,t,n){for(let i=0,r=e.length;i<r;i++)if(e[i]!==t.getUint8(n+i))return!1;return!0}let n=function(e){if("string"==typeof e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=255&e.charCodeAt(n);return t.buffer||t}return e}(e);return function(e){let n=new DataView(e);if(84+50*n.getUint32(80,!0)===n.byteLength)return!0;let i=[115,111,108,105,100];for(let r=0;r<5;r++)if(t(i,n,r))return!1;return!0}(n)?function(e){let t,n,i,r,a,s,o,l,h=new DataView(e),c=h.getUint32(80,!0),u=!1;for(let m=0;m<70;m++)1129270351==h.getUint32(m,!1)&&82==h.getUint8(m+4)&&61==h.getUint8(m+5)&&(u=!0,r=new Float32Array(3*c*3),a=h.getUint8(m+6)/255,s=h.getUint8(m+7)/255,o=h.getUint8(m+8)/255,l=h.getUint8(m+9)/255);let d=new et,p=new Float32Array(3*c*3),f=new Float32Array(3*c*3);for(let m=0;m<c;m++){let e=84+50*m,l=h.getFloat32(e,!0),c=h.getFloat32(e+4,!0),d=h.getFloat32(e+8,!0);if(u){let r=h.getUint16(e+48,!0);32768&r?(t=a,n=s,i=o):(t=(31&r)/31,n=(r>>5&31)/31,i=(r>>10&31)/31)}for(let a=1;a<=3;a++){let s=e+12*a,o=3*m*3+3*(a-1);p[o]=h.getFloat32(s,!0),p[o+1]=h.getFloat32(s+4,!0),p[o+2]=h.getFloat32(s+8,!0),f[o]=l,f[o+1]=c,f[o+2]=d,u&&(r[o]=t,r[o+1]=n,r[o+2]=i)}}return d.setAttribute("position",new Ct(p,3)),d.setAttribute("normal",new Ct(f,3)),u&&(d.setAttribute("color",new Ct(r,3)),d.hasColors=!0,d.alpha=l),d}(n):function(e){let t,n=new et,i=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,a=0,s=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+s+s+s,"g"),l=new RegExp("normal"+s+s+s,"g"),h=[],c=[],u=new M,d=0,p=0,f=0;for(;null!==(t=i.exec(e));){p=f;let e=t[0];for(;null!==(t=r.exec(e));){let e=0,n=0,i=t[0];for(;null!==(t=l.exec(i));)u.x=parseFloat(t[1]),u.y=parseFloat(t[2]),u.z=parseFloat(t[3]),n++;for(;null!==(t=o.exec(i));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),c.push(u.x,u.y,u.z),e++,f++;1!==n&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+a),3!==e&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+a),a++}let i=p,s=f-p;n.addGroup(i,s,d),d++}return n.setAttribute("position",new tt(h,3)),n.setAttribute("normal",new tt(c,3)),n}("string"!=typeof(i=e)?(new TextDecoder).decode(i):i);var i}},Vp=class{constructor(e){this.buffer=e,this.u8=new Uint8Array(e)}getBit(e){var t=7&e;return(this.u8[e>>3]&128>>t)>>7-t}setBit(e,t){var n=e>>3,i=this.u8[n],r=7&e;this.u8[n]=t?i|128>>r:i&~(128>>r)}getInt12(e){var t=e/8|0,n=this.u8[t],i=this.u8[t+1],r=this.u8[t+2],a=e%8,s=8-a,o=Math.min(12-s,8);return(((n&=~(255<<s))<<16)+((i&=255<<8-o)<<8)+(r&=255<<8-Math.max(12-s-o,0))>>12-a)-2048}setInt12(e,t){var n=e/8|0,i=e%8,r=(t+=2048)<<12-i,a=(16711680&r)>>16,s=(65280&r)>>8,o=255&r,l=8-i,h=Math.min(12-l,8),c=Math.max(12-l-h,0),u=255<<l;this.u8[n]=(this.u8[n]&u)+a;var d=~(255<<8-h);this.u8[n+1]=(this.u8[n+1]&d)+s;var p=~(255<<8-c);this.u8[n+2]=(this.u8[n+2]&p)+o}getInt6(e){var t=e/8|0,n=this.u8[t],i=this.u8[t+1],r=e%8,a=8-r;return(((n&=~((255<<a)+(255>>8-(2-r))))<<8)+(i&=255<<8-Math.max(6-a,0))>>10-r)-32}setInt6(e,t){var n=e/8|0,i=e%8,r=(t+=32)<<10-i,a=(65280&r)>>8,s=255&r,o=8-i,l=Math.max(6-o,0),h=(255<<o)+(255>>8-(2-i));this.u8[n]=(this.u8[n]&h)+a;var c=~(255<<8-l);this.u8[n+1]=(this.u8[n+1]&c)+s}test(){var e,t,n=new ArrayBuffer(3),i=new Vp(n);for(t=0;t<12;t++)for(e=-2048;e<2048;e++)if(i.setInt12(t,e),i.getInt12(t)!=e){console.log("12-bit prob at",t,e),console.log("expected",e,"got",i.getInt12(t));break}for(t=0;t<18;t++)for(e=-32;e<32;e++)if(i.setInt6(t,e),i.getInt6(t)!=e){console.log("6-bit prob at",t,e),console.log("expected",e,"got",i.getInt6(t));break}return i}},zde=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(zde||{}),TA=class{parse(e){var t={},n=new DataView(e),i=0;if(t.fileCode=n.getInt32(i,!1),9994!=t.fileCode)throw new Error("Unknown file code: "+t.fileCode);for(i+=24,t.wordLength=n.getInt32(i,!1),t.byteLength=2*t.wordLength,i+=4,t.version=n.getInt32(i,!0),i+=4,t.shapeType=n.getInt32(i,!0),i+=4,t.minX=n.getFloat64(i,!0),t.minY=n.getFloat64(i+8,!0),t.maxX=n.getFloat64(i+16,!0),t.maxY=n.getFloat64(i+24,!0),t.minZ=n.getFloat64(i+32,!0),t.maxZ=n.getFloat64(i+40,!0),t.minM=n.getFloat64(i+48,!0),t.maxM=n.getFloat64(i+56,!0),i+=64,t.records=[];i<t.byteLength;){var r={};r.number=n.getInt32(i,!1),i+=4,r.length=n.getInt32(i,!1),i+=4;try{r.shape=this.parseShape(n,i,r.length)}catch(e){console.log(e,r)}i+=2*r.length,t.records.push(r)}return t}parseShape(e,t,n){var i=0,r=null,a={};switch(a.type=e.getInt32(t,!0),t+=4,a.type){case 0:break;case 1:a.content={x:e.getFloat64(t,!0),y:e.getFloat64(t+8,!0)};break;case 3:case 5:for(r=a.content={minX:e.getFloat64(t,!0),minY:e.getFloat64(t+8,!0),maxX:e.getFloat64(t+16,!0),maxY:e.getFloat64(t+24,!0),parts:new Int32Array(e.getInt32(t+32,!0)),points:new Float64Array(2*e.getInt32(t+36,!0))},t+=40,i=0;i<r.parts.length;i++)r.parts[i]=e.getInt32(t,!0),t+=4;for(i=0;i<r.points.length;i++)r.points[i]=e.getFloat64(t,!0),t+=8;break;case 8:case 11:case 13:case 15:case 18:case 21:case 23:case 25:case 28:case 31:throw new Error("Shape type not supported: "+a.type+":"+ +a.type);default:throw new Error("Unknown shape type at "+(t-4)+": "+a.type)}return a}},wA=class{constructor(){this.LINE_MATERIAL=new Jt({color:0,linewidth:2,opacity:.8,transparent:!0}),this.MESH_MATERIAL=new Pt({color:1926655,opacity:.8,transparent:!0})}createModel(e){for(var t=[],n=[],i=0;i<e.records.length;i++){var r=e.records[i].shape;if(3===r.type||5===r.type)for(var a=r.content.points,s=r.content.parts,o=0;o<s.length;o++){let e=[];for(var l=s[o],h=s[o+1]||a.length/2;l<h;l++){var c=a[2*l],u=a[2*l+1];e.push(new M(c,u,0))}if(5===r.type){let i=Wi.triangulateShape(e,[]),r=[];i.forEach((e=>r.push(...e)));let a=new et;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new et;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),n.push(s)}else{let t=new et;t.setFromPoints(e),n.push(t)}}}var d=new Tt;for(i=0;i<n.length;i++)d.add(new sn(n[i],this.LINE_MATERIAL));for(i=0;i<t.length;i++)d.add(new Ge(t[i],this.MESH_MATERIAL));return console.log("parsed",t.length,n.length),d}loadCompressed(e){for(var t=this.deltaDecode6(e),n=[],i=[],r=0;r<t.length;r++){let e=[];if(-32768!==t[r]){var a=180*t[r]/32767,s=180*t[r+1]/32767;r++,e.push(new M(a,s,0))}else{for(var o=[],l=1;l<e.length;l++)e[l-1].x==e[l].x&&e[l-1].y==e[l].y||o.push(e[l]);let t=new et;t.setFromPoints(o),n.push(t),e=[]}}var h=new Tt;for(r=0;r<i.length;r++)h.add(new sn(i[r],this.LINE_MATERIAL));for(r=0;r<n.length;r++)h.add(new Ge(n[r],this.MESH_MATERIAL));return console.log("parsed compressed",n.length,i.length),h}compress(e){for(var t=[],n=0;n<e.records.length;n++){var i=e.records[n].shape;if(5===i.type)for(var r=i.content.points,a=i.content.parts,s=0;s<a.length;s++){for(var o=a[s],l=a[s+1]||r.length/2;o<l;o++){var h=r[2*o],c=r[2*o+1];t.push(h/180*32767,c/180*32767)}t.push(-32768)}}var u=new Int16Array(t);console.log("16-bit quantized byteLength",u.buffer.byteLength);var d=this.deltaEncode6(u);return console.log("delta-encoded byteLength",d.byteLength),d}deltaEncode(e){for(var t=[],n=[],i=[],r=0,a=0,s=0,o=0;o<e.length;o++)-32768!=e[o]?0==i.length?(r=e[o],a=e[o+1],i.push(r,a),s+=4,o++):Math.abs(r-e[o])>1023||Math.abs(a-e[o+1])>1023?(n.push(i),s+=1,i=[],r=e[o],a=e[o+1],i.push(r,a),s+=4,o++):(i.push((e[o]-r)/8,(e[o+1]-a)/8),r+=8*((e[o]-r)/8|0),a+=8*((e[o+1]-a)/8|0),s+=2,o++):(n.push(i),t.push(n),n=[],i=[],s+=3);return this.storeDeltas(s,t)}deltaEncode6(e){var t=[],n=[],i=[],r=0,a=0,s=0,o=0;for(s=0;s<e.length;s++)e[s]=0|e[s]/16;for(s=0;s<e.length;s++)-2048!==e[s]?0==i.length?(r=e[s],a=e[s+1],i.push(r,a),o+=4,s++):Math.abs(r-e[s])>31||Math.abs(a-e[s+1])>31?(n.push(i),o+=1,i=[],r=e[s],a=e[s+1],i.push(r,a),o+=4,s++):(i.push(e[s]-r,e[s+1]-a),r+=e[s]-r,a+=e[s+1]-a,o+=2,s++):(n.push(i),t.push(n),n=[],i=[],o+=3);return this.storeDeltas6(o,t)}storeDeltas(e,t){for(var n=new ArrayBuffer(e),i=new DataView(n),r=0,a=0;a<t.length;a++){for(var s=t[a],o=0;o<s.length;o++){var l=s[o];i.setInt16(r,l[0]),r+=2,i.setInt16(r,l[1]),r+=2;for(var h=2;h<l.length;h++)i.setInt8(r++,l[h]);i.setInt8(r,-128),r+=1}i.setInt16(r,-32768),r+=2}return n}deltaDecode(e){for(var t=new DataView(e),n=0,i=[];n<e.byteLength;){var r=t.getInt16(n);if(n+=2,-32768!==r){var a=t.getInt16(n);for(n+=2,i.push(r,a);n<e.byteLength;){var s=t.getInt8(n);if(n++,-128==s)break;var o=t.getInt8(n);n++,r+=8*s,a+=8*o,i.push(r,a)}}else i.push(-32768)}return i}storeDeltas6(e,t){for(var n=new ArrayBuffer(Math.ceil(.75*e)+4),i=new Vp(n),r=32,a=0;a<t.length;a++){for(var s=t[a],o=0;o<s.length;o++){var l=s[o];i.setInt12(r,l[0]),r+=12,i.setInt12(r,l[1]),r+=12;for(var h=2;h<l.length;h++)i.setInt6(r,l[h]),r+=6;i.setInt6(r,-32),r+=6}i.setInt12(r,-2048),r+=12}return new DataView(n).setUint32(0,r),n}deltaDecode6(e){for(var t=new DataView(e).getUint32(0),n=new Vp(e),i=32,r=[];i<t;){var a=n.getInt12(i);if(i+=12,-2048!==a){var s=n.getInt12(i);for(i+=12,r.push(a,s);i<t;){var o=n.getInt6(i);if(i+=6,-32===o)break;var l=n.getInt6(i);i+=6,a+=o,s+=l,r.push(a,s)}}else r.push(-2048)}for(var h=0;h<r.length;h++)r[h]*=16;return r}},MA=class{load(e,t,n,i){return $e(this,null,(function*(){this.updateProgress(n,0);let r=new XMLHttpRequest;r.responseType="arraybuffer",r.onload=()=>{this.updateProgress(n,50);let e=(new TA).parse(r.response),i=(new wA).createModel(e);this.updateProgress(n,99),t(i)},r.onerror=i,r.open("GET",e),r.send(null)}))}updateProgress(e,t){e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:t,total:100}))}},GH=class{constructor(e){this.manager=e}loadLocalModel(e,t,n){return $e(this,null,(function*(){let i=t.toLowerCase();return i.endsWith("fbx")?this.loadFbx(e,n):i.endsWith("obj")?this.loadObj(e,n):i.endsWith("stl")?this.loadStl(e,n):i.endsWith("ifc")?($.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"),Promise.reject("Not supported!")):i.endsWith("shp")?this.loadShp(e,n):i.endsWith("dae")?this.loadDae(e,n):i.endsWith("dxf")?this.loadDxf(e,n):i.endsWith("jpg")||i.endsWith("jpeg")||i.endsWith("png")?this.loadImage(e,n):this.loadGltf(e,n)}))}loadModel(e,t,n){return $e(this,null,(function*(){let i=e;if(!i)return Promise.resolve();let r=(null==t?void 0:t.toLowerCase())||"";if(!r){let e=i.split("?")[0].toLowerCase();if(e){let t=e.lastIndexOf(".");-1!==t&&(r=e.slice(t+1))}}return r.endsWith("fbx")?this.loadFbx(i,n):r.endsWith("obj")?this.loadObj(i,n):r.endsWith("stl")?this.loadStl(i,n):r.endsWith("ifc")?void $.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"):r.endsWith("shp")?this.loadShp(i,n):r.endsWith("dae")?this.loadDae(i,n):r.endsWith("dxf")?this.loadDxf(i,n):r.endsWith("jpg")||r.endsWith("jpeg")||r.endsWith("png")?this.loadImage(i,n):this.loadGltf(i,n)}))}loadGltf(e,t){return $e(this,null,(function*(){let n=this.getGltfLoader();-1!==e.indexOf("#")&&console.warn(`[LoadingHelper] '#' is not allowed in filename ${e}`),e=e.replace(/#/g,encodeURIComponent("#"));let i=yield n.loadAsync(e,t);return Promise.resolve(i.scene)}))}parseGltf(e,t,n,i){return this.getGltfLoader().parse(e,t,(e=>n(e.scene)),i)}loadFbx(e,t){return $e(this,null,(function*(){let n=yield new fA(this.manager).loadAsync(e,t);return Promise.resolve(n)}))}loadObj(e,t){return $e(this,null,(function*(){let n=new yA(this.manager),i=new vA(this.manager),r=e.replace(".obj",".mtl"),a=yield i.loadAsync(r,t);a.preload(),n.setMaterials(a);let s=yield n.loadAsync(e,t);return Promise.resolve(s)}))}loadStl(e,t){return $e(this,null,(function*(){let n=yield new _A(this.manager).loadAsync(e,t);return Promise.resolve(new Ge(n))}))}loadShp(e,t){return $e(this,null,(function*(){let n=new MA;return new Promise(((i,r)=>{n.load(e,(e=>{i(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return $e(this,null,(function*(){let n=yield new cA(this.manager).loadAsync(e,t);return Promise.resolve(n.scene)}))}loadDxf(e,t){return $e(this,null,(function*(){var n;this.font||console.warn("[LoadingHelper] Should set font first!");let i=new Dt(this.manager,!0,!1);i.setFont(this.font);try{this.font&&this.font.getFontData&&(yield null==(n=this.font)?void 0:n.getFontData());let r=yield i.loadAsync(e,t);return Promise.resolve(r.threejsObject)}catch(e){let n=new ErrorEvent("");return Promise.reject(n)}}))}loadPly(e,t){return $e(this,null,(function*(){let n=yield new bA(this.manager).loadAsync(e,t);return Promise.resolve(new Ge(n))}))}loadImage(e,t){return $e(this,null,(function*(){let n=yield new Ai(this.manager).loadAsync(e,t);if(!n)return Promise.reject("Failed to load image!");let i=n.image,r=i&&i.height||10,a=i&&i.width||10;r*=10/a,a=10;let s=new Pt({map:n,side:tr,transparent:!0}),o=new Ur(a,r),l=new Ge(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,n,i,r,a,s){return $e(this,null,(function*(){var o;this.font||console.warn("[LoadingHelper] Should set font first!");let l=new Dt(this.manager,r,a,s);return l.setFont(this.font),l.manager.onLoad=()=>{i&&i()},this.font&&this.font.getFontData&&(yield null==(o=this.font)?void 0:o.getFontData()),l.load(e,t,n)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new Wc(this.manager);let e=new uA(this.manager);e.setDecoderPath(GH.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},Ks=GH;Ks.decoderPath="three/js/libs/draco/gltf/";var SA,Bd=class{constructor(e){this.running=!1,this.workers=[];let t=1;e?t=e:window.navigator&&(t=Math.max(t,window.navigator.hardwareConcurrency-1));for(let n=0;n<t;n++)this.workers[n]=new JS}isRunning(){return this.running}generate(e){return $e(this,arguments,(function*(e,t={}){if(this.running)$.warn("[BVHHelper] Already running job.");else{if(0!==this.workers.length)return this.running=!0,new Promise((n=>{let i=this.workers.length,r=e.length,a=[],s=Math.floor(r/i),o=r%i,l=0,h=0;for(let c=0;c<i;c++){let n=this.workers[c];if(c<o?(l=c*s+c,h=l+s+1):(l=c*s+o,h=l+s),l=Math.min(l,r),h=Math.min(h,r),l>=h)break;$.debug("startIndex: "+l+" endIndex: "+h),a.push(n.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,n()}))}));$.warn("[BVHHelper] Worker has been disposed.")}}))}dispose(){for(let e=0;e<this.workers.length;e++)this.workers[e].dispose();this.workers=[]}static createMeshBvhSync(e,t={}){let n=new Set;e.forEach((e=>{e.traverse((e=>{let i=e;if(i.isMesh&&i.geometry&&gr.isMergedMesh(i)&&!(i instanceof Ar)){if(n.has(i.geometry.id))return;i.geometry.index&&t.saveOriginalIndex&&(i.geometry.userData.originalIndex=i.geometry.index.array.slice()),i.geometry.boundsTree=new Al(i.geometry,t),n.add(i.geometry.id)}}))}))}static createMeshBvhAsync(e,t={}){let n=new Set,i=[];e.forEach((e=>{e.traverse((e=>{let t=e;if(t.isMesh&&t.geometry&&gr.isMergedMesh(t)&&!(t instanceof Ar)){if(n.has(t.geometry.id))return;i.push(t.geometry),n.add(t.geometry.id)}}))}));let r=new Bd;r.generate(i,t).then((()=>{r.dispose()}))}},Gde=class{constructor(e,t,n,i,r){this.targetPixelHeight=100,this.canvasHeight=800,this.camera=e,this.object=n,this.targetPixelHeight=i,this.canvasHeight=r,this.adjustSize(),t.addEventListener("update",(()=>{this.adjustSize()}))}adjustSize(){let e=new lt;if(this.object.updateMatrix(),e.expandByObject(this.object),!e)return;let t=e.max.x-e.min.x,n=this.camera.position.distanceTo(this.object.position),i=tot(t,n,this.canvasHeight);if(Math.abs(i-this.targetPixelHeight)<5)return;let r=this.object.scale.x;r*=this.targetPixelHeight/i,this.object.scale.set(r,r,r),this.object.updateMatrix()}},tot=(e,t,n=800,i=45)=>{let r=i*(Math.PI/180);return n*(e/(2*Math.tan(r/2)*t))},Es=class extends ns{constructor(e){super(it.guid()),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.snapType="Dot",this.snapLineVisible=!1,this.snapType=e,this.drawSnapFunctions={Dot:this.drawDot.bind(this),Square:this.drawSquare.bind(this),Triangle:this.drawTriangle.bind(this),CircleWithCross:this.drawCircleWithCross.bind(this),Cross:this.drawCross.bind(this),Perpendicular:this.drawPerpendicular.bind(this)}}setSnapLineVisible(e){this.snapLineVisible=e}draw(e,t){this.osnapInfo&&(this.snapLineVisible&&this.drawSnapLine(e,t),e.save(),e.fillStyle=Es.FILL_COLOR,e.strokeStyle=Es.LINE_COLOR,e.lineWidth=Es.LINE_WIDTH,"CircleWithCross"===this.snapType&&(e.fillStyle=Es.FILL_COLOR_NONE,e.lineWidth=Es.LINE_WIDTH_1),e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),SA&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==SA||SA.forEach((n=>{let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y)}))}drawSelect(e,t){}isPointInPath(e){return!1}drawSnapLine(e,t){e.save(),e.strokeStyle=Es.SNAP_LINE_COLOR,e.lineWidth=Es.LINE_WIDTH;let n=this.osnapInfo.line;if(!n)return;let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y),e.stroke(),e.restore()}drawDot(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t);e.arc(n.x,n.y,Es.SNAP_ICON_SIZE/3,0,2*Math.PI)}drawSquare(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=Es.SNAP_ICON_SIZE/1.2,r=Es.SNAP_ICON_SIZE/1.2;e.rect(n.x-i/2,n.y-r/2,i,r)}drawTriangle(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=Es.SNAP_ICON_SIZE/1.2/2,r=new Q(0,-i).add(n),a=new Q(-.87*i,i/2).add(n),s=new Q(.87*i,i/2).add(n);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.lineTo(s.x,s.y),e.closePath()}drawCircleWithCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=Es.SNAP_ICON_SIZE/1.2;e.arc(n.x,n.y,i,0,2*Math.PI),e.moveTo(n.x-i/1.8,n.y),e.lineTo(n.x+i/1.8,n.y),e.moveTo(n.x,n.y-i/1.8),e.lineTo(n.x,n.y+i/1.8)}drawCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=Es.SNAP_ICON_SIZE/1.2/2,r=new Q(-i,-i).add(n),a=new Q(i,i).add(n),s=new Q(i,-i).add(n),o=new Q(-i,i).add(n);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y)}drawPerpendicular(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=Es.SNAP_ICON_SIZE/1.2/2;[new Q(0,0).add(n),new Q(-i,0).add(n),new Q(0,0).add(n),new Q(0,i).add(n),new Q(i,i).add(n),new Q(-i,i).add(n),new Q(-i,i).add(n),new Q(-i,-i).add(n)].forEach(((t,n)=>{0===n?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}))}update(e){this.osnapInfo=e}getClassType(){return"SnapDrawable"}},bs=Es;bs.LINE_COLOR="rgba(255, 240, 0, 0.8)",bs.FILL_COLOR="rgba(135, 206, 250, 0.5)",bs.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",bs.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",bs.LINE_WIDTH_1=.8,bs.LINE_WIDTH=2.5,bs.SNAP_ICON_SIZE=10,$t._registerDrawableClass(bs);var not=(e=>(e[e.None=0]="None",e[e.PointOnLine=1]="PointOnLine",e[e.StartPoint=2]="StartPoint",e[e.EndPoint=4]="EndPoint",e[e.MiddlePoint=8]="MiddlePoint",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(not||{}),rot=1e-5,RA=class{constructor(e){var t;this.drawableList=new Pl("snap"),this.markers={},this.activeOSnapType=0,this.snapTolerance=1,this.overlayRender=e,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList),this.initOSnapMarkers()}initOSnapMarkers(){let e=new bs("Dot"),t=new bs("Square"),n=new bs("Triangle"),i=new bs("CircleWithCross"),r=new bs("Cross"),a=new bs("Perpendicular");this.markers[2]=t,this.markers[4]=t,this.markers[8]=n,this.markers[1]=e,this.markers[32]=r,this.markers[64]=i,this.markers[16]=a,Object.values(this.markers).forEach((e=>{e.visible=!1,this.drawableList.addDrawable(e)}))}updateSnapTolerance(e){this.snapTolerance=e}getSnapTolerance(){return this.snapTolerance}getMarker(e){return this.markers[e]}deactivate(){this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=0}destroy(){}handleSnap(e,t,n,i){if(null==t||!t.length)return void this.activateMarker(0);let r=this.getIntersectionPointsAndLines(e,t,n);if(r){let t=this.getSnapInfo(e,r,i);return t&&0!==t.type?(this.activateMarker(t.type,n,t),t.point):void this.activateMarker(0)}this.activateMarker(0)}activateMarker(e,t=!1,n){var i;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=e;let r=this.markers[e];r&&n&&(r.setSnapLineVisible(t),r.update(n),r.visible=!0),null==(i=this.overlayRender)||i.render()}getFootOfPerpendicular(e,t,n=rot){let{start:i,end:r}=t,a=i.x-r.x,s=i.y-r.y,o=i.z-r.z;if(i.distanceTo(r)<n)return i.clone();let l=(e.x-i.x)*(i.x-r.x)+(e.y-i.y)*(i.y-r.y)+(e.z-i.z)*(i.z-r.z);return l/=a*a+s*s+o*o,new M(i.x+l*a,i.y+l*s,i.z+l*o)}getIntersectionPointsAndLines(e,t,n){if(!t.length)return;let i=[],r=new lt;r.setFromCenterAndSize(e,new M(1,1,1).multiplyScalar(5*this.snapTolerance));let a=new lt;for(let s=0;s<t.length;s++){let e=t[s],o=e.object;if(o instanceof sn){let e=o instanceof Dn?2:1,t=o.geometry.index,s=o.geometry.attributes.position;if(t)for(let l=0,h=t.count;l<h-1;l+=e){let e=t.getX(l),h=t.getX(l+1),c=new M,u=new M;c.fromBufferAttribute(s,e),u.fromBufferAttribute(s,h),c.applyMatrix4(o.matrixWorld),u.applyMatrix4(o.matrixWorld),n||(c.setZ(0),u.setZ(0)),a.setFromPoints([c,u]),r.intersectsBox(a)&&i.push({start:c,end:u})}else for(let l=1,h=s.count;l<h;l+=e){let e=new M,t=new M;e.fromBufferAttribute(s,l-1),t.fromBufferAttribute(s,l),e.applyMatrix4(o.matrixWorld),t.applyMatrix4(o.matrixWorld),n||(e.setZ(0),t.setZ(0)),a.setFromPoints([e,t]),r.intersectsBox(a)&&i.push({start:e,end:t})}}else if(o instanceof or){let t=o.geometry.getAttribute("position"),r=t.array,a=t.itemSize,s=(e.index||0)*a,l=r.itemSize>2?r[s+2]:0,h=new M(r[s],r[s+1],l);h.applyMatrix4(o.matrixWorld),n||h.setZ(0),"CircleCenter"===o.userData.type?i.push(h):i.push({start:h,end:h})}}return i}getSnapInfo(e,t,n){let i,r=[];for(let a of t)if(a instanceof M){let t=e.distanceTo(a);t<2*this.snapTolerance&&r.push({distance:t,type:64,point:a})}else{let t=a,{start:s,end:o}=t;if(n){let i=this.getFootOfPerpendicular(n,t,this.snapTolerance),a=e.distanceTo(i);if(a<this.snapTolerance){r.push({distance:wt.floorNumber(a,7),type:16,point:i,line:t});continue}}let l=e.distanceTo(s),h=e.distanceTo(o);if(l<this.snapTolerance){r.push({distance:wt.floorNumber(l,7),type:2,point:s,line:t});continue}if(h<this.snapTolerance){r.push({distance:wt.floorNumber(h,7),type:4,point:o,line:t});continue}if(xt.isPointOnLineSegment(e,t,this.snapTolerance)){let n=o.clone().add(s).multiplyScalar(.5),a=n.distanceTo(e);if(a<this.snapTolerance){r.push({point:n,distance:wt.floorNumber(a,7),type:8,line:t});continue}if(i){let n=xt.getLineSegmentsIntersectingPoint(i,t);if(n){let a=e.distanceTo(n)/2;if(a<this.snapTolerance){r.push({point:n,distance:wt.floorNumber(a,7),type:32,line:t}),i=void 0;continue}continue}}else{let n=this.getFootOfPerpendicular(e,t,this.snapTolerance),a=e.distanceTo(n);if(a<this.snapTolerance){r.push({point:n,distance:wt.floorNumber(a,7),type:1,line:t}),i=t;continue}}}}return r=r.sort(((e,t)=>t.type-e.type)),r[0]}},AA=class{constructor(e){this.actived=!1,this.isResolvedOrRejected=!1,this.mouseClicked=e=>{var t;if(e.markupData){let n=e.markupData.id,i=null==(t=this.viewer.overlayRender)?void 0:t.getDrawableById(n);if(i){let e=i.getBounds();e=e.clone().expandByScalar(20*this.viewer.getPixelSizeInWorldCoord());let t=nn.worldCoordinate2NormalizedScreenCoordinate(e.min,this.camera,this.viewerContainer),n=nn.worldCoordinate2NormalizedScreenCoordinate(e.max,this.camera,this.viewerContainer),r=new si(new Q(Math.min(t.x,n.x),Math.min(t.y,n.y)),new Q(Math.max(t.x,n.x),Math.max(t.y,n.y)));r.min.x=Math.max(r.min.x,0)*this.viewerContainer.clientWidth,r.min.y=Math.max(r.min.y,0)*this.viewerContainer.clientHeight,r.max.x=Math.min(r.max.x,1)*this.viewerContainer.clientWidth,r.max.y=Math.min(r.max.y,1)*this.viewerContainer.clientHeight,this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate(),this.viewer.clearSelection()}}},this.viewer=e}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}isActived(){return this.actived}activate(){var e;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked);let t=this.viewer.translate;if(t){this.tooltip=new Yo("pick-markup-tooltip",t("Tooltip.pickMarkup"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let n=document.getElementById("pick-markup-tooltip");n&&(n.style.pointerEvents="none");let i=t("Tooltip.pickMarkup");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}this.viewer.dispatchEvent("PickMarkupActivated")}deactivate(){var e,t;this.actived=!1,this.viewer.removeEventListener("MouseClicked",this.mouseClicked),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.viewer.dispatchEvent("PickMarkupDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}pick(){return $e(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){this.deactivate(),this.isResolvedOrRejected||this.reject&&this.reject("PickMarkupHelper is not done for some reason!")}},CA=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.actived=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,n;if(0===e.button){this.mouseDown=!0;let i=new Q(e.x,e.y);this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}},this.mousemove=e=>{if(!this.mouseDown)return;let t=new Q(e.x,e.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(t.x-this.mouseDownPositionX)>=5||Math.abs(t.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;let e=new Q(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new Q(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y));this.drawRect(e,n)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){let t=new Q(e.x,e.y),n=new Q(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new Q(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new si(n,i);this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate(),this.setRectDomVisible(!1)}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.viewer=e,this.input=e.getInputManager()}get viewerContainer(){return this.viewer.viewerContainer}isActived(){return this.actived}activate(){var e;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup);let t=this.viewer.controls;this.tempKey=t.mouseButtons.left,this.tempEnableRotate=t.enableRotate,t.mouseButtons.left=Ve.NONE,this.tempTouch=t.touches.one,t.touches.one=Ve.NONE,t.enableRotate=!1;let n=this.viewer.translate;if(n){this.tooltip=new Yo("box-select-tooltip",n("Tooltip.boxSelect"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let t=document.getElementById("box-select-tooltip");t&&(t.style.pointerEvents="none");let i=n("Tooltip.boxSelect");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}this.viewer.dispatchEvent("BoxSelectActivated")}deactivate(){var e,t;this.actived=!1,this.input.removeEventListener("pointerdown",this.mousedown),this.input.removeEventListener("pointermove",this.mousemove),this.input.removeEventListener("pointerup",this.mouseup),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.enableRotate=this.tempEnableRotate,this.viewer.controls.touches.one=this.tempTouch,this.viewer.dispatchEvent("BoxSelectDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}drawRect(e,t){this.rectDom||(this.rectDom=document.createElement("div"),this.rectDom.style.cssText=`position: absolute;border: ${CA.BORDER_WIDTH} solid ${CA.BORDER_COLOR};`,this.viewerContainer.appendChild(this.rectDom)),this.setRectDomVisible(!0),this.rectDom.style.left=`${e.x}px`,this.rectDom.style.top=`${e.y}px`;let n=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);this.rectDom.style.width=`${n}px`,this.rectDom.style.height=`${i}px`}setRectDomVisible(e){this.rectDom&&(this.rectDom.style.display=e?"inline-block":"none")}select(){return $e(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){var e;this.deactivate(),null==(e=this.rectDom)||e.remove(),this.rectDom=void 0,this.isResolvedOrRejected||this.reject&&this.reject("BoxSelectHelper is not done for some reason!")}},Fd=CA;Fd.BORDER_COLOR="#fff000",Fd.BORDER_WIDTH="2px";var i0=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(i0||{}),Hd=class extends Xi{constructor(e){super(),this.name="BaseViewer",this.translate=this.initLocalization(),this.height=0,this.width=0,this.jobCount=0,this.enableOverlayRenderer=!0,this.viewerCfg=e,this.undoRedoManager=new _R,this.initLogLevel(),this.initLocalization(),tn.isBrowser&&!e.context&&(this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&kle(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return UE.init({lng:t,debug:!1,resources:{en:{translation:dce},cn:{translation:fce}}}),UE.t}initViewerContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||($.error("[BaseViewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("viewer-container"),t.style.cssText="display: inline-block;position: relative; overflow: hidden;",e.appendChild(t),this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=t}initWidgetContainer(){var e;let t=document.createElement("div");t.classList.add("widget-container"),null==(e=this.viewerContainer)||e.appendChild(t),this.widgetContainer=t}initSpinner(){var e;if(!this.viewerCfg.enableSpinner)return;let t=document.createElement("div");t.classList.add("gemini-spinner"),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),null==(e=this.widgetContainer)||e.appendChild(t),this.spinner=t,this.setSpinnerVisibility(this.jobCount>0)}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.jobCount<=0?$.warn("[BaseViewer] jobCount should be at least 1 here!"):this.setSpinnerVisibility(--this.jobCount>0)}destroy(){var e,t,n,i;null==(e=this.widgetContainer)||e.remove(),this.widgetContainer=void 0,null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener(),null==(i=this.undoRedoManager)||i.destroy(),this.spinner&&(this.spinner.remove(),this.spinner=void 0)}getInputManager(){return this.inputManager}getViewConfig(){return this.viewerCfg}enableRender(){}getRaycaster(){}getRaycastableObjectsByMouse(e){return[]}getBBox(){}getActiveSection(){}flyTo(e,t){}is3d(){return!0}getMeasurementManager(){}getMarkupManager(){}deactivateMeasurement(){}setMeasurementVisibility(e,t){return!1}screenshot(e){return $e(this,null,(function*(){}))}showStats(){}hideStats(){}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer,i=1;if("OrthographicCamera"===e.type){let r=e;i=Math.max(r.right-r.left,r.top-r.bottom)/r.zoom/Math.max(t,n)}else if("PerspectiveCamera"===e.type){let t=e,r=this.cameraCfg,a=r&&it.arrayToVector3(r.eye),s=r&&it.arrayToVector3(r.look);i=a.distanceTo(s)*Math.tan(t.fov/2*Math.PI/180)*2/n}return i}},s0=class{constructor(e){this.actived=!1,this.viewer=e,this.boxSelectHelper=new Fd(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActived(){return this.actived}activate(){var e;this.actived=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.actived=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){let t=nn.screenPoint2NdcPoint(e,this.camera,this.viewerContainer);this.raycaster.layers.set(10),this.raycaster.setFromCamera(t,this.camera);let n=[];"BimViewer"===this.viewer.name?n=this.viewer.getRaycastableObjectsByMouse({x:e.x,y:e.y}):"DxfViewer"===this.viewer.name&&(n=[this.viewer.groundPlane]);let i=this.raycaster.intersectObjects(n)||[];if(i.length>0)return i[0].point}handleZoomToRect(e,t){let n=this.pickPositionByScreenPoint(e),i=this.pickPositionByScreenPoint(t);if(n&&i){let e=new M(Math.min(n.x,i.x),Math.min(n.y,i.y),Math.min(n.z,i.z)),t=new M(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),r=new lt(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},PA=class extends ns{constructor(e){super("MobileHelper"),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.position=e}setPosition(e){this.position=e}isPointInPath(e,t){return!1}draw(e,t){this.drawInnerCircle(e),this.drawOuterRing(e),this.drawSnapTriangle(e)}drawInnerCircle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(137, 137, 138, 0.8)",e.beginPath(),e.arc(t,n,25,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}drawOuterRing(e){let{x:t,y:n}=this.position;e.save(),e.strokeStyle="rgba(17, 17, 19, 0.8)",e.lineWidth=10,e.beginPath(),e.arc(t,n,30,0,2*Math.PI),e.closePath(),e.stroke(),e.restore(),e.save(),e.strokeStyle="rgba(173, 173, 174, 0.8)",e.lineWidth=3,e.beginPath(),e.arc(t,n,35,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}drawSnapTriangle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(17, 17, 19, 0.8)",e.strokeStyle="rgba(137, 137, 138, 0.8)",e.lineWidth=2,e.beginPath(),e.moveTo(t-35,n-35),e.lineTo(t-35+12,n-35),e.lineTo(t-35,n-35+12),e.closePath(),e.fill(),e.stroke(),e.restore()}translate(e,t){this.position.add(new Q(e,t))}getTouchPoint(){return{x:this.position.x-35,y:this.position.y-35}}isIntersect(e){return this.position.x-35<e.x&&this.position.y-35<e.y&&this.position.x+35>e.x&&this.position.y+35>e.y}drawSelect(e,t){}getClassType(){return"MobileTouchHelperDrawable"}},WE=class extends Kn{constructor(e,t){super(e,t),this.type="Area",this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Kn.LINE_WIDTH,e.strokeStyle=Kn.MAJOR_COLOR,e.fillStyle=Kn.AREA_FILL_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.fill(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let n=this.points,i=this.calculateArea(n);this.label=`${Cc(i,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(n),t),super.drawText(e,t)}calculateArea(e){let t=0,n=bd.getFaces(e);for(let i=0;i<n.length/3;i++){let r=e[n[3*i]],a=e[n[3*i+1]],s=e[n[3*i+2]],o=a.clone().sub(r),l=s.clone().sub(r);t+=o.cross(l).length()/2}return t}getBarycenter(e){let t=e.length,n=0,i=0,r=0;return e.forEach((e=>{n+=e.x,i+=e.y,r+=e.z})),new M(n/t,i/t,r/t)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(i))return!0;let r=3*this.tolerance,a=new M,s=new M,o=this.points;for(let h=0;h<o.length;h++){let e=o[h],t=o[h+1]||o[0];if(n.distanceSqToSegment(e,t,s,a)<r*r)return!0}let l=bd.getFaces(this.points);for(let h=0;h<l.length/3;h++){let t=this.points[l[3*h]],i=this.points[l[3*h+1]],r=this.points[l[3*h+2]];if(n.intersectTriangle(t,i,r,!1,e))return!0}return!1}getClassType(){return"Area"}};$t._registerDrawableClass(WE);var IA=class extends qc{constructor(e,t,n,i){super("Area",e,t,n,i)}activate(){super.activate()}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.exitButton&&(this.exitButton.style.display="none")}createMeasureDrawable(){if(this.drawingPoints)return new WE(it.guid(),this.drawingPoints)}onMouseClick(e){var t,n;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;this.drawingPoints||(this.drawingPoints=[]);let i=this.drawingPoints;if(2===e.button)return void this.exitDrawing();let r=this.getIntersections(e)[0];if(!r)return void $.warn("[Measure] No intersection found!");let a=null!=(n=null==(t=this.snapPoint)?void 0:t.clone())?n:null==r?void 0:r.point.clone();if(!this.drawingPoints[0]||!wt.areVector3sEqual(this.drawingPoints[0],a)){if(i.length>=3&&!bd.arePointsCoplanar([...i,a]))return void $.warn("[Measure] The position is not coplanar with other points");i.push(a),this.lastMouseDownPosition=a,1===i.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable()}}exitDrawing(){let e=this.drawingPoints||[],t=!0;if(e.length<3&&($.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&bd.isSelfIntersecting(e)&&($.warn("[Measure] The area formed by these points intersects itself, so the correct measurement cannot be obtained !"),t=!1),!t)return this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,void(this.lastMouseDownPosition=void 0);this.createOrUpdateMeasureDrawable(),this.complete()}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.areaMeasurement");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}},jE=class extends Kn{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=Kn.LINE_WIDTH,e.strokeStyle=Kn.MAJOR_COLOR,e.fillStyle=Kn.AREA_FILL_COLOR;let n=this.points;e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.arc(i.x,i.y,Kn.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let n=this.points[0];wt.areNumbersEqual(n.x,0);let i=wt.areNumbersEqual(n.x,0)?0:n.x,r=wt.areNumbersEqual(n.y,0)?0:n.y,a=wt.areNumbersEqual(n.z,0)?0:n.z;this.label=`${Cc(i,2)}, ${Cc(r,2)}, ${Cc(a,2)}`,e.font=`${Kn.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*Kn.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(n,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new Q(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=Kn.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};$t._registerDrawableClass(jE);var DA=class extends qc{constructor(e,t,n,i){super("Coordinate",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new jE(it.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point,r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(i),r.length>=1&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){!0!==this.completed&&(this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}},qH=class extends Kn{constructor(e,t){super(e,t),this.type="Distance",this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Kn.LINE_WIDTH,e.strokeStyle=Kn.MAJOR_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}else this.selected||this.drawVerticalLine(e,t);this.drawText(e,t)}drawText(e,t){if(this.points.length<2)return;let[n,i]=this.points,r=n.distanceTo(i);this.label=`${Cc(r,2)}`,this.labelPositon=this.transToScreenCoord(n.clone().add(i).divideScalar(2),t),super.drawText(e,t)}drawVerticalLine(e,t){if(this.points.length<2)return;let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t))),[r,a]=this.getShortLineBySegments(n,i),[s,o]=this.getShortLineBySegments(i,n);e.save(),e.lineWidth=Kn.LINE_WIDTH,e.strokeStyle=Kn.MAJOR_COLOR,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y),e.stroke(),e.restore()}getShortLineBySegments(e,t){let n=(new Q).subVectors(t,e).normalize(),i=qH.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[n.clone().rotateAround(new Q,r).normalize().multiplyScalar(i).add(e),n.clone().rotateAround(new Q,-r).normalize().multiplyScalar(i).add(e)]}getClassType(){return"Distance"}},a0=qH;a0.SHORT_LINE_LENGTH=12,$t._registerDrawableClass(a0);var _s,LA=class extends qc{constructor(e,t,n,i){super("Distance",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new a0(it.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&wt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.length<2&&r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=2&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}},Hl=class{constructor(e,t){var n,i;this.selectedMeasurementDrawable=void 0,this.drawableList=new Pl("measure"),this.drawableHelperList=new Pl("touchHelper"),this.measurements={},this.activeMeasurementType=void 0,this.keydown=e=>{var t;let n,i=this.getActiveMeasurementType();i&&(n=this.measurements[i]);let r=this.selectedMeasurementDrawable;r&&"Delete"===e.code&&(this.removeMeasurement(r),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Ov(this,r.getData())),this.activeMeasurementType&&this.measurements[this.activeMeasurementType].clearClickedDrawable()),e.ctrlKey&&"KeyZ"===e.code&&null!=n&&n.isMeasuring&&n.cancel(),e.ctrlKey&&"KeyY"===e.code&&null!=n&&n.isMeasuring},this.viewer=e,this.inputManager=t,this.overlayRender=this.viewer.overlayRender,null==(n=this.overlayRender)||n.addDrawableList(this.drawableHelperList),null==(i=this.overlayRender)||i.addDrawableList(this.drawableList),this.osnapHelper=new RA(this.overlayRender),this.measurements.Distance=new LA(this.viewer,t,this.drawableList,this.osnapHelper),this.measurements.Area=new IA(this.viewer,t,this.drawableList,this.osnapHelper),this.measurements.Angle=new oA(this.viewer,t,this.drawableList,this.osnapHelper),this.measurements.Coordinate=new DA(this.viewer,t,this.drawableList,this.osnapHelper),this.inputManager.addEventListener("wheel",(()=>{this.updateSnapTolerance()})),this.viewer.addEventListener("LayoutChanged",(()=>{this.updateSnapTolerance()})),this.initEvents()}initEvents(){Object.values(this.measurements).forEach((e=>{e.addEventListener("Completed",(e=>{var t;this.viewer.dispatchEvent("MeasurementAdded",e.getData()),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Vy(this,e.getData())),this.selectMeasurement(e)})),e.addEventListener("WillBeAdded",(e=>{this.addMeasurement(e,!1)})),e.addEventListener("Updated",(()=>{this.render()})),e.addEventListener("WillBeRemoved",(e=>{this.removeMeasurement(e,!1)})),e.addEventListener("Deactivate",(()=>{this.osnapHelper.deactivate(),this.viewer.deactivateMeasurement()})),e.addEventListener("FirstPointPicked",(()=>{this.unselectMeasurement()})),e.addEventListener("ClickedOnMeasurement",(e=>{this.selectMeasurement(e)}))}))}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get raycaster(){return this.viewer.getRaycaster()}addMeasurement(e,t=!0){this.drawableList.addDrawable(e),this.selectedMeasurementDrawable=e,this.render(),t&&this.viewer.dispatchEvent("MeasurementAdded",e.getData())}createMeasurement(e){return $t.createDrawable(e)}removeMeasurement(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MeasurementRemoved",e.getData())}updateSnapTolerance(e=3){let t=this.viewer.getPixelSizeInWorldCoord()*e;this.osnapHelper.updateSnapTolerance(t)}activateMeasurement(e){this.activeMeasurementType&&this.deactivateMeasurement(),this.measurements[e]?(this.measurements[e].activate(),this.activeMeasurementType=e,this.updateSnapTolerance()):(this.activeMeasurementType=void 0,$.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:n}=this.canvas.getBoundingClientRect();tn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new PA(new Q(t/2,n/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new Q(t/2,n/2)),this.measurements[e].setTouchHelper(this.mobileTouchHelper),this.mobileTouchHelper.visible=!0),this.inputManager.addEventListener("keydown",this.keydown)}deactivateMeasurement(){this.unselectMeasurement();let e=this.activeMeasurementType;e&&this.measurements[e].deactivate(),this.activeMeasurementType=void 0,this.mobileTouchHelper&&(this.mobileTouchHelper.visible=!1),this.inputManager.removeEventListener("keydown",this.keydown)}getActiveMeasurementType(){return this.activeMeasurementType}isMeasurementActive(){let e=this.activeMeasurementType;return e?this.measurements[e].isActive:!!this.getActiveMeasurementType()}isMeasurementMeasuring(){let e=this.activeMeasurementType;return!!e&&this.measurements[e].isMeasuring}getMeasurementsData(){return this.drawableList.getDrawableDatas()}cancelMeasurement(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing()}setMeasurementsData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.measurements[e.type]?e.points.length>=2?(this.addMeasurement($t.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Vy(this,e))):$.info("[Measure] Invalid points found in MeasurementData:",e):$.warn("[Measure] Failed to add measurement data for",e)})),null==(n=this.viewer.undoRedoManager)||n.endTransaction()}setMeasurementVisibility(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setMeasurementsVisibility(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clearMeasurements(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing(),this.drawableList.clear(),this.render()}getMeasurementById(e){return this.drawableList.getDrawableById(e)}removeMeasurementById(e){let t=this.drawableList.getDrawableById(e);t?this.removeMeasurement(t):$.warn("[Measure] Failed to find measurement by id:",e)}selectMeasurementById(e){let t=this.drawableList.getDrawableById(e);t&&this.selectMeasurement(t)}selectMeasurement(e){this.unselectMeasurement(!1),e.selected=!0,this.selectedMeasurementDrawable=e,this.render()}unselectMeasurement(e=!0){this.selectedMeasurementDrawable&&(this.selectedMeasurementDrawable.selected=!1,e&&this.render()),this.selectedMeasurementDrawable=void 0}destroy(){this.deactivateMeasurement(),this.clearMeasurements(),this.drawableHelperList.clear(),this.measurements={},this.osnapHelper.destroy(),this.render()}render(e=!1){var t;e?this.viewer.enableRender():null==(t=this.overlayRender)||t.render()}},qde={HomeView:{icon:{default:"icon-home",active:"icon-home-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},OrthoMode:{icon:{default:"icon-orthomode",active:"icon-orthomode-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.orthoView",type:4,onActive:e=>{$.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{$.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.deactivateSection(),e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.deactivateSection(),e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{$.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}},mutexIds:["Section","SectionAxis","SectionBox","SectionPlane"]},Section:{icon:{default:"icon-section",active:"icon-section-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.section",type:3,children:{SectionAxis:{icon:{default:"icon-sectionplane",active:"icon-sectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.axisSection",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==_s||_s.destroy(),e.activateSection("AxisPlaneSection"),_s=new sA(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==_s||_s.destroy(),_s=void 0},mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==_s||_s.destroy(),e.activateSection("PickPlaneSection"),_s=new aA(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==_s||_s.destroy(),_s=void 0},mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),e.activateSection()},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection()},mutexIds:["SectionAxis","SectionPlane"]}},mutexIds:["Measure","MeasureDistance","MeasureArea","MeasureAngle","MeasureCoordinate"]},BimTree:{icon:{default:"icon-bimtree",active:"icon-bimtree-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.bimTree",type:4,onActive:()=>{$.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Bim Tree")}},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{$.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Viewpoint")},visible:!1},Annotation:{icon:{default:"icon-annotation",active:"icon-annotation-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.annotation",type:4,onActive:()=>{$.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Annotation")},visible:!1},Property:{icon:{default:"icon-property",active:"icon-property-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.property",type:4,onActive:()=>{$.info("[Toolbar]","Activate Property")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Property")},visible:!1},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{$.info("[Toolbar]","Activate Settings")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Settings")},visible:!1},FullScreen:{icon:{default:"icon-fullscreen",active:"icon-fullscreen-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(it.isFullScreen())};it.isFullScreen()?(it.exitFullscreen(),window.removeEventListener("resize",i)):it.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},Wde={SceneClear:{icon:{default:"icon-clear",active:"icon-clear-filled"},menuName:"clear",type:1,onClick:()=>{}}},jde={HomeView:{icon:{default:"icon-zhushitu",active:"icon-zhushitu"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},ZoomToRectangle:{icon:{default:"icon-kuangxuanfangda",active:"icon-kuangxuanfangda"},menuName:"Toolbar.zoomToRectangle",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("ZoomToRectangle",!1)})),e.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("GetScreenshot",!1)})),e.getScreenshot().then((e=>{if($.info("[Toolbar] getScreenshot() returns:",null==e?void 0:e.base64Image),null==e||!e.base64Image)throw"[Toolbar] Image data is empty!";let t=document.createElement("a");t.href=null==e?void 0:e.base64Image,t.download="",t.click()})).catch((t=>{var n;$.error("[Toolbar] Failed to get screenshot, reason:",t),null==(n=e.toolbar)||n.setActive("GetScreenshot",!1)}))},mutexIds:["ZoomToRectangle"]},Measure:{icon:{default:"icon-celiang1",active:"icon-celiang1"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{$.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{var n,i,r;null==(n=e.toolbar)||n.updateMenu("Measure",{defaultActive:!1}),null==(i=e.toolbar)||i.setActive("ZoomToRectangle",!1),e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0))),null==(r=e.toolbar)||r.setActive("MarkupVisibility",!1),e.activateMarkup("CloudRectWithTextMarkup"),t.hide(),new nA(e,yn({},cde))}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!1)))},onDeactive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{$.info("[Toolbar]","Activate Settings")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{$.info("[Toolbar]","Activate Compare")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{$.info("[Toolbar]","Activate Compare")},onDeactive:()=>{$.info("[Toolbar]","Deactivate Compare")},visible:!1},Layers:{icon:{default:"icon-tucengkongzhi",active:"icon-tucengkongzhi"},menuName:"Toolbar.layers",type:4,onClick:()=>{}},FullScreen:{icon:{default:"icon-quanping",active:"icon-quanping"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(it.isFullScreen())};it.isFullScreen()?(it.exitFullscreen(),window.removeEventListener("resize",i)):it.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},Xde={enableNavCube:!0,enableAxisGizmo:!0,enableToolbar:!0,enableBottomBar:!0,enableContextMenu:!0,enableSpinner:!0,containerId:"myCanvas",units:"meters"},oVt={enableNavCube:!1,enableAxisGizmo:!1,enableToolbar:!1,enableBottomBar:!1,enableContextMenu:!1,containerId:"myCanvas"},Jde=wi(Ll(),1),XE=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var r=(performance||Date).now(),a=r,s=0,o=n(new XE.Panel("FPS","#0ff","#002")),l=n(new XE.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var h=n(new XE.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){s++;var e=(performance||Date).now();if(l.update(e-r,200),e>=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,h)){var t=performance.memory;h.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};XE.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,h=3*s,c=2*s,u=3*s,d=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u,d,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",h,c),g.drawImage(m,u+s,d,p-s,f,u,d,p-s,f),g.fillRect(u+p-s,d,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u+p-s,d,s,a((1-l/v)*f))}}};var OA=XE,jH=wi(Ll(),1),iot="bottomBar",sot={"gemini-viewer-threejs-stats":{icon:{default:"icon-showsectionplane",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-statistics","gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-tips"],onActive:e=>{e.viewer.showStats()},onDeactive:e=>{e.viewer.hideStats()}},"gemini-viewer-threejs-statistics":{icon:{default:"icon-info",active:"icon-info-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-stats","gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-tips"],onActive:e=>{let t=document.createElement("span");if(!e.viewer.scene)return void(t.textContent="Failed!");t.textContent="Comupting...";let n={components:{},points:0,faces:0,materials:{},lights:{}},i=["SKYBOX","GROUND_GRID","GRASS_GROUND","BIM_VIEWER_BOX_HELPER"];e.viewer.scene.traverse((e=>{(e instanceof Ge||e instanceof sn||e instanceof or)&&!i.includes(e.name)?((e,t)=>{if(t.components[e.type]?t.components[e.type]++:t.components[e.type]=1,e.geometry){let n=e.geometry;if(e instanceof Ge)if(n.index&&n.index.count){let i=Math.round(n.index.count/3);e instanceof Ar&&(i*=e.count),t.faces+=i}else if(n.groups.length>0)for(let e=0;e<n.groups.length;++e)t.faces+=n.groups[e].count/3;if(n.attributes.position){let e=n.attributes.position;e.count&&e.itemSize&&(t.points+=e.count)}}let n=e=>{t.materials[e]?t.materials[e]++:t.materials[e]=1},i=e.material;i instanceof Rn?n(i.id):Array.isArray(i)&&i.forEach((e=>n(e.id)))})(e,n):e instanceof Do&&(n.lights[e.type]?n.lights[e.type]++:n.lights[e.type]=1)}));let r=(e,n)=>{t.innerHTML+=`<p><span>${e}:</span>${n}</p>`};t.innerHTML="";let a=` (${(e=>{var t;let n=null==(t=e.renderer)?void 0:t.domElement;return null==n?void 0:n.dataset.engine})(e.viewer)})`;r("Version",`${SE}${a}`),r("Components",JSON.stringify(n.components)),r("Points",n.points),r("Faces",n.faces),r("Materials",Object.keys(n.materials).length),r("Lights",JSON.stringify(n.lights)),"DxfViewer"===e.viewer.name&&r("Entities",e.viewer.getEntitiesCount()),e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=e.viewer.renderer,n=document.createElement("span"),i=(e,t)=>{n.innerHTML+=`<p><span>${e}:</span>${t}</p>`};n.innerHTML="<p>-- Renderer Info --</p>";let r=null==t?void 0:t.info;i("Drawcalls",JSON.stringify(null==r?void 0:r.render.calls)),i("Points",JSON.stringify(null==r?void 0:r.render.points)),i("Lines",JSON.stringify(null==r?void 0:r.render.lines)),i("Triangles",JSON.stringify(null==r?void 0:r.render.triangles)),i("Geometries",JSON.stringify(null==r?void 0:r.memory.geometries)),i("Textures",JSON.stringify(null==r?void 0:r.memory.textures)),e.tooltip.updateChildContent(n)}},"gemini-viewer-threejs-cameraInfo":{icon:{default:"icon-view",active:"icon-view-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-stats","gemini-viewer-threejs-statistics","gemini-viewer-threejs-tips"],onActive:e=>{let t=()=>{if(!e.viewer||!e.viewer.camera||!e.viewer.controls)return;let n=e.viewer.camera,i=e.viewer.controls,r=e=>it.numberToString(e),a=e=>it.vectorToString(e),s=n.position,o=i instanceof ba?i.getTarget(new M):i.target;if(s){let t=document.createElement("span");t.innerHTML=`\n <p><span>Camera position:</span>${a(s)}</p>\n <p><span>Camera target:</span>${a(o)}</p>`,n instanceof dr&&(t.innerHTML+=`\n <p>top: ${r(n.top)}, bottom: ${r(n.bottom)}, left: ${r(n.left)}, right: ${r(n.right)}</p>\n <p>zoom: ${r(n.zoom)}</p>`),e.tooltip.setContent(t)}e.active||window.removeEventListener("mouseup",t)};if(t(),window.addEventListener("mouseup",t),"BimViewer"===e.viewer.name){let n=e.viewer.controls;null==n||n.addEventListener("update",t)}else e.viewer.controls.addEventListener("change",t);e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}},"gemini-viewer-threejs-tips":{icon:{default:"icon-more",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-stats","gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-cameraInfo"],onActive:e=>{let t=document.createElement("span");"BimViewer"===e.viewer.name?t.innerHTML="\n <p><span>W: </span>Move forward</p>\n <p><span>A: </span>Move backward</p>\n <p><span>S: </span>Move left</p>\n <p><span>D: </span>Move right</p>\n <p><span>Q: </span>Rise up</p>\n <p><span>E: </span>Lower down</p>\n <p><span>\u2191: </span>Rotate up</p>\n <p><span>\u2193: </span>Rotate down</p>\n <p><span>\u2190: </span>Rotate to left</p>\n <p><span>\u2192: </span>Rotate to right</p>\n ":"DxfViewer"===e.viewer.name?t.innerHTML="\n <p><span>\u2191: </span>Move up</p>\n <p><span>\u2193: </span>Move down</p>\n <p><span>\u2190: </span>Move to left</p>\n <p><span>\u2192: </span>Move to right</p>\n ":"VRViewer"===e.viewer.name?t.innerHTML="\n <p><span>\u2191: </span>Rotate up</p>\n <p><span>\u2193: </span>Rotate down</p>\n <p><span>\u2190: </span>Rotate to left</p>\n <p><span>\u2192: </span>Rotate to right</p>\n ":t.innerHTML="\n <p>Nothing to show</p>\n ",e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}}},kd=class{constructor(e){this.viewer=e,this.itemList=new Map,this.init()}update(){this.itemList.forEach((e=>{e.update()}))}init(){var e;let t=document.createElement("div");t.id=iot,t.classList.add("bottom-bar"),(0,jH.forEach)(sot,((e,n)=>{let i=this.createItem(this.viewer,n,e);t.appendChild(i.element)})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(this.element)}createItem(e,t,n){let i=new WH(e,this,t,n);return this.itemList.set(t,i),i}},WH=class{constructor(e,t,n,i){this.viewer=e,this.bottomBar=t,this.menuId=n,this.cfg=i,this.eventBus=Kv(),this.active=!1,this.itemconfig=i,this.element=this.createButton(this.menuId,i),this.tooltip=new Yo(n+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,jH.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.bottomBar)?void 0:t.itemList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(this)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(this)),this.element instanceof HTMLElement&&WS(this.element.classList,i.icon,this.active)}))}createButton(e,t){let n=document.createElement("i");n.id=e;let{default:i="icon-new",iconFont:r=Tv}=t.icon;return n.classList.add("icon"),n.classList.add(r),n.classList.add(i),n.onclick=()=>{this.active=!this.active,t.onClick&&t.onClick(this),this.eventBus.emit("activeChange",this.active)},n}setActive(e){this.active=e,this.eventBus.emit("activeChange",this.active)}update(){this.active&&this.itemconfig.onUpdate&&this.itemconfig.onUpdate(this)}},YE=wi(Ll(),1),aot="gemini-context-menu",NA=class{constructor(e){this.itemList=[],this.id=e.id||aot,this.container=e.container||document.body,this.context=e.context||{},this.element=this.createMenuUI(e.items||[]),this.handleClick=()=>{this.hide()},!1!==e.hideOnMouseDown&&document.addEventListener("click",this.handleClick),this.hide()}isEnable(e){return e.getEnabled?e.getEnabled(this.context):void 0===e.enabled||e.enabled}isShown(e){return e.getShown?e.getShown(this.context):void 0===e.shown||e.shown}getTitle(e){return e.title||e.getTitle&&e.getTitle(this.context)||""}createMenuUI(e){let t=document.createElement("div");t.id=this.id,t.classList.add("context-menu");let n=this.createMenuGroup(e);return t.append(...n),this.container.appendChild(t),t}createMenuGroup(e){return(0,YE.map)(e,(e=>{let t=document.createElement("ul");return(0,YE.forEach)(e,(e=>{let n=this.createMenuItem(e);t.append(n)})),t}))}createMenuItem(e){let t=document.createElement("li");return t.innerHTML=this.getTitle(e),t.onclick=()=>e.doAction&&e.doAction(this.context),this.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.itemList.push([e,t]),t}updateMenuItems(){(0,YE.forEach)(this.itemList,(([e,t])=>{this.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),t.innerHTML=this.getTitle(e)}))}showMenuElement(e,t){let n=this.element.offsetHeight,i=this.element.offsetWidth;t+n>window.innerHeight&&(t=window.innerHeight-n-5),e+i>window.innerWidth&&(e=window.innerWidth-i-5),this.element.style.left=e+"px",this.element.style.top=t+"px"}show(e,t){this.updateMenuItems(),this.element.removeAttribute("hidden"),this.showMenuElement(e,t)}hide(){this.element.setAttribute("hidden","")}destroy(){document.removeEventListener("click",this.handleClick),this.container.removeChild(this.element)}},wa=e=>({bimViewer:t})=>t.translate(`ContextMenu.${e}`),$de=e=>{var t;let n=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof Ge&&n++})),n>0},oot=e=>{var t,n;let i=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof Ge&&i++})),null==(n=e.scene)||n.traverseVisible((e=>{e instanceof Ge&&i--})),i>0},XH=e=>e.hasTransparentObject(),UA=e=>!1!==e.userData.selectable,Yde=(e,t,n,i)=>{let r=e.selectedObject;return!(!r||!t||r.id!==t.id)&&(null!=n&&r.isInstancedMesh?n===r.userData.instanceId:null==i||!gr.isMergedMesh(r)||i===r.userData.batchId)},lot={getTitle:wa("viewFitEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.flyToObject(t)}},cot={getTitle:wa("viewFitAll"),getEnabled:({bimViewer:e})=>$de(e),doAction:({bimViewer:e})=>e.viewFitAll()},uot={getTitle:wa("hideEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{UA(t)&&(t.visible=!1,e.enableRender())}},hot={getTitle:wa("hideOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{var n;null==(n=e.scene)||n.traverse((e=>{e instanceof Ge&&UA(e)&&(e.visible=!1)})),t.visible=!0,e.enableRender()}},dot={getTitle:wa("hideAll"),getEnabled:({bimViewer:e})=>$de(e),doAction:({bimViewer:e})=>{var t;null==(t=e.scene)||t.traverse((e=>{e instanceof Ge&&UA(e)&&(e.visible=!1)})),e.enableRender()}},fot={getTitle:wa("showAll"),getEnabled:({bimViewer:e})=>oot(e),doAction:({bimViewer:e})=>{var t;null==(t=e.scene)||t.traverse((e=>{e instanceof Ge&&UA(e)&&(e.visible=!0)})),e.enableRender()}},pot={getTitle:({hit:e,bimViewer:t,instanceId:n,batchId:i})=>Yde(t,e,n,i)?wa("deselect")({bimViewer:t}):wa("select")({bimViewer:t}),getShown:({hit:e})=>e,doAction:({hit:e,bimViewer:t,instanceId:n,batchId:i})=>{!1!==e.userData.selectable?Yde(t,e,n,i)?t.clearSelection():t.selectObject(e,e.instanceId,i):$.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},mot={getTitle:wa("selectNone"),getEnabled:({bimViewer:e})=>e.selectedObject,doAction:({bimViewer:e})=>e.clearSelection()},got={getTitle:wa("xRayAll"),getShown:({bimViewer:e})=>!XH(e),doAction:({bimViewer:e})=>{e.addOrRemoveObjectOpacity(!0),e.enableRender()}},vot={getTitle:wa("xRayNone"),getEnabled:({bimViewer:e})=>XH(e),doAction:({bimViewer:e})=>{XH(e)&&(e.addOrRemoveObjectOpacity(!1),e.enableRender())}},xot={getTitle:wa("xRayEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},yot={getTitle:wa("xRayOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),e.enableRender()}},Eot={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="*showSectionPlane";break;case"AxisPlaneSection":t="showAxisSection";break;case"ObjectsBoxSection":t="*showSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:({bimViewer:e,section:t})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!t&&!t.isShowSectionPlane,doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!0))}},bot={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="hideSectionPlane";break;case"AxisPlaneSection":t="hideAxisSection";break;case"ObjectsBoxSection":t="hideSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:e=>Zde(e),doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!1))}},_ot={getTitle:wa("undoSection"),getShown:e=>Zde(e),doAction:({bimViewer:e,toolbar:t})=>{if("PickPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},Zde=({bimViewer:e,hit:t,section:n})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!n&&n.isShowSectionPlane&&(null==t?void 0:t.name)===DF,Kde=[[Eot],[bot,_ot],[lot,cot],[uot,hot,dot,fot],[xot,yot,got,vot],[pot,mot]],BA=class{constructor(e){this.viewer=e,this.itemList={},this.handleMouseWheel=e=>{e.preventDefault(),this.element&&(this.element.scrollLeft+=e.deltaY)},e.addEventListener("ModelLoaded",(()=>{this.init()}))}init(){var e;let t=document.createElement("div");t.classList.add("model-layout-switch-bar");let n=document.createElement("div");n.classList.add("model-layout-switch-bar-content"),n.addEventListener("wheel",this.handleMouseWheel),this.viewer.getLayoutNames().forEach(((e,t)=>{let i=this.createItem(e,t);this.itemList[e]=i,i.resetActivate=()=>{for(let e in this.itemList)this.itemList[e].resetActive()},null==n||n.appendChild(i.element)})),this.element=t,this.content=n,this.element.appendChild(this.content),null==(e=this.viewer.widgetContainer)||e.appendChild(this.element)}createItem(e,t){let n=new YH(this.viewer,e);return 0===t&&n.setActive(!0),n}destroy(){var e,t;for(let n in this.itemList){let t=this.itemList[n];t.destroy(),null==(e=this.content)||e.removeChild(t.element)}this.itemList={},this.element&&this.content&&(this.element.removeChild(this.content),this.element.removeEventListener("wheel",this.handleMouseWheel),null==(t=this.viewer.widgetContainer)||t.removeChild(this.element),this.element=void 0)}show(){this.element&&(this.element.style.display="block")}hide(){this.element&&(this.element.style.display="none")}},YH=class{constructor(e,t){this.viewer=e,this.eventBus=Kv(),this.active=!1,this.element=this.createItem(t),this.eventBus.on("activechange",(e=>{this.resetActivate&&this.resetActivate(),e?(this.element.classList.add("activate"),this.viewer.activateLayout(t)):this.element.classList.remove("activate")}))}createItem(e){let t=document.createElement("div"),n=document.createElement("span");return t.classList.add("model-layout-switch-item"),t.onclick=()=>{this.active=!this.active,this.eventBus.emit("activechange",this.active)},n.innerText=e,t.appendChild(n),t}setActive(e){this.active!==e&&(this.active=e,this.eventBus.emit("activechange",e))}resetActive(){this.active=!1,this.element.classList.remove("activate")}destroy(){this.eventBus.off("activechange")}},o0=new Ae,FA=new Ae,HA=new ps,$H=new M,l0=new lt,$E=class extends Hd{constructor(e){super(e),this.name="DxfViewer",this.CAMERA_Z_POSITION=100,this.CAMERA_MIN_ZOOM=1e-6,this.frustumSize=this.width,this.timer=Date.now(),this.loadedModels={},this.masterModelId="",this.raycaster=new Gs,this.selected=!0,this.raf=new t0,this.clock=new Oo,this.renderEnabled=!1,this.enableHideVisuallySmallObjects=!0,this.sortedHidableObjects={},this.lastCameraZoom=1/0,this.lastFrame=-1,this.activeLayoutName="",this.layoutInfos={},this.units=void 0,this.fpsUtils=new XS,this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.loadingDxfCount=0,this.compareMode=!1,this.viewerCfg=e,this.increaseJobCount(),this.init(),this.animate(),this.enableRender(),this.decreaseJobCount(),$.info(`[DxfViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),tn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.renderer&&(this.inputManager=new Rp(this.renderer.domElement))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&(this.axes=this.initAxes()),!0===e.enableStats&&(this.stats=this.initStats()),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&(this.bottomBar=this.initBottomBar()),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new BA(this))}initScene(){let e=new ii;e.background=new Ie(2172976),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initRenderer(){var e;let{context:t}=this.viewerCfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!tn.isBrowser&&t&&Object.assign(n,{context:t,canvas:tn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ms(n),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,tn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),it.printGpuInfo(this.renderer.getContext()),Dt.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new $t(this))}initCSS2DRenderer(){var e;let t=new Rc;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){if(!this.scene)return;let e=new dr(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new ba(e,this.inputManager);t.enableRotate=!1,t.enabled=!0,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.5,t.truckSpeed=1,t.mouseButtons={left:Ve.TRUCK,middle:Ve.TRUCK,wheel:Ve.ZOOM,right:Ve.TRUCK},t.touches={one:Ve.TOUCH_TRUCK,two:Ve.TOUCH_ZOOM_TRUCK,three:Ve.NONE},t.listenToKeyEvents(),t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange(this))}onControlsChange(e){return()=>{this.updateHidableObjectsVisibility(),e.enableRender()}}initEvents(){if(!this.inputManager||!this.renderer)return;let e=!1,t=!1;this.inputManager.addEventListener("pointerdown",(n=>{var i;t=!1,e=!0,1===n.button&&(null==(i=this.inputManager)||i.setCursor("move"))})),this.inputManager.addEventListener("pointermove",(()=>{var n;e&&(t=!0,null==(n=this.inputManager)||n.setCursor("move"))})),this.inputManager.addEventListener("pointerup",(n=>{var i;if(e=!1,null==(i=this.inputManager)||i.setCursor("default"),t)return void(t=!1);this.handleMouseClick(n);let r={evt:n};if(this.selectedObject&&this.selectedObject instanceof wr&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Kn&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Tt){let e=t=>t.parent&&!t.parent.isScene?e(t.parent):t.name;r.entityData={modelId:e(this.selectedObject),layoutName:this.selectedObject.userData.layerName}}this.dispatchEvent("MouseClicked",r)})),this.inputManager.addEventListener("keydown",(e=>{var t,n,i,r,a;if(e.altKey&&"KeyR"===e.code)this.flyToRandomObject();else if(e.ctrlKey&&"KeyZ"===e.code){if(this.measurementManager&&this.measurementManager.isMeasurementMeasuring())return;null==(t=this.undoRedoManager)||t.undo()}else if(e.ctrlKey&&"KeyY"===e.code){if(this.measurementManager&&this.measurementManager.isMeasurementMeasuring())return;null==(n=this.undoRedoManager)||n.redo()}else"Delete"===e.code&&this.selectedObject&&(this.markupManager&&this.selectedObject instanceof wr&&(this.markupManager.removeMarkup(this.selectedObject),null==(i=this.undoRedoManager)||i.addCommand(new Ip(this.markupManager,this.selectedObject.getData()))),this.measurementManager&&this.selectedObject instanceof Kn&&(null==(r=this.measurementManager)||r.removeMeasurement(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new Ov(this.measurementManager,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initAxes(){var e;let t=document.createElement("div");t.classList.add("axesRenderer");let n=new vd(t,this.camera,!0);return null==(e=this.widgetContainer)||e.append(t),n}initStats(){var e;let t=new OA,n=document.createElement("div");return n.classList.add("statsOutput"),n.appendChild(t.domElement),t.domElement.style.position="absolute",null==(e=this.widgetContainer)||e.append(n),t}showStats(){this.stats||(this.stats=this.initStats()),this.stats.showPanel(0)}hideStats(){this.stats&&this.stats.showPanel(-1)}initToolbar(){let e=this.viewerCfg;return new Gc(this,(0,Jde.merge)({},jde,e.toolbarMenuConfig))}initBottomBar(){return new kd(this)}initLoadingProgressBar(){return new Zv(this.widgetContainer)}showLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.show()}hideLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.hide()}animate(){var e,t,n,i,r,a;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this));let s=this.clock.getDelta(),o=null==(e=this.controls)?void 0:e.update(s);if(this.scene&&this.camera){if(this.viewerContainer&&this.viewerContainer.parentElement){let{width:e,height:t}=this.viewerContainer.parentElement.getBoundingClientRect();(this.width!==e||this.height!==t)&&(o=!0,this.resize(e,t))}if(this.renderEnabled||o){if(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(this.camera.zoom),Dt.resolutionUniform.value.set(this.width,this.height),null==(t=this.renderer)||t.render(this.scene,this.camera),!tn.isBrowser){let e=null==(n=this.renderer)?void 0:n.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.hotpointRoot&&this.hotpointRoot.children.length>0&&(null==(i=this.css2dRenderer)||i.render(this.scene,this.camera)),this.dispatchEvent("AfterRender")}}null==(r=this.stats)||r.update(),this.fpsUtils.update(),null==(a=this.bottomBar)||a.update()}getFps(){return this.fpsUtils.fps}is3d(){return!1}destroy(){var e,t,n,i,r,a,s;Dt.abortJobs=!0,this.dxfLayoutBar&&(this.dxfLayoutBar.destroy(),this.dxfLayoutBar=void 0),null==(e=this.measurementManager)||e.destroy(),this.measurementManager=void 0,null==(t=this.markupManager)||t.destroy(),this.markupManager=void 0,null==(n=this.zoomToRectHelper)||n.destroy(),this.zoomToRectHelper=void 0,null==(i=this.boxSelectHelper)||i.destroy(),this.boxSelectHelper=void 0,null==(r=this.pickMarkupHelper)||r.destroy(),this.pickMarkupHelper=void 0,this.sortedHidableObjects={},this.layoutInfos={},this.raycastableObjects=void 0,this.changes={},Object.keys(this.loadedModels).forEach((e=>{delete this.loadedModels[e]})),this.loadedModels={},this.css2dRenderer&&(null==(a=this.viewerContainer)||a.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.stats=void 0,this.raycaster=void 0,this.selectedObject=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),this.contextMenu&&(this.contextMenu.destroy(),this.contextMenu=void 0),this.axes&&(this.axes.dispose(),this.axes=void 0),this.toolbar&&(this.toolbar.destroy(),this.toolbar=void 0),this.bottomBar=void 0,this.font=void 0,null==(s=this.inputManager)||s.removeEventListener(),super.destroy()}loadModelAsync(e,t){return $e(this,null,(function*(){var n,i;this.loadingDxfCount++,this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src;this.masterModelId||(this.masterModelId=r);let a=e.ignorePaperSpace||this.masterModelId!==r;!1===e.ignorePaperSpace&&a&&$.warn(`[DxfViewer] Paper space will be ignored for '${r}' although 'ignorePaperSpace' is false!`),it.printMemory("Before loadModelAsync");let s=new Ks(this.loadingManager);s.setFont(this.font);let o=r,l=this.translate("ProgressBar.Loading"),h=e=>{var n;null==(n=this.loadingProgressBar)||n.updateProgress(o,l,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},c=(e,n,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-n)/100+n,null==(r=this.loadingProgressBar)||r.updateProgress(o,l,a),t&&t(new ProgressEvent("LoadProgress",{loaded:a,total:100}))};null==(n=this.loadingProgressBar)||n.addProgressItem(o),h(0);let u=this.viewerCfg,d=yield s.loadDxfData(e.src,e.modelId,(e=>c(e,0,90)),void 0,a,u.enableLocalCache,e.merge).finally((()=>{this.loadingDxfCount--,0===this.loadingDxfCount&&this.font&&this.font.releaseFontData&&this.font.releaseFontData()}));if($.info(`[DxfViewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),Dt.abortJobs&&Promise.reject("[DxfViewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[DxfViewer] Nothing was loaded from ${e.src}`;return $.warn(t),this.decreaseJobCount(),Promise.reject(t)}let p=d.threejsObject;p.name=r;let f=this.getDxfUnits(d);if(this.masterModelId===e.modelId&&(this.units=f),$.info(`[DxfViewer] Units of '${e.src}' is '${f}'`),f){let t=1;this.units&&f!==this.units&&(t=H5(f,this.units)),e.scale?e.scale=[e.scale[0]*t,e.scale[0]*t,e.scale[0]*t]:e.scale=[t,t,t]}if(e.matrix&&16===e.matrix.length){let t=new Ae;t.elements=e.matrix,p.applyMatrix4(t)}else{let t=e.position||[0,0,0],n=e.rotation||[0,0,0],i=e.scale||[1,1,1];p.position.set(t[0],t[1],t[2]),p.rotation.set(n[0]*Math.PI/180,n[1]*Math.PI/180,n[2]*Math.PI/180),p.scale.set(i[0],i[1],i[2])}return yield this.addLoadedModelToScene(p,e,d,(e=>c(e,90,99))),it.printMemory("After addLoadedModelToScene"),$.info(`[DxfViewer] Added '${e.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.decreaseJobCount(),h(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(o),this.dispatchEvent("ModelLoaded"),Promise.resolve()}))}unloadDxf(){throw new Error("Not implemented yet!")}isCompareMode(){return this.compareMode}compare(e,t,n){return $e(this,null,(function*(){var i,r,a,s,o;let{src:l,modelId:h}=e,{src:c}=t;if(this.compareMode)return Promise.reject("[DxfViewer] It is already under comparing mode!");if(this.masterModelId||Object.keys(this.loadedModels).length>0)return Promise.reject("[DxfViewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.font)return Promise.reject("[DxfViewer] Should set font first!");let u=new Dt(this.loadingManager,!0);u.setFont(this.font),this.font instanceof to&&this.font.getFontData&&(yield this.font.getFontData());let d=l+c,p=this.translate("ProgressBar.Comparing"),f=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(d,p,e),n&&n(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},m=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(d,p,a),n&&n(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};it.printMemory("Before comparing"),this.masterModelId=h||l,this.loadingDxfCount+=2,null==(i=this.loadingProgressBar)||i.addProgressItem(d),f(0);let g=Date.now(),v=yield u.parse(l,(e=>m(e,0,15))),y=yield u.parse(c,(e=>m(e,15,30))),[x,_]=yield Promise.allSettled([v,y]);if("rejected"===x.status)return Promise.reject(`[DxfViewer] Failed to parse ${l}`);if("rejected"===_.status)return Promise.reject(`[DxfViewer] Failed to parse ${c}`);if($.info(`[DxfViewer] loadFiles in ${(Date.now()-g)/1e3}s`),Dt.abortJobs)return Promise.reject("[DxfViewer] compare loadFile aborted");let b=x.value,M=_.value;g=Date.now();let w=yield new Zr(b,M).compare((e=>m(e,30,60)));if($.info(`[DxfViewer] Compared in ${(Date.now()-g)/1e3}s`),$.debug("Compared results:",w),Dt.abortJobs)return Promise.reject("[DxfViewer] compare change aborted");it.printMemory("After getting the comparison results"),g=Date.now(),yield u.loadEntitiesForCompare(b,M,w,!0,(e=>m(e,60,95))),it.printMemory("After Creating threejs objects based on comparison result"),null==(r=this.font)||r.releaseFontData(),this.changes=w,$.info(`[DxfViewer] Creates threejs objects based on comparison result in ${(Date.now()-g)/1e3}s`);let S=b,E=M;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(w).length||$.info("[DxfViewer] No change found"),0===(null==(a=S.threejsObject)?void 0:a.children.length)&&0===(null==(s=E.threejsObject)?void 0:s.children.length)){let e=`[DxfViewer] Nothing was loaded from ${l} and ${c}`;return $.warn(e),Promise.reject(e)}let T=S.threejsObject,A=E.threejsObject;return T.name=l,A.name=c,g=Date.now(),this.addLoadedModelToScene(T,Qr(yn({},e),{merge:!1}),S),it.printMemory("After adding first loaded Model to scene"),f(95),this.addLoadedModelToScene(A,Qr(yn({},t),{merge:!1}),E),it.printMemory("After adding second loaded Model to scene"),$.info(`[DxfViewer] Added compared objects to scene in ${(Date.now()-g)/1e3}s`),$.info(`[DxfViewer] The comparison between ${l}' and '${c}' is completed in ${(Date.now()-this.timer)/1e3}s !`),f(100),null==(o=this.loadingProgressBar)||o.delayRemoveProgressItem(d),Promise.resolve()}))}getEntitiesCount(){let e=0;return Object.values(this.loadedModels).forEach((t=>{var n;e+=(null==(n=t.dxfData)?void 0:n.loadedEntityCount)||0})),e}getLoadedDxfModelIds(){return Object.keys(this.loadedModels)}getLayoutNames(){let e=[];return this.getLayouts().forEach((t=>{e.push(t.layoutName)})),e}getLayouts(){let e=[],t=this.loadedModels[this.masterModelId];if(t){let n=t.dxfData,i=null==n?void 0:n.objects.LAYOUT;null==i||i.forEach((t=>{e.push(t)}))}return e}handleOverlayDxf(e){var t;let n=this.loadedModels[e];if(!n)return void $.warn(`[DxfViewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(Dt.MODEL_LAYOUT_NAME,e);let i=null==(t=n.dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===Dt.MODEL_LAYOUT_NAME));r&&(r.traverse((e=>{this.addSpatialFilterSection(e,n.dxfData)})),this.calcBoundingBoxOfLayoutChild(r)),this.showLayoutObjects(this.activeLayoutName),this.decreaseJobCount()}activateLayout(e){var t,n,i,r;if(this.increaseJobCount(),0==e.length)return $.warn("[DxfViewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return $.warn(`[DxfViewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels[this.masterModelId];if(!l)return $.warn(`[DxfViewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new M),null==(t=this.camera)||t.getWorldPosition(e.lastCameraPosition),this.controls.update(0),e.lastCameraZoom=s.zoom}if(!(e=>{let t=this.layoutInfos[e];return!(null==t||!t.lastCameraZoom)})(e)){this.switchTransformMs(e,this.masterModelId);let t=this.getLayoutViewports(o),r=[];t.length>0&&(r=t[0].frozenLayerHandles);let a=e!==Dt.MODEL_LAYOUT_NAME,s=null==(n=l.dxfData)?void 0:n.threejsObject,h=null==s?void 0:s.children.find((t=>t.name===e));if(h){let t=[],n=null==(i=l.dxfData)?void 0:i.layersAndThreejsObjects;h.traverse((i=>{this.addSpatialFilterSection(i,l.dxfData);let s=i;if(a&&s.material&&s.geometry){let i=s.userData.layerName;if(!this.isLayerFrozenForViewport(l.dxfData,i,r))return;t.push(s);let a=-1;n&&n[i]&&(a=n[i].indexOf(s),a>=0&&n[i].splice(a,1)),a<0&&$.warn(`[DxfViewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);$.debug("[DxfViewer] Active layout:",e,", viewports:",c);let u=Date.now(),d=this.CAMERA_Z_POSITION/10,p=0;c.forEach((t=>{var n;this.generateObjectsByViewport(e,t,l.dxfData);let i=null==(n=null==t?void 0:t.msToPsMatrix)?void 0:n.elements[14];i&&i>p&&(p=i)}));let f=this.controls,m=f.getPosition(new M);if(p>m.z+d){let e=Math.ceil(p+d);$.info(`[DxfViewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new M);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}$.info(`[DxfViewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==Dt.MODEL_LAYOUT_NAME&&this.switchTransformMs(Dt.MODEL_LAYOUT_NAME,this.masterModelId),e!==Dt.MODEL_LAYOUT_NAME&&h&&this.setLayoutHidableObjectArray(h),h&&this.calcBoundingBoxOfLayoutChild(h)}this.measurementManager&&this.clearMeasurements(),this.markupManager&&this.clearMarkups(),null==(r=this.undoRedoManager)||r.clear(),this.showLayoutObjects(e),this.activeLayoutName=e;let h=this.getActiveLayoutInfo();if(h.lastCameraPosition)this.goTo(h.lastCameraPosition,h.lastCameraZoom,!1);else{h.extent=this.computeBoundingBox();let e=this.getLayoutExtentEx(o);if(e){let t=e.max.x-e.min.x,n=e.max.y-e.min.y;(t<1e-16||n<1e-16||t>1e16||n>1e16)&&($.warn(`[BimViewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else $.warn("[BimViewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),it.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),$.info(`[DxfViewer] Activated layout '${e}' in ${(Date.now()-a)/1e3}s`)}calcBoundingBoxOfLayoutChild(e){let t=e.children.length;for(let n=0;n<t;n++){let t=e.children[n];t.children.length>0?t.userData.boundingBox=Fr.getBoundingBox(t):t.userData.boundingBox&&delete t.userData.boundingBox}}cancelAllOperations(){var e,t,n,i,r,a,s,o,l,h;null!=(e=this.measurementManager)&&e.isMeasurementActive()&&(null==(t=this.measurementManager)||t.deactivateMeasurement()),null!=(n=this.markupManager)&&n.isMarkupActive()&&(null==(i=this.markupManager)||i.deactivate()),null!=(r=this.pickMarkupHelper)&&r.isActived()&&(null==(a=this.pickMarkupHelper)||a.deactivate()),null!=(s=this.boxSelectHelper)&&s.isActived()&&(null==(o=this.boxSelectHelper)||o.deactivate()),null!=(l=this.zoomToRectHelper)&&l.isActived()&&(null==(h=this.zoomToRectHelper)||h.deactivate())}getActiveLayoutName(){return this.activeLayoutName}getLayers(){var e,t,n,i;let r=[];if(this.masterModelId){let n=this.loadedModels[this.masterModelId],i=null==(t=null==(e=null==n?void 0:n.dxfData)?void 0:e.tables)?void 0:t.layer.layers;i&&r.push({modelId:this.masterModelId,layers:i})}for(let[a,s]of Object.entries(this.loadedModels)){if(a===this.masterModelId)continue;let e=null==(i=null==(n=null==s?void 0:s.dxfData)?void 0:n.tables)?void 0:i.layer.layers;e&&r.push({modelId:a,layers:e})}return r}setModelVisibility(e,t){let n=this.loadedModels[e];if(!n||!n.dxfData)throw new Error(`Failed to find model by modelId '${e}'!`);n.dxfData.threejsObject.visible=t,this.enableRender()}setLayerVisibility(e,t,n){let i=this.camera;n=n||this.masterModelId;let r=this.loadedModels[n];if(!r)throw new Error(`Failed to find layer by modelId '${n}'!`);let a=r.dxfData,s=null==a?void 0:a.tables.layer.layers[e];s?s.visible=t:$.warn(`[DxfViewer] Layer '${e}' not found from dxfData!`);let o=null==a?void 0:a.layersAndThreejsObjects[e];if(o){let e=i.zoom;for(let n=0;n<o.length;n++){let i=o[n];this.enableHideVisuallySmallObjects&&t&&e&&i.userData.visibleMinZoom&&e<i.userData.visibleMinZoom||(i.visible=t),(!1===t||null!=i.userData.layerVisible)&&(i.userData.layerVisible=t),i.userData.isSnapObject&&(i.visible?Dt.SHOW_SNAP_OBJECT?i.layers.enableAll():i.layers.set(11):Dt.SHOW_SNAP_OBJECT?i.layers.disableAll():i.layers.disable(11))}}else $.warn(`[DxfViewer] No object found for layer '${e}'`);this.raycastableObjects=void 0,this.enableRender()}setLayerOpacity(){throw new Error("Not implemented yet!")}setLayerColor(e,t,n){n=n||this.masterModelId;let i=this.loadedModels[n];if(!i)throw new Error(`Failed to find layer by modelId '${n}'!`);let r=i.dxfData;if(!(null==r?void 0:r.tables.layer.layers[e]))throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let a=null==r?void 0:r.layersAndThreejsObjects[e];a?a.forEach((e=>{let n=e;if(n.material){n.userData.originalMaterial||(n.userData.originalMaterial=yi.cloneMaterial(n.material));let e=yi.cloneMaterial(n.material);yi.setMaterialColor(e,new Ie(t)),Dt.updateMaterialUniforms(e),n.material=e}})):$.warn(`[DxfViewer] No object found for layer '${e}'`),this.enableRender()}resetLayerColor(e,t){t=t||this.masterModelId;let n=this.loadedModels[t];if(!n)throw new Error(`Failed to find model by modelId '${t}'!`);let i=n.dxfData;if(!(null==i?void 0:i.tables.layer.layers[e]))throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let r=null==i?void 0:i.layersAndThreejsObjects[e];r?r.forEach((e=>{let t=e;t.material&&t.userData.originalMaterial&&(t.material.dispose(),t.material=t.userData.originalMaterial,delete t.userData.originalMaterial)})):$.warn(`[DxfViewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return $e(this,null,(function*(){let t=Date.now();no.isShxFile(e[0])?this.font=yield(new no).loadAsync(e):(e.length>1&&$.warn("[DxfViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new Uc).loadAsync(e[0])),$.info(`[DxfViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getScreenshot(){return $e(this,arguments,(function*(e="BoxSelection"){var t;this.cancelAllOperations();let n,i="image/png",r=null==(t=this.renderer)?void 0:t.domElement;if(!r||!this.viewerContainer||!this.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new AA(this)),n=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new Fd(this)),n=yield this.boxSelectHelper.select()),"Default"!==e&&!n)return;let a=yield it.canvasToImage(r),s=document.createElement("canvas");s.width=r.width,s.height=r.height;let o=window.devicePixelRatio,l=s.getContext("2d");if(l.drawImage(a,0,0,a.width/o,a.height/o),this.overlayRender){let e=yield this.overlayRender.getImage((e=>e instanceof Kn||e instanceof wr));l.drawImage(e,0,0,e.width/o,e.height/o)}return{base64Image:it.renderingContextToImage(l,n,i,.8),viewExtent:this.getCurrentViewExtent(),imageType:i}}))}getMeasurementManager(){return this.measurementManager}activateMeasurement(e){this.cancelAllOperations(),this.inputManager&&(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.activateMeasurement(e),this.clearSelection(),this.dispatchEvent("MeasurementActivated"))}deactivateMeasurement(){var e;null==(e=this.measurementManager)||e.deactivateMeasurement(),this.dispatchEvent("MeasurementDeactivated")}getActiveMeasurementType(){var e;return null==(e=this.measurementManager)?void 0:e.getActiveMeasurementType()}getMeasurements(){var e;return(null==(e=this.measurementManager)?void 0:e.getMeasurementsData())||[]}cancelMeasurement(){var e;null==(e=this.measurementManager)||e.cancelMeasurement()}setMeasurements(e){this.inputManager&&(this.clearMeasurements(),this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.setMeasurementsData(e))}selectMeasurement(e){this.inputManager&&(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.selectMeasurementById(e))}unselectMeasurement(){this.inputManager&&(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.unselectMeasurement())}removeMeasurement(e){this.inputManager&&(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.removeMeasurementById(e))}setMeasurementVisibility(e,t){return!!(this.inputManager&&this.measurementManager&&e)&&this.measurementManager.setMeasurementVisibility(e,t)}clearMeasurements(){var e;null==(e=this.measurementManager)||e.clearMeasurements()}getMarkupManager(){return this.markupManager}activateMarkup(e){this.cancelAllOperations(),this.inputManager&&(this.markupManager||(this.markupManager=new Gy(this,this.inputManager)),this.markupManager.isMarkupActive()||this.markupManager.activate(),this.markupManager.setDrawType(e),this.clearSelection(),this.dispatchEvent("MarkupActivated"))}deactivateMarkup(){this.markupManager&&this.markupManager.deactivate(),this.dispatchEvent("MarkupDeactivated")}getActiveMarkupType(){var e;return null==(e=this.markupManager)?void 0:e.getActiveMarkupType()}setMarkupLineColor(e){var t;null==(t=this.markupManager)||t.setLineColor(e)}getMarkupLineColor(){var e;return null==(e=this.markupManager)?void 0:e.getLineColor()}setMarkupFillColor(e){var t;null==(t=this.markupManager)||t.setFillColor(e)}getMarkupFillColor(){var e;return null==(e=this.markupManager)?void 0:e.getFillColor()}setMarkupLineWidth(e){var t;null==(t=this.markupManager)||t.setLineWidth(e)}getMarkupLineWidth(){var e;return null==(e=this.markupManager)?void 0:e.getLineWidth()}setMarkupFontSize(e){var t;null==(t=this.markupManager)||t.setFontSize(e)}getMarkupFontSize(){var e;return null==(e=this.markupManager)?void 0:e.getFontSize()}getMarkups(){var e;return(null==(e=this.markupManager)?void 0:e.getMarkupData())||[]}setMarkups(e){this.inputManager&&(this.clearMarkups(),this.markupManager||(this.markupManager=new Gy(this,this.inputManager)),this.markupManager.setMarkupData(e))}setMarkupVisibility(e,t){return!!(this.inputManager&&this.markupManager&&e)&&this.markupManager.setMarkupVisibility(e,t)}updateMarkup(e){if(!(this.inputManager&&this.markupManager&&e&&e.id))return!1;let t=!1,n=this.markupManager,i=n.getMarkupById(e.id);return i&&(n.updateMarkup(i,e),t=!0),t}removeMarkup(e){return!(!this.inputManager||!this.markupManager)&&this.markupManager.removeMarkupById(e)}clearMarkups(){var e;null==(e=this.markupManager)||e.clearAll()}addHotpoint(e){var t;if(this.hasHotpoint(e.hotpointId))return void $.warn(`[DxfViewer] Hotpoint with id '${e.hotpointId}' already exist!`);let n=e.anchorPosition,i=Ac.createHotpoint(e.html);i.position.set(n[0]||0,n[1]||0,n[2]||0),i.visible=!1!==e.visible,i.userData.hotpoint=e,this.hotpointRoot||(this.hotpointRoot=new Nt,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(i),i.updateWorldMatrix(!1,!1),this.enableRender()}removeHotpoint(e){var t,n;let i=(null==(t=this.hotpointRoot)?void 0:t.children)||[];for(let r=0;r<i.length;++r){let t=i[r];(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e&&t.removeFromParent()}}clearHotpoints(){var e;null==(e=this.hotpointRoot)||e.clear()}hasHotpoint(e){var t;return-1!==((null==(t=this.hotpointRoot)?void 0:t.children)||[]).findIndex((t=>{var n;return(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e}))}getHitResult(e){let t=this.viewerContainer;if(!this.camera||!this.raycaster||!this.groundPlane)return;let n=nn.getScreenPointByEvent(e,t),i=nn.screenPoint2NdcPoint(n,this.camera,t);return this.getHitResultByNdcCoordinate(i)}getHitResultByNdcCoordinate(e){if(!this.camera||!this.raycaster||!this.groundPlane)return;this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.set(10);let t=this.raycaster.intersectObject(this.groundPlane,!0);return t&&t.length>0?t[0].point:void 0}zoomToRect(){this.cancelAllOperations(),this.zoomToRectHelper||(this.zoomToRectHelper=new s0(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}getLayoutByName(e){let t,n=this.getLayouts();for(let i of n)if(i.layoutName===e){t=i;break}return t}getActiveLayoutInfo(){return this.getLayoutInfo(this.activeLayoutName)}getMsTransformMatrix(e){var t,n;let i=this.loadedModels[e],r=null==(t=i.dxfData)?void 0:t.header;if(!r)return;let a=r.$ANGDIR,s=this.getDxfUnits(i.dxfData),o=null==(n=i.dxfData)?void 0:n.tables.viewport.viewports.filter((e=>"*ACTIVE"===e.name.toLocaleUpperCase()));if(!o)return;let l=new Ae,h=Dt.getDcs2WcsMatrix(o[0],a),c=new M(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=H5(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0),l.multiply((new Ae).makeRotationZ(Yt.degToRad(o[0].viewTwistAngle))),l.multiply((new Ae).makeTranslation(-c.x,-c.y,0)),this.loadedModels[e].msTransformMatrix=l}switchTransformMs(e,t){var n;let i=this.loadedModels[t];if(!i)return void $.warn(`[DxfViewer] Can't find model whose modelId is ${t}`);let r=i.msTransformMatrix;if(o0.identity(),!r||r.equals(o0))return;let a=null==(n=i.dxfData)?void 0:n.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===Dt.MODEL_LAYOUT_NAME));s&&(e===Dt.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===Dt.MODEL_LAYOUT_NAME?this.getModelSpaceExtent():this.getLayoutExtent(e)}getModelSpaceExtent(){var e,t;let n=this.loadedModels[this.masterModelId],i=null==(e=n.dxfData)?void 0:e.header,r=new M,a=new M;if(!i)return void $.error(`Header is undefined in ${this.masterModelId}!`);let s=null==(t=n.dxfData)?void 0:t.tables.viewport.viewports,o=i.$EXTMIN,l=i.$EXTMAX,h=i.$ANGDIR;if(s&&s.length>0)for(let c=0;c<s.length;c++){let e=s[c];if("*ACTIVE"===e.name.toLocaleUpperCase()){let{center:t,viewHeight:n,aspectRatio:i}=e,r=n*i,a=Dt.getDcs2WcsMatrix(e,h),s=new M(t.x,t.y,0);s.applyMatrix4(a),o={x:s.x-r/2,y:s.y-n/2,z:0},l={x:s.x+r/2,y:s.y+n/2,z:0};break}}return r.set(o.x,o.y,o.z),a.set(l.x,l.y,l.z),new lt(r,a)}getLayoutExtent(e){var t;let n=null==(t=this.loadedModels[this.masterModelId].dxfData)?void 0:t.header,i=new M,r=new M;if(!n)throw new Error(`Header is undefined in ${this.masterModelId}!`);let a=this.getLayoutViewports(e),s=n.$PEXTMIN,o=n.$PEXTMAX,l=n.$ANGDIR;if(a&&a.length>0){let e,t=a.filter((e=>1===parseInt(e.viewportId)));e=t.length>0?t[0]:a[0];let{centerPoint:n,width_paperSpace:i,height_paperSpace:r}=e,h=Dt.getDcs2WcsMatrix(e,l),c=new M(n.x,n.y,0);c.applyMatrix4(h),s={x:c.x-i/2,y:c.y-r/2,z:0},o={x:c.x+i/2,y:c.y+r/2,z:0}}return i.set(s.x,s.y,s.z),r.set(o.x,o.y,o.z),new lt(i,r)}showLayoutObjects(e){Object.values(this.loadedModels).forEach((t=>{var n;let i=0,r=0,a=null==(n=t.dxfData)?void 0:n.threejsObject;null==a||a.children.forEach((t=>{let n=t.name===e;t.visible=n,n?i++:r++})),$.debug(`[DxfViewer] showLayoutObjects('${e}') sets ${i} layout level object(s) to visible and ${r} to hidden for model '${null==a?void 0:a.name}'`)}))}getLayoutViewports(e){var t;let n=this.loadedModels[this.masterModelId],i=e.ownerHandle;return(null==(t=n.dxfData)?void 0:t.layoutViewportsMap[i])||[]}setMaterialUniforms(e,t){e instanceof It&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Dt.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=Dt.viewportScaleUniform))}isLayerFrozenForViewport(e,t,n){if(!e||!t)return!1;let i=e.tables.layer.layers[t];return!!(i&&(1&i.flag)>0)||!(!n||n.length<=0)&&i&&n.indexOf(i.handle)>=0}getFilteredViewports(e){let t=this.getLayoutViewports(e),n=t.filter((e=>"1"!==e.viewportId));return n.length===t.length&&(n=t.filter(((e,t)=>0!==t))),n}generateObjectsByViewport(e,t,n,i=[]){let r=t;if("1"==t.viewportId)return;if(!r.psBBox||!r.msToPsMatrix)throw new Error("The bbox or matrix is invalid in the viewport!");Dt.transformMatrixUniform={value:r.msToPsMatrix},Dt.viewportScaleUniform={value:t.viewHeight/t.height_paperSpace};let a=r.psBBox.clone();a.applyMatrix4(r.msToPsMatrix.clone().invert()),a.min.setZ(-1),a.max.setZ(1);let s=this.getObjectsByBoundingBox(a);if(0===s.length)return;let o,l=r.psBBox.min,h=r.psBBox.max,c=new si(new Q(l.x,l.y),new Q(h.x,h.y)),u=Ic.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],n),Ic.setMaterialSection(d[e.id],u)),d[e.id]),f=[...i,...t.frozenLayerHandles||[]];if(e!==Dt.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new Nt;m.name=t.viewportId;let g=null==n?void 0:n.layersAndThreejsObjects,v=[];if(s.forEach((t=>{let i=t.clone();i.traverse((t=>{if(t.material&&t.geometry){let i=t.userData.layerName;if(this.isLayerFrozenForViewport(n,i,f))return void v.push(t);!1!==t.userData.layerVisible&&(t.visible=!0),t.material=(e=>{if(Array.isArray(e)){let t=[];return e.forEach((e=>{let n=p(e);t.push(n)})),t}return p(e)})(t.material),null==o||o.add(t),g&&g[i]?g[i].push(t):$.warn(`[DxfViewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),i.userData.boundingBox&&(i.visible=!0,delete i.userData.boundingBox),m.add(i)})),o&&0===o.size)return;let y=null==n?void 0:n.threejsObject,x=null==y?void 0:y.children.find((t=>t.name===e));x||(x=new Nt,cn.setSharedVariablesOfObject(x),x.name=e,null==y||y.add(x)),x.add(m),m.applyMatrix4(r.msToPsMatrix),m.updateMatrixWorld(!0);let _=x.children.find((e=>e.name===Dt.SNAP_GROUP_NAME));_||(_=new Nt,_.visible=Dt.SHOW_SNAP_OBJECT,_.name=Dt.SNAP_GROUP_NAME,x.add(_));let b=null==y?void 0:y.children.find((e=>e.name===Dt.MODEL_LAYOUT_NAME)),M=null==b?void 0:b.children.find((e=>e.name===Dt.SNAP_GROUP_NAME));M&&M.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(n,t,f)||(l0.makeEmpty(),l0.expandByObject(e),!a.intersectsBox(l0)))return;let i=e.clone();cn.setSharedVariablesOfObject(i);let s=i.parent,l=o0.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)l.premultiply(s.matrix),s=s.parent;l.premultiply(r.msToPsMatrix),i.applyMatrix4(l),null==_||_.add(i),null==o||o.add(i),g&&g[t]&&g[t].push(i)})),v.length>0&&cn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{cn.setSharedVariablesOfObject(e),this.addSpatialFilterSection(e,n,!0)}))}findSpatialFilter(e,t){let n,i=t.objects.SPATIAL_FILTER;if(i){for(let t of i)if(t.handle===e){n=t;break}return n}}getAnyMaterial(e){let t,n=e;if(n.material)return Array.isArray(n.material)?n.material[0]:n.material;for(let i=0;i<e.children.length&&(t=this.getAnyMaterial(e.children[i]),!t);i++);return t}addSpatialFilterSection(e,t,n=!1){if("INSERT"!==e.userData.entityType||!e.userData.spatialFilterHandle)return;let i=this.findSpatialFilter(e.userData.spatialFilterHandle,t);if(i){let t=n,r=!1,a=this.getAnyMaterial(e);if(a&&(a.clippingPlanes&&(t=a.clippingPlanes.length>0),r=a.clipIntersection),t&&r!==i.clipPolylines[0].bReversed)return void $.warn("[DxfViewer] Material cannot set clipIntersection to different values at the same time. clipIntersection needs to be set to true here!");r=i.clipPolylines[0].bReversed;let s=this.generateSectionsBySpatialFilter(i,e.matrixWorld);if(s){let n=e=>{let t=0;return e.clippingPlanes&&(t=e.clippingPlanes.length),t+s.length>Dt.maxFragmentUniforms},i=new Set,a=e=>{i.has(e.id)||(i.add(e.id),n(e)||Ic.setMaterialSection(e,s,t,r))};e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{a(e)})):t&&a(t)}))}}}getObjectsByBoundingBox(e){var t;let n=[];if(e.isEmpty())return $.warn("[DxfViewer] bbox is empty !"),n;let i=null==(t=this.loadedModels[this.masterModelId].dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===Dt.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==Dt.SNAP_GROUP_NAME&&(t=>{let i=Fr.getBoundingBox(t,!1);e.intersectsBox(i)&&n.push(t)})(t)})),n}getDxfUnits(e){if(e||Object.keys(this.loadedModels).length>0&&(e=this.loadedModels[this.masterModelId].dxfData),!e)return"Unitless";let t=null==e?void 0:e.header;if(!t)return $.warn("DxfData or its header is undefined!"),"Unitless";let n=t.$INSUNITS;return Dt.getDxfUnits(n)}generateSectionsBySpatialFilter(e,t){let n=e.clipPolylines[0];if(n.bConcave)return void $.warn("[DxfViewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");o0.copy(t),e.localMatrix&&o0.multiply(e.localMatrix);let i=n.polyline,r=[];i.forEach((e=>{let t=e.clone().applyMatrix4(o0);r.push(new Q(t.x,t.y))}));let a=Wi.isClockWise(r),s=!a&&!n.bReversed||a&&n.bReversed;return Ic.generateSectionPlanesByPoints(r,s)}addLoadedModelToScene(e,t,n,i){return $e(this,null,(function*(){if(!this.scene)return;let r=t.modelId||t.src;if(this.loadedModels[r]){let e=1;for(;this.loadedModels[`${r}_${e}`];)e++;r=`${r}_${e}`,$.warn(`[DxfViewer] Model '${r}' is loaded more than once!`)}this.loadedModels[r]={dxfData:n},e.matrixAutoUpdate=!1,e.updateMatrix(),!1!==t.merge&&(it.printMemory("Before merge"),yield Dt.merge(n,i),it.printMemory("After merged")),e.updateMatrixWorld(!0),Dt.computeLineDistances(e),this.getMsTransformMatrix(r),this.masterModelId===r?this.activateLayout(Dt.MODEL_LAYOUT_NAME):this.handleOverlayDxf(r),$.debug(n),this.scene.add(e);let a=null==n?void 0:n.threejsObject.children.find((e=>e.name===Dt.MODEL_LAYOUT_NAME));a&&this.setLayoutHidableObjectArray(a),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===r||this.enableRender()}))}resize(e,t){let n=this.camera;if(n&&t){let i=e/t;n.left=-this.frustumSize/2,n.right=this.frustumSize/2,n.top=this.frustumSize/i/2,n.bottom=-this.frustumSize/i/2,n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(e,t,!0),this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.width="0",this.css2dRenderer.domElement.style.height="0"),this.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjects(){var e;if(this.raycastableObjects)return this.raycastableObjects;let t=Date.now(),n=[];for(let i of Object.values(this.loadedModels)){let t=null==(e=i.dxfData)?void 0:e.threejsObject,r=t&&t.children.find((e=>e.name===this.activeLayoutName));r&&r.traverse((e=>{(e.visible||e.userData.isSnapObject)&&cn.isLeafObject(e)&&n.push(e)}))}return this.groundPlane&&n.push(this.groundPlane),this.raycastableObjects=n,$.debug(`[DxfViewer] getRaycastableObjects() finds ${n.length} objects`),$.debug(`[DxfViewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),n}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===Dt.MODEL_LAYOUT_NAME)return;let t=this.getLayoutByName(this.activeLayoutName);if(!t)return;let n=t=>e.x<t.min.x||e.x>t.max.x||e.y<t.min.y||e.y>t.max.y,i=this.getFilteredViewports(t);for(let r=0,a=i.length;r<a;r++){let e=i[r];if(!n(e.psBBox))return e}}getRaycastableObjectsByMouse(e){var t,n,i,r,a,s;let o=[],l=this.viewerContainer;if(!(this.raycaster&&this.camera&&this.scene&&e))return o;let h=Date.now(),c=new Q(e.x,e.y),u=nn.screenPoint2NdcPoint(c,this.camera,l);if(this.raycaster.setFromCamera(u,this.camera),$.debug("[DxfViewer] Space coordinates corresponding to the mouse position:",this.raycaster.ray.origin),this.activeLayoutName===Dt.MODEL_LAYOUT_NAME){if((null==(t=this.renderer)?void 0:t.info.render.frame)===this.lastFrame&&this.raycastableObjects)return this.raycastableObjects;if(null!=(n=this.renderer)&&n.renderLists){let e=null==(i=this.renderer)?void 0:i.renderLists.get(this.scene,0);e&&(e.opaque.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})),e.transparent.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})))}FA.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),HA.setFromProjectionMatrix(FA);for(let e of Object.values(this.loadedModels)){let t=null==(r=e.dxfData)?void 0:r.threejsObject,n=t&&t.children.find((e=>e.name===this.activeLayoutName));if(n){let e=n.children.find((e=>e.name===Dt.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(cn.isLeafObject(e)){if(l0.makeEmpty(),l0.expandByObject(e),!HA.intersectsBox(l0))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),$.debug("[DxfViewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let n=t.directAssociatedLeafObjectSet;n&&n.forEach((t=>{t.visible&&!e.has(t)&&(o.push(t),e.add(t))}))}let n=this.getViewportByPoint(this.raycaster.ray.origin);n&&n.associatedLeafObjectSet?(null==(s=n.associatedLeafObjectSet)||s.forEach((t=>{!e.has(t)&&(t.visible||t.userData.isSnapObject)&&(o.push(t),e.add(t))})),$.debug("[DxfViewer] getRaycastableObjectsByMouse() from inside of viewport:",n.viewportId)):$.debug("[DxfViewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return $.debug(`[DxfViewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){if(this.measurementManager&&this.measurementManager.isMeasurementActive()||this.markupManager&&this.markupManager.isMarkupActive()||(this.selectDrawableByEvent(e),this.selectedObject)||!this.enableSelection)return;this.raycaster&&this.raycaster.layers.set(12);let t=this.getIntersections(e);if(t.length>0){let e=e=>it.vectorToString(e);$.debug(`[DxfViewer] Clicked at: ${e(t[0].point)}`)}let n=t.find((e=>{let t=e.object;return t.visible&&!1!==t.userData.selectable})),i=n&&n.object||void 0;this.selectedObject&&this.clearSelection(),i&&this.selectedObject&&this.selectedObject.id===i.id&&(i=void 0),i?this.selectObject(i):this.clearSelection()}selectDrawableByEvent(e){var t,n;this.clearSelection();let i=this.getHitResult(e);if(!i)return;let r=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(i,this.raycaster);r&&r.length>0&&(r[0].selected=!0,this.selectedObject=r[0],null==(n=this.overlayRender)||n.render())}selectObject(e,t=!1){if(!this.enableSelection)return;let n=e=>{if(e.children.length>0&&e.children.forEach((e=>n(e))),e instanceof Ge||e instanceof sn||e instanceof or){let n=yi.clonedHighlightMaterials(e,{depthTest:t});n&&(e.userData.originalMaterial=e.material,e.material=n)}},i=e=>{if(e.children.length>0&&e.children.forEach((e=>i(e))),(e instanceof Ge||e instanceof sn||e instanceof or)&&e.userData.originalMaterial){let t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach((e=>e.dispose())):t instanceof Rn&&t.dispose()}},r=!1;this.selectedObject&&(i(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(n(e),this.selectedObject=e,e.userData.dxfEntity?$.info("[DxfViewer] Selected entity:",e.userData.dxfEntity):$.info("[DxfViewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof ns?(this.selectedObject.selected=!1,null==(e=this.overlayRender)||e.render()):this.selectObject(),this.selectedObject=void 0}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new lt;e.forEach((e=>{let n=Fr.getBoundingBox(e);n.isEmpty()||t.union(n)})),this.zoomToBBox(t)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Ar&&e.userData.clonedMesh||e instanceof Ge&&gr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e;let t=this.scene,n=[];for(let c of Object.values(this.loadedModels)){let t=null==(e=c.dxfData)?void 0:e.threejsObject;t&&n.push(t.id)}let i=n.length;if(i<=0)return;let r=n[Math.floor(Math.random()*i)],a=t.getObjectById(r);if(!a)return;let s=this.getActiveLayoutName();if(!a.children.find((e=>e.name===s)))return;let o=[];if(t.traverseVisible((e=>{(e instanceof Ge||e instanceof sn)&&!["SKYBOX","GROUND_GRID","GRASS_GROUND","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&o.push(e.id)})),o.length<1)return;let l=Math.floor(Math.random()*o.length),h=t.getObjectById(o[l]);h&&($.info(`[DxfViewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0),this.flyToObject(h))}flyTo(e,t,n,i){let r=this.camera,a=this.controls;if(!r||!a)return;if(n&&(n=this.checkAndGetLimitedCameraZoom(n)),e.equals(t))return void $.error("[DxfViewer] Camera position and lookAt cannot be the same!");if(!it.isVectorValid(e)||!it.isVectorValid(t))return void $.error("[DxfViewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);s<r.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*r.near),$.warn("[DxfViewer] Camera could be too close to see the object!")):s>r.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),$.warn("[DxfViewer] Camera could be too far to see the object!"));let o=(e,t,n)=>{n&&Number.isFinite(n)&&a.zoomTo(n),a.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z),this.updateHidableObjectsVisibility(),this.enableRender()};if(!1===i)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void o(e,t,n);let l=r.position.clone(),h=a.getTarget(new M),c=r.zoom,u=300,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let i=Date.now()-d;i>u&&(i=u);let r,a=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new M(i,r,a)},s=a(l,e,i/u),p=a(h,t,i/u);n&&(r=c+(n-c)*i/u),o(s,p,r),i>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}goTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;let a=new M(e.x,e.y,i.position.z),s=r.getTarget(new M),o=new M(e.x,e.y,s.z);this.flyTo(a,o,t,n)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):$.error(`[DxfViewer] Failed to find extent for ${this.activeLayoutName}`)}zoomToBBox(e){let t=this.camera;if(!t)return;let n=e.max.x-e.min.x,i=e.max.y-e.min.y,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);s/=1.1;let o=new lt(new M(e.min.x,e.min.y,0),new M(e.max.x,e.max.y,0)),l=new M;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[DxfViewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.zoomToBBox(n.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,n){this.scene&&(this.scene.background=new Ie(e,t,n),this.enableRender())}getLayoutInfo(e){return this.layoutInfos[e]||(this.layoutInfos[e]={}),this.layoutInfos[e]}updateGroundPlane(){if(!this.scene)return;let e=this.getActiveLayoutInfo();if(!e.homeViewExtent)return;let t=e.homeViewExtent.clone();it.expandBoxByScale(t,3);let n=t.min,i=t.max,r=i.x-n.x+i.y-n.y+i.z-n.z;it.expandBoxByMinSize(t,r);let a=[],s=(e,t,n)=>{a.push(new M(e,t,n))},o=t.getSize(new M),l=t.getCenter(new M);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.copy(l),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new et;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new Pt({color:"#888",transparent:!0,opacity:0,side:tr});this.groundPlane=new Ge(e,t),this.groundPlane.visible=!1,this.groundPlane.frustumCulled=!1,this.groundPlane.position.copy(l),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.userData.selectable=!1,this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),cn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new lt;for(let n of Object.values(this.loadedModels)){let i=null==(e=n.dxfData)?void 0:e.threejsObject;for(let e=0;i&&e<i.children.length;++e){let n=i.children[e];if(n.name===this.activeLayoutName){let e=Fr.getBoundingBox(n,!1);e.isEmpty()||t.union(e)}}}return t.min.z=0,t.max.z=0,$.info(`[DxfViewer] computeBoundingBox(), BBox's max: ${t.max.toArray()}, min: ${t.min.toArray()}`),t}checkAndGetLimitedCameraZoom(e){if(!e)return 1;let t=e;return e<this.CAMERA_MIN_ZOOM&&($.warn(`[DxfViewer] Attampting to set camera's zoom value to ${e}, will use ${this.CAMERA_MIN_ZOOM}`),t=this.CAMERA_MIN_ZOOM),t}setVisibilityByCameraFrustum(){var e;if(!this.camera)return;let t=Date.now();FA.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),HA.setFromProjectionMatrix(FA);for(let n of Object.values(this.loadedModels)){let t=null==(e=n.dxfData)?void 0:e.threejsObject;!t||!t.visible||t.children.forEach((e=>{e.visible&&e.children.forEach((e=>{e.userData.boundingBox&&(HA.intersectsBox(e.userData.boundingBox)?e.visible=!0:e.visible=!1)}))}))}$.debug(`[DxfViewer] setVisibilityByCameraFrustum cost: ${(Date.now()-t)/1e3}s`)}getVisiblePixelSize(e){let t=6.5*Yt.smoothstep(e,1e4,3e4)+.5;return $.debug("[DxfViewer] visiblePixelSize:",t),t}setLayoutHidableObjectArray(e){let t=this.camera;if(!this.enableHideVisuallySmallObjects||!t)return;let n=Date.now(),i=e.name;this.sortedHidableObjects[i]||(this.sortedHidableObjects[i]=[]);let r=this.sortedHidableObjects[i];this.controls.update(0);let a=t.zoom;this.lastCameraZoom=a;let s=e=>{if(!this.isCompareMode()||!e.material)return!1;let t;return t=e.material instanceof It?e.material.uniforms.u_color.value:e.material.color,t.equals(new Ie(Zr.ENTITY_COLOR_ADDED))||t.equals(new Ie(Zr.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!cn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let n=t.boundingBox.clone();if(!n||!it.isBoxValid(n))return;n.applyMatrix4(e.matrixWorld),n.getSize($H);let i=Math.max($H.x,$H.y),a=o/i;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof or?r.push({visibleMinZoom:o,object:e}):$.warn("[DxfViewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),$.debug(`[DxfViewer] setLayoutHidableObjectArray cost: ${(Date.now()-n)/1e3}s, ${l} objects changed to hidden`)}statObjects(e){let t=this.sortedHidableObjects[this.activeLayoutName],n=t.length,i={},r=0;t.forEach((t=>{let n=t.object;if(n.geometry&&n.material){r++;let n=(t=>{let n=0,i=t;for(;i&&(n++,i!==e);)i=i.parent;return n})(t.object);i[n]||(i[n]=0),i[n]++}}));let a=0;e.traverse((e=>{let t=e;t.geometry&&t.material&&a++})),$.info(`[DxfViewer] hidableObjects count:${n}, real count:${r}, layout count: ${a}, level:`,i),$.info("[DxfViewer] scene:",this.scene)}updateHidableObjectsVisibility(){let e=this.camera;if(!e)return;let t=Date.now();this.controls.update(0);let n=e.zoom;if(Math.abs(n-this.lastCameraZoom)<1e-5||(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(n),this.raycastableObjects=void 0,!this.sortedHidableObjects[this.activeLayoutName]))return;let i=this.sortedHidableObjects[this.activeLayoutName];if(0===i.length)return;let r=n>this.lastCameraZoom,a=Math.min(n,this.lastCameraZoom),s=Math.max(n,this.lastCameraZoom),o=[],l=0;for(let h=0;h<i.length;++h)if(!1!==i[h].object.userData.layerVisible){if(i[h].visibleMinZoom<a){o.push(i[h].object);continue}if(i[h].visibleMinZoom>s)break;i[h].object.visible=r,r&&o.push(i[h].object),l++}this.lastCameraZoom=n,$.debug(`[DxfViewer] updateHidableObjectsVisibility cost: ${(Date.now()-t)/1e3}s, ${l}(out of ${i.length}) objects changed to ${r?"visible":"hidden"}`)}updateRaycasterThreshold(){if(!this.camera||!this.raycaster)return;let e=3*this.getPixelSizeInWorldCoord(),t=this.raycaster.params;t.Line?t.Line.threshold=e:t.Line={threshold:e},t.Points?t.Points.threshold=e:t.Points={threshold:e}}updateCameraZoomUniform(e){Dt.cameraZoomUniform.value=e}},Qde=class{constructor(e,t){this.enableSyncCamera=!1,this.jobCount=0,this.syncCamera=(e,t,n)=>{let i=new M,r=new M,a=new M;e.getPosition(r),e.getTarget(a),e.getFocalOffset(i),t.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z),t.zoomTo(n)},this.viewer1=new $E(e),this.viewer2=new $E(t);let n=document.getElementById(e.containerId);this.container=(null==n?void 0:n.parentElement)||document.body,this.loadingProgressBar=new Zv(this.container),this.loader=new Dt(this.loadingManager,!0),this.initSyncCameraEvent(),this.initSpinner()}initSyncCameraEvent(){let e=this.viewer1.controls,t=this.viewer2.controls,n=!1;e.addEventListener("control",(()=>{n=!1})),e.addEventListener("update",(()=>{!this.enableSyncCamera||n||this.syncCamera(e,t,this.viewer1.camera.zoom)})),t.addEventListener("control",(()=>{n=!0})),t.addEventListener("update",(()=>{!this.enableSyncCamera||!n||this.syncCamera(t,e,this.viewer2.camera.zoom)}))}initSpinner(){let e=document.createElement("div");e.classList.add("gemini-spinner"),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),this.container.appendChild(e),this.spinner=e,this.setSpinnerVisibility(this.jobCount>0)}setFont(e){return $e(this,null,(function*(){let t=Date.now();no.isShxFile(e[0])?this.font=yield(new no).loadAsync(e):(e.length>1&&$.warn("[DxfViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new Uc).loadAsync(e[0])),$.info(`[DxfViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,n){return $e(this,null,(function*(){var i,r,a,s,o;let{src:l,modelId:h}=e,{src:c,modelId:u}=t;this.viewer1.masterModelId=h||l,this.viewer2.masterModelId=u||c;let d=Date.now();if(this.increaseJobCount(),!this.font)return Promise.reject("[DxfViewer] Should set font first!");this.loader.setFont(this.font),this.font instanceof to&&this.font.getFontData&&(yield this.font.getFontData());let p=l+c,f=UE.t("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),n&&n(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),n&&n(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};it.printMemory("Before comparing"),null==(i=this.loadingProgressBar)||i.addProgressItem(p),m(0);let v=Date.now(),y=yield this.loader.parse(l,(e=>g(e,0,15))),x=yield this.loader.parse(c,(e=>g(e,15,30))),[_,b]=yield Promise.allSettled([y,x]);if("rejected"===_.status)return Promise.reject(`[DxfViewer] Failed to parse ${l}`);if("rejected"===b.status)return Promise.reject(`[DxfViewer] Failed to parse ${c}`);if($.info(`[DxfViewer] loadFiles in ${(Date.now()-v)/1e3}s`),Dt.abortJobs)return Promise.reject("[DxfViewer] compare loadFile aborted");let M=_.value,w=b.value;v=Date.now();let S=yield new Zr(M,w).compare((e=>g(e,30,60)));if($.info(`[DxfViewer] Compared in ${(Date.now()-v)/1e3}s`),$.debug("Compared results:",S),Dt.abortJobs)return Promise.reject("[DxfViewer] compare change aborted");it.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(M,w,S,!1,(e=>g(e,60,95))),it.printMemory("After Creating threejs objects based on comparison result"),null==(r=this.font)||r.releaseFontData(),this.changes=S,$.info(`[DxfViewer] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=M,T=w;if(this.decreaseJobCount(),Object.keys(S).length||$.info("[DxfViewer] No change found"),0===(null==(a=E.threejsObject)?void 0:a.children.length)&&0===(null==(s=T.threejsObject)?void 0:s.children.length)){let e=`[DxfViewer] Nothing was loaded from ${l} and ${c}`;return $.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=l,C.name=c,v=Date.now(),this.viewer1.addLoadedModelToScene(A,yn({},e),E),it.printMemory("After adding first loaded Model to scene"),m(95),this.viewer2.addLoadedModelToScene(C,yn({},t),T),it.printMemory("After adding second loaded Model to scene"),$.info(`[DxfViewer] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),$.info(`[DxfViewer] The comparison between ${l}' and '${c}' is completed in ${(Date.now()-d)/1e3}s !`),m(100),null==(o=this.loadingProgressBar)||o.delayRemoveProgressItem(p),Promise.resolve()}))}getCompareChanges(){return this.changes}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&(this.viewer1.zoomToBBox(n.clone().expandByScalar(1.2)),this.viewer2.zoomToBBox(n.clone().expandByScalar(1.2)))}}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.setSpinnerVisibility(--this.jobCount>0)}},zp=wi(efe(),1),th=class{constructor(e,t){this.current=e,this.next=t,this.inNormal=this.inwardsNormal(),this.outNormal=this.outwardsNormal()}outwardsNormal(){let e=this.inwardsNormal();return[-e[0],-e[1]]}inwardsNormal(){let e=this.next[0]-this.current[0],t=this.next[1]-this.current[1],n=Math.sqrt(e*e+t*t);if(0===n)throw new Error("Vertices overlap");return[-t/n,e/n]}offset(e,t){return th.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return th.offsetEdge(this.next,this.current,e,t)}inverse(){return new th(this.next,this.current)}static offsetEdge(e,t,n,i){return new th([e[0]+n,e[1]+i],[t[0]+n,t[1]+i])}},ZE=Array.isArray,tfe=(e,t)=>e[0]===t[0]&&e[1]===t[1],JH=e=>Array.isArray(e)&&e.length,rfe=(e,t=0,n=!1)=>{let i,r;if(JH(e)&&"number"==typeof e[0][0]){let t=0,a=e;for(i=0,r=a.length;i<r;i++){let e=a[i],n=a[(i+1)%r];t+=e[0]*n[1],t-=n[0]*e[1]}(!n&&t>0||n&&t<0)&&a.reverse()}else for(i=0,r=e.length;i<r;i++)rfe(e[i],t+1,i>0);if(0===t&&JH(e)&&JH(e[0])&&"number"==typeof e[0][0][0]){let t=e[0].slice(0,1)[0];e[0].pop(),e[0].push([t[0],t[1]])}return e},nfe=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!ZE(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],ZE(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=rfe(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let n,i;if(ZE(e[0])&&"number"==typeof e[0][0])for(i=e.length,tfe(e[0],e[i-1])&&(i-=1),n=0;n<i;n++)t.push(new th(e[n],e[(n+1)%i]));else for(n=0,i=e.length;n<i;n++)t.push([]),this.processContour(e[n],t[t.length-1])}setArcSegments(e){return this.arcSegments=e,this}createArc(e,t,n,i,r,a,s){let o=2*Math.PI,l=Math.atan2(i[1]-t[1],i[0]-t[0]),h=Math.atan2(r[1]-t[1],r[0]-t[0]);a%2==0&&(a-=1),l<0&&(l+=o),h<0&&(h+=o);let c=l>h?l-h:l+o-h,u=(s?-c:o-c)/a;e.push(i);for(let d=1;d<a;++d)c=l+u*d,e.push([t[0]+Math.cos(c)*n,t[1]+Math.sin(c)*n]);return e.push(r),e}setDistance(e){return this.distance=e,this}ensureLastPoint(e){return tfe(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e}offset(e){return this.setDistance(e),0===this.distance?this.vertices:this.distance>0?this.margin(this.distance):this.padding(-this.distance)}offsetSegment(e,t,n,i){let r=[n.offset(n.inNormal[0]*i,n.inNormal[1]*i),n.inverseOffset(n.outNormal[0]*i,n.outNormal[1]*i)],a=[];for(let s=0,o=2;s<o;s++){let n=r[s],l=r[(s+o-1)%o];this.createArc(a,0===s?e:t,i,l.next,n.current,this.arcSegments,!0)}return a}margin(e){if(this.setDistance(e),"number"==typeof this.vertices[0])return this.offsetPoint(this.distance);if(0===e)return this.vertices;let t=this.offsetLines(this.distance);return t=(0,zp.union)(this.vertices,t),t}padding(e){if(this.setDistance(e),0===this.distance)return this.vertices;if(2===this.vertices.length&&"number"==typeof this.vertices[0])return this.vertices;let t=this.offsetLines(this.distance);return(0,zp.difference)(this.vertices,t)}offsetLine(e){return 0===e?this.vertices:this.offsetLines(e)}offsetLines(e){if(e<0)throw new Error("Cannot apply negative margin to the line");this.setDistance(e);let t=[];if(ZE(this.vertices[0])&&"number"!=typeof this.vertices[0][0]){let e=[];for(let t=0,n=this.edges.length;t<n;t++){let n=this.offsetContour(this.vertices[t],this.edges[t]);n.length>0&&e.push(n)}e.length>0&&(t=1===e.length?e[0]:(0,zp.union)(e[0],...e.slice(1)))}else t=1===this.vertices.length?this.offsetPoint(e):this.offsetContour(this.vertices,this.edges);return t}offsetContour(e,t){let n=[],i=0,r=0;if(ZE(e[0])&&"number"==typeof e[0][0]){for(i=0,r=e.length-1;i<r;i++){let r=[this.ensureLastPoint(this.offsetSegment(e[i],e[i+1],t[i],this.distance))];n.push(r)}n.length>0&&(n=1===n.length?[n[0]]:(0,zp.union)(n[0],n.slice(1)))}else{let a=[];for(i=0,r=t.length;i<r;i++){let n=this.offsetContour(e[i],t[i]);n.length>0&&a.push(n)}a.length>0&&(n=1===a.length?a[0]:(0,zp.union)(a[0],...a.slice(1)))}return n}offsetPoint(e){this.setDistance(e);let t=2*this.arcSegments,n=[],i=this.vertices,r=this.distance,a=0;t%2==0&&t++;for(let s=0;s<t;s++)a+=2*Math.PI/t,n.push([i[0]+r*Math.cos(a),i[1]+r*Math.sin(a)]);return[[this.ensureLastPoint(n)]]}},KE=class{constructor(e="uploadModelFile"){this.input=document.createElement("input"),this.input.id=e,this.input.type="file",this.input.multiple=!0,this.input.accept=this.formats().map((e=>"."+e)).join(","),this.input.style.display="none",this.input.onchange=e=>{let t=e.target.files;!t||t.length<=0?$.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return $.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){$.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},kA=class extends KE{constructor(e,t){super(t),this.defaultModelConfig={src:"",position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],instantiate:!1,merge:!1},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;let n,i,r,a=yn({},this.defaultModelConfig),s=new Map;for(let h=0;h<t;h++){let t=e[h];s.set(t.name,t),t.name.match(/\.(gltf|glb)$/)&&(r=t)}let o=[],l=()=>{r&&(n=URL.createObjectURL(r),o.push(n),a.src=r.name)};if(r){l();let e=ts.extractUrlBase(n);i=new Tc,i.setURLModifier((t=>{let n=decodeURI(t).replace(e,"").replace(/^(\.?\/)/,"");if(s.has(n)){let e=s.get(n),t=URL.createObjectURL(e);return o.push(t),t}return t}))}else r=e[0],l();this.viewer.loadLocalModel(n,a,i,(e=>{let t=Math.floor(100*e.loaded/e.total);$.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{$.info(`[Uploader] Loaded ${null==r?void 0:r.name}`),o.forEach(URL.revokeObjectURL)}))}},ife=class extends KE{constructor(e,t){super(t),this.defaultModelConfig={src:"",position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],instantiate:!1,merge:!0},this.viewer=e}formats(){return["dxf"]}uploadFiles(e){let t=e=>{let t=(100*e.loaded/e.total).toFixed(1);$.info(`[Uploader] Progress: ${t}%`)},n=new Tc,i=[],r=new Map;for(let s=0;s<e.length;s++){let t=e[s];r.set(t.name,t),t.name.match(/\.(dxf)$/)&&i.push(t)}let a=[];if(n.setURLModifier((e=>{let t=decodeURI(e).replace(/^(.?[\/ | \\]+)/,"");if(r.has(t)){let e=r.get(t),n=URL.createObjectURL(e);return a.push(n),n}return e})),this.viewer.setLoadingManager(n),2===i.length){let e=i[0],n=i[1],r=URL.createObjectURL(e),a=URL.createObjectURL(n);this.viewer.compare({src:r,modelId:e.name},{src:a,modelId:n.name},t).then((()=>{this.onSuccess&&this.onSuccess({compare:!0}),$.debug(`[Uploader] Compared models: ${r}, ${a}`)})).catch((e=>{$.error(`[Uploader] Failed to compare models: ${r}, ${a}. reason: ${e}`)}))}else{let n=i[0],r=URL.createObjectURL(n),a=yn({},this.defaultModelConfig);a.src=r,a.modelId=n.name;try{this.viewer.loadModelAsync(a,t).then((()=>{this.onSuccess&&this.onSuccess({}),$.info(`[Uploader] Loaded model '${a.src}'`)}))}catch(e){$.info(e)}}}},sfe=class extends KE{constructor(e,t){super(t),this.viewer=e}formats(){return["png","jpg","jpeg"]}uploadFiles(e){let t={panoramas:[],id:"viewpoint_1",name:"",position:[0,1,0],initialDirection:[0,0,1]};if(1===e.length){let n=[];n.push(URL.createObjectURL(e[0])),t.panoramas.push({id:"panorama_1",images:n}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else if(6===e.length){let n=t=>{let n="";for(let i=0;i<e.length;++i){let r=e[i].name;r=r.slice(0,r.indexOf(".")),r=r.toLowerCase();let a=!1;for(let e=0;e<t.length;++e)if(t[e]===r){a=!0;break}if(a){n=URL.createObjectURL(e[i]);break}}return n},i=[n(["right","r"]),n(["left","l"]),n(["up","top","u"]),n(["down","bottom","d"]),n(["front","f"]),n(["back","b"])];t.panoramas.push({id:"panorama_1",images:i}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else $.warn(`[Uploader] Expected 1 or 6 file, bug got ${e.length}!`)}},qp=wi(Ll(),1),afe=new M,Tot=new En,ofe=new M,Gp=class extends Tt{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}},jc=new Ae,wot=new Ae,VA=class{constructor(e={}){let t,n,i,r,a=this,s={camera:{fov:0,style:""},objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;let l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);let h=document.createElement("div");function c(e){return Math.abs(e)<1e-10?0:e}function u(e){let t=e.elements;return"matrix3d("+c(t[0])+","+c(-t[1])+","+c(t[2])+","+c(t[3])+","+c(t[4])+","+c(-t[5])+","+c(t[6])+","+c(t[7])+","+c(t[8])+","+c(-t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(-t[13])+","+c(t[14])+","+c(t[15])+")"}function d(e){let t=e.elements;return"translate(-50%,-50%)matrix3d("+c(t[0])+","+c(t[1])+","+c(t[2])+","+c(t[3])+","+c(-t[4])+","+c(-t[5])+","+c(-t[6])+","+c(-t[7])+","+c(t[8])+","+c(t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(t[13])+","+c(t[14])+","+c(t[15])+")"}function p(e,t,n,i){if(e.isCSS3DObject){let i=!0===e.visible&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===i?"":"none",!0===i){let i;e.onBeforeRender(a,t,n),e.isCSS3DSprite?(jc.copy(n.matrixWorldInverse),jc.transpose(),0!==e.rotation2D&&jc.multiply(wot.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(afe,Tot,ofe),jc.setPosition(afe),jc.scale(ofe),jc.elements[3]=0,jc.elements[7]=0,jc.elements[11]=0,jc.elements[15]=1,i=d(jc)):i=d(e.matrixWorld);let r=e.element,o=s.objects.get(e);if(void 0===o||o.style!==i){r.style.transform=i;let t={style:i};s.objects.set(e,t)}r.parentNode!==h&&h.appendChild(r),e.onAfterRender(a,t,n)}}for(let r=0,a=e.children.length;r<a;r++)p(e.children[r],t,n,i)}h.style.transformStyle="preserve-3d",l.appendChild(h),this.getSize=function(){return{width:t,height:n}},this.render=function(e,a){let o,d,f=a.projectionMatrix.elements[5]*r;s.camera.fov!==f&&(l.style.perspective=a.isPerspectiveCamera?f+"px":"",s.camera.fov=f),a.view&&a.view.enabled?(l.style.transform=`translate( ${-a.view.offsetX*(t/a.view.width)}px, ${-a.view.offsetY*(n/a.view.height)}px )`,l.style.transform+=`scale( ${a.view.fullWidth/a.view.width}, ${a.view.fullHeight/a.view.height} )`):l.style.transform="",!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===a.parent&&!0===a.matrixWorldAutoUpdate&&a.updateMatrixWorld(),a.isOrthographicCamera&&(o=-(a.right+a.left)/2,d=(a.top+a.bottom)/2);let m=a.view&&a.view.enabled?a.view.height/a.view.fullHeight:1,g=a.isOrthographicCamera?`scale( ${m} )scale(`+f+")translate("+c(o)+"px,"+c(d)+"px)"+u(a.matrixWorldInverse):`scale( ${m} )translateZ(`+f+"px)"+u(a.matrixWorldInverse),v=g+"translate("+i+"px,"+r+"px)";s.camera.style!==v&&(h.style.transform=v,s.camera.style=v),p(e,e,a,g)},this.setSize=function(e,a){t=e,n=a,i=t/2,r=n/2,o.style.width=e+"px",o.style.height=a+"px",l.style.width=e+"px",l.style.height=a+"px",h.style.width=e+"px",h.style.height=a+"px"}}},lfe="#2C7BE5",Mr=Math.PI/2,Jn=Math.PI/4,Yi=([e,t,n],[i,r,a])=>({position:new M(e,t,n),rotation:new rn(i,r,a)}),Mot={Front:Qr(yn({},Yi([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:Qr(yn({},Yi([1,0,0],[0,Mr,0])),{label:"NavCube.right"}),Back:Qr(yn({},Yi([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:Qr(yn({},Yi([-1,0,0],[0,-Mr,0])),{label:"NavCube.left"}),Top:Qr(yn({},Yi([0,1,0],[-Mr,0,0])),{label:"NavCube.top"}),Bottom:Qr(yn({},Yi([0,-1,0],[Mr,0,0])),{label:"NavCube.bottom"})},Sot=[Yi([0,1,1],[-Jn,0,-Mr]),Yi([0,1,-1],[-3*Jn,0,-Mr]),Yi([0,-1,1],[Jn,0,-Mr]),Yi([0,-1,-1],[3*Jn,0,-Mr]),Yi([1,1,0],[-Mr,Jn,0]),Yi([1,-1,0],[-Mr,3*Jn,0]),Yi([-1,1,0],[-Mr,-Jn,0]),Yi([-1,-1,0],[-Mr,-3*Jn,0]),Yi([1,0,1],[0,Jn,0]),Yi([1,0,-1],[0,3*Jn,0]),Yi([-1,0,1],[0,-Jn,0]),Yi([-1,0,-1],[0,-3*Jn,0])],Rot=[{position:new M(1,1,1),rotation:[new rn(-Mr,Mr,-Jn),new rn(-Mr,0,Jn),new rn(0,0,3*Jn)]},{position:new M(1,1,-1),rotation:[new rn(0,Mr,3*Jn),new rn(-Mr,0,3*Jn),new rn(0,Math.PI,-3*Jn)]},{position:new M(-1,1,-1),rotation:[new rn(Math.PI,-Mr,Jn),new rn(-Mr,0,-3*Jn),new rn(0,Math.PI,3*Jn)]},{position:new M(-1,1,1),rotation:[new rn(0,-Mr,3*Jn),new rn(-Mr,0,-Jn),new rn(0,0,-3*Jn)]},{position:new M(1,-1,1),rotation:[new rn(0,Mr,-Jn),new rn(-Mr,Math.PI,-Jn),new rn(0,0,Jn)]},{position:new M(1,-1,-1),rotation:[new rn(-Mr,Mr,3*Jn),new rn(Mr,0,Jn),new rn(0,Math.PI,-Jn)]},{position:new M(-1,-1,1),rotation:[new rn(0,-Mr,Jn),new rn(Mr,0,-3*Jn),new rn(0,0,-Jn)]},{position:new M(-1,-1,-1),rotation:[new rn(0,-Mr,-Jn),new rn(Mr,0,-Jn),new rn(0,Math.PI,Jn)]}],zA=class extends Tt{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,qp.forEach)(Mot,(e=>{this.createPlane(e)})),(0,qp.forEach)(Sot,(e=>{this.createEdge(e)})),(0,qp.forEach)(Rot,((e,t)=>{this.createCorner(e,t)}))}createPlane(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),{rotation:n,label:i}=e,r=document.createElement("div");r.style.width=this.NAVCUBE_SIZE+"px",r.style.height=this.NAVCUBE_SIZE+"px",r.classList.add("navcube-plane"),r.classList.add("outer");let a=document.createElement("div");a.style.width=this.NAVCUBE_SIZE-4+"px",a.style.height=this.NAVCUBE_SIZE-4+"px",a.innerHTML=zc(i),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new Gp(r);s.position.copy(t),s.rotation.copy(n),this.add(s),r.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),n)}))}createEdge(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),n=document.createElement("div");n.style.width="4px",n.style.height=this.NAVCUBE_SIZE-40+"px",n.style.background=lfe,n.classList.add("navcube-edge");let i=new Gp(n);i.position.copy(t),i.rotation.copy(e.rotation),this.add(i),n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),e.rotation)}))}createCorner(e,t){let n=n=>{n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(e.position.clone().normalize(),new rn)})),n.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,qp.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),n.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,qp.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.remove("highlight")}))}))},i=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2+.5),r=document.createElement("div");r.style.borderTop=14*Math.sqrt(3)+"px solid #efefef",r.style.borderLeft="14px solid transparent",r.style.borderRight="14px solid transparent",r.classList.add("navcube-corner"),r.classList.add("group-"+t);let a=new Gp(r);a.position.copy(i).lerp(e.position,.14);let s=Math.atan2(i.z,i.x);a.rotateY(i.z*i.x<0?Math.PI+s:s);let o=(new rn).setFromVector3(i.clone().normalize());a.rotateX(-o.y),i.y<0&&a.rotateZ(Math.PI),this.add(a);let l=(t,r,a)=>{let s=document.createElement("div");s.style.borderTop=`13px solid ${lfe}`,s.style.borderLeft="13px solid transparent",s.style.borderRight="13px solid transparent",s.classList.add("navcube-corner-plane"),s.classList.add("group-"+r);let o=new Gp(s),l=e.position.clone();l.setComponent(a,0),o.position.copy(i).sub(l),o.rotateX(t.x),o.rotateY(t.y),o.rotateZ(t.z),this.add(o),n(s)};(0,qp.forEach)(e.rotation,((e,n)=>{l(e,t,n)})),n(r)}},GA=class{constructor(e,t){this.height=150,this.width=150,this.width=e||this.width,this.height=t||this.height,this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){this.renderer=new VA,this.renderer.setSize(this.width,this.height),this.renderer.domElement.classList.add("css3d-navcube"),document.body.appendChild(this.renderer.domElement)}initScene(){this.scene=new ii;let e=window.innerWidth/window.innerHeight;this.camera=new dr(200*e/-2,200*e/2,100,-100,1,1e3),this.camera.position.set(-200,200,200),this.scene.add(this.camera),this.navCube=new zA({onClick:e=>{if(!(this.camera&&e&&this.hostViewer&&this.hostViewer.camera&&this.hostViewer.controls))return;let t=this.hostViewer.controls instanceof ba?this.hostViewer.controls.getTarget(new M):this.hostViewer.controls.target,n=this.hostViewer.camera.position.distanceTo(t);this.hostViewer.flyTo(t.clone().add(e.clone().multiplyScalar(n)),t)}}),this.scene.add(this.navCube)}render(){this.renderer&&this.scene&&this.camera&&(this.update(),this.renderer.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}setHostViewer(e){this.hostViewer=e,this.update()}update(){if(!this.hostViewer||!this.hostViewer.camera)return;let e=this.hostViewer.camera;if(e){let t=new M;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(20*-e.x+0,20*-e.y+0,20*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t)}dispose(){!this.scene||!this.camera||!this.navCube||(this.scene.clear(),this.hostViewer=void 0,this.camera=void 0,this.navCube=void 0,this.scene=void 0)}},Aot=new M(1,0,0),Cot=new M(0,1,0),Pot=new M(0,0,1),qA=class extends Ld{constructor(e,t){super(e,t);let{min:n,max:i}=this.sectionBox;this.sectionRange={x:[n.x,i.x],y:[n.y,i.y],z:[n.z,i.z]}}activate(){super.activate(),this.initOrUpdateClipPlane(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.setClippingEnable(!0)}deactivate(){super.deactivate(),this.planesMesh&&this.scene.remove(...this.planesMesh),this.planesMesh=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new M(t.x,t.y,t.z),new M(e.x,t.y,t.z),new M(e.x,e.y,t.z),new M(t.x,e.y,t.z),new M(t.x,t.y,e.z),new M(e.x,t.y,e.z),new M(e.x,e.y,e.z),new M(t.x,e.y,e.z)]}initOrUpdateClipPlane(){let{min:e,max:t}=this.sectionBox;this.clipPlanes?(this.clipPlanes[0].constant=t.x,this.clipPlanes[1].constant=-e.x,this.clipPlanes[2].constant=t.y,this.clipPlanes[3].constant=-e.y,this.clipPlanes[4].constant=t.z,this.clipPlanes[5].constant=-e.z):this.clipPlanes=[new er(new M(-1,0,0),t.x),new er(new M(1,0,0),-e.x),new er(new M(0,-1,0),t.y),new er(new M(0,1,0),-e.y),new er(new M(0,0,-1),t.z),new er(new M(0,0,1),-e.z)]}initOrUpdateSectionPlane(){let e=this.vertices;if(e){if(this.planesMesh)this.planesMesh[0].update([e[4],e[0],e[3],e[7]]),this.planesMesh[1].update([e[1],e[5],e[6],e[2]]),this.planesMesh[2].update([e[4],e[5],e[1],e[0]]),this.planesMesh[3].update([e[6],e[7],e[3],e[2]]),this.planesMesh[4].update([e[0],e[1],e[2],e[3]]),this.planesMesh[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new Pr("Right",[e[4],e[0],e[3],e[7]]),new Pr("Left",[e[1],e[5],e[6],e[2]]),new Pr("Top",[e[4],e[5],e[1],e[0]]),new Pr("Bottom",[e[6],e[7],e[3],e[2]]),new Pr("Front",[e[0],e[1],e[2],e[3]]),new Pr("Back",[e[5],e[4],e[7],e[6]])];this.planesMesh=t,this.scene.add(...t)}this.viewer.enableRender()}}activateSelectedObject(e){var t;null==(t=this.selectedObject)||t.setActive(e)}onDragStart(e){var t;this.selectedObject&&(this.controls&&this.dragStarted&&(this.controls.enableRotate=!1),$.info("[ObjectsBoxSection] onDragStart:",e),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),this.selectedObject.getPlaneCenter()),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos))}onDragMove(e){var t;if(!this.lastWorldPos||!this.selectedObject)return;let n=new M;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,n);let i=this.selectedObject.actionType;switch(i){case"Top":case"Bottom":this.dragTranslateSectionPlane(Cot,this.lastWorldPos,n,i);break;case"Left":case"Right":this.dragTranslateSectionPlane(Aot,this.lastWorldPos,n,i);break;case"Front":case"Back":this.dragTranslateSectionPlane(Pot,this.lastWorldPos,n,i)}this.lastWorldPos=n}onDragEnd(e){this.controls&&!this.controls.enableRotate&&(this.controls.enableRotate=!0),$.info("[ObjectsBoxSection] onDragEnd:",e)}dragTranslateSectionPlane(e,t,n,i){let r,{min:a,max:s}=this.sectionBox,o=n.clone().sub(t).projectOnVector(e);switch(i){case"Top":r=s.y+o.y,this.isInRange(r,this.sectionRange.y)&&(s.y=r);break;case"Bottom":r=a.y+o.y,this.isInRange(r,this.sectionRange.y)&&(a.y=r);break;case"Left":r=a.x+o.x,this.isInRange(r,this.sectionRange.x)&&(a.x=r);break;case"Right":r=s.x+o.x,this.isInRange(r,this.sectionRange.x)&&(s.x=r);break;case"Front":r=s.z+o.z,this.isInRange(r,this.sectionRange.z)&&(s.z=r);break;case"Back":r=a.z+o.z,this.isInRange(r,this.sectionRange.z)&&(a.z=r)}this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}isInRange(e,t){return e>t[0]&&e<t[1]}getIntersections(e){return this.raycaster?(this.updateRaycasterByMouse(e),(this.raycaster.intersectObjects(this.getIntersectObjects())||[])[0]):void 0}getIntersectObjects(){return this.planesMesh||[]}resetSection(){this.sectionBox=this.viewer.getBBox(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}setSectionVisible(e){var t;null==(t=this.planesMesh)||t.forEach((t=>t.visible=e)),this.isShowSectionPlane=e,this.viewer.enableRender()}},WA=class extends Ld{constructor(e,t){super(e,t),this.mousedown=e=>{var t;if(0===e.button){if(!this.faceInfo){let n=this.pickFace(e);if(n&&n.face){let e=n.face.normal,i=new Wt;e.applyNormalMatrix(i.getNormalMatrix(n.object.matrixWorld)),this.faceInfo={position:n.point,normal:e.normalize()},this.setSection(),null==(t=this.tooltip)||t.hide()}return}this.camera&&this.selectedObject&&(this.mouseDown=!0)}},this.mousemove=e=>{var t,n,i;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(null==(i=this.selectedObject)?void 0:i.parent)instanceof Bl&&(this.dragStarted||(this.dragStarted=!0,this.onDragStart(e)))):this.selectedObject=void 0}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(n=this.tooltip)||n.hide()},this.center=new M,this.sectionBox.getCenter(this.center),this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.tooltip=new Yo("pick-section-plane",zc("Tooltip.section"),{parentNode:this.viewer.widgetContainer,followPointer:!0})}deactivate(){var e,t,n;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}setSection(){this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}resetSection(){var e,t,n;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.show(),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new er).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;if(!this.faceInfo)return;let{normal:t,position:n}=this.faceInfo,i=new M;this.sectionBox.getSize(i);let r=i.length(),a=n,s=(new lt).setFromCenterAndSize(a,new M(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new Pr("Plane",[new M(a.x,l.y,o.z),new M(a.x,l.y,l.z),new M(a.x,o.y,l.z),new M(a.x,o.y,o.z)]),this.planeMesh.setDirection(t),this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;if(!this.faceInfo)return;null==(e=this.gizmo)||e.removeFromParent();let{normal:n,position:i}=this.faceInfo;this.gizmo=new Bl,this.gizmo.setDirection(n),this.gizmo.position.copy(i),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof Pr)return;this.controls&&this.dragStarted&&this.selectedObject&&!(this.selectedObject instanceof Pr)&&(this.controls.enableRotate=!1),$.info("[PickPlaneSection] onDragStart:",e);let{position:n}=this.faceInfo;this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||!this.faceInfo||this.selectedObject&&this.selectedObject instanceof Pr)return;let r=new M;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new M).subVectors(this.lastWorldPos,s).normalize(),l=(new M).subVectors(r,s).normalize(),h=(new M).subVectors(r,this.lastWorldPos).projectOnVector(Zs.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new M).crossVectors(o,l),d=new M;this.sectionBox.getSize(d);let p,f=Math.max(d.x,d.y,d.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":p=(new M).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new M(f,f,f)).containsPoint(p)&&(null==(n=this.gizmo)||n.position.add(h),null==(i=this.planeMesh)||i.position.add(h));break;case"RotateX":{let e=Zs.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateX(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateY":{let e=Id.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateY(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateZ":{let e=Dd.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateZ(c),this.planeMesh.rotatePlane(e,c)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Pr||(this.controls&&!this.controls.enableRotate&&(this.controls.enableRotate=!0),$.info("[PickPlaneSection] onDragEnd:",e))}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Pr?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Bl&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new Q(e.x,e.y),n=nn.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return Object.values(this.viewer.loadedModels).forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.id);t&&t.visible&&i.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&(!1!==t.userData.selectable||t instanceof Ge)}))}},jA=class{constructor(e,t){this.sections={},this.viewer=e,this.sections.ObjectsBoxSection=new qA(e,t),this.sections.AxisPlaneSection=new iA(e,t),this.sections.PickPlaneSection=new WA(e,t)}get raycaster(){return this.viewer.getRaycaster()}activateSection(e,t){this.activeSectionType&&this.deactivateSection(),this.activeSectionType=e,this.setSectionClippingObjectIds(t),this.sections[e].activate()}deactivateSection(){let e=this.activeSectionType;e&&this.sections[e].deactivate(),this.activeSectionType=void 0}resetSection(){}isSectionActive(){let e=this.activeSectionType;return e?this.sections[e].isActive:!!this.getActiveSectionType()}getActiveSectionType(){return this.activeSectionType}getActiveSection(){if(this.activeSectionType)return this.sections[this.activeSectionType]}setSectionClippingObjectIds(e){this.activeSectionType&&(this.sections[this.activeSectionType].clearClippingObjectIds(),e&&e.length&&(this.sections[this.activeSectionType].clippingObjetIds=e,this.sections[this.activeSectionType].setClippingEnable(!0)))}destroy(){this.deactivateSection(),this.activeSectionType=void 0}};function QH(e){let t;try{t=new URL(e,"http://fakehost.com/")}catch(e){return null}let n=t.pathname.split("/").pop(),i=n.lastIndexOf(".");return-1===i||i===n.length-1?null:n.substring(i+1)}function Iot(e){Promise.resolve().then(e)}var XA=class{constructor(){this.maxSize=800,this.minSize=600,this.unloadPercent=.05,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadPriorityCallback=null;let e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize}add(e,t){let n=this.itemSet;if(n.has(e)||this.isFull())return!1;let i=this.usedSet,r=this.itemList,a=this.callbacks;return r.push(e),i.add(e),n.set(e,Date.now()),a.set(e,t),!0}remove(e){let t=this.usedSet,n=this.itemSet,i=this.itemList,r=this.callbacks;if(n.has(e)){r.get(e)(e);let a=i.indexOf(e);return i.splice(a,1),t.delete(e),n.delete(e),r.delete(e),!0}return!1}markUsed(e){let t=this.itemSet,n=this.usedSet;t.has(e)&&!n.has(e)&&(t.set(e,Date.now()),n.add(e))}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){let e=this.unloadPercent,t=this.minSize,n=this.itemList,i=this.itemSet,r=this.usedSet,a=this.callbacks,s=n.length-r.size,o=n.length-t,l=this.unloadPriorityCallback||this.defaultPriorityCallback;if(o>0&&s>0){n.sort(((e,t)=>{let n=r.has(e),i=r.has(t);return n&&i?0:n||i?n?1:-1:l(t)-l(e)}));let h=Math.min(o,s),c=Math.max(t*e,h*e),u=Math.min(c,s);u=Math.ceil(u);let d=n.splice(0,u);for(let e=0,t=d.length;e<t;e++){let t=d[e];a.get(t)(t),i.delete(t),a.delete(t)}}}scheduleUnload(e=!0){this.scheduled||(this.scheduled=!0,Iot((()=>{this.scheduled=!1,this.unloadUnusedContent(),e&&this.markAllUnused()})))}},JE=class{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){let e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise(((n,i)=>{let r=this.items,a=this.callbacks;r.push(e),a.set(e,((...e)=>t(...e).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(e){let t=this.items,n=this.callbacks,i=t.indexOf(e);-1!==i&&(t.splice(i,1),n.delete(e))}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,n=this.maxJobs,i=this.currJobs;for(;n>i&&e.length>0;){i++;let n=e.pop(),r=t.get(n);t.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}},Dot=.0033528106647474805,cfe=-(6378137*Dot-6378137);function tk(e){return 3===e||4===e}function Wp(e,t){return e.__lastFrameVisited===t&&e.__used}function ufe(e,t){e.__lastFrameVisited!==t&&(e.__lastFrameVisited=t,e.__used=!1,e.__inFrustum=!1,e.__isLeaf=!1,e.__visible=!1,e.__active=!1,e.__error=1/0,e.__distanceFromCamera=1/0,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1)}function hfe(e,t,n){if(ufe(e,t),e.__used=!0,n.markUsed(e),e.__contentEmpty){let i=e.children;for(let e=0,r=i.length;e<r;e++)hfe(i[e],t,n)}}function dfe(e,t,n){if(!e.__contentEmpty||e.__externalTileSet&&!tk(e.__loadingState))n.requestTileContents(e);else{let i=e.children;for(let e=0,r=i.length;e<r;e++){let r=i[e];r.__depthFromRenderedParent=t,dfe(r,t,n)}}}function $A(e,t=null,n=null,i=null,r=0){if(t&&t(e,i,r))return void(n&&n(e,i,r));let a=e.children;for(let s=0,o=a.length;s<o;s++)$A(a[s],t,n,e,r+1);n&&n(e,i,r)}function nk(e,t){let n=t.stats,i=t.frameCount,r=t.errorTarget,a=t.maxDepth,s=t.loadSiblings,o=t.lruCache,l=t.stopAtEmptyTiles;if(ufe(e,i),!1===t.tileInView(e))return!1;if(e.__used=!0,o.markUsed(e),e.__inFrustum=!0,n.inFrustum++,(l||!e.__contentEmpty)&&!e.__externalTileSet&&(t.calculateError(e),e.__error<=r||t.maxDepth>0&&e.__depth+1>=a))return!0;let h=!1,c=e.children;for(let u=0,d=c.length;u<d;u++){let e=nk(c[u],t);h=h||e}if(h&&s)for(let u=0,d=c.length;u<d;u++)hfe(c[u],i,o);return!0}function rk(e,t){let n=t.stats,i=t.frameCount;if(!Wp(e,i))return;n.used++;let r=e.children,a=!1;for(let s=0,o=r.length;s<o;s++){let e=r[s];a=a||Wp(e,i)}if(a){let n=!1,a=!0;for(let e=0,s=r.length;e<s;e++){let s=r[e];if(rk(s,t),n=n||s.__wasSetVisible||s.__childrenWereVisible,Wp(s,i)){let e=s.__allChildrenLoaded||!s.__contentEmpty&&tk(s.__loadingState)||s.__externalTileSet&&4===s.__loadingState;a=a&&e}}e.__childrenWereVisible=n,e.__allChildrenLoaded=a}else e.__isLeaf=!0}function ik(e,t){let n=t.stats,i=t.frameCount;if(!Wp(e,i))return;let r=e.parent,a=r?r.__depthFromRenderedParent:-1;e.__depthFromRenderedParent=a;let s=t.lruCache;if(e.__isLeaf)return e.__depthFromRenderedParent++,void(3===e.__loadingState?(e.__inFrustum&&(e.__visible=!0,n.visible++),e.__active=!0,n.active++):!s.isFull()&&(!e.__contentEmpty||e.__externalTileSet)&&t.requestTileContents(e));let o=(t.errorTarget+1)*t.errorThreshold,l=e.__error<=o,h=l||"ADD"===e.refine,c=!e.__contentEmpty,u=c||e.__externalTileSet,d=tk(e.__loadingState)&&u,p=e.__childrenWereVisible,f=e.children,m=e.__allChildrenLoaded;if(h&&c&&e.__depthFromRenderedParent++,h&&!d&&!s.isFull()&&u&&t.requestTileContents(e),(l&&!m&&!p&&d||"ADD"===e.refine&&d)&&(e.__inFrustum&&(e.__visible=!0,n.visible++),e.__active=!0,n.active++),"ADD"!==e.refine&&l&&!m&&d)for(let g=0,v=f.length;g<v;g++){let n=f[g];Wp(n,i)&&!s.isFull()&&(n.__depthFromRenderedParent=e.__depthFromRenderedParent+1,dfe(n,n.__depthFromRenderedParent,t))}else for(let g=0,v=f.length;g<v;g++){let e=f[g];Wp(e,i)&&ik(e,t)}}function sk(e,t){let n=Wp(e,t.frameCount);if(n||e.__usedLastFrame){let i=!1,r=!1;n&&(i=e.__active,r=t.displayActiveTiles&&e.__active||e.__visible),!e.__contentEmpty&&3===e.__loadingState&&(e.__wasSetActive!==i&&t.setTileActive(e,i),e.__wasSetVisible!==r&&t.setTileVisible(e,r)),e.__wasSetActive=i,e.__wasSetVisible=r,e.__usedLastFrame=n;let a=e.children;for(let e=0,n=a.length;e<n;e++)sk(a[e],t)}}var pfe=(e,t)=>e.__depth!==t.__depth?e.__depth>t.__depth?-1:1:e.__inFrustum!==t.__inFrustum?e.__inFrustum?1:-1:e.__used!==t.__used?e.__used?1:-1:e.__error!==t.__error?e.__error>t.__error?1:-1:e.__distanceFromCamera!==t.__distanceFromCamera?e.__distanceFromCamera>t.__distanceFromCamera?-1:1:0,Lot=e=>1/(e.__depthFromRenderedParent+1),ZA=class{get rootTileSet(){let e=this.tileSets[this.rootURL];return!e||e instanceof Promise?null:e}get root(){let e=this.rootTileSet;return e?e.root:null}constructor(e){this.tileSets={},this.rootURL=e,this.fetchOptions={},this.preprocessURL=null;let t=new XA;t.unloadPriorityCallback=Lot;let n=new JE;n.maxJobs=4,n.priorityCallback=pfe;let i=new JE;i.maxJobs=1,i.priorityCallback=pfe,this.lruCache=t,this.downloadQueue=n,this.parseQueue=i,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.loadSiblings=!0,this.displayActiveTiles=!1,this.maxDepth=1/0,this.stopAtEmptyTiles=!0}traverse(e,t){let n=this.tileSets[this.rootURL];!n||!n.root||$A(n.root,e,t)}update(){let e=this.stats,t=this.lruCache,n=this.tileSets,i=n[this.rootURL];if(!(this.rootURL in n))return void this.loadRootTileSet(this.rootURL);if(!i||!i.root)return;let r=i.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,nk(r,this),rk(r,this),ik(r,this),sk(r,this),t.scheduleUnload()}parseTile(e,t,n){return null}disposeTile(e){}preprocessNode(e,t,n){if(e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.uri&&(e.content.uri=new URL(e.content.uri,n+"/").toString()),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=t,e.children=e.children||[],e.content&&e.content.uri){let t=QH(e.content.uri),n=Boolean(t&&"json"===t.toLowerCase());e.__externalTileSet=n,e.__contentEmpty=n}else e.__externalTileSet=!1,e.__contentEmpty=!0;e.__distanceFromCamera=1/0,e.__error=1/0,e.__inFrustum=!1,e.__isLeaf=!1,e.__usedLastFrame=!1,e.__used=!1,e.__wasSetVisible=!1,e.__visible=!1,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1,e.__wasSetActive=!1,e.__active=!1,e.__loadingState=0,e.__loadIndex=0,e.__loadAbort=null,e.__depthFromRenderedParent=-1,null===t?(e.__depth=0,e.refine=e.refine||"REPLACE"):(e.__depth=t.__depth+1,e.refine=e.refine||t.refine)}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}resetFailedTiles(){let e=this.stats;0!==e.failed&&(this.traverse((e=>{4===e.__loadingState&&(e.__loadingState=0)})),e.failed=0)}fetchTileSet(e,t,n=null){return fetch(e,t).then((t=>{if(t.ok)return t.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)})).then((t=>{let i=t.asset.version;console.assert("1.0"===i||"0.0"===i,'asset.version is expected to be a string of "1.0" or "0.0"');let r=e.replace(/\/[^\/]*\/?$/,"");return r=new URL(r,window.location.href).toString(),$A(t.root,((e,t)=>this.preprocessNode(e,t,r)),null,n,n?n.__depth:0),t}))}loadRootTileSet(e){let t=this.tileSets;if(e in t)return t[e]instanceof Error?Promise.reject(t[e]):Promise.resolve(t[e]);{let n=this.fetchTileSet(this.preprocessURL?this.preprocessURL(e):e,this.fetchOptions).then((n=>{t[e]=n}));return n.catch((n=>{console.error(n),t[e]=n})),t[e]=n,n}}requestTileContents(e){if(0!==e.__loadingState)return;let t=this.stats,n=this.lruCache,i=this.downloadQueue,r=this.parseQueue,a=e.__externalTileSet;n.add(e,(e=>{1===e.__loadingState?(e.__loadAbort.abort(),e.__loadAbort=null):a?e.children.length=0:this.disposeTile(e),1===e.__loadingState?t.downloading--:2===e.__loadingState&&t.parsing--,e.__loadingState=0,e.__loadIndex++,r.remove(e),i.remove(e)})),e.__loadIndex++;let s=e.__loadIndex,o=new AbortController,l=o.signal;t.downloading++,e.__loadAbort=o,e.__loadingState=1;let h=a=>{e.__loadIndex===s&&("AbortError"!==a.name?(r.remove(e),i.remove(e),2===e.__loadingState?t.parsing--:1===e.__loadingState&&t.downloading--,t.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(a),e.__loadingState=4):n.remove(e))};a?i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return this.fetchTileSet(t,Object.assign({signal:l},this.fetchOptions),e)})).then((n=>{e.__loadIndex===s&&(t.downloading--,e.__loadAbort=null,e.__loadingState=3,e.children.push(n.root))})).catch(h):i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return fetch(t,Object.assign({signal:l},this.fetchOptions))})).then((t=>{if(e.__loadIndex===s){if(t.ok)return t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((n=>{if(e.__loadIndex===s)return t.downloading--,t.parsing++,e.__loadAbort=null,e.__loadingState=2,r.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=QH(e.content.uri);return this.parseTile(n,e,t)}))})).then((()=>{e.__loadIndex===s&&(t.parsing--,e.__loadingState=3,e.__wasSetVisible&&this.setTileVisible(e,!0),e.__wasSetActive&&this.setTileActive(e,!0))})).catch(h)}dispose(){let e=this.lruCache;this.traverse((t=>{e.remove(t)})),this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0}};function KA(e){return(new TextDecoder).decode(e)}var nh=class{constructor(e,t,n,i){this.buffer=e,this.binOffset=t+n,this.binLength=i;let r=null;if(0!==n){let i=new Uint8Array(e,t,n);r=JSON.parse(KA(i))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,n=null,i=null){let r=this.header;if(!(e in r))return null;let a=r[e];if(a instanceof Object){if(Array.isArray(a))return a;{let r,{buffer:s,binOffset:o,binLength:l}=this,h=a.byteOffset||0,c=a.type||i,u=a.componentType||n;if("type"in a&&i&&a.type!==i)throw new Error("FeatureTable: Specified type does not match expected type.");switch(c){case"SCALAR":r=1;break;case"VEC2":r=2;break;case"VEC3":r=3;break;case"VEC4":r=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let d,p=o+h,f=t*r;switch(u){case"BYTE":d=new Int8Array(s,p,f);break;case"UNSIGNED_BYTE":d=new Uint8Array(s,p,f);break;case"SHORT":d=new Int16Array(s,p,f);break;case"UNSIGNED_SHORT":d=new Uint16Array(s,p,f);break;case"INT":d=new Int32Array(s,p,f);break;case"UNSIGNED_INT":d=new Uint32Array(s,p,f);break;case"FLOAT":d=new Float32Array(s,p,f);break;case"DOUBLE":d=new Float64Array(s,p,f);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(p+f*d.BYTES_PER_ELEMENT>o+l)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return a}},Vd=class extends nh{constructor(e,t,n,i,r){super(e,n,i,r),this.batchSize=t}getData(e,t=null,n=null){return super.getData(e,this.batchSize,t,n)}},Qo=class{constructor(){this.fetchOptions={},this.workingPath=""}load(e){return fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((t=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(e)),this.parse(t))))}resolveExternalURL(e){return/^[^\\/]/.test(e)?this.workingPath+"/"+e:e}workingPathForURL(e){let t=e.split(/[\\/]/g);return t.pop(),t.join("/")+"/"}parse(e){throw new Error("LoaderBase: Parse not implemented.")}};function kl(e){let t;if(t=e instanceof DataView?e:new DataView(e),"{"===String.fromCharCode(t.getUint8(0)))return null;let n="";for(let i=0;i<4;i++)n+=String.fromCharCode(t.getUint8(i));return n}var JA=class extends Qo{parse(e){let t=new DataView(e),n=kl(t);console.assert("b3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new nh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new Vd(d,c.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:c,batchTable:p,glbBytes:new Uint8Array(e,f,r-f)}}},c0=class extends JA{constructor(e=ma){super(),this.manager=e,this.adjustmentTransform=new Ae}parse(e){let t=super.parse(e),n=t.glbBytes.slice().buffer;return new Promise(((e,i)=>{let r=this.manager,a=this.fetchOptions,s=r.getHandler("path.gltf")||new Wc(r);"include"===a.credentials&&"cors"===a.mode&&s.setCrossOrigin("use-credentials"),"credentials"in a&&s.setWithCredentials("include"===a.credentials),a.headers&&s.setRequestHeader(a.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");let l=this.adjustmentTransform;s.parse(n,o,(n=>{let{batchTable:i,featureTable:r}=t,{scene:a}=n,s=r.getData("RTC_CENTER");s&&(a.position.x+=s[0],a.position.y+=s[1],a.position.z+=s[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,a.batchTable=i,a.featureTable=r,e(n)}),i)}))}},QA=class extends Qo{parse(e){let t=new DataView(e),n=kl(t);console.assert("pnts"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new nh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new Vd(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:c,batchTable:p})}},u0=class extends QA{constructor(e=ma){super(),this.manager=e}parse(e){return super.parse(e).then((e=>{let{featureTable:t}=e,n=t.getData("POINTS_LENGTH"),i=t.getData("POSITION",n,"FLOAT","VEC3"),r=t.getData("RGB",n,"UNSIGNED_BYTE","VEC3");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in t.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new et;a.setAttribute("position",new Ct(i,3,!1));let s=new Br;s.size=2,s.sizeAttenuation=!1,null!==r&&(a.setAttribute("color",new Ct(r,3,!0)),s.vertexColors=!0);let o=new or(a,s);e.scene=o,e.scene.featureTable=t;let l=t.getData("RTC_CENTER");return l&&(e.scene.position.x+=l[0],e.scene.position.y+=l[1],e.scene.position.z+=l[2]),e}))}},eC=class extends Qo{parse(e){let t=new DataView(e),n=kl(t);console.assert("i3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=t.getUint32(28,!0),c=e.slice(32,32+a+s),u=new nh(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new Vd(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(e,m,r-m),v=null,y=null;if(h)v=g,y=Promise.resolve();else{let e=this.resolveExternalURL(KA(g));y=fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((e=>{v=new Uint8Array(e)}))}return y.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:v})))}},mfe=new M,lk=new M,ck=new M,gfe=new M,uk=new En,tC=new M,nC=new Ae,h0=class extends eC{constructor(e=ma){super(),this.manager=e,this.adjustmentTransform=new Ae}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then((e=>{let{featureTable:t,batchTable:n}=e,i=e.glbBytes.slice().buffer;return new Promise(((e,r)=>{let a=this.fetchOptions,s=this.manager,o=s.getHandler("path.gltf")||new Wc(s);"include"===a.credentials&&"cors"===a.mode&&o.setCrossOrigin("use-credentials"),"credentials"in a&&o.setWithCredentials("include"===a.credentials),a.headers&&o.setRequestHeader(a.headers);let l=this.workingPath;/[\\/]$/.test(l)||(l+="/");let h=this.adjustmentTransform;o.parse(i,l,(i=>{let r=t.getData("INSTANCES_LENGTH"),a=t.getData("POSITION",r,"FLOAT","VEC3"),s=t.getData("NORMAL_UP",r,"FLOAT","VEC3"),o=t.getData("NORMAL_RIGHT",r,"FLOAT","VEC3"),l=t.getData("SCALE_NON_UNIFORM",r,"FLOAT","VEC3"),c=t.getData("SCALE",r,"FLOAT","SCALAR");["RTC_CENTER","QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((e=>{e in t.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let u=new Map,d=[];i.scene.traverse((e=>{if(e.isMesh){let{geometry:t,material:n}=e,i=new Ar(t,n,r);i.position.copy(e.position),i.rotation.copy(e.rotation),i.scale.copy(e.scale),d.push(i),u.set(e,i)}}));let p=new M;for(let e=0;e<r;e++)p.x+=a[3*e+0]/r,p.y+=a[3*e+1]/r,p.z+=a[3*e+2]/r;u.forEach(((e,t)=>{let n=t.parent;n&&(n.remove(t),n.add(e),e.updateMatrixWorld(),e.position.copy(p).applyMatrix4(e.matrixWorld))}));for(let e=0;e<r;e++){gfe.set(a[3*e+0]-p.x,a[3*e+1]-p.y,a[3*e+2]-p.z),s?(lk.set(s[3*e+0],s[3*e+1],s[3*e+2]),ck.set(o[3*e+0],o[3*e+1],o[3*e+2]),mfe.crossVectors(ck,lk).normalize(),nC.makeBasis(ck,lk,mfe),uk.setFromRotationMatrix(nC)):uk.set(0,0,0,1),c?tC.setScalar(c[e]):l?tC.set(l[3*e+0],l[3*e+1],l[3*e+2]):tC.set(1,1,1),nC.compose(gfe,uk,tC).multiply(h);for(let t=0,n=d.length;t<n;t++)d[t].setMatrixAt(e,nC)}i.batchTable=n,i.featureTable=t,i.scene.batchTable=n,i.scene.featureTable=t,e(i)}),r)}))}))}},rC=class extends Qo{parse(e){let t=new DataView(e),n=kl(t);console.assert("cmpt"===n,'CMPTLoader: The magic bytes equal "cmpt".');let i=t.getUint32(4,!0);console.assert(1===i,'CMPTLoader: The version listed in the header is "1".');let r=t.getUint32(8,!0);console.assert(r===e.byteLength,"CMPTLoader: The contents buffer length listed in the header matches the file.");let a=t.getUint32(12,!0),s=[],o=16;for(let l=0;l<a;l++){let t=new DataView(e,o,12),n=kl(t),i=t.getUint32(4,!0),r=t.getUint32(8,!0),a=new Uint8Array(e,o,r);s.push({type:n,buffer:a,version:i}),o+=r}return{version:i,tiles:s}}},iC=class extends rC{constructor(e=ma){super(),this.manager=e,this.adjustmentTransform=new Ae}parse(e){let t=super.parse(e),n=this.manager,i=this.adjustmentTransform,r=[];for(let a in t.tiles){let{type:e,buffer:s}=t.tiles[a];switch(e){case"b3dm":{let e=s.slice(),t=new c0(n);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.adjustmentTransform.copy(i);let a=t.parse(e.buffer);r.push(a);break}case"pnts":{let e=s.slice(),t=new u0(n);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions;let i=t.parse(e.buffer);r.push(i);break}case"i3dm":{let e=s.slice(),t=new h0(n);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.adjustmentTransform.copy(i);let a=t.parse(e.buffer);r.push(a);break}}}return Promise.all(r).then((e=>{let t=new Nt;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},sC=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},aC=class extends Qo{constructor(e=ma){super(),this.manager=e}parse(e){return new Promise(((t,n)=>{let i=this.manager,r=this.fetchOptions,a=i.getHandler("path.gltf")||i.getHandler("path.glb");a||(a=new Wc(i),a.register((()=>new sC)),"include"===r.credentials&&"cors"===r.mode&&a.setCrossOrigin("use-credentials"),"credentials"in r&&a.setWithCredentials("include"===r.credentials),r.headers&&a.setRequestHeader(r.headers));let s=a.resourcePath||a.path||this.workingPath;!/[\\/]$/.test(s)&&s.length&&(s+="/"),a.parse(e,s,(e=>{t(e)}),n)}))}},oC=new Ae,lC=class extends Nt{constructor(e){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e}raycast(e,t){this.tilesRenderer.optimizeRaycast&&this.tilesRenderer.raycast(e,t)}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){null===this.parent?oC.copy(this.matrix):oC.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=oC.elements,t=this.matrixWorld.elements,n=!1;for(let i=0;i<16;i++){let r=e[i],a=t[i];if(Math.abs(r-a)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(oC);let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateMatrixWorld()}}}};function vfe(e){let{x:t,y:n,z:i}=e;e.x=i,e.y=t,e.z=n}function Oot(e){return-e+Math.PI/2}var cC=new od,QE=new M,jp=new M,uC=class{constructor(e=1,t=1,n=1){this.radius=new M(e,t,n)}getCartographicToPosition(e,t,n,i){let r=this.radius;cC.set(1,Oot(e),t),QE.setFromSpherical(cC).normalize(),vfe(QE),jp.copy(QE),jp.x*=Kl(r.x,2),jp.y*=Kl(r.y,2),jp.z*=Kl(r.z,2);let a=Math.sqrt(QE.dot(jp));return jp.divideScalar(a),i.copy(jp).addScaledVector(QE,n)}getCartographicToNormal(e,t,n){return cC.set(1,-e+Math.PI/2,t),n.setFromSpherical(cC).normalize(),vfe(n),n}getPositionToNormal(e,t){let n=this.radius;return t.copy(e),t.x/=Kl(n.x,2),t.y/=Kl(n.y,2),t.z/=Kl(n.z,2),t.normalize(),t}},zd=Math.PI,hC=zd/2,eb=new M,d0=new M,f0=new M,xfe=new Ae,tb=0,hk=[];function Not(e=!1){return e?(hk[tb]||(hk[tb]=new M),tb++,hk[tb-1]):new M}function yfe(){tb=0}var dC=class extends uC{constructor(e,t,n,i=-hC,r=hC,a=0,s=2*zd,o=0,l=0){super(e,t,n),this.latStart=i,this.latEnd=r,this.lonStart=a,this.lonEnd=s,this.heightStart=o,this.heightEnd=l}_getPoints(e=!1){let{latStart:t,latEnd:n,lonStart:i,lonEnd:r,heightStart:a,heightEnd:s}=this,o=Yt.mapLinear(.5,0,1,t,n),l=Yt.mapLinear(.5,0,1,i,r),h=Math.floor(i/hC)*hC,c=[[-zd/2,0],[zd/2,0],[0,h],[0,h+zd/2],[0,h+zd],[0,h+3*zd/2],[t,r],[n,r],[t,i],[n,i],[0,i],[0,r],[o,l],[t,l],[n,l],[o,i],[o,r]],u=[],d=c.length;for(let p=0;p<=1;p++){let o=Yt.mapLinear(p,0,1,a,s);for(let a=0,s=d;a<s;a++){let[s,l]=c[a];if(s>=t&&s<=n&&l>=i&&l<=r){let t=Not(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){yfe();let{latStart:n,latEnd:i,lonStart:r,lonEnd:a}=this;if(i-n<zd/2){let e=Yt.mapLinear(.5,0,1,n,i),s=Yt.mapLinear(.5,0,1,r,a);this.getCartographicToNormal(e,s,f0),d0.set(0,0,1),eb.crossVectors(d0,f0),d0.crossVectors(eb,f0),t.makeBasis(eb,d0,f0)}else eb.set(1,0,0),d0.set(0,1,0),f0.set(0,0,1),t.makeBasis(eb,d0,f0);xfe.copy(t).invert();let s=this._getPoints(!0);for(let o=0,l=s.length;o<l;o++)s[o].applyMatrix4(xfe);e.makeEmpty(),e.setFromPoints(s)}getBoundingSphere(e,t){yfe();let n=this._getPoints(!0);e.makeEmpty(),e.setFromPoints(n,t)}},g0=new hr,rh=new Ae,Efe=new M,p0=new M,m0=new Wa,el=[];function dk(e,t){return e.distance-t.distance}function fk(e,t,n){e.traverse((e=>{Object.getPrototypeOf(e).raycast.call(e,t,n)}))}function pk(e,t,n,i){if(n.has(e)){if(fk(e.cached.scene,i,el),el.length>0){el.length>1&&el.sort(dk);let e=el[0];return el.length=0,e}return null}let r=[],a=e.children;for(let l=0,h=a.length;l<h;l++){let e=a[l],n=e.cached,s=t.matrixWorld;rh.copy(s);let o=n.sphere;if(o&&(g0.copy(o),g0.applyMatrix4(rh),!i.ray.intersectsSphere(g0)))continue;let h=n.box,c=n.boxTransform;if(h){if(rh.multiply(c).invert(),m0.copy(i.ray),m0.applyMatrix4(rh),!m0.intersectBox(h,Efe))continue;{p0.setFromMatrixScale(rh);let t=p0.x;Math.abs(Math.max(p0.x-p0.y,p0.x-p0.z))>1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting.");let n={distance:1/0,tile:null};r.push(n),n.distance=Efe.distanceToSquared(m0.origin)*t*t,n.tile=e}}}r.sort(dk);let s=1/0,o=null;for(let l=0,h=r.length;l<h;l++){let e=r[l];if(e.distance>s)break;{let r=e.tile,a=r.cached.scene,l=null;if(n.has(r)?(fk(a,i,el),el.length>0&&(el.length>1&&el.sort(dk),l=el[0])):l=pk(r,t,n,i),l){let e=l.distance*l.distance;e<s&&(s=e,o=l),el.length=0}}}return o}function mk(e,t,n,i,r){let a=e.cached,s=t.matrixWorld;rh.copy(s);let o=a.sphere;if(o&&(g0.copy(o),g0.applyMatrix4(rh),!i.ray.intersectsSphere(g0)))return;let l=a.box,h=a.boxTransform;if(l&&(rh.multiply(h).invert(),m0.copy(i.ray).applyMatrix4(rh),!m0.intersectsBox(l)))return;let c=a.scene;if(n.has(e))return void fk(c,i,r);let u=e.children;for(let d=0,p=u.length;d<p;d++)mk(u[d],t,n,i,r)}var Tfe=Symbol("INITIAL_FRUSTUM_CULLED"),Vl=new Ae,gk=new Ae,zl=new M,ih=new M,sh=new M,ah=new M,Uot=new M(1,0,0),Bot=new M(0,1,0);function _fe(e,t){e.traverse((e=>{e.frustumCulled=e[Tfe]&&t}))}var nb=class extends ZA{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{_fe(t,!e)})))}constructor(...e){super(...e),this.group=new lC(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;let t=new Tc;t.setURLModifier((e=>this.preprocessURL?this.preprocessURL(e):e)),this.manager=t;let n=this;this._overridenRaycast=function(e,t){n.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,t)}}getBounds(e){if(!this.root)return!1;let t=this.root.cached,n=t.box,i=t.boxTransform;return!!n&&(e.copy(n),e.applyMatrix4(i),!0)}getOrientedBounds(e,t){if(!this.root)return!1;let n=this.root.cached,i=n.box,r=n.boxTransform;return!!i&&(e.copy(i),t.copy(r),!0)}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.cached.sphere;return!!t&&(e.copy(t),!0)}forEachLoadedModel(e){this.traverse((t=>{let n=t.cached.scene;n&&e(n,t)}))}raycast(e,t){if(this.root)if(e.firstHitOnly){let n=pk(this.root,this.group,this.activeTiles,e);n&&t.push(n)}else mk(this.root,this.group,this.activeTiles,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,n=this.cameraMap;return!n.has(e)&&(n.set(e,new Q),t.push(e),!0)}setResolution(e,t,n){let i=this.cameraMap;return!!i.has(e)&&(t instanceof Q?i.get(e).copy(t):i.get(e).set(t,n),!0)}setResolutionFromRenderer(e,t){let n=this.cameraMap;if(!n.has(e))return!1;let i=n.get(e);return t.getSize(i),i.multiplyScalar(t.getPixelRatio()),!0}deleteCamera(e){let t=this.cameras,n=this.cameraMap;if(n.has(e)){let i=t.indexOf(e);return t.splice(i,1),n.delete(e),!0}return!1}fetchTileSet(e,...t){let n=super.fetchTileSet(e,...t);return n.then((t=>{this.onLoadTileSet&&Promise.resolve().then((()=>{this.onLoadTileSet(t,e)}))})),n}update(){let e=this.group,t=this.cameras,n=this.cameraMap,i=this.cameraInfo;if(0===t.length)return void console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");for(;i.length>t.length;)i.pop();for(;i.length<t.length;)i.push({frustum:new ps,isOrthographic:!1,sseDenominator:-1,position:new M,invScale:-1,pixelSize:0});gk.copy(e.matrixWorld).invert(),zl.setFromMatrixScale(gk);let r=zl.x;Math.abs(Math.max(zl.x-zl.y,zl.x-zl.z))>1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,s=i.length;a<s;a++){let s=t[a],o=i[a],l=o.frustum,h=o.position,c=n.get(s);(0===c.width||0===c.height)&&console.warn("TilesRenderer: resolution for camera error calculation is not set.");let u=s.projectionMatrix.elements;if(o.isOrthographic=1===u[15],o.isOrthographic){let e=2/u[0],t=2/u[5];o.pixelSize=Math.max(t/c.height,e/c.width)}else o.sseDenominator=2/u[5]/c.height;o.invScale=r,Vl.copy(e.matrixWorld),Vl.premultiply(s.matrixWorldInverse),Vl.premultiply(s.projectionMatrix),l.setFromProjectionMatrix(Vl),h.set(0,0,0),h.applyMatrix4(s.matrixWorld),h.applyMatrix4(gk)}super.update()}preprocessNode(e,t,n){super.preprocessNode(e,t,n);let i=new Ae;if(e.transform){let t=e.transform;for(let e=0;e<16;e++)i.elements[e]=t[e]}else i.identity();t&&i.premultiply(t.cached.transform);let r=(new Ae).copy(i).invert(),a=null,s=null,o=null;if("box"in e.boundingVolume){let t=e.boundingVolume.box;a=new lt,s=new Ae,o=new Ae,ih.set(t[3],t[4],t[5]),sh.set(t[6],t[7],t[8]),ah.set(t[9],t[10],t[11]);let n=ih.length(),r=sh.length(),l=ah.length();ih.normalize(),sh.normalize(),ah.normalize(),0===n&&ih.crossVectors(sh,ah),0===r&&sh.crossVectors(ih,ah),0===l&&ah.crossVectors(ih,sh),s.set(ih.x,sh.x,ah.x,t[0],ih.y,sh.y,ah.y,t[1],ih.z,sh.z,ah.z,t[2],0,0,0,1),s.premultiply(i),o.copy(s).invert(),a.min.set(-n,-r,-l),a.max.set(n,r,l)}let l=null;if("sphere"in e.boundingVolume){let t=e.boundingVolume.sphere;l=new hr,l.center.set(t[0],t[1],t[2]),l.radius=t[3],l.applyMatrix4(i)}else if("box"in e.boundingVolume){let t=e.boundingVolume.box;l=new hr,a.getBoundingSphere(l),l.center.set(t[0],t[1],t[2]),l.applyMatrix4(i)}let h=null;if("region"in e.boundingVolume){let t=e.boundingVolume.region,[n,i,r,c,u,d]=t;h=new dC(6378137,6378137,cfe,i,c,n,r,u,d),null===l&&(l=new hr,h.getBoundingSphere(l)),null===a&&(a=new lt,s=new Ae,o=new Ae,h.getBoundingBox(a,s),o.copy(s).invert())}e.cached={loadIndex:0,transform:i,transformInverse:r,active:!1,inFrustum:[],box:a,boxTransform:s,boxTransformInverse:o,sphere:l,region:h,scene:null,geometry:null,material:null}}parseTile(e,t,n){t._loadIndex=t._loadIndex||0,t._loadIndex++;let i=t.content.uri.split(/[\\\/]/g);i.pop();let r=i.join("/"),a=this.fetchOptions,s=this.manager,o=t._loadIndex,l=null,h=this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y",c=t.cached,u=c.transform;switch(h.toLowerCase()){case"x":Vl.makeRotationAxis(Bot,-Math.PI/2);break;case"y":Vl.makeRotationAxis(Uot,Math.PI/2);break;case"z":Vl.identity()}let d=kl(e)||n;switch(d){case"b3dm":{let t=new c0(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(Vl),l=t.parse(e).then((e=>e.scene));break}case"pnts":{let t=new u0(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new h0(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(Vl),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new iC(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(Vl),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new aC(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break;default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),l=Promise.resolve(null)}return l.then((e=>{if(t._loadIndex!==o)return;e.updateMatrix(),("glb"===d||"gltf"===d)&&e.matrix.multiply(Vl),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[Tfe]=e.frustumCulled})),_fe(e,!this.autoDisableRendererCulling),c.scene=e,e.traverse((e=>{e.raycast=this._overridenRaycast}));let n=[],i=[],r=[];e.traverse((e=>{if(e.geometry&&i.push(e.geometry),e.material){let t=e.material;n.push(e.material);for(let e in t){let n=t[e];n&&n.isTexture&&r.push(n)}}})),c.materials=n,c.geometry=i,c.textures=r,this.onLoadModel&&this.onLoadModel(e,t)}))}disposeTile(e){let t=e.cached;if(t.scene){let n=t.materials,i=t.geometry,r=t.textures,a=t.scene.parent;for(let e=0,t=i.length;e<t;e++)i[e].dispose();for(let e=0,t=n.length;e<t;e++)n[e].dispose();for(let e=0,t=r.length;e<t;e++)r[e].dispose();a&&a.remove(t.scene),this.onDisposeModel&&this.onDisposeModel(t.scene,e),t.scene=null,t.materials=null,t.textures=null,t.geometry=null}this.activeTiles.delete(e),this.visibleTiles.delete(e),e._loadIndex++}setTileVisible(e,t){let n=e.cached.scene,i=this.visibleTiles,r=this.group;t?(r.add(n),i.add(e),n.updateMatrixWorld(!0)):(r.remove(n),i.delete(e)),this.onTileVisibilityChange&&this.onTileVisibilityChange(n,e,t)}setTileActive(e,t){let n=this.activeTiles;t?n.add(e):n.delete(e)}calculateError(e){let t=e.cached,n=t.inFrustum,i=this.cameras,r=this.cameraInfo,a=t.sphere,s=t.box,o=t.boxTransformInverse,l=t.transformInverse,h=s&&o,c=-1/0,u=1/0;for(let d=0,p=i.length;d<p;d++){if(!n[d])continue;let t,i=r[d],p=i.invScale;if(i.isOrthographic){let n=i.pixelSize;t=e.geometricError/(n*p)}else{let n;zl.copy(i.position),h?(zl.applyMatrix4(o),n=s.distanceToPoint(zl)):(zl.applyMatrix4(l),n=Math.max(a.distanceToPoint(zl),0));let r=n*p,c=i.sseDenominator;t=e.geometricError/(r*c),u=Math.min(u,r)}c=Math.max(c,t)}e.__distanceFromCamera=u,e.__error=c}tileInView(e){let t=e.cached,n=t.sphere,i=t.inFrustum;if(n){let e=this.cameraInfo,t=!1;for(let r=0,a=e.length;r<a;r++)e[r].frustum.intersectsSphere(n)?(t=!0,i[r]=!0):i[r]=!1;return t}return!0}},jd=wi(Ll(),1),rb=new M,ib=new M,wfe=new Wt,fC=class extends Dn{constructor(e,t=1,n=16711680){let i=new et,r=e.geometry.attributes.normal.count,a=new tt(2*r*3,3);i.setAttribute("position",a),super(i,new Jt({color:n,toneMapped:!1})),this.object=e,this.size=t,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){this.object.updateMatrixWorld(!0),wfe.getNormalMatrix(this.object.matrixWorld);let e=this.object.matrixWorld,t=this.geometry.attributes.position,n=this.object.geometry;if(n){let i=n.attributes.position,r=n.attributes.normal,a=0;for(let n=0,s=i.count;n<s;n++)rb.fromBufferAttribute(i,n).applyMatrix4(e),ib.fromBufferAttribute(r,n),ib.applyMatrix3(wfe).normalize().multiplyScalar(this.size).add(rb),t.setXYZ(a,rb.x,rb.y,rb.z),a+=1,t.setXYZ(a,ib.x,ib.y,ib.z),a+=1}t.needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},_i=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}},Fot=new dr(-1,1,1,-1,0,1),vk=new et;vk.setAttribute("position",new tt([-1,3,0,-1,-1,0,3,-1,0],3)),vk.setAttribute("uv",new tt([0,2,0,0,2,0],2));var Ts=class{constructor(e){this._mesh=new Ge(vk,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Fot)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},xk={defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{value:null},uImageIncrement:{value:new Q(.001953125,0)},cKernel:{value:[]}},vertexShader:"\n\n\t\tuniform vec2 uImageIncrement;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float cKernel[ KERNEL_SIZE_INT ];\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 uImageIncrement;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 imageCoord = vUv;\n\t\t\tvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n\t\t\tfor( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {\n\n\t\t\t\tsum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];\n\t\t\t\timageCoord += uImageIncrement;\n\n\t\t\t}\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}",buildKernel:function(e){let t=2*Math.ceil(3*e)+1;t>25&&(t=25);let n=.5*(t-1),i=new Array(t),r=0;for(let a=0;a<t;++a)i[a]=Hot(a-n,e),r+=i[a];for(let a=0;a<t;++a)i[a]/=r;return i}};function Hot(e,t){return Math.exp(-e*e/(2*t*t))}var Xc=class extends _i{constructor(e=1,t=25,n=4){super(),this.renderTargetX=new Sn,this.renderTargetX.texture.name="BloomPass.x",this.renderTargetY=new Sn,this.renderTargetY.texture.name="BloomPass.y",this.combineUniforms=Lr.clone(yk.uniforms),this.combineUniforms.strength.value=e,this.materialCombine=new It({uniforms:this.combineUniforms,vertexShader:yk.vertexShader,fragmentShader:yk.fragmentShader,blending:Ou,transparent:!0});let i=xk;this.convolutionUniforms=Lr.clone(i.uniforms),this.convolutionUniforms.uImageIncrement.value=Xc.blurX,this.convolutionUniforms.cKernel.value=xk.buildKernel(n),this.materialConvolution=new It({uniforms:this.convolutionUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,defines:{KERNEL_SIZE_FLOAT:t.toFixed(1),KERNEL_SIZE_INT:t.toFixed(0)}}),this.needsSwap=!1,this.fsQuad=new Ts(null)}render(e,t,n,i,r){r&&e.state.buffers.stencil.setTest(!1),this.fsQuad.material=this.materialConvolution,this.convolutionUniforms.tDiffuse.value=n.texture,this.convolutionUniforms.uImageIncrement.value=Xc.blurX,e.setRenderTarget(this.renderTargetX),e.clear(),this.fsQuad.render(e),this.convolutionUniforms.tDiffuse.value=this.renderTargetX.texture,this.convolutionUniforms.uImageIncrement.value=Xc.blurY,e.setRenderTarget(this.renderTargetY),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCombine,this.combineUniforms.tDiffuse.value=this.renderTargetY.texture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.clear&&e.clear(),this.fsQuad.render(e)}setSize(e,t){this.renderTargetX.setSize(e,t),this.renderTargetY.setSize(e,t)}dispose(){this.renderTargetX.dispose(),this.renderTargetY.dispose(),this.materialCombine.dispose(),this.materialConvolution.dispose(),this.fsQuad.dispose()}},yk={uniforms:{tDiffuse:{value:null},strength:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float strength;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = strength * texel;\n\n\t\t}"};Xc.blurX=new Q(.001953125,0),Xc.blurY=new Q(0,.001953125);var ws={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor.a *= opacity;\n\n\n\t\t}"},v0=class extends _i{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof It?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Lr.clone(e.uniforms),this.material=new It({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Ts(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}},sb=class extends _i{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let i,r,a=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0),this.inverse?(i=0,r=1):(i=1,r=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),s.buffers.stencil.setFunc(a.ALWAYS,i,4294967295),s.buffers.stencil.setClear(r),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(a.EQUAL,1,4294967295),s.buffers.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),s.buffers.stencil.setLocked(!0)}},pC=class extends _i{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},mC=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){let n=e.getSize(new Q);this._width=n.width,this._height=n.height,(t=new Sn(this._width*this._pixelRatio,this._height*this._pixelRatio)).texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new v0(ws),this.clock=new Oo}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){void 0===e&&(e=this.clock.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let i=0,r=this.passes.length;i<r;i++){let t=this.passes[i];if(!1!==t.enabled){if(t.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),t.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),t.needsSwap){if(n){let t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==sb&&(t instanceof sb?n=!0:t instanceof pC&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(void 0===e){let t=this.renderer.getSize(new Q);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,(e=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},Gl=class extends _i{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new Ie(1,1,1),this.hiddenEdgeColor=new Ie(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this.resolution=void 0!==e?new Q(e.x,e.y):new Q(256,256);let r=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Sn(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new ku,this.depthMaterial.side=tr,this.depthMaterial.depthPacking=rv,this.depthMaterial.blending=yr,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=tr,this.prepareMaskMaterial.fragmentShader=function(e,t){let n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new Sn(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Sn(r,a),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Sn(r,a),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Sn(Math.round(r/2),Math.round(a/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Sn(r,a),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Sn(Math.round(r/2),Math.round(a/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(r,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(r/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial();let s=ws;this.copyUniforms=Lr.clone(s.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new It({uniforms:this.copyUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,blending:yr,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Ie,this.oldClearAlpha=1,this.fsQuad=new Ts(null),this.tempPulseColor1=new Ie,this.tempPulseColor2=new Ie,this.textureMatrix=new Ae}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value.set(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value.set(n,i)}changeVisibilityOfSelectedObjects(e){let t=this._visibilityCache;function n(n){n.isMesh&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}for(let i=0;i<this.selectedObjects.length;i++)this.selectedObjects[i].traverse(n)}changeVisibilityOfNonSelectedObjects(e){let t=this._visibilityCache,n=[];function i(e){e.isMesh&&n.push(e)}for(let r=0;r<this.selectedObjects.length;r++)this.selectedObjects[r].traverse(i);this.renderScene.traverse((function(i){if(i.isMesh||i.isSprite){let r=!1;for(let e=0;e<n.length;e++)if(n[e].id===i.id){r=!0;break}if(!1===r){let n=i.visible;(!1===e||!0===t.get(i))&&(i.visible=e),t.set(i,n)}}else(i.isPoints||i.isLine)&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}))}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,r){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let t=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);let i=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){let e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Gl.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Gl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Gl.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Gl.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new It({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new Q(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}getEdgeDetectionMaterial(){return new It({uniforms:{maskTexture:{value:null},texSize:{value:new Q(.5,.5)},visibleEdgeColor:{value:new M(1,1,1)},hiddenEdgeColor:{value:new M(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}getSeperableBlurMaterial(e){return new It({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Q(.5,.5)},direction:{value:new Q(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}getOverlayMaterial(){return new It({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n\t\t\t\t}",blending:Ou,depthTest:!1,depthWrite:!1,transparent:!0})}};Gl.BlurDirectionX=new Q(1,0),Gl.BlurDirectionY=new Q(0,1);var gC=class extends _i{constructor(e,t,n,i,r){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Ie}render(e,t,n){let i,r,a=e.autoClear;e.autoClear=!1,void 0!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),i=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=r),e.autoClear=a}},ab={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new Q(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new Ae},cameraInverseProjectionMatrix:{value:new Ae},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform sampler2D tDepth;\n\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include <packing>\n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#else\n\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},oh={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new Q(512,512)},sampleUvOffsets:{value:[new Q(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include <common>\n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},ob={createSampleWeights:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(kot(i,t));return n},createSampleOffsets:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(t.clone().multiplyScalar(i));return n},configure:function(e,t,n,i){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=ob.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=ob.createSampleWeights(t,n),e.needsUpdate=!0}};function kot(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var vC={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include <packing>\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );\n\t\t\tgl_FragColor = vec4( vec3( depth ), opacity );\n\n\t\t}"},lb=class extends _i{constructor(e,t,n=!1,i=!1,r=new Q(256,256)){let a;super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=i,this.originalClearColor=new Ie,this._oldClearColor=new Ie,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new Q(r.x,r.y),this.saoRenderTarget=new Sn(this.resolution.x,this.resolution.y),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Sn(this.resolution.x,this.resolution.y,{minFilter:cr,magFilter:cr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new td,a.type=fy,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new ku,this.depthMaterial.depthPacking=rv,this.depthMaterial.blending=yr,this.normalMaterial=new sd,this.normalMaterial.blending=yr,this.saoMaterial=new It({defines:Object.assign({},ab.defines),fragmentShader:ab.fragmentShader,vertexShader:ab.vertexShader,uniforms:Lr.clone(ab.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=yr,this.vBlurMaterial=new It({uniforms:Lr.clone(oh.uniforms),defines:Object.assign({},oh.defines),vertexShader:oh.vertexShader,fragmentShader:oh.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=yr,this.hBlurMaterial=new It({uniforms:Lr.clone(oh.uniforms),defines:Object.assign({},oh.defines),vertexShader:oh.vertexShader,fragmentShader:oh.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=yr,this.materialCopy=new It({uniforms:Lr.clone(ws.uniforms),vertexShader:ws.vertexShader,fragmentShader:ws.fragmentShader,blending:yr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=$u,this.materialCopy.blendSrc=ev,this.materialCopy.blendDst=ld,this.materialCopy.blendEquation=Us,this.materialCopy.blendSrcAlpha=Qg,this.materialCopy.blendDstAlpha=ld,this.materialCopy.blendEquationAlpha=Us,this.depthCopy=new It({uniforms:Lr.clone(vC.uniforms),vertexShader:vC.vertexShader,fragmentShader:vC.fragmentShader,blending:yr}),this.fsQuad=new Ts(null)}render(e,t,n){if(this.renderToScreen&&(this.materialCopy.blending=yr,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(e,this.materialCopy,null)),1===this.params.output)return;e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let i=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.depthRenderTarget),e.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;let r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),(this.prevStdDev!==this.params.saoBlurStdDev||this.prevNumSamples!==this.params.saoBlurRadius)&&(ob.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new Q(0,1)),ob.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new Q(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),e.setClearColor(0),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(e,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(e,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(e,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(e,this.hBlurMaterial,this.saoRenderTarget,16777215,1));let a=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,a=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?a.blending=$u:a.blending=yr,this.renderPass(e,a,this.renderToScreen?null:n),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=i}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.beautyRenderTarget.setSize(e,t),this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.depthRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(e,t),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(e,t),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.depthRenderTarget.dispose(),this.depthMaterial.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.depthCopy.dispose(),this.fsQuad.dispose()}};lb.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var xC=class extends _i{constructor(e,t,n,i){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==i?i:0,this._oldClearColor=new Ie;let r=ws;this.copyUniforms=Lr.clone(r.uniforms),this.copyMaterial=new It({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:$u,blendEquation:Us,blendDst:Jg,blendDstAlpha:Jg,blendSrc:hy,blendSrcAlpha:Jg}),this.fsQuad=new Ts(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null),this.copyMaterial.dispose(),this.fsQuad.dispose()}setSize(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}render(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=new Sn(n.width,n.height),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let i=Vot[Math.max(0,Math.min(this.sampleLevel,5))],r=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);let a=e.getClearAlpha(),s=1/i.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;let o={fullWidth:n.width,fullHeight:n.height,offsetX:0,offsetY:0,width:n.width,height:n.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let h=0;h<i.length;h++){let n=i[h];this.camera.setViewOffset&&this.camera.setViewOffset(o.fullWidth,o.fullHeight,o.offsetX+.0625*n[0],o.offsetY+.0625*n[1],o.width,o.height);let r=s;this.unbiased&&(r+=.03125*((h+.5)/i.length-.5)),this.copyUniforms.opacity.value=r,e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(this.renderToScreen?null:t),0===h&&(e.setClearColor(0,0),e.clear()),this.fsQuad.render(e)}this.camera.setViewOffset&&l.enabled?this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX,l.offsetY,l.width,l.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),e.autoClear=r,e.setClearColor(this._oldClearColor,a)}},Vot=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],yC=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[255&t];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}noise(e,t){let n,i,r,a,s,o=(e+t)*(.5*(Math.sqrt(3)-1)),l=Math.floor(e+o),h=Math.floor(t+o),c=(3-Math.sqrt(3))/6,u=(l+h)*c,d=e-(l-u),p=t-(h-u);d>p?(a=1,s=0):(a=0,s=1);let f=d-a+c,m=p-s+c,g=d-1+2*c,v=p-1+2*c,y=255&l,x=255&h,_=this.perm[y+this.perm[x]]%12,b=this.perm[y+a+this.perm[x+s]]%12,M=this.perm[y+1+this.perm[x+1]]%12,w=.5-d*d-p*p;w<0?n=0:(w*=w,n=w*w*this.dot(this.grad3[_],d,p));let S=.5-f*f-m*m;S<0?i=0:(S*=S,i=S*S*this.dot(this.grad3[b],f,m));let E=.5-g*g-v*v;return E<0?r=0:(E*=E,r=E*E*this.dot(this.grad3[M],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s,o,l,h,c,u,d,p=.3333333333333333*(e+t+n),f=Math.floor(e+p),m=Math.floor(t+p),g=Math.floor(n+p),v=1/6,y=(f+m+g)*v,x=e-(f-y),_=t-(m-y),b=n-(g-y);x>=_?_>=b?(o=1,l=0,h=0,c=1,u=1,d=0):x>=b?(o=1,l=0,h=0,c=1,u=0,d=1):(o=0,l=0,h=1,c=1,u=0,d=1):_<b?(o=0,l=0,h=1,c=0,u=1,d=1):x<b?(o=0,l=1,h=0,c=0,u=1,d=1):(o=0,l=1,h=0,c=1,u=1,d=0);let M=x-o+v,w=_-l+v,S=b-h+v,E=x-c+2*v,T=_-u+2*v,A=b-d+2*v,C=x-1+.5,R=_-1+.5,P=b-1+.5,L=255&f,D=255&m,I=255&g,O=this.perm[L+this.perm[D+this.perm[I]]]%12,U=this.perm[L+o+this.perm[D+l+this.perm[I+h]]]%12,N=this.perm[L+c+this.perm[D+u+this.perm[I+d]]]%12,F=this.perm[L+1+this.perm[D+1+this.perm[I+1]]]%12,k=.6-x*x-_*_-b*b;k<0?i=0:(k*=k,i=k*k*this.dot3(this.grad3[O],x,_,b));let B=.6-M*M-w*w-S*S;B<0?r=0:(B*=B,r=B*B*this.dot3(this.grad3[U],M,w,S));let z=.6-E*E-T*T-A*A;z<0?a=0:(z*=z,a=z*z*this.dot3(this.grad3[N],E,T,A));let V=.6-C*C-R*R-P*P;return V<0?s=0:(V*=V,s=V*V*this.dot3(this.grad3[F],C,R,P)),32*(i+r+a+s)}noise4d(e,t,n,i){let r,a,s,o,l,h=this.grad4,c=this.simplex,u=this.perm,d=(Math.sqrt(5)-1)/4,p=(5-Math.sqrt(5))/20,f=(e+t+n+i)*d,m=Math.floor(e+f),g=Math.floor(t+f),v=Math.floor(n+f),y=Math.floor(i+f),x=(m+g+v+y)*p,_=e-(m-x),b=t-(g-x),M=n-(v-x),w=i-(y-x),S=(_>b?32:0)+(_>M?16:0)+(b>M?8:0)+(_>w?4:0)+(b>w?2:0)+(M>w?1:0),E=c[S][0]>=3?1:0,T=c[S][1]>=3?1:0,A=c[S][2]>=3?1:0,C=c[S][3]>=3?1:0,R=c[S][0]>=2?1:0,P=c[S][1]>=2?1:0,L=c[S][2]>=2?1:0,D=c[S][3]>=2?1:0,I=c[S][0]>=1?1:0,O=c[S][1]>=1?1:0,U=c[S][2]>=1?1:0,N=c[S][3]>=1?1:0,F=_-E+p,k=b-T+p,B=M-A+p,z=w-C+p,V=_-R+2*p,H=b-P+2*p,G=M-L+2*p,j=w-D+2*p,W=_-I+3*p,X=b-O+3*p,q=M-U+3*p,Y=w-N+3*p,$=_-1+4*p,K=b-1+4*p,Z=M-1+4*p,J=w-1+4*p,Q=255&m,ee=255&g,te=255&v,ne=255&y,ie=u[Q+u[ee+u[te+u[ne]]]]%32,re=u[Q+E+u[ee+T+u[te+A+u[ne+C]]]]%32,ae=u[Q+R+u[ee+P+u[te+L+u[ne+D]]]]%32,se=u[Q+I+u[ee+O+u[te+U+u[ne+N]]]]%32,oe=u[Q+1+u[ee+1+u[te+1+u[ne+1]]]]%32,le=.6-_*_-b*b-M*M-w*w;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ie],_,b,M,w));let he=.6-F*F-k*k-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],F,k,B,z));let ce=.6-V*V-H*H-G*G-j*j;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],V,H,G,j));let ue=.6-W*W-X*X-q*q-Y*Y;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],W,X,q,Y));let de=.6-$*$-K*K-Z*Z-J*J;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],$,K,Z,J)),27*(r+a+s+o+l)}},cb={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new Q},cameraProjectionMatrix:{value:new Ae},cameraInverseProjectionMatrix:{value:new Ae},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\n\t\tuniform vec3 kernel[ KERNEL_SIZE ];\n\n\t\tuniform vec2 resolution;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float kernelRadius;\n\t\tuniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference\n\t\tuniform float maxDistance; // avoid the influence of fragments which are too far away\n\n\t\tvarying vec2 vUv;\n\n\t\t#include <packing>\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t}\n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec2 screenPosition ) {\n\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\n\t\t\tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );\n\t\t\tvec3 viewNormal = getViewNormal( vUv );\n\n\t\t\tvec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );\n\t\t\tvec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );\n\n\t\t\t// compute matrix used to reorient a kernel vector\n\n\t\t\tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );\n\t\t\tvec3 bitangent = cross( viewNormal, tangent );\n\t\t\tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );\n\n\t\t float occlusion = 0.0;\n\n\t\t for ( int i = 0; i < KERNEL_SIZE; i ++ ) {\n\n\t\t\t\tvec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space\n\t\t\t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point\n\n\t\t\t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC\n\t\t\t\tsamplePointNDC /= samplePointNDC.w;\n\n\t\t\t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n\n\t\t\t\tfloat realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture\n\t\t\t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value\n\t\t\t\tfloat delta = sampleDepth - realDepth;\n\n\t\t\t\tif ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion\n\n\t\t\t\t\tocclusion += 1.0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );\n\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );\n\n\t\t}"},ub={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include <packing>\n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}"},hb={uniforms:{tDiffuse:{value:null},resolution:{value:new Q}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\t\t\tfloat result = 0.0;\n\n\t\t\tfor ( int i = - 2; i <= 2; i ++ ) {\n\n\t\t\t\tfor ( int j = - 2; j <= 2; j ++ ) {\n\n\t\t\t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;\n\t\t\t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );\n\n\t\t}"},tl=class extends _i{constructor(e,t,n,i){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=new Map,this.generateSampleKernel(),this.generateRandomKernelRotations();let r=new td;r.format=Uu,r.type=Lu,this.beautyRenderTarget=new Sn(this.width,this.height),this.normalRenderTarget=new Sn(this.width,this.height,{minFilter:cr,magFilter:cr,depthTexture:r}),this.ssaoRenderTarget=new Sn(this.width,this.height),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new It({defines:Object.assign({},cb.defines),uniforms:Lr.clone(cb.uniforms),vertexShader:cb.vertexShader,fragmentShader:cb.fragmentShader,blending:yr}),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new sd,this.normalMaterial.blending=yr,this.blurMaterial=new It({defines:Object.assign({},hb.defines),uniforms:Lr.clone(hb.uniforms),vertexShader:hb.vertexShader,fragmentShader:hb.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new It({defines:Object.assign({},ub.defines),uniforms:Lr.clone(ub.uniforms),vertexShader:ub.vertexShader,fragmentShader:ub.fragmentShader,blending:yr}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new It({uniforms:Lr.clone(ws.uniforms),vertexShader:ws.vertexShader,fragmentShader:ws.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:ev,blendDst:ld,blendEquation:Us,blendSrcAlpha:Qg,blendDstAlpha:ld,blendEquationAlpha:Us}),this.fsQuad=new Ts(null),this.originalClearColor=new Ie}dispose(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(e,t){switch(!1===e.capabilities.isWebGL2&&(this.noiseTexture.format=mS),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.overrideVisibility(),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case tl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=yr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case tl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=yr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case tl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=yr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case tl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case tl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=yr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case tl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=yr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=$u,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.width=e,this.height=t,this.beautyRenderTarget.setSize(e,t),this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}generateSampleKernel(){let e=this.kernelSize,t=this.kernel;for(let n=0;n<e;n++){let i=new M;i.x=2*Math.random()-1,i.y=2*Math.random()-1,i.z=Math.random(),i.normalize();let r=n/e;r=Yt.lerp(.1,1,r*r),i.multiplyScalar(r),t.push(i)}}generateRandomKernelRotations(){let e=new yC,t=new Float32Array(16);for(let n=0;n<16;n++){let i=2*Math.random()-1,r=2*Math.random()-1,a=0;t[n]=e.noise3d(i,r,a)}this.noiseTexture=new Ro(t,4,4,gS,Bs),this.noiseTexture.wrapS=Nr,this.noiseTexture.wrapT=Nr,this.noiseTexture.needsUpdate=!0}overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse((function(e){t.set(e,e.visible),(e.isPoints||e.isLine)&&(e.visible=!1)}))}restoreVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse((function(e){let n=t.get(e);e.visible=n})),t.clear()}};tl.OUTPUT={Default:0,SSAO:1,Blur:2,Beauty:3,Depth:4,Normal:5};var Mfe={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new Ie(0)},defaultOpacity:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n\n\t\t\tfloat v = dot( texel.xyz, luma );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"},lh=class extends _i{constructor(e,t,n,i){super(),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=i,this.resolution=void 0!==e?new Q(e.x,e.y):new Q(256,256),this.clearColor=new Ie(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let r=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new Sn(r,a),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){let e=new Sn(r,a);e.texture.name="UnrealBloomPass.h"+h,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);let t=new Sn(r,a);t.texture.name="UnrealBloomPass.v"+h,t.texture.generateMipmaps=!1,this.renderTargetsVertical.push(t),r=Math.round(r/2),a=Math.round(a/2)}let s=Mfe;this.highPassUniforms=Lr.clone(s.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new It({uniforms:this.highPassUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,defines:{}}),this.separableBlurMaterials=[];let o=[3,5,7,9,11];r=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let h=0;h<this.nMips;h++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(o[h])),this.separableBlurMaterials[h].uniforms.texSize.value=new Q(r,a),r=Math.round(r/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0,this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new M(1,1,1),new M(1,1,1),new M(1,1,1),new M(1,1,1),new M(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;let l=ws;this.copyUniforms=Lr.clone(l.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new It({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:Ou,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Ie,this.oldClearAlpha=1,this.basic=new Pt,this.fsQuad=new Ts(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.materialCopy.dispose(),this.basic.dispose(),this.fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(n,i);for(let r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(n,i),this.renderTargetsVertical[r].setSize(n,i),this.separableBlurMaterials[r].uniforms.texSize.value=new Q(n,i),n=Math.round(n/2),i=Math.round(i/2)}render(e,t,n,i,r){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let a=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),r&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);let s=this.renderTargetBright;for(let o=0;o<this.nMips;o++)this.fsQuad.material=this.separableBlurMaterials[o],this.separableBlurMaterials[o].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[o].uniforms.direction.value=lh.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[o]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[o].uniforms.colorTexture.value=this.renderTargetsHorizontal[o].texture,this.separableBlurMaterials[o].uniforms.direction.value=lh.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[o]),e.clear(),this.fsQuad.render(e),s=this.renderTargetsVertical[o];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,r&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(n),this.fsQuad.render(e)),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}getSeperableBlurMaterial(e){return new It({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new Q(.5,.5)},direction:{value:new Q(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(e){return new It({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}};lh.BlurDirectionX=new Q(1,0),lh.BlurDirectionY=new Q(0,1);var Sfe={uniforms:{tDiffuse:{value:null},resolution:{value:new Q(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\tprecision highp float;\n\n\tuniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t//----------------------------------------------------------------------------------\n\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t// SDK Version: v3.00\n\t// Email: gameworks@nvidia.com\n\t// Site: http://developer.nvidia.com/\n\t//\n\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t//\n\t// Redistribution and use in source and binary forms, with or without\n\t// modification, are permitted provided that the following conditions\n\t// are met:\n\t// * Redistributions of source code must retain the above copyright\n\t// notice, this list of conditions and the following disclaimer.\n\t// * Redistributions in binary form must reproduce the above copyright\n\t// notice, this list of conditions and the following disclaimer in the\n\t// documentation and/or other materials provided with the distribution.\n\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t// contributors may be used to endorse or promote products derived\n\t// from this software without specific prior written permission.\n\t//\n\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t//\n\t//----------------------------------------------------------------------------------\n\n\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t#endif\n\n\t/*--------------------------------------------------------------------------*/\n\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t/*--------------------------------------------------------------------------*/\n\n\t#define NUM_SAMPLES 5\n\n\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t}\n\n\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t============================================================================*/\n\n\t/*--------------------------------------------------------------------------*/\n\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t\t// locate the edge\n\t\t\t\t\tvec2 dirToEdge;\n\t\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t\t// . 2 . . 1 .\n\t\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t\t// . 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 H\n\n\t\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t\t// V 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 .\n\n\t\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t\t\t// 1 1 .\n\t\t\t\t\t\t\t// 0 0 1\n\t\t\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t\t\t// do a simple blur\n\t\t\t\t\t\t\treturn mix(\n\t\t\t\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t\t\t\t.4\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\t\titerationsUsed = i;\n\n\t\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\t\tif(!doneN) {\n\t\t\t\t\t\t\tnDist += increment;\n\t\t\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(!doneP) {\n\t\t\t\t\t\t\tpDist += increment;\n\t\t\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\t\trgbaM,\n\t\t\t\t\trgbaN,\n\t\t\t\t\tdist * .5\n\t\t\t);\n\t}\n\n\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\t\tvUv,\n\t\t\t\t\ttDiffuse,\n\t\t\t\t\tresolution,\n\t\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t}\n\t"};function zot(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}function E0(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+s+"}":"unknown format"}var Rfe=Array.prototype.forEach,db=Array.prototype.slice,nt={BREAK:{},extend:function(e){return this.each(db.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(db.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=db.call(arguments);return function(){for(var t=db.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(Rfe&&e.forEach&&e.forEach===Rfe)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===this.BREAK)return}else for(var a in e)if(t.call(n,e[a],a)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var i=void 0;return function(){var r=this,a=arguments,s=n||!i;clearTimeout(i),i=setTimeout((function(){i=null,n||e.apply(r,a)}),t),s&&e.apply(r,a)}},toArray:function(e){return e.toArray?e.toArray():db.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},Got=[{litmus:nt.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:E0},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:E0},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:E0},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:E0}}},{litmus:nt.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:nt.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:nt.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(nt.isNumber(e.r)&&nt.isNumber(e.g)&&nt.isNumber(e.b)&&nt.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(nt.isNumber(e.r)&&nt.isNumber(e.g)&&nt.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(nt.isNumber(e.h)&&nt.isNumber(e.s)&&nt.isNumber(e.v)&&nt.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(nt.isNumber(e.h)&&nt.isNumber(e.s)&&nt.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],fb=void 0,EC=void 0,bk=function(){EC=!1;var e=arguments.length>1?nt.toArray(arguments):arguments[0];return nt.each(Got,(function(t){if(t.litmus(e))return nt.each(t.conversions,(function(t,n){if(fb=t.read(e),!1===EC&&!1!==fb)return EC=fb,fb.conversionName=n,fb.conversion=t,nt.BREAK})),nt.BREAK})),EC},Afe=void 0,_C={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Afe=8*t)|e&~(255<<Afe)}},qot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ql=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Wl=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),Gd=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,i)}if("value"in r)return r.value;var s=r.get;return void 0===s?void 0:s.call(i)},qd=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},Wd=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},$i=function(){function e(){if(ql(this,e),this.__state=bk.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Wl(e,[{key:"toString",value:function(){return E0(this)}},{key:"toHexString",value:function(){return E0(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function Rk(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||$i.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&($i.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function Ak(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||$i.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&($i.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}$i.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=_C.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");nt.extend(e.__state,_C.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},$i.recalculateHSV=function(e){var t=_C.rgb_to_hsv(e.r,e.g,e.b);nt.extend(e.__state,{s:t.s,v:t.v}),nt.isNaN(t.h)?nt.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},$i.COMPONENTS=["r","g","b","h","s","v","hex","a"],Rk($i.prototype,"r",2),Rk($i.prototype,"g",1),Rk($i.prototype,"b",0),Ak($i.prototype,"h"),Ak($i.prototype,"s"),Ak($i.prototype,"v"),Object.defineProperty($i.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty($i.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=_C.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Xp=function(){function e(t,n){ql(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return Wl(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),Wot={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},Ffe={};nt.each(Wot,(function(e,t){nt.each(e,(function(e){Ffe[e]=t}))}));var jot=/(\d+(\.\d+)?)px/;function Yc(e){if("0"===e||nt.isUndefined(e))return 0;var t=e.match(jot);return nt.isNull(t)?0:parseFloat(t[1])}var Ue={makeSelectable:function(e,t){void 0===e||void 0===e.style||(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var i=n,r=t;nt.isUndefined(r)&&(r=!0),nt.isUndefined(i)&&(i=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),i&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,i){var r=n||{},a=Ffe[t];if(!a)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(a);switch(a){case"MouseEvents":var o=r.x||r.clientX||0,l=r.y||r.clientY||0;s.initMouseEvent(t,r.bubbles||!1,r.cancelable||!0,window,r.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var h=s.initKeyboardEvent||s.initKeyEvent;nt.defaults(r,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,r.bubbles||!1,r.cancelable,window,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.keyCode,r.charCode);break;default:s.initEvent(t,r.bubbles||!1,r.cancelable||!0)}nt.defaults(s,i),e.dispatchEvent(s)},bind:function(e,t,n,i){var r=i||!1;return e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on"+t,n),Ue},unbind:function(e,t,n,i){var r=i||!1;return e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on"+t,n),Ue},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return Ue},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),i=n.indexOf(t);-1!==i&&(n.splice(i,1),e.className=n.join(" "))}else e.className=void 0;return Ue},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Yc(t["border-left-width"])+Yc(t["border-right-width"])+Yc(t["padding-left"])+Yc(t["padding-right"])+Yc(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Yc(t["border-top-width"])+Yc(t["border-bottom-width"])+Yc(t["padding-top"])+Yc(t["padding-bottom"])+Yc(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Hfe=function(e){function t(e,n){ql(this,t);var i=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=i;return i.__prev=i.getValue(),i.__checkbox=document.createElement("input"),i.__checkbox.setAttribute("type","checkbox"),Ue.bind(i.__checkbox,"change",(function(){r.setValue(!r.__prev)}),!1),i.domElement.appendChild(i.__checkbox),i.updateDisplay(),i}return qd(t,Xp),Wl(t,[{key:"setValue",value:function(e){var n=Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Xot=function(e){function t(e,n,i){ql(this,t);var r=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i,s=r;if(r.__select=document.createElement("select"),nt.isArray(a)){var o={};nt.each(a,(function(e){o[e]=e})),a=o}return nt.each(a,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),s.__select.appendChild(n)})),r.updateDisplay(),Ue.bind(r.__select,"change",(function(){var e=this.options[this.selectedIndex].value;s.setValue(e)})),r.domElement.appendChild(r.__select),r}return qd(t,Xp),Wl(t,[{key:"setValue",value:function(e){var n=Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return Ue.isActive(this.__select)?this:(this.__select.value=this.getValue(),Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(),Yot=function(e){function t(e,n){ql(this,t);var i=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=i;function a(){r.setValue(r.__input.value)}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),Ue.bind(i.__input,"keyup",a),Ue.bind(i.__input,"change",a),Ue.bind(i.__input,"blur",(function(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())})),Ue.bind(i.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return qd(t,Xp),Wl(t,[{key:"updateDisplay",value:function(){return Ue.isActive(this.__input)||(this.__input.value=this.getValue()),Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function Cfe(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var kfe=function(e){function t(e,n,i){ql(this,t);var r=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,nt.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=Cfe(r.__impliedStep),r}return qd(t,Xp),Wl(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=Cfe(e),this}}]),t}();function $ot(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}var TC=function(e){function t(e,n,i){ql(this,t);var r=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function h(){Ue.unbind(window,"mousemove",l),Ue.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Ue.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);nt.isNaN(e)||a.setValue(e)})),Ue.bind(r.__input,"blur",(function(){o()})),Ue.bind(r.__input,"mousedown",(function(e){Ue.bind(window,"mousemove",l),Ue.bind(window,"mouseup",h),s=e.clientY})),Ue.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return qd(t,kfe),Wl(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():$ot(this.getValue(),this.__precision),Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function Pfe(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var _k=function(e){function t(e,n,i,r,a){ql(this,t);var s=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(Pfe(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){Ue.unbind(window,"mousemove",l),Ue.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function c(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(Pfe(t,n.left,n.right,o.__min,o.__max))}function u(){Ue.unbind(window,"touchmove",c),Ue.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),Ue.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),Ue.bind(window,"mousemove",l),Ue.bind(window,"mouseup",h),l(e)})),Ue.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(Ue.bind(window,"touchmove",c),Ue.bind(window,"touchend",u),c(e))})),Ue.addClass(s.__background,"slider"),Ue.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return qd(t,kfe),Wl(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Gd(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Vfe=function(e){function t(e,n,i){ql(this,t);var r=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,Ue.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Ue.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return qd(t,Xp),Wl(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),Tk=function(e){function t(e,n){ql(this,t);var i=Wd(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new $i(i.getValue()),i.__temp=new $i(0);var r=i;i.domElement=document.createElement("div"),Ue.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",Ue.bind(i.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),Ue.bind(i.__input,"blur",c),Ue.bind(i.__selector,"mousedown",(function(){Ue.addClass(this,"drag").bind(window,"mouseup",(function(){Ue.removeClass(r.__selector,"drag")}))})),Ue.bind(i.__selector,"touchstart",(function(){Ue.addClass(this,"drag").bind(window,"touchend",(function(){Ue.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),Ue.bind(window,"mousemove",d),Ue.bind(window,"touchmove",d),Ue.bind(window,"mouseup",l),Ue.bind(window,"touchend",l)}function o(e){p(e),Ue.bind(window,"mousemove",p),Ue.bind(window,"touchmove",p),Ue.bind(window,"mouseup",h),Ue.bind(window,"touchend",h)}function l(){Ue.unbind(window,"mousemove",d),Ue.unbind(window,"touchmove",d),Ue.unbind(window,"mouseup",l),Ue.unbind(window,"touchend",l),u()}function h(){Ue.unbind(window,"mousemove",p),Ue.unbind(window,"touchmove",p),Ue.unbind(window,"mouseup",h),Ue.unbind(window,"touchend",h),u()}function c(){var e=bk(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return nt.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),nt.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),nt.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),nt.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),nt.extend(a.style,{width:"100%",height:"100%",background:"none"}),Ife(a,"top","rgba(0,0,0,0)","#000"),nt.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),Kot(i.__hue_field),nt.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),Ue.bind(i.__saturation_field,"mousedown",s),Ue.bind(i.__saturation_field,"touchstart",s),Ue.bind(i.__field_knob,"mousedown",s),Ue.bind(i.__field_knob,"touchstart",s),Ue.bind(i.__hue_field,"mousedown",o),Ue.bind(i.__hue_field,"touchstart",o),i.__saturation_field.appendChild(a),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return qd(t,Xp),Wl(t,[{key:"updateDisplay",value:function(){var e=bk(this.getValue());if(!1!==e){var t=!1;nt.each($i.COMPONENTS,(function(n){if(!nt.isUndefined(e[n])&&!nt.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&nt.extend(this.__color.__state,e)}nt.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;nt.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,Ife(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),nt.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(),Zot=["-moz-","-o-","-webkit-","-ms-",""];function Ife(e,t,n,i){e.style.background="",nt.each(Zot,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}function Kot(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var Jot={load:function(e,t){var n=t||document,i=n.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=e,n.getElementsByTagName("head")[0].appendChild(i)},inject:function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}},Qot='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',elt=function(e,t){var n=e[t];return nt.isArray(arguments[2])||nt.isObject(arguments[2])?new Xot(e,t,arguments[2]):nt.isNumber(n)?nt.isNumber(arguments[2])&&nt.isNumber(arguments[3])?nt.isNumber(arguments[4])?new _k(e,t,arguments[2],arguments[3],arguments[4]):new _k(e,t,arguments[2],arguments[3]):nt.isNumber(arguments[4])?new TC(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new TC(e,t,{min:arguments[2],max:arguments[3]}):nt.isString(n)?new Yot(e,t):nt.isFunction(n)?new Vfe(e,t,""):nt.isBoolean(n)?new Hfe(e,t):null};function tlt(e){setTimeout(e,1e3/60)}var nlt=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||tlt,rlt=function(){function e(){ql(this,e),this.backgroundElement=document.createElement("div"),nt.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Ue.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),nt.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Ue.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Wl(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),nt.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Ue.unbind(e.domElement,"webkitTransitionEnd",t),Ue.unbind(e.domElement,"transitionend",t),Ue.unbind(e.domElement,"oTransitionEnd",t)};Ue.bind(this.domElement,"webkitTransitionEnd",t),Ue.bind(this.domElement,"transitionend",t),Ue.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Ue.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Ue.getHeight(this.domElement)/2+"px"}}]),e}(),ilt=zot(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");Jot.inject(ilt);var Dfe="dg",Lfe=72,Ofe=20,vb="Default",pb=function(){try{return!!window.localStorage}catch(e){return!1}}(),mb=void 0,Nfe=!0,x0=void 0,Ek=!1,zfe=[],Hr=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Ue.addClass(this.domElement,Dfe),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=nt.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=nt.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),nt.isUndefined(i.load)?i.load={preset:vb}:i.preset&&(i.load.preset=i.preset),nt.isUndefined(i.parent)&&i.hideable&&zfe.push(this),i.resizable=nt.isUndefined(i.parent)&&i.resizable,i.autoPlace&&nt.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=pb&&"true"===localStorage.getItem(y0(this,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,llt(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,Sk(n,e)}},name:{get:function(){return i.name},set:function(e){i.name=e,o&&(o.innerHTML=i.name)}},closed:{get:function(){return i.closed},set:function(t){i.closed=t,i.closed?Ue.addClass(n.__ul,e.CLASS_CLOSED):Ue.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return i.load}},useLocalStorage:{get:function(){return a},set:function(e){pb&&(a=e,e?Ue.bind(window,"unload",s):Ue.unbind(window,"unload",s),localStorage.setItem(y0(n,"isLocal"),e))}}}),nt.isUndefined(i.parent)){if(this.closed=i.closed||!1,Ue.addClass(this.domElement,e.CLASS_MAIN),Ue.makeSelectable(this.domElement,!1),pb&&a){n.useLocalStorage=!0;var l=localStorage.getItem(y0(this,"gui"));l&&(i.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,Ue.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(Ue.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(Ue.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),Ue.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===i.closed&&(i.closed=!0);var h=document.createTextNode(i.name);Ue.addClass(h,"controller-name"),o=Ck(n,h),Ue.addClass(this.__ul,e.CLASS_CLOSED),Ue.addClass(o,"title"),Ue.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),i.closed||(this.closed=!1)}i.autoPlace&&(nt.isUndefined(i.parent)&&(Nfe&&(x0=document.createElement("div"),Ue.addClass(x0,Dfe),Ue.addClass(x0,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(x0),Nfe=!1),x0.appendChild(this.domElement),Ue.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||Sk(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},Ue.bind(window,"resize",this.__resizeHandler),Ue.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),Ue.bind(this.__ul,"transitionend",this.__resizeHandler),Ue.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&olt(this),s=function(){pb&&"true"===localStorage.getItem(y0(n,"isLocal"))&&localStorage.setItem(y0(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,i.parent||((r=n.getRoot()).width+=1,nt.defer((function(){r.width-=1})))};function Ck(e,t,n){var i=document.createElement("li");return t&&i.appendChild(t),n?e.__ul.insertBefore(i,n):e.__ul.appendChild(i),e.onResize(),i}function Ufe(e){Ue.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&Ue.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function wk(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function slt(e,t,n){if(n.__li=t,n.__gui=e,nt.extend(n,{options:function(t){if(arguments.length>1){var i=n.__li.nextElementSibling;return n.remove(),gb(e,n.object,n.property,{before:i,factoryArgs:[nt.toArray(arguments)]})}if(nt.isArray(t)||nt.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),gb(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof _k){var i=new TC(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});nt.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),Ue.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof TC){var r=function(t){if(nt.isNumber(n.__min)&&nt.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=gb(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=nt.compose(r,n.min),n.max=nt.compose(r,n.max)}else n instanceof Hfe?(Ue.bind(t,"click",(function(){Ue.fakeEvent(n.__checkbox,"click")})),Ue.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof Vfe?(Ue.bind(t,"click",(function(){Ue.fakeEvent(n.__button,"click")})),Ue.bind(t,"mouseover",(function(){Ue.addClass(n.__button,"hover")})),Ue.bind(t,"mouseout",(function(){Ue.removeClass(n.__button,"hover")}))):n instanceof Tk&&(Ue.addClass(t,"color"),n.updateDisplay=nt.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=nt.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&wk(e.getRoot(),!0),t}),n.setValue)}function Gfe(e,t){var n=e.getRoot(),i=n.__rememberedObjects.indexOf(t.object);if(-1!==i){var r=n.__rememberedObjectIndecesToControllers[i];if(void 0===r&&(r={},n.__rememberedObjectIndecesToControllers[i]=r),r[t.property]=t,n.load&&n.load.remembered){var a=n.load.remembered,s=void 0;if(a[e.preset])s=a[e.preset];else{if(!a[vb])return;s=a[vb]}if(s[i]&&void 0!==s[i][t.property]){var o=s[i][t.property];t.initialValue=o,t.setValue(o)}}}}function gb(e,t,n,i){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(i.color)r=new Tk(t,n);else{var a=[t,n].concat(i.factoryArgs);r=elt.apply(e,a)}i.before instanceof Xp&&(i.before=i.before.__li),Gfe(e,r),Ue.addClass(r.domElement,"c");var s=document.createElement("span");Ue.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=Ck(e,o,i.before);return Ue.addClass(l,Hr.CLASS_CONTROLLER_ROW),r instanceof Tk?Ue.addClass(l,"color"):Ue.addClass(l,qot(r.getValue())),slt(e,l,r),e.__controllers.push(r),r}function y0(e,t){return document.location.href+"."+t}function Mk(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Bfe(e,t){t.style.display=e.useLocalStorage?"block":"none"}function alt(e){var t=e.__save_row=document.createElement("li");Ue.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Ue.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML="&nbsp;",Ue.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",Ue.addClass(i,"button"),Ue.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",Ue.addClass(r,"button"),Ue.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Ue.addClass(a,"button"),Ue.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?nt.each(e.load.remembered,(function(t,n){Mk(e,n,n===e.preset)})):Mk(e,vb,!1),Ue.bind(s,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(s),t.appendChild(n),t.appendChild(i),t.appendChild(r),t.appendChild(a),pb){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(y0(e,"isLocal"))&&l.setAttribute("checked","checked"),Bfe(e,o),Ue.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,Bfe(e,o)}))}var h=document.getElementById("dg-new-constructor");Ue.bind(h,"keydown",(function(e){e.metaKey&&(67===e.which||67===e.keyCode)&&mb.hide()})),Ue.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),mb.show(),h.focus(),h.select()})),Ue.bind(i,"click",(function(){e.save()})),Ue.bind(r,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),Ue.bind(a,"click",(function(){e.revert()}))}function olt(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){Ue.removeClass(e.__closeButton,Hr.CLASS_DRAG),Ue.unbind(window,"mousemove",n),Ue.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,Ue.addClass(e.__closeButton,Hr.CLASS_DRAG),Ue.bind(window,"mousemove",n),Ue.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),nt.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Ue.bind(e.__resize_handle,"mousedown",r),Ue.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Sk(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function bC(e,t){var n={};return nt.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];nt.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function llt(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}function qfe(e){0!==e.length&&nlt.call(window,(function(){qfe(e)})),nt.each(e,(function(e){e.updateDisplay()}))}Hr.toggleHide=function(){Ek=!Ek,nt.each(zfe,(function(e){e.domElement.style.display=Ek?"none":""}))},Hr.CLASS_AUTO_PLACE="a",Hr.CLASS_AUTO_PLACE_CONTAINER="ac",Hr.CLASS_MAIN="main",Hr.CLASS_CONTROLLER_ROW="cr",Hr.CLASS_TOO_TALL="taller-than-window",Hr.CLASS_CLOSED="closed",Hr.CLASS_CLOSE_BUTTON="close-button",Hr.CLASS_CLOSE_TOP="close-top",Hr.CLASS_CLOSE_BOTTOM="close-bottom",Hr.CLASS_DRAG="drag",Hr.DEFAULT_WIDTH=245,Hr.TEXT_CLOSED="Close Controls",Hr.TEXT_OPEN="Open Controls",Hr._keydownHandler=function(e){"text"!==document.activeElement.type&&(e.which===Lfe||e.keyCode===Lfe)&&Hr.toggleHide()},Ue.bind(window,"keydown",Hr._keydownHandler,!1),nt.extend(Hr.prototype,{add:function(e,t){return gb(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return gb(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;nt.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&x0.removeChild(this.domElement);var e=this;nt.each(this.__folders,(function(t){e.removeFolder(t)})),Ue.unbind(window,"keydown",Hr._keydownHandler,!1),Ufe(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new Hr(t);this.__folders[e]=n;var i=Ck(this,n.domElement);return Ue.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],Ufe(e);var t=this;nt.each(e.__folders,(function(t){e.removeFolder(t)})),nt.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Ue.getOffset(e.__ul).top,n=0;nt.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Ue.getHeight(t))})),window.innerHeight-t-Ofe<n?(Ue.addClass(e.domElement,Hr.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-Ofe+"px"):(Ue.removeClass(e.domElement,Hr.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&nt.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:nt.debounce((function(){this.onResize()}),50),remember:function(){if(nt.isUndefined(mb)&&((mb=new rlt).domElement.innerHTML=Qot),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;nt.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&alt(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&Sk(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=bC(this)),e.folders={},nt.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=bC(this),wk(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[vb]=bC(this,!0)),this.load.remembered[e]=bC(this),this.preset=e,Mk(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){nt.each(this.__controllers,(function(t){this.getRoot().load.remembered?Gfe(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),nt.each(this.__folders,(function(e){e.revert(e)})),e||wk(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&qfe(this.__listening)},updateDisplay:function(){nt.each(this.__controllers,(function(e){e.updateDisplay()})),nt.each(this.__folders,(function(e){e.updateDisplay()}))}});var Wfe=Hr,jfe=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],ch=(()=>{if("undefined"==typeof document)return!1;let e=jfe[0],t={};for(let n of jfe)if((null==n?void 0:n[1])in document){for(let[i,r]of n.entries())t[e[i]]=r;return t}return!1})(),Xfe={change:ch.fullscreenchange,error:ch.fullscreenerror},io={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{let r=()=>{io.off("change",r),n()};io.on("change",r);let a=e[ch.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!io.isFullscreen)return void e();let n=()=>{io.off("change",n),e()};io.on("change",n);let i=document[ch.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>io.isFullscreen?io.exit():io.request(e,t),onchange(e){io.on("change",e)},onerror(e){io.on("error",e)},on(e,t){let n=Xfe[e];n&&document.addEventListener(n,t,!1)},off(e,t){let n=Xfe[e];n&&document.removeEventListener(n,t,!1)},raw:ch};Object.defineProperties(io,{isFullscreen:{get:()=>Boolean(document[ch.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[ch.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[ch.fullscreenEnabled])}}),ch||(io={isEnabled:!1});var wC=io;function Yfe(e,t,n,i,r,a,s){let o=e.addFolder(t);o.add(n,"x",r,a,s).onChange(i),o.add(n,"y",r,a,s).onChange(i),o.add(n,"z",r,a,s).onChange(i)}var MC=class{constructor(e){this.exploderDict={},this.controls={showGroundGrid:!1,showGrassGround:!1,skyMode:["None","Black Background","White Background","Gradient ramp","Cloudy"],environments:["None","Default (City Streat 64x32)","Venice Sunset","Footprint Court (HDR Labs)","City Street"],homeView:()=>console.log("[DGH] Go to home view"),views:["Top","Bottom","Front","Back","Left","Right"],OrthographicCamera:!1,viewpoints:!1,annotations:!1,takeSnapshot:()=>console.log("[DGH] Taking snapshot..."),fullScreen:()=>console.log("[DGH] Full screen..."),webcam:!1,uploadFile:()=>console.log("[DGH] Upload file..."),showBimTree:!1,showPropertyPanel:!1,transparentMode:!1,showVertexNormals:!1,sectionMode:["No section","Box section","Plane section"],alVisible:!0,alColor:"#cccccc",alIntensity:1,dlColor:"#dddddd",showDlHelper:!1,hlVisible:!0,hlIntensity:1,hlColor:[255,255,255,.6],hlGroundColor:[200,255,200,.6],fogEnabled:!1,fogColor:14540253,fogNearDistance:1,fogFarDistance:1e3,composerEnabled:!1,renderPassEnabled:!1,fxaaEnabled:!1,saoEnabled:!1,ssaoEnabled:!1,outlineEnabled:!1,ssaaEnabled:!1,bloomEnabled:!1,unrealBloomEnabled:!1},this.viewer=e,this.init()}init(){if(!this.viewer||!this.viewer.renderer||!this.viewer.scene)throw new Error("Need to initialize renderer, scene first!");let e=this.viewer,t=this.viewer.scene,n=this.controls;this.gui=new Wfe({name:"controls",autoPlace:!0,width:300,closed:!0}),this.gui.domElement.style.opacity="0.6";let i=this.gui.addFolder("Common settings");i.add(n,"showGroundGrid").name("Show ground grid").onChange((n=>{e.groundGrid?e.groundGrid.visible=n:n&&(e.groundGrid=vs.createGroundGrid(),t.add(e.groundGrid),e.enableRender()),e.enableRender()})),i.add(n,"showGrassGround").name("Show grass ground").onChange((n=>{e.grassGround?e.grassGround.visible=n:n&&$e(this,null,(function*(){e.grassGround=yield vs.createGrassGround(),t.add(e.grassGround),e.enableRender()})),e.enableRender()}));let r=i.add(n,"skyMode",n.skyMode).name("Sky mode");r.onChange((n=>{if(e.skyOfGradientRamp&&(e.skyOfGradientRamp.visible="Gradient ramp"===n),"Black Background"===n)t.background=new Ie(0);else if("White Background"===n)t.background=new Ie(16777215);else if("Gradient ramp"===n)e.skyOfGradientRamp||(e.skyOfGradientRamp=Ka.createSkyOfGradientRamp(),t.add(e.skyOfGradientRamp)),e.skyOfGradientRamp.visible=!0;else if("Cloudy"===n){let e=["right.jpg","left.jpg","top.jpg","bottom.jpg","front.jpg","back.jpg"];e=e.map((e=>`${window.location.origin}/images/skybox/cloudy/${e}`)),Ka.createSkyFromTextures(e).then((e=>{t.background=e}))}else t.background=e.sceneBackgroundColor;e.enableRender()})),r.setValue("Gradient ramp"),i.add(n,"environments",n.environments).name("Environments").onChange((n=>{let i="";if("Default (City Streat 64x32)"===n){if(e.pmremGenerator)return Cl.createEnvTextureFromDataArray(e.pmremGenerator).then((e=>{t.environment=e})),void e.enableRender()}else"Venice Sunset"===n?i="venice_sunset_1k.hdr":"Footprint Court (HDR Labs)"===n?i="footprint_court_2k.hdr":"City Street"===n&&(i="city_street_256.hdr");""===i?t.environment=null:(i=`${window.location.origin}/images/envmap/${i}`,Cl.createEnvTexture(e.pmremGenerator,i).then((e=>{t.environment=e}))),e.enableRender()})),i.add(n,"homeView").name("Go to home view").onChange((()=>{e.goToHomeView()})),i.add(n,"views",n.views).name("Views").onChange((n=>{var i;let r=new M,a=new M,s=Fr.getVisibleObjectBoundingBox(t),o=Ws.getCameraDirectionByView(n);Ws.getCameraPositionByBboxAndDirection(s,r,a,null==(i=e.camera)?void 0:i.projectionMatrix,o),e.flyTo(r,a)})),i.add(n,"OrthographicCamera").name("Orth Camera").onChange((t=>{e.setToOrthographicCamera(t)})),i.add(n,"takeSnapshot").name("Take snapshot").onChange((()=>{})),i.add(n,"fullScreen").name("Full screen").onChange((()=>{wC&&wC.isEnabled&&wC.request(),e.enableRender()})),i.add(n,"uploadFile").name("Upload file").onChange((()=>{new kA(e).openFileBrowserToUpload()}));let a=this.gui.addFolder("Model operations");a.add(n,"transparentMode",n.transparentMode).name("Transparent mode").onChange((t=>{e.addOrRemoveObjectOpacity(t),e.enableRender()})),a.add(n,"showVertexNormals",n.showVertexNormals).name("Show Vertex Normals").onChange((t=>{e.showVertexNormals(t),e.enableRender()})),a.add(n,"sectionMode",n.sectionMode).name("Section mode").onChange((t=>{"No section"===t?e.deactivateSection():"Box section"===t?e.activateSection("ObjectsBoxSection"):"Plane section"===t&&e.activateSection("PickPlaneSection"),e.enableRender()}));let s=this.viewer.ambientLight,o=this.gui.addFolder("Ambient light");o.add(n,"alVisible",n.alVisible).name("visible").onChange((t=>{s&&(s.visible=t),e.enableRender()})),o.addColor(n,"alColor").name("color").onChange((t=>{s&&(s.color=new Ie(t)),e.enableRender()})),o.add(n,"alIntensity",0,5).name("intensity").onChange((t=>{s&&(s.intensity=t),e.enableRender()}));let l=this.viewer.directionalLight;if(l){let t=this.gui.addFolder("Directional light");t.add(l,"visible").name("visible").onChange((t=>{l&&(l.visible=t),e.enableRender()})),t.addColor(n,"dlColor").name("color").onChange((t=>{l&&(l.color=new Ie(t)),e.enableRender()})),t.add(l,"intensity",0,5).name("intensity").onChange((t=>{l&&(l.intensity=t),e.enableRender()})),t.add(l,"castShadow").name("castShadow").onChange((t=>{l&&(l.castShadow=t),e.enableRender()})),t.add(n,"showDlHelper").name("showDlHelper").onChange((t=>{e.showDirectionalLightHelper(t),e.enableRender()}));let i=()=>{e.updateDirectionalLight(),e.enableRender()};Yfe(t,"position",l.position,i),Yfe(t,"target",l.target.position,i);let r=t.addFolder("shadow");r.add(l.shadow.camera,"near").name("near").onChange(i),r.add(l.shadow.camera,"far").name("far").onChange(i),r.add(l.shadow.camera,"zoom").name("zoom").onChange(i)}let h=this.viewer.hemisphereLight,c=this.gui.addFolder("Hemisphere Light");c.add(n,"hlVisible",n.hlVisible).name("visible").onChange((t=>{h&&(h.visible=t),e.enableRender()})),c.add(n,"hlIntensity",0,5).name("intensity").onChange((t=>{h&&(h.intensity=t),e.enableRender()})),c.addColor(n,"hlColor").name("color").onChange((t=>{h&&(h.color=new Ie(t)),e.enableRender()})),c.addColor(n,"hlGroundColor").name("groundColor").onChange((t=>{h&&(h.groundColor=new Ie(t)),e.enableRender()}));let u=this.gui.addFolder("Fog");u.add(n,"fogEnabled",n.fogEnabled).name("Enabled").onChange((i=>{t.fog=i?new xc(n.fogColor,n.fogNearDistance,n.fogFarDistance):null,e.enableRender()})),u.add(n,"fogNearDistance",0,100).name("Near").onChange((i=>{n.fogEnabled&&t&&(t.fog=new xc(n.fogColor,i,n.fogFarDistance)),e.enableRender()})),u.add(n,"fogFarDistance",100,2e3).name("Far").onChange((i=>{n.fogEnabled&&t&&(t.fog=new xc(n.fogColor,n.fogNearDistance,i)),e.enableRender()}));let d=this.gui.addFolder("Composer");d.add(n,"composerEnabled",n.composerEnabled).name("Composer Enabled").onChange((t=>{e.enableComposer(t)})),d.add(n,"renderPassEnabled",n.renderPassEnabled).name("RenderPass Enabled").onChange((t=>{e.enableRenderPass(t)})),d.add(n,"fxaaEnabled",n.fxaaEnabled).name("Effect FXAA Enabled").onChange((t=>{e.enableFxaaPass(t)})),d.add(n,"saoEnabled",n.saoEnabled).name("SAO Enabled").onChange((t=>{e.enableSaoPass(t)})),d.add(n,"ssaoEnabled",n.ssaoEnabled).name("SSAO Enabled").onChange((t=>{e.enableSsaoPass(t)})),d.add(n,"outlineEnabled",n.outlineEnabled).name("OutlinePass Enabled").onChange((t=>{e.enableOutlinePass(t)})),d.add(n,"ssaaEnabled",n.ssaaEnabled).name("SSAA Enabled").onChange((t=>{e.enableSsaaPass(t)})),d.add(n,"bloomEnabled",n.bloomEnabled).name("Bloom Enabled").onChange((t=>{e.enableBloomPass(t)})),d.add(n,"unrealBloomEnabled",n.unrealBloomEnabled).name("Unreal Bloom Enabled").onChange((t=>{e.enableUnrealBloomPass(t)}))}setExplodeMode(e,t=!1){!this.viewer||!this.viewer.scene||!this.viewer.loadedModels||!this.exploderDict||(e?Fr.explodeObjects(this.viewer.scene,this.exploderDict,Object.values(this.viewer.loadedModels).map((e=>e.id)),t):Fr.unexplodeObjects(this.viewer.scene,this.exploderDict||{}))}open(){this.gui&&this.gui.open()}close(){this.gui&&this.gui.close()}beforeDestroy(){this.viewer=void 0,this.gui&&this.gui.destroy(),this.gui=void 0,this.exploderDict=[]}},SC=class{constructor(){this.vertexShader="\n varying vec2 vUv;\n void main( void ) {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }",this.fragmentShader="\n uniform vec3 keyColor;\n uniform float similarity;\n uniform float smoothness;\n varying vec2 vUv;\n uniform sampler2D map;\n void main() {\n vec4 videoColor = texture2D(map, vUv);\n\n float Y1 = 0.299 * keyColor.r + 0.587 * keyColor.g + 0.114 * keyColor.b;\n float Cr1 = keyColor.r - Y1;\n float Cb1 = keyColor.b - Y1;\n \n float Y2 = 0.299 * videoColor.r + 0.587 * videoColor.g + 0.114 * videoColor.b;\n float Cr2 = videoColor.r - Y2; \n float Cb2 = videoColor.b - Y2; \n \n float blend = smoothstep(similarity, similarity + smoothness, distance(vec2(Cr2, Cb2), vec2(Cr1, Cb1)));\n gl_FragColor = vec4(videoColor.rgb, videoColor.a * blend); \n }";let e=document.createElement("video");this.webcam=e,navigator.mediaDevices.getUserMedia({video:{width:600,height:400}}).then((t=>{e.srcObject=t,e.onloadedmetadata=()=>{e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.play()}})).catch((function(e){alert(e.name+": "+e.message)})),this.webcamCanvas=document.createElement("canvas");let t=this.webcamCanvas.getContext("2d");this.canvasCtx=t,t.fillStyle="#000000",t.fillRect(0,0,this.webcamCanvas.width,this.webcamCanvas.height);let n=new ur(this.webcamCanvas);this.webcamTexture=n,n.minFilter=Vn,n.magFilter=Vn,this.shaderMaterial=new It({transparent:!0,uniforms:{map:{value:n},keyColor:{value:[0,1,0]},similarity:{value:.3},smoothness:{value:0}},vertexShader:this.vertexShader,fragmentShader:this.fragmentShader})}getShaderMaterial(){return this.shaderMaterial}createWebCamPlane(e=5,t=4){let n=new Ur(e,t);return new Ge(n,this.shaderMaterial)}animate(){this.webcam.readyState===this.webcam.HAVE_ENOUGH_DATA&&(this.canvasCtx.drawImage(this.webcam,0,0,this.webcamCanvas.width,this.webcamCanvas.height),this.webcamTexture.needsUpdate=!0)}},RC=class{constructor(e){this.width=0,this.height=0,this.raycaster=new Gs,this.cfg=e,this.init(),this.animate()}init(){tn.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=document.getElementById(this.cfg.containerId);e||($.error("[ViewCubePlugin] containerId:",this.cfg.containerId,"is not found in dom tree! will append to document body"),e=document.body),this.width=e.clientWidth,this.height=e.clientHeight,this.container=e}initScene(){let e=new ii;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new dr(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(300,300,300),e.lookAt(0,0,0),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e}initRenderer(){var e;this.renderer=new ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),this.renderer.shadowMap.enabled=!0,null==(e=this.container)||e.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=new ji(16777215,1.5);e.name="sun",e.castShadow=!0,e.position.set(-2,2,4),e.shadow.autoUpdate=!1,e.shadow.mapSize.width=1024,e.shadow.mapSize.height=1024,this.directionalLight=e,this.scene.add(e),this.scene.add(e.target)}getNdcPointByPointerEvent(e){if(!this.container||!this.camera)return;let t=nn.getScreenPointByEvent(e,this.container);return nn.screenPoint2NdcPoint(t,this.camera,this.container)}getIntersects(e){return this.scene&&this.camera?(this.camera.updateMatrixWorld(),this.raycaster.layers.set(12),this.raycaster.setFromCamera(e,this.camera),this.raycaster&&this.raycaster.intersectObjects(this.scene.children,!0)||[]):void 0}zoomToBbox(e){if(!this.camera)return;let t=this.camera.right-this.camera.left,n=this.camera.top-this.camera.bottom,i=new M;e.getSize(i);let r=Math.sqrt(Math.pow(i.x,2)+Math.pow(i.y,2)+Math.pow(i.z,2)),a=Math.min(t/r,n/r);this.camera.position.set(i.x/2,i.y/2,i.z/2),this.camera.zoom=a,this.camera.updateProjectionMatrix()}animate(){var e,t,n;if(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.scene&&this.camera&&(null==(e=this.renderer)||e.render(this.scene,this.camera),!tn.isBrowser)){let e=null==(t=this.renderer)?void 0:t.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}null==(n=this.update)||n.call(this)}destroy(){var e,t,n;this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),null==(e=this.container)||e.remove(),this.container=void 0,null==(t=this.scene)||t.clear(),this.scene=void 0,null==(n=this.directionalLight)||n.dispose(),this.directionalLight=void 0,this.update=void 0}};function ult(e,t,n,i,r){let a=document.createElement("span");return a.style.font="1px serif",a.style.fontFamily=e,a.style.fontSize=`${t}px`,a.style.fontStyle=n,a.style.fontVariant=i,a.style.fontWeight=r,a.style.font}var hlt=Object.freeze({text:"",color:"#fff",alignment:"center",backgroundColor:0,fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineGap:1/4,padding:.5,strokeColor:"#000",strokeWidth:0}),AC=class extends ur{constructor(e,t=document.createElement("canvas")){super(t),this.canvas=t,this.isTextTexture=!0,this.needsRedraw=!0,this.contentOffset=0,this.lineOffset=0,this.width=0,this.height=0,this.pixelRatio=Math.max(window.devicePixelRatio||1),this.computeOptimalPixelRatio=()=>{let e=new M,t=new Q,n=new M,i=new M,r=new Q;return(a,s,o)=>{var l,h;if(r.set(this.width,this.height),r.x&&r.y){a.getWorldPosition(n),o.getWorldPosition(e);let c=n.distanceTo(e);if(o.isPerspectiveCamera&&(c*=2*Math.tan(Yt.degToRad(o.fov)/2)),(o.isPerspectiveCamera||o.isOrthographicCamera)&&(c/=o.zoom),c){a.getWorldScale(i);let e=null!=(h=null==(l=s.capabilities)?void 0:l.maxTextureSize)?h:1/0;return s.getDrawingBufferSize(t),Math.min(Math.max(i.x/c*(t.x/r.x),i.y/c*(t.y/r.y)),e/r.x,e/r.y)}}return 0}},this.cfg=yn(yn({},hlt),e)}get lines(){let{text:e}=this.cfg;return e?e.split("\n"):[]}get font(){let{fontFamily:e,fontSize:t,fontStyle:n,fontVariant:i,fontWeight:r}=this.cfg;return ult(e,t,n,i,r)}getContentWidth(){let{font:e,lines:t}=this,n=document.createElement("canvas").getContext("2d");return n.font=e,Math.max(...t.map((e=>n.measureText(e).width)))}initDraw(){let{lineGap:e,padding:t,strokeWidth:n}=this.cfg;t*=this.cfg.fontSize,e*=this.cfg.fontSize,n*=this.cfg.fontSize;let i=this.lines.length,r=this.cfg.fontSize+e,a=t+n/2,s=(i?this.getContentWidth():0)+2*a,o=(i?this.cfg.fontSize+r*(i-1):0)+2*a;this.width=s,this.height=o,this.contentOffset=a,this.lineOffset=r}getDrawPosition(e){let t=this.contentOffset+this.cfg.fontSize/2;switch(e){case"left":return{x:this.contentOffset,y:t};case"right":return{x:this.width-this.contentOffset,y:t}}return{x:this.width/2,y:t}}draw(){let e=this.canvas.getContext("2d"),{alignment:t,backgroundColor:n,color:i,strokeColor:r,strokeWidth:a}=this.cfg;e.fillStyle="#"+n.toString(16),e.fillRect(0,0,e.canvas.width,e.canvas.height),Object.assign(e,{fillStyle:i,font:this.font,lineWidth:a,miterLimit:1,strokeStyle:r,textAlign:t,textBaseline:"middle"});let{x:s,y:o}=this.getDrawPosition(t),l=o;this.lines.forEach((t=>{e.fillText(t,s,l),a&&e.strokeText(t,s,l),l+=this.lineOffset}))}getDrawingBufferWidth(){return Yt.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return Yt.ceilPowerOfTwo(this.height*this.pixelRatio)}redrew(){if(this.needsRedraw){this.initDraw();let e=this.canvas,t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),e.width=this.getDrawingBufferWidth(),e.height=this.getDrawingBufferHeight(),e.width&&e.height?(t.save(),t.scale(e.width/this.width,e.height/this.height),this.draw(),t.restore()):e.width=e.height=1,this.needsRedraw=!1,this.needsUpdate=!0}}setPixelRatio(e){if(this.pixelRatio!==e){let t=this.getDrawingBufferWidth(),n=this.getDrawingBufferHeight();this.pixelRatio=e;let i=this.getDrawingBufferWidth(),r=this.getDrawingBufferHeight();(i!==t||r!==n)&&(this.needsRedraw=!0)}}setOptimalPixelRatio(e,t,n){let i=this.computeOptimalPixelRatio();this.setPixelRatio(i(e,t,n))}updateConfig(e){this.cfg=yn(yn({},this.cfg),e),this.needsRedraw=!0}};function Pk(e,t,n){let i=new Ie(e),r=new Ie(t);return i.lerp(r,n).getHex()}var qn=(e=>(e[e.Rotate0=0]="Rotate0",e[e.Rotate90=Math.PI/2]="Rotate90",e[e.Rotate180=Math.PI]="Rotate180",e[e.Rotate270=1.5*Math.PI]="Rotate270",e))(qn||{}),$c=new M(1,0,0),Ms=new M(0,1,0),Pi=new M(0,0,1),CC=class{constructor(e){this.name="ViewCube",this.viewCubeFaces={right:{text:"\u53f3",name:"RightFace",position:new M(50,0,0),rotation:{axis:Ms,rad:qn.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new M(-50,0,0),rotation:{axis:Ms,rad:qn.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new M(0,50,0),rotation:{axis:$c,rad:qn.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new M(0,-50,0),rotation:{axis:$c,rad:qn.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new M(0,0,50),rotation:{axis:Ms,rad:0}},back:{text:"\u540e",name:"BackFace",position:new M(0,0,-50),rotation:{axis:Ms,rad:qn.Rotate180}}},this.AXIS_LENGTH=130,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255,this.FACE_BACKGROUND_COLOR=16777215,this.FACE_HOVER_BACKGROUND_COLOR=8618481,this.EDGE_COLOUR=13290452,this.EDGE_OPACITY=.1,this.EDGE_SIZE=new Q(70,12),this.CORNER_WIDTH=12,this.CORNER_COLOR=13290452,this.CORNER_OPACITY=1,this.faces=[],this.onPointerDown=e=>{let t=this.plugin.getNdcPointByPointerEvent(e);if(!t)return;let n=this.plugin.getIntersects(t);if(this.lastCoords=t,!n||0===n.length)return;let i,r=n[0].object.name;if(r){switch(r){case"TopFace":i=new M(0,1,0);break;case"BottomFace":i=new M(0,-1,0);break;case"FrontFace":i=new M(0,0,1);break;case"BackFace":i=new M(0,0,-1);break;case"LeftFace":i=new M(-1,0,0);break;case"RightFace":i=new M(1,0,0);break;case"TopFrontEdge":i=new M(0,1,1);break;case"TopRightEdge":i=new M(1,1,0);break;case"TopBackEdge":i=new M(0,1,-1);break;case"TopLeftEdge":i=new M(-1,1,0);break;case"BottomFrontEdge":i=new M(0,-1,1);break;case"BottomRightEdge":i=new M(1,-1,0);break;case"BottomBackEdge":i=new M(0,-1,-1);break;case"BottomLeftEdge":i=new M(-1,-1,0);break;case"FrontLeftEdge":i=new M(-1,0,1);break;case"FrontRightEdge":i=new M(1,0,1);break;case"BackRightEdge":i=new M(1,0,-1);break;case"BackLeftEdge":i=new M(-1,0,-1);break;case"TopFrontLeftCorner":i=new M(-1,1,1);break;case"TopFrontRightCorner":i=new M(1,1,1);break;case"TopBackRightCorner":i=new M(1,1,-1);break;case"TopBackLeftCorner":i=new M(-1,1,-1);break;case"BottomFrontLeftCorner":i=new M(-1,-1,1);break;case"BottomFrontRightCorner":i=new M(1,-1,1);break;case"BottomBackRightCorner":i=new M(1,-1,-1);break;case"BottomBackLeftCorner":i=new M(-1,-1,-1)}i&&this.updateHostViewerCamera(i)}},this.onPointerMove=e=>{let t=this.plugin.getNdcPointByPointerEvent(e);t&&(this.updateActivateMaterial(t),this.lastCoords=t)},this.onPointerleave=()=>{this.lastCoords=void 0,this.activateMeshName&&(this.activateMeshName=void 0)},this.cfg=e,this.showAxes=e.showAxes||!1,this.lineColor=e.lineColor||9343125,this.plugin=new RC(this.cfg),this.plugin.update=this.update.bind(this),this.init(),this.initEvent()}init(){var e;this.group=new Nt,this.group.name="ViewCube",this.showAxes&&this.group.add(this.createAxes()),this.group.add(this.createViewCubeFaces()),this.group.add(this.createViewCubeEdges()),this.group.add(this.createViewCubeCorners()),null==(e=this.plugin.scene)||e.add(this.group);let t=(new lt).setFromObject(this.group);this.plugin.zoomToBbox(t)}createAxes(){let e=new Tt,t=new M(-50,-50,-50),n=new M(1,0,0),i=new M(0,1,0),r=new M(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new Rl(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new Rl(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new Rl(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new Tt,t=[],n=new Pt({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(this.viewCubeFaces).forEach((e=>{let i=this.viewCubeFaces[e],r=new AC({text:i.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new Pt({map:r,opacity:1,transparent:!0});t.push(a);let s=this.createViewCubeFace(i.name,n,i.position,i.rotation);s.layers.enableAll(),s.userData={textTexture:r,tick:0,translateTick:0},this.faces.push(s)})),e.add(...this.faces);let i=new Qi(76,76,76),r=new Ge(i,t);this.innerViewCubeMesh=r,e.add(r);let a=new ja(new Qi(100,100,100)),s=new Pt({color:this.lineColor}),o=new Dn(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,n,i){let r=new Ur(76,76),a=new Ge(r,t);return a.name=e,a.rotateOnAxis(i.axis,i.rad),a.position.copy(n),a}createViewCubeEdges(){let e=new Tt,t=this.createEdge("TopFrontEdge",new M(0,51,51),[{axis:Pi,rad:qn.Rotate180}]),n=this.createEdge("TopRightEdge",new M(51,51,0),[{axis:$c,rad:qn.Rotate180},{axis:Ms,rad:qn.Rotate90},{axis:Pi,rad:0}]),i=this.createEdge("TopBackEdge",new M(0,51,-51),[{axis:Pi,rad:qn.Rotate180},{axis:Ms,rad:qn.Rotate180}]),r=this.createEdge("TopLeftEdge",new M(-51,51,0),[{axis:$c,rad:qn.Rotate90},{axis:Ms,rad:qn.Rotate180},{axis:Pi,rad:qn.Rotate90}]),a=this.createEdge("BottomFrontEdge",new M(0,-51,51),[{axis:Pi,rad:0}]),s=this.createEdge("BottomRightEdge",new M(51,-51,0),[{axis:$c,rad:qn.Rotate90},{axis:Ms,rad:0},{axis:Pi,rad:qn.Rotate90}]),o=this.createEdge("BottomBackEdge",new M(0,-51,-51),[{axis:Pi,rad:0},{axis:Ms,rad:qn.Rotate180}]),l=this.createEdge("BottomLeftEdge",new M(-51,-51,0),[{axis:$c,rad:qn.Rotate90},{axis:Ms,rad:qn.Rotate270},{axis:Pi,rad:qn.Rotate90}]),h=this.createEdge("FrontRightEdge",new M(51,0,51),[{axis:Pi,rad:qn.Rotate90}]),c=this.createEdge("BackRightEdge",new M(51,0,-51),[{axis:Pi,rad:qn.Rotate90},{axis:Ms,rad:qn.Rotate180}]),u=this.createEdge("BackLeftEdge",new M(-51,0,-51),[{axis:Pi,rad:qn.Rotate270},{axis:Ms,rad:qn.Rotate180}]),d=this.createEdge("FrontLeftEdge",new M(-51,0,51),[{axis:Pi,rad:qn.Rotate270}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e.add(h),e.add(c),e.add(u),e.add(d),e}createEdge(e,t,n){let i=new Tt,r=new Ur(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new Pt({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:1},o=new Ge(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new Ge(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new M(1,0,0),Math.PI/2),l.layers.enableAll(),i.add(o),i.add(l),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}createViewCubeCorners(){let e=new Tt,t=this.createCorner("TopFrontLeftCorner",new M(-51,51,51),[{axis:Pi,rad:qn.Rotate270}]),n=this.createCorner("TopFrontRightCorner",new M(51,51,51),[{axis:Pi,rad:qn.Rotate180}]),i=this.createCorner("TopBackRightCorner",new M(51,51,-51),[{axis:$c,rad:qn.Rotate90},{axis:Ms,rad:qn.Rotate180},{axis:Pi,rad:0}]),r=this.createCorner("TopBackLeftCorner",new M(-51,51,-51),[{axis:$c,rad:qn.Rotate90},{axis:Ms,rad:qn.Rotate180},{axis:Pi,rad:qn.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new M(-51,-51,51),[{axis:Pi,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new M(51,-51,51),[{axis:Pi,rad:qn.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new M(51,-51,-51),[{axis:$c,rad:0},{axis:Ms,rad:qn.Rotate180},{axis:Pi,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new M(-51,-51,-51),[{axis:$c,rad:0},{axis:Ms,rad:qn.Rotate180},{axis:Pi,rad:qn.Rotate90}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e}createCorner(e,t,n){let i=new Tt,r=new Ur(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new Pt({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:1},o=new Ge(r,a);o.name=e,o.userData=s,o.position.set(this.CORNER_WIDTH/2,this.CORNER_WIDTH/2,0),o.layers.enableAll();let l=new Ge(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new M(1,0,0),Math.PI/2),l.layers.enableAll();let h=new Ge(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new M(0,1,0),-Math.PI/2),h.layers.enableAll(),i.add(o),i.add(l),i.add(h),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}updateActivateMaterial(e){let t=this.plugin.getIntersects(e);if(this.activateMeshName&&(this.activateMeshName=void 0),!t||0===t.length)return;let n=t[0].object;this.activateMeshName=n.name}initEvent(){this.plugin.container&&(this.plugin.container.addEventListener("pointerdown",this.onPointerDown),this.plugin.container.addEventListener("pointermove",this.onPointerMove),this.plugin.container.addEventListener("pointerleave",this.onPointerleave))}update(){var e;if(!this.hostViewer||!this.hostViewer.camera)return;let t=this.hostViewer.camera;if(t){let e=new M;t.getWorldDirection(e);let n=t.up;this.updateCameraDirection(e,n)}this.lastCoords&&this.updateActivateMaterial(this.lastCoords),null==(e=this.plugin.scene)||e.traverse((e=>{e instanceof Ge&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let n=Pk(this.FACE_BACKGROUND_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.updateConfig({backgroundColor:n}),t.redrew()}if(this.innerViewCubeMesh){this.updateMeshTick(e,"translateTick",5);let t=e.position.clone().normalize(),n=Math.max(2*e.userData.translateTick-5,0);t.multiplyScalar(3*n),n>0&&this.innerViewCubeMesh.position.copy(t)}}else if(e.name.indexOf("Edge")>-1){let t=e.material,n=Pk(this.EDGE_COLOUR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n),t.opacity=e.userData.tick}else if(e.name.indexOf("Corner")>-1){let t=e.material,n=Pk(this.CORNER_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n);let i=1+.3*e.userData.tick;e.parent&&e.parent.scale.set(i,i,i)}}updateMeshTick(e,t="tick",n=1){void 0!==e.userData[t]&&(e.name===this.activateMeshName&&e.userData[t]<n?e.userData[t]+=.05:e.name!==this.activateMeshName&&e.userData[t]>0&&(e.userData[t]-=.05),e.userData[t]=Math.min(Math.max(e.userData[t],0),n))}updateHostViewerCamera(e){var t,n;if(null==(t=this.hostViewer)||!t.camera||null==(n=this.hostViewer)||!n.controls)return;e.normalize();let i=this.hostViewer.controls instanceof ba?this.hostViewer.getBBox().getCenter(new M):this.hostViewer.controls.target,r=this.hostViewer.camera.position.distanceTo(i);this.hostViewer.flyTo(i.clone().add(e.clone().multiplyScalar(r)),i)}updateCameraDirection(e,t){this.plugin.camera&&e&&(e.normalize(),this.plugin.camera.position.set(200*-e.x+0,200*-e.y+0,200*-e.z+0),this.plugin.camera.lookAt(0,0,0),this.plugin.camera.up=t,this.plugin.camera.updateMatrixWorld())}setHostViewer(e){this.hostViewer=e}destroy(){var e,t,n;null==(e=this.plugin.container)||e.removeEventListener("pointerdown",this.onPointerDown),null==(t=this.plugin.container)||t.removeEventListener("pointermove",this.onPointerMove),null==(n=this.plugin.container)||n.removeEventListener("pointerleave",this.onPointerleave),this.plugin.destroy(),this.hostViewer=void 0,this.activateMeshName=void 0}},$fe=new M,Zfe=new hr,Kfe=class extends Hd{constructor(e,t){var n;super(e),this.name="BimViewer",this.timer=Date.now(),this.selectedObject=void 0,this.sceneBackgroundColor=new Ie(15463159),this.loadedModels={},this.loaded3dTiles={},this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new t0,this.clock=new Oo,this.renderEnabled=!0,this.isFrustumInsectChecking=!1,this.lastFrameExecuteTime=Date.now(),this.maxFps=60,this.settings=Ev,this.twoDModelCount=0,this.bbox=new lt,this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onKeyDown=e=>{let t=this.camera,n=this.controls;if(!t||!n)return;let i=this.settings.keyboard.sensitivity||3,r=n.getPosition(new M),a=n.getTarget(new M),s=a.clone();if("ArrowLeft"===e.code||"ArrowRight"===e.code){let t=Math.PI*i/180;"ArrowLeft"===e.code&&(t=-t),s.x=(a.x-r.x)*Math.cos(t)-(a.z-r.z)*Math.sin(t)+r.x,s.z=(a.z-r.z)*Math.cos(t)+(a.x-r.x)*Math.sin(t)+r.z,n.setTarget(s.x,s.y,s.z)}else if("ArrowUp"===e.code||"ArrowDown"===e.code){let t=Math.PI*i/180,o=new M(a.x-r.x,a.y-r.y,a.z-r.z).length(),l=a.y-r.y;"ArrowDown"===e.code&&(t=-t);let h=Math.asin(l/o)+t;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;s.y=a.y+(c-l),n.setTarget(s.x,s.y,s.z)}else if("KeyW"===e.code){let e=.01*i,s=r.distanceTo(a);if(s<10*t.near){let e=n.getTarget(new M).lerp(r,-t.near/s);n.setTarget(e.x,e.y,e.z)}r.lerp(a,e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z)}else if("KeyS"===e.code){let e=.01*i;r.lerp(a,-e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z,!1)}else if("KeyF"===e.code)this.flyToSelectedObject();else if("KeyT"===e.code){this.raycaster&&this.raycaster.layers.set(10);let e=this.getIntersections();if(e.length>0){let i=e.find((e=>{let t=e.object;return t.visible&&t instanceof Ge}));if(i&&i.point&&this.camera&&this.controls){let e=this.camera.position,r=i.point,a=n.getTarget(new M),s=e.distanceTo(r);if(s>t.near&&s<t.far){let t=e.distanceTo(a),i=e.clone().lerp(a,s/t);n.setTarget(i.x,i.y,i.z)}}}}else"KeyY"===e.code&&this.flyTo(r,a.clone().setY(r.y));this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1,this.composerRenderEnabled=!0}),e))},this.applyOptionsAndAddToScene=(e,t,n)=>{$.info(`[BimViewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let i=n.src&&n.src.toLowerCase();if(i&&i.endsWith("dxf")&&this.twoDModelCount++,n.matrix&&16===n.matrix.length){let e=new Ae;e.elements=n.matrix,t.applyMatrix4(e)}else{let e=n.position||[0,0,0],i=n.rotation||[0,0,0],r=n.scale||[1,1,1];t.position.set(e[0],e[1],e[2]),t.rotation.set(i[0]*Math.PI/180,i[1]*Math.PI/180,i[2]*Math.PI/180),t.scale.set(r[0],r[1],r[2])}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())}));let r=n.instantiate,a=n.merge;r?setTimeout((()=>{this.instantiate(t),setTimeout((()=>{a&&this.merge(t),this.addLoadedModelToScene(t,n)}),0)}),0):a?setTimeout((()=>{this.merge(t),setTimeout((()=>this.addLoadedModelToScene(t,n)),0)}),0):this.addLoadedModelToScene(t,n)},this.onAnchorPointerDown=e=>{var t,n;null==(t=this.controls)||!t.enableRotate||!this.renderer||null!=(n=this.sectionManager)&&n.isSectionActive()||this.setOrbitPoint(e)},this.onAnchorPointerUp=()=>{this.anchor&&(this.anchor.className="anchor"),!this.viewerContainer||!this.camera||this.controls},this.viewerCfg=yn(yn({},Xde),e),$.info("[BimViewer]","viewerCfg:",this.viewerCfg),this.settings=Ev,this.cameraCfg=t,this.cameraCfg&&this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg&&this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.increaseJobCount(),this.init(),this.animate(),this.renderer&&(null==(n=this.viewerContainer)||n.append(this.renderer.domElement)),this.decreaseJobCount(),$.info(`[BimViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),tn.isBrowser&&!e.context&&this.initDom(),this.initEvents(),this.initControls()}initThree(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableDatGui&&this.initDatGui(),this.initOthers(),!0===e.enableAxisGizmo&&(this.axes=this.initAxes()),!0===e.enableStats&&(this.stats=this.initStats()),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&(this.bottomBar=this.initBottomBar()),e.enableNavCube&&(this.navCube=this.initNavCube()),e.enableViewCube&&(this.viewCube=this.initViewCube()),e.enableContextMenu&&(this.contextMenu=this.initContextMenu())}initScene(){this.scene=new ii,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=St,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Kg,it.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new Hu(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new $t(this)),this.setEnvironmentFromDataArray()}initCSS2DRenderer(){var e;let t=new Rc;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){this.scene&&(this.perspectiveCamera=new bn(45,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.perspectiveCamera.position.set(0,100,0),this.scene.add(this.perspectiveCamera),this.camera=this.perspectiveCamera)}initControls(e=!1){if(!this.renderer)return;tn.printDeviceInfo();let t,n=e?this.orthoCamera:this.perspectiveCamera;n&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new ba(n,this.inputManager),t.dollySpeed=.1,t.dollyToCursor=!0,t.enabled=!0,t.keyTruckSpeed=10,t.restThreshold=0,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.listenToKeyEvents(),t.update(0)),t&&(e?(this.orthoCameraConrols=t,t.minZoom=3):(this.perspectiveCameraControls=t,this.bbox&&(t.minDistance=.1,t.maxDistance=3*this.bbox.getSize(new M).length())),this.controls=t))}initRotateToCursor(){this.anchor=this.createAnchor()}initLights(){if(!this.scene)return;let e=16777215,t=new ji(e,1.5);t.name="sun",t.castShadow=!0,t.position.set(-2,2,4),t.shadow.autoUpdate=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.directionalLight=t,this.scene.add(t),this.scene.add(t.target),this.directionalLightHelper=new oy(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new ly(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new Lo(3158064),this.hemisphereLight=new ad(e,14540253,.2),this.hemisphereLight.position.set(0,300,0),this.scene.add(this.ambientLight),this.scene.add(this.hemisphereLight)}initEvents(){if(!this.renderer)return;let e=new Rp(this.renderer.domElement);this.inputManager=e;let t,n=!1,i=!1;e.addEventListener("pointerdown",(e=>{i=!1,n=!0,0===e.button&&this.onAnchorPointerDown(e)})),e.addEventListener("pointermove",(()=>{n&&(i=!0)})),e.addEventListener("pointerup",(()=>{n=!1,this.onAnchorPointerUp()})),e.addEventListener("click",(e=>{var n;i?i=!1:(t&&clearTimeout(t),t=setTimeout((()=>{0===e.button&&this.handleMouseClick(e)}),300),(!this.selectedObject||this.selectedObject&&this.selectedObject instanceof Tt)&&(null==(n=this.contextMenu)||n.hide()))})),e.addEventListener("dblclick",(e=>{var n,r;!i&&null!=(n=this.sectionManager)&&n.isSectionActive()&&null!=(r=this.measurementManager)&&r.isMeasurementActive()||(t&&clearTimeout(t),this.handleMouseClick(e),this.flyToSelectedObject(),this.enableRender())})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),e.addEventListener("contextmenu",(e=>{var t,n;i||null!=(t=this.sectionManager)&&t.isSectionActive()||null!=(n=this.measurementManager)&&n.isMeasurementActive()||this.handleRightClick(e)})),this.initRotateToCursor(),this.raycaster=new Gs}initDatGui(){this.datGui=new MC(this),this.datGui.close()}initOthers(){if(!this.scene||!this.renderer||!this.camera)return;let e=this.datGui&&this.datGui.controls;e&&(e.showGroundGrid&&(this.groundGrid=vs.createGroundGrid(),this.scene.add(this.groundGrid)),e.showGrassGround&&$e(this,null,(function*(){this.grassGround=yield vs.createGrassGround(),this.scene&&this.scene.add(this.grassGround),this.enableRender()})),e.webcam&&this.enableWebCam(),this.composerEnabled=e.composerEnabled,this.composerEnabled&&(this.enableComposer(!0),this.enableRenderPass(e.renderPassEnabled),this.enableFxaaPass(e.fxaaEnabled),this.enableSaoPass(e.saoEnabled),this.enableSsaoPass(e.ssaoEnabled),this.enableOutlinePass(e.outlineEnabled),this.enableSsaaPass(e.ssaaEnabled),this.enableBloomPass(e.bloomEnabled),this.enableUnrealBloomPass(e.unrealBloomEnabled))),this.renderer.domElement.style.outlineWidth="0"}initNavCube(){var e;let t=document.createElement("div");t.id="navCube";let n=new GA;return n.renderer&&(t.appendChild(n.renderer.domElement),n.setHostViewer(this)),null==(e=this.widgetContainer)||e.appendChild(t),n}initViewCube(){var e;let t=document.createElement("div");t.id="viewCube",null==(e=this.widgetContainer)||e.appendChild(t);let n=new CC({containerId:t.id});return n.setHostViewer(this),n}initAxes(){var e,t;let n=document.createElement("div");n.classList.add("axesRenderer");let i=new vd(n,this.camera);return null==(e=this.widgetContainer)||e.append(n),this.axesInScene=new yv(!1),null==(t=this.scene)||t.add(this.axesInScene),i}initStats(){var e;let t=new OA;t.setMode(0);let n=document.createElement("div");return n.classList.add("statsOutput"),n.appendChild(t.domElement),null==(e=this.widgetContainer)||e.append(n),t}initContextMenu(){let e=new NA({items:Kde,context:{bimViewer:this,toolbar:this.toolbar,section:this.section},container:this.widgetContainer});return window.oncontextmenu=e=>e.preventDefault(),e}initToolbar(){let e=this.viewerCfg;return new Gc(this,(0,jd.merge)({},qde,e.toolbarMenuConfig))}initBottomBar(){return new kd(this)}get has2dModel(){return this.twoDModelCount>0}showContextMenu(e){if(!this.contextMenu||!this.widgetContainer)return;this.raycaster&&this.raycaster.layers.set(10);let t=this.getAllIntersections(e);$.debug("[BimViewer] showContextMenu intersections = ",t);let n,i=(0,jd.find)(t,(e=>{let t=e.object;return t instanceof Ge&&t.visible})),r=this.contextMenu.context,a=null==i?void 0:i.instanceId,s=null==i?void 0:i.faceIndex;s&&(n=gr.getBatchIdByFaceIndex(null==i?void 0:i.object,s)),this.contextMenu.context=Qr(yn({},r),{hit:null==i?void 0:i.object,instanceId:a,batchId:n});let{x:o,y:l}=e;this.contextMenu.show(o,l)}handleRightClick(e){this.showContextMenu(e)}sycnCameraPosition(e,t){let n=e.position;if(t.position.set(n.x,n.y,n.z),this.scene){let e=this.scene.position;t.lookAt(e)}}sycnControls(e,t){let n=e.getTarget(new M),i=e.getPosition(new M);t.setPosition(i.x,i.y,i.z),t.setTarget(n.x,n.y,n.z)}setToOrthographicCamera(e=!1){var t;if(!this.scene||!this.controls)return;let n=this.perspectiveCamera,i=this.perspectiveCameraControls,r=this.orthoCamera,a=this.orthoCameraConrols;e?(r||(r=new dr(-this.width/2,this.width/2,this.height/2,-this.height/2,this.settings.camera.near,this.settings.camera.far),r.position.set(0,100,0),r.zoom=10,r.updateProjectionMatrix(),this.scene&&this.scene.add(r),this.orthoCamera=r),a||(this.initControls(!0),a=this.orthoCameraConrols),n&&(this.sycnCameraPosition(n,r),r.zoom=10,r.updateProjectionMatrix()),i&&a&&n&&this.sycnControls(i,a),this.camera=r,this.controls=a):(n&&r&&this.sycnCameraPosition(r,n),i&&a&&r&&this.sycnControls(a,i),this.camera=n,this.controls=i),null==(t=this.axes)||t.setHostCamera(this.camera),this.resize(this.width,this.height),this.dispatchEvent("CameraChanged")}animate(){var e,t,n,i;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this));let r=this.clock.getDelta(),a=this.controls&&this.controls.update(r);if(this.maxFps>0){if(Date.now()-this.lastFrameExecuteTime<1e3/this.maxFps)return;this.lastFrameExecuteTime=Date.now()}if(this.webcam&&this.webcam.animate(),this.scene&&this.camera){if(this.viewerContainer&&this.viewerContainer.parentElement){let{width:e,height:t}=this.viewerContainer.parentElement.getBoundingClientRect();(this.width!==e||this.height!==t)&&this.resize(e,t)}(this.renderEnabled||a)&&(this.update3dTiles(),null==(e=this.renderer)||e.render(this.scene,this.camera),this.hotpointRoot&&this.hotpointRoot.children.length>0&&(null==(t=this.css2dRenderer)||t.render(this.scene,this.camera)),this.dispatchEvent("AfterRender"))}this.composerRenderEnabled&&this.composer&&this.composerEnabled&&(this.composer.render(),this.composerRenderEnabled=!1),this.frustrumCullingByModelBBox(),null==(n=this.stats)||n.update(),null==(i=this.bottomBar)||i.update()}update3dTiles(){if(!this.camera)return;let e=Object.values(this.loaded3dTiles);0!==e.length&&(this.camera.updateMatrixWorld(),e.forEach((e=>{e.renderer.update()})))}frustrumCullingByModelBBox(){let e=new ps,t=new Ae;this.isFrustumInsectChecking=!0,this.camera&&(t.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),e.setFromProjectionMatrix(t),Object.values(this.loadedModels).forEach((t=>{let n=this.scene&&this.scene.getObjectById(t.id),i=t.bbox;n&&i&&this.scene&&(void 0===n.userData._visible&&(n.userData._visible=!0,Object.defineProperties(n,{visible:{set:e=>{n.userData._visible=e,this.isFrustumInsectChecking||(n.userData.userConfigVisibility=!0)},get:()=>n.userData._visible}})),void 0===n.userData.userConfigVisibility&&(n.visible=e.intersectsBox(i)))})),Object.values(this.loaded3dTiles).forEach((t=>{let n=t.renderer.group;n&&!t.bbox.isEmpty()&&this.scene&&(void 0===n.userData._visible&&(n.userData._visible=!0,Object.defineProperties(n,{visible:{set:e=>{n.userData._visible=e,this.isFrustumInsectChecking||(n.userData.userConfigVisibility=!0)},get:()=>n.userData._visible}})),void 0===n.userData.userConfigVisibility&&(n.visible=e.intersectsBox(t.bbox)))}))),this.isFrustumInsectChecking=!1}destroy(){var e,t,n,i,r;null==(e=this.inputManager)||e.removeEventListener(),this.datGui&&this.datGui.gui&&(this.datGui.beforeDestroy(),this.datGui=void 0);let a=this.webcamPlane;this.scene&&a&&(this.scene.remove(a),a.geometry.dispose(),a.material.dispose(),this.webcamPlane=void 0),this.webcam=void 0,this.composer=void 0,this.renderPass=void 0,this.effectFxaaPass=void 0,this.saoPass=void 0,this.ssaoPass=void 0,this.outlinePass=void 0,this.ambientLight=void 0,this.directionalLight=void 0,this.hemisphereLight=void 0,this.directionalLightHelper&&(this.directionalLightHelper.dispose(),this.directionalLightHelper=void 0),this.controls&&(this.disposeRotateToCursor(),this.controls.dispose(),this.controls=void 0),this.perspectiveCameraControls&&(this.perspectiveCameraControls.dispose(),this.perspectiveCameraControls=void 0),this.shadowCameraHelper&&(this.shadowCameraHelper.dispose(),this.shadowCameraHelper=void 0),this.css2dRenderer&&(null==(t=this.viewerContainer)||t.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.stats=void 0,this.raycaster=void 0,this.selectedObject=void 0,this.groundGrid&&(this.groundGrid.geometry.dispose(),this.groundGrid.material.dispose(),this.groundGrid.clear(),this.groundGrid=void 0),this.grassGround&&(this.grassGround.geometry.dispose(),this.grassGround.material.dispose(),this.grassGround.clear(),this.grassGround=void 0),this.skyOfGradientRamp&&(this.skyOfGradientRamp.geometry.dispose(),this.skyOfGradientRamp.material.dispose(),this.skyOfGradientRamp.clear(),this.skyOfGradientRamp=void 0),this.savedMaterialsForOpacity=void 0,this.section=void 0,this.sectionType=void 0,Object.keys(this.loadedModels).forEach((e=>{delete this.loadedModels[e]})),Object.values(this.loaded3dTiles).forEach((e=>{e.renderer.dispose()})),this.loaded3dTiles={},this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),this.contextMenu&&(this.contextMenu.destroy(),this.contextMenu=void 0),this.navCube&&(this.navCube.dispose(),this.navCube=void 0),this.viewCube&&(this.viewCube.destroy(),this.viewCube=void 0),this.axes&&(this.axes.dispose(),this.axes=void 0),this.axesInScene&&(this.axesInScene.clear(),this.axesInScene=void 0),this.toolbar&&(this.toolbar.destroy(),this.toolbar=void 0),this.font=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(n=this.measurementManager)||n.destroy(),this.measurementManager=void 0,null==(i=this.zoomToRectHelper)||i.destroy(),this.zoomToRectHelper=void 0,null==(r=this.sectionManager)||r.destroy(),this.sectionManager=void 0,super.destroy()}loadLocalModel(e,t,n,i){return $e(this,null,(function*(){this.timer=Date.now(),this.increaseJobCount();try{let r=new Ks(n);this.font&&r.setFont(this.font);let a=yield r.loadLocalModel(e,t.src,i);if(a)return this.applyOptionsAndAddToScene(e,a,t),Promise.resolve()}catch(e){let i=`Error loading ${t.src}`;return $.error(i,e),Promise.reject(i)}finally{this.decreaseJobCount()}return Promise.reject()}))}loadModel(e,t){return $e(this,null,(function*(){this.timer=Date.now(),this.increaseJobCount();try{let n=new Ks;this.font&&n.setFont(this.font);let i=yield n.loadModel(e.src,e.fileFormat,t);if(i)return this.applyOptionsAndAddToScene(e.src,i,e),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return $.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount()}return Promise.reject()}))}load3dTiles(e){return $e(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let n=new nb(e.src),i=new lt,r=yield new Promise(((t,r)=>{n.onLoadTileSet=()=>{n.getBounds(i)||(n.getBoundingSphere(Zfe)?Zfe.getBoundingBox(i):($.warn(`[BimViewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),$.debug(i),n.onLoadTileSet=null;let a=n.group;$.debug(a),t(a)},n.onLoadModel=e=>{e.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix()),e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0),e.geometry&&e.layers.enableAll()})),e.updateWorldMatrix(!1,!0),this.updateDirectionalLightShadow(),this.enableRender()},n.setCamera(this.camera),n.setResolutionFromRenderer(this.camera,this.renderer),n.update()}));if(r){let a=Date.now(),s=e.modelId||e.src;if(this.loaded3dTiles[s]){let e=1;for(;this.loaded3dTiles[`${s}_${e}`];)e++;s=`${s}_${e}`,$.warn(`[BimViewer] 3dTiles '${s}' is loaded more than once!`)}if(this.loaded3dTiles[s]={id:r.id,bbox:i,renderer:n},e.matrix&&16===e.matrix.length){let t=new Ae;t.elements=e.matrix,r.applyMatrix4(t)}else{let t=e.position||[0,0,0],n=e.rotation||[0,0,0],i=e.scale||[1,1,1];r.position.set(t[0],t[1],t[2]),r.rotation.set(n[0]*Math.PI/180,n[1]*Math.PI/180,n[2]*Math.PI/180),r.scale.set(i[0],i[1],i[2])}if(r.matrixAutoUpdate=!1,r.updateMatrix(),r.updateMatrixWorld(!0),null==(t=this.scene)||t.add(r),i.applyMatrix4(r.matrix),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),0===Object.keys(this.loadedModels).length&&1===Object.keys(this.loaded3dTiles).length){let e=this.datGui&&this.datGui.controls;this.regenSkyOfGradientRamp(),e&&e.showGroundGrid&&this.regenGroundGrid(),this.tryAdjustCameraNearAndFar(),this.goToHomeView()}return $.info(`[BimViewer] Added 3dTiles '${e.src}' to scene in ${(Date.now()-a)/1e3}s`),this.enableRender(),this.decreaseJobCount(),Promise.resolve()}return this.decreaseJobCount(),Promise.reject()}))}setFont(e){return $e(this,null,(function*(){let t=Date.now();no.isShxFile(e[0])?this.font=yield(new no).loadAsync(e):(e.length>1&&$.warn("[BimViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new Uc).loadAsync(e[0])),$.info(`[BimViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){Ks.setDracoDecoderPath(e)}addLoadedModelToScene(e,t){if(!this.scene)return;if(t.merge){let t=Date.now();Bd.createMeshBvhAsync([e],{saveOriginalIndex:!0}),$.info(`[BimViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0),e.geometry&&e.layers.enableAll()})),this.scene.add(e);let n=(new lt).setFromObject(e),i=t.modelId||t.src;if(this.loadedModels[i]){let e=1;for(;this.loadedModels[`${i}_${e}`];)e++;i=`${i}_${e}`,$.warn(`[BimViewer] Model '${i}' is loaded more than once!`)}this.loadedModels[i]={id:e.id,bbox:n},this.computeBoundingBox(),this.tryAdjustDirectionalLight();let r=Object.values(this.loadedModels).map((e=>e.id));if(Object.values(this.loaded3dTiles).forEach((e=>r.push(e.id))),!r||r.length<=1){if(this.has2dModel)this.setToOrthographicCamera(!0),this.skyOfGradientRamp&&this.scene.remove(this.skyOfGradientRamp);else{let e=this.datGui&&this.datGui.controls;this.regenSkyOfGradientRamp(),e&&e.showGroundGrid&&this.regenGroundGrid()}this.tryAdjustCameraNearAndFar(),this.goToHomeView()}t.edges&&cn.addOutlines(e),$.info(`[BimViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.enableRender(),this.dispatchEvent("ModelLoaded")}addOrRemoveObjectOpacity(e=!0,t=.3,n,i){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[],s=Object.values(this.loadedModels).map((e=>e.id));Object.values(this.loaded3dTiles).forEach((e=>s.push(e.id))),s.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&cn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=cn.setObjectOpacityById(r,s,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&cn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[],this.enableRender()}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}showVertexNormals(e,t=.1){var n,i,r;e?(this.vertexNormalsHelpers||(this.vertexNormalsHelpers=new Nt),null==(n=this.scene)||n.traverseVisible((e=>{var n;if(e instanceof Ge&&!["SKYBOX","GROUND_GRID","GRASS_GROUND","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let i=new fC(e,t,16711680);null==(n=this.vertexNormalsHelpers)||n.add(i)}})),null==(i=this.scene)||i.add(this.vertexNormalsHelpers)):this.vertexNormalsHelpers&&(null==(r=this.scene)||r.remove(this.vertexNormalsHelpers),this.vertexNormalsHelpers=void 0)}resize(e,t){let n=this.camera;n&&(this.width=e||window.innerWidth,this.height=t||window.innerHeight,n instanceof bn?n.aspect=this.width/this.height:n instanceof dr&&(n.left=-this.width/2,n.right=this.width/2,n.top=this.height/2,n.bottom=-this.height/2),n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(this.width,this.height),this.composer&&this.composer.setSize(this.width,this.height),this.effectFxaaPass&&this.effectFxaaPass.uniforms.resolution.value.set(1/this.width,1/this.height),this.overlayRender&&this.overlayRender.setSize(this.width,this.height)),this.width=e,this.height=t,this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjectsByMouse(e){let t=[];if(!(this.raycaster&&this.camera&&this.scene&&e&&this.viewerContainer))return t;let n=new Q(e.x,e.y),i=nn.screenPoint2NdcPoint(n,this.camera,this.viewerContainer);return this.camera.updateMatrixWorld(),this.raycaster.setFromCamera(i,this.camera),t=this.getRaycastableObjects(),t}getRaycastableObjects(){let e=[];return Object.values(this.loadedModels).forEach((t=>{let n=this.scene&&this.scene.getObjectById(t.id);n&&n.visible&&e.push(n)})),Object.values(this.loaded3dTiles).forEach((t=>{let n=this.scene&&this.scene.getObjectById(t.id);n&&n.visible&&e.push(n)})),e}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e),n=this.raycaster&&this.raycaster.intersectObjects(t,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(n=n.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),n}getAllIntersections(e){if(!(this.raycaster&&this.camera&&this.scene&&this.viewerContainer))return[];let t=new Q(null==e?void 0:e.x,null==e?void 0:e.y),n=nn.screenPoint2NdcPoint(t,this.camera,this.viewerContainer);this.raycaster.setFromCamera(n,this.camera);let i=this.scene.children,r=this.raycaster.intersectObjects(i,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(r=r.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),r}handleMouseClick(e){var t,n,i;if(null!=(t=this.measurementManager)&&t.isMeasurementActive()||null!=(n=this.sectionManager)&&n.isSectionActive())return;let r=Date.now();this.raycaster&&this.raycaster.layers.set(12);let a=this.getIntersections(e);$.debug(`[BimViewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&(!1!==t.userData.selectable||t instanceof Ge)})),h=l&&l.object||void 0;if(h)if(h instanceof Ar)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(gr.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=gr.getBatchIdByFaceIndex(h,e),this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.batchId===o&&(h=void 0)):h=void 0}else this.selectedObject&&this.selectedObject.id===h.id&&(h=void 0);if(a.length>0&&a[0].point){let e=null==(i=this.overlayRender)?void 0:i.getDrawablesByPosition(a[0].point,this.raycaster);e&&e.length>0&&(h=e[0])}this.selectedObject&&this.clearSelection(),h?this.selectObject(h,s,o):this.clearSelection()}selectObject(e,t,n,i=void 0){if(e instanceof ns)return this.selectedObject=e,this.selectedObject.selected=!0,void this.enableRender();if(this.selectedObject){let t=this.selectedObject.userData;if(null!=t.instanceId&&t.originalMatrix&&t.clonedMesh){this.scene&&this.scene.remove(t.clonedMesh);let n=this.selectedObject;if(n.setMatrixAt(t.instanceId,t.originalMatrix),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),delete t.instanceId,delete t.originalMatrix,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(null!=t.batchId&&t.clonedMesh){if(this.scene&&this.scene.remove(t.clonedMesh),delete t.batchId,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(t.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof Rn&&e.dispose()}this.selectedObject.material=t.originalMaterial,delete t.originalMaterial}this.selectedObject=void 0,this.outlinePass&&(this.outlinePass.selectedObjects=[])}if(this.scene&&e){if(e instanceof Ar&&null!=t){let n=e,r=new Ae,a=new Ae;a.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n.getMatrixAt(t,r),this.selectedObject=e,this.outlinePass&&(this.outlinePass.selectedObjects=[e]);let s=yi.clonedHighlightMaterials(e,{depthTest:i});if(s){let i=new Ge(n.geometry.clone(),s);i.applyMatrix4(e.matrixWorld.multiply(r)),i.matrixWorldNeedsUpdate=!0,i.name="Cloned mesh for highlighting",i.layers.enableAll();let o=r.clone();o.multiplyMatrices(r,a),n.setMatrixAt(t,o),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),this.selectedObject.userData.instanceId=t,this.selectedObject.userData.originalMatrix=r,this.selectedObject.userData.clonedMesh=i,this.scene.add(i)}}else if(gr.isMergedMesh(e)&&null!=n){let t=gr.getBatchByBatchId(e,n),r=`[BimViewer] Clicked on merged mesh(id: ${e.id}).`;r+=` Original mesh batchId: ${n}, name: ${null==t?void 0:t.name}`,$.info(r);let a=yi.clonedHighlightMaterials(e,{depthTest:i}),s=gr.cloneGeometryForBatch(e,t);if(a&&s){let t=new Ge(s,a);t.applyMatrix4(e.matrixWorld),t.matrixWorldNeedsUpdate=!0,t.name="Cloned mesh for highlighting",t.layers.enableAll(),this.selectedObject=e,this.selectedObject.userData.batchId=n,this.selectedObject.userData.clonedMesh=t,this.scene.add(t)}}else{let t=yi.clonedHighlightMaterials(e,{depthTest:i});t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t,this.outlinePass&&(this.outlinePass.selectedObjects=[e]))}this.enableRender()}else this.enableRender()}clearSelection(){this.selectedObject&&this.selectedObject instanceof ns?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new M,n=new M,i=new lt;e.forEach((e=>{let t=Fr.getBoundingBox(e);i.union(t)}));let r=new M;this.camera.getWorldDirection(r),Ws.getCameraPositionByBboxAndDirection(i,t,n,this.camera.projectionMatrix,r);let a=(new M).subVectors(t,n).length();if(this.controls.moveTo(t.x,t.y,t.z,!0),this.camera instanceof dr){let e=this.camera.right-this.camera.left,t=this.camera.top-this.camera.bottom,n=new M;i.getSize(n);let r=Math.min(e/n.x,t/n.y);this.controls.zoomTo(r,!0)}else this.camera instanceof bn&&this.controls.dollyTo(a,!0);this.controls.setFocalOffset(0,0,0,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Ar&&e.userData.clonedMesh||gr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,n;let i=Object.values(this.loadedModels).map((e=>e.id));Object.values(this.loaded3dTiles).forEach((e=>i.push(e.id)));let r=i.length;if(r<=0)return;let a=Math.floor(Math.random()*r),s=i[a];if(!(null==(e=this.scene)?void 0:e.getObjectById(s)))return;let o=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof Ge||e instanceof sn)&&!["SKYBOX","GROUND_GRID","GRASS_GROUND","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&o.push(e.id)})),o.length<1)return;let l=Math.floor(Math.random()*o.length),h=null==(n=this.scene)?void 0:n.getObjectById(o[l]);h&&($.info(`[BimViewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0,void 0,!0),this.flyToObject(h))}flyTo(e,t){let n=this.camera,i=this.controls;if(!n||!i)return;if(e.equals(t))return void $.error("[BimViewer] camera position and lookAt cannot be the same!");if(!it.isVectorValid(e)||!it.isVectorValid(t))return void $.error("[BimViewer] invalid position or lookAt!");let r=e.distanceTo(t);r<n.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*n.near),$.warn("[BimViewer] camera could be too close to see the object!")):r>n.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),$.warn("[BimViewer] camera could be too far to see the object!")),i.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!0)}viewFitAll(){var e;if(!this.scene||!this.camera)return;let t=new M,n=new M,i=Fr.getVisibleObjectBoundingBox(this.scene),r=new M;null==(e=this.camera)||e.getWorldDirection(r),Ws.getCameraPositionByBboxAndDirection(i,t,n,this.camera.projectionMatrix,r),this.flyTo(t,n)}goToHomeView(){let e=this.camera,t=this.cameraCfg,n=t&&it.arrayToVector3(t.eye),i=t&&it.arrayToVector3(t.look);if(n&&i)this.controls.setLookAt(n.x,n.y,n.z,i.x,i.y,i.z,!0),this.controls.setFocalOffset(0,0,0,!0);else if(this.scene){let t=new M,n=new M,i=new M(-1,-.5,-1);if(this.has2dModel){let e=this.bbox.max.x-this.bbox.min.x,t=this.bbox.max.y-this.bbox.min.y,n=this.bbox.max.z-this.bbox.min.z,r=Math.min(e,t,n);e-r<=0?i.set(1,0,0):t-r<=0?i.set(0,-1,0):n-r<=0&&i.set(0,0,-1)}if(Ws.getCameraPositionByBboxAndDirection(this.bbox,t,n,null==e?void 0:e.projectionMatrix,i),(!this.cameraCfg||this.cameraCfg&&(!this.cameraCfg.eye||!this.cameraCfg.look))&&(this.cameraCfg={eye:t.toArray(),look:n.toArray()}),e instanceof dr){let t=this.bbox,n=t.max.x-t.min.x,i=t.max.z-t.min.z,r=e.right-e.left,a=e.top-e.bottom;e.zoom=Math.max(r,a)/Math.max(n,i),e.zoom/=2,e.updateProjectionMatrix()}t.equals(n)||this.flyTo(t,n)}}zoomToBBox(e){var t,n;let i=new M,r=new M,a=new M;if(null==(t=this.camera)||t.getWorldDirection(a),Ws.getCameraPositionByBboxAndDirection(e,i,r,null==(n=this.camera)?void 0:n.projectionMatrix,a),!i.equals(r)){let t=(new M).subVectors(i,r).length();if(this.controls.moveTo(i.x,i.y,i.z,!0),this.camera instanceof dr){let t=this.camera.right-this.camera.left,n=this.camera.top-this.camera.bottom,i=new M;e.getSize(i);let r=Math.min(t/i.x,n/i.y);this.controls.zoomTo(r,!0)}else this.camera instanceof bn&&this.controls.dollyTo(t,!0);this.controls.setFocalOffset(0,0,0,!0)}}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||i<h){let t=e=>it.numberToString(e);$.info(`[BimViewer] BBox's longest side is: ${t(o)}`),n>l&&($.warn(`[BimViewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i<h&&($.warn(`[BimViewer] camera.far(${t(i)}) shouldn't smaller than ${t(h)}, will change it!`),e.far=h)}if(e instanceof dr){let t=e.right-e.left,n=e.top-e.bottom;e.zoom=Math.max(t,n)/Math.max(r,s),e.zoom/=2}e.updateProjectionMatrix()}tryAdjustDirectionalLight(){if(!this.directionalLight)return;let e=this.bbox,t=new hr;e.getBoundingSphere(t);let n=t.center,i=t.radius,r=this.directionalLight.shadow.camera;r.zoom=1,r.top=i,r.bottom=-i,r.right=i,r.left=-i,r.near=.1,r.far=2*i,r.updateProjectionMatrix();let a=new M(-1,-.5,1);a.normalize().multiplyScalar(i),this.directionalLight.position.copy(n).addScaledVector(a,-1),this.directionalLight.target.position.copy(n),$.debug("[BimViewer] this.directionalLight.position",this.directionalLight.position),$.debug("[BimViewer] this.directionalLight.target.position",this.directionalLight.target.position),this.updateDirectionalLight(),this.enableRender()}updateDirectionalLight(){var e,t;if(this.directionalLight&&(this.directionalLight.updateMatrixWorld(),this.directionalLight.target.updateMatrixWorld(),this.directionalLightHelper&&(this.directionalLightHelper.update(),!(null!=(e=this.scene)&&e.matrixAutoUpdate)&&this.directionalLightHelper.updateWorldMatrix(!1,!0)),this.directionalLight.shadow.needsUpdate=!0,this.directionalLight.shadow.camera.updateProjectionMatrix(),this.shadowCameraHelper&&(this.shadowCameraHelper.update(),null==(t=this.scene)||!t.matrixAutoUpdate))){let e=this.directionalLight.shadow.camera;e.position.setFromMatrixPosition(this.directionalLight.matrixWorld),$fe.setFromMatrixPosition(this.directionalLight.target.matrixWorld),e.lookAt($fe),e.updateMatrixWorld(),this.shadowCameraHelper.updateWorldMatrix(!1,!0)}}updateDirectionalLightShadow(){this.directionalLight&&(this.directionalLight.shadow.needsUpdate=!0)}showDirectionalLightHelper(e){this.directionalLightHelper&&(this.directionalLightHelper.visible=e),this.shadowCameraHelper&&(this.shadowCameraHelper.visible=e)}regenSkyOfGradientRamp(){if(!this.scene)return;this.skyOfGradientRamp&&(this.skyOfGradientRamp.geometry.dispose(),this.skyOfGradientRamp.material.dispose(),this.scene.remove(this.skyOfGradientRamp),this.skyOfGradientRamp.clear(),this.skyOfGradientRamp=void 0);let e=Object.values(this.loadedModels).map((e=>e.id));if(Object.values(this.loaded3dTiles).forEach((t=>e.push(t.id))),e){let t=this.cameraCfg,n=t&&it.arrayToVector3(t.eye),i=t&&it.arrayToVector3(t.look),r=new lt;if(n&&i){let e=n,t=i;r.expandByPoint(new M(e.x,e.y,e.z)),r.expandByPoint(new M(t.x,t.y,t.z))}else r=Fr.getObjectsBoundingBox(this.scene,e);this.skyOfGradientRamp=Ka.createSkyOfGradientRampByBoundingBox(r),this.scene.add(this.skyOfGradientRamp)}}regenGroundGrid(){if(!this.scene)return;this.groundGrid&&(this.groundGrid.geometry.dispose(),this.groundGrid.material.dispose(),this.scene.remove(this.groundGrid));let e=Object.values(this.loadedModels).map((e=>e.id));if(Object.values(this.loaded3dTiles).forEach((t=>e.push(t.id))),e){let e=this.cameraCfg,t=e&&it.arrayToVector3(e.look);t&&(t.y=0),this.groundGrid=vs.createGroundGrid(void 0,void 0,t),this.scene.add(this.groundGrid)}}setOrbitPoint(e){let t=this.controls;if(this.camera&&this.renderer&&this.controls&&this.scene&&this.raycaster&&this.viewerContainer)if(this.selectedObject&&this.selectedObject instanceof Tt){let e=(new lt).setFromObject(this.selectedObject),n=new M;e.getCenter(n),null==t||t.setOrbitPoint(n.x,n.y,n.z);let i=nn.worldPosition2ScreenPoint(n,this.camera,this.viewerContainer);this.setAnchorPosition(i)}else{this.raycaster&&this.raycaster.layers.set(10);let n=this.getIntersections(e),i=new Q(e.x,e.y);if(n&&0!==n.length){let e=n[0].point;null==t||t.setOrbitPoint(e.x,e.y,e.z),this.setAnchorPosition(i)}else{let e=this.bbox.getCenter(new M);t.setOrbitPoint(e.x,e.y,e.z);let n=nn.worldPosition2ScreenPoint(e,this.camera,this.renderer.domElement);this.setAnchorPosition(n)}}}setAnchorPosition(e){this.anchor&&(this.anchor.className="anchor active",this.anchor.style.left=`${e.x}px`,this.anchor.style.top=`${e.y}px`)}createAnchor(){var e;let t=document.createElement("div");return t.className="anchor",null==(e=this.viewerContainer)||e.appendChild(t),t}disposeAnchor(){var e;this.anchor&&(null==(e=this.viewerContainer)||e.removeChild(this.anchor),this.anchor=void 0)}disposeRotateToCursor(){this.disposeAnchor()}addHotpoint(e){var t;if(this.hasHotpoint(e.hotpointId))return void $.warn(`[BimViewer] Hotpoint with id '${e.hotpointId}' already exist!`);let n=e.anchorPosition,i=Ac.createHotpoint(e.html);i.position.set(n[0]||0,n[1]||0,n[2]||0),i.visible=!1!==e.visible,i.userData.hotpoint=e,this.hotpointRoot||(this.hotpointRoot=new Nt,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(i),i.updateWorldMatrix(!1,!1),this.enableRender()}removeHotpoint(e){var t,n;let i=(null==(t=this.hotpointRoot)?void 0:t.children)||[];for(let r=0;r<i.length;++r){let t=i[r];(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e&&t.removeFromParent()}}clearHotpoints(){var e;null==(e=this.hotpointRoot)||e.clear()}hasHotpoint(e){var t;return-1!==((null==(t=this.hotpointRoot)?void 0:t.children)||[]).findIndex((t=>{var n;return(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e}))}enableComposer(e){!this.scene||!this.camera||!this.renderer||(this.composerEnabled=e,e&&!this.composer&&(this.composer=new mC(this.renderer)),this.enableRender())}enableRenderPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.renderPass){let e=new gC(this.scene,this.camera);e.setSize(this.width,this.height),this.composer.addPass(e),this.renderPass=e}this.renderPass&&(this.renderPass.enabled=e),this.enableRender()}}enableFxaaPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.effectFxaaPass){let e=new v0(Sfe);e.uniforms.resolution.value.set(1/this.width,1/this.height),e.setSize(this.width,this.height),e.renderToScreen=!0,this.composer.addPass(e),this.effectFxaaPass=e}this.effectFxaaPass&&(this.effectFxaaPass.enabled=e),this.enableRender()}}enableSaoPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.saoPass){let e=new lb(this.scene,this.camera,!1,!0,new Q(1/this.width,1/this.height));e.setSize(this.width,this.height),e.params.output=0,e.params.saoBias=.5,e.params.saoIntensity=5e-5,e.params.saoScale=5,e.params.saoKernelRadius=40,e.params.saoMinResolution=0,this.composer.addPass(e),this.saoPass=e}this.saoPass&&(this.saoPass.enabled=e),this.enableRender()}}enableSsaoPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.ssaoPass){let e=new tl(this.scene,this.camera,this.width,this.height);e.kernelRadius=16,e.minDistance=.005,e.maxDistance=.1,this.composer.addPass(e),this.ssaoPass=e}this.ssaoPass&&(this.ssaoPass.enabled=e),this.enableRender()}}enableOutlinePass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.outlinePass){let e=new Gl(new Q(this.width,this.height),this.scene,this.camera);e.edgeStrength=3,e.edgeGlow=0,e.edgeThickness=2,e.pulsePeriod=0,e.visibleEdgeColor.set(16711680),e.hiddenEdgeColor.set(16752768),this.composer.addPass(e),this.outlinePass=e}this.outlinePass&&(this.outlinePass.enabled=e),this.enableRender()}}enableSsaaPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.ssaaRenderPass){let e=new xC(this.scene,this.camera,16777215,0);this.composer.addPass(e),this.ssaaRenderPass=e}this.ssaaRenderPass&&(this.ssaaRenderPass.enabled=e),this.enableRender()}}enableBloomPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.bloomPass){let e=new Xc(1,25,4);e.renderToScreen=!0,this.composer.addPass(e),this.bloomPass=e}this.bloomPass&&(this.bloomPass.enabled=e),this.enableRender()}}enableUnrealBloomPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.unrealBloomPass){let e=new lh(new Q(this.width,this.height),1,0,0);e.threshold=0,e.strength=.5,e.radius=0,this.composer.addPass(e),this.unrealBloomPass=e}this.unrealBloomPass&&(this.unrealBloomPass.enabled=e),this.enableRender()}}activateSection(e="ObjectsBoxSection",t){var n;!this.inputManager||null!=(n=this.sectionManager)&&n.isSectionActive()||(this.sectionType=e,this.clearSelection(),this.sectionManager||(this.sectionManager=new jA(this,this.inputManager)),this.sectionManager.activateSection(e,t),this.enableRender())}deactivateSection(){var e;null==(e=this.sectionManager)||e.deactivateSection(),this.enableRender()}setSectionClippingObjectIds(e){var t;null==(t=this.sectionManager)||t.setSectionClippingObjectIds(e),this.enableRender()}getActiveSection(){var e;return null==(e=this.sectionManager)?void 0:e.getActiveSection()}getMeasurementManager(){return this.measurementManager}getMeasurements(){return this.inputManager?(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.getMeasurementsData()):[]}activateMeasurement(e){this.inputManager&&(this.measurementManager||(this.measurementManager=new Hl(this,this.inputManager)),this.measurementManager.activateMeasurement(e),this.clearSelection())}deactivateMeasurement(){var e;null==(e=this.measurementManager)||e.deactivateMeasurement()}setMeasurementVisibility(e,t){return!!(this.inputManager&&this.measurementManager&&e)&&this.measurementManager.setMeasurementVisibility(e,t)}clearMeasurements(){var e;null==(e=this.measurementManager)||e.clearMeasurements()}zoomToRect(){this.zoomToRectHelper||(this.zoomToRectHelper=new s0(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new SC),this.webcamPlane||(this.webcamPlane=this.webcam.createWebCamPlane(),this.webcamPlane.position.set(10,2,0)),this.scene.add(this.webcamPlane))}disableWebCam(){this.scene&&this.webcamPlane&&(this.webcamPlane.geometry.dispose(),this.webcamPlane.material.dispose(),this.scene.remove(this.webcamPlane))}setEnvironment(e){Cl.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e)}))}setEnvironmentFromDataArray(e){Cl.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e)}))}takeObjectsScreenshot(e){return $e(this,null,(function*(){return new Promise(((t,n)=>{var i;this.renderer||n("renderer is undefined"),null==(i=this.scene)||i.traverse((t=>{t instanceof Ge&&((0,jd.includes)(e,(0,jd.get)(t.userData,"UniqueId"))?t.visible=!0:t.visible=!1)})),this.enableRender(),setTimeout((()=>{var e;t(null==(e=this.renderer)?void 0:e.domElement.toDataURL("image/png"))}),1e3)}))}))}setObjectColor(e,t){this.clearSelection();let n={};e.traverse((e=>{let t=e.material;t&&(Array.isArray(t)?t.forEach((e=>{n[e.id]=e})):n[t.id]=t)}));for(let i in n)yi.setMaterialColor(n[i],new Ie(t));this.enableRender()}updateRaycasterThreshold(){let e=this.camera;if(!e||!this.raycaster)return;let t=12/e.zoom,n=this.raycaster.params;n.Line?n.Line.threshold=t:n.Line={threshold:t},n.Points?n.Points.threshold=t:n.Points={threshold:t}}instantiate(e){new e0(e).instantiate()}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),gr.deepMerge(t,e)}finally{this.decreaseJobCount()}}updateProjectSettings(e){this.settings=e;let t=(e,t)=>{e&&t&&(e.near=t.near,e.far=t.far,e.updateProjectionMatrix())};t(this.perspectiveCamera,this.settings.camera),t(this.orthoCamera,this.settings.camera),this.enableRender(10)}computeBoundingBox(){let e=new lt;return Object.values(this.loadedModels).forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),Object.values(this.loaded3dTiles).forEach((t=>{t.bbox.isEmpty()||e.union(t.bbox)})),this.bbox=e,this.controls&&(this.controls.minDistance=.1,this.controls.maxDistance=3*this.bbox.getSize(new M).length()),e}},PC=wi(Ll(),1),dlt=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(dlt||{}),Jfe=class{constructor(e,t,n){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels={},this.clock=new Oo,this.viewerMode=0,this.raycaster=new Gs,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new lt,this.outlineMaterial=new Jt({color:1118481}),this.outlineRoot=new Nt,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,n)=>{if($.info(`[SimplifiedBimViewer] '${e}' is loaded, adding to scene...`),n.matrix&&16===n.matrix.length){let e=new Ae;e.elements=n.matrix,t.applyMatrix4(e)}else{let e=n.position||[0,0,0],i=n.rotation||[0,0,0],r=n.scale||[1,1,1];t.position.set(e[0],e[1],e[2]),t.rotation.set(i[0]*Math.PI/180,i[1]*Math.PI/180,i[2]*Math.PI/180),t.scale.set(r[0],r[1],r[2])}this.addLoadedModelToScene(t,n)},this.getMeshes=e=>{let t=[];return e instanceof Ge?t.push(e):e.traverseVisible((e=>{e instanceof Ge&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=n,1===this.viewerMode&&(e instanceof HTMLDivElement||!n))throw new Error("[SimplifiedBimViewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),$.info("[SimplifiedBimViewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new ii;return e.background=new Ie(7112861),e.matrixAutoUpdate=!0,e}isBrowserlessMode(){return 1===this.viewerMode}isBrowserMode(){return 0===this.viewerMode}initRenderer(){let e={antialias:!0,preserveDrawingBuffer:!0},t=this.isBrowserlessMode();t&&Object.assign(e,{canvas:this.containerOrCanvas,context:this.glContext});let n=new ms(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;$.info(`[SimplifiedBimViewer] Render target size: ${e} x ${t}`),this.renderTarget=new Sn(e,t,{minFilter:Vn,magFilter:cr,format:Ji,type:gc}),n.setRenderTarget(this.renderTarget)}else{let e=this.containerOrCanvas.clientWidth,t=this.containerOrCanvas.clientHeight;this.containerOrCanvas.append(n.domElement),n.setPixelRatio(window.devicePixelRatio),n.setSize(e,t)}n.outputColorSpace=St,n.toneMappingExposure=1,n.useLegacyLights=!1,n.setClearColor(11119017,1),n.shadowMap.enabled=!0,n.shadowMap.type=Kg,this.renderer=n,t||(this.pmremGenerator=new Hu(n),this.pmremGenerator.compileEquirectangularShader(),this.setEnvironmentFromDataArray())}initCamera(){if(!this.scene)return;let e=this.containerOrCanvas.clientWidth||this.containerOrCanvas.width||0,t=this.containerOrCanvas.clientHeight||this.containerOrCanvas.height||0,n=1;e&&t&&(n=e/t),this.camera=new bn(68,n,.05,1e4),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.scene.add(this.camera)}initControls(){if(!this.renderer)return;let e=this.camera;if(!e)return;let t=new ba(e,this.renderer.domElement);t.smoothTime=.5,t.enabled=!0,t.keyTruckSpeed=10,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.update(0),this.controls=t,t.addEventListener("update",(()=>{!this.isBrowserMode()&&this.renderer&&this.renderer.render(this.scene,e)}))}initLights(){if(!this.scene)return;let e=16777215,t=new ji(e,.3);t.position.set(-2,2,4);let n=new Lo(3158064),i=new ad(e,14540253,3);i.position.set(0,300,0),this.scene.add(t),this.scene.add(n),this.scene.add(i)}initPointerEvents(){if(!this.renderer||!this.camera||!this.controls)return;let e=!1,t=!1,n=-1,i=-1;this.renderer.domElement.addEventListener("pointerdown",(t=>{n=t.x,i=t.y,e=!1})),this.renderer.domElement.addEventListener("pointermove",(t=>{n>=0&&i>=0&&(Math.abs(t.x-n)>5||Math.abs(t.y-i)>5)&&(e=!0)})),this.renderer.domElement.addEventListener("pointerup",(()=>{t&&setTimeout((()=>{t=!1}),200),n=-1,i=-1})),this.renderer.domElement.addEventListener("dblclick",(n=>{t=!0,e||(this.handleMouseClick(n),this.flyToSelectedObject())}))}animate(){var e;this.isBrowserMode()&&requestAnimationFrame(this.animate.bind(this));let t=this.clock.getDelta();this.controls&&this.controls.update(t),this.scene&&this.camera&&(null==(e=this.renderer)||e.render(this.scene,this.camera))}destroy(){this.camera=void 0,this.scene&&this.scene.clear(),this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.containerOrCanvas.removeChild(this.renderer.domElement),this.renderer.clear(),this.renderer.dispose(),this.renderer=void 0),this.controls&&(this.controls.dispose(),this.controls=void 0),this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,Object.keys(this.loadedModels).forEach((e=>{delete this.loadedModels[e]}))}loadLocalModel(e,t,n){return $e(this,null,(function*(){let i=yield(new Ks).loadLocalModel(e,t.src,n);return i?(this.applyOptionsAndAddToScene(e,i,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return $e(this,null,(function*(){this.increaseJobCount();let n=yield(new Ks).loadModel(e.src,e.fileFormat,t);return n?(this.applyOptionsAndAddToScene(e.src,n,e),Promise.resolve()):Promise.reject()}))}parseGltf(e,t,n,i){this.increaseJobCount(),(new Ks).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),n&&n(e)}),(e=>{i&&i(e)}))}addLoadedModelToScene(e,t){if(!this.scene)return;e.updateMatrix(),e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let n=new cy(e);n.name="BIM_VIEWER_BOX_HELPER",n.visible=!1,n.material&&(n.material=void 0,n.layers.enableAll(),n.layers.disable(12));let i=t.modelId||t.src;if(this.loadedModels[i]){let e=1;for(;this.loadedModels[`${i}_${e}`];)e++;i=`${i}_${e}`,$.warn(`[BimViewer] Model '${i}' is loaded more than once!`)}this.loadedModels[i]={id:e.id,bbox:n},this.computeBoundingBox();let r=Object.values(this.loadedModels).map((e=>e.id));(!r||r.length<=1)&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),this.scene.add(n),t.edges&&cn.addOutlines(e),this.decreaseJobCount(),$.info(`[SimplifiedBimViewer] Added '${t.src}' to scene`)}addOrRemoveObjectOpacity(e=!0,t=.3,n,i){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[];Object.keys(this.loadedModels).forEach((s=>{let o=this.loadedModels[s];if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&cn.revertObjectOpacityById(r,o.id,this.savedMaterialsForOpacity);let e=cn.setObjectOpacityById(r,o.id,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&cn.revertObjectOpacityById(r,o.id,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[]}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}getIntersections(e){if(!this.raycaster||!this.camera||!this.scene)return[];let t=new Q;e&&(t=nn.getScreenPointByEvent(e,this.containerOrCanvas));let n=nn.screenPoint2NdcPoint(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return Object.values(this.loadedModels).forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.id);t&&t.visible&&i.push(t)})),this.raycaster.intersectObjects(i,!0)||[]}handleMouseClick(e){this.raycaster&&this.raycaster.layers.set(12);let t=this.getIntersections(e).find((e=>{let t=e.object;return t.visible&&(!1!==t.userData.selectable||t instanceof Ge)})),n=t&&t.object||void 0;n&&this.selectedObject&&this.selectedObject.id===n.id&&(n=void 0),n?this.selectObject(n):this.clearSelection()}selectObject(e){if(this.selectedObject){let e=this.selectedObject.userData;if(e.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof Rn&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=yi.clonedHighlightMaterials(e);t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t)}clearSelection(){this.selectObject()}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new M,n=new M,i=new lt;e.forEach((e=>{let t=Fr.getBoundingBox(e);i.union(t)}));let r=new M;this.camera.getWorldDirection(r),Ws.getCameraPositionByBboxAndDirection(i,t,n,this.camera.projectionMatrix,r),this.flyTo(t,n)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){this.selectedObject&&this.flyToObject(this.selectedObject)}flyTo(e,t,n){var i;let r=this.camera,a=this.controls;if(!r||!a)return;let s=e=Array.isArray(e)?new M(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new M(t[0],t[1],t[2]):t;$.info("[SimplifiedBimViewer] flyTo: ",it.vectorToString(s)),a.setPosition(s.x,s.y,s.z),a.setTarget(o.x,o.y,o.z),this.isBrowserMode()||null==(i=this.renderer)||i.render(this.scene,r),n&&n()}goToHomeView(){var e;let t=new M,n=new M,i=new M,r=new M;this.bbox.getSize(r),this.bbox.getCenter(i);let a=(r.x+r.y+r.z)/3*1.5,s=new M(i.x+a,i.y+a/1.5,i.z+a),o=i.clone().sub(s);Ws.getCameraPositionByBboxAndDirection(this.bbox,t,n,null==(e=this.camera)?void 0:e.projectionMatrix,o),t.equals(n)||this.flyTo(t,n)}setEnvironmentFromDataArray(e){Cl.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene.environment=e,this.isBrowserMode()||this.animate()}))}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||i<h){let t=e=>it.numberToString(e);$.info(`[SimplifiedBimViewer] BBox's longest side is: ${t(o)}`),n>l&&($.warn(`[SimplifiedBimViewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i<h&&($.warn(`[SimplifiedBimViewer] camera.far(${t(i)}) shouldn't smaller than ${t(h)}, will change it!`),e.far=h)}e.updateProjectionMatrix()}isolateObjects(e){let t=this.transparentObjectIds.length>0?void 0:this.transparentObjectIds,n=this.transparentObjectIds.length>0?this.transparentObjectIds:void 0,i=new Pt({color:16777215,transparent:!0,opacity:.1});Object.keys(this.loadedModels).forEach((e=>{let r=this.loadedModels[e];cn.applyMaterialToObjectById(this.scene,r.id,i,n,t)})),this.outlineRoot.clear();let r=[];if(e.forEach((e=>{let t=e.modelId,n=t?this.scene.getObjectById(this.loadedModels[t].id):this.scene;n||($.warn(`[BimViewer] The ModelId of ${t} has no corresponding model.`),n=this.scene),n.traverse((t=>{if((0,PC.includes)(e.id,(0,PC.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=cn.createOutline(e.geometry,this.outlineMaterial);t.applyMatrix4(e.matrixWorld),this.outlineRoot.add(t),t.updateWorldMatrix(!0,!1)}));let e=r.map((e=>e.id));Object.keys(this.loadedModels).forEach((t=>{let n=this.loadedModels[t];cn.revertAppliedMaterialToObjectById(this.scene,n.id,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else $.warn(`[BimViewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new lt;return Object.values(this.loadedModels).forEach((t=>{if(t.bbox){t.bbox.geometry.computeBoundingBox();let n=t.bbox.geometry.boundingBox;n&&!n.isEmpty()&&e.union(n)}})),this.bbox=e,e}getContext(){var e;return null==(e=this.renderer)?void 0:e.getContext()}getCameraDirection(){var e;let t=new M;return null==(e=this.camera)||e.getWorldDirection(t),{x:t.x,y:t.y,z:t.z}}setFov(e){this.camera&&(this.camera.fov=e,this.camera.updateProjectionMatrix())}},Qfe=wi(Ll(),1),Xd=class extends Nt{constructor(e,t,n=10){super(),this.images=e,this.thumbnailImages=t,this.size=n,this.textureLoader=new Ai,this.mesh=new Ge}fadeIn(e=1e3){let t=this.getMaterials();if(!(Array.isArray(t)&&t.length>0))return void(this.visible=!0);t.forEach((e=>e.opacity=0));let n=1/(e/10);this.visible=!0,this.clearFading(),this.renderOrder+=1,this.fadingInInterval=setInterval((()=>{let e=1,i=this.getMaterials();this.materialEquals(t,i)||(t=i),t.length>0&&(e=Math.min(t[0].opacity+n,1),t.forEach((t=>t.opacity=e))),e>=1&&this.clearFading()}),10)}materialEquals(e,t){return Qfe.default.isEqualWith(e,t,((e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return e.id===t.id}))}fadeOut(e=1e3){let t=this.getMaterials(),n=1/(e/10),i=1/(e/10);this.clearFading(),this.scale.set(2,2,2),this.fadingOutInterval=setInterval((()=>{let e=this.scale.x+i;this.scale.set(e,e,e);let r=0;t.length>0&&(r=Math.max(t[0].opacity-n,0),t.forEach((e=>e.opacity=r))),(r<=0||e>=3)&&this.clearFading()}),10)}clearFading(){let e=this.getMaterials();this.fadingInInterval&&(clearInterval(this.fadingInInterval),this.fadingInInterval=void 0,this.visible=!0,e.forEach((e=>e.opacity=1)),this.renderOrder-=1),this.fadingOutInterval&&(clearInterval(this.fadingOutInterval),this.fadingOutInterval=void 0,this.visible=!1,e.forEach((e=>e.opacity=1)),this.scale.set(1,1,1))}getMaterials(){let e=this.thumbnailMesh;e||(e=this.mesh);let t=[];return Array.isArray(e.material)?t.push(...e.material):e.material&&t.push(e.material),t}create(){}createThumbnailMesh(e){return $e(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new Ge(new Qi(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new Pt({map:e,side:Tr,transparent:!0})));this.thumbnailMesh&&(this.thumbnailMesh.material=t,this.add(this.thumbnailMesh))}))}loadTextures(e){return e.map((e=>this.textureLoader.load(e)))}loadTexturesAsync(e){return $e(this,null,(function*(){let t=e.map((e=>this.textureLoader.loadAsync(e)));return yield Promise.all(t)}))}destroyMesh(e){var t;this.remove(e),e.clear(),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((e=>{var t;null==(t=e.map)||t.dispose(),e.dispose()})):(null==(t=e.material.map)||t.dispose(),e.material.dispose())}destroy(){this.clearFading(),this.images=[],this.mesh&&(this.mesh instanceof Ge?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof Ge&&this.destroyMesh(e)})),this.mesh=void 0)}},IC=class extends Xd{constructor(e,t,n=200){if(super(e,t,n),6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`)}create(){return $e(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return $e(this,null,(function*(){let e=this.mesh;e.geometry=new Qi(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new Pt({map:e,side:Tr,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},DC=class extends Xd{constructor(e,t,n=200){if(super(e,t,n),24!==e.length)throw new Error(`[VRCube24Faces] Wrong number of images! Expected 24, got ${e.length}`);this.ratio=1,this.subPlaneWidth0=this.size*(this.ratio/(this.ratio+1)),this.subPlaneWidth1=this.size-this.subPlaneWidth0}create(){return $e(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return $e(this,null,(function*(){var e;this.mesh=new Nt,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new Pt({map:e,side:ri,transparent:!0})));if(24!==t.length)throw new Error(`[VRCube24Faces] Wrong number of materials! Expected 24, got ${t.length}`);let n=this.createPlaneOfAFace(t.slice(0,4));n.rotateOnAxis(new M(0,1,0),-Math.PI/2),n.position.set(this.size/2,0,0);let i=this.createPlaneOfAFace(t.slice(4,8));i.rotateOnAxis(new M(0,1,0),Math.PI/2),i.position.set(-this.size/2,0,0);let r=this.createPlaneOfAFace(t.slice(8,12));r.rotateOnAxis(new M(1,0,0),-Math.PI/2),r.rotateOnAxis(new M(0,0,1),Math.PI),r.rotateOnAxis(new M(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new M(1,0,0),Math.PI/2),a.rotateOnAxis(new M(0,0,1),Math.PI),a.rotateOnAxis(new M(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new M(0,1,0),Math.PI),s.position.set(0,0,this.size/2),this.createPlaneOfAFace(t.slice(20,24)).position.set(0,0,-this.size/2),this.add(this.mesh),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}createPlaneOfAFace(e){var t;let n=new Nt,i=new Ur(this.subPlaneWidth0,this.subPlaneWidth0),r=new Ur(this.subPlaneWidth1,this.subPlaneWidth0),a=new Ur(this.subPlaneWidth0,this.subPlaneWidth1),s=new Ur(this.subPlaneWidth1,this.subPlaneWidth1),o=new Ge(i,e[0]),l=new Ge(r,e[1]),h=new Ge(a,e[2]),c=new Ge(s,e[3]);return o.position.set(this.subPlaneWidth1/2,this.subPlaneWidth1/2,0),l.position.set(-this.subPlaneWidth0/2,this.subPlaneWidth1/2,0),h.position.set(this.subPlaneWidth1/2,-this.subPlaneWidth0/2,0),c.position.set(-this.subPlaneWidth0/2,-this.subPlaneWidth0/2,0),o.geometry.scale(-1,1,1),l.geometry.scale(-1,1,1),h.geometry.scale(-1,1,1),c.geometry.scale(-1,1,1),n.add(o,l,h,c),null==(t=this.mesh)||t.add(n),n}},LC=class extends Xd{constructor(e,t,n=100){if(super(e,t,n),1!==e.length)throw new Error(`[VRSphere] Wrong number of images! Expected 1, got ${e.length}`)}create(){return $e(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return $e(this,null,(function*(){var e;let t=this.mesh;t.geometry=new da(this.size,100,100),t.geometry.scale(-1,1,1);let n=(yield this.loadTexturesAsync(this.images)).map((e=>new Pt({map:e,side:Tr,transparent:!0})));t.material=n[0],this.add(t),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}},epe=class extends Hd{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels={},this.minFov=50,this.maxFov=95,this.raycaster=new Gs,this.autoRotate=!0,this.events=[],this.lastFrameExecuteTime=Date.now(),this.maxFps=60,this.isMousePressing=!1,this.settings=Ev,this.viewpoints=[],this.previousViewpointId="",this.previousPanoramaId="",this.activeViewpointId="",this.activePanoramaId="",this.viewpointAssetsMap=new Map,this.loadingPanos=[],this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onMouseWheel=e=>{let t=e.wheelDelta>0?-5:5;this.updateFov(t)},this.applyOptionsAndAddToScene=(e,t,n)=>{if($.info(`[VRViewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now(),n.matrix&&16===n.matrix.length){let e=new Ae;e.elements=n.matrix,t.applyMatrix4(e)}else{let e=n.position||[0,0,0],i=n.rotation||[0,0,0],r=n.scale||[1,1,1];t.position.set(e[0],e[1],e[2]),t.rotation.set(i[0]*Math.PI/180,i[1]*Math.PI/180,i[2]*Math.PI/180),t.scale.set(r[0],r[1],r[2])}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())}));let i=n.instantiate,r=n.merge;i?setTimeout((()=>{this.instantiate(t),setTimeout((()=>{r&&this.merge(t),this.addLoadedModelToScene(t,n)}),0)}),0):r?setTimeout((()=>{this.merge(t),setTimeout((()=>this.addLoadedModelToScene(t,n)),0)}),0):this.addLoadedModelToScene(t,n)},this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=Ev,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){let e=this.viewerCfg;this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initEvents(),this.initOthers(),!0===e.enableAxisGizmo&&(this.axes=this.initAxes()),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&(this.bottomBar=this.initBottomBar())}initScene(){let e=new ii;e.background=new Ie(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new ms({antialias:!1,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.useLegacyLights=!1,this.css2dRenderer=new Rc,this.css2dRenderer.setSize(this.width,this.height),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement),null==(t=this.viewerContainer)||t.appendChild(this.css2dRenderer.domElement)}initCamera(){this.scene&&(this.camera=new bn(75,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.scene.add(this.camera))}initControls(){if(!this.renderer||!this.camera)return;let e=this.camera,t=this.viewerCfg,n=new pR(e,this.renderer.domElement,!0);n.enabled=!0,n.autoRotate=this.autoRotate,n.autoRotateSpeed=t.autoRotateSpeed||-2,n.enablePan=!1,n.enableZoom=!1,n.enableRotate=!0,n.rotateSpeed=.3,n.minPolarAngle=.05*Math.PI,n.maxPolarAngle=.95*Math.PI,n.listenToKeyEvents(document.body),n.update(),this.controls=n,this.controlsHelper=new lA(e,n),this.controls.controlsHelper=this.controlsHelper,this.autoRotate&&this.controlsHelper.delayAutoRotate(),this.controlsHelper.automaticallyAdjustCameraPosition=!1,this.controls.addEventListener("end",(()=>{this.handleDragEnd&&this.handleDragEnd()}));let i=new M(0,0,0),r=new M(10,0,0);this.setCameraPositionAndDirection(i,r)}onKeyDown(e){return t=>{var n,i;let r=e.camera,a=e.controls;!r||!a||(("ArrowLeft"===t.code||"ArrowRight"===t.code||"ArrowUp"===t.code||"ArrowDown"===t.code)&&(null==(n=this.controlsHelper)||n.startToRotate(t)),null==(i=this.controlsHelper)||i.delayAutoRotate())}}initLights(){if(!this.scene)return;let e=new ji(16777215,.3);e.position.set(-2,2,4),this.scene.add(e)}initEvents(){let e=this.renderer,t=this.camera;if(!e||!t)return;let n=!1,i=-1,r=-1;this.addEvent(window,"keydown",this.onKeyDown(this)),this.addEvent(window,"resize",this.onResize),this.addEvent(window,"mousewheel",this.onMouseWheel),this.addEvent(window,"pointerdown",(t=>{var a;i=t.x,r=t.y,n=!1,this.isMousePressing=!0,this.autoRotate&&(null==(a=this.controlsHelper)||a.delayAutoRotate()),t.button===fS.LEFT&&t.target instanceof HTMLCanvasElement&&(e.domElement.style.cursor="move")})),this.addEvent(window,"pointermove",(e=>{i>=0&&r>=0&&(Math.abs(e.x-i)>5||Math.abs(e.y-r)>5)&&(n=!0)})),this.addEvent(window,"pointerup",(i=>{var r,a;if(this.isMousePressing=!1,this.autoRotate&&(null==(r=this.controlsHelper)||r.delayAutoRotate()),e.domElement.style.cursor="auto",!n&&i.button===fS.LEFT)if(i.target&&i.target instanceof HTMLDivElement){let e=Ac.tryFindObjectId(i.target);if(e){let t=null==(a=this.scene)?void 0:a.getObjectById(e);if(t){let e=t.userData.hotpoint;e&&($.info("[VRViewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(i);if(e){let n=e=>it.vectorToString(e),i=e.point,r=i.clone().sub(t.position).normalize();$.info(`[VRViewer] Clicked at: ${n(i)},\n Camera position: ${n(t.position)},\n Target direction: ${n(r)}`)}}}))}initOthers(){!this.controls||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initAxes(){var e;let t=document.createElement("div");t.classList.add("axesRenderer");let n=new vd(t,this.camera);return null==(e=this.widgetContainer)||e.append(t),n}initToolbar(){let e=this.viewerCfg;return new Gc(this,yn(yn({},Wde),e.toolbarMenuConfig),[["SceneClear"]])}initBottomBar(){return new kd(this)}animate(){var e,t,n;if(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.maxFps>0){let e=Date.now()-this.lastFrameExecuteTime;if(e<1e3/this.maxFps)return;if(this.lastFrameExecuteTime=Date.now(),this.autoRotate){let t=this.controlsHelper;t&&t.autoRotateRemainingTime>0&&!this.isMousePressing&&(t.autoRotateRemainingTime-=e,t.autoRotateRemainingTime<=0&&this.controls&&t.startAutoRotate())}}this.controls&&this.controls.update(),this.scene&&this.camera&&(null==(e=this.renderer)||e.render(this.scene,this.camera),null==(t=this.css2dRenderer)||t.render(this.scene,this.camera),null==(n=this.css3dRenderer)||n.render(this.scene,this.camera))}clearAllCachedPanoramas(){this.handleCameraUpdateInterval(),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.viewpointAssetsMap.forEach((e=>{var t;let n=e.panoramas;for(let i=n.length-1;i>=0;--i){let e=n[i];e.box.destroy(),null==(t=this.scene)||t.remove(e.box)}})),this.loadingPanos=[],this.viewpointAssetsMap.clear(),this.activePanoramaId="",this.activePanoramaId="",this.previousViewpointId="",this.previousPanoramaId=""}destroy(){var e,t,n;this.events.forEach((e=>e.node.removeEventListener(e.type,e.func))),this.events=[],this.clearAllCachedPanoramas(),this.css2dRenderer&&(null==(e=this.viewerContainer)||e.removeChild(this.css2dRenderer.domElement)),null==(t=this.axes)||t.dispose(),null==(n=this.toolbar)||n.destroy(),super.destroy()}updateFov(e){var t;let n=this.camera;if(!n)return;let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix())},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}setMinAndMaxFov(e,t){let n=this.controls;n&&(this.minFov=e,this.maxFov=t,n.minFov=e,n.maxFov=t)}resize(e,t){var n,i,r;let a=this.camera;a&&(this.width=e||window.innerWidth,this.height=t||window.innerHeight,a.aspect=this.width/this.height,a.updateProjectionMatrix(),null==(n=this.renderer)||n.setSize(this.width,this.height),null==(i=this.css2dRenderer)||i.setSize(this.width,this.height),null==(r=this.css3dRenderer)||r.setSize(this.width,this.height)),this.width=e,this.height=t}enableAutoRotate(e){this.controls&&(this.autoRotate=e,this.controls.autoRotate=e)}setAutoRotateSpeed(e=1){this.controls&&(this.controls.autoRotateSpeed=e)}setCameraFov(e=75){let t=this.camera;t&&(t.fov=e,t.updateProjectionMatrix())}addEvent(e,t,n){e.addEventListener(t,n),this.events.push({node:e,type:t,func:n})}setCameraPositionAndDirection(e,t,n){let i,r,a=this.camera,s=this.controls;if(!a||!s)return;i=t?Array.isArray(t)?new M(t[0],t[1],t[2]):new M(t.x,t.y,t.z):s.target.clone().sub(a.position),i.normalize(),r=Array.isArray(e)?new M(e[0],e[1],e[2]):new M(e.x,e.y,e.z);let o=r.clone().addScaledVector(i,.01);this.fianlCameraPosition=r,this.finalCameraTarget=o;let l=(e,t)=>{a.position.set(e.x,e.y,e.z),s.target.set(t.x,t.y,t.z),s.update()};if(!1===n)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void l(r,o);let h=a.position.clone(),c=s.target.clone(),u=500,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let e=Date.now()-d;e>u&&(e=u);let t=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new M(i,r,a)},n=t(h,r,e/u),i=t(c,o,e/u);l(n,i),e>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,n=new M;return e.getWorldDirection(n),{position:{x:t.x,y:t.y,z:t.z},direction:{x:n.x,y:n.y,z:n.z}}}getCameraFov(){let e=this.camera;if(e)return e.fov}setViewpoints(e){this.handleCameraUpdateInterval(),this.viewpointAssetsMap.size>0&&(this.viewpointAssetsMap.forEach((e=>{let t=e.panoramas,n=e.css2dObjects;t.forEach((e=>{var t;e.box.destroy(),null==(t=this.scene)||t.remove(e.box)})),n.forEach((e=>{var t;null==(t=this.scene)||t.remove(e)}))})),this.viewpointAssetsMap.clear()),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.loadingPanos=[],this.previousViewpointId="",this.previousPanoramaId="",this.activeViewpointId="",this.activePanoramaId="",this.viewpoints=e}loadModel(e,t){return $e(this,null,(function*(){this.timer=Date.now(),this.increaseJobCount();try{let n=yield(new Ks).loadModel(e.src,e.fileFormat,t);if(n)return this.applyOptionsAndAddToScene(e.src,n,e),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return $.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount()}return Promise.reject()}))}setModelVisibility(e,t){var n;let i=this.loadedModels[e],r=null==(n=this.scene)?void 0:n.getObjectById(i.id);if(!r)throw new Error(`Failed to find model by modelId '${e}'!`);r.visible=t,this.enableRender()}addLoadedModelToScene(e,t){if(!this.scene)return;if(t.merge){let t=Date.now();Bd.createMeshBvhAsync([e],{saveOriginalIndex:!0}),$.info(`[VRViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let n=(new lt).setFromObject(e),i=t.modelId||t.src;if(this.loadedModels[i]){let e=1;for(;this.loadedModels[`${i}_${e}`];)e++;i=`${i}_${e}`,$.warn(`[VRViewer] Model '${i}' is loaded more than once!`)}this.loadedModels[i]={id:e.id,bbox:n},t.edges&&cn.addOutlines(e),$.info(`[VRViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.enableRender(),this.dispatchEvent("ModelLoaded")}addPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(!n)throw new Error(`[VRViewer] Failed to find viewpoint by id '${e}'`);n.panoramas||(n.panoramas=[]),n.panoramas.push(t)}findPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(n&&n.panoramas)return n.panoramas.find((e=>e.id===t))}setHotpointsVisibility(e,t="",n=[]){if(!this.viewpoints)return;let i=t=>{var i;let r=this.viewpointAssetsMap.get(t.id),a=(null==r?void 0:r.css2dObjects)||[];null==(i=t.hotpoints)||i.forEach((i=>{if(n&&n.length>0){if(-1===n.findIndex((e=>e===i.hotpointId)))return;if(i.visible=e,this.activeViewpointId===t.id){let t=a.find((e=>e.userData.hotpoint.hotpointId===i.hotpointId));t&&(t.visible=e)}}else i.visible=e,this.activeViewpointId===t.id&&a.forEach((t=>t.visible=e))}))};if(t){let e=this.viewpoints.find((e=>e.id===t));e&&i(e)}else this.viewpoints.forEach((e=>i(e)))}addHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||(t.hotpoints||(t.hotpoints=[]),e.forEach((e=>{var i,r;if(-1!==(null==(i=t.hotpoints)?void 0:i.findIndex((t=>t.hotpointId===e.hotpointId))))return void $.warn(`[VRViewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=Ac.createHotpoint(e.html),l=new M(s[0],s[1],s[2]),h=new M(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(o,l,h),o.visible=!1!==e.visible,o.userData.hotpoint=e,n.css2dObjects.push(o),null==(r=this.scene)||r.add(o),t.hotpoints.push(e)})))}removeHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||e.forEach((e=>{var i,r;if(t.hotpoints)for(let n=t.hotpoints.length-1;n>=0;--n)e===t.hotpoints[n].hotpointId&&t.hotpoints.splice(n,1);for(let t=n.css2dObjects.length-1;t>=0;--t){let a=n.css2dObjects[t];e===(null==(i=a.userData.hotpoint)?void 0:i.hotpointId)&&(n.css2dObjects.splice(t,1),null==(r=this.scene)||r.remove(a))}}))}activeViewpointById(e,t,n,i){this.activatePanoramaById(e,"",!0,t,n,i)}activatePanoramaById(e,t,n=!0,i,r,a){if(e===this.activeViewpointId&&t===this.activePanoramaId)return;let s=this.viewpoints.find((t=>t.id===e));s&&this.activatePanorama(s,t,n,i,r,a)}removeCachedPanoramas(){this.viewpointAssetsMap.forEach(((e,t)=>{var n;let i=e.panoramas;for(let r=i.length-1;r>=0;--r){let e=i[r];if(t===this.activeViewpointId&&e.id===this.activePanoramaId||t===this.previousViewpointId&&e.id===this.previousPanoramaId)return;e.box.destroy(),null==(n=this.scene)||n.remove(e.box),i.splice(r,1)}}))}unlimitControlsAndShowAssets(e=!1){if(this.controls){let e=this.controls;e.enablePan=!0,e.enableZoom=!0}this.viewpointAssetsMap.forEach((t=>{t.panoramas.forEach((e=>{e.box.visible=!0})),e&&t.css2dObjects.forEach((e=>{e.visible=!0}))}))}relocateAnchorIfTooCloseToCamera(e,t,n){let i=this.camera;if(!i)return $.error("[VRViewer] Camera is not initialized"),void e.position.set(t.x,t.y,t.z);let r,a=Math.abs(t.distanceTo(n));if(a<i.near){let e=t.clone().sub(n).normalize();r=n.clone().add(e.multiplyScalar(a+1))}else r=t;e.position.set(r.x,r.y,r.z)}activatePanorama(e,t,n=!0,i,r,a){return $e(this,null,(function*(){var s,o,l;let h=(e,t,n)=>{let i=e.panoramas.find((e=>e.id===t)),r=null==i?void 0:i.box;r&&(n?this.fadeIn(r):this.fadeOut(r))},c=(e,t)=>{e.css2dObjects.forEach((e=>{t?!1!==e.userData.hotpoint.visible&&(e.visible=t):e.visible=t}))},u=()=>{var t;let r=new M(0,0,0),a=new M(1,0,0),s=null==(t=this.getCameraPositionAndDirection())?void 0:t.direction;s&&a.set(s.x,s.y,s.z);let o=e.position;if(o&&3===o.length&&r.set(o[0],o[1],o[2]),n){let t=e.initialDirection;t&&3===t.length&&a.set(t[0],t[1],t[2])}this.setCameraPositionAndDirection(r,a,i)};!t&&(null==(s=e.panoramas)?void 0:s.length)>0&&(t=e.panoramas[0].id||""),this.handleCameraUpdateInterval();let d=this.viewpointAssetsMap.get(this.activeViewpointId),p=this.viewpointAssetsMap.get(e.id);if(this.activeViewpointId&&d&&(this.activeViewpointId!==e.id&&c(d,!1),h(d,this.activePanoramaId,!1)),p&&p.panoramas.find((e=>e.id===t)))return h(p,t,!0),this.activeViewpointId!==e.id&&c(p,!0),this.activeViewpointId!==e.id&&u(),this.activeViewpointId=e.id,this.activePanoramaId=t,void(r&&r(e));this.previousViewpointId=this.activeViewpointId,this.previousPanoramaId=this.activePanoramaId,this.activeViewpointId=e.id,this.activePanoramaId=t;try{if(this.loadingPanos.some((n=>n.viewpointId===e.id&&n.panoramaId===t)))return void $.warn(`[VRViewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let n=new GS(this.createBoxByImageOrImages(e,t));this.loadingPanos.push({viewpointId:e.id,panoramaId:t,creationPromise:n});let i=yield n.promise;this.loadingPanos=this.loadingPanos.filter((n=>n.viewpointId!==e.id||n.panoramaId!==t));let a=e.position;a&&3===a.length&&i.position.set(a[0],a[1],a[2]),this.activeViewpointId===e.id&&this.activePanoramaId===t?(this.fadeIn(i),null==(o=this.scene)||o.add(i),u()):(i.visible=!1,null==(l=this.scene)||l.add(i));let s={id:t,box:i},h=this.viewpointAssetsMap.get(e.id);if(h)h.panoramas.push(s),c(h,!0);else{let n=[];e.hotpoints&&e.hotpoints.forEach((r=>{let a=r.anchorPosition,s=Ac.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new M(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(s,o,i.position),(this.activeViewpointId!==e.id||this.activePanoramaId!==t)&&(s.visible=!1),n.push(s)}));let r={panoramas:[s],css2dObjects:n};this.viewpointAssetsMap.set(e.id,r),n.forEach((e=>{var t;return null==(t=this.scene)?void 0:t.add(e)}))}r&&r(e)}catch(e){"cancel"!==e.type&&a&&a(e)}}))}createBoxByImageOrImages(e,t){var n;let i=e.imageOrImages,r=e.thumbnailImages;if((null==(n=e.panoramas)?void 0:n.length)>0){let n=this.findPanorama(e.id,t);n||(n=e.panoramas[0],$.warn(`[VRViewer] Failed to find panorama by id '${t}', will use the first one`)),i=n.images,r=n.thumbnails}if(!i)throw new Error("[VRViewer] Invalid images!");if(Array.isArray(i)||(i=[i]),1===i.length)return this.createBoxByImage(i,r);if(6===i.length)return this.createBoxBy6Images(i,r);if(24===i.length)return this.createBoxBy24Images(i,r);throw new Error(`[VRViewer] Wrong number of images! Expected 1/6/24, got ${i.length}`)}createBoxByImage(e,t){return $e(this,null,(function*(){let n=new LC(e,t);return yield n.create(),n}))}createBoxBy6Images(e,t){return $e(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let n=new IC(e,t);return yield n.create(),n}))}createBoxBy24Images(e,t){return $e(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let n=new DC(e,t);return yield n.create(),n}))}getIntersection(e){if(!this.camera||!this.scene)return;let t=this.viewpointAssetsMap.get(this.activeViewpointId);if(!t)return;let n=t.panoramas.find((e=>e.id===this.activePanoramaId));if(!n)return;let i=n.box,r=this.viewerContainer,a=new Q;e&&(a=nn.getScreenPointByEvent(e,r));let s=nn.screenPoint2NdcPoint(a,this.camera,r);this.raycaster.setFromCamera(s,this.camera);let o=[i],l=this.raycaster.intersectObjects(o,!0)||[];return l.length>0?l.find((e=>{let t=e.object;return t.visible&&t instanceof Ge})):void 0}fadeIn(e,t=500){e.fadeIn(t)}fadeOut(e,t=1e3){e.fadeOut(t)}handleCameraUpdateInterval(){if(this.cameraUpdateInterval){clearInterval(this.cameraUpdateInterval);let e=this.fianlCameraPosition,t=this.finalCameraTarget;if(e&&t&&this.controls&&this.camera){this.camera.position.set(e.x,e.y,e.z);let n=this.controls;n.target.set(t.x,t.y,t.z),n.update()}this.cameraUpdateInterval=void 0}this.fianlCameraPosition=void 0,this.finalCameraTarget=void 0}getHitResult(e){let t={location:null};if(!this.camera)return t;let n=this.getIntersection(e);return t.location=n?{x:n.point.x,y:n.point.y,z:n.point.z}:null,t}lookToPosition(e){var t;if(!this.camera)return;this.handleCameraUpdateInterval();let n=new M(e[0],e[1],e[2]).clone().sub(this.camera.position);null==(t=this.controlsHelper)||t.lookTo(n)}instantiate(e){new e0(e).instantiate()}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),gr.deepMerge(t,e)}finally{this.decreaseJobCount()}}};export{NTt as AXIS_SECTION_PLANE_CONTROL_ID,OTt as AXIS_SECTION_PLANE_ID,oA as AngleMeasurement,k5 as AnnotationTable,IA as AreaMeasurement,YF as ArrowMarkup,iA as AxisPlaneSection,pde as AxisType,d5 as BYBLOCK,wR as BYLAYER,qc as BaseMeasurement,Ld as BaseSection,Bc as BaseTable,Xd as BaseVRMesh,Hd as BaseViewer,Kfe as BimViewer,wd as BinaryReader,Vp as BitView,Fd as BoxSelectHelper,Ac as CSS2DObjectUtils,ba as CameraControlsEx,GS as CancelablePromise,$t as CanvasRender,$F as CircleMarkup,Il as CloudLineMarkup,ZF as CloudRectMarkup,it as CommonUtils,Dp as CompareDrawable,lA as ControlsHelper,yv as CoordinateAxes,vd as CoordinateAxesViewport,nn as CoordinateConversionUtils,DA as CoordinateMeasurement,Ay as CreateEdgesGeometryWorker,qde as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,Xde as DEFAULT_BIM_VIEWER_CONFIG,jde as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,cde as DEFAULT_MARKUP_TOOLBAR_CONFIG,GR as DEFAULT_SIZE,Wde as DEFAULT_VRVIEWER_TOOLBAR_CONFIG,tn as DeviceUtils,LA as DistanceMeasurement,KF as DotMarkup,ns as Drawable,Pl as DrawableList,b5 as DxfChangeType,Zr as DxfCompare,Qde as DxfCompareHelper,Vhe as DxfCompareMarkupManager,Wv as DxfDataTable,Dt as DxfLoader,Up as DxfParser,cue as DxfRenderOrder,$E as DxfViewer,LTt as ENTER_KEY,DTt as ESC_KEY,JF as EllipseMarkup,Xi as Event,Uy as Exploder,bp as ExportUtils,Fc as FontDataTable,XS as FpsUtils,uce as GROUND_PLANE_RENDER_ORDER,lde as GROUP_CONFIG,JS as GenerateMeshBvhWorker,xt as GeometryUtils,vs as GroundUtils,Tv as ICON_FONT_CLASS,KE as IUploader,Ei as IndexedDbManager,Rp as InputManager,e0 as InstantiateHelper,PTt as KEYDOWN_EVENT,ITt as KEYUP_EVENT,git as Keys,e5 as LeaderLineMarkup,kR as LinePatternShaders,Ks as LoadingHelper,ife as LocalDxfUploader,sfe as LocalImageUploader,kA as LocalModelUploader,IF as MOUSEDOWN_EVENT,yd as MOUSEMOVE_EVENT,PF as MOUSEUP_EVENT,Gy as MarkupManager,nA as MarkupToolbar,js as MarkupType,yi as MaterialUtils,wt as MathUtils,Hl as MeasurementManager,$o as MeasurementType,tA as MenuTypeEnums,gr as MergeUtils,Bd as MeshBvhHelper,PA as MobileTouchHelperDrawable,zA as NavCube,GA as NavCubeViewport,Lp as NestCompareTypes,RA as OSnapHelper,Xce as OSnapMarkerType,not as OSnapType,Gde as ObjectPixelSizeHelper,cn as ObjectUtils,qA as ObjectsBoxSection,nfe as Offset,Rhe as Orientation,AA as PickMarkupHelper,WA as PickPlaneSection,bd as PolygonUtils,t5 as PolylineMarkup,t0 as RafHelper,n5 as RectMarkup,FTt as SECTION_BOX_ID,BTt as SECTION_PLANE_CONTROL_ID,UTt as SECTION_PLANE_ID,DF as SECTION_PLANE_NAME,zde as SHP,MA as SHPLoader,TA as SHPParser,oVt as SIMPLE_BIM_VIEWER_CONFIG,Kwt as SNAP_ICON_SIZE,mit as STATE,Dle as SVGObject,jce as SVGObjectUtils,Lle as SVGRenderer,Fr as SceneUtils,hce as ScreenshotMode,jA as SectionManager,wv as SectionType,Ic as SectionUtils,wA as ShpThree,to as ShxFont,no as ShxFontLoader,Hp as ShxFontType,Jfe as SimplifiedBimViewer,Wce as SimplifyUtils,Ka as SkyboxUtils,bs as SnapDrawable,QF as TextMarkup,Cl as TextureUtils,Gc as Toolbar,eH as ToolbarMenu,BE as ToolbarMenuId,F5 as Units,pR as VRControls,IC as VRCube,DC as VRCube24Faces,LC as VRSphere,epe as VRViewer,Ws as Viewer3DUtils,Ja as ViewerEvent,dlt as ViewerMode,i0 as ViewerName,V5 as ViewpointTable,XF as Views,SC as WebCam,r5 as XMarkup,s0 as ZoomToRectHelper,B5 as bspline,She as checkIsNewVersion,fce as cn,The as createHatchPatternShaderMaterial,bst as decodeDxfTextCharacterCodes,Tst as decodeDxfTextMbcsCharacterCodes,_st as decodeDxfTextUnicodeCodePoints,dce as en,sMt as getLengthValueByUnit,By as getUnitStr,wst as getVersionFromLocalStorage,Pc as layerForHitableObjects,$r as layerForSelectableObjects,ya as layerForSnapableObjects,$ as log,mr as matrixAutoUpdate,VR as parseDxfMTextContent,zR as parseDxfTextContent,N5 as round10,CTt as sceneAutoUpdate,WS as setIcon,kle as setLogLevel,Mst as setVersionToLocalStorage,Cc as showPrecisionValue,Yce as unitConversionByMeter,cit as unitLabel,H5 as unitScaleConversion,whe as unitScaleToMeter};